@kaizen/design-tokens 9.0.5 → 10.0.1

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 (71) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/react/ThemeProvider.d.ts +1 -1
  5. package/dist/react/ThemeProvider.d.ts.map +1 -1
  6. package/dist/react/ThemeProvider.js +32 -8
  7. package/dist/react/ThemeProvider.js.map +1 -0
  8. package/dist/react/index.js +1 -0
  9. package/dist/react/index.js.map +1 -0
  10. package/dist/src/ThemeManager.d.ts +4 -1
  11. package/dist/src/ThemeManager.d.ts.map +1 -1
  12. package/dist/src/ThemeManager.js +10 -2
  13. package/dist/src/ThemeManager.js.map +1 -0
  14. package/dist/src/lib/addExtraThemeEntries.js +1 -0
  15. package/dist/src/lib/addExtraThemeEntries.js.map +1 -0
  16. package/dist/src/lib/cssVariables.js +1 -0
  17. package/dist/src/lib/cssVariables.js.map +1 -0
  18. package/dist/src/lib/makeCssVariableDefinitionsMap.js +1 -0
  19. package/dist/src/lib/makeCssVariableDefinitionsMap.js.map +1 -0
  20. package/dist/src/lib/makeCssVariableTheme.js +1 -0
  21. package/dist/src/lib/makeCssVariableTheme.js.map +1 -0
  22. package/dist/src/lib/mapLeafsOfObject.js +1 -0
  23. package/dist/src/lib/mapLeafsOfObject.js.map +1 -0
  24. package/dist/src/themes/heart.js +1 -0
  25. package/dist/src/themes/heart.js.map +1 -0
  26. package/dist/src/themes/index.js +1 -0
  27. package/dist/src/themes/index.js.map +1 -0
  28. package/dist/src/types.js +1 -0
  29. package/dist/src/types.js.map +1 -0
  30. package/package.json +2 -2
  31. package/react/ThemeProvider.tsx +49 -8
  32. package/src/ThemeManager.ts +9 -1
  33. package/react/ThemeProvider.d.ts +0 -12
  34. package/react/ThemeProvider.js +0 -45
  35. package/react/ThemeProvider.js.map +0 -1
  36. package/react/index.d.ts +0 -1
  37. package/react/index.js +0 -14
  38. package/react/index.js.map +0 -1
  39. package/src/ThemeManager.d.ts +0 -22
  40. package/src/ThemeManager.js +0 -68
  41. package/src/ThemeManager.js.map +0 -1
  42. package/src/lib/__tests__/themeForTesting.d.ts +0 -38
  43. package/src/lib/__tests__/themeForTesting.js +0 -21
  44. package/src/lib/__tests__/themeForTesting.js.map +0 -1
  45. package/src/lib/addExtraThemeEntries.d.ts +0 -24
  46. package/src/lib/addExtraThemeEntries.js +0 -60
  47. package/src/lib/addExtraThemeEntries.js.map +0 -1
  48. package/src/lib/cssVariables.d.ts +0 -22
  49. package/src/lib/cssVariables.js +0 -36
  50. package/src/lib/cssVariables.js.map +0 -1
  51. package/src/lib/makeCssVariableDefinitionsMap.d.ts +0 -29
  52. package/src/lib/makeCssVariableDefinitionsMap.js +0 -58
  53. package/src/lib/makeCssVariableDefinitionsMap.js.map +0 -1
  54. package/src/lib/makeCssVariableTheme.d.ts +0 -34
  55. package/src/lib/makeCssVariableTheme.js +0 -58
  56. package/src/lib/makeCssVariableTheme.js.map +0 -1
  57. package/src/lib/mapLeafsOfObject.d.ts +0 -22
  58. package/src/lib/mapLeafsOfObject.js +0 -62
  59. package/src/lib/mapLeafsOfObject.js.map +0 -1
  60. package/src/lib/patterns.d.ts +0 -2
  61. package/src/lib/patterns.js +0 -6
  62. package/src/lib/patterns.js.map +0 -1
  63. package/src/themes/heart.d.ts +0 -2
  64. package/src/themes/heart.js +0 -288
  65. package/src/themes/heart.js.map +0 -1
  66. package/src/themes/index.d.ts +0 -2
  67. package/src/themes/index.js +0 -15
  68. package/src/themes/index.js.map +0 -1
  69. package/src/types.d.ts +0 -205
  70. package/src/types.js +0 -3
  71. package/src/types.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,82 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.0.1](https://github.com/cultureamp/kaizen-design-system/compare/@kaizen/design-tokens@10.0.0...@kaizen/design-tokens@10.0.1) (2022-09-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * be able to specify root element applying theme ([#2951](https://github.com/cultureamp/kaizen-design-system/issues/2951)) ([6498509](https://github.com/cultureamp/kaizen-design-system/commit/6498509d7e198421657e640dbe9f953a918500f3))
12
+
13
+
14
+
15
+
16
+
17
+ # [10.0.0](https://github.com/cultureamp/kaizen-design-system/compare/@kaizen/design-tokens@9.1.0...@kaizen/design-tokens@10.0.0) (2022-09-07)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **design-tokens:** update $typography-paragraph-intro-lede ([#2946](https://github.com/cultureamp/kaizen-design-system/issues/2946)) ([7c6a056](https://github.com/cultureamp/kaizen-design-system/commit/7c6a056829d22dcd075a4dc50745362aa3d2817a)), closes [#2942](https://github.com/cultureamp/kaizen-design-system/issues/2942)
23
+
24
+
25
+ ### BREAKING CHANGES
26
+
27
+ * **design-tokens:** Changes the $typography-paragraph-intro-lede-letter-spacing variable from -0.5px to 0px
28
+
29
+ * chore: release [skip ci]
30
+
31
+ - @kaizen/draft-avatar@2.8.3
32
+ - @kaizen/draft-button@6.2.3
33
+ - @kaizen/draft-collapsible@3.2.3
34
+ - @kaizen/draft-empty-state@5.2.3
35
+ - @kaizen/draft-filter-menu-button@2.6.3
36
+ - @kaizen/draft-form@7.5.3
37
+ - @kaizen/draft-guidance-block@5.2.3
38
+ - @kaizen/draft-hero-card@2.2.3
39
+ - @kaizen/draft-illustration@5.2.3
40
+ - @kaizen/draft-likert-scale-legacy@1.10.4
41
+ - @kaizen/draft-loading-placeholder@2.2.3
42
+ - @kaizen/draft-menu@4.8.3
43
+ - @kaizen/draft-modal@10.5.4
44
+ - @kaizen/draft-popover@5.2.3
45
+ - @kaizen/draft-select@2.5.5
46
+ - @kaizen/draft-split-button@4.2.3
47
+ - @kaizen/draft-table@5.2.4
48
+ - @kaizen/draft-tabs@5.2.3
49
+ - @kaizen/draft-tag@3.2.3
50
+ - @kaizen/draft-tile@5.9.3
51
+ - @kaizen/draft-title-block-zen@7.4.3
52
+ - @kaizen/draft-tooltip@5.4.3
53
+ - @kaizen/draft-well@4.2.3
54
+ - @kaizen/a11y@1.6.3
55
+ - @kaizen/brand-moment@1.12.5
56
+ - @kaizen/button@1.3.3
57
+ - @kaizen/component-library@16.1.0
58
+ - @kaizen/date-picker@5.10.5
59
+ - @kaizen/notification@0.11.3
60
+ - @kaizen/pagination@1.6.3
61
+ - @kaizen/progress-bar@2.2.3
62
+ - @kaizen/rich-text-editor@1.18.5
63
+ - @kaizen/select@1.3.1
64
+ - @kaizen/split-button@1.3.3
65
+ - @kaizen/tabs@1.5.3
66
+
67
+
68
+
69
+
70
+
71
+ # [9.1.0](https://github.com/cultureamp/kaizen-design-system/compare/@kaizen/design-tokens@9.0.5...@kaizen/design-tokens@9.1.0) (2022-08-16)
72
+
73
+
74
+ ### Features
75
+
76
+ * Preload fonts in ThemeProvider & handle default theme ([#2917](https://github.com/cultureamp/kaizen-design-system/issues/2917)) ([67e8efb](https://github.com/cultureamp/kaizen-design-system/commit/67e8efb09f0582ef9e14b408291f1916c7f21eea))
77
+
78
+
79
+
80
+
81
+
6
82
  ## [9.0.5](https://github.com/cultureamp/kaizen-design-system/compare/@kaizen/design-tokens@9.0.4...@kaizen/design-tokens@9.0.5) (2022-07-21)
7
83
 
8
84
  **Note:** Version bump only for package @kaizen/design-tokens
package/dist/index.js CHANGED
@@ -22,3 +22,4 @@ var makeCssVariableTheme_1 = require("./src/lib/makeCssVariableTheme");
22
22
  Object.defineProperty(exports, "makeCSSVariableTheme", { enumerable: true, get: function () { return makeCssVariableTheme_1.makeCSSVariableTheme; } });
23
23
  var mapLeafsOfObject_1 = require("./src/lib/mapLeafsOfObject");
24
24
  Object.defineProperty(exports, "mapLeafsOfObject", { enumerable: true, get: function () { return mapLeafsOfObject_1.mapLeafsOfObject; } });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,4HAA4H;AAC5H,+CAA4B;AAC5B,8CAA2B;AAC3B,qDAAkC;AAClC,0CAAuB;AAEvB,yFAAuF;AAA9E,8IAAA,6BAA6B,OAAA;AACtC,uEAAqE;AAA5D,4HAAA,oBAAoB,OAAA;AAC7B,+DAA6D;AAApD,oHAAA,gBAAgB,OAAA"}
@@ -6,7 +6,7 @@ export declare const ThemeContext: React.Context<Theme>;
6
6
  * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
7
7
  */
8
8
  export declare const ThemeProvider: ({ themeManager, ...props }: {
9
- themeManager: ThemeManager;
9
+ themeManager?: ThemeManager<Theme> | undefined;
10
10
  children: React.ReactNode;
11
11
  }) => JSX.Element;
12
12
  export declare const useTheme: () => Theme;
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../react/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAgB,KAAK,EAAE,MAAM,KAAK,CAAA;AAEvD,eAAO,MAAM,YAAY,sBAA2C,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,aAAa;kBAIV,YAAY;cAChB,MAAM,SAAS;iBAsB1B,CAAA;AAED,eAAO,MAAM,QAAQ,aAAuC,CAAA"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../react/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,YAAY,EAAgB,KAAK,EAAE,MAAM,KAAK,CAAA;AAEvD,eAAO,MAAM,YAAY,sBAA2C,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,aAAa;;cAKd,MAAM,SAAS;iBA+D1B,CAAA;AAED,eAAO,MAAM,QAAQ,aAAuC,CAAA"}
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __rest = (this && this.__rest) || function (s, e) {
3
22
  var t = {};
4
23
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -10,12 +29,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
29
  }
11
30
  return t;
12
31
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
32
  Object.defineProperty(exports, "__esModule", { value: true });
17
33
  exports.useTheme = exports.ThemeProvider = exports.ThemeContext = void 0;
18
- var react_1 = __importDefault(require("react"));
34
+ var react_1 = __importStar(require("react"));
19
35
  var __1 = require("../");
20
36
  exports.ThemeContext = react_1.default.createContext(__1.defaultTheme);
21
37
  /**
@@ -24,21 +40,29 @@ exports.ThemeContext = react_1.default.createContext(__1.defaultTheme);
24
40
  */
25
41
  var ThemeProvider = function (_a) {
26
42
  var themeManager = _a.themeManager, props = __rest(_a, ["themeManager"]);
27
- var _b = react_1.default.useState(themeManager.getCurrentTheme()), theme = _b[0], setTheme = _b[1];
43
+ var themeManagerInstance = (0, react_1.useState)(function () { return themeManager || new __1.ThemeManager(__1.defaultTheme); })[0];
44
+ var _b = react_1.default.useState(themeManagerInstance.getCurrentTheme()), theme = _b[0], setTheme = _b[1];
28
45
  react_1.default.useEffect(function () {
29
46
  var cancelled = false;
30
47
  var listener = function (newTheme) {
31
48
  if (!cancelled)
32
49
  setTheme(newTheme);
33
50
  };
34
- themeManager.addThemeChangeListener(listener);
51
+ themeManagerInstance.addThemeChangeListener(listener);
35
52
  return function () {
36
53
  cancelled = true;
37
- themeManager.removeThemeChangeListener(listener);
54
+ themeManagerInstance.removeThemeChangeListener(listener);
38
55
  };
39
56
  }, []);
40
- return (react_1.default.createElement(exports.ThemeContext.Provider, { value: theme }, props.children));
57
+ return (react_1.default.createElement(react_1.default.Fragment, null,
58
+ react_1.default.createElement(exports.ThemeContext.Provider, { value: theme }, props.children),
59
+ react_1.default.createElement("link", { rel: "preload", href: "https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2", as: "font", type: "font/woff2", crossOrigin: "crossorigin" }),
60
+ react_1.default.createElement("link", { rel: "preload", href: "https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2", as: "font", type: "font/woff2", crossOrigin: "crossorigin" }),
61
+ react_1.default.createElement("link", { rel: "preload", href: "https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2", as: "font", type: "font/woff2", crossOrigin: "crossorigin" }),
62
+ react_1.default.createElement("link", { rel: "preload", href: "https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2", as: "font", type: "font/woff2", crossOrigin: "crossorigin" }),
63
+ react_1.default.createElement("link", { rel: "preload", href: "https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2", as: "font", type: "font/woff2", crossOrigin: "crossorigin" })));
41
64
  };
42
65
  exports.ThemeProvider = ThemeProvider;
43
66
  var useTheme = function () { return react_1.default.useContext(exports.ThemeContext); };
44
67
  exports.useTheme = useTheme;
68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,EAAC,aAAa,GACzB;QACF,wCACE,GAAG,EAAC,SAAS,EACb,IAAI,EAAC,yEAAyE,EAC9E,EAAE,EAAC,MAAM,EACT,IAAI,EAAC,YAAY,EACjB,WAAW,EAAC,aAAa,GACzB;QACF,wCACE,GAAG,EAAC,SAAS,EACb,IAAI,EAAC,sEAAsE,EAC3E,EAAE,EAAC,MAAM,EACT,IAAI,EAAC,YAAY,EACjB,WAAW,EAAC,aAAa,GACzB;QACF,wCACE,GAAG,EAAC,SAAS,EACb,IAAI,EAAC,uEAAuE,EAC5E,EAAE,EAAC,MAAM,EACT,IAAI,EAAC,YAAY,EACjB,WAAW,EAAC,aAAa,GACzB;QACF,wCACE,GAAG,EAAC,SAAS,EACb,IAAI,EAAC,iFAAiF,EACtF,EAAE,EAAC,MAAM,EACT,IAAI,EAAC,YAAY,EACjB,WAAW,EAAC,aAAa,GACzB,CACD,CACJ,CAAA;AACH,CAAC,CAAA;AApEY,QAAA,aAAa,iBAoEzB;AAEM,IAAM,QAAQ,GAAG,cAAM,OAAA,eAAK,CAAC,UAAU,CAAC,oBAAY,CAAC,EAA9B,CAA8B,CAAA;AAA/C,QAAA,QAAQ,YAAuC"}
@@ -11,3 +11,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./ThemeProvider"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../react/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B"}
@@ -10,10 +10,13 @@ export declare class ThemeManager<Theme extends BaseTheme = BaseTheme> {
10
10
  private themeChangeListeners;
11
11
  private theme;
12
12
  private rootElement;
13
- constructor(theme: Theme, apply?: boolean);
13
+ private rootElementId;
14
+ constructor(theme: Theme, rootElementId?: string, apply?: boolean);
14
15
  getRootElement: () => HTMLElement | null;
16
+ getRootElementId: () => string;
15
17
  getCurrentTheme: () => Theme;
16
18
  setRootElement: (element: HTMLElement) => void;
19
+ setRootElementId: (rootElementId: string) => string;
17
20
  setAndApplyTheme: (theme: Theme, force?: boolean | undefined) => void;
18
21
  addThemeChangeListener: (listener: (theme: Theme) => void) => void;
19
22
  removeThemeChangeListener: (listener: (theme: Theme) => void) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../../src/ThemeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS;IAC3D,OAAO,CAAC,oBAAoB,CAAsC;IAClE,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,WAAW,CAA2B;gBAG5C,KAAK,EAAE,KAAK,EAEZ,KAAK,GAAE,OAAc;IAUhB,cAAc,2BAAyB;IACvC,eAAe,cAAmB;IAElC,cAAc,YAAa,WAAW,UAE5C;IACM,gBAAgB,UAAW,KAAK,uCAOtC;IAEM,sBAAsB,qBAAsB,KAAK,KAAK,IAAI,UAEhE;IACM,yBAAyB,qBAAsB,KAAK,KAAK,IAAI,UAInE;IACM,iBAAiB,aAQvB;IAED,OAAO,CAAC,0BAA0B,CAEjC;CACF"}
1
+ {"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../../src/ThemeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS;IAC3D,OAAO,CAAC,oBAAoB,CAAsC;IAClE,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,aAAa,CAAQ;gBAG3B,KAAK,EAAE,KAAK,EACZ,aAAa,GAAE,MAAW,EAE1B,KAAK,GAAE,OAAc;IAWhB,cAAc,2BAAyB;IACvC,gBAAgB,eAA2B;IAC3C,eAAe,cAAmB;IAElC,cAAc,YAAa,WAAW,UAE5C;IACM,gBAAgB,kBAAmB,MAAM,YACV;IAC/B,gBAAgB,UAAW,KAAK,uCAOtC;IAEM,sBAAsB,qBAAsB,KAAK,KAAK,IAAI,UAEhE;IACM,yBAAyB,qBAAsB,KAAK,KAAK,IAAI,UAInE;IACM,iBAAiB,aAUvB;IAED,OAAO,CAAC,0BAA0B,CAEjC;CACF"}
@@ -10,18 +10,23 @@ var makeCssVariableDefinitionsMap_1 = require("./lib/makeCssVariableDefinitionsM
10
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
11
  */
12
12
  var ThemeManager = /** @class */ (function () {
13
- function ThemeManager(theme,
13
+ function ThemeManager(theme, rootElementId,
14
14
  /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
15
15
  apply) {
16
16
  var _this = this;
17
+ if (rootElementId === void 0) { rootElementId = ""; }
17
18
  if (apply === void 0) { apply = true; }
18
19
  this.themeChangeListeners = [];
19
20
  this.rootElement = null;
20
21
  this.getRootElement = function () { return _this.rootElement; };
22
+ this.getRootElementId = function () { return _this.rootElementId; };
21
23
  this.getCurrentTheme = function () { return _this.theme; };
22
24
  this.setRootElement = function (element) {
23
25
  _this.rootElement = element;
24
26
  };
27
+ this.setRootElementId = function (rootElementId) {
28
+ return (_this.rootElementId = rootElementId);
29
+ };
25
30
  this.setAndApplyTheme = function (theme, force) {
26
31
  if (!force) {
27
32
  if (_this.theme === theme)
@@ -38,8 +43,9 @@ var ThemeManager = /** @class */ (function () {
38
43
  _this.themeChangeListeners = _this.themeChangeListeners.filter(function (l) { return l !== listener; });
39
44
  };
40
45
  this.applyCurrentTheme = function () {
46
+ var _a;
41
47
  if (typeof window !== "undefined") {
42
- _this.setRootElement(document.documentElement);
48
+ _this.setRootElement((_a = document.getElementById(_this.rootElementId)) !== null && _a !== void 0 ? _a : document.documentElement);
43
49
  var cssVariableDefinitions = (0, makeCssVariableDefinitionsMap_1.makeCssVariableDefinitionsMap)(_this.theme);
44
50
  Object.entries(cssVariableDefinitions).forEach(function (_a) {
45
51
  var _b;
@@ -56,6 +62,7 @@ var ThemeManager = /** @class */ (function () {
56
62
  If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
57
63
  */
58
64
  this.theme = theme;
65
+ this.rootElementId = rootElementId;
59
66
  if (apply)
60
67
  this.applyCurrentTheme();
61
68
  }
@@ -65,3 +72,4 @@ exports.ThemeManager = ThemeManager;
65
72
  // I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
66
73
  // 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
67
74
  /* export const defaultThemeManager = new ThemeManager(defaultTheme) */
75
+ //# sourceMappingURL=ThemeManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeManager.js","sourceRoot":"","sources":["../../src/ThemeManager.ts"],"names":[],"mappings":";;;AACA,qFAAmF;AACnF;;;;;;GAMG;AACH;IAME,sBACE,KAAY,EACZ,aAA0B;IAC1B,oHAAoH;IACpH,KAAqB;QAJvB,iBAaC;QAXC,8BAAA,EAAA,kBAA0B;QAE1B,sBAAA,EAAA,YAAqB;QATf,yBAAoB,GAAG,EAAmC,CAAA;QAE1D,gBAAW,GAAuB,IAAI,CAAA;QAkBvC,mBAAc,GAAG,cAAM,OAAA,KAAI,CAAC,WAAW,EAAhB,CAAgB,CAAA;QACvC,qBAAgB,GAAG,cAAM,OAAA,KAAI,CAAC,aAAa,EAAlB,CAAkB,CAAA;QAC3C,oBAAe,GAAG,cAAM,OAAA,KAAI,CAAC,KAAK,EAAV,CAAU,CAAA;QAElC,mBAAc,GAAG,UAAC,OAAoB;YAC3C,KAAI,CAAC,WAAW,GAAG,OAAO,CAAA;QAC5B,CAAC,CAAA;QACM,qBAAgB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KAAY;YAChD,KAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAf,CAAe,CAAC,CAAA;QAChE,CAAC,CAAA;QAjDC;;;UAGE;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,KAAK;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACrC,CAAC;IA2CH,mBAAC;AAAD,CAAC,AA9DD,IA8DC;AA9DY,oCAAY;AAgEzB,gIAAgI;AAChI,kIAAkI;AAClI,uEAAuE"}
@@ -57,3 +57,4 @@ var addExtraThemeEntries = function (path, key, value, printValue, _a) {
57
57
  return result;
58
58
  };
59
59
  exports.addExtraThemeEntries = addExtraThemeEntries;
60
+ //# sourceMappingURL=addExtraThemeEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addExtraThemeEntries.js","sourceRoot":"","sources":["../../../src/lib/addExtraThemeEntries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAsC;AACtC,+CAA6D;AAE7D;;;;;;;;;;;;;;;;;GAiBG;AACI,IAAM,oBAAoB,GAAG,UAClC,IAAc,EACd,GAAW,EACX,KAAc,EACd,UAAmD,EACnD,EAKC;;QAJC,aAAa,mBAAA;IAMf,IAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,sBAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC9E,IAAM,MAAM;QACV,GAAC,GAAG,IAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;WAC/B,CAAA;IAED,6EAA6E;IAC7E,IAAI,QAAQ,EAAE;QACZ,uDAAuD;QACvD,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;QAEnD,IAAM,OAAO,mCAAO,IAAI,UAAE,KAAK,SAAC,CAAA;QAChC,IAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACtE,MAAM,CAAC,UAAG,GAAG,SAAM,CAAC,GAAG,SAAS,CAAA;QAChC,IAAI,aAAa,EAAE;YACjB,MAAM,CAAC,UAAG,GAAG,YAAS,CAAC,GAAG,IAAA,2CAA4B,EAAC,OAAO,CAAC,CAAA;SAChE;KACF;IACD,IAAI,aAAa,EAAE;QACjB,MAAM,CAAC,UAAG,GAAG,QAAK,CAAC,GAAG,IAAA,2CAA4B,EAAC,IAAI,CAAC,CAAA;KACzD;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAlCY,QAAA,oBAAoB,wBAkChC"}
@@ -33,3 +33,4 @@ var objectPathToCssVarIdentifier = function (path) {
33
33
  return "--".concat(path.map(lodash_kebabcase_1.default).join("-"));
34
34
  };
35
35
  exports.objectPathToCssVarIdentifier = objectPathToCssVarIdentifier;
36
+ //# sourceMappingURL=cssVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssVariables.js","sourceRoot":"","sources":["../../../src/lib/cssVariables.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAoC;AAEpC;;;;;;;;;;;GAWG;AACI,IAAM,0BAA0B,GAAG,UAAC,IAAc,EAAE,KAAc;IACvE,OAAA,cAAO,IAAA,oCAA4B,EAAC,IAAI,CAAC,eAAK,KAAK,MAAG;AAAtD,CAAsD,CAAA;AAD3C,QAAA,0BAA0B,8BACiB;AAExD;;;;;;;GAOG;AACI,IAAM,4BAA4B,GAAG,UAAC,IAAc;IACzD,OAAA,YAAK,IAAI,CAAC,GAAG,CAAC,0BAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE;AAAhC,CAAgC,CAAA;AADrB,QAAA,4BAA4B,gCACP"}
@@ -55,3 +55,4 @@ function makeCssVariableDefinitionsMap(theme) {
55
55
  return accumulatedCssVariables;
56
56
  }
57
57
  exports.makeCssVariableDefinitionsMap = makeCssVariableDefinitionsMap;
58
+ //# sourceMappingURL=makeCssVariableDefinitionsMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeCssVariableDefinitionsMap.js","sourceRoot":"","sources":["../../../src/lib/makeCssVariableDefinitionsMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAA6D;AAC7D,+CAA6D;AAC7D,uDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,6BAA6B,CAC3C,KAAuC;IAEvC,IAAI,uBAAuB,GAAG,EAA4B,CAAA;IAE1D,kDAAkD;IAClD,IAAA,mCAAgB,EAAC,KAAK,EAAE,UAAC,IAAI,EAAE,KAAK;QAClC,6BAA6B;QAC7B,IAAM,GAAG,GAAG,IAAA,2CAA4B,EAAC,IAAI,CAAC,CAAA;QAC9C,IAAM,gBAAgB,GAAG,IAAA,2CAAoB,EAC3C,IAAI,EACJ,GAAG,EACH,KAAK,EACL,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,UAAG,CAAC,CAAE,EAAN,CAAM,EAChB,EAAE,aAAa,EAAE,KAAK,EAAE,CACzB,CAAA;QACD,uBAAuB,yBAClB,uBAAuB,GACvB,gBAAgB,CACpB,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,uBAAuB,CAAA;AAChC,CAAC;AAtBD,sEAsBC"}
@@ -55,3 +55,4 @@ function makeCSSVariableTheme(theme, printValue) {
55
55
  return augmentedTheme;
56
56
  }
57
57
  exports.makeCSSVariableTheme = makeCSSVariableTheme;
58
+ //# sourceMappingURL=makeCssVariableTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeCssVariableTheme.js","sourceRoot":"","sources":["../../../src/lib/makeCssVariableTheme.ts"],"names":[],"mappings":";;;AACA,+DAA6D;AAC7D,+CAA2D;AAC3D,uDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,oBAAoB,CAElC,KAAgB,EAAE,UAAuC;IAAvC,2BAAA,EAAA,aAAa,yCAA0B;IACzD,IAAM,cAAc,GAA4B,EAAE,CAAA;IAClD,IAAM,MAAM,GAAG,UAAC,QAAkB,EAAE,KAAc;QAChD,IAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC7C,IAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC9D,IAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CACvC,UAAC,KAAK,EAAE,OAAO;YACb,OAAA,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAA4B;QAApE,CAAoE,EACtE,cAAyC,CAC1C,CAAA;QACD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;SACxC;QACD,IAAM,mBAAmB,GAAG,IAAA,2CAAoB,EAC9C,QAAQ,EACR,OAAO,EACP,KAAK,EACL,UAAU,EACV,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAA;IAChD,CAAC,CAAA;IAED,IAAA,mCAAgB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAE/B,OAAO,cAAuD,CAAA;AAChE,CAAC;AA5BD,oDA4BC"}
@@ -59,3 +59,4 @@ function mapLeafsOfObject(object, mapper) {
59
59
  return recurser([], object);
60
60
  }
61
61
  exports.mapLeafsOfObject = mapLeafsOfObject;
62
+ //# sourceMappingURL=mapLeafsOfObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapLeafsOfObject.js","sourceRoot":"","sources":["../../../src/lib/mapLeafsOfObject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,gBAAgB,CAI9B,MAAW,EACX,MAAuD;IAEvD,IAAM,QAAQ,GAAG,UACf,WAAqB,EACrB,GAAM;QAEN,IAAM,WAAW,GAAG,UAAC,GAAW,EAAE,KAAc;YAC9C,IAAM,SAAS,mCAAO,WAAW,UAAE,GAAG,SAAC,CAAA;YACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;gBACtE,OAAO,QAAQ,CAAC,SAAS,EAAE,KAAyC,CAAC,CAAA;aACtE;YACD,OAAO,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QACjC,CAAC,CAAA;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAC/B,UAAC,GAAG,EAAE,EAAoB;;gBAAnB,OAAO,QAAA,EAAE,SAAS,QAAA;YAAM,OAAA,uBAC1B,GAAG,gBACL,OAAO,IAAG,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,OAC1C;QAH6B,CAG7B,EACF,EAAkC,CACnC,CAAA;IACH,CAAC,CAAA;IACD,OAAO,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;AAC7B,CAAC;AA3BD,4CA2BC"}
@@ -285,3 +285,4 @@ exports.heartTheme = {
285
285
  },
286
286
  },
287
287
  };
288
+ //# sourceMappingURL=heart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heart.js","sourceRoot":"","sources":["../../../src/themes/heart.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAU;IAC/B,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE;QACT,cAAc,EAAE;YACd,SAAS,EAAE,yCAAyC;YACpD,MAAM,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,aAAa,EAAE,QAAQ;SACxB;QACD,cAAc,EAAE;YACd,UAAU,EAAE,oDAAoD;YAChE,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE,QAAQ;SACxB;QACD,mBAAmB,EAAE;YACnB,UAAU,EAAE,oDAAoD;YAChE,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,SAAS;YACnB,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE,QAAQ;SACxB;QACD,aAAa,EAAE;YACb,UAAU,EAAE,GAAG;SAChB;QACD,aAAa,EAAE;YACb,UAAU,EAAE,oDAAoD;YAChE,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,QAAQ;YACpB,aAAa,EAAE,QAAQ;SACxB;QACD,eAAe,EAAE;YACf,UAAU,EAAE,oDAAoD;YAChE,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,QAAQ;YACpB,aAAa,EAAE,QAAQ;SACxB;KACF;CACF,CAAA"}
@@ -5,3 +5,4 @@ var heart_1 = require("./heart");
5
5
  var heart_2 = require("./heart");
6
6
  Object.defineProperty(exports, "heartTheme", { enumerable: true, get: function () { return heart_2.heartTheme; } });
7
7
  exports.defaultTheme = heart_1.heartTheme;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/themes/index.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,iCAAoC;AAA3B,mGAAA,UAAU,OAAA;AACN,QAAA,YAAY,GAAG,kBAAU,CAAA"}
package/dist/src/types.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaizen/design-tokens",
3
3
  "description": "Tokens used in the Kaizen Design System",
4
- "version": "9.0.5",
4
+ "version": "10.0.1",
5
5
  "homepage": "https://github.com/cultureamp/kaizen-design-system/tree/master/packages/design-tokens",
6
6
  "repository": {
7
7
  "type": "git",
@@ -58,5 +58,5 @@
58
58
  "peerDependencies": {
59
59
  "react": ">=16 || ^17.0.0 || ^18.0.0"
60
60
  },
61
- "gitHead": "842c6134420f4225025cfe6bbb98c55463d303ed"
61
+ "gitHead": "0e7e4af0401f2c2aeed42717851d6f08357cf14d"
62
62
  }
@@ -1,4 +1,4 @@
1
- import React from "react"
1
+ import React, { useState } from "react"
2
2
  import { ThemeManager, defaultTheme, Theme } from "../"
3
3
 
4
4
  export const ThemeContext = React.createContext<Theme>(defaultTheme)
@@ -11,28 +11,69 @@ export const ThemeProvider = ({
11
11
  themeManager,
12
12
  ...props
13
13
  }: {
14
- themeManager: ThemeManager
14
+ themeManager?: ThemeManager
15
15
  children: React.ReactNode
16
16
  }) => {
17
+ const [themeManagerInstance] = useState(
18
+ () => themeManager || new ThemeManager(defaultTheme)
19
+ )
20
+
17
21
  const [theme, setTheme] = React.useState<Theme>(
18
- themeManager.getCurrentTheme()
22
+ themeManagerInstance.getCurrentTheme()
19
23
  )
20
24
  React.useEffect(() => {
21
25
  let cancelled = false
22
26
  const listener = (newTheme: Theme) => {
23
27
  if (!cancelled) setTheme(newTheme)
24
28
  }
25
- themeManager.addThemeChangeListener(listener)
29
+ themeManagerInstance.addThemeChangeListener(listener)
26
30
  return () => {
27
31
  cancelled = true
28
- themeManager.removeThemeChangeListener(listener)
32
+ themeManagerInstance.removeThemeChangeListener(listener)
29
33
  }
30
34
  }, [])
31
35
 
32
36
  return (
33
- <ThemeContext.Provider value={theme}>
34
- {props.children}
35
- </ThemeContext.Provider>
37
+ <>
38
+ <ThemeContext.Provider value={theme}>
39
+ {props.children}
40
+ </ThemeContext.Provider>
41
+ <link
42
+ rel="preload"
43
+ href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2"
44
+ as="font"
45
+ type="font/woff2"
46
+ crossOrigin="crossorigin"
47
+ />
48
+ <link
49
+ rel="preload"
50
+ href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2"
51
+ as="font"
52
+ type="font/woff2"
53
+ crossOrigin="crossorigin"
54
+ />
55
+ <link
56
+ rel="preload"
57
+ href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2"
58
+ as="font"
59
+ type="font/woff2"
60
+ crossOrigin="crossorigin"
61
+ />
62
+ <link
63
+ rel="preload"
64
+ href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2"
65
+ as="font"
66
+ type="font/woff2"
67
+ crossOrigin="crossorigin"
68
+ />
69
+ <link
70
+ rel="preload"
71
+ href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2"
72
+ as="font"
73
+ type="font/woff2"
74
+ crossOrigin="crossorigin"
75
+ />
76
+ </>
36
77
  )
37
78
  }
38
79
 
@@ -11,9 +11,11 @@ export class ThemeManager<Theme extends BaseTheme = BaseTheme> {
11
11
  private themeChangeListeners = [] as Array<(theme: Theme) => void>
12
12
  private theme: Theme
13
13
  private rootElement: HTMLElement | null = null
14
+ private rootElementId: string
14
15
 
15
16
  constructor(
16
17
  theme: Theme,
18
+ rootElementId: string = "",
17
19
  /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
18
20
  apply: boolean = true
19
21
  ) {
@@ -22,15 +24,19 @@ export class ThemeManager<Theme extends BaseTheme = BaseTheme> {
22
24
  If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
23
25
  */
24
26
  this.theme = theme
27
+ this.rootElementId = rootElementId
25
28
  if (apply) this.applyCurrentTheme()
26
29
  }
27
30
 
28
31
  public getRootElement = () => this.rootElement
32
+ public getRootElementId = () => this.rootElementId
29
33
  public getCurrentTheme = () => this.theme
30
34
 
31
35
  public setRootElement = (element: HTMLElement) => {
32
36
  this.rootElement = element
33
37
  }
38
+ public setRootElementId = (rootElementId: string) =>
39
+ (this.rootElementId = rootElementId)
34
40
  public setAndApplyTheme = (theme: Theme, force?: boolean) => {
35
41
  if (!force) {
36
42
  if (this.theme === theme) return
@@ -50,7 +56,9 @@ export class ThemeManager<Theme extends BaseTheme = BaseTheme> {
50
56
  }
51
57
  public applyCurrentTheme = () => {
52
58
  if (typeof window !== "undefined") {
53
- this.setRootElement(document.documentElement)
59
+ this.setRootElement(
60
+ document.getElementById(this.rootElementId) ?? document.documentElement
61
+ )
54
62
  const cssVariableDefinitions = makeCssVariableDefinitionsMap(this.theme)
55
63
  Object.entries(cssVariableDefinitions).forEach(([key, value]) => {
56
64
  this.rootElement?.style.setProperty(key, value)
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import { ThemeManager, Theme } from "../";
3
- export declare const ThemeContext: React.Context<Theme>;
4
- /**
5
- * Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
6
- * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
7
- */
8
- export declare const ThemeProvider: ({ themeManager, ...props }: {
9
- themeManager: ThemeManager;
10
- children: React.ReactNode;
11
- }) => JSX.Element;
12
- export declare const useTheme: () => Theme;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- exports.__esModule = true;
17
- exports.useTheme = exports.ThemeProvider = exports.ThemeContext = void 0;
18
- var react_1 = __importDefault(require("react"));
19
- var __1 = require("../");
20
- exports.ThemeContext = react_1["default"].createContext(__1.defaultTheme);
21
- /**
22
- * Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
23
- * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
24
- */
25
- var ThemeProvider = function (_a) {
26
- var themeManager = _a.themeManager, props = __rest(_a, ["themeManager"]);
27
- var _b = react_1["default"].useState(themeManager.getCurrentTheme()), theme = _b[0], setTheme = _b[1];
28
- react_1["default"].useEffect(function () {
29
- var cancelled = false;
30
- var listener = function (newTheme) {
31
- if (!cancelled)
32
- setTheme(newTheme);
33
- };
34
- themeManager.addThemeChangeListener(listener);
35
- return function () {
36
- cancelled = true;
37
- themeManager.removeThemeChangeListener(listener);
38
- };
39
- }, []);
40
- return (react_1["default"].createElement(exports.ThemeContext.Provider, { value: theme }, props.children));
41
- };
42
- exports.ThemeProvider = ThemeProvider;
43
- var useTheme = function () { return react_1["default"].useContext(exports.ThemeContext); };
44
- exports.useTheme = useTheme;
45
- //# sourceMappingURL=ThemeProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeProvider.js","sourceRoot":"","sources":["ThemeProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAyB;AACzB,yBAAuD;AAE1C,QAAA,YAAY,GAAG,kBAAK,CAAC,aAAa,CAAQ,gBAAY,CAAC,CAAA;AAEpE;;;GAGG;AACI,IAAM,aAAa,GAAG,UAAC,EAM7B;IALC,IAAA,YAAY,kBAAA,EACT,KAAK,cAFoB,gBAG7B,CADS;IAKF,IAAA,KAAoB,kBAAK,CAAC,QAAQ,CACtC,YAAY,CAAC,eAAe,EAAE,CAC/B,EAFM,KAAK,QAAA,EAAE,QAAQ,QAErB,CAAA;IACD,kBAAK,CAAC,SAAS,CAAC;QACd,IAAI,SAAS,GAAG,KAAK,CAAA;QACrB,IAAM,QAAQ,GAAG,UAAC,QAAe;YAC/B,IAAI,CAAC,SAAS;gBAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;QACpC,CAAC,CAAA;QACD,YAAY,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAA;QAC7C,OAAO;YACL,SAAS,GAAG,IAAI,CAAA;YAChB,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAA;QAClD,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,iCAAC,oBAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAChC,KAAK,CAAC,QAAQ,CACO,CACzB,CAAA;AACH,CAAC,CAAA;AA3BY,QAAA,aAAa,iBA2BzB;AAEM,IAAM,QAAQ,GAAG,cAAM,OAAA,kBAAK,CAAC,UAAU,CAAC,oBAAY,CAAC,EAA9B,CAA8B,CAAA;AAA/C,QAAA,QAAQ,YAAuC"}
package/react/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./ThemeProvider";
package/react/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- exports.__esModule = true;
13
- __exportStar(require("./ThemeProvider"), exports);
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B"}
@@ -1,22 +0,0 @@
1
- import { Theme as BaseTheme } from "./types";
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
- constructor(theme: Theme, apply?: boolean);
14
- getRootElement: () => HTMLElement | null;
15
- getCurrentTheme: () => Theme;
16
- setRootElement: (element: HTMLElement) => void;
17
- setAndApplyTheme: (theme: Theme, force?: boolean | undefined) => void;
18
- addThemeChangeListener: (listener: (theme: Theme) => void) => void;
19
- removeThemeChangeListener: (listener: (theme: Theme) => void) => void;
20
- applyCurrentTheme: () => void;
21
- private notifyThemeChangeListeners;
22
- }