@symbo.ls/scratch 2.27.0 → 2.27.11
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 +5 -8
- package/dist/cjs/index.js +177 -345
- package/dist/cjs/set.js +126 -240
- package/dist/cjs/system/color.js +54 -87
- package/dist/cjs/system/document.js +26 -29
- package/dist/cjs/system/font.js +30 -37
- package/dist/cjs/system/index.js +126 -243
- package/dist/cjs/system/reset.js +33 -43
- package/dist/cjs/system/shadow.js +69 -117
- package/dist/cjs/system/spacing.js +41 -59
- package/dist/cjs/system/svg.js +31 -41
- package/dist/cjs/system/theme.js +67 -113
- package/dist/cjs/system/timing.js +34 -45
- package/dist/cjs/system/typography.js +43 -73
- package/dist/cjs/transforms/index.js +92 -163
- package/dist/cjs/utils/color.js +21 -35
- package/dist/cjs/utils/font.js +3 -6
- package/dist/cjs/utils/index.js +62 -108
- package/dist/cjs/utils/sequence.js +25 -45
- package/dist/cjs/utils/sprite.js +15 -12
- package/dist/cjs/utils/theme.js +3 -6
- package/dist/cjs/utils/var.js +19 -33
- package/package.json +7 -7
- package/src/system/typography.js +12 -20
- package/src/utils/color.js +42 -30
- package/src/utils/sprite.js +12 -7
package/dist/cjs/utils/font.js
CHANGED
|
@@ -32,10 +32,8 @@ __export(font_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(font_exports);
|
|
34
34
|
var getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
35
|
-
if (LIBRARY[key])
|
|
36
|
-
|
|
37
|
-
if (LIBRARY.default)
|
|
38
|
-
return LIBRARY[LIBRARY.default].value;
|
|
35
|
+
if (LIBRARY[key]) return LIBRARY[key].value;
|
|
36
|
+
if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
|
|
39
37
|
const hasValue = Object.keys(LIBRARY)[0];
|
|
40
38
|
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
|
|
41
39
|
};
|
|
@@ -62,8 +60,7 @@ var getFontFace = (LIBRARY) => {
|
|
|
62
60
|
};
|
|
63
61
|
var getFontFaceEachString = (name, weights) => {
|
|
64
62
|
const isArr = weights[0];
|
|
65
|
-
if (isArr)
|
|
66
|
-
return getFontFaceEach(name, weights).map(setInCustomFontMedia);
|
|
63
|
+
if (isArr) return getFontFaceEach(name, weights).map(setInCustomFontMedia);
|
|
67
64
|
return setCustomFontMedia(name, weights.url);
|
|
68
65
|
};
|
|
69
66
|
var getFontFaceString = (LIBRARY) => {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -51,8 +51,8 @@ var require_cjs = __commonJS({
|
|
|
51
51
|
return to;
|
|
52
52
|
};
|
|
53
53
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
54
|
-
var
|
|
55
|
-
__export2(
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
56
56
|
arrayzeValue: () => arrayzeValue,
|
|
57
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
58
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -73,12 +73,11 @@ var require_cjs = __commonJS({
|
|
|
73
73
|
toTitleCase: () => toTitleCase,
|
|
74
74
|
toggleFullscreen: () => toggleFullscreen
|
|
75
75
|
});
|
|
76
|
-
module2.exports = __toCommonJS2(
|
|
76
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
77
77
|
var window22 = globalThis;
|
|
78
78
|
var document22 = window22.document;
|
|
79
79
|
var isObject2 = (arg) => {
|
|
80
|
-
if (arg === null)
|
|
81
|
-
return false;
|
|
80
|
+
if (arg === null) return false;
|
|
82
81
|
return typeof arg === "object" && arg.constructor === Object;
|
|
83
82
|
};
|
|
84
83
|
var isString2 = (arg) => typeof arg === "string";
|
|
@@ -103,13 +102,11 @@ var require_cjs = __commonJS({
|
|
|
103
102
|
};
|
|
104
103
|
var findClosestNumberInFactory = (val, factory) => {
|
|
105
104
|
val = parseFloat(val);
|
|
106
|
-
if (isObject2(factory))
|
|
107
|
-
factory = Object.values(factory);
|
|
105
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
108
106
|
return findClosestNumber(val, factory);
|
|
109
107
|
};
|
|
110
108
|
var formatDate = (timestamp) => {
|
|
111
|
-
if (!timestamp)
|
|
112
|
-
return "";
|
|
109
|
+
if (!timestamp) return "";
|
|
113
110
|
const d = new Date(timestamp);
|
|
114
111
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
115
112
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -176,8 +173,7 @@ var require_cjs = __commonJS({
|
|
|
176
173
|
scriptEle.type = type;
|
|
177
174
|
scriptEle.text = xhr.responseText;
|
|
178
175
|
doc.body.appendChild(scriptEle);
|
|
179
|
-
if (typeof fallback === "function")
|
|
180
|
-
fallback();
|
|
176
|
+
if (typeof fallback === "function") fallback();
|
|
181
177
|
} else {
|
|
182
178
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
183
179
|
}
|
|
@@ -245,20 +241,15 @@ var require_cjs = __commonJS({
|
|
|
245
241
|
);
|
|
246
242
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
247
243
|
var toDescriptionCase = (str = "") => {
|
|
248
|
-
if (typeof str !== "string")
|
|
249
|
-
return;
|
|
244
|
+
if (typeof str !== "string") return;
|
|
250
245
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
251
246
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
252
247
|
};
|
|
253
248
|
var arrayzeValue = (val) => {
|
|
254
|
-
if (isArray2(val))
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
if (isObject2(val))
|
|
259
|
-
return Object.values(val);
|
|
260
|
-
if (isNumber2(val))
|
|
261
|
-
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];
|
|
262
253
|
};
|
|
263
254
|
}
|
|
264
255
|
});
|
|
@@ -318,6 +309,11 @@ var isScalingUnit = (unit) => {
|
|
|
318
309
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
319
310
|
};
|
|
320
311
|
|
|
312
|
+
// ../../../domql/packages/utils/dist/esm/env.js
|
|
313
|
+
var NODE_ENV = "development";
|
|
314
|
+
var isProduction = (env = NODE_ENV) => env === "production";
|
|
315
|
+
var isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
316
|
+
|
|
321
317
|
// ../../../domql/packages/utils/dist/esm/globals.js
|
|
322
318
|
var window2 = globalThis;
|
|
323
319
|
var document2 = window2.document;
|
|
@@ -334,8 +330,7 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
334
330
|
var isNull = (arg) => arg === null;
|
|
335
331
|
var isArray = (arg) => Array.isArray(arg);
|
|
336
332
|
var isObjectLike = (arg) => {
|
|
337
|
-
if (arg === null)
|
|
338
|
-
return false;
|
|
333
|
+
if (arg === null) return false;
|
|
339
334
|
return typeof arg === "object";
|
|
340
335
|
};
|
|
341
336
|
var isUndefined = (arg) => {
|
|
@@ -403,8 +398,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
403
398
|
const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
404
399
|
visited.set(obj, clone2);
|
|
405
400
|
for (const key in obj) {
|
|
406
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
407
|
-
continue;
|
|
401
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
408
402
|
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
409
403
|
continue;
|
|
410
404
|
const value = obj[key];
|
|
@@ -439,10 +433,8 @@ var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(nav
|
|
|
439
433
|
// src/utils/color.js
|
|
440
434
|
var ENV = "development";
|
|
441
435
|
var colorStringToRgbaArray = (color) => {
|
|
442
|
-
if (color === "")
|
|
443
|
-
|
|
444
|
-
if (color.toLowerCase() === "transparent")
|
|
445
|
-
return [0, 0, 0, 0];
|
|
436
|
+
if (color === "") return [0, 0, 0, 0];
|
|
437
|
+
if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
|
446
438
|
if (color[0] === "#") {
|
|
447
439
|
if (color.length < 7) {
|
|
448
440
|
color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
|
|
@@ -473,8 +465,7 @@ var colorStringToRgbaArray = (color) => {
|
|
|
473
465
|
}
|
|
474
466
|
}
|
|
475
467
|
if (color.indexOf("rgb") === 0) {
|
|
476
|
-
if (color.indexOf("rgba") === -1)
|
|
477
|
-
color = `${color}, 1`;
|
|
468
|
+
if (color.indexOf("rgba") === -1) color = `${color}, 1`;
|
|
478
469
|
return color.match(/[\.\d]+/g).map((a) => +a);
|
|
479
470
|
}
|
|
480
471
|
return [0, 0, 0, 0];
|
|
@@ -511,10 +502,7 @@ var mixTwoRgb = (colorA, colorB, range = 0.5) => {
|
|
|
511
502
|
};
|
|
512
503
|
var changeLightness = (delta, hsl) => {
|
|
513
504
|
const [hue, saturation, lightness] = hsl;
|
|
514
|
-
const newLightness = Math.max(
|
|
515
|
-
0,
|
|
516
|
-
Math.min(100, lightness + parseFloat(delta))
|
|
517
|
-
);
|
|
505
|
+
const newLightness = Math.max(0, Math.min(100, lightness + parseFloat(delta)));
|
|
518
506
|
return [hue, saturation, newLightness];
|
|
519
507
|
};
|
|
520
508
|
var rgbToHSL = (r, g, b) => {
|
|
@@ -524,44 +512,32 @@ var rgbToHSL = (r, g, b) => {
|
|
|
524
512
|
const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
|
|
525
513
|
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
|
|
526
514
|
};
|
|
527
|
-
var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(
|
|
528
|
-
Math.min(k - 3, 9 - k, 1),
|
|
529
|
-
-1
|
|
530
|
-
)) => [f(0), f(8), f(4)];
|
|
515
|
+
var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)) => [f(0), f(8), f(4)];
|
|
531
516
|
var getColorShade = (col, amt) => {
|
|
532
517
|
const num = parseInt(col, 16);
|
|
533
518
|
let r = (num >> 16) + amt;
|
|
534
|
-
if (r > 255)
|
|
535
|
-
|
|
536
|
-
else if (r < 0)
|
|
537
|
-
r = 0;
|
|
519
|
+
if (r > 255) r = 255;
|
|
520
|
+
else if (r < 0) r = 0;
|
|
538
521
|
let b = (num >> 8 & 255) + amt;
|
|
539
|
-
if (b > 255)
|
|
540
|
-
|
|
541
|
-
else if (b < 0)
|
|
542
|
-
b = 0;
|
|
522
|
+
if (b > 255) b = 255;
|
|
523
|
+
else if (b < 0) b = 0;
|
|
543
524
|
let g = (num & 255) + amt;
|
|
544
|
-
if (g > 255)
|
|
545
|
-
|
|
546
|
-
else if (g < 0)
|
|
547
|
-
g = 0;
|
|
525
|
+
if (g > 255) g = 255;
|
|
526
|
+
else if (g < 0) g = 0;
|
|
548
527
|
return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
|
|
549
528
|
};
|
|
550
529
|
var mixTwoRgba = (colorA, colorB, range = 0.5) => {
|
|
551
530
|
const arr = [];
|
|
552
531
|
for (let i = 0; i < 4; i++) {
|
|
553
532
|
const round = i === 3 ? (x) => x : Math.round;
|
|
554
|
-
arr[i] = round(
|
|
555
|
-
colorA[i] + (colorB[i] - colorA[i]) * range
|
|
556
|
-
);
|
|
533
|
+
arr[i] = round(colorA[i] + (colorB[i] - colorA[i]) * range);
|
|
557
534
|
}
|
|
558
535
|
return `rgba(${arr})`;
|
|
559
536
|
};
|
|
560
537
|
var opacify = (color, opacity) => {
|
|
561
538
|
const arr = colorStringToRgbaArray(color);
|
|
562
539
|
if (!arr) {
|
|
563
|
-
if (ENV
|
|
564
|
-
console.warn(color + " color is not rgba");
|
|
540
|
+
if (isNotProduction(ENV)) console.warn(color + " color is not rgba");
|
|
565
541
|
return;
|
|
566
542
|
}
|
|
567
543
|
arr[3] = opacity;
|
|
@@ -570,10 +546,8 @@ var opacify = (color, opacity) => {
|
|
|
570
546
|
var getRgbTone = (rgb, tone) => {
|
|
571
547
|
if (isString(rgb) && rgb.includes("rgb"))
|
|
572
548
|
rgb = colorStringToRgbaArray(rgb).join(", ");
|
|
573
|
-
if (isString(rgb))
|
|
574
|
-
|
|
575
|
-
if (isNumber(tone))
|
|
576
|
-
tone += "";
|
|
549
|
+
if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
550
|
+
if (isNumber(tone)) tone += "";
|
|
577
551
|
const toHex = rgbArrayToHex(rgb);
|
|
578
552
|
const abs = tone.slice(0, 1);
|
|
579
553
|
if (abs === "-" || abs === "+") {
|
|
@@ -590,21 +564,16 @@ var getRgbTone = (rgb, tone) => {
|
|
|
590
564
|
|
|
591
565
|
// src/utils/theme.js
|
|
592
566
|
var returnSubThemeOrDefault = (orig, theme) => {
|
|
593
|
-
if (!orig)
|
|
594
|
-
|
|
595
|
-
if (orig
|
|
596
|
-
return orig.themes[theme];
|
|
597
|
-
if (orig[theme])
|
|
598
|
-
return [orig, orig[theme]];
|
|
567
|
+
if (!orig) return;
|
|
568
|
+
if (orig.themes && orig.themes[theme]) return orig.themes[theme];
|
|
569
|
+
if (orig[theme]) return [orig, orig[theme]];
|
|
599
570
|
return orig;
|
|
600
571
|
};
|
|
601
572
|
|
|
602
573
|
// src/utils/font.js
|
|
603
574
|
var getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
604
|
-
if (LIBRARY[key])
|
|
605
|
-
|
|
606
|
-
if (LIBRARY.default)
|
|
607
|
-
return LIBRARY[LIBRARY.default].value;
|
|
575
|
+
if (LIBRARY[key]) return LIBRARY[key].value;
|
|
576
|
+
if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
|
|
608
577
|
const hasValue = Object.keys(LIBRARY)[0];
|
|
609
578
|
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
|
|
610
579
|
};
|
|
@@ -631,8 +600,7 @@ var getFontFace = (LIBRARY) => {
|
|
|
631
600
|
};
|
|
632
601
|
var getFontFaceEachString = (name, weights) => {
|
|
633
602
|
const isArr = weights[0];
|
|
634
|
-
if (isArr)
|
|
635
|
-
return getFontFaceEach(name, weights).map(setInCustomFontMedia);
|
|
603
|
+
if (isArr) return getFontFaceEach(name, weights).map(setInCustomFontMedia);
|
|
636
604
|
return setCustomFontMedia(name, weights.url);
|
|
637
605
|
};
|
|
638
606
|
var getFontFaceString = (LIBRARY) => {
|
|
@@ -910,8 +878,7 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
910
878
|
var setScalingVar = (key, sequenceProps) => {
|
|
911
879
|
const { base, type, unit } = sequenceProps;
|
|
912
880
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
913
|
-
if (key === 0)
|
|
914
|
-
return defaultVal;
|
|
881
|
+
if (key === 0) return defaultVal;
|
|
915
882
|
const prefix = "--" + (type && type.replace(".", "-"));
|
|
916
883
|
const ratioVar = `${prefix}-ratio`;
|
|
917
884
|
if (key > 0) {
|
|
@@ -948,10 +915,8 @@ var generateSubSequence = (props, sequenceProps) => {
|
|
|
948
915
|
const diffRounded = ~~next - ~~value;
|
|
949
916
|
let arr;
|
|
950
917
|
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
951
|
-
if (diffRounded > 16)
|
|
952
|
-
|
|
953
|
-
else
|
|
954
|
-
arr = [first, second];
|
|
918
|
+
if (diffRounded > 16) arr = [first, middle, second];
|
|
919
|
+
else arr = [first, second];
|
|
955
920
|
arr.forEach((v, k) => {
|
|
956
921
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
957
922
|
const newVar = variable + (k + 1);
|
|
@@ -993,8 +958,7 @@ var generateSequence = (sequenceProps) => {
|
|
|
993
958
|
index: key
|
|
994
959
|
};
|
|
995
960
|
setSequenceValue(props, sequenceProps);
|
|
996
|
-
if (subSequence)
|
|
997
|
-
generateSubSequence(props, sequenceProps);
|
|
961
|
+
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
998
962
|
}
|
|
999
963
|
return sequenceProps;
|
|
1000
964
|
};
|
|
@@ -1044,13 +1008,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1044
1008
|
unit = UNIT2.default,
|
|
1045
1009
|
useVariable
|
|
1046
1010
|
} = sequenceProps;
|
|
1047
|
-
if (isString(value) && value.slice(0, 2) === "--")
|
|
1048
|
-
return `var(${value})`;
|
|
1011
|
+
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
1049
1012
|
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
1050
1013
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
1051
1014
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
1052
|
-
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter)
|
|
1053
|
-
return value;
|
|
1015
|
+
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
|
|
1054
1016
|
const letterVal = value.toUpperCase();
|
|
1055
1017
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
1056
1018
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -1074,8 +1036,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1074
1036
|
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1075
1037
|
}
|
|
1076
1038
|
if (!sequence[absValue] && absValue.length === 2) {
|
|
1077
|
-
if (CONFIG2.verbose)
|
|
1078
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
1039
|
+
if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
1079
1040
|
absValue = absValue.slice(0, 1);
|
|
1080
1041
|
}
|
|
1081
1042
|
if (useVariable || CONFIG2.useVariable) {
|
|
@@ -1083,8 +1044,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1083
1044
|
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
1084
1045
|
}
|
|
1085
1046
|
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
1086
|
-
if (!sequenceItem)
|
|
1087
|
-
return console.warn("can't find", sequence, absValue);
|
|
1047
|
+
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
1088
1048
|
if (unit === "ms" || unit === "s") {
|
|
1089
1049
|
return isNegative + sequenceItem.val + unit;
|
|
1090
1050
|
}
|
|
@@ -1093,12 +1053,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1093
1053
|
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
1094
1054
|
if (typeof value !== "string") {
|
|
1095
1055
|
const CONFIG2 = getActiveConfig();
|
|
1096
|
-
if (CONFIG2.verbose)
|
|
1097
|
-
console.warn(propertyName, value, "is not a string");
|
|
1056
|
+
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
1098
1057
|
return { [propertyName]: value };
|
|
1099
1058
|
}
|
|
1100
|
-
if (value === "-" || value === "")
|
|
1101
|
-
return {};
|
|
1059
|
+
if (value === "-" || value === "") return {};
|
|
1102
1060
|
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
1103
1061
|
};
|
|
1104
1062
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
@@ -1166,23 +1124,19 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
|
1166
1124
|
const { mediaRegenerate } = FACTORY2;
|
|
1167
1125
|
const { sequence, scales } = FACTORY2[media];
|
|
1168
1126
|
const query = MEDIA2[mediaName];
|
|
1169
|
-
if (!query && CONFIG2.verbose)
|
|
1170
|
-
console.warn("Can't find media query ", query);
|
|
1127
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
|
|
1171
1128
|
if (!mediaRegenerate) {
|
|
1172
1129
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1173
|
-
if (!underMediaQuery)
|
|
1174
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1130
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1175
1131
|
applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
1176
1132
|
return;
|
|
1177
1133
|
}
|
|
1178
1134
|
for (const key in sequence) {
|
|
1179
1135
|
const item = sequence[key];
|
|
1180
1136
|
const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
|
|
1181
|
-
if (!query && CONFIG2.verbose)
|
|
1182
|
-
console.warn("Can't find query ", query);
|
|
1137
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
|
|
1183
1138
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1184
|
-
if (!underMediaQuery)
|
|
1185
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1139
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1186
1140
|
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
1187
1141
|
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
1188
1142
|
}
|
|
@@ -1190,15 +1144,13 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
|
1190
1144
|
|
|
1191
1145
|
// src/utils/sprite.js
|
|
1192
1146
|
var ENV2 = "development";
|
|
1193
|
-
var isDev = ENV2
|
|
1147
|
+
var isDev = isNotProduction(ENV2);
|
|
1194
1148
|
var generateSprite = (icons) => {
|
|
1195
1149
|
const CONFIG2 = getActiveConfig();
|
|
1196
1150
|
let sprite = "";
|
|
1197
1151
|
for (const key in icons) {
|
|
1198
|
-
if (CONFIG2.__svg_cache[key])
|
|
1199
|
-
|
|
1200
|
-
else
|
|
1201
|
-
CONFIG2.__svg_cache[key] = true;
|
|
1152
|
+
if (CONFIG2.__svg_cache[key]) continue;
|
|
1153
|
+
else CONFIG2.__svg_cache[key] = true;
|
|
1202
1154
|
sprite += icons[key];
|
|
1203
1155
|
}
|
|
1204
1156
|
return sprite;
|
|
@@ -1206,8 +1158,7 @@ var generateSprite = (icons) => {
|
|
|
1206
1158
|
var parseRootAttributes = (htmlString) => {
|
|
1207
1159
|
const val = htmlString.default || htmlString;
|
|
1208
1160
|
if (!isString(val)) {
|
|
1209
|
-
if (isDev)
|
|
1210
|
-
console.warn("parseRootAttributes:", val, "is not a string");
|
|
1161
|
+
if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
|
|
1211
1162
|
return;
|
|
1212
1163
|
}
|
|
1213
1164
|
const match = val.match(/<svg\s+(.*?)>/);
|
|
@@ -1215,7 +1166,9 @@ var parseRootAttributes = (htmlString) => {
|
|
|
1215
1166
|
return {};
|
|
1216
1167
|
}
|
|
1217
1168
|
const attrString = match[1];
|
|
1218
|
-
const attrs = attrString.match(
|
|
1169
|
+
const attrs = attrString.match(
|
|
1170
|
+
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
1171
|
+
);
|
|
1219
1172
|
return attrs.reduce((acc, attr) => {
|
|
1220
1173
|
const [key, value] = attr.split("=");
|
|
1221
1174
|
acc[key] = value.replace(/['"]/g, "");
|
|
@@ -1250,3 +1203,4 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
1250
1203
|
symbol = symbol.replace("</svg", "</symbol");
|
|
1251
1204
|
return symbol;
|
|
1252
1205
|
};
|
|
1206
|
+
// @preserve-env
|
|
@@ -51,8 +51,8 @@ var require_cjs = __commonJS({
|
|
|
51
51
|
return to;
|
|
52
52
|
};
|
|
53
53
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
54
|
-
var
|
|
55
|
-
__export2(
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
56
56
|
arrayzeValue: () => arrayzeValue,
|
|
57
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
58
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -73,12 +73,11 @@ var require_cjs = __commonJS({
|
|
|
73
73
|
toTitleCase: () => toTitleCase,
|
|
74
74
|
toggleFullscreen: () => toggleFullscreen
|
|
75
75
|
});
|
|
76
|
-
module2.exports = __toCommonJS2(
|
|
76
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
77
77
|
var window22 = globalThis;
|
|
78
78
|
var document22 = window22.document;
|
|
79
79
|
var isObject2 = (arg) => {
|
|
80
|
-
if (arg === null)
|
|
81
|
-
return false;
|
|
80
|
+
if (arg === null) return false;
|
|
82
81
|
return typeof arg === "object" && arg.constructor === Object;
|
|
83
82
|
};
|
|
84
83
|
var isString2 = (arg) => typeof arg === "string";
|
|
@@ -103,13 +102,11 @@ var require_cjs = __commonJS({
|
|
|
103
102
|
};
|
|
104
103
|
var findClosestNumberInFactory = (val, factory) => {
|
|
105
104
|
val = parseFloat(val);
|
|
106
|
-
if (isObject2(factory))
|
|
107
|
-
factory = Object.values(factory);
|
|
105
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
108
106
|
return findClosestNumber(val, factory);
|
|
109
107
|
};
|
|
110
108
|
var formatDate = (timestamp) => {
|
|
111
|
-
if (!timestamp)
|
|
112
|
-
return "";
|
|
109
|
+
if (!timestamp) return "";
|
|
113
110
|
const d = new Date(timestamp);
|
|
114
111
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
115
112
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -176,8 +173,7 @@ var require_cjs = __commonJS({
|
|
|
176
173
|
scriptEle.type = type;
|
|
177
174
|
scriptEle.text = xhr.responseText;
|
|
178
175
|
doc.body.appendChild(scriptEle);
|
|
179
|
-
if (typeof fallback === "function")
|
|
180
|
-
fallback();
|
|
176
|
+
if (typeof fallback === "function") fallback();
|
|
181
177
|
} else {
|
|
182
178
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
183
179
|
}
|
|
@@ -245,20 +241,15 @@ var require_cjs = __commonJS({
|
|
|
245
241
|
);
|
|
246
242
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
247
243
|
var toDescriptionCase = (str = "") => {
|
|
248
|
-
if (typeof str !== "string")
|
|
249
|
-
return;
|
|
244
|
+
if (typeof str !== "string") return;
|
|
250
245
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
251
246
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
252
247
|
};
|
|
253
248
|
var arrayzeValue = (val) => {
|
|
254
|
-
if (isArray2(val))
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
if (isObject2(val))
|
|
259
|
-
return Object.values(val);
|
|
260
|
-
if (isNumber2(val))
|
|
261
|
-
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];
|
|
262
253
|
};
|
|
263
254
|
}
|
|
264
255
|
});
|
|
@@ -296,8 +287,7 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
296
287
|
var isNull = (arg) => arg === null;
|
|
297
288
|
var isArray = (arg) => Array.isArray(arg);
|
|
298
289
|
var isObjectLike = (arg) => {
|
|
299
|
-
if (arg === null)
|
|
300
|
-
return false;
|
|
290
|
+
if (arg === null) return false;
|
|
301
291
|
return typeof arg === "object";
|
|
302
292
|
};
|
|
303
293
|
var isUndefined = (arg) => {
|
|
@@ -365,8 +355,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
365
355
|
const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
366
356
|
visited.set(obj, clone2);
|
|
367
357
|
for (const key in obj) {
|
|
368
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
369
|
-
continue;
|
|
358
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
370
359
|
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
371
360
|
continue;
|
|
372
361
|
const value = obj[key];
|
|
@@ -673,8 +662,7 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
673
662
|
var setScalingVar = (key, sequenceProps) => {
|
|
674
663
|
const { base, type, unit } = sequenceProps;
|
|
675
664
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
676
|
-
if (key === 0)
|
|
677
|
-
return defaultVal;
|
|
665
|
+
if (key === 0) return defaultVal;
|
|
678
666
|
const prefix = "--" + (type && type.replace(".", "-"));
|
|
679
667
|
const ratioVar = `${prefix}-ratio`;
|
|
680
668
|
if (key > 0) {
|
|
@@ -711,10 +699,8 @@ var generateSubSequence = (props, sequenceProps) => {
|
|
|
711
699
|
const diffRounded = ~~next - ~~value;
|
|
712
700
|
let arr;
|
|
713
701
|
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
714
|
-
if (diffRounded > 16)
|
|
715
|
-
|
|
716
|
-
else
|
|
717
|
-
arr = [first, second];
|
|
702
|
+
if (diffRounded > 16) arr = [first, middle, second];
|
|
703
|
+
else arr = [first, second];
|
|
718
704
|
arr.forEach((v, k) => {
|
|
719
705
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
720
706
|
const newVar = variable + (k + 1);
|
|
@@ -756,8 +742,7 @@ var generateSequence = (sequenceProps) => {
|
|
|
756
742
|
index: key
|
|
757
743
|
};
|
|
758
744
|
setSequenceValue(props, sequenceProps);
|
|
759
|
-
if (subSequence)
|
|
760
|
-
generateSubSequence(props, sequenceProps);
|
|
745
|
+
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
761
746
|
}
|
|
762
747
|
return sequenceProps;
|
|
763
748
|
};
|
|
@@ -807,13 +792,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
807
792
|
unit = UNIT2.default,
|
|
808
793
|
useVariable
|
|
809
794
|
} = sequenceProps;
|
|
810
|
-
if (isString(value) && value.slice(0, 2) === "--")
|
|
811
|
-
return `var(${value})`;
|
|
795
|
+
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
812
796
|
const prefix = `--${(0, import_utils3.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
813
797
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
814
798
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
815
|
-
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter)
|
|
816
|
-
return value;
|
|
799
|
+
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
|
|
817
800
|
const letterVal = value.toUpperCase();
|
|
818
801
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
819
802
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -837,8 +820,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
837
820
|
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
838
821
|
}
|
|
839
822
|
if (!sequence[absValue] && absValue.length === 2) {
|
|
840
|
-
if (CONFIG2.verbose)
|
|
841
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
823
|
+
if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
842
824
|
absValue = absValue.slice(0, 1);
|
|
843
825
|
}
|
|
844
826
|
if (useVariable || CONFIG2.useVariable) {
|
|
@@ -846,8 +828,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
846
828
|
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
847
829
|
}
|
|
848
830
|
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
849
|
-
if (!sequenceItem)
|
|
850
|
-
return console.warn("can't find", sequence, absValue);
|
|
831
|
+
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
851
832
|
if (unit === "ms" || unit === "s") {
|
|
852
833
|
return isNegative + sequenceItem.val + unit;
|
|
853
834
|
}
|
|
@@ -856,12 +837,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
856
837
|
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
857
838
|
if (typeof value !== "string") {
|
|
858
839
|
const CONFIG2 = getActiveConfig();
|
|
859
|
-
if (CONFIG2.verbose)
|
|
860
|
-
console.warn(propertyName, value, "is not a string");
|
|
840
|
+
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
861
841
|
return { [propertyName]: value };
|
|
862
842
|
}
|
|
863
|
-
if (value === "-" || value === "")
|
|
864
|
-
return {};
|
|
843
|
+
if (value === "-" || value === "") return {};
|
|
865
844
|
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
866
845
|
};
|
|
867
846
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
@@ -872,3 +851,4 @@ var findHeadings = (propertyNames) => {
|
|
|
872
851
|
return sequence[findLetter];
|
|
873
852
|
});
|
|
874
853
|
};
|
|
854
|
+
// @preserve-env
|
package/dist/cjs/utils/sprite.js
CHANGED
|
@@ -25,6 +25,11 @@ __export(sprite_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(sprite_exports);
|
|
27
27
|
|
|
28
|
+
// ../../../domql/packages/utils/dist/esm/env.js
|
|
29
|
+
var NODE_ENV = "development";
|
|
30
|
+
var isProduction = (env = NODE_ENV) => env === "production";
|
|
31
|
+
var isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
32
|
+
|
|
28
33
|
// ../../../domql/packages/utils/dist/esm/globals.js
|
|
29
34
|
var window2 = globalThis;
|
|
30
35
|
var document2 = window2.document;
|
|
@@ -40,8 +45,7 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
40
45
|
var isNull = (arg) => arg === null;
|
|
41
46
|
var isArray = (arg) => Array.isArray(arg);
|
|
42
47
|
var isObjectLike = (arg) => {
|
|
43
|
-
if (arg === null)
|
|
44
|
-
return false;
|
|
48
|
+
if (arg === null) return false;
|
|
45
49
|
return typeof arg === "object";
|
|
46
50
|
};
|
|
47
51
|
var isUndefined = (arg) => {
|
|
@@ -109,8 +113,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
109
113
|
const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
110
114
|
visited.set(obj, clone2);
|
|
111
115
|
for (const key in obj) {
|
|
112
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
113
|
-
continue;
|
|
116
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
114
117
|
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
115
118
|
continue;
|
|
116
119
|
const value = obj[key];
|
|
@@ -365,15 +368,13 @@ var getActiveConfig = (def) => {
|
|
|
365
368
|
|
|
366
369
|
// src/utils/sprite.js
|
|
367
370
|
var ENV = "development";
|
|
368
|
-
var isDev = ENV
|
|
371
|
+
var isDev = isNotProduction(ENV);
|
|
369
372
|
var generateSprite = (icons) => {
|
|
370
373
|
const CONFIG2 = getActiveConfig();
|
|
371
374
|
let sprite = "";
|
|
372
375
|
for (const key in icons) {
|
|
373
|
-
if (CONFIG2.__svg_cache[key])
|
|
374
|
-
|
|
375
|
-
else
|
|
376
|
-
CONFIG2.__svg_cache[key] = true;
|
|
376
|
+
if (CONFIG2.__svg_cache[key]) continue;
|
|
377
|
+
else CONFIG2.__svg_cache[key] = true;
|
|
377
378
|
sprite += icons[key];
|
|
378
379
|
}
|
|
379
380
|
return sprite;
|
|
@@ -381,8 +382,7 @@ var generateSprite = (icons) => {
|
|
|
381
382
|
var parseRootAttributes = (htmlString) => {
|
|
382
383
|
const val = htmlString.default || htmlString;
|
|
383
384
|
if (!isString(val)) {
|
|
384
|
-
if (isDev)
|
|
385
|
-
console.warn("parseRootAttributes:", val, "is not a string");
|
|
385
|
+
if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
|
|
386
386
|
return;
|
|
387
387
|
}
|
|
388
388
|
const match = val.match(/<svg\s+(.*?)>/);
|
|
@@ -390,7 +390,9 @@ var parseRootAttributes = (htmlString) => {
|
|
|
390
390
|
return {};
|
|
391
391
|
}
|
|
392
392
|
const attrString = match[1];
|
|
393
|
-
const attrs = attrString.match(
|
|
393
|
+
const attrs = attrString.match(
|
|
394
|
+
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
395
|
+
);
|
|
394
396
|
return attrs.reduce((acc, attr) => {
|
|
395
397
|
const [key, value] = attr.split("=");
|
|
396
398
|
acc[key] = value.replace(/['"]/g, "");
|
|
@@ -425,3 +427,4 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
425
427
|
symbol = symbol.replace("</svg", "</symbol");
|
|
426
428
|
return symbol;
|
|
427
429
|
};
|
|
430
|
+
// @preserve-env
|