@kaizen/components 0.0.0-canary-cg-test-20231011234329 → 0.0.0-canary-cg-test-20231012014902

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 (36) hide show
  1. package/dist/cjs/KaizenProvider/KaizenProvider.cjs +2 -3
  2. package/dist/cjs/KaizenProvider/KaizenProvider.cjs.map +1 -1
  3. package/dist/cjs/KaizenProvider/ThemeProvider/ThemeProvider.cjs +10 -22
  4. package/dist/cjs/KaizenProvider/ThemeProvider/ThemeProvider.cjs.map +1 -1
  5. package/dist/cjs/KaizenProvider/ThemeProvider/useThemeManager.cjs +37 -0
  6. package/dist/cjs/KaizenProvider/ThemeProvider/useThemeManager.cjs.map +1 -0
  7. package/dist/cjs/dts/KaizenProvider/KaizenProvider.d.ts +4 -4
  8. package/dist/cjs/dts/KaizenProvider/ThemeProvider/ThemeProvider.d.ts +8 -7
  9. package/dist/cjs/dts/KaizenProvider/ThemeProvider/index.d.ts +0 -1
  10. package/dist/cjs/dts/KaizenProvider/ThemeProvider/useThemeManager.d.ts +6 -0
  11. package/dist/cjs/index.cjs +0 -2
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/index.css +4 -4
  14. package/dist/esm/KaizenProvider/KaizenProvider.mjs +2 -3
  15. package/dist/esm/KaizenProvider/KaizenProvider.mjs.map +1 -1
  16. package/dist/esm/KaizenProvider/ThemeProvider/ThemeProvider.mjs +11 -23
  17. package/dist/esm/KaizenProvider/ThemeProvider/ThemeProvider.mjs.map +1 -1
  18. package/dist/esm/KaizenProvider/ThemeProvider/useThemeManager.mjs +35 -0
  19. package/dist/esm/KaizenProvider/ThemeProvider/useThemeManager.mjs.map +1 -0
  20. package/dist/esm/dts/KaizenProvider/KaizenProvider.d.ts +4 -4
  21. package/dist/esm/dts/KaizenProvider/ThemeProvider/ThemeProvider.d.ts +8 -7
  22. package/dist/esm/dts/KaizenProvider/ThemeProvider/index.d.ts +0 -1
  23. package/dist/esm/dts/KaizenProvider/ThemeProvider/useThemeManager.d.ts +6 -0
  24. package/dist/esm/index.css +1 -1
  25. package/dist/esm/index.mjs +0 -1
  26. package/dist/esm/index.mjs.map +1 -1
  27. package/dist/index.d.ts +15 -41
  28. package/dist/styles.css +1 -1
  29. package/future/package.json +2 -2
  30. package/package.json +3 -3
  31. package/dist/cjs/KaizenProvider/ThemeProvider/ThemeManager.cjs +0 -88
  32. package/dist/cjs/KaizenProvider/ThemeProvider/ThemeManager.cjs.map +0 -1
  33. package/dist/cjs/dts/KaizenProvider/ThemeProvider/ThemeManager.d.ts +0 -25
  34. package/dist/esm/KaizenProvider/ThemeProvider/ThemeManager.mjs +0 -86
  35. package/dist/esm/KaizenProvider/ThemeProvider/ThemeManager.mjs.map +0 -1
  36. package/dist/esm/dts/KaizenProvider/ThemeProvider/ThemeManager.d.ts +0 -25
@@ -1,5 +1,5 @@
1
1
  {
2
- "main": "../dist/cjs/future.js",
3
- "module": "../dist/esm/future.js",
2
+ "main": "../dist/cjs/future.cjs",
3
+ "module": "../dist/esm/future.mjs",
4
4
  "types": "../dist/esm/dts/__future__/index.d.ts"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "0.0.0-canary-cg-test-20231011234329",
3
+ "version": "0.0.0-canary-cg-test-20231012014902",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -18,8 +18,8 @@
18
18
  "icons",
19
19
  "locales"
20
20
  ],
21
- "main": "dist/cjs/index.js",
22
- "module": "dist/esm/index.js",
21
+ "main": "dist/cjs/index.cjs",
22
+ "module": "dist/esm/index.mjs",
23
23
  "types": "dist/index.d.ts",
24
24
  "sideEffects": false,
25
25
  "scripts": {
@@ -1,88 +0,0 @@
1
- 'use strict';
2
-
3
- var designTokens = require('@kaizen/design-tokens');
4
-
5
- /**
6
- * Use this class to set and apply themes, and to access or subscribe to the currently active one.
7
- * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
8
- * and the ability to update them in JavaScript - a framework agnostic method.
9
- *
10
- * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
11
- */
12
- var ThemeManager = /** @class */function () {
13
- function ThemeManager(theme, rootElementId, /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
14
- apply) {
15
- if (rootElementId === void 0) {
16
- rootElementId = "";
17
- }
18
- if (apply === void 0) {
19
- apply = true;
20
- }
21
- var _this = this;
22
- this.themeChangeListeners = [];
23
- this.rootElement = null;
24
- this.getRootElement = function () {
25
- return _this.rootElement;
26
- };
27
- this.getRootElementId = function () {
28
- return _this.rootElementId;
29
- };
30
- this.getCurrentTheme = function () {
31
- return _this.theme;
32
- };
33
- this.setRootElement = function (element) {
34
- _this.rootElement = element;
35
- };
36
- this.setRootElementId = function (rootElementId) {
37
- return _this.rootElementId = rootElementId;
38
- };
39
- this.setAndApplyTheme = function (theme, force) {
40
- if (!force) {
41
- if (_this.theme === theme) return;
42
- }
43
- _this.theme = theme;
44
- _this.applyCurrentTheme();
45
- _this.notifyThemeChangeListeners(theme);
46
- };
47
- this.addThemeChangeListener = function (listener) {
48
- _this.themeChangeListeners.push(listener);
49
- };
50
- this.removeThemeChangeListener = function (listener) {
51
- _this.themeChangeListeners = _this.themeChangeListeners.filter(function (l) {
52
- return l !== listener;
53
- });
54
- };
55
- this.applyCurrentTheme = function () {
56
- var _a;
57
- if (typeof window !== "undefined") {
58
- _this.setRootElement((_a = document.getElementById(_this.rootElementId)) !== null && _a !== void 0 ? _a : document.documentElement);
59
- var cssVariableDefinitions = designTokens.makeCssVariableDefinitionsMap(_this.theme);
60
- Object.entries(cssVariableDefinitions).forEach(function (_a) {
61
- var _b;
62
- var key = _a[0],
63
- value = _a[1];
64
- (_b = _this.rootElement) === null || _b === void 0 ? void 0 : _b.style.setProperty(key, value);
65
- });
66
- }
67
- };
68
- this.notifyThemeChangeListeners = function (theme) {
69
- _this.themeChangeListeners.forEach(function (listener) {
70
- return listener(theme);
71
- });
72
- };
73
- /*
74
- For some reason, storybook likes this way of defining class properties better.
75
- If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
76
- */
77
- this.theme = theme;
78
- this.rootElementId = rootElementId;
79
- if (apply) this.applyCurrentTheme();
80
- }
81
- return ThemeManager;
82
- }();
83
- // I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
84
- // For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases
85
- /* export const defaultThemeManager = new ThemeManager(defaultTheme) */
86
-
87
- exports.ThemeManager = ThemeManager;
88
- //# sourceMappingURL=ThemeManager.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeManager.cjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeManager.ts"],"sourcesContent":["import {\n makeCssVariableDefinitionsMap,\n Theme as BaseTheme,\n} from \"@kaizen/design-tokens\"\n\n/**\n * Use this class to set and apply themes, and to access or subscribe to the currently active one.\n * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,\n * and the ability to update them in JavaScript - a framework agnostic method.\n *\n * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.\n */\n\nexport class ThemeManager<Theme extends BaseTheme = BaseTheme> {\n private themeChangeListeners = [] as Array<(theme: Theme) => void>\n private theme: Theme\n private rootElement: HTMLElement | null = null\n private rootElementId: string\n\n constructor(\n theme: Theme,\n rootElementId: string = \"\",\n /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */\n apply: boolean = true\n ) {\n /*\n For some reason, storybook likes this way of defining class properties better.\n If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.\n */\n this.theme = theme\n this.rootElementId = rootElementId\n if (apply) this.applyCurrentTheme()\n }\n\n public getRootElement = (): HTMLElement | null => this.rootElement\n public getRootElementId = (): string => this.rootElementId\n public getCurrentTheme = (): Theme => this.theme\n\n public setRootElement = (element: HTMLElement): void => {\n this.rootElement = element\n }\n public setRootElementId = (rootElementId: string): string =>\n (this.rootElementId = rootElementId)\n public setAndApplyTheme = (theme: Theme, force?: boolean): void => {\n if (!force) {\n if (this.theme === theme) return\n }\n this.theme = theme\n this.applyCurrentTheme()\n this.notifyThemeChangeListeners(theme)\n }\n\n public addThemeChangeListener = (listener: (theme: Theme) => void): void => {\n this.themeChangeListeners.push(listener)\n }\n public removeThemeChangeListener = (\n listener: (theme: Theme) => void\n ): void => {\n this.themeChangeListeners = this.themeChangeListeners.filter(\n l => l !== listener\n )\n }\n public applyCurrentTheme = (): void => {\n if (typeof window !== \"undefined\") {\n this.setRootElement(\n document.getElementById(this.rootElementId) ?? document.documentElement\n )\n const cssVariableDefinitions = makeCssVariableDefinitionsMap(this.theme)\n Object.entries(cssVariableDefinitions).forEach(([key, value]) => {\n this.rootElement?.style.setProperty(key, value)\n })\n }\n }\n\n private notifyThemeChangeListeners = (theme: Theme): void => {\n this.themeChangeListeners.forEach(listener => listener(theme))\n }\n}\n\n// I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.\n// For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases\n/* export const defaultThemeManager = new ThemeManager(defaultTheme) */\n"],"names":["ThemeManager","theme","rootElementId","apply","_this","themeChangeListeners","rootElement","getRootElement","getRootElementId","getCurrentTheme","setRootElement","element","setRootElementId","setAndApplyTheme","force","applyCurrentTheme","notifyThemeChangeListeners","addThemeChangeListener","listener","push","removeThemeChangeListener","filter","l","window","_a","document","getElementById","documentElement","cssVariableDefinitions","makeCssVariableDefinitionsMap","Object","entries","forEach","key","value","_b","style","setProperty"],"mappings":";;;;AAKA;;;;;;AAMG;AAEH,IAAAA,YAAA,gBAAA,YAAA;EAME,SACEA,YAAAA,CAAAC,KAAY,EACZC,aAA0B;EAE1BC,KAAqB,EAAA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AAC,EAAA;AAED;AACA;AACA;;"}
@@ -1,25 +0,0 @@
1
- import { Theme as BaseTheme } from "@kaizen/design-tokens";
2
- /**
3
- * Use this class to set and apply themes, and to access or subscribe to the currently active one.
4
- * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
5
- * and the ability to update them in JavaScript - a framework agnostic method.
6
- *
7
- * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
8
- */
9
- export declare class ThemeManager<Theme extends BaseTheme = BaseTheme> {
10
- private themeChangeListeners;
11
- private theme;
12
- private rootElement;
13
- private rootElementId;
14
- constructor(theme: Theme, rootElementId?: string, apply?: boolean);
15
- getRootElement: () => HTMLElement | null;
16
- getRootElementId: () => string;
17
- getCurrentTheme: () => Theme;
18
- setRootElement: (element: HTMLElement) => void;
19
- setRootElementId: (rootElementId: string) => string;
20
- setAndApplyTheme: (theme: Theme, force?: boolean) => void;
21
- addThemeChangeListener: (listener: (theme: Theme) => void) => void;
22
- removeThemeChangeListener: (listener: (theme: Theme) => void) => void;
23
- applyCurrentTheme: () => void;
24
- private notifyThemeChangeListeners;
25
- }
@@ -1,86 +0,0 @@
1
- import { makeCssVariableDefinitionsMap } from '@kaizen/design-tokens';
2
-
3
- /**
4
- * Use this class to set and apply themes, and to access or subscribe to the currently active one.
5
- * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
6
- * and the ability to update them in JavaScript - a framework agnostic method.
7
- *
8
- * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
9
- */
10
- var ThemeManager = /** @class */function () {
11
- function ThemeManager(theme, rootElementId, /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
12
- apply) {
13
- if (rootElementId === void 0) {
14
- rootElementId = "";
15
- }
16
- if (apply === void 0) {
17
- apply = true;
18
- }
19
- var _this = this;
20
- this.themeChangeListeners = [];
21
- this.rootElement = null;
22
- this.getRootElement = function () {
23
- return _this.rootElement;
24
- };
25
- this.getRootElementId = function () {
26
- return _this.rootElementId;
27
- };
28
- this.getCurrentTheme = function () {
29
- return _this.theme;
30
- };
31
- this.setRootElement = function (element) {
32
- _this.rootElement = element;
33
- };
34
- this.setRootElementId = function (rootElementId) {
35
- return _this.rootElementId = rootElementId;
36
- };
37
- this.setAndApplyTheme = function (theme, force) {
38
- if (!force) {
39
- if (_this.theme === theme) return;
40
- }
41
- _this.theme = theme;
42
- _this.applyCurrentTheme();
43
- _this.notifyThemeChangeListeners(theme);
44
- };
45
- this.addThemeChangeListener = function (listener) {
46
- _this.themeChangeListeners.push(listener);
47
- };
48
- this.removeThemeChangeListener = function (listener) {
49
- _this.themeChangeListeners = _this.themeChangeListeners.filter(function (l) {
50
- return l !== listener;
51
- });
52
- };
53
- this.applyCurrentTheme = function () {
54
- var _a;
55
- if (typeof window !== "undefined") {
56
- _this.setRootElement((_a = document.getElementById(_this.rootElementId)) !== null && _a !== void 0 ? _a : document.documentElement);
57
- var cssVariableDefinitions = makeCssVariableDefinitionsMap(_this.theme);
58
- Object.entries(cssVariableDefinitions).forEach(function (_a) {
59
- var _b;
60
- var key = _a[0],
61
- value = _a[1];
62
- (_b = _this.rootElement) === null || _b === void 0 ? void 0 : _b.style.setProperty(key, value);
63
- });
64
- }
65
- };
66
- this.notifyThemeChangeListeners = function (theme) {
67
- _this.themeChangeListeners.forEach(function (listener) {
68
- return listener(theme);
69
- });
70
- };
71
- /*
72
- For some reason, storybook likes this way of defining class properties better.
73
- If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
74
- */
75
- this.theme = theme;
76
- this.rootElementId = rootElementId;
77
- if (apply) this.applyCurrentTheme();
78
- }
79
- return ThemeManager;
80
- }();
81
- // I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
82
- // For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases
83
- /* export const defaultThemeManager = new ThemeManager(defaultTheme) */
84
-
85
- export { ThemeManager };
86
- //# sourceMappingURL=ThemeManager.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeManager.mjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeManager.ts"],"sourcesContent":["import {\n makeCssVariableDefinitionsMap,\n Theme as BaseTheme,\n} from \"@kaizen/design-tokens\"\n\n/**\n * Use this class to set and apply themes, and to access or subscribe to the currently active one.\n * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,\n * and the ability to update them in JavaScript - a framework agnostic method.\n *\n * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.\n */\n\nexport class ThemeManager<Theme extends BaseTheme = BaseTheme> {\n private themeChangeListeners = [] as Array<(theme: Theme) => void>\n private theme: Theme\n private rootElement: HTMLElement | null = null\n private rootElementId: string\n\n constructor(\n theme: Theme,\n rootElementId: string = \"\",\n /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */\n apply: boolean = true\n ) {\n /*\n For some reason, storybook likes this way of defining class properties better.\n If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.\n */\n this.theme = theme\n this.rootElementId = rootElementId\n if (apply) this.applyCurrentTheme()\n }\n\n public getRootElement = (): HTMLElement | null => this.rootElement\n public getRootElementId = (): string => this.rootElementId\n public getCurrentTheme = (): Theme => this.theme\n\n public setRootElement = (element: HTMLElement): void => {\n this.rootElement = element\n }\n public setRootElementId = (rootElementId: string): string =>\n (this.rootElementId = rootElementId)\n public setAndApplyTheme = (theme: Theme, force?: boolean): void => {\n if (!force) {\n if (this.theme === theme) return\n }\n this.theme = theme\n this.applyCurrentTheme()\n this.notifyThemeChangeListeners(theme)\n }\n\n public addThemeChangeListener = (listener: (theme: Theme) => void): void => {\n this.themeChangeListeners.push(listener)\n }\n public removeThemeChangeListener = (\n listener: (theme: Theme) => void\n ): void => {\n this.themeChangeListeners = this.themeChangeListeners.filter(\n l => l !== listener\n )\n }\n public applyCurrentTheme = (): void => {\n if (typeof window !== \"undefined\") {\n this.setRootElement(\n document.getElementById(this.rootElementId) ?? document.documentElement\n )\n const cssVariableDefinitions = makeCssVariableDefinitionsMap(this.theme)\n Object.entries(cssVariableDefinitions).forEach(([key, value]) => {\n this.rootElement?.style.setProperty(key, value)\n })\n }\n }\n\n private notifyThemeChangeListeners = (theme: Theme): void => {\n this.themeChangeListeners.forEach(listener => listener(theme))\n }\n}\n\n// I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.\n// For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases\n/* export const defaultThemeManager = new ThemeManager(defaultTheme) */\n"],"names":["ThemeManager","theme","rootElementId","apply","_this","themeChangeListeners","rootElement","getRootElement","getRootElementId","getCurrentTheme","setRootElement","element","setRootElementId","setAndApplyTheme","force","applyCurrentTheme","notifyThemeChangeListeners","addThemeChangeListener","listener","push","removeThemeChangeListener","filter","l","window","_a","document","getElementById","documentElement","cssVariableDefinitions","makeCssVariableDefinitionsMap","Object","entries","forEach","key","value","_b","style","setProperty"],"mappings":";;AAKA;;;;;;AAMG;AAEH,IAAAA,YAAA,gBAAA,YAAA;EAME,SACEA,YAAAA,CAAAC,KAAY,EACZC,aAA0B;EAE1BC,KAAqB,EAAA;IAFrB,IAAAD,aAAA,KAAA,KAAA,CAAA,EAAA;MAAAA,aAA0B,GAAA,EAAA;IAAA;IAE1B,IAAAC,KAAA,KAAA,KAAA,CAAA,EAAA;MAAAA,KAAqB,GAAA,IAAA;IAAA;IAJvB,IAaCC,KAAA,GAAA,IAAA;IAlBO,IAAoB,CAAAC,oBAAA,GAAG,EAAmC;IAE1D,IAAW,CAAAC,WAAA,GAAuB,IAAI;IAkBvC,IAAc,CAAAC,cAAA,GAAG;MAA0B,OAAAH,KAAI,CAACE,WAAW;IAAA,CAAA;IAC3D,IAAgB,CAAAE,gBAAA,GAAG;MAAc,OAAAJ,KAAI,CAACF,aAAa;IAAA,CAAA;IACnD,IAAe,CAAAO,eAAA,GAA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AAC;QACxE6B,MAAM,CAACC,OAAO,CAACH,sBAAsB,CAAC,CAACI,OAAO,CAAC,UAACR,EAAY,EAAA;;cAAXS,GAAG,GAAAT,EAAA,CAAA,CAAA,CAAA;YAAEU,KAAK,GAAAV,EAAA,CAAA,CAAA,CAAA;UACzD,CAAAW,EAAA,GAAA/B,KAAI,CAACE,WAAW,MAAA,IAAA,IAAA6B,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAAA,EAAA,CAAEC,KAAK,CAACC,WAAW,CAACJ,GAAG,EAAEC,KAAK,CAAC;QACjD,CAAC,CAAC;MACH;IACH,CAAC;IAEO,IAA0B,CAAAlB,0BAAA,GAAG,UAACf,KAAY,EAAA;MAChDG,KAAI,CAACC,oBAAoB,CAAC2B,OAAO,CAAC,UAAAd,QAAQ,EAAA;QAAI,OAAAA,QAAQ,CAACjB,KAAK,CAAC;MAAf,CAAe,CAAC;IAChE,CAAC;IAnDC;;;AAGE;IACF,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,aAAa,GAAGA,aAAa;IAClC,IAAIC,KAAK,EAAE,IAAI,CAACY,iBAAiB,CAAA,CAAE;EACpC;EA6CH,OAACf,YAAA;AAAD,CAAC,EAAA;AAED;AACA;AACA;;"}
@@ -1,25 +0,0 @@
1
- import { Theme as BaseTheme } from "@kaizen/design-tokens";
2
- /**
3
- * Use this class to set and apply themes, and to access or subscribe to the currently active one.
4
- * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
5
- * and the ability to update them in JavaScript - a framework agnostic method.
6
- *
7
- * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
8
- */
9
- export declare class ThemeManager<Theme extends BaseTheme = BaseTheme> {
10
- private themeChangeListeners;
11
- private theme;
12
- private rootElement;
13
- private rootElementId;
14
- constructor(theme: Theme, rootElementId?: string, apply?: boolean);
15
- getRootElement: () => HTMLElement | null;
16
- getRootElementId: () => string;
17
- getCurrentTheme: () => Theme;
18
- setRootElement: (element: HTMLElement) => void;
19
- setRootElementId: (rootElementId: string) => string;
20
- setAndApplyTheme: (theme: Theme, force?: boolean) => void;
21
- addThemeChangeListener: (listener: (theme: Theme) => void) => void;
22
- removeThemeChangeListener: (listener: (theme: Theme) => void) => void;
23
- applyCurrentTheme: () => void;
24
- private notifyThemeChangeListeners;
25
- }