TP_JO2024/home/dist/scheme/scheme.module.min.js.map
2024-03-27 17:19:37 +01:00

1 line
No EOL
11 KiB
Text

{"version":3,"file":"scheme.module.min.js","sources":["../../.config/config.js","../../src/core/api.js","../../src/scheme/script/scheme/scheme-value.js","../../src/scheme/script/scheme/scheme-attribute.js","../../src/scheme/script/scheme/scheme-theme.js","../../src/scheme/script/scheme/scheme-emission.js","../../src/scheme/script/scheme/scheme-event.js","../../src/scheme/script/scheme/scheme.js","../../src/scheme/script/scheme/scheme-selector.js","../../src/scheme/index.js","../../src/scheme/main.js"],"sourcesContent":["const config = {\r\n prefix: 'fr',\r\n namespace: 'dsfr',\r\n organisation: '@gouvfr',\r\n version: '1.11.2'\r\n};\r\n\r\nexport default config;\r\n","import config from './config.js';\nconst api = window[config.namespace];\nexport default api;\n","export const SchemeValue = {\n SYSTEM: 'system',\n LIGHT: 'light',\n DARK: 'dark'\n};\n","import api from '../../api';\n\nexport const SchemeAttribute = {\n THEME: api.internals.ns.attr('theme'),\n SCHEME: api.internals.ns.attr('scheme'),\n TRANSITION: api.internals.ns.attr('transition')\n};\n","export const SchemeTheme = {\n LIGHT: 'light',\n DARK: 'dark'\n};\n","import api from '../../api';\n\nexport const SchemeEmission = {\n SCHEME: api.internals.ns.emission('scheme', 'scheme'),\n THEME: api.internals.ns.emission('scheme', 'theme'),\n ASK: api.internals.ns.emission('scheme', 'ask')\n};\n","import api from '../../api.js';\n\nconst SchemeEvent = {\n SCHEME: api.internals.ns.event('scheme'),\n THEME: api.internals.ns.event('theme')\n};\n\nexport { SchemeEvent };\n","import api from '../../api.js';\nimport { SchemeValue } from './scheme-value.js';\nimport { SchemeAttribute } from './scheme-attribute.js';\nimport { SchemeTheme } from './scheme-theme.js';\nimport { SchemeEmission } from './scheme-emission.js';\nimport { SchemeEvent } from './scheme-event.js';\n\nclass Scheme extends api.core.Instance {\n constructor () {\n super(false);\n }\n\n static get instanceClassName () {\n return 'Scheme';\n }\n\n init () {\n this.changing = this.change.bind(this);\n\n if (this.hasAttribute(SchemeAttribute.TRANSITION)) {\n this.removeAttribute(SchemeAttribute.TRANSITION);\n this.request(this.restoreTransition.bind(this));\n }\n\n const scheme = api.internals.support.supportLocalStorage() ? localStorage.getItem('scheme') : '';\n const schemeAttr = this.getAttribute(SchemeAttribute.SCHEME);\n\n switch (scheme) {\n case SchemeValue.DARK:\n case SchemeValue.LIGHT:\n case SchemeValue.SYSTEM:\n this.scheme = scheme;\n break;\n\n default:\n switch (schemeAttr) {\n case SchemeValue.DARK:\n this.scheme = SchemeValue.DARK;\n break;\n\n case SchemeValue.LIGHT:\n this.scheme = SchemeValue.LIGHT;\n break;\n\n default:\n this.scheme = SchemeValue.SYSTEM;\n }\n }\n\n this.addAscent(SchemeEmission.ASK, this.ask.bind(this));\n this.addAscent(SchemeEmission.SCHEME, this.apply.bind(this));\n }\n\n get proxy () {\n const scope = this;\n\n const proxyAccessors = {\n get scheme () {\n return scope.scheme;\n },\n set scheme (value) {\n scope.scheme = value;\n }\n };\n\n return api.internals.property.completeAssign(super.proxy, proxyAccessors);\n }\n\n restoreTransition () {\n this.setAttribute(SchemeAttribute.TRANSITION, '');\n }\n\n ask () {\n this.descend(SchemeEmission.SCHEME, this.scheme);\n }\n\n apply (value) {\n this.scheme = value;\n }\n\n get scheme () {\n return this._scheme;\n }\n\n set scheme (value) {\n if (this._scheme === value) return;\n this._scheme = value;\n switch (value) {\n case SchemeValue.SYSTEM:\n this.listenPreferences();\n break;\n\n case SchemeValue.DARK:\n this.unlistenPreferences();\n this.theme = SchemeTheme.DARK;\n break;\n\n case SchemeValue.LIGHT:\n this.unlistenPreferences();\n this.theme = SchemeTheme.LIGHT;\n break;\n\n default:\n this.scheme = SchemeValue.SYSTEM;\n return;\n }\n\n this.descend(SchemeEmission.SCHEME, value);\n if (api.internals.support.supportLocalStorage()) {\n localStorage.setItem('scheme', value);\n }\n this.setAttribute(SchemeAttribute.SCHEME, value);\n this.dispatch(SchemeEvent.SCHEME, { scheme: this._scheme });\n }\n\n get theme () {\n return this._theme;\n }\n\n set theme (value) {\n if (this._theme === value) return;\n switch (value) {\n case SchemeTheme.LIGHT:\n case SchemeTheme.DARK:\n this._theme = value;\n this.setAttribute(SchemeAttribute.THEME, value);\n this.descend(SchemeEmission.THEME, value);\n this.dispatch(SchemeEvent.THEME, { theme: this._theme });\n document.documentElement.style.colorScheme = value === SchemeTheme.DARK ? 'dark' : '';\n break;\n }\n }\n\n listenPreferences () {\n if (this.isListening) return;\n this.isListening = true;\n this.mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n if (this.mediaQuery.addEventListener) this.mediaQuery.addEventListener('change', this.changing);\n this.change();\n }\n\n unlistenPreferences () {\n if (!this.isListening) return;\n this.isListening = false;\n this.mediaQuery.removeEventListener('change', this.changing);\n this.mediaQuery = null;\n }\n\n change () {\n if (!this.isListening) return;\n this.theme = this.mediaQuery.matches ? SchemeTheme.DARK : SchemeTheme.LIGHT;\n }\n\n mutate (attributeNames) {\n if (attributeNames.indexOf(SchemeAttribute.SCHEME) > -1) this.scheme = this.getAttribute(SchemeAttribute.SCHEME);\n if (attributeNames.indexOf(SchemeAttribute.THEME) > -1) this.theme = this.getAttribute(SchemeAttribute.THEME);\n }\n\n dispose () {\n this.unlistenPreferences();\n }\n}\n\nexport { Scheme };\n","import api from '../../api.js';\n\nexport const SchemeSelector = {\n SCHEME: `:root${api.internals.ns.attr.selector('theme')}, :root${api.internals.ns.attr.selector('scheme')}`,\n SWITCH_THEME: api.internals.ns.selector('switch-theme'),\n RADIO_BUTTONS: `input[name=\"${api.internals.ns('radios-theme')}\"]`\n};\n","import api from './api.js';\nimport { Scheme } from './script/scheme/scheme.js';\nimport { SchemeValue } from './script/scheme/scheme-value.js';\nimport { SchemeSelector } from './script/scheme/scheme-selector.js';\nimport { SchemeEmission } from './script/scheme/scheme-emission.js';\nimport { SchemeTheme } from './script/scheme/scheme-theme.js';\nimport { SchemeEvent } from './script/scheme/scheme-event';\n\napi.scheme = {\n Scheme: Scheme,\n SchemeValue: SchemeValue,\n SchemeSelector: SchemeSelector,\n SchemeEmission: SchemeEmission,\n SchemeTheme: SchemeTheme,\n SchemeEvent: SchemeEvent\n};\n\nexport default api;\n","import api from './index.js';\n\napi.internals.register(api.scheme.SchemeSelector.SCHEME, api.scheme.Scheme);\n\nexport default api;\n"],"names":["api","window","SchemeValue","SYSTEM","LIGHT","DARK","SchemeAttribute","THEME","internals","ns","attr","SCHEME","TRANSITION","SchemeTheme","SchemeEmission","emission","ASK","SchemeEvent","event","Scheme","core","Instance","constructor","super","instanceClassName","init","this","changing","change","bind","hasAttribute","removeAttribute","request","restoreTransition","scheme","support","supportLocalStorage","localStorage","getItem","schemeAttr","getAttribute","addAscent","ask","apply","proxy","scope","proxyAccessors","value","property","completeAssign","setAttribute","descend","_scheme","listenPreferences","unlistenPreferences","theme","setItem","dispatch","_theme","document","documentElement","style","colorScheme","isListening","mediaQuery","matchMedia","addEventListener","removeEventListener","matches","mutate","attributeNames","indexOf","dispose","SchemeSelector","selector","SWITCH_THEME","RADIO_BUTTONS","register"],"mappings":";AAAA,MCCMA,EAAMC,OAAuB,KCDtBC,EAAc,CACzBC,OAAQ,SACRC,MAAO,QACPC,KAAM,QCDKC,EAAkB,CAC7BC,MAAOP,EAAIQ,UAAUC,GAAGC,KAAK,SAC7BC,OAAQX,EAAIQ,UAAUC,GAAGC,KAAK,UAC9BE,WAAYZ,EAAIQ,UAAUC,GAAGC,KAAK,eCLvBG,EAAc,CACzBT,MAAO,QACPC,KAAM,QCAKS,EAAiB,CAC5BH,OAAQX,EAAIQ,UAAUC,GAAGM,SAAS,SAAU,UAC5CR,MAAOP,EAAIQ,UAAUC,GAAGM,SAAS,SAAU,SAC3CC,IAAKhB,EAAIQ,UAAUC,GAAGM,SAAS,SAAU,QCHrCE,EAAc,CAClBN,OAAQX,EAAIQ,UAAUC,GAAGS,MAAM,UAC/BX,MAAOP,EAAIQ,UAAUC,GAAGS,MAAM,UCGhC,MAAMC,UAAenB,EAAIo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