@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
|
@@ -34,25 +34,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
var require_cjs = __commonJS({
|
|
35
35
|
"../utils/dist/cjs/index.js"(exports, module2) {
|
|
36
36
|
"use strict";
|
|
37
|
-
var
|
|
37
|
+
var __defProp2 = Object.defineProperty;
|
|
38
38
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
39
39
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
40
|
-
var
|
|
40
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
41
41
|
var __export2 = (target, all) => {
|
|
42
42
|
for (var name in all)
|
|
43
|
-
|
|
43
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
44
44
|
};
|
|
45
45
|
var __copyProps2 = (to, from, except, desc) => {
|
|
46
46
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
47
47
|
for (let key of __getOwnPropNames2(from))
|
|
48
|
-
if (!
|
|
49
|
-
|
|
48
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
49
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
50
50
|
}
|
|
51
51
|
return to;
|
|
52
52
|
};
|
|
53
|
-
var __toCommonJS2 = (mod) => __copyProps2(
|
|
54
|
-
var
|
|
55
|
-
__export2(
|
|
53
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
54
|
+
var index_exports = {};
|
|
55
|
+
__export2(index_exports, {
|
|
56
56
|
arrayzeValue: () => arrayzeValue2,
|
|
57
57
|
copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
|
|
58
58
|
copyStringToClipboard: () => copyStringToClipboard,
|
|
@@ -73,17 +73,85 @@ 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";
|
|
85
84
|
var isNumber2 = (arg) => typeof arg === "number";
|
|
86
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
|
+
];
|
|
87
155
|
var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
88
156
|
async function toggleFullscreen(opts) {
|
|
89
157
|
if (!document.fullscreenElement) {
|
|
@@ -103,13 +171,11 @@ var require_cjs = __commonJS({
|
|
|
103
171
|
};
|
|
104
172
|
var findClosestNumberInFactory = (val, factory) => {
|
|
105
173
|
val = parseFloat(val);
|
|
106
|
-
if (isObject2(factory))
|
|
107
|
-
factory = Object.values(factory);
|
|
174
|
+
if (isObject2(factory)) factory = Object.values(factory);
|
|
108
175
|
return findClosestNumber(val, factory);
|
|
109
176
|
};
|
|
110
177
|
var formatDate = (timestamp) => {
|
|
111
|
-
if (!timestamp)
|
|
112
|
-
return "";
|
|
178
|
+
if (!timestamp) return "";
|
|
113
179
|
const d = new Date(timestamp);
|
|
114
180
|
const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
|
|
115
181
|
const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
|
|
@@ -176,8 +242,7 @@ var require_cjs = __commonJS({
|
|
|
176
242
|
scriptEle.type = type;
|
|
177
243
|
scriptEle.text = xhr.responseText;
|
|
178
244
|
doc.body.appendChild(scriptEle);
|
|
179
|
-
if (typeof fallback === "function")
|
|
180
|
-
fallback();
|
|
245
|
+
if (typeof fallback === "function") fallback();
|
|
181
246
|
} else {
|
|
182
247
|
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
183
248
|
}
|
|
@@ -245,60 +310,19 @@ var require_cjs = __commonJS({
|
|
|
245
310
|
);
|
|
246
311
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
247
312
|
var toDescriptionCase = (str = "") => {
|
|
248
|
-
if (typeof str !== "string")
|
|
249
|
-
return;
|
|
313
|
+
if (typeof str !== "string") return;
|
|
250
314
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
251
315
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
252
316
|
};
|
|
253
317
|
var arrayzeValue2 = (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];
|
|
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];
|
|
262
322
|
};
|
|
263
323
|
}
|
|
264
324
|
});
|
|
265
325
|
|
|
266
|
-
// ../../node_modules/@domql/globals/dist/cjs/index.js
|
|
267
|
-
var require_cjs2 = __commonJS({
|
|
268
|
-
"../../node_modules/@domql/globals/dist/cjs/index.js"(exports, module2) {
|
|
269
|
-
"use strict";
|
|
270
|
-
var __defProp3 = Object.defineProperty;
|
|
271
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
272
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
273
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
274
|
-
var __export2 = (target, all) => {
|
|
275
|
-
for (var name in all)
|
|
276
|
-
__defProp3(target, name, { get: all[name], enumerable: true });
|
|
277
|
-
};
|
|
278
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
279
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
280
|
-
for (let key of __getOwnPropNames2(from))
|
|
281
|
-
if (!__hasOwnProp3.call(to, key) && key !== except)
|
|
282
|
-
__defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
283
|
-
}
|
|
284
|
-
return to;
|
|
285
|
-
};
|
|
286
|
-
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
287
|
-
var globals_exports = {};
|
|
288
|
-
__export2(globals_exports, {
|
|
289
|
-
document: () => document4,
|
|
290
|
-
global: () => global,
|
|
291
|
-
self: () => self,
|
|
292
|
-
window: () => window4
|
|
293
|
-
});
|
|
294
|
-
module2.exports = __toCommonJS2(globals_exports);
|
|
295
|
-
var global = globalThis;
|
|
296
|
-
var self = globalThis;
|
|
297
|
-
var window4 = globalThis;
|
|
298
|
-
var document4 = window4.document;
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
326
|
// src/system/spacing.js
|
|
303
327
|
var spacing_exports = {};
|
|
304
328
|
__export(spacing_exports, {
|
|
@@ -307,61 +331,116 @@ __export(spacing_exports, {
|
|
|
307
331
|
getSpacingByKey: () => getSpacingByKey
|
|
308
332
|
});
|
|
309
333
|
module.exports = __toCommonJS(spacing_exports);
|
|
310
|
-
var
|
|
334
|
+
var import_utils9 = __toESM(require_cjs(), 1);
|
|
311
335
|
|
|
312
|
-
// ../../node_modules/@domql/utils/
|
|
336
|
+
// ../../node_modules/@domql/utils/globals.js
|
|
313
337
|
var window2 = globalThis;
|
|
314
338
|
var document2 = window2.document;
|
|
315
339
|
|
|
316
|
-
// ../../node_modules/@domql/utils/
|
|
340
|
+
// ../../node_modules/@domql/utils/node.js
|
|
317
341
|
var isDOMNode = (obj) => {
|
|
318
342
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
319
343
|
};
|
|
320
344
|
|
|
321
|
-
// ../../node_modules/@domql/utils/
|
|
345
|
+
// ../../node_modules/@domql/utils/types.js
|
|
322
346
|
var isString = (arg) => typeof arg === "string";
|
|
323
347
|
var isFunction = (arg) => typeof arg === "function";
|
|
324
348
|
var isNull = (arg) => arg === null;
|
|
325
349
|
var isArray = (arg) => Array.isArray(arg);
|
|
326
350
|
var isObjectLike = (arg) => {
|
|
327
|
-
if (arg === null)
|
|
328
|
-
return false;
|
|
351
|
+
if (arg === null) return false;
|
|
329
352
|
return typeof arg === "object";
|
|
330
353
|
};
|
|
331
354
|
var isUndefined = (arg) => {
|
|
332
355
|
return arg === void 0;
|
|
333
356
|
};
|
|
334
357
|
|
|
335
|
-
// ../../node_modules/@domql/utils/
|
|
336
|
-
var
|
|
337
|
-
return arr.reduce(
|
|
358
|
+
// ../../node_modules/@domql/utils/array.js
|
|
359
|
+
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
360
|
+
return arr.reduce(
|
|
361
|
+
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
362
|
+
{}
|
|
363
|
+
);
|
|
338
364
|
};
|
|
339
365
|
|
|
340
|
-
// ../../node_modules/@domql/utils/
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
366
|
+
// ../../node_modules/@domql/utils/keys.js
|
|
367
|
+
var STATE_METHODS = [
|
|
368
|
+
"update",
|
|
369
|
+
"parse",
|
|
370
|
+
"clean",
|
|
371
|
+
"create",
|
|
372
|
+
"destroy",
|
|
373
|
+
"add",
|
|
374
|
+
"toggle",
|
|
375
|
+
"remove",
|
|
376
|
+
"apply",
|
|
377
|
+
"set",
|
|
378
|
+
"reset",
|
|
379
|
+
"replace",
|
|
380
|
+
"quietReplace",
|
|
381
|
+
"quietUpdate",
|
|
382
|
+
"applyReplace",
|
|
383
|
+
"applyFunction",
|
|
384
|
+
"keys",
|
|
385
|
+
"values",
|
|
386
|
+
"ref",
|
|
387
|
+
"rootUpdate",
|
|
388
|
+
"parentUpdate",
|
|
389
|
+
"parent",
|
|
390
|
+
"__element",
|
|
391
|
+
"__depends",
|
|
392
|
+
"__ref",
|
|
393
|
+
"__children",
|
|
394
|
+
"root",
|
|
395
|
+
"setByPath",
|
|
396
|
+
"setPathCollection",
|
|
397
|
+
"removeByPath",
|
|
398
|
+
"removePathCollection",
|
|
399
|
+
"getByPath"
|
|
400
|
+
];
|
|
401
|
+
var PROPS_METHODS = ["update", "__element"];
|
|
402
|
+
var METHODS = [
|
|
403
|
+
"set",
|
|
404
|
+
"reset",
|
|
405
|
+
"update",
|
|
406
|
+
"remove",
|
|
407
|
+
"updateContent",
|
|
408
|
+
"removeContent",
|
|
409
|
+
"lookup",
|
|
410
|
+
"lookdown",
|
|
411
|
+
"lookdownAll",
|
|
412
|
+
"getRef",
|
|
413
|
+
"getPath",
|
|
414
|
+
"setNodeStyles",
|
|
415
|
+
"spotByPath",
|
|
416
|
+
"keys",
|
|
417
|
+
"parse",
|
|
418
|
+
"setProps",
|
|
419
|
+
"parseDeep",
|
|
420
|
+
"variables",
|
|
421
|
+
"if",
|
|
422
|
+
"log",
|
|
423
|
+
"verbose",
|
|
424
|
+
"warn",
|
|
425
|
+
"error",
|
|
426
|
+
"call",
|
|
427
|
+
"nextElement",
|
|
428
|
+
"previousElement"
|
|
429
|
+
];
|
|
430
|
+
var METHODS_EXL = [
|
|
431
|
+
...["node", "context", "extends", "__element", "__ref"],
|
|
432
|
+
...METHODS,
|
|
433
|
+
...STATE_METHODS,
|
|
434
|
+
...PROPS_METHODS
|
|
435
|
+
];
|
|
436
|
+
|
|
437
|
+
// ../../node_modules/@domql/utils/object.js
|
|
360
438
|
var merge = (element, obj, excludeFrom = []) => {
|
|
361
439
|
for (const e in obj) {
|
|
362
|
-
const
|
|
363
|
-
if (!
|
|
440
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e);
|
|
441
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
364
442
|
continue;
|
|
443
|
+
}
|
|
365
444
|
const elementProp = element[e];
|
|
366
445
|
const objProp = obj[e];
|
|
367
446
|
if (elementProp === void 0) {
|
|
@@ -370,11 +449,12 @@ var merge = (element, obj, excludeFrom = []) => {
|
|
|
370
449
|
}
|
|
371
450
|
return element;
|
|
372
451
|
};
|
|
373
|
-
var deepMerge = (element, extend, excludeFrom =
|
|
452
|
+
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
374
453
|
for (const e in extend) {
|
|
375
|
-
const
|
|
376
|
-
if (!
|
|
454
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
455
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
377
456
|
continue;
|
|
457
|
+
}
|
|
378
458
|
const elementProp = element[e];
|
|
379
459
|
const extendProp = extend[e];
|
|
380
460
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -392,7 +472,7 @@ var deepClone = (obj, options = {}) => {
|
|
|
392
472
|
cleanNull = false,
|
|
393
473
|
window: targetWindow,
|
|
394
474
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
395
|
-
|
|
475
|
+
handleExtends = false
|
|
396
476
|
} = options;
|
|
397
477
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
398
478
|
return obj;
|
|
@@ -400,40 +480,42 @@ var deepClone = (obj, options = {}) => {
|
|
|
400
480
|
if (visited.has(obj)) {
|
|
401
481
|
return visited.get(obj);
|
|
402
482
|
}
|
|
403
|
-
const
|
|
404
|
-
visited.set(obj,
|
|
483
|
+
const clone = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
|
|
484
|
+
visited.set(obj, clone);
|
|
405
485
|
for (const key in obj) {
|
|
406
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
407
|
-
|
|
408
|
-
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
|
|
486
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
487
|
+
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
409
488
|
continue;
|
|
489
|
+
}
|
|
410
490
|
const value = obj[key];
|
|
411
|
-
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
|
|
491
|
+
if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
|
|
412
492
|
continue;
|
|
493
|
+
}
|
|
413
494
|
if (isDOMNode(value)) {
|
|
414
|
-
|
|
495
|
+
clone[key] = value;
|
|
415
496
|
continue;
|
|
416
497
|
}
|
|
417
|
-
if (
|
|
418
|
-
|
|
498
|
+
if (handleExtends && key === "extends" && isArray(value)) {
|
|
499
|
+
clone[key] = unstackArrayOfObjects(value, exclude);
|
|
419
500
|
continue;
|
|
420
501
|
}
|
|
421
502
|
if (isFunction(value) && targetWindow) {
|
|
422
|
-
|
|
503
|
+
clone[key] = targetWindow.eval("(" + value.toString() + ")");
|
|
423
504
|
continue;
|
|
424
505
|
}
|
|
425
506
|
if (isObjectLike(value)) {
|
|
426
|
-
|
|
507
|
+
clone[key] = deepClone(value, {
|
|
508
|
+
...options,
|
|
427
509
|
visited
|
|
428
|
-
})
|
|
510
|
+
});
|
|
429
511
|
} else {
|
|
430
|
-
|
|
512
|
+
clone[key] = value;
|
|
431
513
|
}
|
|
432
514
|
}
|
|
433
|
-
return
|
|
515
|
+
return clone;
|
|
434
516
|
};
|
|
435
517
|
|
|
436
|
-
// ../../node_modules/@domql/utils/
|
|
518
|
+
// ../../node_modules/@domql/utils/cookie.js
|
|
437
519
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
438
520
|
|
|
439
521
|
// src/defaultConfig/index.js
|
|
@@ -662,11 +744,8 @@ var isScalingUnit = (unit) => {
|
|
|
662
744
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
663
745
|
};
|
|
664
746
|
|
|
665
|
-
// src/utils/color.js
|
|
666
|
-
var import_globals4 = __toESM(require_cjs2(), 1);
|
|
667
|
-
|
|
668
747
|
// src/utils/sequence.js
|
|
669
|
-
var
|
|
748
|
+
var import_utils6 = __toESM(require_cjs(), 1);
|
|
670
749
|
var numToLetterMap = {
|
|
671
750
|
"-6": "U",
|
|
672
751
|
"-5": "V",
|
|
@@ -712,8 +791,7 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
712
791
|
var setScalingVar = (key, sequenceProps) => {
|
|
713
792
|
const { base, type, unit } = sequenceProps;
|
|
714
793
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
715
|
-
if (key === 0)
|
|
716
|
-
return defaultVal;
|
|
794
|
+
if (key === 0) return defaultVal;
|
|
717
795
|
const prefix = "--" + (type && type.replace(".", "-"));
|
|
718
796
|
const ratioVar = `${prefix}-ratio`;
|
|
719
797
|
if (key > 0) {
|
|
@@ -750,10 +828,8 @@ var generateSubSequence = (props, sequenceProps) => {
|
|
|
750
828
|
const diffRounded = ~~next - ~~value;
|
|
751
829
|
let arr;
|
|
752
830
|
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
753
|
-
if (diffRounded > 16)
|
|
754
|
-
|
|
755
|
-
else
|
|
756
|
-
arr = [first, second];
|
|
831
|
+
if (diffRounded > 16) arr = [first, middle, second];
|
|
832
|
+
else arr = [first, second];
|
|
757
833
|
arr.forEach((v, k) => {
|
|
758
834
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
759
835
|
const newVar = variable + (k + 1);
|
|
@@ -795,8 +871,7 @@ var generateSequence = (sequenceProps) => {
|
|
|
795
871
|
index: key
|
|
796
872
|
};
|
|
797
873
|
setSequenceValue(props, sequenceProps);
|
|
798
|
-
if (subSequence)
|
|
799
|
-
generateSubSequence(props, sequenceProps);
|
|
874
|
+
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
800
875
|
}
|
|
801
876
|
return sequenceProps;
|
|
802
877
|
};
|
|
@@ -808,13 +883,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
808
883
|
unit = UNIT2.default,
|
|
809
884
|
useVariable
|
|
810
885
|
} = sequenceProps;
|
|
811
|
-
if (isString(value) && value.slice(0, 2) === "--")
|
|
812
|
-
|
|
813
|
-
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
886
|
+
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
887
|
+
const prefix = `--${(0, import_utils6.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
814
888
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
815
889
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
816
|
-
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)
|
|
817
|
-
return value;
|
|
890
|
+
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;
|
|
818
891
|
const letterVal = value.toUpperCase();
|
|
819
892
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
820
893
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -838,8 +911,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
838
911
|
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
839
912
|
}
|
|
840
913
|
if (!sequence[absValue] && absValue.length === 2) {
|
|
841
|
-
if (CONFIG2.verbose)
|
|
842
|
-
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
914
|
+
if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
843
915
|
absValue = absValue.slice(0, 1);
|
|
844
916
|
}
|
|
845
917
|
if (useVariable || CONFIG2.useVariable) {
|
|
@@ -847,8 +919,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
847
919
|
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
848
920
|
}
|
|
849
921
|
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
850
|
-
if (!sequenceItem)
|
|
851
|
-
return console.warn("can't find", sequence, absValue);
|
|
922
|
+
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
852
923
|
if (unit === "ms" || unit === "s") {
|
|
853
924
|
return isNegative + sequenceItem.val + unit;
|
|
854
925
|
}
|
|
@@ -857,12 +928,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
857
928
|
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
858
929
|
if (typeof value !== "string") {
|
|
859
930
|
const CONFIG2 = getActiveConfig();
|
|
860
|
-
if (CONFIG2.verbose)
|
|
861
|
-
console.warn(propertyName, value, "is not a string");
|
|
931
|
+
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
862
932
|
return { [propertyName]: value };
|
|
863
933
|
}
|
|
864
|
-
if (value === "-" || value === "")
|
|
865
|
-
return {};
|
|
934
|
+
if (value === "-" || value === "") return {};
|
|
866
935
|
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
867
936
|
};
|
|
868
937
|
|
|
@@ -914,23 +983,19 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
|
914
983
|
const { mediaRegenerate } = FACTORY2;
|
|
915
984
|
const { sequence, scales } = FACTORY2[media];
|
|
916
985
|
const query = MEDIA2[mediaName];
|
|
917
|
-
if (!query && CONFIG2.verbose)
|
|
918
|
-
console.warn("Can't find media query ", query);
|
|
986
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
|
|
919
987
|
if (!mediaRegenerate) {
|
|
920
988
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
921
|
-
if (!underMediaQuery)
|
|
922
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
989
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
923
990
|
applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
924
991
|
return;
|
|
925
992
|
}
|
|
926
993
|
for (const key in sequence) {
|
|
927
994
|
const item = sequence[key];
|
|
928
995
|
const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
|
|
929
|
-
if (!query && CONFIG2.verbose)
|
|
930
|
-
console.warn("Can't find query ", query);
|
|
996
|
+
if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
|
|
931
997
|
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
932
|
-
if (!underMediaQuery)
|
|
933
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
998
|
+
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
934
999
|
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
935
1000
|
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
936
1001
|
}
|
|
@@ -941,8 +1006,7 @@ var runThroughMedia = (FACTORY2) => {
|
|
|
941
1006
|
for (const prop in FACTORY2) {
|
|
942
1007
|
const mediaProps = FACTORY2[prop];
|
|
943
1008
|
const isMediaName = prop.slice(0, 1) === "@";
|
|
944
|
-
if (!isMediaName)
|
|
945
|
-
continue;
|
|
1009
|
+
if (!isMediaName) continue;
|
|
946
1010
|
const {
|
|
947
1011
|
type,
|
|
948
1012
|
base,
|
|
@@ -979,8 +1043,7 @@ var applySpacingSequence = () => {
|
|
|
979
1043
|
var getSequence = (sequenceProps) => {
|
|
980
1044
|
const CONFIG2 = getActiveConfig();
|
|
981
1045
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
982
|
-
if (!sequenceProps)
|
|
983
|
-
return SPACING2;
|
|
1046
|
+
if (!sequenceProps) return SPACING2;
|
|
984
1047
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
985
1048
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
986
1049
|
};
|
|
@@ -989,9 +1052,8 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
989
1052
|
if (isString(value) && (value.includes("calc") || value.includes("var"))) {
|
|
990
1053
|
return { [propertyName]: value };
|
|
991
1054
|
}
|
|
992
|
-
const stack = (0,
|
|
993
|
-
if (!isArray(stack))
|
|
994
|
-
return;
|
|
1055
|
+
const stack = (0, import_utils9.arrayzeValue)(value);
|
|
1056
|
+
if (!isArray(stack)) return;
|
|
995
1057
|
if (stack.length > 1) {
|
|
996
1058
|
let suffix = "";
|
|
997
1059
|
if (propertyName === "borderWidth") {
|