@siemens/ix 0.0.0-pr-2300-20260109081436 → 0.0.0-pr-2300-20260112084442

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/components/index.js +1 -1
  2. package/components/ix-application.js +1 -1
  3. package/components/ix-menu.js +1 -1
  4. package/components/{p-G5i1Siog.js → p-CsHYWHE6.js} +5 -15
  5. package/components/p-CsHYWHE6.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +1 -1
  7. package/dist/cjs/ix-application.cjs.entry.js +1 -1
  8. package/dist/cjs/ix-menu.cjs.entry.js +1 -1
  9. package/dist/cjs/{theme-switcher-BCyZa6wG.js → theme-switcher-76Td30il.js} +5 -15
  10. package/dist/cjs/theme-switcher-76Td30il.js.map +1 -0
  11. package/dist/collection/components/utils/theme-switcher.js +3 -13
  12. package/dist/collection/components/utils/theme-switcher.js.map +1 -1
  13. package/dist/esm/index.js +1 -1
  14. package/dist/esm/ix-application.entry.js +1 -1
  15. package/dist/esm/ix-menu.entry.js +1 -1
  16. package/dist/esm/{theme-switcher-EbjilqRl.js → theme-switcher-DRqJGlG2.js} +5 -15
  17. package/dist/esm/theme-switcher-DRqJGlG2.js.map +1 -0
  18. package/dist/siemens-ix/index.esm.js +1 -1
  19. package/dist/siemens-ix/{p-f5dd421a.entry.js → p-35d6b656.entry.js} +2 -2
  20. package/dist/siemens-ix/p-CsHYWHE6.js +2 -0
  21. package/dist/siemens-ix/p-CsHYWHE6.js.map +1 -0
  22. package/dist/siemens-ix/{p-f5f9940c.entry.js → p-f27c0a6c.entry.js} +2 -2
  23. package/dist/siemens-ix/siemens-ix.esm.js +1 -1
  24. package/hydrate/index.js +3 -13
  25. package/hydrate/index.mjs +3 -13
  26. package/package.json +1 -1
  27. package/components/p-G5i1Siog.js.map +0 -1
  28. package/dist/cjs/theme-switcher-BCyZa6wG.js.map +0 -1
  29. package/dist/esm/theme-switcher-EbjilqRl.js.map +0 -1
  30. package/dist/siemens-ix/p-G5i1Siog.js +0 -2
  31. package/dist/siemens-ix/p-G5i1Siog.js.map +0 -1
  32. /package/dist/siemens-ix/{p-f5dd421a.entry.js.map → p-35d6b656.entry.js.map} +0 -0
  33. /package/dist/siemens-ix/{p-f5f9940c.entry.js.map → p-f27c0a6c.entry.js.map} +0 -0
@@ -8,7 +8,7 @@ export { c as closeModal, d as dismissModal, r as registerFrameworkDelegate, a a
8
8
  import { A as Animation } from './p-C5MWUgDN.js';
9
9
  export { T as TypedEvent } from './p-BdCnOrqW.js';
10
10
  export { c as convertToAbbreviationString, a as convertToRemString } from './p-JJddxCCh.js';
11
- export { g as getCurrentSystemAppearance, t as themeSwitcher } from './p-G5i1Siog.js';
11
+ export { g as getCurrentSystemAppearance, t as themeSwitcher } from './p-CsHYWHE6.js';
12
12
 
13
13
  /*
14
14
  * SPDX-FileCopyrightText: 2024 Siemens AG
@@ -3,7 +3,7 @@ import { u as useContextProvider, A as ApplicationLayoutContext } from './p-BhgW
3
3
  import { a as applicationLayoutService } from './p-gkooEHol.js';
4
4
  import { m as menuController } from './p-BncjKdXL.js';
5
5
  import { h as hasSlottedElements } from './p-Bi1VyG64.js';
6
- import { t as themeSwitcher } from './p-G5i1Siog.js';
6
+ import { t as themeSwitcher } from './p-CsHYWHE6.js';
7
7
 
8
8
  const applicationCss = ":host{display:flex;position:relative;width:100vw;height:100vh;flex-direction:column}:host *,:host *::after,:host *::before{box-sizing:border-box}:host ::-webkit-scrollbar-button{display:none}@-moz-document url-prefix(){:host *{scrollbar-color:var(--theme-scrollbar-thumb--background) var(--theme-scrollbar-track--background);scrollbar-width:thin}}:host{}:host ::-webkit-scrollbar{width:0.5rem;height:0.5rem}:host{}:host ::-webkit-scrollbar-track{border-radius:5px;background:var(--theme-scrollbar-track--background)}:host ::-webkit-scrollbar-track:hover{background:var(--theme-scrollbar-track--background--hover)}:host{}:host ::-webkit-scrollbar-thumb{border-radius:5px;background:var(--theme-scrollbar-thumb--background)}:host{}:host ::-webkit-scrollbar-thumb:hover{background:var(--theme-scrollbar-thumb--background--hover)}:host ::-webkit-scrollbar-corner{display:none}:host ix-application-header{z-index:calc(var(--theme-z-index-sticky) + 1)}:host .logo-wrapper{display:contents}:host .application{display:flex;position:relative;flex-direction:row;height:100%;width:100%;overflow:hidden}:host .content-area{display:flex;position:relative;flex-direction:column;flex-wrap:nowrap;height:calc(100% - var(--ix-safe-area-inset-bottom, 0px));width:100%;margin-left:var(--ix-application-menu-margin-left);min-width:0}:host main{display:block;position:relative;flex-grow:1;width:100%;padding-bottom:var(--ix-safe-area-inset-bottom);overflow:auto}:host footer{display:block;position:relative;width:100%}:host(.breakpoint-md){--ix-application-menu-margin-left:calc(\n 3.25rem + var(--ix-application-menu-safe-area-left, 0rem)\n )}:host(.breakpoint-md) aside.slotted{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-md) aside.slotted+.content-area{margin-left:0}:host(.breakpoint-md) aside:not(.slotted)+.content-area{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-lg){--ix-application-menu-margin-left:0}:host(.breakpoint-sm){--ix-application-menu-margin-left:var(\n --ix-application-menu-safe-area-left,\n 0rem\n )}";
9
9
 
@@ -5,7 +5,7 @@ import { a as useContextConsumer, A as ApplicationLayoutContext } from './p-BhgW
5
5
  import { a as applicationLayoutService } from './p-gkooEHol.js';
6
6
  import { m as menuController } from './p-BncjKdXL.js';
7
7
  import { a as convertToRemString } from './p-JJddxCCh.js';
8
- import { t as themeSwitcher } from './p-G5i1Siog.js';
8
+ import { t as themeSwitcher } from './p-CsHYWHE6.js';
9
9
  import { C as iconNavigationLeft, D as iconNavigationRight, a as iconApps, E as iconCogwheel, F as iconLightDark, o as iconInfo } from './p-BvsadYCu.js';
10
10
  import { A as Animation } from './p-C5MWUgDN.js';
11
11
  import { d as defineCustomElement$7 } from './p-BEDohapR.js';
@@ -70,15 +70,9 @@ class ThemeSwitcher {
70
70
  return target.getAttribute(dataIxColorSchema);
71
71
  }
72
72
  getCurrentTheme() {
73
- const themeClass = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className));
74
- if (themeClass) {
75
- return themeClass;
76
- }
77
- const dataTheme = document.documentElement.getAttribute(dataIxTheme);
78
- const dataColorSchema = document.documentElement.getAttribute(dataIxColorSchema);
79
- const theme = dataTheme || 'classic';
80
- const variant = dataColorSchema || getCurrentSystemAppearance();
81
- return `theme-${theme}-${variant}`;
73
+ var _a;
74
+ return ((_a = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className))) !== null && _a !== void 0 ? _a : `theme-${document.documentElement.getAttribute(dataIxTheme) || 'classic'}-${document.documentElement.getAttribute(dataIxColorSchema) ||
75
+ getCurrentSystemAppearance()}`);
82
76
  }
83
77
  setVariant(variant = getCurrentSystemAppearance()) {
84
78
  if (this.getDataColorSchema(document.documentElement)) {
@@ -86,10 +80,6 @@ class ThemeSwitcher {
86
80
  return;
87
81
  }
88
82
  const currentTheme = this.getCurrentTheme();
89
- if (!currentTheme) {
90
- document.documentElement.setAttribute(dataIxColorSchema, variant);
91
- return;
92
- }
93
83
  document.documentElement.classList.remove(currentTheme);
94
84
  if (currentTheme.endsWith(this.suffixDark)) {
95
85
  document.documentElement.classList.add(currentTheme.replace(/-dark$/g, `-${variant}`));
@@ -179,6 +169,6 @@ const getCurrentSystemAppearance = () => {
179
169
  const themeSwitcher = new ThemeSwitcher();
180
170
 
181
171
  export { getCurrentSystemAppearance as g, themeSwitcher as t };
182
- //# sourceMappingURL=p-G5i1Siog.js.map
172
+ //# sourceMappingURL=p-CsHYWHE6.js.map
183
173
 
184
- //# sourceMappingURL=p-G5i1Siog.js.map
174
+ //# sourceMappingURL=p-CsHYWHE6.js.map
@@ -0,0 +1 @@
1
+ {"file":"p-CsHYWHE6.js","mappings":";;AAAA;;;;;;;AAOG;AAOH,MAAM,WAAW,GAAG,eAAe;AACnC,MAAM,iBAAiB,GAAG,sBAAsB;AAEhD,MAAM,aAAa,CAAA;AAUjB,IAAA,IAAW,Y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QAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,eAAe,CAAC;QAC7D,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAC3B,QAAQ,CAAC,eAAe,EACxB,sBAAsB,CACvB;;AAGH,IAAA,WAAA,GAAA;AAzNS,QAAA,IAAW,CAAA,WAAA,GAAG,QAAQ;AACtB,QAAA,IAAW,CAAA,WAAA,GAAG,QAAQ;AACtB,QAAA,IAAU,CAAA,UAAA,GAAG,OAAO;AACpB,QAAA,IAAY,CAAA,YAAA,GAAG,oBAAoB;AAG5C,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,UAAU,EAAU;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,UAAU,EAAU;QAmNvC,IAAI,CAAC,yBAAyB,EAAE;;AAEnC;AAMM,MAAM,0BAA0B,GAAG,MAAmB;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC;AAEpE,IAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACtB,QAAA,OAAO,MAAM;;AAGf,IAAA,OAAO,OAAO;AAChB;AAEa,MAAA,aAAa,GAAG,IAAI,aAAa;;;;","names":[],"sources":["src/components/utils/theme-switcher.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n return (\n Array.from(document.documentElement.classList).find((className) =>\n this.isThemeClass(className)\n ) ??\n `theme-${\n document.documentElement.getAttribute(dataIxTheme) || 'classic'\n }-${\n document.documentElement.getAttribute(dataIxColorSchema) ||\n getCurrentSystemAppearance()\n }`\n );\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"],"version":3}
@@ -7,7 +7,7 @@ var modal = require('./modal-CsEGB0kd.js');
7
7
  var animation = require('./animation-DtTuOXbI.js');
8
8
  var typedEvent = require('./typed-event-DxWATHPL.js');
9
9
  var rwd_util = require('./rwd.util-GTn-vgCJ.js');
10
- var themeSwitcher = require('./theme-switcher-BCyZa6wG.js');
10
+ var themeSwitcher = require('./theme-switcher-76Td30il.js');
11
11
  var setup = require('./setup-Do7b4BhK.js');
12
12
  require('./index-Dyz3z1FD.js');
13
13
  require('./index-C8Xo8L1k.js');
@@ -5,7 +5,7 @@ var context = require('./context-CmNuiaNz.js');
5
5
  var service = require('./service-DuiJmf7R.js');
6
6
  var menuService = require('./menu-service-CW0vT80Q.js');
7
7
  var shadowDom = require('./shadow-dom-DT01VwcB.js');
8
- var themeSwitcher = require('./theme-switcher-BCyZa6wG.js');
8
+ var themeSwitcher = require('./theme-switcher-76Td30il.js');
9
9
  require('./typed-event-DxWATHPL.js');
10
10
  require('./breakpoints-C5ZrUCbZ.js');
11
11
 
@@ -7,7 +7,7 @@ var context = require('./context-CmNuiaNz.js');
7
7
  var service = require('./service-DuiJmf7R.js');
8
8
  var menuService = require('./menu-service-CW0vT80Q.js');
9
9
  var rwd_util = require('./rwd.util-GTn-vgCJ.js');
10
- var themeSwitcher = require('./theme-switcher-BCyZa6wG.js');
10
+ var themeSwitcher = require('./theme-switcher-76Td30il.js');
11
11
  var index$1 = require('./index-Dyz3z1FD.js');
12
12
  var animation = require('./animation-DtTuOXbI.js');
13
13
  require('./modal-CsEGB0kd.js');
@@ -72,15 +72,9 @@ class ThemeSwitcher {
72
72
  return target.getAttribute(dataIxColorSchema);
73
73
  }
74
74
  getCurrentTheme() {
75
- const themeClass = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className));
76
- if (themeClass) {
77
- return themeClass;
78
- }
79
- const dataTheme = document.documentElement.getAttribute(dataIxTheme);
80
- const dataColorSchema = document.documentElement.getAttribute(dataIxColorSchema);
81
- const theme = dataTheme || 'classic';
82
- const variant = dataColorSchema || getCurrentSystemAppearance();
83
- return `theme-${theme}-${variant}`;
75
+ var _a;
76
+ return ((_a = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className))) !== null && _a !== void 0 ? _a : `theme-${document.documentElement.getAttribute(dataIxTheme) || 'classic'}-${document.documentElement.getAttribute(dataIxColorSchema) ||
77
+ getCurrentSystemAppearance()}`);
84
78
  }
85
79
  setVariant(variant = getCurrentSystemAppearance()) {
86
80
  if (this.getDataColorSchema(document.documentElement)) {
@@ -88,10 +82,6 @@ class ThemeSwitcher {
88
82
  return;
89
83
  }
90
84
  const currentTheme = this.getCurrentTheme();
91
- if (!currentTheme) {
92
- document.documentElement.setAttribute(dataIxColorSchema, variant);
93
- return;
94
- }
95
85
  document.documentElement.classList.remove(currentTheme);
96
86
  if (currentTheme.endsWith(this.suffixDark)) {
97
87
  document.documentElement.classList.add(currentTheme.replace(/-dark$/g, `-${variant}`));
@@ -182,6 +172,6 @@ const themeSwitcher = new ThemeSwitcher();
182
172
 
183
173
  exports.getCurrentSystemAppearance = getCurrentSystemAppearance;
184
174
  exports.themeSwitcher = themeSwitcher;
185
- //# sourceMappingURL=theme-switcher-BCyZa6wG.js.map
175
+ //# sourceMappingURL=theme-switcher-76Td30il.js.map
186
176
 
187
- //# sourceMappingURL=theme-switcher-BCyZa6wG.js.map
177
+ //# sourceMappingURL=theme-switcher-76Td30il.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-switcher-76Td30il.js","sources":["src/components/utils/theme-switcher.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n return (\n Array.from(document.documentElement.classList).find((className) =>\n this.isThemeClass(className)\n ) ??\n `theme-${\n document.documentElement.getAttribute(dataIxTheme) || 'classic'\n }-${\n document.documentElement.getAttribute(dataIxColorSchema) ||\n getCurrentSystemAppearance()\n }`\n );\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"],"names":["TypedEvent"],"mappings":";;;;AAAA;;;;;;;AAOG;AAOH,MAAM,WAAW,GAAG,eAAe;AACnC,MAAM,iBAAiB,GAAG,sBAAsB;AAEhD,MAAM,aAAa,CAAA;AAUjB,IAAA,IAAW,YAAY,GAAA;QACrB,OAAO,IAAI,CAAC,aAAa;;AAG3B,IAAA,IAAW,aAAa,GAAA;QACtB,OAAO,IAAI,CAAC,cAAc;;AAGrB,IAAA,gBAAgB,CAAC,SAAiB,EAAA;QACvC,QACE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YACnC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;;AAIhC,IAAA,YAAY,CAAC,SAAiB,EAAA;AACpC,QAAA,QACE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC;;AAIvE,IAAA,QAAQ,CAAC,SAAiB,EAAE,gBAAgB,GAAG,KAAK,EAAA;AACzD,QAAA,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;AAChC,YAAA,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC;;aAC5B;YACL,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC;;QAG/D,IAAI,gBAAgB,EAAE;AACpB,YAAA,MAAM,uBAAuB,GAAG,0BAA0B,EAAE;AAC5D,YAAA,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC;;;AAIpC,IAAA,iBAAiB,CAAC,SAAiB,EAAA;QACzC,MAAM,SAAS,GAAa,EAAE;QAC9B,KAAK,CAAC,IAAI,CA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AAE,CAAC,OAAO,EAAE,WAAW,EAAE,iBAAiB,CAAC;AAC1D,YAAA,iBAAiB,EAAE,IAAI;SACxB;AAED,QAAA,MAAM,eAAe,GAAG,CAAC,SAA2B,KAAI;AACtD,YAAA,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;AAExE,YAAA,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;AACzC,YAAA,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC;AACzC,SAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,eAAe,CAAC;QAC7D,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAC3B,QAAQ,CAAC,eAAe,EACxB,sBAAsB,CACvB;;AAGH,IAAA,WAAA,GAAA;AAzNS,QAAA,IAAW,CAAA,WAAA,GAAG,QAAQ;AACtB,QAAA,IAAW,CAAA,WAAA,GAAG,QAAQ;AACtB,QAAA,IAAU,CAAA,UAAA,GAAG,OAAO;AACpB,QAAA,IAAY,CAAA,YAAA,GAAG,oBAAoB;AAG5C,QAAA,IAAA,CAAA,aAAa,GAAG,IAAIA,qBAAU,EAAU;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,IAAIA,qBAAU,EAAU;QAmNvC,IAAI,CAAC,yBAAyB,EAAE;;AAEnC;AAMM,MAAM,0BAA0B,GAAG,MAAmB;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC;AAEpE,IAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACtB,QAAA,OAAO,MAAM;;AAGf,IAAA,OAAO,OAAO;AAChB;AAEa,MAAA,aAAa,GAAG,IAAI,aAAa;;;;;"}
@@ -69,15 +69,9 @@ class ThemeSwitcher {
69
69
  return target.getAttribute(dataIxColorSchema);
70
70
  }
71
71
  getCurrentTheme() {
72
- const themeClass = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className));
73
- if (themeClass) {
74
- return themeClass;
75
- }
76
- const dataTheme = document.documentElement.getAttribute(dataIxTheme);
77
- const dataColorSchema = document.documentElement.getAttribute(dataIxColorSchema);
78
- const theme = dataTheme || 'classic';
79
- const variant = dataColorSchema || getCurrentSystemAppearance();
80
- return `theme-${theme}-${variant}`;
72
+ var _a;
73
+ return ((_a = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className))) !== null && _a !== void 0 ? _a : `theme-${document.documentElement.getAttribute(dataIxTheme) || 'classic'}-${document.documentElement.getAttribute(dataIxColorSchema) ||
74
+ getCurrentSystemAppearance()}`);
81
75
  }
82
76
  setVariant(variant = getCurrentSystemAppearance()) {
83
77
  if (this.getDataColorSchema(document.documentElement)) {
@@ -85,10 +79,6 @@ class ThemeSwitcher {
85
79
  return;
86
80
  }
87
81
  const currentTheme = this.getCurrentTheme();
88
- if (!currentTheme) {
89
- document.documentElement.setAttribute(dataIxColorSchema, variant);
90
- return;
91
- }
92
82
  document.documentElement.classList.remove(currentTheme);
93
83
  if (currentTheme.endsWith(this.suffixDark)) {
94
84
  document.documentElement.classList.add(currentTheme.replace(/-dark$/g, `-${variant}`));
@@ -1 +1 @@
1
- {"version":3,"file":"theme-switcher.js","sourceRoot":"","sources":["../../../src/components/utils/theme-switcher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,WAAW,GAAG,eAAe,CAAC;AACpC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,MAAM,aAAa;IAUjB,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,gBAAgB,CAAC,SAAiB;QACvC,OAAO,CACL,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YACnC,SAAS,CAAC,QAAQ,CAA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EAAE,iBAAiB,CAAC;YAC1D,iBAAiB,EAAE,IAAI;SACxB,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,SAA2B,EAAE,EAAE;YACtD,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YAEzE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;YAC1C,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;QAC9D,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAC3B,QAAQ,CAAC,eAAe,EACxB,sBAAsB,CACvB,CAAC;IACJ,CAAC;IAED;QAnOS,gBAAW,GAAG,QAAQ,CAAC;QACvB,gBAAW,GAAG,QAAQ,CAAC;QACvB,eAAU,GAAG,OAAO,CAAC;QACrB,iBAAY,GAAG,oBAAoB,CAAC;QAG7C,kBAAa,GAAG,IAAI,UAAU,EAAU,CAAC;QACzC,mBAAc,GAAG,IAAI,UAAU,EAAU,CAAC;QA6NxC,IAAI,CAAC,yBAAyB,EAAE,CAAC;IACnC,CAAC;CACF;AAMD,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAiB,EAAE;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC;IAErE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n const themeClass = Array.from(document.documentElement.classList).find(\n (className) => this.isThemeClass(className)\n );\n\n if (themeClass) {\n return themeClass;\n }\n\n const dataTheme = document.documentElement.getAttribute(dataIxTheme);\n const dataColorSchema =\n document.documentElement.getAttribute(dataIxColorSchema);\n\n const theme = dataTheme || 'classic';\n const variant = dataColorSchema || getCurrentSystemAppearance();\n\n return `theme-${theme}-${variant}`;\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n if (!currentTheme) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"]}
1
+ {"version":3,"file":"theme-switcher.js","sourceRoot":"","sources":["../../../src/components/utils/theme-switcher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,WA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,CAAC;YAC1D,iBAAiB,EAAE,IAAI;SACxB,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,SAA2B,EAAE,EAAE;YACtD,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YAEzE,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;YAC1C,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;QAC9D,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAC3B,QAAQ,CAAC,eAAe,EACxB,sBAAsB,CACvB,CAAC;IACJ,CAAC;IAED;QAzNS,gBAAW,GAAG,QAAQ,CAAC;QACvB,gBAAW,GAAG,QAAQ,CAAC;QACvB,eAAU,GAAG,OAAO,CAAC;QACrB,iBAAY,GAAG,oBAAoB,CAAC;QAG7C,kBAAa,GAAG,IAAI,UAAU,EAAU,CAAC;QACzC,mBAAc,GAAG,IAAI,UAAU,EAAU,CAAC;QAmNxC,IAAI,CAAC,yBAAyB,EAAE,CAAC;IACnC,CAAC;CACF;AAMD,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAiB,EAAE;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC;IAErE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC","sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n return (\n Array.from(document.documentElement.classList).find((className) =>\n this.isThemeClass(className)\n ) ??\n `theme-${\n document.documentElement.getAttribute(dataIxTheme) || 'classic'\n }-${\n document.documentElement.getAttribute(dataIxColorSchema) ||\n getCurrentSystemAppearance()\n }`\n );\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"]}
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ export { c as closeModal, d as dismissModal, r as registerFrameworkDelegate, a a
6
6
  import { A as Animation } from './animation-C5MWUgDN.js';
7
7
  export { T as TypedEvent } from './typed-event-BdCnOrqW.js';
8
8
  export { a as convertToAbbreviationString, c as convertToRemString } from './rwd.util-pXYAoEyc.js';
9
- export { g as getCurrentSystemAppearance, t as themeSwitcher } from './theme-switcher-EbjilqRl.js';
9
+ export { g as getCurrentSystemAppearance, t as themeSwitcher } from './theme-switcher-DRqJGlG2.js';
10
10
  export { h as handlePlatformHelpers } from './setup-BHVEOpQp.js';
11
11
  import './index-8HpPmDK_.js';
12
12
  import './index-CtoreFVF.js';
@@ -3,7 +3,7 @@ import { u as useContextProvider, A as ApplicationLayoutContext } from './contex
3
3
  import { a as applicationLayoutService } from './service-Da0kv8hS.js';
4
4
  import { m as menuController } from './menu-service-BMvtckRa.js';
5
5
  import { h as hasSlottedElements } from './shadow-dom-i60z1FJC.js';
6
- import { t as themeSwitcher } from './theme-switcher-EbjilqRl.js';
6
+ import { t as themeSwitcher } from './theme-switcher-DRqJGlG2.js';
7
7
  import './typed-event-BdCnOrqW.js';
8
8
  import './breakpoints-D_Hmobxf.js';
9
9
 
@@ -5,7 +5,7 @@ import { a as useContextConsumer, A as ApplicationLayoutContext } from './contex
5
5
  import { a as applicationLayoutService } from './service-Da0kv8hS.js';
6
6
  import { m as menuController } from './menu-service-BMvtckRa.js';
7
7
  import { c as convertToRemString } from './rwd.util-pXYAoEyc.js';
8
- import { t as themeSwitcher } from './theme-switcher-EbjilqRl.js';
8
+ import { t as themeSwitcher } from './theme-switcher-DRqJGlG2.js';
9
9
  import { P as iconNavigationLeft, Q as iconNavigationRight, e as iconApps, R as iconCogwheel, S as iconLightDark, b as iconInfo } from './index-8HpPmDK_.js';
10
10
  import { A as Animation } from './animation-C5MWUgDN.js';
11
11
  import './modal-BTxff2hq.js';
@@ -70,15 +70,9 @@ class ThemeSwitcher {
70
70
  return target.getAttribute(dataIxColorSchema);
71
71
  }
72
72
  getCurrentTheme() {
73
- const themeClass = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className));
74
- if (themeClass) {
75
- return themeClass;
76
- }
77
- const dataTheme = document.documentElement.getAttribute(dataIxTheme);
78
- const dataColorSchema = document.documentElement.getAttribute(dataIxColorSchema);
79
- const theme = dataTheme || 'classic';
80
- const variant = dataColorSchema || getCurrentSystemAppearance();
81
- return `theme-${theme}-${variant}`;
73
+ var _a;
74
+ return ((_a = Array.from(document.documentElement.classList).find((className) => this.isThemeClass(className))) !== null && _a !== void 0 ? _a : `theme-${document.documentElement.getAttribute(dataIxTheme) || 'classic'}-${document.documentElement.getAttribute(dataIxColorSchema) ||
75
+ getCurrentSystemAppearance()}`);
82
76
  }
83
77
  setVariant(variant = getCurrentSystemAppearance()) {
84
78
  if (this.getDataColorSchema(document.documentElement)) {
@@ -86,10 +80,6 @@ class ThemeSwitcher {
86
80
  return;
87
81
  }
88
82
  const currentTheme = this.getCurrentTheme();
89
- if (!currentTheme) {
90
- document.documentElement.setAttribute(dataIxColorSchema, variant);
91
- return;
92
- }
93
83
  document.documentElement.classList.remove(currentTheme);
94
84
  if (currentTheme.endsWith(this.suffixDark)) {
95
85
  document.documentElement.classList.add(currentTheme.replace(/-dark$/g, `-${variant}`));
@@ -179,6 +169,6 @@ const getCurrentSystemAppearance = () => {
179
169
  const themeSwitcher = new ThemeSwitcher();
180
170
 
181
171
  export { getCurrentSystemAppearance as g, themeSwitcher as t };
182
- //# sourceMappingURL=theme-switcher-EbjilqRl.js.map
172
+ //# sourceMappingURL=theme-switcher-DRqJGlG2.js.map
183
173
 
184
- //# sourceMappingURL=theme-switcher-EbjilqRl.js.map
174
+ //# sourceMappingURL=theme-switcher-DRqJGlG2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-switcher-DRqJGlG2.js","sources":["src/components/utils/theme-switcher.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n return (\n Array.from(document.documentElement.classList).find((className) =>\n this.isThemeClass(className)\n ) ??\n `theme-${\n document.documentElement.getAttribute(dataIxTheme) || 'classic'\n }-${\n document.documentElement.getAttribute(dataIxColorSchema) ||\n getCurrentSystemAppearance()\n }`\n );\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAOH,MAAM,WAAW,GAAG,eAAe;AACnC,MAAM,iBAAiB,GAAG,sBAAsB;AAEhD,MAAM,aAAa,CAAA;AAUjB,IAAA,IAAW,YAAY,GAAA;QACrB,OAAO,IAAI,CAAC,aAAa;;AAG3B,IAAA,IAAW,aAAa,GAAA;QACtB,OAAO,IAAI,CAAC,cAAc;;AAGrB,IAAA,gBAAgB,CAAC,SAAiB,EAAA;QACvC,QACE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YACnC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;;AAIhC,IAAA,YAAY,CAAC,SAAiB,EAAA;AACpC,QAAA,QACE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,IA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,CAAA,aAAa,GAAG,IAAI,UAAU,EAAU;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,UAAU,EAAU;QAmNvC,IAAI,CAAC,yBAAyB,EAAE;;AAEnC;AAMM,MAAM,0BAA0B,GAAG,MAAmB;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC;AAEpE,IAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACtB,QAAA,OAAO,MAAM;;AAGf,IAAA,OAAO,OAAO;AAChB;AAEa,MAAA,aAAa,GAAG,IAAI,aAAa;;;;"}
@@ -1,2 +1,2 @@
1
- export{I as InputState,L as LogicalFilterOperator}from"./p-BH3f5fa3.js";export{d as defaultRefreshTreeOptions,r as renderDefaultItem}from"./p-DSTYytot.js";export{U as UploadFileState}from"./p-BGzrnl_l.js";import{g as e}from"./p-BC0Exw_O.js";export{c as closeModal,d as dismissModal,r as registerFrameworkDelegate,a as resolveDelegate,b as showMessage,s as showModal}from"./p-BC0Exw_O.js";import{A as o}from"./p-C5MWUgDN.js";export{T as TypedEvent}from"./p-BdCnOrqW.js";export{a as convertToAbbreviationString,c as convertToRemString}from"./p-pXYAoEyc.js";export{g as getCurrentSystemAppearance,t as themeSwitcher}from"./p-G5i1Siog.js";export{h as handlePlatformHelpers}from"./p-BhAVd5ka.js";import"./p-8HpPmDK_.js";import"./p-CtoreFVF.js";class n{constructor(){this.tokens=[];this.categories=[]}}function i(){const e=Array.from(document.querySelectorAll("ix-toast-container"));const[t]=e;if(e.length>1){console.warn("Multiple toast containers were found. Only the first one will be used.");return t}if(!t){const e=document.createElement("ix-toast-container");document.body.appendChild(e);return e}return t}function p(e){const t=i();t.setAttribute("position",e)}function l(e){const t=i();return t.showToast(e)}l.info=e=>l(Object.assign(Object.assign({},e),{type:"info"}));l.error=e=>l(Object.assign(Object.assign({},e),{type:"error"}));l.success=e=>l(Object.assign(Object.assign({},e),{type:"success"}));l.warning=e=>l(Object.assign(Object.assign({},e),{type:"warning"}));function m(t){const r=document.createElement("ix-modal");r.disableEscapeClose=true;const s=document.createElement("ix-modal-loading");s.innerText=t;r.appendChild(s);e().attachView(r);r.showModal();return{update:e=>s.innerHTML=e,finish:(t,n=250)=>{if(t!==undefined){s.innerText=t}else{n=0}setTimeout((()=>{r.closeModal(null);setTimeout((async()=>await e().removeView(r)),o.mediumTime)}),n)}}}export{n as FilterState,e as getCoreDelegate,i as getToastContainer,p as setToastPosition,m as showModalLoading,l as toast};
1
+ export{I as InputState,L as LogicalFilterOperator}from"./p-BH3f5fa3.js";export{d as defaultRefreshTreeOptions,r as renderDefaultItem}from"./p-DSTYytot.js";export{U as UploadFileState}from"./p-BGzrnl_l.js";import{g as e}from"./p-BC0Exw_O.js";export{c as closeModal,d as dismissModal,r as registerFrameworkDelegate,a as resolveDelegate,b as showMessage,s as showModal}from"./p-BC0Exw_O.js";import{A as o}from"./p-C5MWUgDN.js";export{T as TypedEvent}from"./p-BdCnOrqW.js";export{a as convertToAbbreviationString,c as convertToRemString}from"./p-pXYAoEyc.js";export{g as getCurrentSystemAppearance,t as themeSwitcher}from"./p-CsHYWHE6.js";export{h as handlePlatformHelpers}from"./p-BhAVd5ka.js";import"./p-8HpPmDK_.js";import"./p-CtoreFVF.js";class n{constructor(){this.tokens=[];this.categories=[]}}function i(){const e=Array.from(document.querySelectorAll("ix-toast-container"));const[t]=e;if(e.length>1){console.warn("Multiple toast containers were found. Only the first one will be used.");return t}if(!t){const e=document.createElement("ix-toast-container");document.body.appendChild(e);return e}return t}function p(e){const t=i();t.setAttribute("position",e)}function l(e){const t=i();return t.showToast(e)}l.info=e=>l(Object.assign(Object.assign({},e),{type:"info"}));l.error=e=>l(Object.assign(Object.assign({},e),{type:"error"}));l.success=e=>l(Object.assign(Object.assign({},e),{type:"success"}));l.warning=e=>l(Object.assign(Object.assign({},e),{type:"warning"}));function m(t){const r=document.createElement("ix-modal");r.disableEscapeClose=true;const s=document.createElement("ix-modal-loading");s.innerText=t;r.appendChild(s);e().attachView(r);r.showModal();return{update:e=>s.innerHTML=e,finish:(t,n=250)=>{if(t!==undefined){s.innerText=t}else{n=0}setTimeout((()=>{r.closeModal(null);setTimeout((async()=>await e().removeView(r)),o.mediumTime)}),n)}}}export{n as FilterState,e as getCoreDelegate,i as getToastContainer,p as setToastPosition,m as showModalLoading,l as toast};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,h as t,H as a,g as i}from"./p-CtoreFVF.js";import{u as o,A as r}from"./p-BhgW5qDm.js";import{a as s}from"./p-gkooEHol.js";import{m as n}from"./p-BncjKdXL.js";import{h as l}from"./p-i60z1FJC.js";import{t as c}from"./p-G5i1Siog.js";import"./p-BdCnOrqW.js";import"./p-D_Hmobxf.js";const h=":host{display:flex;position:relative;width:100vw;height:100vh;flex-direction:column}:host *,:host *::after,:host *::before{box-sizing:border-box}:host ::-webkit-scrollbar-button{display:none}@-moz-document url-prefix(){:host *{scrollbar-color:var(--theme-scrollbar-thumb--background) var(--theme-scrollbar-track--background);scrollbar-width:thin}}:host{}:host ::-webkit-scrollbar{width:0.5rem;height:0.5rem}:host{}:host ::-webkit-scrollbar-track{border-radius:5px;background:var(--theme-scrollbar-track--background)}:host ::-webkit-scrollbar-track:hover{background:var(--theme-scrollbar-track--background--hover)}:host{}:host ::-webkit-scrollbar-thumb{border-radius:5px;background:var(--theme-scrollbar-thumb--background)}:host{}:host ::-webkit-scrollbar-thumb:hover{background:var(--theme-scrollbar-thumb--background--hover)}:host ::-webkit-scrollbar-corner{display:none}:host ix-application-header{z-index:calc(var(--theme-z-index-sticky) + 1)}:host .logo-wrapper{display:contents}:host .application{display:flex;position:relative;flex-direction:row;height:100%;width:100%;overflow:hidden}:host .content-area{display:flex;position:relative;flex-direction:column;flex-wrap:nowrap;height:calc(100% - var(--ix-safe-area-inset-bottom, 0px));width:100%;margin-left:var(--ix-application-menu-margin-left);min-width:0}:host main{display:block;position:relative;flex-grow:1;width:100%;padding-bottom:var(--ix-safe-area-inset-bottom);overflow:auto}:host footer{display:block;position:relative;width:100%}:host(.breakpoint-md){--ix-application-menu-margin-left:calc(\n 3.25rem + var(--ix-application-menu-safe-area-left, 0rem)\n )}:host(.breakpoint-md) aside.slotted{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-md) aside.slotted+.content-area{margin-left:0}:host(.breakpoint-md) aside:not(.slotted)+.content-area{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-lg){--ix-application-menu-margin-left:0}:host(.breakpoint-sm){--ix-application-menu-margin-left:var(\n --ix-application-menu-safe-area-left,\n 0rem\n )}";const d=class{constructor(t){e(this,t);this.themeSystemAppearance=false;this.breakpoints=["sm","md","lg"];this.breakpoint="lg";this.applicationSidebarSlotted=false}forceLayoutChange(e){if(!e){s.enableBreakpointDetection();return}s.disableBreakpointDetection();s.setBreakpoint(e)}onBreakpointsChange(e){s.setBreakpoints(e)}get menu(){return this.hostElement.querySelector("ix-menu")}get applicationSidebarSlot(){return this.hostElement.shadowRoot.querySelector(".application-sidebar slot")}onContentClick(){var e;if(n.isPinned){return}(e=this.menu)===null||e===void 0?void 0:e.toggleMenu(false)}componentWillLoad(){s.setBreakpoints(this.breakpoints);this.contextProvider=o(this.hostElement,r,{hideHeader:false,sidebar:this.applicationSidebarSlotted,appSwitchConfig:this.appSwitchConfig});this.modeDisposable=s.onChange.on((e=>{this.breakpoint=e}));this.breakpoint=s.breakpoint;if(this.forceBreakpoint){this.forceLayoutChange(this.forceBreakpoint)}this.changeTheme()}disconnectedCallback(){var e;(e=this.modeDisposable)===null||e===void 0?void 0:e.dispose()}changeTheme(){if(!this.theme){if(this.themeSystemAppearance){c.setVariant()}return}if(c.hasVariantSuffix(this.theme)){c.setTheme(`theme-${this.theme}`);return}c.setTheme(`theme-${this.theme}-dark`,this.themeSystemAppearance)}onApplicationSidebarChange(){if(!this.contextProvider){console.error("Context provider not available");return}this.contextProvider.emit({hideHeader:false,sidebar:this.applicationSidebarSlotted,appSwitchConfig:this.appSwitchConfig})}render(){return t(a,{key:"80437ae705c381c0167b8d7c5ce429e611b03f91","data-role":"",class:{[`breakpoint-${this.breakpoint}`]:true}},t("slot",{key:"865d2e5a9252459f62ff8ab5dce1413d11c04379",name:"application-header"}),t("div",{key:"ae1960437e8721fbc4afab659d149265660e4164",class:"application"},t("slot",{key:"a2a9a835af35e30d2ebe52347903f1838e75ac8d",name:"menu"}),t("aside",{key:"6141152471ac7dc7310247b23278dc594e025fa3",class:{"application-sidebar":true,slotted:this.applicationSidebarSlotted},onClick:()=>this.onContentClick()},t("slot",{key:"3285cc16452a7a6936a542dd26758beebb515972",name:"application-sidebar",onSlotchange:()=>this.applicationSidebarSlotted=l(this.applicationSidebarSlot)})),t("div",{key:"c6d022a1a5c220ed088adeba49ab5daa27ff8c77",class:"content-area"},t("main",{key:"8ab781e17318078290a6ce4e1e64dfea43d5ae00",class:"content",onClick:()=>this.onContentClick()},t("slot",{key:"24e83882ab5746f4e00a0c16c797ddf4111aa1e8"})),t("footer",{key:"3ce838daa8f8f4b4e56cb2626476223d9575177c",class:"footer"},t("slot",{key:"e49d1cd476554dfddca3b538194040ca29394967",name:"bottom"})))))}get hostElement(){return i(this)}static get watchers(){return{breakpoints:["onBreakpointsChange"],theme:["changeTheme"],themeSystemAppearance:["changeTheme"],appSwitchConfig:["onApplicationSidebarChange"],applicationSidebarSlotted:["onApplicationSidebarChange"]}}};d.style=h;export{d as ix_application};
2
- //# sourceMappingURL=p-f5dd421a.entry.js.map
1
+ import{r as e,h as t,H as a,g as i}from"./p-CtoreFVF.js";import{u as o,A as r}from"./p-BhgW5qDm.js";import{a as s}from"./p-gkooEHol.js";import{m as n}from"./p-BncjKdXL.js";import{h as l}from"./p-i60z1FJC.js";import{t as c}from"./p-CsHYWHE6.js";import"./p-BdCnOrqW.js";import"./p-D_Hmobxf.js";const h=":host{display:flex;position:relative;width:100vw;height:100vh;flex-direction:column}:host *,:host *::after,:host *::before{box-sizing:border-box}:host ::-webkit-scrollbar-button{display:none}@-moz-document url-prefix(){:host *{scrollbar-color:var(--theme-scrollbar-thumb--background) var(--theme-scrollbar-track--background);scrollbar-width:thin}}:host{}:host ::-webkit-scrollbar{width:0.5rem;height:0.5rem}:host{}:host ::-webkit-scrollbar-track{border-radius:5px;background:var(--theme-scrollbar-track--background)}:host ::-webkit-scrollbar-track:hover{background:var(--theme-scrollbar-track--background--hover)}:host{}:host ::-webkit-scrollbar-thumb{border-radius:5px;background:var(--theme-scrollbar-thumb--background)}:host{}:host ::-webkit-scrollbar-thumb:hover{background:var(--theme-scrollbar-thumb--background--hover)}:host ::-webkit-scrollbar-corner{display:none}:host ix-application-header{z-index:calc(var(--theme-z-index-sticky) + 1)}:host .logo-wrapper{display:contents}:host .application{display:flex;position:relative;flex-direction:row;height:100%;width:100%;overflow:hidden}:host .content-area{display:flex;position:relative;flex-direction:column;flex-wrap:nowrap;height:calc(100% - var(--ix-safe-area-inset-bottom, 0px));width:100%;margin-left:var(--ix-application-menu-margin-left);min-width:0}:host main{display:block;position:relative;flex-grow:1;width:100%;padding-bottom:var(--ix-safe-area-inset-bottom);overflow:auto}:host footer{display:block;position:relative;width:100%}:host(.breakpoint-md){--ix-application-menu-margin-left:calc(\n 3.25rem + var(--ix-application-menu-safe-area-left, 0rem)\n )}:host(.breakpoint-md) aside.slotted{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-md) aside.slotted+.content-area{margin-left:0}:host(.breakpoint-md) aside:not(.slotted)+.content-area{margin-left:var(--ix-application-menu-margin-left)}:host(.breakpoint-lg){--ix-application-menu-margin-left:0}:host(.breakpoint-sm){--ix-application-menu-margin-left:var(\n --ix-application-menu-safe-area-left,\n 0rem\n )}";const d=class{constructor(t){e(this,t);this.themeSystemAppearance=false;this.breakpoints=["sm","md","lg"];this.breakpoint="lg";this.applicationSidebarSlotted=false}forceLayoutChange(e){if(!e){s.enableBreakpointDetection();return}s.disableBreakpointDetection();s.setBreakpoint(e)}onBreakpointsChange(e){s.setBreakpoints(e)}get menu(){return this.hostElement.querySelector("ix-menu")}get applicationSidebarSlot(){return this.hostElement.shadowRoot.querySelector(".application-sidebar slot")}onContentClick(){var e;if(n.isPinned){return}(e=this.menu)===null||e===void 0?void 0:e.toggleMenu(false)}componentWillLoad(){s.setBreakpoints(this.breakpoints);this.contextProvider=o(this.hostElement,r,{hideHeader:false,sidebar:this.applicationSidebarSlotted,appSwitchConfig:this.appSwitchConfig});this.modeDisposable=s.onChange.on((e=>{this.breakpoint=e}));this.breakpoint=s.breakpoint;if(this.forceBreakpoint){this.forceLayoutChange(this.forceBreakpoint)}this.changeTheme()}disconnectedCallback(){var e;(e=this.modeDisposable)===null||e===void 0?void 0:e.dispose()}changeTheme(){if(!this.theme){if(this.themeSystemAppearance){c.setVariant()}return}if(c.hasVariantSuffix(this.theme)){c.setTheme(`theme-${this.theme}`);return}c.setTheme(`theme-${this.theme}-dark`,this.themeSystemAppearance)}onApplicationSidebarChange(){if(!this.contextProvider){console.error("Context provider not available");return}this.contextProvider.emit({hideHeader:false,sidebar:this.applicationSidebarSlotted,appSwitchConfig:this.appSwitchConfig})}render(){return t(a,{key:"80437ae705c381c0167b8d7c5ce429e611b03f91","data-role":"",class:{[`breakpoint-${this.breakpoint}`]:true}},t("slot",{key:"865d2e5a9252459f62ff8ab5dce1413d11c04379",name:"application-header"}),t("div",{key:"ae1960437e8721fbc4afab659d149265660e4164",class:"application"},t("slot",{key:"a2a9a835af35e30d2ebe52347903f1838e75ac8d",name:"menu"}),t("aside",{key:"6141152471ac7dc7310247b23278dc594e025fa3",class:{"application-sidebar":true,slotted:this.applicationSidebarSlotted},onClick:()=>this.onContentClick()},t("slot",{key:"3285cc16452a7a6936a542dd26758beebb515972",name:"application-sidebar",onSlotchange:()=>this.applicationSidebarSlotted=l(this.applicationSidebarSlot)})),t("div",{key:"c6d022a1a5c220ed088adeba49ab5daa27ff8c77",class:"content-area"},t("main",{key:"8ab781e17318078290a6ce4e1e64dfea43d5ae00",class:"content",onClick:()=>this.onContentClick()},t("slot",{key:"24e83882ab5746f4e00a0c16c797ddf4111aa1e8"})),t("footer",{key:"3ce838daa8f8f4b4e56cb2626476223d9575177c",class:"footer"},t("slot",{key:"e49d1cd476554dfddca3b538194040ca29394967",name:"bottom"})))))}get hostElement(){return i(this)}static get watchers(){return{breakpoints:["onBreakpointsChange"],theme:["changeTheme"],themeSystemAppearance:["changeTheme"],appSwitchConfig:["onApplicationSidebarChange"],applicationSidebarSlotted:["onApplicationSidebarChange"]}}};d.style=h;export{d as ix_application};
2
+ //# sourceMappingURL=p-35d6b656.entry.js.map
@@ -0,0 +1,2 @@
1
+ import{T as t}from"./p-BdCnOrqW.js";const e="data-ix-theme";const s="data-ix-color-schema";class i{get themeChanged(){return this._themeChanged}get schemaChanged(){return this._schemaChanged}hasVariantSuffix(t){return t.endsWith(this.suffixDark)||t.endsWith(this.suffixLight)}isThemeClass(t){return t.startsWith(this.prefixTheme)&&this.hasVariantSuffix(t)}setTheme(t,s=false){if(this.isThemeClass(t)){this.replaceThemeClass(t)}else{document.documentElement.setAttribute(e,t)}if(s){const t=n();this.setVariant(t)}}replaceThemeClass(t){const e=[];Array.from(document.documentElement.classList).filter((t=>t&&this.isThemeClass(t))).forEach((t=>{e.push(t)}));document.documentElement.classList.remove(...e);document.documentElement.classList.add(t)}toggleMode(){if(document.documentElement.hasAttribute(s)){const t=this.getDataColorSchema(document.documentElement);document.documentElement.setAttribute(s,t==="dark"?"light":"dark");return}const t=[];Array.from(document.documentElement.classList).filter((t=>t&&this.isThemeClass(t))).forEach((e=>{t.push(e)}));if(t.length===0){document.documentElement.classList.add(this.getOppositeMode(this.defaultTheme));return}t.forEach((t=>{document.documentElement.classList.replace(t,this.getOppositeMode(t))}))}getDataColorSchema(t){return t.getAttribute(s)}getCurrentTheme(){var t;return(t=Array.from(document.documentElement.classList).find((t=>this.isThemeClass(t))))!==null&&t!==void 0?t:`theme-${document.documentElement.getAttribute(e)||"classic"}-${document.documentElement.getAttribute(s)||n()}`}setVariant(t=n()){if(this.getDataColorSchema(document.documentElement)){document.documentElement.setAttribute(s,t);return}const e=this.getCurrentTheme();document.documentElement.classList.remove(e);if(e.endsWith(this.suffixDark)){document.documentElement.classList.add(e.replace(/-dark$/g,`-${t}`))}if(e.endsWith(this.suffixLight)){document.documentElement.classList.add(e.replace(/-light$/g,`-${t}`))}document.documentElement.setAttribute(s,t)}getOppositeMode(t){if(t.endsWith(this.suffixDark)){return t.replace(/-dark$/g,this.suffixLight)}if(t.endsWith(this.suffixLight)){return t.replace(/-light$/g,this.suffixDark)}return""}splitMutations(t){const i=t.filter((t=>t.attributeName==="class"));const n=t.filter((t=>t.attributeName===e||t.attributeName===s));return{classMutations:i,dataMutations:n}}handleClassMutations(t){return t.forEach((t=>{const{target:e}=t;e.classList.forEach((e=>{var s;if(this.isThemeClass(e)&&!((s=t.oldValue)===null||s===void 0?void 0:s.includes(e))){this._themeChanged.emit(e)}}))}))}handleDataMutations(t){return t.forEach((t=>{const{target:i}=t;const n=i.attributes.getNamedItem(e);if((n===null||n===void 0?void 0:n.value)&&t.oldValue!==n.value){this._themeChanged.emit(n.value)}const r=i.attributes.getNamedItem(s);if((r===null||r===void 0?void 0:r.value)&&t.oldValue!==r.value){this._schemaChanged.emit(r.value)}}))}registerMutationObservers(){if(typeof window==="undefined"){return}if(!("MutationObserver"in window)){console.warn("ThemeSwitcher not supported by your browser. Missing MutationObserver API");return}const t={attributeFilter:["class",e,s],attributeOldValue:true};const i=t=>{const{classMutations:e,dataMutations:s}=this.splitMutations(t);this.handleClassMutations(e);this.handleDataMutations(s)};this.mutationObserver=new MutationObserver(i);this.mutationObserver.observe(document.documentElement,t)}constructor(){this.prefixTheme="theme-";this.suffixLight="-light";this.suffixDark="-dark";this.defaultTheme="theme-classic-dark";this._themeChanged=new t;this._schemaChanged=new t;this.registerMutationObservers()}}const n=()=>{const t=window.matchMedia("(prefers-color-scheme: dark)");if(t.matches){return"dark"}return"light"};const r=new i;export{n as g,r as t};
2
+ //# sourceMappingURL=p-CsHYWHE6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p-CsHYWHE6.js","sources":["src/components/utils/theme-switcher.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2025 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { type LiteralStringUnion } from './type-helper';\nimport { TypedEvent } from './typed-event';\n\nexport type ThemeVariant = 'light' | 'dark';\n\nconst dataIxTheme = 'data-ix-theme';\nconst dataIxColorSchema = 'data-ix-color-schema';\n\nclass ThemeSwitcher {\n readonly prefixTheme = 'theme-';\n readonly suffixLight = '-light';\n readonly suffixDark = '-dark';\n readonly defaultTheme = 'theme-classic-dark';\n\n mutationObserver?: MutationObserver;\n _themeChanged = new TypedEvent<string>();\n _schemaChanged = new TypedEvent<string>();\n\n public get themeChanged() {\n return this._themeChanged;\n }\n\n public get schemaChanged() {\n return this._schemaChanged;\n }\n\n public hasVariantSuffix(className: string) {\n return (\n className.endsWith(this.suffixDark) ||\n className.endsWith(this.suffixLight)\n );\n }\n\n private isThemeClass(className: string) {\n return (\n className.startsWith(this.prefixTheme) && this.hasVariantSuffix(className)\n );\n }\n\n public setTheme(themeName: string, systemAppearance = false) {\n if (this.isThemeClass(themeName)) {\n this.replaceThemeClass(themeName);\n } else {\n document.documentElement.setAttribute(dataIxTheme, themeName);\n }\n\n if (systemAppearance) {\n const currentSystemAppearance = getCurrentSystemAppearance();\n this.setVariant(currentSystemAppearance);\n }\n }\n\n private replaceThemeClass(themeName: string) {\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n document.documentElement.classList.remove(...oldThemes);\n document.documentElement.classList.add(themeName);\n }\n\n public toggleMode() {\n if (document.documentElement.hasAttribute(dataIxColorSchema)) {\n const currentSchema = this.getDataColorSchema(document.documentElement)!;\n document.documentElement.setAttribute(\n dataIxColorSchema,\n currentSchema === 'dark' ? 'light' : 'dark'\n );\n return;\n }\n\n const oldThemes: string[] = [];\n Array.from(document.documentElement.classList)\n .filter((className) => className && this.isThemeClass(className))\n .forEach((className) => {\n oldThemes.push(className);\n });\n\n if (oldThemes.length === 0) {\n document.documentElement.classList.add(\n this.getOppositeMode(this.defaultTheme)\n );\n return;\n }\n\n oldThemes.forEach((themeName) => {\n document.documentElement.classList.replace(\n themeName,\n this.getOppositeMode(themeName)\n );\n });\n }\n\n private getDataColorSchema(target: HTMLElement) {\n return target.getAttribute(dataIxColorSchema);\n }\n\n public getCurrentTheme() {\n return (\n Array.from(document.documentElement.classList).find((className) =>\n this.isThemeClass(className)\n ) ??\n `theme-${\n document.documentElement.getAttribute(dataIxTheme) || 'classic'\n }-${\n document.documentElement.getAttribute(dataIxColorSchema) ||\n getCurrentSystemAppearance()\n }`\n );\n }\n\n public setVariant(variant: ThemeVariant = getCurrentSystemAppearance()) {\n if (this.getDataColorSchema(document.documentElement)) {\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n return;\n }\n\n const currentTheme = this.getCurrentTheme();\n document.documentElement.classList.remove(currentTheme);\n\n if (currentTheme.endsWith(this.suffixDark)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-dark$/g, `-${variant}`)\n );\n }\n\n if (currentTheme.endsWith(this.suffixLight)) {\n document.documentElement.classList.add(\n currentTheme.replace(/-light$/g, `-${variant}`)\n );\n }\n\n document.documentElement.setAttribute(dataIxColorSchema, variant);\n }\n\n private getOppositeMode(themeName: string) {\n if (themeName.endsWith(this.suffixDark)) {\n return themeName.replace(/-dark$/g, this.suffixLight);\n }\n\n if (themeName.endsWith(this.suffixLight)) {\n return themeName.replace(/-light$/g, this.suffixDark);\n }\n\n return '';\n }\n\n private splitMutations(mutations: MutationRecord[]) {\n const classMutations = mutations.filter(\n (mutation) => mutation.attributeName === 'class'\n );\n\n const dataMutations = mutations.filter(\n (mutation) =>\n mutation.attributeName === dataIxTheme ||\n mutation.attributeName === dataIxColorSchema\n );\n\n return { classMutations, dataMutations };\n }\n\n private handleClassMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n (target as HTMLElement).classList.forEach((className) => {\n if (\n this.isThemeClass(className) &&\n !mutation.oldValue?.includes(className)\n ) {\n this._themeChanged.emit(className);\n }\n });\n });\n }\n\n private handleDataMutations(mutations: MutationRecord[]) {\n return mutations.forEach((mutation) => {\n const { target } = mutation;\n const theme = (target as Element).attributes.getNamedItem(dataIxTheme);\n if (theme?.value && mutation.oldValue !== theme.value) {\n this._themeChanged.emit(theme.value);\n }\n\n const colorSchema = (target as Element).attributes.getNamedItem(\n dataIxColorSchema\n );\n if (colorSchema?.value && mutation.oldValue !== colorSchema.value) {\n this._schemaChanged.emit(colorSchema.value);\n }\n });\n }\n\n private registerMutationObservers() {\n if (typeof (window as any) === 'undefined') {\n return;\n }\n\n if (!('MutationObserver' in window)) {\n console.warn(\n 'ThemeSwitcher not supported by your browser. Missing MutationObserver API'\n );\n return;\n }\n\n const mutationObserverConfig = {\n attributeFilter: ['class', dataIxTheme, dataIxColorSchema],\n attributeOldValue: true,\n };\n\n const handleMutations = (mutations: MutationRecord[]) => {\n const { classMutations, dataMutations } = this.splitMutations(mutations);\n\n this.handleClassMutations(classMutations);\n this.handleDataMutations(dataMutations);\n };\n\n this.mutationObserver = new MutationObserver(handleMutations);\n this.mutationObserver.observe(\n document.documentElement,\n mutationObserverConfig\n );\n }\n\n public constructor() {\n this.registerMutationObservers();\n }\n}\n\nexport type IxTheme = LiteralStringUnion<\n 'classic' | 'classic-dark' | 'classic-light'\n>;\n\nexport const getCurrentSystemAppearance = (): ThemeVariant => {\n const matchMedia = window.matchMedia('(prefers-color-scheme: dark)');\n\n if (matchMedia.matches) {\n return 'dark';\n }\n\n return 'light';\n};\n\nexport const themeSwitcher = new ThemeSwitcher();\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAOH,MAAM,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