@hanzogui/theme-builder 2.0.0
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 +184 -0
- package/dist/cjs/ThemeBuilder.native.js +262 -0
- package/dist/cjs/ThemeBuilder.native.js.map +1 -0
- package/dist/cjs/createStudioThemes.cjs +40 -0
- package/dist/cjs/createStudioThemes.native.js +43 -0
- package/dist/cjs/createStudioThemes.native.js.map +1 -0
- package/dist/cjs/createThemes.cjs +345 -0
- package/dist/cjs/createThemes.native.js +366 -0
- package/dist/cjs/createThemes.native.js.map +1 -0
- package/dist/cjs/defaultComponentThemes.cjs +84 -0
- package/dist/cjs/defaultComponentThemes.native.js +87 -0
- package/dist/cjs/defaultComponentThemes.native.js.map +1 -0
- package/dist/cjs/defaultTemplates.cjs +149 -0
- package/dist/cjs/defaultTemplates.native.js +160 -0
- package/dist/cjs/defaultTemplates.native.js.map +1 -0
- package/dist/cjs/defaultTemplatesStronger.cjs +147 -0
- package/dist/cjs/defaultTemplatesStronger.native.js +158 -0
- package/dist/cjs/defaultTemplatesStronger.native.js.map +1 -0
- package/dist/cjs/defaultTemplatesStrongest.cjs +147 -0
- package/dist/cjs/defaultTemplatesStrongest.native.js +158 -0
- package/dist/cjs/defaultTemplatesStrongest.native.js.map +1 -0
- package/dist/cjs/getThemeSuitePalettes.cjs +81 -0
- package/dist/cjs/getThemeSuitePalettes.native.js +93 -0
- package/dist/cjs/getThemeSuitePalettes.native.js.map +1 -0
- package/dist/cjs/helpers.cjs +34 -0
- package/dist/cjs/helpers.native.js +39 -0
- package/dist/cjs/helpers.native.js.map +1 -0
- package/dist/cjs/index.cjs +43 -0
- package/dist/cjs/index.native.js +46 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/masks.cjs +114 -0
- package/dist/cjs/masks.native.js +118 -0
- package/dist/cjs/masks.native.js.map +1 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.js +19 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/ThemeBuilder.mjs +160 -0
- package/dist/esm/ThemeBuilder.mjs.map +1 -0
- package/dist/esm/ThemeBuilder.native.js +235 -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 +316 -0
- package/dist/esm/createThemes.mjs.map +1 -0
- package/dist/esm/createThemes.native.js +334 -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 +126 -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 +124 -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 +124 -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 +57 -0
- package/dist/esm/getThemeSuitePalettes.mjs.map +1 -0
- package/dist/esm/getThemeSuitePalettes.native.js +66 -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 +91 -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,184 @@
|
|
|
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: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var ThemeBuilder_exports = {};
|
|
22
|
+
__export(ThemeBuilder_exports, {
|
|
23
|
+
ThemeBuilder: () => ThemeBuilder,
|
|
24
|
+
createThemeBuilder: () => createThemeBuilder
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(ThemeBuilder_exports);
|
|
27
|
+
var import_create_theme = require("@hanzogui/create-theme");
|
|
28
|
+
class ThemeBuilder {
|
|
29
|
+
constructor(state) {
|
|
30
|
+
this.state = state;
|
|
31
|
+
}
|
|
32
|
+
_getThemeFn;
|
|
33
|
+
addPalettes(palettes) {
|
|
34
|
+
return this.state.palettes = {
|
|
35
|
+
// as {} prevents generic string key merge messing up types
|
|
36
|
+
...this.state.palettes,
|
|
37
|
+
...palettes
|
|
38
|
+
}, this;
|
|
39
|
+
}
|
|
40
|
+
addTemplates(templates) {
|
|
41
|
+
return this.state.templates = {
|
|
42
|
+
// as {} prevents generic string key merge messing up types
|
|
43
|
+
...this.state.templates,
|
|
44
|
+
...templates
|
|
45
|
+
}, this;
|
|
46
|
+
}
|
|
47
|
+
addMasks(masks) {
|
|
48
|
+
return this.state.masks = {
|
|
49
|
+
// as {} prevents generic string key merge messing up types
|
|
50
|
+
...this.state.masks,
|
|
51
|
+
...(0, import_create_theme.objectFromEntries)((0, import_create_theme.objectEntries)(masks).map(([key, val]) => [key, (0, import_create_theme.createMask)(val)]))
|
|
52
|
+
}, this;
|
|
53
|
+
}
|
|
54
|
+
// for dev mode only really
|
|
55
|
+
_addedThemes = [];
|
|
56
|
+
addThemes(themes) {
|
|
57
|
+
return this._addedThemes.push({
|
|
58
|
+
type: "themes",
|
|
59
|
+
args: [themes]
|
|
60
|
+
}), this.state.themes = {
|
|
61
|
+
// as {} prevents generic string key merge messing up types
|
|
62
|
+
...this.state.themes,
|
|
63
|
+
...themes
|
|
64
|
+
}, this;
|
|
65
|
+
}
|
|
66
|
+
// these wont be typed to save some complexity and because they don't need to be typed!
|
|
67
|
+
addComponentThemes(childThemeDefinition, options) {
|
|
68
|
+
return this.addChildThemes(childThemeDefinition, options), this;
|
|
69
|
+
}
|
|
70
|
+
addChildThemes(childThemeDefinition, options) {
|
|
71
|
+
const currentThemes = this.state.themes;
|
|
72
|
+
if (!currentThemes) throw new Error("No themes defined yet, use addThemes first to set your base themes");
|
|
73
|
+
this._addedThemes.push({
|
|
74
|
+
type: "childThemes",
|
|
75
|
+
args: [childThemeDefinition, options]
|
|
76
|
+
});
|
|
77
|
+
const currentThemeNames = Object.keys(currentThemes),
|
|
78
|
+
incomingThemeNames = Object.keys(childThemeDefinition),
|
|
79
|
+
namesWithDefinitions = currentThemeNames.flatMap(prefix => {
|
|
80
|
+
const avoidNestingWithin = options?.avoidNestingWithin;
|
|
81
|
+
return avoidNestingWithin && avoidNestingWithin.some(avoidName => prefix.startsWith(avoidName) || prefix.endsWith(avoidName)) ? [] : incomingThemeNames.map(subName => {
|
|
82
|
+
const fullName = `${prefix}_${subName}`,
|
|
83
|
+
definition = childThemeDefinition[subName];
|
|
84
|
+
return "avoidNestingWithin" in definition && definition.avoidNestingWithin.some(name => (name === "light" || name === "dark") && prefix.includes("_") ? !1 : prefix.startsWith(name) || prefix.endsWith(name)) || prefix.endsWith(`_${subName}`) || fullName in currentThemes ? null : [fullName, definition];
|
|
85
|
+
}).filter(Boolean);
|
|
86
|
+
}),
|
|
87
|
+
childThemes = Object.fromEntries(namesWithDefinitions),
|
|
88
|
+
next = {
|
|
89
|
+
// as {} prevents generic string key merge messing up types
|
|
90
|
+
...this.state.themes,
|
|
91
|
+
...childThemes
|
|
92
|
+
};
|
|
93
|
+
return this.state.themes = next, this;
|
|
94
|
+
}
|
|
95
|
+
getTheme(fn) {
|
|
96
|
+
return this._getThemeFn = fn, this;
|
|
97
|
+
}
|
|
98
|
+
build() {
|
|
99
|
+
if (!this.state.themes) return {};
|
|
100
|
+
const out = {},
|
|
101
|
+
maskedThemes = [];
|
|
102
|
+
for (const themeName in this.state.themes) {
|
|
103
|
+
const nameParts = themeName.split("_"),
|
|
104
|
+
parentName = nameParts.slice(0, nameParts.length - 1).join("_"),
|
|
105
|
+
definitions = this.state.themes[themeName],
|
|
106
|
+
themeDefinition = Array.isArray(definitions) ? (() => {
|
|
107
|
+
const found = definitions.find(
|
|
108
|
+
// endWith match stronger than startsWith
|
|
109
|
+
d => d.parent ? parentName.endsWith(d.parent) || parentName.startsWith(d.parent) : !0);
|
|
110
|
+
return found || null;
|
|
111
|
+
})() : definitions;
|
|
112
|
+
if (themeDefinition) if ("theme" in themeDefinition) out[themeName] = themeDefinition.theme;else if ("mask" in themeDefinition) maskedThemes.push({
|
|
113
|
+
parentName,
|
|
114
|
+
themeName,
|
|
115
|
+
mask: themeDefinition
|
|
116
|
+
});else {
|
|
117
|
+
let {
|
|
118
|
+
palette: paletteName = "",
|
|
119
|
+
template: templateName,
|
|
120
|
+
...options
|
|
121
|
+
} = themeDefinition;
|
|
122
|
+
const parentDefinition = this.state.themes[parentName];
|
|
123
|
+
if (!this.state.palettes) throw new Error(`No palettes defined for theme with palette expected: ${themeName}`);
|
|
124
|
+
let palette = this.state.palettes[paletteName || ""],
|
|
125
|
+
attemptParentName = `${parentName}_${paletteName}`;
|
|
126
|
+
for (; !palette && attemptParentName;) attemptParentName in this.state.palettes ? (palette = this.state.palettes[attemptParentName], paletteName = attemptParentName) : attemptParentName = attemptParentName.split("_").slice(0, -1).join("_");
|
|
127
|
+
if (!palette) {
|
|
128
|
+
const msg = process.env.NODE_ENV !== "production" ? `: ${themeName}: ${paletteName}
|
|
129
|
+
Definition: ${JSON.stringify(themeDefinition)}
|
|
130
|
+
Parent: ${JSON.stringify(parentDefinition)}
|
|
131
|
+
Potential: (${Object.keys(this.state.palettes).join(", ")})` : "";
|
|
132
|
+
throw new Error(`No palette for theme${msg}`);
|
|
133
|
+
}
|
|
134
|
+
const template = this.state.templates?.[templateName] ??
|
|
135
|
+
// fall back to finding the scheme specific on if it exists
|
|
136
|
+
this.state.templates?.[`${nameParts[0]}_${templateName}`];
|
|
137
|
+
if (!template) throw new Error(`No template for theme ${themeName}: ${templateName} in templates:
|
|
138
|
+
- ${Object.keys(this.state.templates || {}).join(`
|
|
139
|
+
- `)}`);
|
|
140
|
+
const theme = (0, import_create_theme.createThemeWithPalettes)(this.state.palettes, paletteName, template, options, themeName, !0);
|
|
141
|
+
out[themeName] = this._getThemeFn ? {
|
|
142
|
+
...theme,
|
|
143
|
+
...this._getThemeFn({
|
|
144
|
+
theme,
|
|
145
|
+
name: themeName,
|
|
146
|
+
level: nameParts.length,
|
|
147
|
+
parentName,
|
|
148
|
+
scheme: /^(light|dark)$/.test(nameParts[0]) ? nameParts[0] : void 0,
|
|
149
|
+
parentNames: nameParts.slice(0, -1),
|
|
150
|
+
palette,
|
|
151
|
+
template
|
|
152
|
+
})
|
|
153
|
+
} : theme;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const {
|
|
157
|
+
mask,
|
|
158
|
+
themeName,
|
|
159
|
+
parentName
|
|
160
|
+
} of maskedThemes) {
|
|
161
|
+
const parent = out[parentName];
|
|
162
|
+
if (!parent) continue;
|
|
163
|
+
const {
|
|
164
|
+
mask: maskName,
|
|
165
|
+
...options
|
|
166
|
+
} = mask;
|
|
167
|
+
let maskFunction = this.state.masks?.[maskName];
|
|
168
|
+
if (!maskFunction) throw new Error(`No mask ${maskName}`);
|
|
169
|
+
const parentTheme = this.state.themes[parentName];
|
|
170
|
+
if (parentTheme && "childOptions" in parentTheme) {
|
|
171
|
+
const {
|
|
172
|
+
mask: mask2,
|
|
173
|
+
...childOpts
|
|
174
|
+
} = parentTheme.childOptions;
|
|
175
|
+
mask2 && (maskFunction = this.state.masks?.[mask2]), Object.assign(options, childOpts);
|
|
176
|
+
}
|
|
177
|
+
out[themeName] = (0, import_create_theme.applyMask)(parent, maskFunction, options, parentName, themeName);
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function createThemeBuilder() {
|
|
183
|
+
return new ThemeBuilder({});
|
|
184
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
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: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
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
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
32
|
+
}
|
|
33
|
+
function _defineProperties(target, props) {
|
|
34
|
+
for (var i = 0; i < props.length; i++) {
|
|
35
|
+
var descriptor = props[i];
|
|
36
|
+
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
40
|
+
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
|
|
41
|
+
}
|
|
42
|
+
function _define_property(obj, key, value) {
|
|
43
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
44
|
+
value,
|
|
45
|
+
enumerable: !0,
|
|
46
|
+
configurable: !0,
|
|
47
|
+
writable: !0
|
|
48
|
+
}) : obj[key] = value, obj;
|
|
49
|
+
}
|
|
50
|
+
var ThemeBuilder = /* @__PURE__ */function () {
|
|
51
|
+
"use strict";
|
|
52
|
+
|
|
53
|
+
function ThemeBuilder2(state) {
|
|
54
|
+
_class_call_check(this, ThemeBuilder2), _define_property(this, "state", void 0), _define_property(this, "_getThemeFn", void 0), _define_property(this, "_addedThemes", void 0), this.state = state, this._addedThemes = [];
|
|
55
|
+
}
|
|
56
|
+
return _create_class(ThemeBuilder2, [{
|
|
57
|
+
key: "addPalettes",
|
|
58
|
+
value: function (palettes) {
|
|
59
|
+
return this.state.palettes = {
|
|
60
|
+
// as {} prevents generic string key merge messing up types
|
|
61
|
+
...this.state.palettes,
|
|
62
|
+
...palettes
|
|
63
|
+
}, this;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "addTemplates",
|
|
67
|
+
value: function (templates) {
|
|
68
|
+
return this.state.templates = {
|
|
69
|
+
// as {} prevents generic string key merge messing up types
|
|
70
|
+
...this.state.templates,
|
|
71
|
+
...templates
|
|
72
|
+
}, this;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "addMasks",
|
|
76
|
+
value: function (masks) {
|
|
77
|
+
return this.state.masks = {
|
|
78
|
+
// as {} prevents generic string key merge messing up types
|
|
79
|
+
...this.state.masks,
|
|
80
|
+
...(0, import_create_theme.objectFromEntries)((0, import_create_theme.objectEntries)(masks).map(function (param) {
|
|
81
|
+
var [key, val] = param;
|
|
82
|
+
return [key, (0, import_create_theme.createMask)(val)];
|
|
83
|
+
}))
|
|
84
|
+
}, this;
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "addThemes",
|
|
88
|
+
value: function (themes) {
|
|
89
|
+
return this._addedThemes.push({
|
|
90
|
+
type: "themes",
|
|
91
|
+
args: [themes]
|
|
92
|
+
}), this.state.themes = {
|
|
93
|
+
// as {} prevents generic string key merge messing up types
|
|
94
|
+
...this.state.themes,
|
|
95
|
+
...themes
|
|
96
|
+
}, this;
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
// lets infer template themes directly onto here to avoid some type nesting issues later one
|
|
100
|
+
// themes: {
|
|
101
|
+
// [Key in keyof T]: TemplateToTheme<T[Key]>
|
|
102
|
+
// } & State['themes']
|
|
103
|
+
// these wont be typed to save some complexity and because they don't need to be typed!
|
|
104
|
+
key: "addComponentThemes",
|
|
105
|
+
value: function (childThemeDefinition, options) {
|
|
106
|
+
return this.addChildThemes(childThemeDefinition, options), this;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "addChildThemes",
|
|
110
|
+
value: function (childThemeDefinition, options) {
|
|
111
|
+
var currentThemes = this.state.themes;
|
|
112
|
+
if (!currentThemes) throw new Error("No themes defined yet, use addThemes first to set your base themes");
|
|
113
|
+
this._addedThemes.push({
|
|
114
|
+
type: "childThemes",
|
|
115
|
+
args: [childThemeDefinition, options]
|
|
116
|
+
});
|
|
117
|
+
var currentThemeNames = Object.keys(currentThemes),
|
|
118
|
+
incomingThemeNames = Object.keys(childThemeDefinition),
|
|
119
|
+
namesWithDefinitions = currentThemeNames.flatMap(function (prefix) {
|
|
120
|
+
var avoidNestingWithin = options?.avoidNestingWithin;
|
|
121
|
+
return avoidNestingWithin && avoidNestingWithin.some(function (avoidName) {
|
|
122
|
+
return prefix.startsWith(avoidName) || prefix.endsWith(avoidName);
|
|
123
|
+
}) ? [] : incomingThemeNames.map(function (subName) {
|
|
124
|
+
var fullName = `${prefix}_${subName}`,
|
|
125
|
+
definition = childThemeDefinition[subName];
|
|
126
|
+
if ("avoidNestingWithin" in definition) {
|
|
127
|
+
var avoidNest = definition.avoidNestingWithin;
|
|
128
|
+
if (avoidNest.some(function (name) {
|
|
129
|
+
return (name === "light" || name === "dark") && prefix.includes("_") ? !1 : prefix.startsWith(name) || prefix.endsWith(name);
|
|
130
|
+
})) return null;
|
|
131
|
+
}
|
|
132
|
+
return prefix.endsWith(`_${subName}`) || fullName in currentThemes ? null : [fullName, definition];
|
|
133
|
+
}).filter(Boolean);
|
|
134
|
+
}),
|
|
135
|
+
childThemes = Object.fromEntries(namesWithDefinitions),
|
|
136
|
+
next = {
|
|
137
|
+
// as {} prevents generic string key merge messing up types
|
|
138
|
+
...this.state.themes,
|
|
139
|
+
...childThemes
|
|
140
|
+
};
|
|
141
|
+
return this.state.themes = next, this;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "getTheme",
|
|
145
|
+
value: function (fn) {
|
|
146
|
+
return this._getThemeFn = fn, this;
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
key: "build",
|
|
150
|
+
value: function () {
|
|
151
|
+
var _this,
|
|
152
|
+
_loop = function (themeName2) {
|
|
153
|
+
var nameParts = themeName2.split("_"),
|
|
154
|
+
parentName2 = nameParts.slice(0, nameParts.length - 1).join("_"),
|
|
155
|
+
definitions = _this.state.themes[themeName2],
|
|
156
|
+
themeDefinition = Array.isArray(definitions) ? function () {
|
|
157
|
+
var found = definitions.find(
|
|
158
|
+
// endWith match stronger than startsWith
|
|
159
|
+
function (d) {
|
|
160
|
+
return d.parent ? parentName2.endsWith(d.parent) || parentName2.startsWith(d.parent) : !0;
|
|
161
|
+
});
|
|
162
|
+
return found || null;
|
|
163
|
+
}() : definitions;
|
|
164
|
+
if (!themeDefinition) return "continue";
|
|
165
|
+
if ("theme" in themeDefinition) out[themeName2] = themeDefinition.theme;else if ("mask" in themeDefinition) maskedThemes.push({
|
|
166
|
+
parentName: parentName2,
|
|
167
|
+
themeName: themeName2,
|
|
168
|
+
mask: themeDefinition
|
|
169
|
+
});else {
|
|
170
|
+
var _this_state_templates,
|
|
171
|
+
_this_state_templates1,
|
|
172
|
+
{
|
|
173
|
+
palette: paletteName = "",
|
|
174
|
+
template: templateName,
|
|
175
|
+
...options2
|
|
176
|
+
} = themeDefinition,
|
|
177
|
+
parentDefinition = _this.state.themes[parentName2];
|
|
178
|
+
if (!_this.state.palettes) throw new Error(`No palettes defined for theme with palette expected: ${themeName2}`);
|
|
179
|
+
for (var palette = _this.state.palettes[paletteName || ""], attemptParentName = `${parentName2}_${paletteName}`; !palette && attemptParentName;) attemptParentName in _this.state.palettes ? (palette = _this.state.palettes[attemptParentName], paletteName = attemptParentName) : attemptParentName = attemptParentName.split("_").slice(0, -1).join("_");
|
|
180
|
+
if (!palette) {
|
|
181
|
+
var msg = process.env.NODE_ENV !== "production" ? `: ${themeName2}: ${paletteName}
|
|
182
|
+
Definition: ${JSON.stringify(themeDefinition)}
|
|
183
|
+
Parent: ${JSON.stringify(parentDefinition)}
|
|
184
|
+
Potential: (${Object.keys(_this.state.palettes).join(", ")})` : "";
|
|
185
|
+
throw new Error(`No palette for theme${msg}`);
|
|
186
|
+
}
|
|
187
|
+
var _this_state_templates_templateName,
|
|
188
|
+
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}`];
|
|
189
|
+
if (!template) throw new Error(`No template for theme ${themeName2}: ${templateName} in templates:
|
|
190
|
+
- ${Object.keys(_this.state.templates || {}).join(`
|
|
191
|
+
- `)}`);
|
|
192
|
+
var theme = (0, import_create_theme.createThemeWithPalettes)(_this.state.palettes, paletteName, template, options2, themeName2, !0);
|
|
193
|
+
out[themeName2] = _this._getThemeFn ? {
|
|
194
|
+
...theme,
|
|
195
|
+
..._this._getThemeFn({
|
|
196
|
+
theme,
|
|
197
|
+
name: themeName2,
|
|
198
|
+
level: nameParts.length,
|
|
199
|
+
parentName: parentName2,
|
|
200
|
+
scheme: /^(light|dark)$/.test(nameParts[0]) ? nameParts[0] : void 0,
|
|
201
|
+
parentNames: nameParts.slice(0, -1),
|
|
202
|
+
palette,
|
|
203
|
+
template
|
|
204
|
+
})
|
|
205
|
+
} : theme;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (!this.state.themes) return {};
|
|
209
|
+
var out = {},
|
|
210
|
+
maskedThemes = [];
|
|
211
|
+
for (var themeName in this.state.themes) _this = this, _loop(themeName);
|
|
212
|
+
var _iteratorNormalCompletion = !0,
|
|
213
|
+
_didIteratorError = !1,
|
|
214
|
+
_iteratorError = void 0;
|
|
215
|
+
try {
|
|
216
|
+
for (var _iterator = maskedThemes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
217
|
+
var {
|
|
218
|
+
mask,
|
|
219
|
+
themeName: themeName1,
|
|
220
|
+
parentName
|
|
221
|
+
} = _step.value,
|
|
222
|
+
_this_state_masks,
|
|
223
|
+
parent = out[parentName];
|
|
224
|
+
if (parent) {
|
|
225
|
+
var {
|
|
226
|
+
mask: maskName,
|
|
227
|
+
...options
|
|
228
|
+
} = mask,
|
|
229
|
+
maskFunction = (_this_state_masks = this.state.masks) === null || _this_state_masks === void 0 ? void 0 : _this_state_masks[maskName];
|
|
230
|
+
if (!maskFunction) throw new Error(`No mask ${maskName}`);
|
|
231
|
+
var parentTheme = this.state.themes[parentName];
|
|
232
|
+
if (parentTheme && "childOptions" in parentTheme) {
|
|
233
|
+
var {
|
|
234
|
+
mask: mask1,
|
|
235
|
+
...childOpts
|
|
236
|
+
} = parentTheme.childOptions;
|
|
237
|
+
if (mask1) {
|
|
238
|
+
var _this_state_masks1;
|
|
239
|
+
maskFunction = (_this_state_masks1 = this.state.masks) === null || _this_state_masks1 === void 0 ? void 0 : _this_state_masks1[mask1];
|
|
240
|
+
}
|
|
241
|
+
Object.assign(options, childOpts);
|
|
242
|
+
}
|
|
243
|
+
out[themeName1] = (0, import_create_theme.applyMask)(parent, maskFunction, options, parentName, themeName1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} catch (err) {
|
|
247
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
248
|
+
} finally {
|
|
249
|
+
try {
|
|
250
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
251
|
+
} finally {
|
|
252
|
+
if (_didIteratorError) throw _iteratorError;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
257
|
+
}]), ThemeBuilder2;
|
|
258
|
+
}();
|
|
259
|
+
function createThemeBuilder() {
|
|
260
|
+
return new ThemeBuilder({});
|
|
261
|
+
}
|
|
262
|
+
//# 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","palettes","templates","masks","objectFromEntries","objectEntries","map","param","val","createMask","themes","push","type","args","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","fn","_getThemeFn","_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"],"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,GAAe,UAAAC,SAAA;AAAA;AAF1B,SAIRC,iBAA6DA,CAAAC,MAAA,EAAAC,KAAA;EAC3D,SAAAC,CAAA,IAAK,EAAAA,CAAA,GAAMD,KAAA,CAAAE,MAAW,EAAAD,CAAA;IAAA,IAAAE,UAAA,GAAAH,K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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: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var createStudioThemes_exports = {};
|
|
22
|
+
__export(createStudioThemes_exports, {
|
|
23
|
+
createStudioThemes: () => createStudioThemes
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createStudioThemes_exports);
|
|
26
|
+
var import_createThemes = require("./createThemes.cjs"),
|
|
27
|
+
import_defaultComponentThemes = require("./defaultComponentThemes.cjs"),
|
|
28
|
+
import_defaultTemplates = require("./defaultTemplates.cjs"),
|
|
29
|
+
import_defaultTemplatesStronger = require("./defaultTemplatesStronger.cjs"),
|
|
30
|
+
import_defaultTemplatesStrongest = require("./defaultTemplatesStrongest.cjs");
|
|
31
|
+
function createStudioThemes(props) {
|
|
32
|
+
const palettes = (0, import_createThemes.createPalettes)(props.palettes),
|
|
33
|
+
templates = props.templateStrategy === "stronger" ? import_defaultTemplatesStronger.defaultTemplatesStronger : props.templateStrategy === "strongest" ? import_defaultTemplatesStrongest.defaultTemplatesStrongest : import_defaultTemplates.defaultTemplates;
|
|
34
|
+
return (0, import_createThemes.createSimpleThemeBuilder)({
|
|
35
|
+
palettes,
|
|
36
|
+
templates,
|
|
37
|
+
componentThemes: import_defaultComponentThemes.defaultComponentThemes,
|
|
38
|
+
accentTheme: !!props.palettes.accent
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
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.native.js"),
|
|
29
|
+
import_defaultComponentThemes = require("./defaultComponentThemes.native.js"),
|
|
30
|
+
import_defaultTemplates = require("./defaultTemplates.native.js"),
|
|
31
|
+
import_defaultTemplatesStronger = require("./defaultTemplatesStronger.native.js"),
|
|
32
|
+
import_defaultTemplatesStrongest = require("./defaultTemplatesStrongest.native.js");
|
|
33
|
+
function createStudioThemes(props) {
|
|
34
|
+
var palettes = (0, import_createThemes.createPalettes)(props.palettes),
|
|
35
|
+
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
|
+
}
|
|
43
|
+
//# sourceMappingURL=createStudioThemes.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createStudioThemes_exports","__export","createStudioThemes","module","exports","import_createThemes","require","import_defaultComponentThemes","import_defaultTemplates","import_defaultTemplatesStronger","import_defaultTemplatesStrongest","props","palettes","createPalettes","templates","templateStrategy","defaultTemplatesStronger","defaultTemplatesStrongest","defaultTemplates","createSimpleThemeBuilder","componentThemes","defaultComponentThemes","accentTheme","accent"],"sources":["../../src/createStudioThemes.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAyD,CAAAK,0BACzD;AAUO,IAAAK,mBAAS,GAAAC,OAAmB,2BAA6B;EAAAC,6BAAA,GAAAD,OAAA;EAAAE,uBAAA,GAAAF,OAAA;EAAAG,+BAAA,GAAAH,OAAA;EAAAI,gCAAA,GAAAJ,OAAA;AAC9D,SAAMJ,kBAAWA,CAAAS,KAAA;EASjB,IAAAC,QAAO,OAAAP,mBAAA,CAAAQ,cAAA,EAAAF,KAAyB,CAAAC,QAAA;IAAAE,SAAA,GAAAH,KAAA,CAAAI,gBAAA,kBAAAN,+BAAA,CAAAO,wBAAA,GAAAL,KAAA,CAAAI,gBAAA,mBAAAL,gCAAA,CAAAO,yBAAA,GAAAT,uBAAA,CAAAU,gBAAA;EAAA,OAC9B,IAAAb,mBAAA,CAAAc,wBAAA;IACAP,QAAA;IACAE,SAAA;IACAM,eAAe,EAAAb,6BAAe,CAAAc,sBAAA;IAC/BC,WAAA,IAAAX,KAAA,CAAAC,QAAA,CAAAW;EACH","ignoreList":[]}
|