@symbo.ls/scratch 3.8.1 → 3.8.6
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/dist/cjs/system/theme.js +182 -0
- package/dist/esm/system/theme.js +182 -0
- package/dist/iife/index.js +195 -1
- package/package.json +3 -3
- package/src/system/theme.js +66 -0
package/dist/cjs/system/theme.js
CHANGED
|
@@ -28,6 +28,163 @@ var import_color = require("./color");
|
|
|
28
28
|
var import_factory = require("../factory.js");
|
|
29
29
|
var import_color2 = require("../utils/color.js");
|
|
30
30
|
var import_utils = require("@domql/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
|
+
]);
|
|
31
188
|
const setThemeValue = (theme) => {
|
|
32
189
|
const value = {};
|
|
33
190
|
const { state, media, helpers, ...rest } = theme;
|
|
@@ -151,6 +308,23 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
151
308
|
for (const scheme in schemes) {
|
|
152
309
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
153
310
|
}
|
|
311
|
+
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
312
|
+
if (globalTheme === "auto") {
|
|
313
|
+
for (const param of allKeys) {
|
|
314
|
+
const symb = param.slice(0, 1);
|
|
315
|
+
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
316
|
+
for (const scheme in schemes) {
|
|
317
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
318
|
+
const val = schemes[scheme]?.[param];
|
|
319
|
+
if (val === void 0) continue;
|
|
320
|
+
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
321
|
+
if (color === void 0) continue;
|
|
322
|
+
if ((0, import_utils.isString)(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
323
|
+
brokenSchemes.add(scheme);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
154
328
|
for (const param of allKeys) {
|
|
155
329
|
const symb = param.slice(0, 1);
|
|
156
330
|
const hasObject = Object.values(schemes).some((s) => (0, import_utils.isObjectLike)(s?.[param]));
|
|
@@ -171,11 +345,16 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
171
345
|
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
172
346
|
const autoVar = `--theme-${varPrefix}-${param}`;
|
|
173
347
|
if (globalTheme === "auto") {
|
|
348
|
+
let fallbackColor;
|
|
174
349
|
for (const scheme in schemes) {
|
|
350
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
175
351
|
const val = schemes[scheme]?.[param];
|
|
176
352
|
if (val === void 0) continue;
|
|
177
353
|
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
178
354
|
if (color === void 0) continue;
|
|
355
|
+
if (scheme === "light" || fallbackColor === void 0) {
|
|
356
|
+
fallbackColor = color;
|
|
357
|
+
}
|
|
179
358
|
const selector = `[data-theme="${scheme}"]`;
|
|
180
359
|
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
181
360
|
MEDIA_VARS[selector][autoVar] = color;
|
|
@@ -185,6 +364,9 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
185
364
|
MEDIA_VARS[mq][autoVar] = color;
|
|
186
365
|
}
|
|
187
366
|
}
|
|
367
|
+
if (fallbackColor !== void 0) {
|
|
368
|
+
CSS_VARS[autoVar] = fallbackColor;
|
|
369
|
+
}
|
|
188
370
|
} else {
|
|
189
371
|
const forced = String(globalTheme).replace(/^'|'$/g, "");
|
|
190
372
|
const source = schemes[forced]?.[param];
|
package/dist/esm/system/theme.js
CHANGED
|
@@ -7,6 +7,163 @@ import {
|
|
|
7
7
|
isObjectLike,
|
|
8
8
|
isArray
|
|
9
9
|
} from "@domql/utils";
|
|
10
|
+
const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
11
|
+
"black",
|
|
12
|
+
"white",
|
|
13
|
+
"red",
|
|
14
|
+
"green",
|
|
15
|
+
"blue",
|
|
16
|
+
"yellow",
|
|
17
|
+
"orange",
|
|
18
|
+
"purple",
|
|
19
|
+
"pink",
|
|
20
|
+
"brown",
|
|
21
|
+
"gray",
|
|
22
|
+
"grey",
|
|
23
|
+
"cyan",
|
|
24
|
+
"magenta",
|
|
25
|
+
"lime",
|
|
26
|
+
"olive",
|
|
27
|
+
"navy",
|
|
28
|
+
"teal",
|
|
29
|
+
"aqua",
|
|
30
|
+
"maroon",
|
|
31
|
+
"silver",
|
|
32
|
+
"fuchsia",
|
|
33
|
+
"transparent",
|
|
34
|
+
"currentColor",
|
|
35
|
+
"currentcolor",
|
|
36
|
+
"inherit",
|
|
37
|
+
"initial",
|
|
38
|
+
"unset",
|
|
39
|
+
"none",
|
|
40
|
+
"aliceblue",
|
|
41
|
+
"antiquewhite",
|
|
42
|
+
"aquamarine",
|
|
43
|
+
"azure",
|
|
44
|
+
"beige",
|
|
45
|
+
"bisque",
|
|
46
|
+
"blanchedalmond",
|
|
47
|
+
"blueviolet",
|
|
48
|
+
"burlywood",
|
|
49
|
+
"cadetblue",
|
|
50
|
+
"chartreuse",
|
|
51
|
+
"chocolate",
|
|
52
|
+
"coral",
|
|
53
|
+
"cornflowerblue",
|
|
54
|
+
"cornsilk",
|
|
55
|
+
"crimson",
|
|
56
|
+
"darkblue",
|
|
57
|
+
"darkcyan",
|
|
58
|
+
"darkgoldenrod",
|
|
59
|
+
"darkgray",
|
|
60
|
+
"darkgreen",
|
|
61
|
+
"darkgrey",
|
|
62
|
+
"darkkhaki",
|
|
63
|
+
"darkmagenta",
|
|
64
|
+
"darkolivegreen",
|
|
65
|
+
"darkorange",
|
|
66
|
+
"darkorchid",
|
|
67
|
+
"darkred",
|
|
68
|
+
"darksalmon",
|
|
69
|
+
"darkseagreen",
|
|
70
|
+
"darkslateblue",
|
|
71
|
+
"darkslategray",
|
|
72
|
+
"darkslategrey",
|
|
73
|
+
"darkturquoise",
|
|
74
|
+
"darkviolet",
|
|
75
|
+
"deeppink",
|
|
76
|
+
"deepskyblue",
|
|
77
|
+
"dimgray",
|
|
78
|
+
"dimgrey",
|
|
79
|
+
"dodgerblue",
|
|
80
|
+
"firebrick",
|
|
81
|
+
"floralwhite",
|
|
82
|
+
"forestgreen",
|
|
83
|
+
"gainsboro",
|
|
84
|
+
"ghostwhite",
|
|
85
|
+
"gold",
|
|
86
|
+
"goldenrod",
|
|
87
|
+
"greenyellow",
|
|
88
|
+
"honeydew",
|
|
89
|
+
"hotpink",
|
|
90
|
+
"indianred",
|
|
91
|
+
"indigo",
|
|
92
|
+
"ivory",
|
|
93
|
+
"khaki",
|
|
94
|
+
"lavender",
|
|
95
|
+
"lavenderblush",
|
|
96
|
+
"lawngreen",
|
|
97
|
+
"lemonchiffon",
|
|
98
|
+
"lightblue",
|
|
99
|
+
"lightcoral",
|
|
100
|
+
"lightcyan",
|
|
101
|
+
"lightgoldenrodyellow",
|
|
102
|
+
"lightgray",
|
|
103
|
+
"lightgreen",
|
|
104
|
+
"lightgrey",
|
|
105
|
+
"lightpink",
|
|
106
|
+
"lightsalmon",
|
|
107
|
+
"lightseagreen",
|
|
108
|
+
"lightskyblue",
|
|
109
|
+
"lightslategray",
|
|
110
|
+
"lightslategrey",
|
|
111
|
+
"lightsteelblue",
|
|
112
|
+
"lightyellow",
|
|
113
|
+
"limegreen",
|
|
114
|
+
"linen",
|
|
115
|
+
"mediumaquamarine",
|
|
116
|
+
"mediumblue",
|
|
117
|
+
"mediumorchid",
|
|
118
|
+
"mediumpurple",
|
|
119
|
+
"mediumseagreen",
|
|
120
|
+
"mediumslateblue",
|
|
121
|
+
"mediumspringgreen",
|
|
122
|
+
"mediumturquoise",
|
|
123
|
+
"mediumvioletred",
|
|
124
|
+
"midnightblue",
|
|
125
|
+
"mintcream",
|
|
126
|
+
"mistyrose",
|
|
127
|
+
"moccasin",
|
|
128
|
+
"navajowhite",
|
|
129
|
+
"oldlace",
|
|
130
|
+
"olivedrab",
|
|
131
|
+
"orangered",
|
|
132
|
+
"orchid",
|
|
133
|
+
"palegoldenrod",
|
|
134
|
+
"palegreen",
|
|
135
|
+
"paleturquoise",
|
|
136
|
+
"palevioletred",
|
|
137
|
+
"papayawhip",
|
|
138
|
+
"peachpuff",
|
|
139
|
+
"peru",
|
|
140
|
+
"plum",
|
|
141
|
+
"powderblue",
|
|
142
|
+
"rosybrown",
|
|
143
|
+
"royalblue",
|
|
144
|
+
"saddlebrown",
|
|
145
|
+
"salmon",
|
|
146
|
+
"sandybrown",
|
|
147
|
+
"seagreen",
|
|
148
|
+
"seashell",
|
|
149
|
+
"sienna",
|
|
150
|
+
"skyblue",
|
|
151
|
+
"slateblue",
|
|
152
|
+
"slategray",
|
|
153
|
+
"slategrey",
|
|
154
|
+
"snow",
|
|
155
|
+
"springgreen",
|
|
156
|
+
"steelblue",
|
|
157
|
+
"tan",
|
|
158
|
+
"thistle",
|
|
159
|
+
"tomato",
|
|
160
|
+
"turquoise",
|
|
161
|
+
"violet",
|
|
162
|
+
"wheat",
|
|
163
|
+
"whitesmoke",
|
|
164
|
+
"yellowgreen",
|
|
165
|
+
"rebeccapurple"
|
|
166
|
+
]);
|
|
10
167
|
const setThemeValue = (theme) => {
|
|
11
168
|
const value = {};
|
|
12
169
|
const { state, media, helpers, ...rest } = theme;
|
|
@@ -130,6 +287,23 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
130
287
|
for (const scheme in schemes) {
|
|
131
288
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
132
289
|
}
|
|
290
|
+
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
291
|
+
if (globalTheme === "auto") {
|
|
292
|
+
for (const param of allKeys) {
|
|
293
|
+
const symb = param.slice(0, 1);
|
|
294
|
+
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
295
|
+
for (const scheme in schemes) {
|
|
296
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
297
|
+
const val = schemes[scheme]?.[param];
|
|
298
|
+
if (val === void 0) continue;
|
|
299
|
+
const color = getColor(val, `@${scheme}`);
|
|
300
|
+
if (color === void 0) continue;
|
|
301
|
+
if (isString(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
302
|
+
brokenSchemes.add(scheme);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
133
307
|
for (const param of allKeys) {
|
|
134
308
|
const symb = param.slice(0, 1);
|
|
135
309
|
const hasObject = Object.values(schemes).some((s) => isObjectLike(s?.[param]));
|
|
@@ -150,11 +324,16 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
150
324
|
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
151
325
|
const autoVar = `--theme-${varPrefix}-${param}`;
|
|
152
326
|
if (globalTheme === "auto") {
|
|
327
|
+
let fallbackColor;
|
|
153
328
|
for (const scheme in schemes) {
|
|
329
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
154
330
|
const val = schemes[scheme]?.[param];
|
|
155
331
|
if (val === void 0) continue;
|
|
156
332
|
const color = getColor(val, `@${scheme}`);
|
|
157
333
|
if (color === void 0) continue;
|
|
334
|
+
if (scheme === "light" || fallbackColor === void 0) {
|
|
335
|
+
fallbackColor = color;
|
|
336
|
+
}
|
|
158
337
|
const selector = `[data-theme="${scheme}"]`;
|
|
159
338
|
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
160
339
|
MEDIA_VARS[selector][autoVar] = color;
|
|
@@ -164,6 +343,9 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
164
343
|
MEDIA_VARS[mq][autoVar] = color;
|
|
165
344
|
}
|
|
166
345
|
}
|
|
346
|
+
if (fallbackColor !== void 0) {
|
|
347
|
+
CSS_VARS[autoVar] = fallbackColor;
|
|
348
|
+
}
|
|
167
349
|
} else {
|
|
168
350
|
const forced = String(globalTheme).replace(/^'|'$/g, "");
|
|
169
351
|
const source = schemes[forced]?.[param];
|
package/dist/iife/index.js
CHANGED
|
@@ -197,6 +197,17 @@ var SmblsScratch = (() => {
|
|
|
197
197
|
}
|
|
198
198
|
return result;
|
|
199
199
|
}
|
|
200
|
+
if (param != null && element?.context?.plugins && (isArray(param) || isObject(param) && !isDOMNode(param))) {
|
|
201
|
+
const plugins = element.context.plugins;
|
|
202
|
+
for (const plugin of plugins) {
|
|
203
|
+
if (plugin.resolveHandler) {
|
|
204
|
+
const resolved = plugin.resolveHandler(param, element);
|
|
205
|
+
if (typeof resolved === "function") {
|
|
206
|
+
return exec(resolved, element, state, context);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
200
211
|
return param;
|
|
201
212
|
};
|
|
202
213
|
merge = (element, obj, excludeFrom = []) => {
|
|
@@ -964,9 +975,10 @@ var SmblsScratch = (() => {
|
|
|
964
975
|
// ../smbls-utils/dist/esm/index.js
|
|
965
976
|
init_esm();
|
|
966
977
|
var toCamelCase = (str) => {
|
|
978
|
+
if (typeof str !== "string") str = String(str || "");
|
|
967
979
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
968
980
|
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
969
|
-
}).
|
|
981
|
+
}).replace(/\s+/g, "");
|
|
970
982
|
};
|
|
971
983
|
var toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
972
984
|
var arrayzeValue = (val) => {
|
|
@@ -1867,6 +1879,163 @@ var SmblsScratch = (() => {
|
|
|
1867
1879
|
|
|
1868
1880
|
// src/system/theme.js
|
|
1869
1881
|
init_esm();
|
|
1882
|
+
var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
1883
|
+
"black",
|
|
1884
|
+
"white",
|
|
1885
|
+
"red",
|
|
1886
|
+
"green",
|
|
1887
|
+
"blue",
|
|
1888
|
+
"yellow",
|
|
1889
|
+
"orange",
|
|
1890
|
+
"purple",
|
|
1891
|
+
"pink",
|
|
1892
|
+
"brown",
|
|
1893
|
+
"gray",
|
|
1894
|
+
"grey",
|
|
1895
|
+
"cyan",
|
|
1896
|
+
"magenta",
|
|
1897
|
+
"lime",
|
|
1898
|
+
"olive",
|
|
1899
|
+
"navy",
|
|
1900
|
+
"teal",
|
|
1901
|
+
"aqua",
|
|
1902
|
+
"maroon",
|
|
1903
|
+
"silver",
|
|
1904
|
+
"fuchsia",
|
|
1905
|
+
"transparent",
|
|
1906
|
+
"currentColor",
|
|
1907
|
+
"currentcolor",
|
|
1908
|
+
"inherit",
|
|
1909
|
+
"initial",
|
|
1910
|
+
"unset",
|
|
1911
|
+
"none",
|
|
1912
|
+
"aliceblue",
|
|
1913
|
+
"antiquewhite",
|
|
1914
|
+
"aquamarine",
|
|
1915
|
+
"azure",
|
|
1916
|
+
"beige",
|
|
1917
|
+
"bisque",
|
|
1918
|
+
"blanchedalmond",
|
|
1919
|
+
"blueviolet",
|
|
1920
|
+
"burlywood",
|
|
1921
|
+
"cadetblue",
|
|
1922
|
+
"chartreuse",
|
|
1923
|
+
"chocolate",
|
|
1924
|
+
"coral",
|
|
1925
|
+
"cornflowerblue",
|
|
1926
|
+
"cornsilk",
|
|
1927
|
+
"crimson",
|
|
1928
|
+
"darkblue",
|
|
1929
|
+
"darkcyan",
|
|
1930
|
+
"darkgoldenrod",
|
|
1931
|
+
"darkgray",
|
|
1932
|
+
"darkgreen",
|
|
1933
|
+
"darkgrey",
|
|
1934
|
+
"darkkhaki",
|
|
1935
|
+
"darkmagenta",
|
|
1936
|
+
"darkolivegreen",
|
|
1937
|
+
"darkorange",
|
|
1938
|
+
"darkorchid",
|
|
1939
|
+
"darkred",
|
|
1940
|
+
"darksalmon",
|
|
1941
|
+
"darkseagreen",
|
|
1942
|
+
"darkslateblue",
|
|
1943
|
+
"darkslategray",
|
|
1944
|
+
"darkslategrey",
|
|
1945
|
+
"darkturquoise",
|
|
1946
|
+
"darkviolet",
|
|
1947
|
+
"deeppink",
|
|
1948
|
+
"deepskyblue",
|
|
1949
|
+
"dimgray",
|
|
1950
|
+
"dimgrey",
|
|
1951
|
+
"dodgerblue",
|
|
1952
|
+
"firebrick",
|
|
1953
|
+
"floralwhite",
|
|
1954
|
+
"forestgreen",
|
|
1955
|
+
"gainsboro",
|
|
1956
|
+
"ghostwhite",
|
|
1957
|
+
"gold",
|
|
1958
|
+
"goldenrod",
|
|
1959
|
+
"greenyellow",
|
|
1960
|
+
"honeydew",
|
|
1961
|
+
"hotpink",
|
|
1962
|
+
"indianred",
|
|
1963
|
+
"indigo",
|
|
1964
|
+
"ivory",
|
|
1965
|
+
"khaki",
|
|
1966
|
+
"lavender",
|
|
1967
|
+
"lavenderblush",
|
|
1968
|
+
"lawngreen",
|
|
1969
|
+
"lemonchiffon",
|
|
1970
|
+
"lightblue",
|
|
1971
|
+
"lightcoral",
|
|
1972
|
+
"lightcyan",
|
|
1973
|
+
"lightgoldenrodyellow",
|
|
1974
|
+
"lightgray",
|
|
1975
|
+
"lightgreen",
|
|
1976
|
+
"lightgrey",
|
|
1977
|
+
"lightpink",
|
|
1978
|
+
"lightsalmon",
|
|
1979
|
+
"lightseagreen",
|
|
1980
|
+
"lightskyblue",
|
|
1981
|
+
"lightslategray",
|
|
1982
|
+
"lightslategrey",
|
|
1983
|
+
"lightsteelblue",
|
|
1984
|
+
"lightyellow",
|
|
1985
|
+
"limegreen",
|
|
1986
|
+
"linen",
|
|
1987
|
+
"mediumaquamarine",
|
|
1988
|
+
"mediumblue",
|
|
1989
|
+
"mediumorchid",
|
|
1990
|
+
"mediumpurple",
|
|
1991
|
+
"mediumseagreen",
|
|
1992
|
+
"mediumslateblue",
|
|
1993
|
+
"mediumspringgreen",
|
|
1994
|
+
"mediumturquoise",
|
|
1995
|
+
"mediumvioletred",
|
|
1996
|
+
"midnightblue",
|
|
1997
|
+
"mintcream",
|
|
1998
|
+
"mistyrose",
|
|
1999
|
+
"moccasin",
|
|
2000
|
+
"navajowhite",
|
|
2001
|
+
"oldlace",
|
|
2002
|
+
"olivedrab",
|
|
2003
|
+
"orangered",
|
|
2004
|
+
"orchid",
|
|
2005
|
+
"palegoldenrod",
|
|
2006
|
+
"palegreen",
|
|
2007
|
+
"paleturquoise",
|
|
2008
|
+
"palevioletred",
|
|
2009
|
+
"papayawhip",
|
|
2010
|
+
"peachpuff",
|
|
2011
|
+
"peru",
|
|
2012
|
+
"plum",
|
|
2013
|
+
"powderblue",
|
|
2014
|
+
"rosybrown",
|
|
2015
|
+
"royalblue",
|
|
2016
|
+
"saddlebrown",
|
|
2017
|
+
"salmon",
|
|
2018
|
+
"sandybrown",
|
|
2019
|
+
"seagreen",
|
|
2020
|
+
"seashell",
|
|
2021
|
+
"sienna",
|
|
2022
|
+
"skyblue",
|
|
2023
|
+
"slateblue",
|
|
2024
|
+
"slategray",
|
|
2025
|
+
"slategrey",
|
|
2026
|
+
"snow",
|
|
2027
|
+
"springgreen",
|
|
2028
|
+
"steelblue",
|
|
2029
|
+
"tan",
|
|
2030
|
+
"thistle",
|
|
2031
|
+
"tomato",
|
|
2032
|
+
"turquoise",
|
|
2033
|
+
"violet",
|
|
2034
|
+
"wheat",
|
|
2035
|
+
"whitesmoke",
|
|
2036
|
+
"yellowgreen",
|
|
2037
|
+
"rebeccapurple"
|
|
2038
|
+
]);
|
|
1870
2039
|
var setThemeValue = (theme2) => {
|
|
1871
2040
|
const value = {};
|
|
1872
2041
|
const { state, media: media2, helpers, ...rest } = theme2;
|
|
@@ -1984,6 +2153,23 @@ var SmblsScratch = (() => {
|
|
|
1984
2153
|
for (const scheme in schemes) {
|
|
1985
2154
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
1986
2155
|
}
|
|
2156
|
+
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
2157
|
+
if (globalTheme === "auto") {
|
|
2158
|
+
for (const param of allKeys) {
|
|
2159
|
+
const symb = param.slice(0, 1);
|
|
2160
|
+
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
2161
|
+
for (const scheme in schemes) {
|
|
2162
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
2163
|
+
const val = schemes[scheme]?.[param];
|
|
2164
|
+
if (val === void 0) continue;
|
|
2165
|
+
const color2 = getColor(val, `@${scheme}`);
|
|
2166
|
+
if (color2 === void 0) continue;
|
|
2167
|
+
if (isString(color2) && /^[a-z][a-zA-Z]+$/.test(color2) && !CSS_NAMED_COLORS.has(color2)) {
|
|
2168
|
+
brokenSchemes.add(scheme);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
1987
2173
|
for (const param of allKeys) {
|
|
1988
2174
|
const symb = param.slice(0, 1);
|
|
1989
2175
|
const hasObject = Object.values(schemes).some((s) => isObjectLike(s?.[param]));
|
|
@@ -2004,11 +2190,16 @@ var SmblsScratch = (() => {
|
|
|
2004
2190
|
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
2005
2191
|
const autoVar = `--theme-${varPrefix}-${param}`;
|
|
2006
2192
|
if (globalTheme === "auto") {
|
|
2193
|
+
let fallbackColor;
|
|
2007
2194
|
for (const scheme in schemes) {
|
|
2195
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
2008
2196
|
const val = schemes[scheme]?.[param];
|
|
2009
2197
|
if (val === void 0) continue;
|
|
2010
2198
|
const color2 = getColor(val, `@${scheme}`);
|
|
2011
2199
|
if (color2 === void 0) continue;
|
|
2200
|
+
if (scheme === "light" || fallbackColor === void 0) {
|
|
2201
|
+
fallbackColor = color2;
|
|
2202
|
+
}
|
|
2012
2203
|
const selector = `[data-theme="${scheme}"]`;
|
|
2013
2204
|
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
2014
2205
|
MEDIA_VARS[selector][autoVar] = color2;
|
|
@@ -2018,6 +2209,9 @@ var SmblsScratch = (() => {
|
|
|
2018
2209
|
MEDIA_VARS[mq][autoVar] = color2;
|
|
2019
2210
|
}
|
|
2020
2211
|
}
|
|
2212
|
+
if (fallbackColor !== void 0) {
|
|
2213
|
+
CSS_VARS2[autoVar] = fallbackColor;
|
|
2214
|
+
}
|
|
2021
2215
|
} else {
|
|
2022
2216
|
const forced = String(globalTheme).replace(/^'|'$/g, "");
|
|
2023
2217
|
const source = schemes[forced]?.[param];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "3.8.
|
|
5
|
+
"version": "3.8.6",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"*.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"prepublish": "npm run build && npm run copy:package:cjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@domql/utils": "^3.8.
|
|
37
|
-
"@symbo.ls/smbls-utils": "^3.8.
|
|
36
|
+
"@domql/utils": "^3.8.6",
|
|
37
|
+
"@symbo.ls/smbls-utils": "^3.8.6",
|
|
38
38
|
"color-contrast-checker": "^1.5.0"
|
|
39
39
|
},
|
|
40
40
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
package/src/system/theme.js
CHANGED
|
@@ -11,6 +11,38 @@ import {
|
|
|
11
11
|
isArray
|
|
12
12
|
} from '@domql/utils'
|
|
13
13
|
|
|
14
|
+
// Common CSS named colors — used to distinguish valid CSS color names
|
|
15
|
+
// from unresolved design-system tokens (e.g. 'blackRussian', 'grayMid')
|
|
16
|
+
const CSS_NAMED_COLORS = new Set([
|
|
17
|
+
'black', 'white', 'red', 'green', 'blue', 'yellow', 'orange', 'purple',
|
|
18
|
+
'pink', 'brown', 'gray', 'grey', 'cyan', 'magenta', 'lime', 'olive',
|
|
19
|
+
'navy', 'teal', 'aqua', 'maroon', 'silver', 'fuchsia', 'transparent',
|
|
20
|
+
'currentColor', 'currentcolor', 'inherit', 'initial', 'unset', 'none',
|
|
21
|
+
'aliceblue', 'antiquewhite', 'aquamarine', 'azure', 'beige', 'bisque',
|
|
22
|
+
'blanchedalmond', 'blueviolet', 'burlywood', 'cadetblue', 'chartreuse',
|
|
23
|
+
'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'darkblue',
|
|
24
|
+
'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki',
|
|
25
|
+
'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred',
|
|
26
|
+
'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey',
|
|
27
|
+
'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey',
|
|
28
|
+
'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'gainsboro', 'ghostwhite',
|
|
29
|
+
'gold', 'goldenrod', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo',
|
|
30
|
+
'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon',
|
|
31
|
+
'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray',
|
|
32
|
+
'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen',
|
|
33
|
+
'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow',
|
|
34
|
+
'limegreen', 'linen', 'mediumaquamarine', 'mediumblue', 'mediumorchid',
|
|
35
|
+
'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen',
|
|
36
|
+
'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose',
|
|
37
|
+
'moccasin', 'navajowhite', 'oldlace', 'olivedrab', 'orangered', 'orchid',
|
|
38
|
+
'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip',
|
|
39
|
+
'peachpuff', 'peru', 'plum', 'powderblue', 'rosybrown', 'royalblue',
|
|
40
|
+
'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna',
|
|
41
|
+
'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen',
|
|
42
|
+
'steelblue', 'tan', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat',
|
|
43
|
+
'whitesmoke', 'yellowgreen', 'rebeccapurple'
|
|
44
|
+
])
|
|
45
|
+
|
|
14
46
|
const setThemeValue = theme => {
|
|
15
47
|
const value = {}
|
|
16
48
|
const { state, media, helpers, ...rest } = theme
|
|
@@ -166,6 +198,27 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
166
198
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k)
|
|
167
199
|
}
|
|
168
200
|
|
|
201
|
+
// Pre-scan: detect schemes with unresolvable color values
|
|
202
|
+
// If any color in a scheme fails to resolve, skip the ENTIRE scheme
|
|
203
|
+
// to avoid partial theme application (e.g. white text without dark background)
|
|
204
|
+
const brokenSchemes = new Set()
|
|
205
|
+
if (globalTheme === 'auto') {
|
|
206
|
+
for (const param of allKeys) {
|
|
207
|
+
const symb = param.slice(0, 1)
|
|
208
|
+
if (symb === '@' || symb === '.' || symb === ':') continue
|
|
209
|
+
for (const scheme in schemes) {
|
|
210
|
+
if (brokenSchemes.has(scheme)) continue
|
|
211
|
+
const val = schemes[scheme]?.[param]
|
|
212
|
+
if (val === undefined) continue
|
|
213
|
+
const color = getColor(val, `@${scheme}`)
|
|
214
|
+
if (color === undefined) continue
|
|
215
|
+
if (isString(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
216
|
+
brokenSchemes.add(scheme)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
169
222
|
for (const param of allKeys) {
|
|
170
223
|
const symb = param.slice(0, 1)
|
|
171
224
|
|
|
@@ -193,12 +246,19 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
193
246
|
const autoVar = `--theme-${varPrefix}-${param}`
|
|
194
247
|
|
|
195
248
|
if (globalTheme === 'auto') {
|
|
249
|
+
let fallbackColor
|
|
196
250
|
for (const scheme in schemes) {
|
|
251
|
+
if (brokenSchemes.has(scheme)) continue
|
|
197
252
|
const val = schemes[scheme]?.[param]
|
|
198
253
|
if (val === undefined) continue
|
|
199
254
|
const color = getColor(val, `@${scheme}`)
|
|
200
255
|
if (color === undefined) continue
|
|
201
256
|
|
|
257
|
+
// Use 'light' scheme (or first resolved) as base fallback
|
|
258
|
+
if (scheme === 'light' || fallbackColor === undefined) {
|
|
259
|
+
fallbackColor = color
|
|
260
|
+
}
|
|
261
|
+
|
|
202
262
|
// [data-theme] selector for ALL schemes (custom + standard)
|
|
203
263
|
const selector = `[data-theme="${scheme}"]`
|
|
204
264
|
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {}
|
|
@@ -211,6 +271,12 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
211
271
|
MEDIA_VARS[mq][autoVar] = color
|
|
212
272
|
}
|
|
213
273
|
}
|
|
274
|
+
|
|
275
|
+
// Set fallback default (light or first scheme) so the variable
|
|
276
|
+
// always resolves even without a matching media query
|
|
277
|
+
if (fallbackColor !== undefined) {
|
|
278
|
+
CSS_VARS[autoVar] = fallbackColor
|
|
279
|
+
}
|
|
214
280
|
} else {
|
|
215
281
|
// Force specific theme — set non-suffixed var directly
|
|
216
282
|
const forced = String(globalTheme).replace(/^'|'$/g, '')
|