@tamagui/create-theme 1.30.26 → 1.30.28

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 (72) hide show
  1. package/package.json +3 -3
  2. package/dist/cjs/Palette.js +0 -17
  3. package/dist/cjs/Palette.js.map +0 -6
  4. package/dist/cjs/THEME_INFO.js +0 -40
  5. package/dist/cjs/THEME_INFO.js.map +0 -6
  6. package/dist/cjs/ThemeBuilder.js +0 -167
  7. package/dist/cjs/ThemeBuilder.js.map +0 -6
  8. package/dist/cjs/buildThemes.js +0 -160
  9. package/dist/cjs/buildThemes.js.map +0 -6
  10. package/dist/cjs/createTheme.js +0 -69
  11. package/dist/cjs/createTheme.js.map +0 -6
  12. package/dist/cjs/helpers.js +0 -39
  13. package/dist/cjs/helpers.js.map +0 -6
  14. package/dist/cjs/isMinusZero.js +0 -31
  15. package/dist/cjs/isMinusZero.js.map +0 -6
  16. package/dist/cjs/masks.js +0 -151
  17. package/dist/cjs/masks.js.map +0 -6
  18. package/dist/cjs/palettes.js +0 -102
  19. package/dist/cjs/palettes.js.map +0 -6
  20. package/dist/cjs/templates.js +0 -96
  21. package/dist/cjs/templates.js.map +0 -6
  22. package/dist/cjs/tests-buildThemes.js +0 -26
  23. package/dist/cjs/tests-buildThemes.js.map +0 -6
  24. package/dist/cjs/tests.js +0 -57
  25. package/dist/cjs/tests.js.map +0 -6
  26. package/dist/cjs/themeInfo.js +0 -42
  27. package/dist/cjs/themeInfo.js.map +0 -6
  28. package/dist/cjs/types.js +0 -17
  29. package/dist/cjs/types.js.map +0 -6
  30. package/dist/esm/Palette.js +0 -1
  31. package/dist/esm/Palette.js.map +0 -6
  32. package/dist/esm/THEME_INFO.js +0 -15
  33. package/dist/esm/THEME_INFO.js.map +0 -6
  34. package/dist/esm/ThemeBuilder.js +0 -143
  35. package/dist/esm/ThemeBuilder.js.map +0 -6
  36. package/dist/esm/buildThemes.js +0 -136
  37. package/dist/esm/buildThemes.js.map +0 -6
  38. package/dist/esm/createTheme.js +0 -44
  39. package/dist/esm/createTheme.js.map +0 -6
  40. package/dist/esm/helpers.js +0 -13
  41. package/dist/esm/helpers.js.map +0 -6
  42. package/dist/esm/isMinusZero.js +0 -7
  43. package/dist/esm/isMinusZero.js.map +0 -6
  44. package/dist/esm/masks.js +0 -118
  45. package/dist/esm/masks.js.map +0 -6
  46. package/dist/esm/palettes.js +0 -78
  47. package/dist/esm/palettes.js.map +0 -6
  48. package/dist/esm/templates.js +0 -72
  49. package/dist/esm/templates.js.map +0 -6
  50. package/dist/esm/tests-buildThemes.js +0 -25
  51. package/dist/esm/tests-buildThemes.js.map +0 -6
  52. package/dist/esm/tests.js +0 -33
  53. package/dist/esm/tests.js.map +0 -6
  54. package/dist/esm/themeInfo.js +0 -17
  55. package/dist/esm/themeInfo.js.map +0 -6
  56. package/dist/esm/types.js +0 -1
  57. package/dist/esm/types.js.map +0 -6
  58. package/types/Palette.d.ts.map +0 -1
  59. package/types/THEME_INFO.d.ts.map +0 -1
  60. package/types/ThemeBuilder.d.ts.map +0 -1
  61. package/types/buildThemes.d.ts.map +0 -1
  62. package/types/createTheme.d.ts.map +0 -1
  63. package/types/helpers.d.ts.map +0 -1
  64. package/types/index.d.ts.map +0 -1
  65. package/types/isMinusZero.d.ts.map +0 -1
  66. package/types/masks.d.ts.map +0 -1
  67. package/types/palettes.d.ts.map +0 -1
  68. package/types/templates.d.ts.map +0 -1
  69. package/types/tests-buildThemes.d.ts.map +0 -1
  70. package/types/tests.d.ts.map +0 -1
  71. package/types/themeInfo.d.ts.map +0 -1
  72. package/types/types.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/create-theme",
3
- "version": "1.30.26",
3
+ "version": "1.30.28",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,10 +27,10 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@tamagui/web": "1.30.26"
30
+ "@tamagui/web": "1.30.28"
31
31
  },
32
32
  "devDependencies": {
33
- "@tamagui/build": "1.30.26"
33
+ "@tamagui/build": "1.30.28"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var Palette_exports = {};
16
- module.exports = __toCommonJS(Palette_exports);
17
- //# sourceMappingURL=Palette.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Palette.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
5
- "names": []
6
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var THEME_INFO_exports = {};
20
- __export(THEME_INFO_exports, {
21
- getThemeInfo: () => getThemeInfo,
22
- setThemeInfo: () => setThemeInfo
23
- });
24
- module.exports = __toCommonJS(THEME_INFO_exports);
25
- const THEME_INFO = /* @__PURE__ */ new Map();
26
- const getThemeInfo = (theme) => {
27
- return THEME_INFO.get(JSON.stringify(theme));
28
- };
29
- const setThemeInfo = (theme, info) => {
30
- THEME_INFO.set(JSON.stringify(theme), {
31
- ...info,
32
- cache: /* @__PURE__ */ new Map()
33
- });
34
- };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- getThemeInfo,
38
- setThemeInfo
39
- });
40
- //# sourceMappingURL=THEME_INFO.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/THEME_INFO.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,MAAM,aAAa,oBAAI,IAAuB;AAEvC,MAAM,eAAe,CAAC,UAA2D;AACtF,SAAO,WAAW,IAAI,KAAK,UAAU,KAAK,CAAC;AAC7C;AAEO,MAAM,eAAe,CAC1B,OACA,SACG;AACH,aAAW,IAAI,KAAK,UAAU,KAAK,GAAG;AAAA,IACpC,GAAG;AAAA,IACH,OAAO,oBAAI,IAAI;AAAA,EACjB,CAAC;AACH;",
5
- "names": []
6
- }
@@ -1,167 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var ThemeBuilder_exports = {};
20
- __export(ThemeBuilder_exports, {
21
- createThemeBuilder: () => createThemeBuilder
22
- });
23
- module.exports = __toCommonJS(ThemeBuilder_exports);
24
- var import_createTheme = require("./createTheme");
25
- var import_helpers = require("./helpers");
26
- var import_masks = require("./masks");
27
- class ThemeBuilder {
28
- constructor(state) {
29
- this.state = state;
30
- }
31
- addPalettes(palettes) {
32
- return new ThemeBuilder({
33
- ...this.state,
34
- palettes: {
35
- // as {} prevents generic string key merge messing up types
36
- ...this.state.palettes,
37
- ...palettes
38
- }
39
- });
40
- }
41
- addTemplates(templates) {
42
- return new ThemeBuilder({
43
- ...this.state,
44
- templates: {
45
- // as {} prevents generic string key merge messing up types
46
- ...this.state.templates,
47
- ...templates
48
- }
49
- });
50
- }
51
- addMasks(masks) {
52
- return new ThemeBuilder({
53
- ...this.state,
54
- masks: {
55
- // as {} prevents generic string key merge messing up types
56
- ...this.state.masks,
57
- ...(0, import_helpers.objectFromEntries)(
58
- (0, import_helpers.objectEntries)(masks).map(([key, val]) => [key, (0, import_masks.createMask)(val)])
59
- )
60
- }
61
- });
62
- }
63
- addThemes(themes) {
64
- return new ThemeBuilder({
65
- ...this.state,
66
- themes: {
67
- // as {} prevents generic string key merge messing up types
68
- ...this.state.themes,
69
- ...themes
70
- }
71
- });
72
- }
73
- addChildThemes(childThemeDefinition, options) {
74
- const currentThemes = this.state.themes;
75
- if (!currentThemes) {
76
- throw new Error(
77
- `No themes defined yet, use addThemes first to set your base themes`
78
- );
79
- }
80
- const currentThemeNames = (0, import_helpers.objectKeys)(currentThemes);
81
- const incomingThemeNames = (0, import_helpers.objectKeys)(childThemeDefinition);
82
- const namesWithDefinitions = currentThemeNames.flatMap((prefix) => {
83
- return incomingThemeNames.map((subName) => {
84
- const fullName = `${prefix}_${subName}`;
85
- const definition = childThemeDefinition[subName];
86
- return [fullName, definition];
87
- });
88
- });
89
- const childThemes = (0, import_helpers.objectFromEntries)(namesWithDefinitions);
90
- return new ThemeBuilder({
91
- ...this.state,
92
- themes: {
93
- // as {} prevents generic string key merge messing up types
94
- ...this.state.themes,
95
- ...childThemes
96
- }
97
- });
98
- }
99
- build() {
100
- var _a, _b;
101
- if (!this.state.themes) {
102
- return {};
103
- }
104
- const out = {};
105
- const maskedThemes = [];
106
- for (const themeName in this.state.themes) {
107
- const nameParts = themeName.split("_");
108
- const parentName = nameParts.slice(0, nameParts.length - 1).join("_");
109
- const definitions = this.state.themes[themeName];
110
- const themeDefinition = Array.isArray(definitions) ? (() => {
111
- const found = definitions.find((d) => parentName.startsWith(d.parent));
112
- if (!found) {
113
- throw new Error(`No parent for ${themeName}: ${parentName}`);
114
- }
115
- return found;
116
- })() : definitions;
117
- if ("theme" in themeDefinition) {
118
- out[themeName] = themeDefinition.theme;
119
- } else if ("mask" in themeDefinition) {
120
- maskedThemes.push({ parentName, themeName, mask: themeDefinition.mask });
121
- } else {
122
- if (!this.state.palettes) {
123
- throw new Error(
124
- `No palettes defined for theme with palette expected: ${themeName}`
125
- );
126
- }
127
- let palette = this.state.palettes[themeDefinition.palette];
128
- if (!palette) {
129
- const fullPaletteName = `${parentName}_${themeDefinition.palette}`;
130
- palette = this.state.palettes[fullPaletteName];
131
- }
132
- if (!palette) {
133
- throw new Error(`No palette for theme ${themeName}: ${themeDefinition.palette}`);
134
- }
135
- const template = (_a = this.state.templates) == null ? void 0 : _a[themeDefinition.template];
136
- if (!template) {
137
- throw new Error(
138
- `No template for theme ${themeName}: ${themeDefinition.template}`
139
- );
140
- }
141
- out[themeName] = (0, import_createTheme.createTheme)(palette, template);
142
- }
143
- }
144
- for (const { mask, themeName, parentName } of maskedThemes) {
145
- const parent = out[parentName];
146
- if (!parent) {
147
- throw new Error(
148
- `No parent theme found with name ${parentName} for theme ${themeName} to use as a mask target`
149
- );
150
- }
151
- const maskFunction = (_b = this.state.masks) == null ? void 0 : _b[mask];
152
- if (!maskFunction) {
153
- throw new Error(`No mask ${maskFunction}`);
154
- }
155
- out[themeName] = (0, import_masks.applyMask)(parent, maskFunction);
156
- }
157
- return out;
158
- }
159
- }
160
- function createThemeBuilder() {
161
- return new ThemeBuilder({});
162
- }
163
- // Annotate the CommonJS export names for ESM import in node:
164
- 0 && (module.exports = {
165
- createThemeBuilder
166
- });
167
- //# sourceMappingURL=ThemeBuilder.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/ThemeBuilder.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAC5B,qBAA6D;AAC7D,mBAAsC;AA4GtC,MAAM,aAA8C;AAAA,EAClD,YAAmB,OAAc;AAAd;AAAA,EAAe;AAAA,EAElC,YAAgD,UAAa;AAC3D,WAAO,IAAI,aAAa;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,UAAU;AAAA;AAAA,QAER,GAAI,KAAK,MAAM;AAAA,QACf,GAAG;AAAA,MACL;AAAA,IACF,CAAU;AAAA,EACZ;AAAA,EAEA,aAAkD,WAAc;AAC9D,WAAO,IAAI,aAAa;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,WAAW;AAAA;AAAA,QAET,GAAI,KAAK,MAAM;AAAA,QACf,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,SAA0C,OAAU;AAClD,WAAO,IAAI,aAAa;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,OAAO;AAAA;AAAA,QAEL,GAAI,KAAK,MAAM;AAAA,QACf,OAAI;AAAA,cACF,8BAAc,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,SAAK,yBAAW,GAAG,CAAC,CAAC;AAAA,QAC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,SAAS,QAAI,wBAAU,QAAQ,YAAmB;AAAA,IACxD;AAEA,WAAO;AAAA,EACT;AACF;AAEO,SAAS,qBAAqB;AACnC,SAAO,IAAI,aAAa,CAAC,CAAC;AAC5B;",
5
- "names": []
6
- }
@@ -1,160 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var buildThemes_exports = {};
20
- __export(buildThemes_exports, {
21
- ThemeBuilder: () => ThemeBuilder
22
- });
23
- module.exports = __toCommonJS(buildThemes_exports);
24
- var import_createTheme = require("./createTheme");
25
- var import_helpers = require("./helpers");
26
- var import_masks = require("./masks");
27
- class ThemeBuilder {
28
- constructor(state = {}) {
29
- this.state = state;
30
- }
31
- addPalettes(palettes) {
32
- return new ThemeBuilder({
33
- ...this.state,
34
- palettes: {
35
- // as {} prevents generic string key merge messing up types
36
- ...this.state.palettes,
37
- ...palettes
38
- }
39
- });
40
- }
41
- addTemplates(templates) {
42
- return new ThemeBuilder({
43
- ...this.state,
44
- templates: {
45
- // as {} prevents generic string key merge messing up types
46
- ...this.state.templates,
47
- ...templates
48
- }
49
- });
50
- }
51
- addMasks(masks) {
52
- return new ThemeBuilder({
53
- ...this.state,
54
- masks: {
55
- // as {} prevents generic string key merge messing up types
56
- ...this.state.masks,
57
- ...masks
58
- }
59
- });
60
- }
61
- addThemes(themes) {
62
- return new ThemeBuilder({
63
- ...this.state,
64
- themes: {
65
- // as {} prevents generic string key merge messing up types
66
- ...this.state.themes,
67
- ...themes
68
- }
69
- });
70
- }
71
- addChildThemes(childThemeDefinition, options) {
72
- const currentThemes = this.state.themes;
73
- if (!currentThemes) {
74
- throw new Error(
75
- `No themes defined yet, use addThemes first to set your base themes`
76
- );
77
- }
78
- const currentThemeNames = (0, import_helpers.objectKeys)(currentThemes);
79
- const incomingThemeNames = (0, import_helpers.objectKeys)(childThemeDefinition);
80
- const namesWithDefinitions = currentThemeNames.flatMap((prefix) => {
81
- return incomingThemeNames.map((subName) => {
82
- const fullName = `${prefix}_${subName}`;
83
- const definition = childThemeDefinition[subName];
84
- return [fullName, definition];
85
- });
86
- });
87
- const childThemes = (0, import_helpers.objectFromEntries)(namesWithDefinitions);
88
- return new ThemeBuilder({
89
- ...this.state,
90
- themes: {
91
- // as {} prevents generic string key merge messing up types
92
- ...this.state.themes,
93
- ...childThemes
94
- }
95
- });
96
- }
97
- build() {
98
- var _a, _b;
99
- if (!this.state.themes) {
100
- return {};
101
- }
102
- const out = {};
103
- const maskedThemes = [];
104
- for (const themeName in this.state.themes) {
105
- const nameParts = themeName.split("_");
106
- const parentName = nameParts.slice(0, nameParts.length - 1).join("_");
107
- const definitions = this.state.themes[themeName];
108
- const themeDefinition = Array.isArray(definitions) ? (() => {
109
- const found = definitions.find((d) => parentName.startsWith(d.parent));
110
- if (!found) {
111
- throw new Error(`No parent for ${themeName}: ${parentName}`);
112
- }
113
- return found;
114
- })() : definitions;
115
- if ("mask" in themeDefinition) {
116
- maskedThemes.push({ parentName, themeName, mask: themeDefinition.mask });
117
- } else {
118
- if (!this.state.palettes) {
119
- throw new Error(
120
- `No palettes defined for theme with palette expected: ${themeName}`
121
- );
122
- }
123
- let palette = this.state.palettes[themeDefinition.palette];
124
- if (!palette) {
125
- const fullPaletteName = `${parentName}_${themeDefinition.palette}`;
126
- palette = this.state.palettes[fullPaletteName];
127
- }
128
- if (!palette) {
129
- throw new Error(`No palette for theme ${themeName}: ${themeDefinition.palette}`);
130
- }
131
- const template = (_a = this.state.templates) == null ? void 0 : _a[themeDefinition.template];
132
- if (!template) {
133
- throw new Error(
134
- `No template for theme ${themeName}: ${themeDefinition.template}`
135
- );
136
- }
137
- out[themeName] = (0, import_createTheme.createTheme)(palette, template);
138
- }
139
- }
140
- for (const { mask, themeName, parentName } of maskedThemes) {
141
- const parent = out[parentName];
142
- if (!parent) {
143
- throw new Error(
144
- `No parent theme found with name ${parentName} for theme ${themeName} to use as a mask target`
145
- );
146
- }
147
- const maskFunction = (_b = this.state.masks) == null ? void 0 : _b[mask];
148
- if (!maskFunction) {
149
- throw new Error(`No mask ${maskFunction}`);
150
- }
151
- out[themeName] = (0, import_masks.applyMask)(parent, maskFunction);
152
- }
153
- return out;
154
- }
155
- }
156
- // Annotate the CommonJS export names for ESM import in node:
157
- 0 && (module.exports = {
158
- ThemeBuilder
159
- });
160
- //# sourceMappingURL=buildThemes.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/buildThemes.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,qBAA8C;AAC9C,mBAA0B;AAmDnB,MAAM,aAA8C;AAAA,EACzD,YAAmB,QAAe,CAAC,GAAY;AAA5B;AAAA,EAA6B;AAAA,EAEhD,YAA0C,UAAa;AACrD,WAAO,IAAI,aAAa;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,UAAU;AAAA;AAAA,QAER,GAAI,KAAK,MAAM;AAAA,QACf,GAAG;AAAA,MACL;AAAA,IACF,CAAU;AAAA,EACZ;AAAA,EAEA,aAA4C,WAAc;AACxD,WAAO,IAAI,aAAa;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,WAAW;AAAA;AAAA,QAET,GAAI,KAAK,MAAM;AAAA,QACf,GAAG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gBAAe,UAAK,MAAM,UAAX,mBAAmB;AAExC,UAAI,CAAC,cAAc;AACjB,cAAM,IAAI,MAAM,WAAW,cAAc;AAAA,MAC3C;AAEA,UAAI,SAAS,QAAI,wBAAU,QAAQ,YAAmB;AAAA,IACxD;AAEA,WAAO;AAAA,EAGT;AACF;",
5
- "names": []
6
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var createTheme_exports = {};
20
- __export(createTheme_exports, {
21
- addChildren: () => addChildren,
22
- createTheme: () => createTheme
23
- });
24
- module.exports = __toCommonJS(createTheme_exports);
25
- var import_isMinusZero = require("./isMinusZero");
26
- var import_themeInfo = require("./themeInfo");
27
- const identityCache = /* @__PURE__ */ new Map();
28
- function createTheme(palette, definition, options) {
29
- const cacheKey = JSON.stringify([palette, definition, options]);
30
- if (identityCache.has(cacheKey)) {
31
- return identityCache.get(cacheKey);
32
- }
33
- const theme = {
34
- ...Object.fromEntries(
35
- Object.entries(definition).map(([key, offset]) => {
36
- return [key, getValue(palette, offset)];
37
- })
38
- ),
39
- ...options == null ? void 0 : options.nonInheritedValues
40
- };
41
- (0, import_themeInfo.setThemeInfo)(theme, { palette, definition });
42
- identityCache.set(cacheKey, theme);
43
- return theme;
44
- }
45
- const getValue = (palette, value) => {
46
- if (typeof value === "string")
47
- return value;
48
- const max = palette.length - 1;
49
- const isPositive = value === 0 ? !(0, import_isMinusZero.isMinusZero)(value) : value >= 0;
50
- const next = isPositive ? value : max + value;
51
- const index = Math.min(Math.max(0, next), max);
52
- return palette[index];
53
- };
54
- function addChildren(themes, getChildren) {
55
- const out = { ...themes };
56
- for (const key in themes) {
57
- const subThemes = getChildren(key, themes[key]);
58
- for (const sKey in subThemes) {
59
- out[`${key}_${sKey}`] = subThemes[sKey];
60
- }
61
- }
62
- return out;
63
- }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- addChildren,
67
- createTheme
68
- });
69
- //# sourceMappingURL=createTheme.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/createTheme.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,uBAA6B;AAG7B,MAAM,gBAAgB,oBAAI,IAAI;AAEvB,SAAS,YAId,SACA,YACA,SAKA;AACA,QAAM,WAAW,KAAK,UAAU,CAAC,SAAS,YAAY,OAAO,CAAC;AAC9D,MAAI,cAAc,IAAI,QAAQ,GAAG;AAC/B,WAAO,cAAc,IAAI,QAAQ;AAAA,EACnC;AAEA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO;AAAA,MACT,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM;AAChD,eAAO,CAAC,KAAK,SAAS,SAAS,MAAM,CAAC;AAAA,MACxC,CAAC;AAAA,IACH;AAAA,IACA,GAAG,mCAAS;AAAA,EACd;AAEA,qCAAa,OAAO,EAAE,SAAS,WAAW,CAAC;AAC3C,gBAAc,IAAI,UAAU,KAAK;AAEjC,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,SAA6B,UAA2B;AACxE,MAAI,OAAO,UAAU;AAAU,WAAO;AACtC,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,aAAa,UAAU,IAAI,KAAC,gCAAY,KAAK,IAAI,SAAS;AAChE,QAAM,OAAO,aAAa,QAAQ,MAAM;AACxC,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,GAAG;AAC7C,SAAO,QAAQ,KAAK;AACtB;AAWO,SAAS,YAId,QACA,aAGA;AACA,QAAM,MAAM,EAAE,GAAG,OAAO;AACxB,aAAW,OAAO,QAAQ;AACxB,UAAM,YAAY,YAAY,KAAK,OAAO,GAAG,CAAC;AAC9C,eAAW,QAAQ,WAAW;AAC5B,UAAI,GAAG,OAAO,MAAM,IAAI,UAAU,IAAI;AAAA,IACxC;AAAA,EACF;AACA,SAAO;AACT;",
5
- "names": []
6
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var helpers_exports = {};
20
- __export(helpers_exports, {
21
- objectEntries: () => objectEntries,
22
- objectFromEntries: () => objectFromEntries,
23
- objectKeys: () => objectKeys
24
- });
25
- module.exports = __toCommonJS(helpers_exports);
26
- const objectKeys = (obj) => Object.keys(obj);
27
- function objectEntries(obj) {
28
- return Object.entries(obj);
29
- }
30
- function objectFromEntries(arr) {
31
- return Object.fromEntries(arr);
32
- }
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- objectEntries,
36
- objectFromEntries,
37
- objectKeys
38
- });
39
- //# sourceMappingURL=helpers.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,aAAa,CAAmB,QAAW,OAAO,KAAK,GAAG;AAEhE,SAAS,cACd,KACsB;AACtB,SAAO,OAAO,QAAQ,GAAG;AAC3B;AAyBO,SAAS,kBACd,KACwB;AACxB,SAAO,OAAO,YAAY,GAAG;AAC/B;",
5
- "names": []
6
- }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var isMinusZero_exports = {};
20
- __export(isMinusZero_exports, {
21
- isMinusZero: () => isMinusZero
22
- });
23
- module.exports = __toCommonJS(isMinusZero_exports);
24
- function isMinusZero(value) {
25
- return 1 / value === -Infinity;
26
- }
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- isMinusZero
30
- });
31
- //# sourceMappingURL=isMinusZero.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/isMinusZero.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,YAAY,OAAO;AACjC,SAAO,IAAI,UAAU;AACvB;",
5
- "names": []
6
- }