@symbo.ls/scratch 3.14.0 → 3.14.2
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/README.md +1 -1
- package/package.json +2 -2
- package/src/utils/sprite.js +29 -12
- package/dist/cjs/defaultConfig/animation.js +0 -24
- package/dist/cjs/defaultConfig/cases.js +0 -24
- package/dist/cjs/defaultConfig/class.js +0 -24
- package/dist/cjs/defaultConfig/color.js +0 -31
- package/dist/cjs/defaultConfig/document.js +0 -24
- package/dist/cjs/defaultConfig/font-family.js +0 -38
- package/dist/cjs/defaultConfig/font.js +0 -33
- package/dist/cjs/defaultConfig/grid.js +0 -25
- package/dist/cjs/defaultConfig/icons.js +0 -26
- package/dist/cjs/defaultConfig/index.js +0 -46
- package/dist/cjs/defaultConfig/media.js +0 -29
- package/dist/cjs/defaultConfig/responsive.js +0 -50
- package/dist/cjs/defaultConfig/sequence.js +0 -49
- package/dist/cjs/defaultConfig/shadow.js +0 -24
- package/dist/cjs/defaultConfig/spacing.js +0 -38
- package/dist/cjs/defaultConfig/svg.js +0 -26
- package/dist/cjs/defaultConfig/templates.js +0 -24
- package/dist/cjs/defaultConfig/theme.js +0 -36
- package/dist/cjs/defaultConfig/timing.js +0 -37
- package/dist/cjs/defaultConfig/typography.js +0 -41
- package/dist/cjs/defaultConfig/unit.js +0 -26
- package/dist/cjs/factory.js +0 -145
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/set.js +0 -286
- package/dist/cjs/system/color.js +0 -268
- package/dist/cjs/system/document.js +0 -36
- package/dist/cjs/system/font.js +0 -71
- package/dist/cjs/system/index.js +0 -27
- package/dist/cjs/system/reset.js +0 -114
- package/dist/cjs/system/shadow.js +0 -108
- package/dist/cjs/system/spacing.js +0 -134
- package/dist/cjs/system/svg.js +0 -133
- package/dist/cjs/system/theme.js +0 -496
- package/dist/cjs/system/timing.js +0 -48
- package/dist/cjs/system/typography.js +0 -108
- package/dist/cjs/tests/index.js +0 -28
- package/dist/cjs/transforms/index.js +0 -219
- package/dist/cjs/utils/color.js +0 -206
- package/dist/cjs/utils/font.js +0 -114
- package/dist/cjs/utils/index.js +0 -24
- package/dist/cjs/utils/sequence.js +0 -342
- package/dist/cjs/utils/sprite.js +0 -92
- package/dist/cjs/utils/theme.js +0 -29
- package/dist/cjs/utils/unit.js +0 -79
- package/dist/cjs/utils/var.js +0 -116
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/class.js +0 -4
- package/dist/esm/defaultConfig/color.js +0 -11
- package/dist/esm/defaultConfig/document.js +0 -4
- package/dist/esm/defaultConfig/font-family.js +0 -18
- package/dist/esm/defaultConfig/font.js +0 -13
- package/dist/esm/defaultConfig/grid.js +0 -5
- package/dist/esm/defaultConfig/icons.js +0 -6
- package/dist/esm/defaultConfig/index.js +0 -25
- package/dist/esm/defaultConfig/media.js +0 -9
- package/dist/esm/defaultConfig/responsive.js +0 -30
- package/dist/esm/defaultConfig/sequence.js +0 -29
- package/dist/esm/defaultConfig/shadow.js +0 -4
- package/dist/esm/defaultConfig/spacing.js +0 -18
- package/dist/esm/defaultConfig/svg.js +0 -6
- package/dist/esm/defaultConfig/templates.js +0 -4
- package/dist/esm/defaultConfig/theme.js +0 -16
- package/dist/esm/defaultConfig/timing.js +0 -17
- package/dist/esm/defaultConfig/typography.js +0 -21
- package/dist/esm/defaultConfig/unit.js +0 -6
- package/dist/esm/factory.js +0 -120
- package/dist/esm/index.js +0 -14
- package/dist/esm/set.js +0 -280
- package/dist/esm/system/color.js +0 -253
- package/dist/esm/system/document.js +0 -16
- package/dist/esm/system/font.js +0 -58
- package/dist/esm/system/index.js +0 -10
- package/dist/esm/system/reset.js +0 -94
- package/dist/esm/system/shadow.js +0 -92
- package/dist/esm/system/spacing.js +0 -121
- package/dist/esm/system/svg.js +0 -113
- package/dist/esm/system/theme.js +0 -481
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -94
- package/dist/esm/tests/index.js +0 -8
- package/dist/esm/transforms/index.js +0 -216
- package/dist/esm/utils/color.js +0 -192
- package/dist/esm/utils/font.js +0 -94
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/sequence.js +0 -322
- package/dist/esm/utils/sprite.js +0 -72
- package/dist/esm/utils/theme.js +0 -9
- package/dist/esm/utils/unit.js +0 -59
- package/dist/esm/utils/var.js +0 -96
- package/dist/iife/index.js +0 -3630
package/dist/cjs/system/theme.js
DELETED
|
@@ -1,496 +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_exports = {};
|
|
20
|
-
__export(theme_exports, {
|
|
21
|
-
getMediaTheme: () => getMediaTheme,
|
|
22
|
-
getTheme: () => getTheme,
|
|
23
|
-
setMediaTheme: () => setMediaTheme,
|
|
24
|
-
setTheme: () => setTheme
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(theme_exports);
|
|
27
|
-
var import_color = require("./color.js");
|
|
28
|
-
var import_factory = require("../factory.js");
|
|
29
|
-
var import_color2 = require("../utils/color.js");
|
|
30
|
-
var import_utils = require("@symbo.ls/utils");
|
|
31
|
-
const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
32
|
-
"black",
|
|
33
|
-
"white",
|
|
34
|
-
"red",
|
|
35
|
-
"green",
|
|
36
|
-
"blue",
|
|
37
|
-
"yellow",
|
|
38
|
-
"orange",
|
|
39
|
-
"purple",
|
|
40
|
-
"pink",
|
|
41
|
-
"brown",
|
|
42
|
-
"gray",
|
|
43
|
-
"grey",
|
|
44
|
-
"cyan",
|
|
45
|
-
"magenta",
|
|
46
|
-
"lime",
|
|
47
|
-
"olive",
|
|
48
|
-
"navy",
|
|
49
|
-
"teal",
|
|
50
|
-
"aqua",
|
|
51
|
-
"maroon",
|
|
52
|
-
"silver",
|
|
53
|
-
"fuchsia",
|
|
54
|
-
"transparent",
|
|
55
|
-
"currentColor",
|
|
56
|
-
"currentcolor",
|
|
57
|
-
"inherit",
|
|
58
|
-
"initial",
|
|
59
|
-
"unset",
|
|
60
|
-
"none",
|
|
61
|
-
"aliceblue",
|
|
62
|
-
"antiquewhite",
|
|
63
|
-
"aquamarine",
|
|
64
|
-
"azure",
|
|
65
|
-
"beige",
|
|
66
|
-
"bisque",
|
|
67
|
-
"blanchedalmond",
|
|
68
|
-
"blueviolet",
|
|
69
|
-
"burlywood",
|
|
70
|
-
"cadetblue",
|
|
71
|
-
"chartreuse",
|
|
72
|
-
"chocolate",
|
|
73
|
-
"coral",
|
|
74
|
-
"cornflowerblue",
|
|
75
|
-
"cornsilk",
|
|
76
|
-
"crimson",
|
|
77
|
-
"darkblue",
|
|
78
|
-
"darkcyan",
|
|
79
|
-
"darkgoldenrod",
|
|
80
|
-
"darkgray",
|
|
81
|
-
"darkgreen",
|
|
82
|
-
"darkgrey",
|
|
83
|
-
"darkkhaki",
|
|
84
|
-
"darkmagenta",
|
|
85
|
-
"darkolivegreen",
|
|
86
|
-
"darkorange",
|
|
87
|
-
"darkorchid",
|
|
88
|
-
"darkred",
|
|
89
|
-
"darksalmon",
|
|
90
|
-
"darkseagreen",
|
|
91
|
-
"darkslateblue",
|
|
92
|
-
"darkslategray",
|
|
93
|
-
"darkslategrey",
|
|
94
|
-
"darkturquoise",
|
|
95
|
-
"darkviolet",
|
|
96
|
-
"deeppink",
|
|
97
|
-
"deepskyblue",
|
|
98
|
-
"dimgray",
|
|
99
|
-
"dimgrey",
|
|
100
|
-
"dodgerblue",
|
|
101
|
-
"firebrick",
|
|
102
|
-
"floralwhite",
|
|
103
|
-
"forestgreen",
|
|
104
|
-
"gainsboro",
|
|
105
|
-
"ghostwhite",
|
|
106
|
-
"gold",
|
|
107
|
-
"goldenrod",
|
|
108
|
-
"greenyellow",
|
|
109
|
-
"honeydew",
|
|
110
|
-
"hotpink",
|
|
111
|
-
"indianred",
|
|
112
|
-
"indigo",
|
|
113
|
-
"ivory",
|
|
114
|
-
"khaki",
|
|
115
|
-
"lavender",
|
|
116
|
-
"lavenderblush",
|
|
117
|
-
"lawngreen",
|
|
118
|
-
"lemonchiffon",
|
|
119
|
-
"lightblue",
|
|
120
|
-
"lightcoral",
|
|
121
|
-
"lightcyan",
|
|
122
|
-
"lightgoldenrodyellow",
|
|
123
|
-
"lightgray",
|
|
124
|
-
"lightgreen",
|
|
125
|
-
"lightgrey",
|
|
126
|
-
"lightpink",
|
|
127
|
-
"lightsalmon",
|
|
128
|
-
"lightseagreen",
|
|
129
|
-
"lightskyblue",
|
|
130
|
-
"lightslategray",
|
|
131
|
-
"lightslategrey",
|
|
132
|
-
"lightsteelblue",
|
|
133
|
-
"lightyellow",
|
|
134
|
-
"limegreen",
|
|
135
|
-
"linen",
|
|
136
|
-
"mediumaquamarine",
|
|
137
|
-
"mediumblue",
|
|
138
|
-
"mediumorchid",
|
|
139
|
-
"mediumpurple",
|
|
140
|
-
"mediumseagreen",
|
|
141
|
-
"mediumslateblue",
|
|
142
|
-
"mediumspringgreen",
|
|
143
|
-
"mediumturquoise",
|
|
144
|
-
"mediumvioletred",
|
|
145
|
-
"midnightblue",
|
|
146
|
-
"mintcream",
|
|
147
|
-
"mistyrose",
|
|
148
|
-
"moccasin",
|
|
149
|
-
"navajowhite",
|
|
150
|
-
"oldlace",
|
|
151
|
-
"olivedrab",
|
|
152
|
-
"orangered",
|
|
153
|
-
"orchid",
|
|
154
|
-
"palegoldenrod",
|
|
155
|
-
"palegreen",
|
|
156
|
-
"paleturquoise",
|
|
157
|
-
"palevioletred",
|
|
158
|
-
"papayawhip",
|
|
159
|
-
"peachpuff",
|
|
160
|
-
"peru",
|
|
161
|
-
"plum",
|
|
162
|
-
"powderblue",
|
|
163
|
-
"rosybrown",
|
|
164
|
-
"royalblue",
|
|
165
|
-
"saddlebrown",
|
|
166
|
-
"salmon",
|
|
167
|
-
"sandybrown",
|
|
168
|
-
"seagreen",
|
|
169
|
-
"seashell",
|
|
170
|
-
"sienna",
|
|
171
|
-
"skyblue",
|
|
172
|
-
"slateblue",
|
|
173
|
-
"slategray",
|
|
174
|
-
"slategrey",
|
|
175
|
-
"snow",
|
|
176
|
-
"springgreen",
|
|
177
|
-
"steelblue",
|
|
178
|
-
"tan",
|
|
179
|
-
"thistle",
|
|
180
|
-
"tomato",
|
|
181
|
-
"turquoise",
|
|
182
|
-
"violet",
|
|
183
|
-
"wheat",
|
|
184
|
-
"whitesmoke",
|
|
185
|
-
"yellowgreen",
|
|
186
|
-
"rebeccapurple"
|
|
187
|
-
]);
|
|
188
|
-
const COLOR_PARAM_TOKENS = ["color", "Color", "background", "Background", "fill", "Fill", "stroke", "Stroke"];
|
|
189
|
-
const isColorParam = (param) => {
|
|
190
|
-
for (let i = 0; i < COLOR_PARAM_TOKENS.length; i++) {
|
|
191
|
-
if (param.includes(COLOR_PARAM_TOKENS[i])) return true;
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
};
|
|
195
|
-
const setThemeValue = (theme) => {
|
|
196
|
-
const value = {};
|
|
197
|
-
const { state, media, helpers, ...rest } = theme;
|
|
198
|
-
const keys = Object.keys(rest);
|
|
199
|
-
keys.map((key) => {
|
|
200
|
-
const conditions = ["color", "Color", "background", "border"];
|
|
201
|
-
const isColor = conditions.some((k) => key.includes(k));
|
|
202
|
-
return value[key] = isColor ? (0, import_color.getColor)(theme[key]) : theme[key];
|
|
203
|
-
});
|
|
204
|
-
return value;
|
|
205
|
-
};
|
|
206
|
-
const getThemeValue = (theme) => {
|
|
207
|
-
if (theme.value) return theme.value;
|
|
208
|
-
theme.value = setThemeValue(theme);
|
|
209
|
-
return theme.value;
|
|
210
|
-
};
|
|
211
|
-
const getTheme = (value, modifier) => {
|
|
212
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
213
|
-
if (CONFIG.useVariable) return getMediaTheme(value, modifier);
|
|
214
|
-
const THEME = CONFIG.theme;
|
|
215
|
-
if ((0, import_utils.isString)(value)) {
|
|
216
|
-
const [theme, subtheme] = value.split(" ");
|
|
217
|
-
const isOurTheme = THEME[theme];
|
|
218
|
-
if (isOurTheme) {
|
|
219
|
-
if (!subtheme && !modifier) return getThemeValue(isOurTheme);
|
|
220
|
-
value = [theme, subtheme || modifier];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if ((0, import_utils.isObjectLike)(value) && value[1]) {
|
|
224
|
-
const themeName = value[0];
|
|
225
|
-
const subThemeName = value[1];
|
|
226
|
-
const { helpers, media, state } = THEME[themeName];
|
|
227
|
-
if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
|
|
228
|
-
if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
|
|
229
|
-
if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
|
|
230
|
-
} else if ((0, import_utils.isObject)(value)) return setThemeValue(value);
|
|
231
|
-
};
|
|
232
|
-
const setInverseTheme = (theme, variant, value) => {
|
|
233
|
-
if ((0, import_utils.isObject)(variant)) {
|
|
234
|
-
theme.variants.inverse.value = setThemeValue(variant);
|
|
235
|
-
} else if (variant === true) {
|
|
236
|
-
const { color, background } = value;
|
|
237
|
-
theme.variants.inverse = {
|
|
238
|
-
value: {
|
|
239
|
-
color: background,
|
|
240
|
-
background: color
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const setPseudo = (theme, key, variant, themeValue) => {
|
|
246
|
-
const result = getTheme(variant);
|
|
247
|
-
themeValue[`&:${key}`] = result;
|
|
248
|
-
if ((0, import_utils.isObject)(variant) && !variant.value) variant.value = result;
|
|
249
|
-
};
|
|
250
|
-
const setSelectors = (theme, value) => {
|
|
251
|
-
const { state } = theme;
|
|
252
|
-
if (!state) return;
|
|
253
|
-
const keys = Object.keys(state);
|
|
254
|
-
keys.map((key) => {
|
|
255
|
-
const variant = state[key];
|
|
256
|
-
setPseudo(theme, key, variant, value);
|
|
257
|
-
return theme;
|
|
258
|
-
});
|
|
259
|
-
return theme;
|
|
260
|
-
};
|
|
261
|
-
const setPrefersScheme = (theme, key, variant, themeValue) => {
|
|
262
|
-
const result = getTheme(variant);
|
|
263
|
-
themeValue[`@media (prefers-color-scheme: ${key})`] = result;
|
|
264
|
-
if ((0, import_utils.isObject)(variant) && !variant.value) variant.value = result;
|
|
265
|
-
};
|
|
266
|
-
const setMedia = (theme, value) => {
|
|
267
|
-
const { media } = theme;
|
|
268
|
-
if (!media) return;
|
|
269
|
-
const keys = Object.keys(media);
|
|
270
|
-
keys.map((key) => {
|
|
271
|
-
const variant = media[key];
|
|
272
|
-
if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
|
|
273
|
-
if (key === "inverse") setInverseTheme(theme, variant, value);
|
|
274
|
-
return theme;
|
|
275
|
-
});
|
|
276
|
-
return theme;
|
|
277
|
-
};
|
|
278
|
-
const setHelpers = (theme, value) => {
|
|
279
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
280
|
-
const { helpers } = theme;
|
|
281
|
-
if (!helpers) return;
|
|
282
|
-
const keys = Object.keys(helpers);
|
|
283
|
-
keys.map((key) => {
|
|
284
|
-
const helper = helpers[key];
|
|
285
|
-
if ((0, import_utils.isString)(helper)) helpers[key] = CONFIG.theme[helper];
|
|
286
|
-
else getThemeValue(helpers[key]);
|
|
287
|
-
return theme;
|
|
288
|
-
});
|
|
289
|
-
return theme;
|
|
290
|
-
};
|
|
291
|
-
const setTheme = (val, key) => {
|
|
292
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
293
|
-
if (CONFIG.useVariable) return setMediaTheme(val, key);
|
|
294
|
-
const { state, media, helpers } = val;
|
|
295
|
-
const value = setThemeValue(val, key);
|
|
296
|
-
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
297
|
-
const CSSvar = `--${vp}theme-${key}`;
|
|
298
|
-
setSelectors(val, value);
|
|
299
|
-
setMedia(val, value);
|
|
300
|
-
setHelpers(val, value);
|
|
301
|
-
return { var: CSSvar, value, state, media, helpers };
|
|
302
|
-
};
|
|
303
|
-
const keySetters = {
|
|
304
|
-
// eslint-disable-line
|
|
305
|
-
"@": (theme, value) => setMedia(theme, value),
|
|
306
|
-
":": (theme, value) => setSelectors(theme, value),
|
|
307
|
-
".": (theme, value) => setHelpers(theme, value)
|
|
308
|
-
};
|
|
309
|
-
const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
310
|
-
const { cssVars: CSS_VARS } = CONFIG;
|
|
311
|
-
if (!CONFIG.cssMediaVars) CONFIG.cssMediaVars = {};
|
|
312
|
-
const MEDIA_VARS = CONFIG.cssMediaVars;
|
|
313
|
-
const globalTheme = CONFIG.globalTheme !== void 0 ? CONFIG.globalTheme : "auto";
|
|
314
|
-
const result = {};
|
|
315
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
316
|
-
for (const scheme in schemes) {
|
|
317
|
-
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
318
|
-
}
|
|
319
|
-
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
320
|
-
for (const param of allKeys) {
|
|
321
|
-
const symb = param.slice(0, 1);
|
|
322
|
-
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
323
|
-
if (!isColorParam(param)) continue;
|
|
324
|
-
for (const scheme in schemes) {
|
|
325
|
-
if (brokenSchemes.has(scheme)) continue;
|
|
326
|
-
const val = schemes[scheme]?.[param];
|
|
327
|
-
if (val === void 0) continue;
|
|
328
|
-
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
329
|
-
if (color === void 0) continue;
|
|
330
|
-
if ((0, import_utils.isString)(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
331
|
-
brokenSchemes.add(scheme);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
for (const param of allKeys) {
|
|
336
|
-
const symb = param.slice(0, 1);
|
|
337
|
-
const hasObject = Object.values(schemes).some((s) => (0, import_utils.isObjectLike)(s?.[param]));
|
|
338
|
-
if (symb === "." && hasObject) {
|
|
339
|
-
const helperName = param.slice(1);
|
|
340
|
-
const subSchemes = {};
|
|
341
|
-
for (const scheme in schemes) {
|
|
342
|
-
if ((0, import_utils.isObjectLike)(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
|
|
343
|
-
}
|
|
344
|
-
result[param] = generateAutoVars(subSchemes, `${varPrefix}-${helperName}`, CONFIG);
|
|
345
|
-
} else if (symb === ":" && hasObject) {
|
|
346
|
-
const pseudoName = param.replace(/^:+/, "");
|
|
347
|
-
const subSchemes = {};
|
|
348
|
-
for (const scheme in schemes) {
|
|
349
|
-
if ((0, import_utils.isObjectLike)(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
|
|
350
|
-
}
|
|
351
|
-
result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG);
|
|
352
|
-
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
353
|
-
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
354
|
-
const autoVar = `--${vp}theme-${varPrefix}-${param}`;
|
|
355
|
-
const forced = globalTheme && globalTheme !== "auto" ? String(globalTheme).replace(/^'|'$/g, "") : null;
|
|
356
|
-
let fallbackColor;
|
|
357
|
-
for (const scheme in schemes) {
|
|
358
|
-
if (brokenSchemes.has(scheme)) continue;
|
|
359
|
-
const val = schemes[scheme]?.[param];
|
|
360
|
-
if (val === void 0) continue;
|
|
361
|
-
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
362
|
-
if (color === void 0) continue;
|
|
363
|
-
if (forced && scheme === forced || !forced && (scheme === "light" || fallbackColor === void 0)) {
|
|
364
|
-
fallbackColor = color;
|
|
365
|
-
}
|
|
366
|
-
const selector = `[data-theme="${scheme}"]`;
|
|
367
|
-
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
368
|
-
MEDIA_VARS[selector][autoVar] = color;
|
|
369
|
-
if (scheme === "dark" || scheme === "light") {
|
|
370
|
-
const mq = `@media (prefers-color-scheme: ${scheme})`;
|
|
371
|
-
if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
|
|
372
|
-
MEDIA_VARS[mq][autoVar] = color;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
if (fallbackColor !== void 0) {
|
|
376
|
-
CSS_VARS[autoVar] = fallbackColor;
|
|
377
|
-
}
|
|
378
|
-
result[param] = `var(${autoVar})`;
|
|
379
|
-
result[`.${param}`] = { [param]: result[param] };
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
if (result.background || result.color || result.backgroundColor) {
|
|
383
|
-
result[".inversed"] = {
|
|
384
|
-
color: result.background || result.backgroundColor,
|
|
385
|
-
background: result.color
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
return result;
|
|
389
|
-
};
|
|
390
|
-
const setMediaTheme = (val, key, suffix, prefers) => {
|
|
391
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
392
|
-
const { cssVars: CSS_VARS } = CONFIG;
|
|
393
|
-
const theme = { value: val };
|
|
394
|
-
const isTopLevel = !suffix && !prefers;
|
|
395
|
-
if ((0, import_utils.isObjectLike)(val)) {
|
|
396
|
-
if (isTopLevel && CONFIG.useVariable) {
|
|
397
|
-
const schemes = {};
|
|
398
|
-
for (const param in val) {
|
|
399
|
-
if (param.startsWith("@") && (0, import_utils.isObjectLike)(val[param])) {
|
|
400
|
-
schemes[param.slice(1)] = val[param];
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
if (Object.keys(schemes).length) {
|
|
404
|
-
const autoResult = generateAutoVars(schemes, key, CONFIG);
|
|
405
|
-
Object.assign(theme, autoResult);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
for (const param in val) {
|
|
409
|
-
const symb = param.slice(0, 1);
|
|
410
|
-
const value = val[param];
|
|
411
|
-
if (symb === "@" || symb === ":" || symb === ".") {
|
|
412
|
-
const hasPrefers = symb === "@" && param;
|
|
413
|
-
theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
|
|
414
|
-
} else if (!isTopLevel) {
|
|
415
|
-
const color = (0, import_color.getColor)(value, prefers);
|
|
416
|
-
const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
|
|
417
|
-
const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
|
|
418
|
-
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
419
|
-
const CSSVar = `--${vp}theme-${key}${varmetaSuffixName}-${param}`;
|
|
420
|
-
if (CONFIG.useVariable) {
|
|
421
|
-
if (CONFIG.useThemeSuffixedVars) CSS_VARS[CSSVar] = color;
|
|
422
|
-
theme[param] = `var(${CSSVar})`;
|
|
423
|
-
} else {
|
|
424
|
-
theme[param] = color;
|
|
425
|
-
}
|
|
426
|
-
theme[`.${param}`] = { [param]: theme[param] };
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
if (!theme[".inversed"] && (theme.background || theme.color || theme.backgroundColor)) {
|
|
430
|
-
theme[".inversed"] = {
|
|
431
|
-
color: theme.background || theme.backgroundColor,
|
|
432
|
-
background: theme.color
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if ((0, import_utils.isString)(val) && (0, import_color2.isCSSVar)(val)) {
|
|
437
|
-
const THEME = CONFIG.theme;
|
|
438
|
-
const value = THEME[val.slice(2)];
|
|
439
|
-
const getReferenced = getMediaTheme(value, prefers);
|
|
440
|
-
return getReferenced;
|
|
441
|
-
}
|
|
442
|
-
return theme;
|
|
443
|
-
};
|
|
444
|
-
const recursiveTheme = (val) => {
|
|
445
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
446
|
-
const obj = {};
|
|
447
|
-
for (const param in val) {
|
|
448
|
-
const symb = param.slice(0, 1);
|
|
449
|
-
if ((0, import_utils.isObjectLike)(val[param])) {
|
|
450
|
-
if (symb === "@") {
|
|
451
|
-
continue;
|
|
452
|
-
} else if (symb === ":") {
|
|
453
|
-
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
454
|
-
} else if (symb === ".") {
|
|
455
|
-
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
456
|
-
}
|
|
457
|
-
} else obj[param] = val[param];
|
|
458
|
-
}
|
|
459
|
-
return obj;
|
|
460
|
-
};
|
|
461
|
-
const findModifierFromArray = (val, modifierArray) => {
|
|
462
|
-
const currentMod = modifierArray.shift();
|
|
463
|
-
if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
|
|
464
|
-
return val;
|
|
465
|
-
};
|
|
466
|
-
const findModifier = (val, modifier) => {
|
|
467
|
-
if ((0, import_utils.isArray)(modifier)) return findModifierFromArray(val, modifier);
|
|
468
|
-
else if ((0, import_utils.isString)(modifier) && val[modifier]) return val[modifier];
|
|
469
|
-
else return val;
|
|
470
|
-
};
|
|
471
|
-
const checkForReference = (val, callback) => {
|
|
472
|
-
if ((0, import_utils.isString)(val) && (0, import_color2.isCSSVar)(val)) return getMediaTheme(val.slice(2));
|
|
473
|
-
return val;
|
|
474
|
-
};
|
|
475
|
-
const checkThemeReference = (val) => checkForReference(val, checkThemeReference);
|
|
476
|
-
const getMediaTheme = (value, modifier) => {
|
|
477
|
-
const activeConfig = (0, import_factory.getActiveConfig)();
|
|
478
|
-
if ((0, import_utils.isString)(value) && (0, import_color2.isCSSVar)(value)) {
|
|
479
|
-
value = getMediaTheme(value.slice(2));
|
|
480
|
-
}
|
|
481
|
-
if (!value || !(0, import_utils.isString)(value)) {
|
|
482
|
-
if (activeConfig.verbose) {
|
|
483
|
-
console.warn(`${value} - Theme is not a string`);
|
|
484
|
-
}
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
const [themeName, ...themeModifiers] = (0, import_utils.isArray)(value) ? value : value.split(" ");
|
|
488
|
-
let themeValue = activeConfig.theme[themeName];
|
|
489
|
-
if (themeValue && themeModifiers.length) {
|
|
490
|
-
themeValue = findModifier(themeValue, themeModifiers);
|
|
491
|
-
} else if (themeValue && modifier) {
|
|
492
|
-
themeValue = findModifier(themeValue, modifier);
|
|
493
|
-
}
|
|
494
|
-
const resolvedTheme = recursiveTheme(themeValue);
|
|
495
|
-
return resolvedTheme;
|
|
496
|
-
};
|
|
@@ -1,48 +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 timing_exports = {};
|
|
20
|
-
__export(timing_exports, {
|
|
21
|
-
applyTimingSequence: () => applyTimingSequence,
|
|
22
|
-
getTimingByKey: () => getTimingByKey,
|
|
23
|
-
getTimingFunction: () => getTimingFunction
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(timing_exports);
|
|
26
|
-
var import_utils = require("@symbo.ls/utils");
|
|
27
|
-
var import_factory = require("../factory.js");
|
|
28
|
-
var import_utils2 = require("../utils/index.js");
|
|
29
|
-
const applyTimingSequence = () => {
|
|
30
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
31
|
-
const { timing: TIMING } = CONFIG;
|
|
32
|
-
(0, import_utils2.generateSequence)(TIMING);
|
|
33
|
-
(0, import_utils2.applySequenceVars)(TIMING);
|
|
34
|
-
};
|
|
35
|
-
const getTimingFunction = (value) => {
|
|
36
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
37
|
-
const { timing: TIMING } = CONFIG;
|
|
38
|
-
return TIMING[value] || TIMING[(0, import_utils.toCamelCase)(value)] || value;
|
|
39
|
-
};
|
|
40
|
-
const getTimingByKey = (value, property = "timing") => {
|
|
41
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
42
|
-
const { timing: TIMING } = CONFIG;
|
|
43
|
-
return (0, import_utils2.getSequenceValuePropertyPair)(
|
|
44
|
-
value,
|
|
45
|
-
property,
|
|
46
|
-
TIMING
|
|
47
|
-
);
|
|
48
|
-
};
|
|
@@ -1,108 +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 typography_exports = {};
|
|
20
|
-
__export(typography_exports, {
|
|
21
|
-
applyHeadings: () => applyHeadings,
|
|
22
|
-
applyTypographySequence: () => applyTypographySequence,
|
|
23
|
-
getFontSizeByKey: () => getFontSizeByKey,
|
|
24
|
-
runThroughMedia: () => runThroughMedia
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(typography_exports);
|
|
27
|
-
var import_utils = require("@symbo.ls/utils");
|
|
28
|
-
var import_factory = require("../factory.js");
|
|
29
|
-
var import_utils2 = require("../utils/index.js");
|
|
30
|
-
const runThroughMedia = (FACTORY) => {
|
|
31
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
32
|
-
const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG;
|
|
33
|
-
for (const prop in FACTORY) {
|
|
34
|
-
const isPropMedia = prop.slice(0, 1) === "@";
|
|
35
|
-
const mediaValue = FACTORY[prop];
|
|
36
|
-
if (!isPropMedia) continue;
|
|
37
|
-
const { mediaRegenerate } = FACTORY;
|
|
38
|
-
const mediaName = prop.slice(1);
|
|
39
|
-
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
|
|
40
|
-
(0, import_utils.merge)(mediaValue, {
|
|
41
|
-
type,
|
|
42
|
-
base,
|
|
43
|
-
ratio,
|
|
44
|
-
range,
|
|
45
|
-
subSequence,
|
|
46
|
-
h1Matches,
|
|
47
|
-
unit
|
|
48
|
-
});
|
|
49
|
-
const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
|
|
50
|
-
const inheritedUnit = mediaValue.unit || unit;
|
|
51
|
-
const mediaUnit = !mediaValue.unit && VIEWPORT_UNITS.has(unit) ? "rem" : inheritedUnit;
|
|
52
|
-
const query = MEDIA[mediaName];
|
|
53
|
-
const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
54
|
-
TYPOGRAPHY.templates[media] = {
|
|
55
|
-
fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + mediaUnit
|
|
56
|
-
};
|
|
57
|
-
if (!mediaRegenerate) {
|
|
58
|
-
(0, import_utils.merge)(mediaValue, {
|
|
59
|
-
sequence: {},
|
|
60
|
-
scales: {},
|
|
61
|
-
vars: {}
|
|
62
|
-
});
|
|
63
|
-
(0, import_utils2.generateSequence)(mediaValue);
|
|
64
|
-
(0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
(0, import_utils.merge)(mediaValue, {
|
|
68
|
-
sequence: {},
|
|
69
|
-
scales: {},
|
|
70
|
-
templates: {},
|
|
71
|
-
vars: {}
|
|
72
|
-
});
|
|
73
|
-
(0, import_utils2.generateSequence)(mediaValue);
|
|
74
|
-
(0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const applyHeadings = (props) => {
|
|
78
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
79
|
-
if (props.h1Matches) {
|
|
80
|
-
const unit = props.unit;
|
|
81
|
-
const HEADINGS = (0, import_utils2.findHeadings)(props);
|
|
82
|
-
const { templates } = props;
|
|
83
|
-
for (const k in HEADINGS) {
|
|
84
|
-
const headerName = `h${parseInt(k) + 1}`;
|
|
85
|
-
const headerStyle = templates[headerName];
|
|
86
|
-
templates[headerName] = {
|
|
87
|
-
fontSize: CONFIG.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k]?.scaling}${unit}`,
|
|
88
|
-
margin: headerStyle ? headerStyle.margin : 0,
|
|
89
|
-
lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
|
|
90
|
-
letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
|
|
91
|
-
fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const applyTypographySequence = () => {
|
|
97
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
98
|
-
const { typography: TYPOGRAPHY } = CONFIG;
|
|
99
|
-
(0, import_utils2.generateSequence)(TYPOGRAPHY);
|
|
100
|
-
applyHeadings(TYPOGRAPHY);
|
|
101
|
-
(0, import_utils2.applySequenceVars)(TYPOGRAPHY);
|
|
102
|
-
runThroughMedia(TYPOGRAPHY);
|
|
103
|
-
};
|
|
104
|
-
const getFontSizeByKey = (value) => {
|
|
105
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
106
|
-
const { typography: TYPOGRAPHY } = CONFIG;
|
|
107
|
-
return (0, import_utils2.getSequenceValuePropertyPair)(value, "fontSize", TYPOGRAPHY);
|
|
108
|
-
};
|
package/dist/cjs/tests/index.js
DELETED
|
@@ -1,28 +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 tests_exports = {};
|
|
20
|
-
__export(tests_exports, {
|
|
21
|
-
testWCAGAA: () => testWCAGAA,
|
|
22
|
-
testWCAGAAA: () => testWCAGAAA
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(tests_exports);
|
|
25
|
-
const testWCAGAA = (colorA, colorB) => {
|
|
26
|
-
};
|
|
27
|
-
const testWCAGAAA = (colorA, colorB) => {
|
|
28
|
-
};
|