@symbo.ls/scratch 2.11.523 → 3.0.1
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/factory.js +13 -20
- package/dist/cjs/index.js +193 -383
- package/dist/cjs/set.js +132 -282
- package/dist/cjs/system/color.js +61 -142
- package/dist/cjs/system/document.js +28 -84
- package/dist/cjs/system/font.js +29 -88
- package/dist/cjs/system/index.js +135 -285
- package/dist/cjs/system/reset.js +35 -98
- package/dist/cjs/system/shadow.js +77 -173
- package/dist/cjs/system/spacing.js +41 -112
- package/dist/cjs/system/svg.js +34 -94
- package/dist/cjs/system/theme.js +74 -168
- package/dist/cjs/system/timing.js +33 -96
- package/dist/cjs/system/typography.js +41 -110
- package/dist/cjs/transforms/index.js +112 -228
- package/dist/cjs/utils/color.js +22 -85
- package/dist/cjs/utils/font.js +3 -6
- package/dist/cjs/utils/index.js +67 -155
- package/dist/cjs/utils/sequence.js +34 -58
- package/dist/cjs/utils/sprite.js +13 -20
- package/dist/cjs/utils/theme.js +3 -6
- package/dist/cjs/utils/var.js +27 -45
- package/package.json +3 -3
- package/src/system/svg.js +1 -1
- package/src/transforms/index.js +9 -2
- package/src/utils/color.js +1 -2
- package/src/utils/sequence.js +1 -1
package/dist/cjs/system/theme.js
CHANGED
|
@@ -30,44 +30,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/@domql/globals/dist/cjs/index.js
|
|
34
|
-
var require_cjs = __commonJS({
|
|
35
|
-
"../../node_modules/@domql/globals/dist/cjs/index.js"(exports, module2) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var __defProp3 = Object.defineProperty;
|
|
38
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
39
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
40
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
41
|
-
var __export2 = (target, all) => {
|
|
42
|
-
for (var name in all)
|
|
43
|
-
__defProp3(target, name, { get: all[name], enumerable: true });
|
|
44
|
-
};
|
|
45
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
46
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
47
|
-
for (let key of __getOwnPropNames2(from))
|
|
48
|
-
if (!__hasOwnProp3.call(to, key) && key !== except)
|
|
49
|
-
__defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
50
|
-
}
|
|
51
|
-
return to;
|
|
52
|
-
};
|
|
53
|
-
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
54
|
-
var globals_exports = {};
|
|
55
|
-
__export2(globals_exports, {
|
|
56
|
-
document: () => document4,
|
|
57
|
-
global: () => global,
|
|
58
|
-
self: () => self,
|
|
59
|
-
window: () => window4
|
|
60
|
-
});
|
|
61
|
-
module2.exports = __toCommonJS2(globals_exports);
|
|
62
|
-
var global = globalThis;
|
|
63
|
-
var self = globalThis;
|
|
64
|
-
var window4 = globalThis;
|
|
65
|
-
var document4 = window4.document;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
33
|
// ../utils/dist/cjs/index.js
|
|
70
|
-
var
|
|
34
|
+
var require_cjs = __commonJS({
|
|
71
35
|
"../utils/dist/cjs/index.js"(exports, module2) {
|
|
72
36
|
"use strict";
|
|
73
37
|
var __defProp3 = Object.defineProperty;
|
|
@@ -87,8 +51,8 @@ var require_cjs2 = __commonJS({
|
|
|
87
51
|
return to;
|
|
88
52
|
};
|
|
89
53
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
90
|
-
var
|
|
91
|
-
__export2(
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
92
56
|
arrayzeValue: () => arrayzeValue,
|
|
93
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
94
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -109,12 +73,11 @@ var require_cjs2 = __commonJS({
|
|
|
109
73
|
toTitleCase: () => toTitleCase,
|
|
110
74
|
toggleFullscreen: () => toggleFullscreen
|
|
111
75
|
});
|
|
112
|
-
module2.exports = __toCommonJS2(
|
|
76
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
113
77
|
var window22 = globalThis;
|
|
114
78
|
var document22 = window22.document;
|
|
115
79
|
var isObject2 = (arg) => {
|
|
116
|
-
if (arg === null)
|
|
117
|
-
return false;
|
|
80
|
+
if (arg === null) return false;
|
|
118
81
|
return typeof arg === "object" && arg.constructor === Object;
|
|
119
82
|
};
|
|
120
83
|
var isString2 = (arg) => typeof arg === "string";
|
|
@@ -139,13 +102,11 @@ var require_cjs2 = __commonJS({
|
|
|
139
102
|
};
|
|
140
103
|
var findClosestNumberInFactory = (val, factory) => {
|
|
141
104
|
val = parseFloat(val);
|
|
142
|
-
if (isObject2(factory))
|
|
143
|
-
factory = Object.values(factory);
|
|
105
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
144
106
|
return findClosestNumber(val, factory);
|
|
145
107
|
};
|
|
146
108
|
var formatDate = (timestamp) => {
|
|
147
|
-
if (!timestamp)
|
|
148
|
-
return "";
|
|
109
|
+
if (!timestamp) return "";
|
|
149
110
|
const d = new Date(timestamp);
|
|
150
111
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
151
112
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -212,8 +173,7 @@ var require_cjs2 = __commonJS({
|
|
|
212
173
|
scriptEle.type = type;
|
|
213
174
|
scriptEle.text = xhr.responseText;
|
|
214
175
|
doc.body.appendChild(scriptEle);
|
|
215
|
-
if (typeof fallback === "function")
|
|
216
|
-
fallback();
|
|
176
|
+
if (typeof fallback === "function") fallback();
|
|
217
177
|
} else {
|
|
218
178
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
219
179
|
}
|
|
@@ -281,20 +241,15 @@ var require_cjs2 = __commonJS({
|
|
|
281
241
|
);
|
|
282
242
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
283
243
|
var toDescriptionCase = (str = "") => {
|
|
284
|
-
if (typeof str !== "string")
|
|
285
|
-
return;
|
|
244
|
+
if (typeof str !== "string") return;
|
|
286
245
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
287
246
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
288
247
|
};
|
|
289
248
|
var arrayzeValue = (val) => {
|
|
290
|
-
if (isArray2(val))
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
if (isObject2(val))
|
|
295
|
-
return Object.values(val);
|
|
296
|
-
if (isNumber2(val))
|
|
297
|
-
return [val];
|
|
249
|
+
if (isArray2(val)) return val;
|
|
250
|
+
if (isString2(val)) return val.split(" ");
|
|
251
|
+
if (isObject2(val)) return Object.values(val);
|
|
252
|
+
if (isNumber2(val)) return [val];
|
|
298
253
|
};
|
|
299
254
|
}
|
|
300
255
|
});
|
|
@@ -309,19 +264,18 @@ __export(theme_exports, {
|
|
|
309
264
|
});
|
|
310
265
|
module.exports = __toCommonJS(theme_exports);
|
|
311
266
|
|
|
312
|
-
//
|
|
267
|
+
// node_modules/@domql/utils/dist/esm/globals.js
|
|
313
268
|
var window2 = globalThis;
|
|
314
269
|
var document2 = window2.document;
|
|
315
270
|
|
|
316
|
-
//
|
|
271
|
+
// node_modules/@domql/utils/dist/esm/node.js
|
|
317
272
|
var isDOMNode = (obj) => {
|
|
318
273
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
319
274
|
};
|
|
320
275
|
|
|
321
|
-
//
|
|
276
|
+
// node_modules/@domql/utils/dist/esm/types.js
|
|
322
277
|
var isObject = (arg) => {
|
|
323
|
-
if (arg === null)
|
|
324
|
-
return false;
|
|
278
|
+
if (arg === null) return false;
|
|
325
279
|
return typeof arg === "object" && arg.constructor === Object;
|
|
326
280
|
};
|
|
327
281
|
var isString = (arg) => typeof arg === "string";
|
|
@@ -330,20 +284,19 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
330
284
|
var isNull = (arg) => arg === null;
|
|
331
285
|
var isArray = (arg) => Array.isArray(arg);
|
|
332
286
|
var isObjectLike = (arg) => {
|
|
333
|
-
if (arg === null)
|
|
334
|
-
return false;
|
|
287
|
+
if (arg === null) return false;
|
|
335
288
|
return typeof arg === "object";
|
|
336
289
|
};
|
|
337
290
|
var isUndefined = (arg) => {
|
|
338
291
|
return arg === void 0;
|
|
339
292
|
};
|
|
340
293
|
|
|
341
|
-
//
|
|
294
|
+
// node_modules/@domql/utils/dist/esm/array.js
|
|
342
295
|
var mergeArray = (arr, exclude = []) => {
|
|
343
296
|
return arr.reduce((a, c) => deepMerge(a, deepClone(c, { exclude }), exclude), {});
|
|
344
297
|
};
|
|
345
298
|
|
|
346
|
-
//
|
|
299
|
+
// node_modules/@domql/utils/dist/esm/object.js
|
|
347
300
|
var __defProp2 = Object.defineProperty;
|
|
348
301
|
var __defProps = Object.defineProperties;
|
|
349
302
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -366,8 +319,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
366
319
|
var deepMerge = (element, extend, excludeFrom = []) => {
|
|
367
320
|
for (const e in extend) {
|
|
368
321
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
369
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
370
|
-
continue;
|
|
322
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
|
|
371
323
|
const elementProp = element[e];
|
|
372
324
|
const extendProp = extend[e];
|
|
373
325
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -396,13 +348,10 @@ var deepClone = (obj, options = {}) => {
|
|
|
396
348
|
const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
397
349
|
visited.set(obj, clone2);
|
|
398
350
|
for (const key in obj) {
|
|
399
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
400
|
-
|
|
401
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
402
|
-
continue;
|
|
351
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
352
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
|
|
403
353
|
const value = obj[key];
|
|
404
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
405
|
-
continue;
|
|
354
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) continue;
|
|
406
355
|
if (isDOMNode(value)) {
|
|
407
356
|
clone2[key] = value;
|
|
408
357
|
continue;
|
|
@@ -426,7 +375,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
426
375
|
return clone2;
|
|
427
376
|
};
|
|
428
377
|
|
|
429
|
-
//
|
|
378
|
+
// node_modules/@domql/utils/dist/esm/cookie.js
|
|
430
379
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
431
380
|
|
|
432
381
|
// src/defaultConfig/index.js
|
|
@@ -651,12 +600,9 @@ var getActiveConfig = (def) => {
|
|
|
651
600
|
};
|
|
652
601
|
|
|
653
602
|
// src/utils/color.js
|
|
654
|
-
var import_globals4 = __toESM(require_cjs(), 1);
|
|
655
603
|
var colorStringToRgbaArray = (color) => {
|
|
656
|
-
if (color === "")
|
|
657
|
-
|
|
658
|
-
if (color.toLowerCase() === "transparent")
|
|
659
|
-
return [0, 0, 0, 0];
|
|
604
|
+
if (color === "") return [0, 0, 0, 0];
|
|
605
|
+
if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
|
660
606
|
if (color[0] === "#") {
|
|
661
607
|
if (color.length < 7) {
|
|
662
608
|
color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
|
|
@@ -669,26 +615,25 @@ var colorStringToRgbaArray = (color) => {
|
|
|
669
615
|
];
|
|
670
616
|
}
|
|
671
617
|
if (color.indexOf("rgb") === -1) {
|
|
672
|
-
if (
|
|
673
|
-
const elem =
|
|
618
|
+
if (document2 && window2) {
|
|
619
|
+
const elem = document2.body.appendChild(document2.createElement("fictum"));
|
|
674
620
|
const flag = "rgb(1, 2, 3)";
|
|
675
621
|
elem.style.color = flag;
|
|
676
622
|
if (elem.style.color !== flag) {
|
|
677
|
-
|
|
623
|
+
document2.body.removeChild(elem);
|
|
678
624
|
return;
|
|
679
625
|
}
|
|
680
626
|
elem.style.color = color;
|
|
681
627
|
if (elem.style.color === flag || elem.style.color === "") {
|
|
682
|
-
|
|
628
|
+
document2.body.removeChild(elem);
|
|
683
629
|
return [0, 0, 0, 0];
|
|
684
630
|
}
|
|
685
|
-
color =
|
|
686
|
-
|
|
631
|
+
color = window2.getComputedStyle(elem).color;
|
|
632
|
+
document2.body.removeChild(elem);
|
|
687
633
|
}
|
|
688
634
|
}
|
|
689
635
|
if (color.indexOf("rgb") === 0) {
|
|
690
|
-
if (color.indexOf("rgba") === -1)
|
|
691
|
-
color = `${color}, 1`;
|
|
636
|
+
if (color.indexOf("rgba") === -1) color = `${color}, 1`;
|
|
692
637
|
return color.match(/[\.\d]+/g).map((a) => +a);
|
|
693
638
|
}
|
|
694
639
|
return [0, 0, 0, 0];
|
|
@@ -714,29 +659,20 @@ var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) %
|
|
|
714
659
|
var getColorShade = (col, amt) => {
|
|
715
660
|
const num = parseInt(col, 16);
|
|
716
661
|
let r = (num >> 16) + amt;
|
|
717
|
-
if (r > 255)
|
|
718
|
-
|
|
719
|
-
else if (r < 0)
|
|
720
|
-
r = 0;
|
|
662
|
+
if (r > 255) r = 255;
|
|
663
|
+
else if (r < 0) r = 0;
|
|
721
664
|
let b = (num >> 8 & 255) + amt;
|
|
722
|
-
if (b > 255)
|
|
723
|
-
|
|
724
|
-
else if (b < 0)
|
|
725
|
-
b = 0;
|
|
665
|
+
if (b > 255) b = 255;
|
|
666
|
+
else if (b < 0) b = 0;
|
|
726
667
|
let g = (num & 255) + amt;
|
|
727
|
-
if (g > 255)
|
|
728
|
-
|
|
729
|
-
else if (g < 0)
|
|
730
|
-
g = 0;
|
|
668
|
+
if (g > 255) g = 255;
|
|
669
|
+
else if (g < 0) g = 0;
|
|
731
670
|
return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
|
|
732
671
|
};
|
|
733
672
|
var getRgbTone = (rgb, tone) => {
|
|
734
|
-
if (isString(rgb) && rgb.includes("rgb"))
|
|
735
|
-
|
|
736
|
-
if (
|
|
737
|
-
rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
738
|
-
if (isNumber(tone))
|
|
739
|
-
tone += "";
|
|
673
|
+
if (isString(rgb) && rgb.includes("rgb")) rgb = colorStringToRgbaArray(rgb).join(", ");
|
|
674
|
+
if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
675
|
+
if (isNumber(tone)) tone += "";
|
|
740
676
|
const toHex = rgbArrayToHex(rgb);
|
|
741
677
|
const abs = tone.slice(0, 1);
|
|
742
678
|
if (abs === "-" || abs === "+") {
|
|
@@ -752,33 +688,27 @@ var getRgbTone = (rgb, tone) => {
|
|
|
752
688
|
};
|
|
753
689
|
|
|
754
690
|
// src/utils/sequence.js
|
|
755
|
-
var import_utils4 = __toESM(
|
|
691
|
+
var import_utils4 = __toESM(require_cjs(), 1);
|
|
756
692
|
|
|
757
693
|
// src/system/color.js
|
|
758
694
|
var getColor = (value, key, config) => {
|
|
759
695
|
const CONFIG2 = config || getActiveConfig();
|
|
760
696
|
if (!isString(value)) {
|
|
761
|
-
if (CONFIG2.verbose)
|
|
762
|
-
console.warn(value, "- type for color is not valid");
|
|
697
|
+
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
763
698
|
return;
|
|
764
699
|
}
|
|
765
|
-
if (value.slice(0, 2) === "--")
|
|
766
|
-
|
|
767
|
-
if (key && value[key])
|
|
768
|
-
value = value[key];
|
|
700
|
+
if (value.slice(0, 2) === "--") return `var(${value})`;
|
|
701
|
+
if (key && value[key]) value = value[key];
|
|
769
702
|
const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
|
|
770
703
|
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
771
704
|
let val = COLOR2[name] || GRADIENT2[name];
|
|
772
705
|
if (!val) {
|
|
773
|
-
if (CONFIG2.verbose)
|
|
774
|
-
console.warn("Can't find color ", name);
|
|
706
|
+
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
775
707
|
return value;
|
|
776
708
|
}
|
|
777
709
|
if (key) {
|
|
778
|
-
if (val[key])
|
|
779
|
-
|
|
780
|
-
else if (CONFIG2.verbose)
|
|
781
|
-
console.warn(value, " - does not have ", key);
|
|
710
|
+
if (val[key]) val = val[key];
|
|
711
|
+
else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
|
|
782
712
|
}
|
|
783
713
|
let rgb = val.rgb;
|
|
784
714
|
if (!rgb) {
|
|
@@ -788,10 +718,8 @@ var getColor = (value, key, config) => {
|
|
|
788
718
|
rgb = getRgbTone(rgb, tone);
|
|
789
719
|
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
790
720
|
}
|
|
791
|
-
if (val[tone])
|
|
792
|
-
|
|
793
|
-
if (alpha)
|
|
794
|
-
return `rgba(${rgb}, ${alpha})`;
|
|
721
|
+
if (val[tone]) rgb = val[tone].rgb;
|
|
722
|
+
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
795
723
|
return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
796
724
|
};
|
|
797
725
|
|
|
@@ -808,22 +736,19 @@ var setThemeValue = (theme) => {
|
|
|
808
736
|
return value;
|
|
809
737
|
};
|
|
810
738
|
var getThemeValue = (theme) => {
|
|
811
|
-
if (theme.value)
|
|
812
|
-
return theme.value;
|
|
739
|
+
if (theme.value) return theme.value;
|
|
813
740
|
theme.value = setThemeValue(theme);
|
|
814
741
|
return theme.value;
|
|
815
742
|
};
|
|
816
743
|
var getTheme = (value, modifier) => {
|
|
817
744
|
const CONFIG2 = getActiveConfig();
|
|
818
|
-
if (CONFIG2.useVariable)
|
|
819
|
-
return getMediaTheme(value, modifier);
|
|
745
|
+
if (CONFIG2.useVariable) return getMediaTheme(value, modifier);
|
|
820
746
|
const { THEME: THEME2 } = CONFIG2;
|
|
821
747
|
if (isString(value)) {
|
|
822
748
|
const [theme, subtheme] = value.split(" ");
|
|
823
749
|
const isOurTheme = THEME2[theme];
|
|
824
750
|
if (isOurTheme) {
|
|
825
|
-
if (!subtheme && !modifier)
|
|
826
|
-
return getThemeValue(isOurTheme);
|
|
751
|
+
if (!subtheme && !modifier) return getThemeValue(isOurTheme);
|
|
827
752
|
value = [theme, subtheme || modifier];
|
|
828
753
|
}
|
|
829
754
|
}
|
|
@@ -831,14 +756,10 @@ var getTheme = (value, modifier) => {
|
|
|
831
756
|
const themeName = value[0];
|
|
832
757
|
const subThemeName = value[1];
|
|
833
758
|
const { helpers, media, state } = THEME2[themeName];
|
|
834
|
-
if (media && media[subThemeName])
|
|
835
|
-
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
if (state && state[subThemeName])
|
|
839
|
-
return getThemeValue(state[subThemeName]);
|
|
840
|
-
} else if (isObject(value))
|
|
841
|
-
return setThemeValue(value);
|
|
759
|
+
if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
|
|
760
|
+
if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
|
|
761
|
+
if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
|
|
762
|
+
} else if (isObject(value)) return setThemeValue(value);
|
|
842
763
|
};
|
|
843
764
|
var setInverseTheme = (theme, variant, value) => {
|
|
844
765
|
if (isObject(variant)) {
|
|
@@ -856,13 +777,11 @@ var setInverseTheme = (theme, variant, value) => {
|
|
|
856
777
|
var setPseudo = (theme, key, variant, themeValue) => {
|
|
857
778
|
const result = getTheme(variant);
|
|
858
779
|
themeValue[`&:${key}`] = result;
|
|
859
|
-
if (isObject(variant) && !variant.value)
|
|
860
|
-
variant.value = result;
|
|
780
|
+
if (isObject(variant) && !variant.value) variant.value = result;
|
|
861
781
|
};
|
|
862
782
|
var setSelectors = (theme, value) => {
|
|
863
783
|
const { state } = theme;
|
|
864
|
-
if (!state)
|
|
865
|
-
return;
|
|
784
|
+
if (!state) return;
|
|
866
785
|
const keys = Object.keys(state);
|
|
867
786
|
keys.map((key) => {
|
|
868
787
|
const variant = state[key];
|
|
@@ -874,20 +793,16 @@ var setSelectors = (theme, value) => {
|
|
|
874
793
|
var setPrefersScheme = (theme, key, variant, themeValue) => {
|
|
875
794
|
const result = getTheme(variant);
|
|
876
795
|
themeValue[`@media (prefers-color-scheme: ${key})`] = result;
|
|
877
|
-
if (isObject(variant) && !variant.value)
|
|
878
|
-
variant.value = result;
|
|
796
|
+
if (isObject(variant) && !variant.value) variant.value = result;
|
|
879
797
|
};
|
|
880
798
|
var setMedia = (theme, value) => {
|
|
881
799
|
const { media } = theme;
|
|
882
|
-
if (!media)
|
|
883
|
-
return;
|
|
800
|
+
if (!media) return;
|
|
884
801
|
const keys = Object.keys(media);
|
|
885
802
|
keys.map((key) => {
|
|
886
803
|
const variant = media[key];
|
|
887
|
-
if (key === "dark" || key === "light")
|
|
888
|
-
|
|
889
|
-
if (key === "inverse")
|
|
890
|
-
setInverseTheme(theme, variant, value);
|
|
804
|
+
if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
|
|
805
|
+
if (key === "inverse") setInverseTheme(theme, variant, value);
|
|
891
806
|
return theme;
|
|
892
807
|
});
|
|
893
808
|
return theme;
|
|
@@ -895,23 +810,19 @@ var setMedia = (theme, value) => {
|
|
|
895
810
|
var setHelpers = (theme, value) => {
|
|
896
811
|
const CONFIG2 = getActiveConfig();
|
|
897
812
|
const { helpers } = theme;
|
|
898
|
-
if (!helpers)
|
|
899
|
-
return;
|
|
813
|
+
if (!helpers) return;
|
|
900
814
|
const keys = Object.keys(helpers);
|
|
901
815
|
keys.map((key) => {
|
|
902
816
|
const helper = helpers[key];
|
|
903
|
-
if (isString(helper))
|
|
904
|
-
|
|
905
|
-
else
|
|
906
|
-
getThemeValue(helpers[key]);
|
|
817
|
+
if (isString(helper)) helpers[key] = CONFIG2.THEME[helper];
|
|
818
|
+
else getThemeValue(helpers[key]);
|
|
907
819
|
return theme;
|
|
908
820
|
});
|
|
909
821
|
return theme;
|
|
910
822
|
};
|
|
911
823
|
var setTheme = (val, key) => {
|
|
912
824
|
const CONFIG2 = getActiveConfig();
|
|
913
|
-
if (CONFIG2.useVariable)
|
|
914
|
-
return setMediaTheme(val, key);
|
|
825
|
+
if (CONFIG2.useVariable) return setMediaTheme(val, key);
|
|
915
826
|
const { state, media, helpers } = val;
|
|
916
827
|
const value = setThemeValue(val, key);
|
|
917
828
|
const CSSvar = `--theme-${key}`;
|
|
@@ -973,24 +884,19 @@ var recursiveTheme = (val) => {
|
|
|
973
884
|
} else if (symb === ":") {
|
|
974
885
|
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
975
886
|
}
|
|
976
|
-
} else
|
|
977
|
-
obj[param] = val[param];
|
|
887
|
+
} else obj[param] = val[param];
|
|
978
888
|
}
|
|
979
889
|
return obj;
|
|
980
890
|
};
|
|
981
891
|
var findModifierFromArray = (val, modifierArray) => {
|
|
982
892
|
const currentMod = modifierArray.shift();
|
|
983
|
-
if (val[currentMod])
|
|
984
|
-
return findModifierFromArray(val[currentMod], modifierArray);
|
|
893
|
+
if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
|
|
985
894
|
return val;
|
|
986
895
|
};
|
|
987
896
|
var findModifier = (val, modifier) => {
|
|
988
|
-
if (isArray(modifier))
|
|
989
|
-
|
|
990
|
-
else
|
|
991
|
-
return val[modifier];
|
|
992
|
-
else
|
|
993
|
-
return val;
|
|
897
|
+
if (isArray(modifier)) return findModifierFromArray(val, modifier);
|
|
898
|
+
else if (isString(modifier) && val[modifier]) return val[modifier];
|
|
899
|
+
else return val;
|
|
994
900
|
};
|
|
995
901
|
var getMediaTheme = (value, modifier) => {
|
|
996
902
|
const activeConfig = getActiveConfig();
|