@symbo.ls/scratch 2.11.523 → 3.0.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/dist/cjs/factory.js +106 -51
- package/dist/cjs/index.js +366 -423
- package/dist/cjs/set.js +304 -321
- package/dist/cjs/system/color.js +231 -181
- package/dist/cjs/system/document.js +198 -121
- package/dist/cjs/system/font.js +199 -127
- package/dist/cjs/system/index.js +308 -325
- package/dist/cjs/system/reset.js +205 -135
- package/dist/cjs/system/shadow.js +247 -212
- package/dist/cjs/system/spacing.js +215 -153
- package/dist/cjs/system/svg.js +203 -132
- package/dist/cjs/system/theme.js +243 -206
- package/dist/cjs/system/timing.js +206 -138
- package/dist/cjs/system/typography.js +212 -148
- package/dist/cjs/transforms/index.js +285 -268
- package/dist/cjs/utils/color.js +93 -85
- package/dist/cjs/utils/font.js +3 -6
- package/dist/cjs/utils/index.js +236 -193
- package/dist/cjs/utils/sequence.js +206 -99
- package/dist/cjs/utils/sprite.js +106 -51
- package/dist/cjs/utils/theme.js +3 -6
- package/dist/cjs/utils/var.js +196 -83
- package/package.json +4 -4
- 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
|
@@ -30,65 +30,29 @@ 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
|
-
var
|
|
37
|
+
var __defProp2 = Object.defineProperty;
|
|
74
38
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
75
39
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
76
|
-
var
|
|
40
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
77
41
|
var __export2 = (target, all) => {
|
|
78
42
|
for (var name in all)
|
|
79
|
-
|
|
43
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
80
44
|
};
|
|
81
45
|
var __copyProps2 = (to, from, except, desc) => {
|
|
82
46
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
83
47
|
for (let key of __getOwnPropNames2(from))
|
|
84
|
-
if (!
|
|
85
|
-
|
|
48
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
49
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
86
50
|
}
|
|
87
51
|
return to;
|
|
88
52
|
};
|
|
89
|
-
var __toCommonJS2 = (mod) => __copyProps2(
|
|
90
|
-
var
|
|
91
|
-
__export2(
|
|
53
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
92
56
|
arrayzeValue: () => arrayzeValue2,
|
|
93
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
94
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -109,17 +73,85 @@ 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";
|
|
121
84
|
var isNumber2 = (arg) => typeof arg === "number";
|
|
122
85
|
var isArray2 = (arg) => Array.isArray(arg);
|
|
86
|
+
var STATE_METHODS2 = [
|
|
87
|
+
"update",
|
|
88
|
+
"parse",
|
|
89
|
+
"clean",
|
|
90
|
+
"create",
|
|
91
|
+
"destroy",
|
|
92
|
+
"add",
|
|
93
|
+
"toggle",
|
|
94
|
+
"remove",
|
|
95
|
+
"apply",
|
|
96
|
+
"set",
|
|
97
|
+
"reset",
|
|
98
|
+
"replace",
|
|
99
|
+
"quietReplace",
|
|
100
|
+
"quietUpdate",
|
|
101
|
+
"applyReplace",
|
|
102
|
+
"applyFunction",
|
|
103
|
+
"keys",
|
|
104
|
+
"values",
|
|
105
|
+
"ref",
|
|
106
|
+
"rootUpdate",
|
|
107
|
+
"parentUpdate",
|
|
108
|
+
"parent",
|
|
109
|
+
"__element",
|
|
110
|
+
"__depends",
|
|
111
|
+
"__ref",
|
|
112
|
+
"__children",
|
|
113
|
+
"root",
|
|
114
|
+
"setByPath",
|
|
115
|
+
"setPathCollection",
|
|
116
|
+
"removeByPath",
|
|
117
|
+
"removePathCollection",
|
|
118
|
+
"getByPath"
|
|
119
|
+
];
|
|
120
|
+
var PROPS_METHODS2 = ["update", "__element"];
|
|
121
|
+
var METHODS2 = [
|
|
122
|
+
"set",
|
|
123
|
+
"reset",
|
|
124
|
+
"update",
|
|
125
|
+
"remove",
|
|
126
|
+
"updateContent",
|
|
127
|
+
"removeContent",
|
|
128
|
+
"lookup",
|
|
129
|
+
"lookdown",
|
|
130
|
+
"lookdownAll",
|
|
131
|
+
"getRef",
|
|
132
|
+
"getPath",
|
|
133
|
+
"setNodeStyles",
|
|
134
|
+
"spotByPath",
|
|
135
|
+
"keys",
|
|
136
|
+
"parse",
|
|
137
|
+
"setProps",
|
|
138
|
+
"parseDeep",
|
|
139
|
+
"variables",
|
|
140
|
+
"if",
|
|
141
|
+
"log",
|
|
142
|
+
"verbose",
|
|
143
|
+
"warn",
|
|
144
|
+
"error",
|
|
145
|
+
"call",
|
|
146
|
+
"nextElement",
|
|
147
|
+
"previousElement"
|
|
148
|
+
];
|
|
149
|
+
var METHODS_EXL2 = [
|
|
150
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
151
|
+
...METHODS2,
|
|
152
|
+
...STATE_METHODS2,
|
|
153
|
+
...PROPS_METHODS2
|
|
154
|
+
];
|
|
123
155
|
var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
124
156
|
async function toggleFullscreen(opts) {
|
|
125
157
|
if (!document.fullscreenElement) {
|
|
@@ -139,13 +171,11 @@ var require_cjs2 = __commonJS({
|
|
|
139
171
|
};
|
|
140
172
|
var findClosestNumberInFactory = (val, factory) => {
|
|
141
173
|
val = parseFloat(val);
|
|
142
|
-
if (isObject2(factory))
|
|
143
|
-
factory = Object.values(factory);
|
|
174
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
144
175
|
return findClosestNumber(val, factory);
|
|
145
176
|
};
|
|
146
177
|
var formatDate = (timestamp) => {
|
|
147
|
-
if (!timestamp)
|
|
148
|
-
return "";
|
|
178
|
+
if (!timestamp) return "";
|
|
149
179
|
const d = new Date(timestamp);
|
|
150
180
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
151
181
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -212,8 +242,7 @@ var require_cjs2 = __commonJS({
|
|
|
212
242
|
scriptEle.type = type;
|
|
213
243
|
scriptEle.text = xhr.responseText;
|
|
214
244
|
doc.body.appendChild(scriptEle);
|
|
215
|
-
if (typeof fallback === "function")
|
|
216
|
-
fallback();
|
|
245
|
+
if (typeof fallback === "function") fallback();
|
|
217
246
|
} else {
|
|
218
247
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
219
248
|
}
|
|
@@ -281,20 +310,15 @@ var require_cjs2 = __commonJS({
|
|
|
281
310
|
);
|
|
282
311
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
283
312
|
var toDescriptionCase = (str = "") => {
|
|
284
|
-
if (typeof str !== "string")
|
|
285
|
-
return;
|
|
313
|
+
if (typeof str !== "string") return;
|
|
286
314
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
287
315
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
288
316
|
};
|
|
289
317
|
var arrayzeValue2 = (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];
|
|
318
|
+
if (isArray2(val)) return val;
|
|
319
|
+
if (isString2(val)) return val.split(" ");
|
|
320
|
+
if (isObject2(val)) return Object.values(val);
|
|
321
|
+
if (isNumber2(val)) return [val];
|
|
298
322
|
};
|
|
299
323
|
}
|
|
300
324
|
});
|
|
@@ -307,19 +331,18 @@ __export(shadow_exports, {
|
|
|
307
331
|
});
|
|
308
332
|
module.exports = __toCommonJS(shadow_exports);
|
|
309
333
|
|
|
310
|
-
// ../../node_modules/@domql/utils/
|
|
334
|
+
// ../../node_modules/@domql/utils/globals.js
|
|
311
335
|
var window2 = globalThis;
|
|
312
336
|
var document2 = window2.document;
|
|
313
337
|
|
|
314
|
-
// ../../node_modules/@domql/utils/
|
|
338
|
+
// ../../node_modules/@domql/utils/node.js
|
|
315
339
|
var isDOMNode = (obj) => {
|
|
316
340
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
317
341
|
};
|
|
318
342
|
|
|
319
|
-
// ../../node_modules/@domql/utils/
|
|
343
|
+
// ../../node_modules/@domql/utils/types.js
|
|
320
344
|
var isObject = (arg) => {
|
|
321
|
-
if (arg === null)
|
|
322
|
-
return false;
|
|
345
|
+
if (arg === null) return false;
|
|
323
346
|
return typeof arg === "object" && arg.constructor === Object;
|
|
324
347
|
};
|
|
325
348
|
var isString = (arg) => typeof arg === "string";
|
|
@@ -328,44 +351,99 @@ var isFunction = (arg) => typeof arg === "function";
|
|
|
328
351
|
var isNull = (arg) => arg === null;
|
|
329
352
|
var isArray = (arg) => Array.isArray(arg);
|
|
330
353
|
var isObjectLike = (arg) => {
|
|
331
|
-
if (arg === null)
|
|
332
|
-
return false;
|
|
354
|
+
if (arg === null) return false;
|
|
333
355
|
return typeof arg === "object";
|
|
334
356
|
};
|
|
335
357
|
var isUndefined = (arg) => {
|
|
336
358
|
return arg === void 0;
|
|
337
359
|
};
|
|
338
360
|
|
|
339
|
-
// ../../node_modules/@domql/utils/
|
|
340
|
-
var
|
|
341
|
-
return arr.reduce(
|
|
361
|
+
// ../../node_modules/@domql/utils/array.js
|
|
362
|
+
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
363
|
+
return arr.reduce(
|
|
364
|
+
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
365
|
+
{}
|
|
366
|
+
);
|
|
342
367
|
};
|
|
343
368
|
|
|
344
|
-
// ../../node_modules/@domql/utils/
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
369
|
+
// ../../node_modules/@domql/utils/keys.js
|
|
370
|
+
var STATE_METHODS = [
|
|
371
|
+
"update",
|
|
372
|
+
"parse",
|
|
373
|
+
"clean",
|
|
374
|
+
"create",
|
|
375
|
+
"destroy",
|
|
376
|
+
"add",
|
|
377
|
+
"toggle",
|
|
378
|
+
"remove",
|
|
379
|
+
"apply",
|
|
380
|
+
"set",
|
|
381
|
+
"reset",
|
|
382
|
+
"replace",
|
|
383
|
+
"quietReplace",
|
|
384
|
+
"quietUpdate",
|
|
385
|
+
"applyReplace",
|
|
386
|
+
"applyFunction",
|
|
387
|
+
"keys",
|
|
388
|
+
"values",
|
|
389
|
+
"ref",
|
|
390
|
+
"rootUpdate",
|
|
391
|
+
"parentUpdate",
|
|
392
|
+
"parent",
|
|
393
|
+
"__element",
|
|
394
|
+
"__depends",
|
|
395
|
+
"__ref",
|
|
396
|
+
"__children",
|
|
397
|
+
"root",
|
|
398
|
+
"setByPath",
|
|
399
|
+
"setPathCollection",
|
|
400
|
+
"removeByPath",
|
|
401
|
+
"removePathCollection",
|
|
402
|
+
"getByPath"
|
|
403
|
+
];
|
|
404
|
+
var PROPS_METHODS = ["update", "__element"];
|
|
405
|
+
var METHODS = [
|
|
406
|
+
"set",
|
|
407
|
+
"reset",
|
|
408
|
+
"update",
|
|
409
|
+
"remove",
|
|
410
|
+
"updateContent",
|
|
411
|
+
"removeContent",
|
|
412
|
+
"lookup",
|
|
413
|
+
"lookdown",
|
|
414
|
+
"lookdownAll",
|
|
415
|
+
"getRef",
|
|
416
|
+
"getPath",
|
|
417
|
+
"setNodeStyles",
|
|
418
|
+
"spotByPath",
|
|
419
|
+
"keys",
|
|
420
|
+
"parse",
|
|
421
|
+
"setProps",
|
|
422
|
+
"parseDeep",
|
|
423
|
+
"variables",
|
|
424
|
+
"if",
|
|
425
|
+
"log",
|
|
426
|
+
"verbose",
|
|
427
|
+
"warn",
|
|
428
|
+
"error",
|
|
429
|
+
"call",
|
|
430
|
+
"nextElement",
|
|
431
|
+
"previousElement"
|
|
432
|
+
];
|
|
433
|
+
var METHODS_EXL = [
|
|
434
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
435
|
+
...METHODS,
|
|
436
|
+
...STATE_METHODS,
|
|
437
|
+
...PROPS_METHODS
|
|
438
|
+
];
|
|
439
|
+
|
|
440
|
+
// ../../node_modules/@domql/utils/object.js
|
|
441
|
+
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
365
442
|
for (const e in extend) {
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
443
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
444
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
368
445
|
continue;
|
|
446
|
+
}
|
|
369
447
|
const elementProp = element[e];
|
|
370
448
|
const extendProp = extend[e];
|
|
371
449
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -383,7 +461,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
383
461
|
cleanNull = false,
|
|
384
462
|
window: targetWindow,
|
|
385
463
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
386
|
-
|
|
464
|
+
handleExtends = false
|
|
387
465
|
} = options;
|
|
388
466
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
389
467
|
return obj;
|
|
@@ -391,40 +469,42 @@ var deepClone = (obj, options = {}) => {
|
|
|
391
469
|
if (visited.has(obj)) {
|
|
392
470
|
return visited.get(obj);
|
|
393
471
|
}
|
|
394
|
-
const
|
|
395
|
-
visited.set(obj,
|
|
472
|
+
const clone = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
473
|
+
visited.set(obj, clone);
|
|
396
474
|
for (const key in obj) {
|
|
397
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
398
|
-
|
|
399
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
475
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
476
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
400
477
|
continue;
|
|
478
|
+
}
|
|
401
479
|
const value = obj[key];
|
|
402
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
480
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
|
|
403
481
|
continue;
|
|
482
|
+
}
|
|
404
483
|
if (isDOMNode(value)) {
|
|
405
|
-
|
|
484
|
+
clone[key] = value;
|
|
406
485
|
continue;
|
|
407
486
|
}
|
|
408
|
-
if (
|
|
409
|
-
|
|
487
|
+
if (handleExtends && key === "extends" && isArray(value)) {
|
|
488
|
+
clone[key] = unstackArrayOfObjects(value, exclude);
|
|
410
489
|
continue;
|
|
411
490
|
}
|
|
412
491
|
if (isFunction(value) && targetWindow) {
|
|
413
|
-
|
|
492
|
+
clone[key] = targetWindow.eval("(" + value.toString() + ")");
|
|
414
493
|
continue;
|
|
415
494
|
}
|
|
416
495
|
if (isObjectLike(value)) {
|
|
417
|
-
|
|
496
|
+
clone[key] = deepClone(value, {
|
|
497
|
+
...options,
|
|
418
498
|
visited
|
|
419
|
-
})
|
|
499
|
+
});
|
|
420
500
|
} else {
|
|
421
|
-
|
|
501
|
+
clone[key] = value;
|
|
422
502
|
}
|
|
423
503
|
}
|
|
424
|
-
return
|
|
504
|
+
return clone;
|
|
425
505
|
};
|
|
426
506
|
|
|
427
|
-
// ../../node_modules/@domql/utils/
|
|
507
|
+
// ../../node_modules/@domql/utils/cookie.js
|
|
428
508
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
429
509
|
|
|
430
510
|
// src/defaultConfig/index.js
|
|
@@ -654,12 +734,9 @@ var isScalingUnit = (unit) => {
|
|
|
654
734
|
};
|
|
655
735
|
|
|
656
736
|
// src/utils/color.js
|
|
657
|
-
var import_globals4 = __toESM(require_cjs(), 1);
|
|
658
737
|
var colorStringToRgbaArray = (color) => {
|
|
659
|
-
if (color === "")
|
|
660
|
-
|
|
661
|
-
if (color.toLowerCase() === "transparent")
|
|
662
|
-
return [0, 0, 0, 0];
|
|
738
|
+
if (color === "") return [0, 0, 0, 0];
|
|
739
|
+
if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
|
663
740
|
if (color[0] === "#") {
|
|
664
741
|
if (color.length < 7) {
|
|
665
742
|
color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
|
|
@@ -672,26 +749,25 @@ var colorStringToRgbaArray = (color) => {
|
|
|
672
749
|
];
|
|
673
750
|
}
|
|
674
751
|
if (color.indexOf("rgb") === -1) {
|
|
675
|
-
if (
|
|
676
|
-
const elem =
|
|
752
|
+
if (document2 && window2) {
|
|
753
|
+
const elem = document2.body.appendChild(document2.createElement("fictum"));
|
|
677
754
|
const flag = "rgb(1, 2, 3)";
|
|
678
755
|
elem.style.color = flag;
|
|
679
756
|
if (elem.style.color !== flag) {
|
|
680
|
-
|
|
757
|
+
document2.body.removeChild(elem);
|
|
681
758
|
return;
|
|
682
759
|
}
|
|
683
760
|
elem.style.color = color;
|
|
684
761
|
if (elem.style.color === flag || elem.style.color === "") {
|
|
685
|
-
|
|
762
|
+
document2.body.removeChild(elem);
|
|
686
763
|
return [0, 0, 0, 0];
|
|
687
764
|
}
|
|
688
|
-
color =
|
|
689
|
-
|
|
765
|
+
color = window2.getComputedStyle(elem).color;
|
|
766
|
+
document2.body.removeChild(elem);
|
|
690
767
|
}
|
|
691
768
|
}
|
|
692
769
|
if (color.indexOf("rgb") === 0) {
|
|
693
|
-
if (color.indexOf("rgba") === -1)
|
|
694
|
-
color = `${color}, 1`;
|
|
770
|
+
if (color.indexOf("rgba") === -1) color = `${color}, 1`;
|
|
695
771
|
return color.match(/[\.\d]+/g).map((a) => +a);
|
|
696
772
|
}
|
|
697
773
|
return [0, 0, 0, 0];
|
|
@@ -717,29 +793,20 @@ var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) %
|
|
|
717
793
|
var getColorShade = (col, amt) => {
|
|
718
794
|
const num = parseInt(col, 16);
|
|
719
795
|
let r = (num >> 16) + amt;
|
|
720
|
-
if (r > 255)
|
|
721
|
-
|
|
722
|
-
else if (r < 0)
|
|
723
|
-
r = 0;
|
|
796
|
+
if (r > 255) r = 255;
|
|
797
|
+
else if (r < 0) r = 0;
|
|
724
798
|
let b = (num >> 8 & 255) + amt;
|
|
725
|
-
if (b > 255)
|
|
726
|
-
|
|
727
|
-
else if (b < 0)
|
|
728
|
-
b = 0;
|
|
799
|
+
if (b > 255) b = 255;
|
|
800
|
+
else if (b < 0) b = 0;
|
|
729
801
|
let g = (num & 255) + amt;
|
|
730
|
-
if (g > 255)
|
|
731
|
-
|
|
732
|
-
else if (g < 0)
|
|
733
|
-
g = 0;
|
|
802
|
+
if (g > 255) g = 255;
|
|
803
|
+
else if (g < 0) g = 0;
|
|
734
804
|
return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
|
|
735
805
|
};
|
|
736
806
|
var getRgbTone = (rgb, tone) => {
|
|
737
|
-
if (isString(rgb) && rgb.includes("rgb"))
|
|
738
|
-
|
|
739
|
-
if (
|
|
740
|
-
rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
741
|
-
if (isNumber(tone))
|
|
742
|
-
tone += "";
|
|
807
|
+
if (isString(rgb) && rgb.includes("rgb")) rgb = colorStringToRgbaArray(rgb).join(", ");
|
|
808
|
+
if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
809
|
+
if (isNumber(tone)) tone += "";
|
|
743
810
|
const toHex = rgbArrayToHex(rgb);
|
|
744
811
|
const abs = tone.slice(0, 1);
|
|
745
812
|
if (abs === "-" || abs === "+") {
|
|
@@ -755,7 +822,7 @@ var getRgbTone = (rgb, tone) => {
|
|
|
755
822
|
};
|
|
756
823
|
|
|
757
824
|
// src/utils/sequence.js
|
|
758
|
-
var
|
|
825
|
+
var import_utils6 = __toESM(require_cjs(), 1);
|
|
759
826
|
var numToLetterMap = {
|
|
760
827
|
"-6": "U",
|
|
761
828
|
"-5": "V",
|
|
@@ -801,8 +868,7 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
801
868
|
var setScalingVar = (key, sequenceProps) => {
|
|
802
869
|
const { base, type, unit } = sequenceProps;
|
|
803
870
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
804
|
-
if (key === 0)
|
|
805
|
-
return defaultVal;
|
|
871
|
+
if (key === 0) return defaultVal;
|
|
806
872
|
const prefix = "--" + (type && type.replace(".", "-"));
|
|
807
873
|
const ratioVar = `${prefix}-ratio`;
|
|
808
874
|
if (key > 0) {
|
|
@@ -836,10 +902,8 @@ var generateSubSequence = (props, sequenceProps) => {
|
|
|
836
902
|
const diffRounded = ~~next - ~~value;
|
|
837
903
|
let arr;
|
|
838
904
|
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
839
|
-
if (diffRounded > 16)
|
|
840
|
-
|
|
841
|
-
else
|
|
842
|
-
arr = [first, second];
|
|
905
|
+
if (diffRounded > 16) arr = [first, middle, second];
|
|
906
|
+
else arr = [first, second];
|
|
843
907
|
arr.forEach((v, k) => {
|
|
844
908
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
845
909
|
const newVar = variable + (k + 1);
|
|
@@ -881,8 +945,7 @@ var generateSequence = (sequenceProps) => {
|
|
|
881
945
|
index: key
|
|
882
946
|
};
|
|
883
947
|
setSequenceValue(props, sequenceProps);
|
|
884
|
-
if (subSequence)
|
|
885
|
-
generateSubSequence(props, sequenceProps);
|
|
948
|
+
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
886
949
|
}
|
|
887
950
|
return sequenceProps;
|
|
888
951
|
};
|
|
@@ -894,13 +957,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
894
957
|
unit = UNIT2.default,
|
|
895
958
|
useVariable
|
|
896
959
|
} = sequenceProps;
|
|
897
|
-
if (isString(value) && value.slice(0, 2) === "--")
|
|
898
|
-
|
|
899
|
-
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
960
|
+
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
961
|
+
const prefix = `--${(0, import_utils6.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
900
962
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
901
963
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
902
|
-
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)
|
|
903
|
-
return value;
|
|
964
|
+
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;
|
|
904
965
|
const letterVal = value.toUpperCase();
|
|
905
966
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
906
967
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -924,8 +985,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
924
985
|
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
925
986
|
}
|
|
926
987
|
if (!sequence[absValue] && absValue.length === 2) {
|
|
927
|
-
if (CONFIG2.verbose)
|
|
928
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
988
|
+
if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
929
989
|
absValue = absValue.slice(0, 1);
|
|
930
990
|
}
|
|
931
991
|
if (useVariable || CONFIG2.useVariable) {
|
|
@@ -933,8 +993,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
933
993
|
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
934
994
|
}
|
|
935
995
|
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
936
|
-
if (!sequenceItem)
|
|
937
|
-
return console.warn("can't find", sequence, absValue);
|
|
996
|
+
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
938
997
|
if (unit === "ms" || unit === "s") {
|
|
939
998
|
return isNegative + sequenceItem.val + unit;
|
|
940
999
|
}
|
|
@@ -943,12 +1002,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
943
1002
|
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
944
1003
|
if (typeof value !== "string") {
|
|
945
1004
|
const CONFIG2 = getActiveConfig();
|
|
946
|
-
if (CONFIG2.verbose)
|
|
947
|
-
console.warn(propertyName, value, "is not a string");
|
|
1005
|
+
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
948
1006
|
return { [propertyName]: value };
|
|
949
1007
|
}
|
|
950
|
-
if (value === "-" || value === "")
|
|
951
|
-
return {};
|
|
1008
|
+
if (value === "-" || value === "") return {};
|
|
952
1009
|
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
953
1010
|
};
|
|
954
1011
|
|
|
@@ -956,27 +1013,21 @@ var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
|
956
1013
|
var getColor = (value, key, config) => {
|
|
957
1014
|
const CONFIG2 = config || getActiveConfig();
|
|
958
1015
|
if (!isString(value)) {
|
|
959
|
-
if (CONFIG2.verbose)
|
|
960
|
-
console.warn(value, "- type for color is not valid");
|
|
1016
|
+
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
961
1017
|
return;
|
|
962
1018
|
}
|
|
963
|
-
if (value.slice(0, 2) === "--")
|
|
964
|
-
|
|
965
|
-
if (key && value[key])
|
|
966
|
-
value = value[key];
|
|
1019
|
+
if (value.slice(0, 2) === "--") return `var(${value})`;
|
|
1020
|
+
if (key && value[key]) value = value[key];
|
|
967
1021
|
const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
|
|
968
1022
|
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
969
1023
|
let val = COLOR2[name] || GRADIENT2[name];
|
|
970
1024
|
if (!val) {
|
|
971
|
-
if (CONFIG2.verbose)
|
|
972
|
-
console.warn("Can't find color ", name);
|
|
1025
|
+
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
973
1026
|
return value;
|
|
974
1027
|
}
|
|
975
1028
|
if (key) {
|
|
976
|
-
if (val[key])
|
|
977
|
-
|
|
978
|
-
else if (CONFIG2.verbose)
|
|
979
|
-
console.warn(value, " - does not have ", key);
|
|
1029
|
+
if (val[key]) val = val[key];
|
|
1030
|
+
else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
|
|
980
1031
|
}
|
|
981
1032
|
let rgb = val.rgb;
|
|
982
1033
|
if (!rgb) {
|
|
@@ -986,20 +1037,17 @@ var getColor = (value, key, config) => {
|
|
|
986
1037
|
rgb = getRgbTone(rgb, tone);
|
|
987
1038
|
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
988
1039
|
}
|
|
989
|
-
if (val[tone])
|
|
990
|
-
|
|
991
|
-
if (alpha)
|
|
992
|
-
return `rgba(${rgb}, ${alpha})`;
|
|
1040
|
+
if (val[tone]) rgb = val[tone].rgb;
|
|
1041
|
+
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
993
1042
|
return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
994
1043
|
};
|
|
995
1044
|
|
|
996
1045
|
// src/system/spacing.js
|
|
997
|
-
var
|
|
1046
|
+
var import_utils11 = __toESM(require_cjs(), 1);
|
|
998
1047
|
var getSequence = (sequenceProps) => {
|
|
999
1048
|
const CONFIG2 = getActiveConfig();
|
|
1000
1049
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
1001
|
-
if (!sequenceProps)
|
|
1002
|
-
return SPACING2;
|
|
1050
|
+
if (!sequenceProps) return SPACING2;
|
|
1003
1051
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1004
1052
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1005
1053
|
};
|
|
@@ -1008,9 +1056,8 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1008
1056
|
if (isString(value) && (value.includes("calc") || value.includes("var"))) {
|
|
1009
1057
|
return { [propertyName]: value };
|
|
1010
1058
|
}
|
|
1011
|
-
const stack = (0,
|
|
1012
|
-
if (!isArray(stack))
|
|
1013
|
-
return;
|
|
1059
|
+
const stack = (0, import_utils11.arrayzeValue)(value);
|
|
1060
|
+
if (!isArray(stack)) return;
|
|
1014
1061
|
if (stack.length > 1) {
|
|
1015
1062
|
let suffix = "";
|
|
1016
1063
|
if (propertyName === "borderWidth") {
|
|
@@ -1059,15 +1106,11 @@ var setShadow = (value, key, suffix, prefers) => {
|
|
|
1059
1106
|
if (isString(value) && value.includes(",")) {
|
|
1060
1107
|
value = value.split(",").map((v) => {
|
|
1061
1108
|
v = v.trim();
|
|
1062
|
-
if (v.startsWith("--"))
|
|
1063
|
-
|
|
1064
|
-
if (
|
|
1065
|
-
return getColor(v);
|
|
1066
|
-
if (v.includes("px") || v.slice(-2) === "em")
|
|
1067
|
-
return v;
|
|
1109
|
+
if (v.startsWith("--")) return `var(${v})`;
|
|
1110
|
+
if (getColor(v).length > 2) return getColor(v);
|
|
1111
|
+
if (v.includes("px") || v.slice(-2) === "em") return v;
|
|
1068
1112
|
const arr = v.split(" ");
|
|
1069
|
-
if (!arr.length)
|
|
1070
|
-
return v;
|
|
1113
|
+
if (!arr.length) return v;
|
|
1071
1114
|
return arr.map((v2) => getSpacingByKey(v2, "shadow").shadow).join(" ");
|
|
1072
1115
|
}).join(" ");
|
|
1073
1116
|
}
|
|
@@ -1082,32 +1125,25 @@ var setShadow = (value, key, suffix, prefers) => {
|
|
|
1082
1125
|
};
|
|
1083
1126
|
var getShadow = (value, globalTheme) => {
|
|
1084
1127
|
const CONFIG2 = getActiveConfig();
|
|
1085
|
-
if (!globalTheme)
|
|
1086
|
-
globalTheme = CONFIG2.globalTheme;
|
|
1128
|
+
if (!globalTheme) globalTheme = CONFIG2.globalTheme;
|
|
1087
1129
|
if (!isString(value)) {
|
|
1088
|
-
if (CONFIG2.verbose)
|
|
1089
|
-
console.warn(value, "- type for color is not valid");
|
|
1130
|
+
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
1090
1131
|
return;
|
|
1091
1132
|
}
|
|
1092
|
-
if (value.slice(0, 2) === "--")
|
|
1093
|
-
return `var(${value})`;
|
|
1133
|
+
if (value.slice(0, 2) === "--") return `var(${value})`;
|
|
1094
1134
|
const [name] = isArray(value) ? value : value.split(" ");
|
|
1095
1135
|
const { SHADOW: SHADOW2 } = CONFIG2;
|
|
1096
1136
|
const val = SHADOW2[name];
|
|
1097
1137
|
const isObj = isObject(val);
|
|
1098
1138
|
if (!val) {
|
|
1099
|
-
if (CONFIG2.verbose)
|
|
1100
|
-
console.warn("Can't find color ", name);
|
|
1139
|
+
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
1101
1140
|
return value;
|
|
1102
1141
|
}
|
|
1103
1142
|
if (globalTheme) {
|
|
1104
|
-
if (val[globalTheme])
|
|
1105
|
-
|
|
1106
|
-
else if (CONFIG2.verbose)
|
|
1107
|
-
console.warn(value, " - does not have ", globalTheme);
|
|
1143
|
+
if (val[globalTheme]) return val[globalTheme].value;
|
|
1144
|
+
else if (CONFIG2.verbose) console.warn(value, " - does not have ", globalTheme);
|
|
1108
1145
|
}
|
|
1109
|
-
if (isObj && val.value)
|
|
1110
|
-
return val.value;
|
|
1146
|
+
if (isObj && val.value) return val.value;
|
|
1111
1147
|
if (isObj) {
|
|
1112
1148
|
const obj = {};
|
|
1113
1149
|
for (const mediaName in val) {
|
|
@@ -1117,7 +1153,6 @@ var getShadow = (value, globalTheme) => {
|
|
|
1117
1153
|
}
|
|
1118
1154
|
return obj;
|
|
1119
1155
|
}
|
|
1120
|
-
if (CONFIG2.verbose)
|
|
1121
|
-
console.warn("Can't find color", value);
|
|
1156
|
+
if (CONFIG2.verbose) console.warn("Can't find color", value);
|
|
1122
1157
|
return value;
|
|
1123
1158
|
};
|