@hanzogui/theme-builder 2.0.0-rc.41-hanzoai.5
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.
- package/LICENSE +21 -0
- package/dist/cjs/ThemeBuilder.cjs +248 -0
- package/dist/cjs/ThemeBuilder.native.js +338 -0
- package/dist/cjs/ThemeBuilder.native.js.map +1 -0
- package/dist/cjs/createStudioThemes.cjs +42 -0
- package/dist/cjs/createStudioThemes.native.js +45 -0
- package/dist/cjs/createStudioThemes.native.js.map +1 -0
- package/dist/cjs/createThemes.cjs +395 -0
- package/dist/cjs/createThemes.native.js +405 -0
- package/dist/cjs/createThemes.native.js.map +1 -0
- package/dist/cjs/defaultComponentThemes.cjs +86 -0
- package/dist/cjs/defaultComponentThemes.native.js +89 -0
- package/dist/cjs/defaultComponentThemes.native.js.map +1 -0
- package/dist/cjs/defaultTemplates.cjs +154 -0
- package/dist/cjs/defaultTemplates.native.js +162 -0
- package/dist/cjs/defaultTemplates.native.js.map +1 -0
- package/dist/cjs/defaultTemplatesStronger.cjs +152 -0
- package/dist/cjs/defaultTemplatesStronger.native.js +160 -0
- package/dist/cjs/defaultTemplatesStronger.native.js.map +1 -0
- package/dist/cjs/defaultTemplatesStrongest.cjs +152 -0
- package/dist/cjs/defaultTemplatesStrongest.native.js +160 -0
- package/dist/cjs/defaultTemplatesStrongest.native.js.map +1 -0
- package/dist/cjs/getThemeSuitePalettes.cjs +92 -0
- package/dist/cjs/getThemeSuitePalettes.native.js +117 -0
- package/dist/cjs/getThemeSuitePalettes.native.js.map +1 -0
- package/dist/cjs/helpers.cjs +36 -0
- package/dist/cjs/helpers.native.js +41 -0
- package/dist/cjs/helpers.native.js.map +1 -0
- package/dist/cjs/index.cjs +45 -0
- package/dist/cjs/index.native.js +48 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/masks.cjs +117 -0
- package/dist/cjs/masks.native.js +120 -0
- package/dist/cjs/masks.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/ThemeBuilder.mjs +222 -0
- package/dist/esm/ThemeBuilder.mjs.map +1 -0
- package/dist/esm/ThemeBuilder.native.js +309 -0
- package/dist/esm/ThemeBuilder.native.js.map +1 -0
- package/dist/esm/createStudioThemes.mjs +17 -0
- package/dist/esm/createStudioThemes.mjs.map +1 -0
- package/dist/esm/createStudioThemes.native.js +17 -0
- package/dist/esm/createStudioThemes.native.js.map +1 -0
- package/dist/esm/createThemes.mjs +364 -0
- package/dist/esm/createThemes.mjs.map +1 -0
- package/dist/esm/createThemes.native.js +371 -0
- package/dist/esm/createThemes.native.js.map +1 -0
- package/dist/esm/defaultComponentThemes.mjs +61 -0
- package/dist/esm/defaultComponentThemes.mjs.map +1 -0
- package/dist/esm/defaultComponentThemes.native.js +61 -0
- package/dist/esm/defaultComponentThemes.native.js.map +1 -0
- package/dist/esm/defaultTemplates.mjs +129 -0
- package/dist/esm/defaultTemplates.mjs.map +1 -0
- package/dist/esm/defaultTemplates.native.js +134 -0
- package/dist/esm/defaultTemplates.native.js.map +1 -0
- package/dist/esm/defaultTemplatesStronger.mjs +127 -0
- package/dist/esm/defaultTemplatesStronger.mjs.map +1 -0
- package/dist/esm/defaultTemplatesStronger.native.js +132 -0
- package/dist/esm/defaultTemplatesStronger.native.js.map +1 -0
- package/dist/esm/defaultTemplatesStrongest.mjs +127 -0
- package/dist/esm/defaultTemplatesStrongest.mjs.map +1 -0
- package/dist/esm/defaultTemplatesStrongest.native.js +132 -0
- package/dist/esm/defaultTemplatesStrongest.native.js.map +1 -0
- package/dist/esm/getThemeSuitePalettes.mjs +66 -0
- package/dist/esm/getThemeSuitePalettes.mjs.map +1 -0
- package/dist/esm/getThemeSuitePalettes.native.js +88 -0
- package/dist/esm/getThemeSuitePalettes.native.js.map +1 -0
- package/dist/esm/helpers.mjs +9 -0
- package/dist/esm/helpers.mjs.map +1 -0
- package/dist/esm/helpers.native.js +11 -0
- package/dist/esm/helpers.native.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +10 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +10 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/masks.mjs +92 -0
- package/dist/esm/masks.mjs.map +1 -0
- package/dist/esm/masks.native.js +92 -0
- package/dist/esm/masks.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/package.json +48 -0
- package/src/ThemeBuilder.ts +514 -0
- package/src/createStudioThemes.ts +28 -0
- package/src/createThemes.ts +794 -0
- package/src/defaultComponentThemes.ts +26 -0
- package/src/defaultTemplates.ts +157 -0
- package/src/defaultTemplatesStronger.ts +152 -0
- package/src/defaultTemplatesStrongest.ts +152 -0
- package/src/getThemeSuitePalettes.ts +101 -0
- package/src/helpers.ts +44 -0
- package/src/index.ts +22 -0
- package/src/masks.tsx +83 -0
- package/src/types.ts +97 -0
- package/types/ThemeBuilder.d.ts +80 -0
- package/types/ThemeBuilder.d.ts.map +1 -0
- package/types/createStudioThemes.d.ts +8 -0
- package/types/createStudioThemes.d.ts.map +1 -0
- package/types/createThemes.d.ts +141 -0
- package/types/createThemes.d.ts.map +1 -0
- package/types/defaultComponentThemes.d.ts +63 -0
- package/types/defaultComponentThemes.d.ts.map +1 -0
- package/types/defaultTemplates.d.ts +42 -0
- package/types/defaultTemplates.d.ts.map +1 -0
- package/types/defaultTemplatesStronger.d.ts +42 -0
- package/types/defaultTemplatesStronger.d.ts.map +1 -0
- package/types/defaultTemplatesStrongest.d.ts +42 -0
- package/types/defaultTemplatesStrongest.d.ts.map +1 -0
- package/types/getThemeSuitePalettes.d.ts +7 -0
- package/types/getThemeSuitePalettes.d.ts.map +1 -0
- package/types/helpers.d.ts +24 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +11 -0
- package/types/index.d.ts.map +1 -0
- package/types/masks.d.ts +18 -0
- package/types/masks.d.ts.map +1 -0
- package/types/types.d.ts +76 -0
- package/types/types.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var ThemeBuilder_exports = {};
|
|
24
|
+
__export(ThemeBuilder_exports, {
|
|
25
|
+
ThemeBuilder: () => ThemeBuilder,
|
|
26
|
+
createThemeBuilder: () => createThemeBuilder
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(ThemeBuilder_exports);
|
|
29
|
+
var import_create_theme = require("@hanzogui/create-theme");
|
|
30
|
+
class ThemeBuilder {
|
|
31
|
+
constructor(state) {
|
|
32
|
+
this.state = state;
|
|
33
|
+
}
|
|
34
|
+
state;
|
|
35
|
+
_getThemeFn;
|
|
36
|
+
addPalettes(palettes) {
|
|
37
|
+
this.state.palettes = {
|
|
38
|
+
// as {} prevents generic string key merge messing up types
|
|
39
|
+
...this.state.palettes,
|
|
40
|
+
...palettes
|
|
41
|
+
};
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
addTemplates(templates) {
|
|
45
|
+
this.state.templates = {
|
|
46
|
+
// as {} prevents generic string key merge messing up types
|
|
47
|
+
...this.state.templates,
|
|
48
|
+
...templates
|
|
49
|
+
};
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
addMasks(masks) {
|
|
53
|
+
this.state.masks = {
|
|
54
|
+
// as {} prevents generic string key merge messing up types
|
|
55
|
+
...this.state.masks,
|
|
56
|
+
...(0, import_create_theme.objectFromEntries)((0, import_create_theme.objectEntries)(masks).map(([key, val]) => [key, (0, import_create_theme.createMask)(val)]))
|
|
57
|
+
};
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
// for dev mode only really
|
|
61
|
+
_addedThemes = [];
|
|
62
|
+
addThemes(themes) {
|
|
63
|
+
this._addedThemes.push({
|
|
64
|
+
type: "themes",
|
|
65
|
+
args: [themes]
|
|
66
|
+
});
|
|
67
|
+
this.state.themes = {
|
|
68
|
+
// as {} prevents generic string key merge messing up types
|
|
69
|
+
...this.state.themes,
|
|
70
|
+
...themes
|
|
71
|
+
};
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
// these wont be typed to save some complexity and because they don't need to be typed!
|
|
75
|
+
addComponentThemes(childThemeDefinition, options) {
|
|
76
|
+
void this.addChildThemes(childThemeDefinition, options);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
addChildThemes(childThemeDefinition, options) {
|
|
80
|
+
const currentThemes = this.state.themes;
|
|
81
|
+
if (!currentThemes) {
|
|
82
|
+
throw new Error(`No themes defined yet, use addThemes first to set your base themes`);
|
|
83
|
+
}
|
|
84
|
+
this._addedThemes.push({
|
|
85
|
+
type: "childThemes",
|
|
86
|
+
args: [childThemeDefinition, options]
|
|
87
|
+
});
|
|
88
|
+
const currentThemeNames = Object.keys(currentThemes);
|
|
89
|
+
const incomingThemeNames = Object.keys(childThemeDefinition);
|
|
90
|
+
const namesWithDefinitions = currentThemeNames.flatMap(prefix => {
|
|
91
|
+
const avoidNestingWithin = options?.avoidNestingWithin;
|
|
92
|
+
if (avoidNestingWithin) {
|
|
93
|
+
if (avoidNestingWithin.some(avoidName => prefix.startsWith(avoidName) || prefix.endsWith(avoidName))) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return incomingThemeNames.map(subName => {
|
|
98
|
+
const fullName = `${prefix}_${subName}`;
|
|
99
|
+
const definition = childThemeDefinition[subName];
|
|
100
|
+
if ("avoidNestingWithin" in definition) {
|
|
101
|
+
const avoidNest = definition.avoidNestingWithin;
|
|
102
|
+
if (avoidNest.some(name => {
|
|
103
|
+
if ((name === "light" || name === "dark") && prefix.includes("_")) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return prefix.startsWith(name) || prefix.endsWith(name);
|
|
107
|
+
})) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (prefix.endsWith(`_${subName}`)) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
if (fullName in currentThemes) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
return [fullName, definition];
|
|
118
|
+
}).filter(Boolean);
|
|
119
|
+
});
|
|
120
|
+
const childThemes = Object.fromEntries(namesWithDefinitions);
|
|
121
|
+
const next = {
|
|
122
|
+
// as {} prevents generic string key merge messing up types
|
|
123
|
+
...this.state.themes,
|
|
124
|
+
...childThemes
|
|
125
|
+
};
|
|
126
|
+
this.state.themes = next;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
getTheme(fn) {
|
|
130
|
+
this._getThemeFn = fn;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
build() {
|
|
134
|
+
if (!this.state.themes) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const out = {};
|
|
138
|
+
const maskedThemes = [];
|
|
139
|
+
for (const themeName in this.state.themes) {
|
|
140
|
+
const nameParts = themeName.split("_");
|
|
141
|
+
const parentName = nameParts.slice(0, nameParts.length - 1).join("_");
|
|
142
|
+
const definitions = this.state.themes[themeName];
|
|
143
|
+
const themeDefinition = Array.isArray(definitions) ? (() => {
|
|
144
|
+
const found = definitions.find(
|
|
145
|
+
// endWith match stronger than startsWith
|
|
146
|
+
d => d.parent ? parentName.endsWith(d.parent) || parentName.startsWith(d.parent) : true);
|
|
147
|
+
if (!found) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return found;
|
|
151
|
+
})() : definitions;
|
|
152
|
+
if (!themeDefinition) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if ("theme" in themeDefinition) {
|
|
156
|
+
out[themeName] = themeDefinition.theme;
|
|
157
|
+
} else if ("mask" in themeDefinition) {
|
|
158
|
+
maskedThemes.push({
|
|
159
|
+
parentName,
|
|
160
|
+
themeName,
|
|
161
|
+
mask: themeDefinition
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
let {
|
|
165
|
+
palette: paletteName = "",
|
|
166
|
+
template: templateName,
|
|
167
|
+
...options
|
|
168
|
+
} = themeDefinition;
|
|
169
|
+
const parentDefinition = this.state.themes[parentName];
|
|
170
|
+
if (!this.state.palettes) {
|
|
171
|
+
throw new Error(`No palettes defined for theme with palette expected: ${themeName}`);
|
|
172
|
+
}
|
|
173
|
+
let palette = this.state.palettes[paletteName || ""];
|
|
174
|
+
let attemptParentName = `${parentName}_${paletteName}`;
|
|
175
|
+
while (!palette && attemptParentName) {
|
|
176
|
+
if (attemptParentName in this.state.palettes) {
|
|
177
|
+
palette = this.state.palettes[attemptParentName];
|
|
178
|
+
paletteName = attemptParentName;
|
|
179
|
+
} else {
|
|
180
|
+
attemptParentName = attemptParentName.split("_").slice(0, -1).join("_");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!palette) {
|
|
184
|
+
const msg = process.env.NODE_ENV !== "production" ? `: ${themeName}: ${paletteName}
|
|
185
|
+
Definition: ${JSON.stringify(themeDefinition)}
|
|
186
|
+
Parent: ${JSON.stringify(parentDefinition)}
|
|
187
|
+
Potential: (${Object.keys(this.state.palettes).join(", ")})` : ``;
|
|
188
|
+
throw new Error(`No palette for theme${msg}`);
|
|
189
|
+
}
|
|
190
|
+
const template = this.state.templates?.[templateName] ??
|
|
191
|
+
// fall back to finding the scheme specific on if it exists
|
|
192
|
+
this.state.templates?.[`${nameParts[0]}_${templateName}`];
|
|
193
|
+
if (!template) {
|
|
194
|
+
throw new Error(`No template for theme ${themeName}: ${templateName} in templates:
|
|
195
|
+
- ${Object.keys(this.state.templates || {}).join("\n - ")}`);
|
|
196
|
+
}
|
|
197
|
+
const theme = (0, import_create_theme.createThemeWithPalettes)(this.state.palettes, paletteName, template, options, themeName, true);
|
|
198
|
+
out[themeName] = this._getThemeFn ? {
|
|
199
|
+
...theme,
|
|
200
|
+
...this._getThemeFn({
|
|
201
|
+
theme,
|
|
202
|
+
name: themeName,
|
|
203
|
+
level: nameParts.length,
|
|
204
|
+
parentName,
|
|
205
|
+
scheme: /^(light|dark)$/.test(nameParts[0]) ? nameParts[0] : void 0,
|
|
206
|
+
parentNames: nameParts.slice(0, -1),
|
|
207
|
+
palette,
|
|
208
|
+
template
|
|
209
|
+
})
|
|
210
|
+
} : theme;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const {
|
|
214
|
+
mask,
|
|
215
|
+
themeName,
|
|
216
|
+
parentName
|
|
217
|
+
} of maskedThemes) {
|
|
218
|
+
const parent = out[parentName];
|
|
219
|
+
if (!parent) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const {
|
|
223
|
+
mask: maskName,
|
|
224
|
+
...options
|
|
225
|
+
} = mask;
|
|
226
|
+
let maskFunction = this.state.masks?.[maskName];
|
|
227
|
+
if (!maskFunction) {
|
|
228
|
+
throw new Error(`No mask ${maskName}`);
|
|
229
|
+
}
|
|
230
|
+
const parentTheme = this.state.themes[parentName];
|
|
231
|
+
if (parentTheme && "childOptions" in parentTheme) {
|
|
232
|
+
const {
|
|
233
|
+
mask: mask2,
|
|
234
|
+
...childOpts
|
|
235
|
+
} = parentTheme.childOptions;
|
|
236
|
+
if (mask2) {
|
|
237
|
+
maskFunction = this.state.masks?.[mask2];
|
|
238
|
+
}
|
|
239
|
+
Object.assign(options, childOpts);
|
|
240
|
+
}
|
|
241
|
+
out[themeName] = (0, import_create_theme.applyMask)(parent, maskFunction, options, parentName, themeName);
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function createThemeBuilder() {
|
|
247
|
+
return new ThemeBuilder({});
|
|
248
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var ThemeBuilder_exports = {};
|
|
26
|
+
__export(ThemeBuilder_exports, {
|
|
27
|
+
ThemeBuilder: () => ThemeBuilder,
|
|
28
|
+
createThemeBuilder: () => createThemeBuilder
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(ThemeBuilder_exports);
|
|
31
|
+
var import_create_theme = require("@hanzogui/create-theme");
|
|
32
|
+
function _class_call_check(instance, Constructor) {
|
|
33
|
+
if (!(instance instanceof Constructor)) {
|
|
34
|
+
throw new TypeError("Cannot call a class as a function");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function _defineProperties(target, props) {
|
|
38
|
+
for (var i = 0; i < props.length; i++) {
|
|
39
|
+
var descriptor = props[i];
|
|
40
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
41
|
+
descriptor.configurable = true;
|
|
42
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
43
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
47
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
48
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
49
|
+
return Constructor;
|
|
50
|
+
}
|
|
51
|
+
function _define_property(obj, key, value) {
|
|
52
|
+
if (key in obj) {
|
|
53
|
+
Object.defineProperty(obj, key, {
|
|
54
|
+
value,
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
obj[key] = value;
|
|
61
|
+
}
|
|
62
|
+
return obj;
|
|
63
|
+
}
|
|
64
|
+
var ThemeBuilder = /* @__PURE__ */function () {
|
|
65
|
+
"use strict";
|
|
66
|
+
|
|
67
|
+
function ThemeBuilder2(state) {
|
|
68
|
+
_class_call_check(this, ThemeBuilder2);
|
|
69
|
+
_define_property(this, "state", void 0);
|
|
70
|
+
_define_property(this, "_getThemeFn", void 0);
|
|
71
|
+
_define_property(this, "_addedThemes", void 0);
|
|
72
|
+
this.state = state;
|
|
73
|
+
this._addedThemes = [];
|
|
74
|
+
}
|
|
75
|
+
_create_class(ThemeBuilder2, [{
|
|
76
|
+
key: "addPalettes",
|
|
77
|
+
value: function addPalettes(palettes) {
|
|
78
|
+
this.state.palettes = {
|
|
79
|
+
// as {} prevents generic string key merge messing up types
|
|
80
|
+
...this.state.palettes,
|
|
81
|
+
...palettes
|
|
82
|
+
};
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "addTemplates",
|
|
87
|
+
value: function addTemplates(templates) {
|
|
88
|
+
this.state.templates = {
|
|
89
|
+
// as {} prevents generic string key merge messing up types
|
|
90
|
+
...this.state.templates,
|
|
91
|
+
...templates
|
|
92
|
+
};
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "addMasks",
|
|
97
|
+
value: function addMasks(masks) {
|
|
98
|
+
this.state.masks = {
|
|
99
|
+
// as {} prevents generic string key merge messing up types
|
|
100
|
+
...this.state.masks,
|
|
101
|
+
...(0, import_create_theme.objectFromEntries)((0, import_create_theme.objectEntries)(masks).map(function (param) {
|
|
102
|
+
var [key, val] = param;
|
|
103
|
+
return [key, (0, import_create_theme.createMask)(val)];
|
|
104
|
+
}))
|
|
105
|
+
};
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "addThemes",
|
|
110
|
+
value: function addThemes(themes) {
|
|
111
|
+
this._addedThemes.push({
|
|
112
|
+
type: "themes",
|
|
113
|
+
args: [themes]
|
|
114
|
+
});
|
|
115
|
+
this.state.themes = {
|
|
116
|
+
// as {} prevents generic string key merge messing up types
|
|
117
|
+
...this.state.themes,
|
|
118
|
+
...themes
|
|
119
|
+
};
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
// lets infer template themes directly onto here to avoid some type nesting issues later one
|
|
124
|
+
// themes: {
|
|
125
|
+
// [Key in keyof T]: TemplateToTheme<T[Key]>
|
|
126
|
+
// } & State['themes']
|
|
127
|
+
// these wont be typed to save some complexity and because they don't need to be typed!
|
|
128
|
+
key: "addComponentThemes",
|
|
129
|
+
value: function addComponentThemes(childThemeDefinition, options) {
|
|
130
|
+
void this.addChildThemes(childThemeDefinition, options);
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "addChildThemes",
|
|
135
|
+
value: function addChildThemes(childThemeDefinition, options) {
|
|
136
|
+
var currentThemes = this.state.themes;
|
|
137
|
+
if (!currentThemes) {
|
|
138
|
+
throw new Error(`No themes defined yet, use addThemes first to set your base themes`);
|
|
139
|
+
}
|
|
140
|
+
this._addedThemes.push({
|
|
141
|
+
type: "childThemes",
|
|
142
|
+
args: [childThemeDefinition, options]
|
|
143
|
+
});
|
|
144
|
+
var currentThemeNames = Object.keys(currentThemes);
|
|
145
|
+
var incomingThemeNames = Object.keys(childThemeDefinition);
|
|
146
|
+
var namesWithDefinitions = currentThemeNames.flatMap(function (prefix) {
|
|
147
|
+
var avoidNestingWithin = options === null || options === void 0 ? void 0 : options.avoidNestingWithin;
|
|
148
|
+
if (avoidNestingWithin) {
|
|
149
|
+
if (avoidNestingWithin.some(function (avoidName) {
|
|
150
|
+
return prefix.startsWith(avoidName) || prefix.endsWith(avoidName);
|
|
151
|
+
})) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return incomingThemeNames.map(function (subName) {
|
|
156
|
+
var fullName = `${prefix}_${subName}`;
|
|
157
|
+
var definition = childThemeDefinition[subName];
|
|
158
|
+
if ("avoidNestingWithin" in definition) {
|
|
159
|
+
var avoidNest = definition.avoidNestingWithin;
|
|
160
|
+
if (avoidNest.some(function (name) {
|
|
161
|
+
if ((name === "light" || name === "dark") && prefix.includes("_")) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return prefix.startsWith(name) || prefix.endsWith(name);
|
|
165
|
+
})) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (prefix.endsWith(`_${subName}`)) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
if (fullName in currentThemes) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return [fullName, definition];
|
|
176
|
+
}).filter(Boolean);
|
|
177
|
+
});
|
|
178
|
+
var childThemes = Object.fromEntries(namesWithDefinitions);
|
|
179
|
+
var next = {
|
|
180
|
+
// as {} prevents generic string key merge messing up types
|
|
181
|
+
...this.state.themes,
|
|
182
|
+
...childThemes
|
|
183
|
+
};
|
|
184
|
+
this.state.themes = next;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
key: "getTheme",
|
|
189
|
+
value: function getTheme(fn) {
|
|
190
|
+
this._getThemeFn = fn;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "build",
|
|
195
|
+
value: function build() {
|
|
196
|
+
var _this,
|
|
197
|
+
_loop = function (themeName2) {
|
|
198
|
+
var nameParts = themeName2.split("_");
|
|
199
|
+
var parentName2 = nameParts.slice(0, nameParts.length - 1).join("_");
|
|
200
|
+
var definitions = _this.state.themes[themeName2];
|
|
201
|
+
var themeDefinition = Array.isArray(definitions) ? function () {
|
|
202
|
+
var found = definitions.find(
|
|
203
|
+
// endWith match stronger than startsWith
|
|
204
|
+
function (d) {
|
|
205
|
+
return d.parent ? parentName2.endsWith(d.parent) || parentName2.startsWith(d.parent) : true;
|
|
206
|
+
});
|
|
207
|
+
if (!found) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return found;
|
|
211
|
+
}() : definitions;
|
|
212
|
+
if (!themeDefinition) {
|
|
213
|
+
return "continue";
|
|
214
|
+
}
|
|
215
|
+
if ("theme" in themeDefinition) {
|
|
216
|
+
out[themeName2] = themeDefinition.theme;
|
|
217
|
+
} else if ("mask" in themeDefinition) {
|
|
218
|
+
maskedThemes.push({
|
|
219
|
+
parentName: parentName2,
|
|
220
|
+
themeName: themeName2,
|
|
221
|
+
mask: themeDefinition
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
var _this_state_templates, _this_state_templates1;
|
|
225
|
+
var {
|
|
226
|
+
palette: paletteName = "",
|
|
227
|
+
template: templateName,
|
|
228
|
+
...options2
|
|
229
|
+
} = themeDefinition;
|
|
230
|
+
var parentDefinition = _this.state.themes[parentName2];
|
|
231
|
+
if (!_this.state.palettes) {
|
|
232
|
+
throw new Error(`No palettes defined for theme with palette expected: ${themeName2}`);
|
|
233
|
+
}
|
|
234
|
+
var palette = _this.state.palettes[paletteName || ""];
|
|
235
|
+
var attemptParentName = `${parentName2}_${paletteName}`;
|
|
236
|
+
while (!palette && attemptParentName) {
|
|
237
|
+
if (attemptParentName in _this.state.palettes) {
|
|
238
|
+
palette = _this.state.palettes[attemptParentName];
|
|
239
|
+
paletteName = attemptParentName;
|
|
240
|
+
} else {
|
|
241
|
+
attemptParentName = attemptParentName.split("_").slice(0, -1).join("_");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!palette) {
|
|
245
|
+
var msg = process.env.NODE_ENV !== "production" ? `: ${themeName2}: ${paletteName}
|
|
246
|
+
Definition: ${JSON.stringify(themeDefinition)}
|
|
247
|
+
Parent: ${JSON.stringify(parentDefinition)}
|
|
248
|
+
Potential: (${Object.keys(_this.state.palettes).join(", ")})` : ``;
|
|
249
|
+
throw new Error(`No palette for theme${msg}`);
|
|
250
|
+
}
|
|
251
|
+
var _this_state_templates_templateName;
|
|
252
|
+
var template = (_this_state_templates_templateName = (_this_state_templates = _this.state.templates) === null || _this_state_templates === void 0 ? void 0 : _this_state_templates[templateName]) !== null && _this_state_templates_templateName !== void 0 ? _this_state_templates_templateName : (_this_state_templates1 = _this.state.templates) === null || _this_state_templates1 === void 0 ? void 0 : _this_state_templates1[`${nameParts[0]}_${templateName}`];
|
|
253
|
+
if (!template) {
|
|
254
|
+
throw new Error(`No template for theme ${themeName2}: ${templateName} in templates:
|
|
255
|
+
- ${Object.keys(_this.state.templates || {}).join("\n - ")}`);
|
|
256
|
+
}
|
|
257
|
+
var theme = (0, import_create_theme.createThemeWithPalettes)(_this.state.palettes, paletteName, template, options2, themeName2, true);
|
|
258
|
+
out[themeName2] = _this._getThemeFn ? {
|
|
259
|
+
...theme,
|
|
260
|
+
..._this._getThemeFn({
|
|
261
|
+
theme,
|
|
262
|
+
name: themeName2,
|
|
263
|
+
level: nameParts.length,
|
|
264
|
+
parentName: parentName2,
|
|
265
|
+
scheme: /^(light|dark)$/.test(nameParts[0]) ? nameParts[0] : void 0,
|
|
266
|
+
parentNames: nameParts.slice(0, -1),
|
|
267
|
+
palette,
|
|
268
|
+
template
|
|
269
|
+
})
|
|
270
|
+
} : theme;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
if (!this.state.themes) {
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
var out = {};
|
|
277
|
+
var maskedThemes = [];
|
|
278
|
+
for (var themeName in this.state.themes) _this = this, _loop(themeName);
|
|
279
|
+
var _iteratorNormalCompletion = true,
|
|
280
|
+
_didIteratorError = false,
|
|
281
|
+
_iteratorError = void 0;
|
|
282
|
+
try {
|
|
283
|
+
for (var _iterator = maskedThemes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
284
|
+
var {
|
|
285
|
+
mask,
|
|
286
|
+
themeName: themeName1,
|
|
287
|
+
parentName
|
|
288
|
+
} = _step.value;
|
|
289
|
+
var _this_state_masks;
|
|
290
|
+
var parent = out[parentName];
|
|
291
|
+
if (!parent) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
var {
|
|
295
|
+
mask: maskName,
|
|
296
|
+
...options
|
|
297
|
+
} = mask;
|
|
298
|
+
var maskFunction = (_this_state_masks = this.state.masks) === null || _this_state_masks === void 0 ? void 0 : _this_state_masks[maskName];
|
|
299
|
+
if (!maskFunction) {
|
|
300
|
+
throw new Error(`No mask ${maskName}`);
|
|
301
|
+
}
|
|
302
|
+
var parentTheme = this.state.themes[parentName];
|
|
303
|
+
if (parentTheme && "childOptions" in parentTheme) {
|
|
304
|
+
var {
|
|
305
|
+
mask: mask1,
|
|
306
|
+
...childOpts
|
|
307
|
+
} = parentTheme.childOptions;
|
|
308
|
+
if (mask1) {
|
|
309
|
+
var _this_state_masks1;
|
|
310
|
+
maskFunction = (_this_state_masks1 = this.state.masks) === null || _this_state_masks1 === void 0 ? void 0 : _this_state_masks1[mask1];
|
|
311
|
+
}
|
|
312
|
+
Object.assign(options, childOpts);
|
|
313
|
+
}
|
|
314
|
+
out[themeName1] = (0, import_create_theme.applyMask)(parent, maskFunction, options, parentName, themeName1);
|
|
315
|
+
}
|
|
316
|
+
} catch (err) {
|
|
317
|
+
_didIteratorError = true;
|
|
318
|
+
_iteratorError = err;
|
|
319
|
+
} finally {
|
|
320
|
+
try {
|
|
321
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
322
|
+
_iterator.return();
|
|
323
|
+
}
|
|
324
|
+
} finally {
|
|
325
|
+
if (_didIteratorError) {
|
|
326
|
+
throw _iteratorError;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return out;
|
|
331
|
+
}
|
|
332
|
+
}]);
|
|
333
|
+
return ThemeBuilder2;
|
|
334
|
+
}();
|
|
335
|
+
function createThemeBuilder() {
|
|
336
|
+
return new ThemeBuilder({});
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=ThemeBuilder.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ThemeBuilder_exports","__export","ThemeBuilder","createThemeBuilder","module","exports","import_create_theme","require","_class_call_check","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","prototype","_define_property","obj","ThemeBuilder2","state","_addedThemes","addPalettes","palettes","addTemplates","templates","addMasks","masks","objectFromEntries","objectEntries","map","param","val","createMask","addThemes","themes","push","type","args","addComponentThemes","childThemeDefinition","options","addChildThemes","currentThemes","Error","currentThemeNames","keys","incomingThemeNames","namesWithDefinitions","flatMap","prefix","avoidNestingWithin","some","avoidName","startsWith","endsWith","subName","fullName","definition","avoidNest","name","includes","filter","Boolean","childThemes","fromEntries","next","getTheme","fn","_getThemeFn","build","_this","_loop","themeName2","nameParts","split","parentName2","slice","join","definitions","themeDefinition","Array","isArray","found","find","d","parent","out","theme","maskedThemes","parentName","themeName","mask","_this_state_templates","_this_state_templates1","palette","paletteName","template","templateName","options2","parentDefinition","attemptParentName"],"sources":["../../src/ThemeBuilder.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAQAC,MAAA,CAAAC,OAAA,GAAAV,YAMO,CAAAK,oBAAA;AAwFA,IAAAM,mBAGL,GAAAC,OAAA;AAAA,SAGAC,iBAAiCA,CAAAC,QAAA,EAAAC,WAAA;EAAd,MAAAD,QAAA,YAAAC,WAAA;IAAe,UAAAC,SAAA;EAAf;AAAA;AAFX,SAIRC,iBAA6DA,CAAAC,MAAA,EAAAC,KAAA;EAC3D,SAAKC,CAAA,GAAM,GAAAA,CAAA,GAAAD,KAAW,CAAAE,MAAA,EAAAD,CAAA;IAAA,IAAAE,UAAA,GAAAH,KAAA,CAAAC,CAAA;IAAAE,UAEX,CAAAC,UAAM,GAAAD,UAAA,CAAAC,UAAA;IAAAD,UACZ,CAAAE,YAAA;IACL,eAAAF,UAAA,EAAAA,UAAA,CAAAG,QAAA;IACAC,MAAA,CAAOC,cAAA,CAAAT,MAAA,EAAAI,UAAA,CAAAM,GAAA,EAAAN,UAAA;EAMT;AAAA;AAGE,SAAKO,aAAMA,CAAAd,WAAY,EAAAe,U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AA6B,UAAA;YAEO;YACT,IAAAsB,OAAA,GAAAxB,KAAA,CAAAnD,KAAA,CAAAG,QAAA,CAAAyE,WAAA;YACF,IAAAK,iBAAA,MAAAzB,WAAA,IAAAoB,WAAA;YAEgB,QAAAD,OAAA,IAAqBM,iBAAA;cACxB,IAAAA,iBAAe,IAAA9B,KAAA,CAAAnD,KAAA,CAAAG,QAAA;gBAC5BwE,OAAA,GAAAxB,KAAA,CAAAnD,KAAA,CAAAG,QAAA,CAAA8E,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var createStudioThemes_exports = {};
|
|
24
|
+
__export(createStudioThemes_exports, {
|
|
25
|
+
createStudioThemes: () => createStudioThemes
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(createStudioThemes_exports);
|
|
28
|
+
var import_createThemes = require("./createThemes.cjs");
|
|
29
|
+
var import_defaultComponentThemes = require("./defaultComponentThemes.cjs");
|
|
30
|
+
var import_defaultTemplates = require("./defaultTemplates.cjs");
|
|
31
|
+
var import_defaultTemplatesStronger = require("./defaultTemplatesStronger.cjs");
|
|
32
|
+
var import_defaultTemplatesStrongest = require("./defaultTemplatesStrongest.cjs");
|
|
33
|
+
function createStudioThemes(props) {
|
|
34
|
+
const palettes = (0, import_createThemes.createPalettes)(props.palettes);
|
|
35
|
+
const templates = props.templateStrategy === "stronger" ? import_defaultTemplatesStronger.defaultTemplatesStronger : props.templateStrategy === "strongest" ? import_defaultTemplatesStrongest.defaultTemplatesStrongest : import_defaultTemplates.defaultTemplates;
|
|
36
|
+
return (0, import_createThemes.createSimpleThemeBuilder)({
|
|
37
|
+
palettes,
|
|
38
|
+
templates,
|
|
39
|
+
componentThemes: import_defaultComponentThemes.defaultComponentThemes,
|
|
40
|
+
accentTheme: !!props.palettes.accent
|
|
41
|
+
});
|
|
42
|
+
}
|