@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
@@ -1,68 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.ThemeManager = void 0;
4
- var makeCssVariableDefinitionsMap_1 = require("./lib/makeCssVariableDefinitionsMap");
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,
14
- /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
15
- apply) {
16
- var _this = this;
17
- if (apply === void 0) { apply = true; }
18
- this.themeChangeListeners = [];
19
- this.rootElement = null;
20
- this.getRootElement = function () { return _this.rootElement; };
21
- this.getCurrentTheme = function () { return _this.theme; };
22
- this.setRootElement = function (element) {
23
- _this.rootElement = element;
24
- };
25
- this.setAndApplyTheme = function (theme, force) {
26
- if (!force) {
27
- if (_this.theme === theme)
28
- return;
29
- }
30
- _this.theme = theme;
31
- _this.applyCurrentTheme();
32
- _this.notifyThemeChangeListeners(theme);
33
- };
34
- this.addThemeChangeListener = function (listener) {
35
- _this.themeChangeListeners.push(listener);
36
- };
37
- this.removeThemeChangeListener = function (listener) {
38
- _this.themeChangeListeners = _this.themeChangeListeners.filter(function (l) { return l !== listener; });
39
- };
40
- this.applyCurrentTheme = function () {
41
- if (typeof window !== "undefined") {
42
- _this.setRootElement(document.documentElement);
43
- var cssVariableDefinitions = (0, makeCssVariableDefinitionsMap_1.makeCssVariableDefinitionsMap)(_this.theme);
44
- Object.entries(cssVariableDefinitions).forEach(function (_a) {
45
- var _b;
46
- var key = _a[0], value = _a[1];
47
- (_b = _this.rootElement) === null || _b === void 0 ? void 0 : _b.style.setProperty(key, value);
48
- });
49
- }
50
- };
51
- this.notifyThemeChangeListeners = function (theme) {
52
- _this.themeChangeListeners.forEach(function (listener) { return listener(theme); });
53
- };
54
- /*
55
- For some reason, storybook likes this way of defining class properties better.
56
- If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
57
- */
58
- this.theme = theme;
59
- if (apply)
60
- this.applyCurrentTheme();
61
- }
62
- return ThemeManager;
63
- }());
64
- exports.ThemeManager = ThemeManager;
65
- // I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
66
- // 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
- /* export const defaultThemeManager = new ThemeManager(defaultTheme) */
68
- //# sourceMappingURL=ThemeManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeManager.js","sourceRoot":"","sources":["ThemeManager.ts"],"names":[],"mappings":";;;AACA,qFAAmF;AACnF;;;;;;GAMG;AACH;IAKE,sBACE,KAAY;IACZ,oHAAoH;IACpH,KAAqB;QAHvB,iBAWC;QARC,sBAAA,EAAA,YAAqB;QAPf,yBAAoB,GAAG,EAAmC,CAAA;QAE1D,gBAAW,GAAuB,IAAI,CAAA;QAevC,mBAAc,GAAG,cAAM,OAAA,KAAI,CAAC,WAAW,EAAhB,CAAgB,CAAA;QACvC,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,GAAG,UAAC,KAAY,EAAE,KAAe;YACtD,IAAI,CAAC,KAAK,EAAE;gBACV,IAAI,KAAI,CAAC,KAAK,KAAK,KAAK;oBAAE,OAAM;aACjC;YACD,KAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,KAAI,CAAC,iBAAiB,EAAE,CAAA;YACxB,KAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC,CAAA;QAEM,2BAAsB,GAAG,UAAC,QAAgC;YAC/D,KAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC1C,CAAC,CAAA;QACM,8BAAyB,GAAG,UAAC,QAAgC;YAClE,KAAI,CAAC,oBAAoB,GAAG,KAAI,CAAC,oBAAoB,CAAC,MAAM,CAC1D,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,QAAQ,EAAd,CAAc,CACpB,CAAA;QACH,CAAC,CAAA;QACM,sBAAiB,GAAG;YACzB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;gBACjC,KAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;gBAC7C,IAAM,sBAAsB,GAAG,IAAA,6DAA6B,EAAC,KAAI,CAAC,KAAK,CAAC,CAAA;gBACxE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;;wBAAX,GAAG,QAAA,EAAE,KAAK,QAAA;oBACzD,MAAA,KAAI,CAAC,WAAW,0CAAE,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;gBACjD,CAAC,CAAC,CAAA;aACH;QACH,CAAC,CAAA;QAEO,+BAA0B,GAAG,UAAC,KAAY;YAChD,KAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAf,CAAe,CAAC,CAAA;QAChE,CAAC,CAAA;QA3CC;;;UAGE;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,KAAK;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACrC,CAAC;IAsCH,mBAAC;AAAD,CAAC,AAtDD,IAsDC;AAtDY,oCAAY;AAwDzB,gIAAgI;AAChI,kIAAkI;AAClI,uEAAuE"}
@@ -1,38 +0,0 @@
1
- export declare const themeForTesting: {
2
- readonly border: {
3
- readonly dashed: {
4
- readonly borderWidth: "2px";
5
- readonly red: "red";
6
- };
7
- };
8
- readonly color: {
9
- readonly gray: {
10
- readonly 100: "#eee";
11
- readonly 200: "#ccc";
12
- };
13
- readonly purple: {
14
- readonly 100: "#eee";
15
- readonly 200: "#ccc";
16
- };
17
- readonly blue: {
18
- readonly 100: "#eee";
19
- readonly 200: "#ccc";
20
- };
21
- readonly red: {
22
- readonly 100: "#eee";
23
- readonly 200: "#ccc";
24
- };
25
- readonly yellow: {
26
- readonly 100: "#eee";
27
- readonly 200: "#ccc";
28
- };
29
- readonly orange: {
30
- readonly 100: "#eee";
31
- readonly 200: "#ccc";
32
- };
33
- readonly green: {
34
- readonly 100: "#eee";
35
- readonly 200: "#ccc";
36
- };
37
- };
38
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.themeForTesting = void 0;
4
- exports.themeForTesting = {
5
- border: {
6
- dashed: {
7
- borderWidth: "2px",
8
- red: "red"
9
- }
10
- },
11
- color: {
12
- gray: { 100: "#eee", 200: "#ccc" },
13
- purple: { 100: "#eee", 200: "#ccc" },
14
- blue: { 100: "#eee", 200: "#ccc" },
15
- red: { 100: "#eee", 200: "#ccc" },
16
- yellow: { 100: "#eee", 200: "#ccc" },
17
- orange: { 100: "#eee", 200: "#ccc" },
18
- green: { 100: "#eee", 200: "#ccc" }
19
- }
20
- };
21
- //# sourceMappingURL=themeForTesting.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"themeForTesting.js","sourceRoot":"","sources":["themeForTesting.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE;QACN,MAAM,EAAE;YACN,WAAW,EAAE,KAAK;YAClB,GAAG,EAAE,KAAK;SACX;KACF;IACD,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QAClC,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QACpC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QAClC,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QACjC,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QACpC,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;QACpC,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;KACpC;CACO,CAAA"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Use this to generate an object containing `${key}: value`, `${key}-rgb: r, g, b`, and/or `${key}-id: --color-blah-XXX`.
3
- * This is for adding extra neighbouring properties to a theme.
4
- * For example:
5
- * Input:
6
- * path: [color, purple, 100]
7
- * key: 100
8
- * value: #f0f1f4
9
- * printValue: (path, v) => `var(--some-key, ${v})`
10
- * options: {augmentWithId: true}
11
- *
12
- * Output: {
13
- * "100": "var(--some-key, #f0f1f4)",
14
- * "100-rgb": "var(--some-key, 240, 241, 244)",
15
- * "100-id": "--color-purple-100"
16
- * "100-rgb-id": "--color-purple-100-rgb"
17
- * }
18
- */
19
- export declare const addExtraThemeEntries: (path: string[], key: string, value: unknown, printValue: <I>(path: string[], value: I) => string, { augmentWithId, }: {
20
- /** Setting this to true will add `${key}-id` and ${key}-rgb-id` */
21
- augmentWithId: boolean;
22
- }) => {
23
- [x: string]: string;
24
- };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- exports.__esModule = true;
15
- exports.addExtraThemeEntries = void 0;
16
- var color_string_1 = __importDefault(require("color-string"));
17
- var cssVariables_1 = require("./cssVariables");
18
- /**
19
- * Use this to generate an object containing `${key}: value`, `${key}-rgb: r, g, b`, and/or `${key}-id: --color-blah-XXX`.
20
- * This is for adding extra neighbouring properties to a theme.
21
- * For example:
22
- * Input:
23
- * path: [color, purple, 100]
24
- * key: 100
25
- * value: #f0f1f4
26
- * printValue: (path, v) => `var(--some-key, ${v})`
27
- * options: {augmentWithId: true}
28
- *
29
- * Output: {
30
- * "100": "var(--some-key, #f0f1f4)",
31
- * "100-rgb": "var(--some-key, 240, 241, 244)",
32
- * "100-id": "--color-purple-100"
33
- * "100-rgb-id": "--color-purple-100-rgb"
34
- * }
35
- */
36
- var addExtraThemeEntries = function (path, key, value, printValue, _a) {
37
- var _b;
38
- var augmentWithId = _a.augmentWithId;
39
- var colorRgb = typeof value === "string" ? color_string_1["default"].get.rgb(value) : null;
40
- var result = (_b = {},
41
- _b[key] = printValue(path, value),
42
- _b);
43
- // Add the -rgb key containing the RGB triple of the color (if it is a color)
44
- if (colorRgb) {
45
- // If the value is a color, always convert to lowercase
46
- result[key] = printValue(path, value).toLowerCase();
47
- var rgbPath = __spreadArray(__spreadArray([], path, true), ["rgb"], false);
48
- var rgbTriple = printValue(rgbPath, colorRgb.slice(0, 3).join(", "));
49
- result["".concat(key, "-rgb")] = rgbTriple;
50
- if (augmentWithId) {
51
- result["".concat(key, "-rgb-id")] = (0, cssVariables_1.objectPathToCssVarIdentifier)(rgbPath);
52
- }
53
- }
54
- if (augmentWithId) {
55
- result["".concat(key, "-id")] = (0, cssVariables_1.objectPathToCssVarIdentifier)(path);
56
- }
57
- return result;
58
- };
59
- exports.addExtraThemeEntries = addExtraThemeEntries;
60
- //# sourceMappingURL=addExtraThemeEntries.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addExtraThemeEntries.js","sourceRoot":"","sources":["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,yBAAW,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"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Given an object path (an array of strings) and a value, return a CSS var() function that represents it.
3
- *
4
- * Example:
5
- * Input:
6
- * path: [color, wisteria, 100]
7
- * value: #f0f1f4
8
- *
9
- * Output:
10
- * "var(--color-wisteria-100, #f0f1f4)"
11
- *
12
- */
13
- export declare const objectPathToCssVarFunction: (path: string[], value: unknown) => string;
14
- /**
15
- * Given an object path (an array of strings), return a CSS variable identifier.
16
- *
17
- * Example:
18
- * Input: [color, wisteria, 100]
19
- *
20
- * Output: "--color-wisteria-100"
21
- */
22
- export declare const objectPathToCssVarIdentifier: (path: string[]) => string;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- exports.__esModule = true;
6
- exports.objectPathToCssVarIdentifier = exports.objectPathToCssVarFunction = void 0;
7
- var lodash_kebabcase_1 = __importDefault(require("lodash.kebabcase"));
8
- /**
9
- * Given an object path (an array of strings) and a value, return a CSS var() function that represents it.
10
- *
11
- * Example:
12
- * Input:
13
- * path: [color, wisteria, 100]
14
- * value: #f0f1f4
15
- *
16
- * Output:
17
- * "var(--color-wisteria-100, #f0f1f4)"
18
- *
19
- */
20
- var objectPathToCssVarFunction = function (path, value) {
21
- return "var(".concat((0, exports.objectPathToCssVarIdentifier)(path), ", ").concat(value, ")");
22
- };
23
- exports.objectPathToCssVarFunction = objectPathToCssVarFunction;
24
- /**
25
- * Given an object path (an array of strings), return a CSS variable identifier.
26
- *
27
- * Example:
28
- * Input: [color, wisteria, 100]
29
- *
30
- * Output: "--color-wisteria-100"
31
- */
32
- var objectPathToCssVarIdentifier = function (path) {
33
- return "--".concat(path.map(lodash_kebabcase_1["default"]).join("-"));
34
- };
35
- exports.objectPathToCssVarIdentifier = objectPathToCssVarIdentifier;
36
- //# sourceMappingURL=cssVariables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cssVariables.js","sourceRoot":"","sources":["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,6BAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE;AAAhC,CAAgC,CAAA;AADrB,QAAA,4BAA4B,gCACP"}
@@ -1,29 +0,0 @@
1
- /**
2
-
3
- * Make a map of CSS variables -> values in a consistent way.
4
- * Use this to, for example, create a CSS file that declares each theme variable on the `:root` pseudo element.
5
- * Or for example when you're defining CSS variables using `rootElement.style.setProperty` within ThemeManager.
6
- *
7
- * It is paramount that this function defines every variable that {@link makeCssVariableTheme} expects to be defined.
8
- * Otherwise, it's possible that a CSS variable token (something that looks like var(--color-purple-100-rgb)) won't have a matching defined
9
- * CSS variable like `--color-purple-100-rgb: 123, 123, 123;`
10
- *
11
- *
12
- * For example:
13
- * Input:
14
- * ```
15
- * {
16
- * color: {
17
- * whatever: {
18
- * 100: "#ff0022"
19
- * }
20
- * }
21
- * }
22
- * ```
23
- * Output:
24
- * ```
25
- * {
26
- * "--color-whatever-100": "#ff0022"
27
- * }
28
- */
29
- export declare function makeCssVariableDefinitionsMap(theme: Record<string | number, unknown>): Record<string, string>;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
14
- exports.makeCssVariableDefinitionsMap = void 0;
15
- var addExtraThemeEntries_1 = require("./addExtraThemeEntries");
16
- var cssVariables_1 = require("./cssVariables");
17
- var mapLeafsOfObject_1 = require("./mapLeafsOfObject");
18
- /**
19
-
20
- * Make a map of CSS variables -> values in a consistent way.
21
- * Use this to, for example, create a CSS file that declares each theme variable on the `:root` pseudo element.
22
- * Or for example when you're defining CSS variables using `rootElement.style.setProperty` within ThemeManager.
23
- *
24
- * It is paramount that this function defines every variable that {@link makeCssVariableTheme} expects to be defined.
25
- * Otherwise, it's possible that a CSS variable token (something that looks like var(--color-purple-100-rgb)) won't have a matching defined
26
- * CSS variable like `--color-purple-100-rgb: 123, 123, 123;`
27
- *
28
- *
29
- * For example:
30
- * Input:
31
- * ```
32
- * {
33
- * color: {
34
- * whatever: {
35
- * 100: "#ff0022"
36
- * }
37
- * }
38
- * }
39
- * ```
40
- * Output:
41
- * ```
42
- * {
43
- * "--color-whatever-100": "#ff0022"
44
- * }
45
- */
46
- function makeCssVariableDefinitionsMap(theme) {
47
- var accumulatedCssVariables = {};
48
- // Shamelessly using a map function like a forEach
49
- (0, mapLeafsOfObject_1.mapLeafsOfObject)(theme, function (path, value) {
50
- // Key will be `--color-blah`
51
- var key = (0, cssVariables_1.objectPathToCssVarIdentifier)(path);
52
- var nextCssVariables = (0, addExtraThemeEntries_1.addExtraThemeEntries)(path, key, value, function (_, v) { return "".concat(v); }, { augmentWithId: false });
53
- accumulatedCssVariables = __assign(__assign({}, accumulatedCssVariables), nextCssVariables);
54
- });
55
- return accumulatedCssVariables;
56
- }
57
- exports.makeCssVariableDefinitionsMap = makeCssVariableDefinitionsMap;
58
- //# sourceMappingURL=makeCssVariableDefinitionsMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeCssVariableDefinitionsMap.js","sourceRoot":"","sources":["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"}
@@ -1,34 +0,0 @@
1
- import { DeepMapObjectLeafs } from "../types";
2
- /**
3
- * This function could use a new name during a breaking change
4
- *
5
- * Given a Theme (which is the source of truth and doesn't contain any computed properties), add extra necessary properties to the tree such as `-rgb` suffixed keys with R, G, B triple values, and
6
- * convert the leaf values of a theme to a value like `var(--parent1key-parent2key-leafkey)` - a CSS variable with an identifier that represents it's hierarchy.
7
- *
8
- * Example:
9
- * ```
10
- * {
11
- * color: {
12
- * purple: {
13
- * 100: "#f0f1f4"
14
- * }
15
- * }
16
- * }
17
- * ```
18
- * Transforms into:
19
- * ```
20
- * {
21
- * color: {
22
- * purple: {
23
- * 100: "var(--color-purple-100, "#f0f1f4")",
24
- * "100-rgb": "var(--color-purple-100-rgb, 240, 241, 244)",
25
- * "100-id": "--color-purple-100",
26
- * "100-rgb-id": "--color-purple-100-rgb"
27
- * }
28
- * }
29
- * }
30
- * ```
31
- *
32
- * See {@link addExtraThemeEntries} for how these extra entries are added.
33
- */
34
- export declare function makeCSSVariableTheme<ThemeType extends Record<string | number, unknown>>(theme: ThemeType, printValue?: (path: string[], value: unknown) => string): DeepMapObjectLeafs<ThemeType, string>;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.makeCSSVariableTheme = void 0;
4
- var addExtraThemeEntries_1 = require("./addExtraThemeEntries");
5
- var cssVariables_1 = require("./cssVariables");
6
- var mapLeafsOfObject_1 = require("./mapLeafsOfObject");
7
- /**
8
- * This function could use a new name during a breaking change
9
- *
10
- * Given a Theme (which is the source of truth and doesn't contain any computed properties), add extra necessary properties to the tree such as `-rgb` suffixed keys with R, G, B triple values, and
11
- * convert the leaf values of a theme to a value like `var(--parent1key-parent2key-leafkey)` - a CSS variable with an identifier that represents it's hierarchy.
12
- *
13
- * Example:
14
- * ```
15
- * {
16
- * color: {
17
- * purple: {
18
- * 100: "#f0f1f4"
19
- * }
20
- * }
21
- * }
22
- * ```
23
- * Transforms into:
24
- * ```
25
- * {
26
- * color: {
27
- * purple: {
28
- * 100: "var(--color-purple-100, "#f0f1f4")",
29
- * "100-rgb": "var(--color-purple-100-rgb, 240, 241, 244)",
30
- * "100-id": "--color-purple-100",
31
- * "100-rgb-id": "--color-purple-100-rgb"
32
- * }
33
- * }
34
- * }
35
- * ```
36
- *
37
- * See {@link addExtraThemeEntries} for how these extra entries are added.
38
- */
39
- function makeCSSVariableTheme(theme, printValue) {
40
- if (printValue === void 0) { printValue = cssVariables_1.objectPathToCssVarFunction; }
41
- var augmentedTheme = {};
42
- var mapper = function (leafPath, value) {
43
- var leafKey = leafPath[leafPath.length - 1];
44
- var pathWithoutLast = leafPath.slice(0, leafPath.length - 1);
45
- var leafObject = pathWithoutLast.reduce(function (child, segment) {
46
- return (child[segment] || (child[segment] = {}));
47
- }, augmentedTheme);
48
- if (!leafKey) {
49
- throw new Error("leafKey is undefined");
50
- }
51
- var cssVariablesOfToken = (0, addExtraThemeEntries_1.addExtraThemeEntries)(leafPath, leafKey, value, printValue, { augmentWithId: true });
52
- Object.assign(leafObject, cssVariablesOfToken);
53
- };
54
- (0, mapLeafsOfObject_1.mapLeafsOfObject)(theme, mapper);
55
- return augmentedTheme;
56
- }
57
- exports.makeCSSVariableTheme = makeCSSVariableTheme;
58
- //# sourceMappingURL=makeCssVariableTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeCssVariableTheme.js","sourceRoot":"","sources":["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"}
@@ -1,22 +0,0 @@
1
- import { DeepMapObjectLeafs } from "../types";
2
- /**
3
- * This allows you to map the leaf nodes of an object, and you're provided the path to that leaf as well as the value as parameters to your mapper function.
4
- * This function was build to support mapping theme values to their respective CSS variable identifiers.
5
- * For example:
6
- * ```ts
7
- * mapLeafsOfObject({
8
- * one: {
9
- * two: 4
10
- * }
11
- * }, (path, value) => value + 7)
12
- * ```
13
- * Results in:
14
- * ```
15
- * {
16
- * one: {
17
- * two: 11
18
- * }
19
- * }
20
- * ```
21
- */
22
- export declare function mapLeafsOfObject<Obj extends Record<string | number, unknown>, Value>(object: Obj, mapper: (pathToLeaf: string[], value: unknown) => Value): DeepMapObjectLeafs<Obj, Value>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- exports.__esModule = true;
23
- exports.mapLeafsOfObject = void 0;
24
- /**
25
- * This allows you to map the leaf nodes of an object, and you're provided the path to that leaf as well as the value as parameters to your mapper function.
26
- * This function was build to support mapping theme values to their respective CSS variable identifiers.
27
- * For example:
28
- * ```ts
29
- * mapLeafsOfObject({
30
- * one: {
31
- * two: 4
32
- * }
33
- * }, (path, value) => value + 7)
34
- * ```
35
- * Results in:
36
- * ```
37
- * {
38
- * one: {
39
- * two: 11
40
- * }
41
- * }
42
- * ```
43
- */
44
- function mapLeafsOfObject(object, mapper) {
45
- var recurser = function (currentPath, obj) {
46
- var handleEntry = function (key, value) {
47
- var pathToKey = __spreadArray(__spreadArray([], currentPath, true), [key], false);
48
- if (typeof value === "object" && value !== null && value !== undefined) {
49
- return recurser(pathToKey, value);
50
- }
51
- return mapper(pathToKey, value);
52
- };
53
- return Object.entries(obj).reduce(function (acc, _a) {
54
- var _b;
55
- var nextKey = _a[0], nextValue = _a[1];
56
- return (__assign(__assign({}, acc), (_b = {}, _b[nextKey] = handleEntry(nextKey, nextValue), _b)));
57
- }, {});
58
- };
59
- return recurser([], object);
60
- }
61
- exports.mapLeafsOfObject = mapLeafsOfObject;
62
- //# sourceMappingURL=mapLeafsOfObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapLeafsOfObject.js","sourceRoot":"","sources":["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"}
@@ -1,2 +0,0 @@
1
- export declare const zenColorNamePattern: RegExp;
2
- export declare const heartColorNamePattern: RegExp;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.heartColorNamePattern = exports.zenColorNamePattern = void 0;
4
- exports.zenColorNamePattern = /ash|stone|slate|iron|wisteria|cluny|peach|yuzu|coral|seedling/;
5
- exports.heartColorNamePattern = /purple|blue|orange|yellow|red|green|gray/;
6
- //# sourceMappingURL=patterns.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patterns.js","sourceRoot":"","sources":["patterns.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAC9B,+DAA+D,CAAA;AACpD,QAAA,qBAAqB,GAAG,0CAA0C,CAAA"}
@@ -1,2 +0,0 @@
1
- import { Theme } from "../types";
2
- export declare const heartTheme: Theme;