@symbo.ls/scratch 3.1.1 → 3.2.3
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 +40 -20
- package/dist/cjs/index.js +131 -72
- package/dist/cjs/set.js +127 -58
- package/dist/cjs/system/color.js +121 -41
- package/dist/cjs/system/document.js +120 -38
- package/dist/cjs/system/font.js +118 -36
- package/dist/cjs/system/index.js +128 -63
- package/dist/cjs/system/reset.js +120 -38
- package/dist/cjs/system/shadow.js +121 -41
- package/dist/cjs/system/spacing.js +120 -38
- package/dist/cjs/system/svg.js +119 -39
- package/dist/cjs/system/theme.js +121 -41
- package/dist/cjs/system/timing.js +118 -36
- package/dist/cjs/system/typography.js +124 -55
- package/dist/cjs/transforms/index.js +123 -43
- package/dist/cjs/utils/color.js +16 -18
- package/dist/cjs/utils/index.js +125 -53
- package/dist/cjs/utils/sequence.js +110 -36
- package/dist/cjs/utils/sprite.js +49 -23
- package/dist/cjs/utils/var.js +110 -36
- package/package.json +7 -7
- package/src/system/typography.js +12 -20
- package/src/utils/color.js +42 -31
- package/src/utils/sprite.js +12 -8
package/dist/cjs/utils/sprite.js
CHANGED
|
@@ -25,16 +25,16 @@ __export(sprite_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(sprite_exports);
|
|
27
27
|
|
|
28
|
-
// ../../../domql/packages/utils/globals.js
|
|
28
|
+
// ../../../domql/packages/utils/dist/esm/globals.js
|
|
29
29
|
var window2 = globalThis;
|
|
30
30
|
var document2 = window2.document;
|
|
31
31
|
|
|
32
|
-
// ../../../domql/packages/utils/node.js
|
|
32
|
+
// ../../../domql/packages/utils/dist/esm/node.js
|
|
33
33
|
var isDOMNode = (obj) => {
|
|
34
34
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
// ../../../domql/packages/utils/types.js
|
|
37
|
+
// ../../../domql/packages/utils/dist/esm/types.js
|
|
38
38
|
var isString = (arg) => typeof arg === "string";
|
|
39
39
|
var isFunction = (arg) => typeof arg === "function";
|
|
40
40
|
var isNull = (arg) => arg === null;
|
|
@@ -47,7 +47,7 @@ var isUndefined = (arg) => {
|
|
|
47
47
|
return arg === void 0;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
// ../../../domql/packages/utils/array.js
|
|
50
|
+
// ../../../domql/packages/utils/dist/esm/array.js
|
|
51
51
|
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
52
52
|
return arr.reduce(
|
|
53
53
|
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
@@ -55,7 +55,7 @@ var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
|
55
55
|
);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
// ../../../domql/packages/utils/keys.js
|
|
58
|
+
// ../../../domql/packages/utils/dist/esm/keys.js
|
|
59
59
|
var STATE_METHODS = [
|
|
60
60
|
"update",
|
|
61
61
|
"parse",
|
|
@@ -126,11 +126,30 @@ var METHODS_EXL = [
|
|
|
126
126
|
...PROPS_METHODS
|
|
127
127
|
];
|
|
128
128
|
|
|
129
|
-
// ../../../domql/packages/utils/object.js
|
|
129
|
+
// ../../../domql/packages/utils/dist/esm/object.js
|
|
130
|
+
var __defProp2 = Object.defineProperty;
|
|
131
|
+
var __defProps = Object.defineProperties;
|
|
132
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
133
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
134
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
135
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
136
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
137
|
+
var __spreadValues = (a, b) => {
|
|
138
|
+
for (var prop in b || (b = {}))
|
|
139
|
+
if (__hasOwnProp2.call(b, prop))
|
|
140
|
+
__defNormalProp(a, prop, b[prop]);
|
|
141
|
+
if (__getOwnPropSymbols)
|
|
142
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
143
|
+
if (__propIsEnum.call(b, prop))
|
|
144
|
+
__defNormalProp(a, prop, b[prop]);
|
|
145
|
+
}
|
|
146
|
+
return a;
|
|
147
|
+
};
|
|
148
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
130
149
|
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
131
150
|
for (const e in extend) {
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
151
|
+
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
152
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
134
153
|
continue;
|
|
135
154
|
}
|
|
136
155
|
const elementProp = element[e];
|
|
@@ -152,14 +171,15 @@ var deepClone = (obj, options = {}) => {
|
|
|
152
171
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
153
172
|
handleExtends = false
|
|
154
173
|
} = options;
|
|
174
|
+
const contentWindow = targetWindow || window2 || globalThis;
|
|
155
175
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
156
176
|
return obj;
|
|
157
177
|
}
|
|
158
178
|
if (visited.has(obj)) {
|
|
159
179
|
return visited.get(obj);
|
|
160
180
|
}
|
|
161
|
-
const
|
|
162
|
-
visited.set(obj,
|
|
181
|
+
const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
|
|
182
|
+
visited.set(obj, clone2);
|
|
163
183
|
for (const key in obj) {
|
|
164
184
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
165
185
|
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
@@ -170,30 +190,34 @@ var deepClone = (obj, options = {}) => {
|
|
|
170
190
|
continue;
|
|
171
191
|
}
|
|
172
192
|
if (isDOMNode(value)) {
|
|
173
|
-
|
|
193
|
+
clone2[key] = value;
|
|
174
194
|
continue;
|
|
175
195
|
}
|
|
176
196
|
if (handleExtends && key === "extends" && isArray(value)) {
|
|
177
|
-
|
|
197
|
+
clone2[key] = unstackArrayOfObjects(value, exclude);
|
|
178
198
|
continue;
|
|
179
199
|
}
|
|
180
|
-
if (isFunction(value) &&
|
|
181
|
-
|
|
200
|
+
if (isFunction(value) && options.window) {
|
|
201
|
+
clone2[key] = contentWindow.eval("(" + value.toString() + ")");
|
|
182
202
|
continue;
|
|
183
203
|
}
|
|
184
204
|
if (isObjectLike(value)) {
|
|
185
|
-
|
|
186
|
-
...options,
|
|
205
|
+
clone2[key] = deepClone(value, __spreadProps(__spreadValues({}, options), {
|
|
187
206
|
visited
|
|
188
|
-
});
|
|
207
|
+
}));
|
|
189
208
|
} else {
|
|
190
|
-
|
|
209
|
+
clone2[key] = value;
|
|
191
210
|
}
|
|
192
211
|
}
|
|
193
|
-
return
|
|
212
|
+
return clone2;
|
|
194
213
|
};
|
|
195
214
|
|
|
196
|
-
// ../../../domql/packages/utils/
|
|
215
|
+
// ../../../domql/packages/utils/dist/esm/env.js
|
|
216
|
+
var NODE_ENV = "development";
|
|
217
|
+
var isProduction = (env = NODE_ENV) => env === "production";
|
|
218
|
+
var isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
219
|
+
|
|
220
|
+
// ../../../domql/packages/utils/dist/esm/cookie.js
|
|
197
221
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
198
222
|
|
|
199
223
|
// ../../../domql/packages/event/dist/esm/keys.js
|
|
@@ -493,8 +517,7 @@ var getActiveConfig = (def) => {
|
|
|
493
517
|
};
|
|
494
518
|
|
|
495
519
|
// src/utils/sprite.js
|
|
496
|
-
var
|
|
497
|
-
var isDev = ENV === "development" || ENV === "testing";
|
|
520
|
+
var isDev = isNotProduction();
|
|
498
521
|
var generateSprite = (icons) => {
|
|
499
522
|
const CONFIG2 = getActiveConfig();
|
|
500
523
|
let sprite = "";
|
|
@@ -516,7 +539,9 @@ var parseRootAttributes = (htmlString) => {
|
|
|
516
539
|
return {};
|
|
517
540
|
}
|
|
518
541
|
const attrString = match[1];
|
|
519
|
-
const attrs = attrString.match(
|
|
542
|
+
const attrs = attrString.match(
|
|
543
|
+
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
544
|
+
);
|
|
520
545
|
return attrs.reduce((acc, attr) => {
|
|
521
546
|
const [key, value] = attr.split("=");
|
|
522
547
|
acc[key] = value.replace(/['"]/g, "");
|
|
@@ -551,3 +576,4 @@ var convertSvgToSymbol = (key, code) => {
|
|
|
551
576
|
symbol = symbol.replace("</svg", "</symbol");
|
|
552
577
|
return symbol;
|
|
553
578
|
};
|
|
579
|
+
// @preserve-env
|
package/dist/cjs/utils/var.js
CHANGED
|
@@ -34,23 +34,23 @@ 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 __defProp3 = Object.defineProperty;
|
|
38
38
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
39
39
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
40
|
-
var
|
|
40
|
+
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
41
41
|
var __export2 = (target, all) => {
|
|
42
42
|
for (var name in all)
|
|
43
|
-
|
|
43
|
+
__defProp3(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 (!__hasOwnProp3.call(to, key) && key !== except)
|
|
49
|
+
__defProp3(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(
|
|
53
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
|
|
54
54
|
var index_exports = {};
|
|
55
55
|
__export2(index_exports, {
|
|
56
56
|
arrayzeValue: () => arrayzeValue,
|
|
@@ -66,6 +66,8 @@ var require_cjs = __commonJS({
|
|
|
66
66
|
loadJavascriptFile: () => loadJavascriptFile,
|
|
67
67
|
loadJavascriptFileEmbedSync: () => loadJavascriptFileEmbedSync,
|
|
68
68
|
loadJavascriptFileSync: () => loadJavascriptFileSync,
|
|
69
|
+
loadRemoteCSS: () => loadRemoteCSS,
|
|
70
|
+
loadRemoteScript: () => loadRemoteScript,
|
|
69
71
|
removeChars: () => removeChars,
|
|
70
72
|
toCamelCase: () => toCamelCase,
|
|
71
73
|
toDashCase: () => toDashCase2,
|
|
@@ -273,10 +275,12 @@ var require_cjs = __commonJS({
|
|
|
273
275
|
});
|
|
274
276
|
});
|
|
275
277
|
scriptEle.addEventListener("error", (ev) => {
|
|
276
|
-
reject(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
reject(
|
|
279
|
+
new Error({
|
|
280
|
+
status: false,
|
|
281
|
+
message: `Failed to load the script ${FILE_URL}`
|
|
282
|
+
})
|
|
283
|
+
);
|
|
280
284
|
});
|
|
281
285
|
doc.body.appendChild(scriptEle);
|
|
282
286
|
} catch (error) {
|
|
@@ -347,6 +351,59 @@ var require_cjs = __commonJS({
|
|
|
347
351
|
console.warn(error);
|
|
348
352
|
}
|
|
349
353
|
};
|
|
354
|
+
function loadRemoteScript(url, options = {}) {
|
|
355
|
+
const { window: window4 = globalThis } = options;
|
|
356
|
+
const { document: document4 = window4.document } = options;
|
|
357
|
+
return new Promise((resolve, reject) => {
|
|
358
|
+
const existingScript = document4.querySelector(`script[src="${url}"]`);
|
|
359
|
+
if (existingScript) {
|
|
360
|
+
return resolve(existingScript);
|
|
361
|
+
}
|
|
362
|
+
const script = document4.createElement("script");
|
|
363
|
+
script.src = url;
|
|
364
|
+
script.async = options.async === true;
|
|
365
|
+
script.type = options.type || "text/javascript";
|
|
366
|
+
if (options.id) script.id = options.id;
|
|
367
|
+
if (options.integrity) script.integrity = options.integrity;
|
|
368
|
+
if (options.crossOrigin) script.crossOrigin = options.crossOrigin;
|
|
369
|
+
script.onload = () => {
|
|
370
|
+
script.onerror = script.onload = null;
|
|
371
|
+
resolve(script);
|
|
372
|
+
};
|
|
373
|
+
script.onerror = () => {
|
|
374
|
+
script.onerror = script.onload = null;
|
|
375
|
+
reject(new Error(`Failed to load script: ${url}`));
|
|
376
|
+
};
|
|
377
|
+
document4.head.appendChild(script);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
async function loadRemoteCSS(url, options = {}) {
|
|
381
|
+
const { window: window4 = globalThis } = options;
|
|
382
|
+
const { document: document4 = window4.document } = options;
|
|
383
|
+
return new Promise((resolve, reject) => {
|
|
384
|
+
const existingLink = document4.querySelector(`link[href="${url}"]`);
|
|
385
|
+
if (existingLink) {
|
|
386
|
+
return resolve(existingLink);
|
|
387
|
+
}
|
|
388
|
+
const link = document4.createElement("link");
|
|
389
|
+
link.href = url;
|
|
390
|
+
link.rel = options.rel || "stylesheet";
|
|
391
|
+
link.type = "text/css";
|
|
392
|
+
link.media = options.media || "all";
|
|
393
|
+
if (options.id) link.id = options.id;
|
|
394
|
+
if (options.integrity) link.integrity = options.integrity;
|
|
395
|
+
if (options.crossOrigin) link.crossOrigin = options.crossOrigin;
|
|
396
|
+
link.onload = () => {
|
|
397
|
+
link.onerror = link.onload = null;
|
|
398
|
+
resolve(link);
|
|
399
|
+
};
|
|
400
|
+
link.onerror = () => {
|
|
401
|
+
link.onerror = link.onload = null;
|
|
402
|
+
reject(new Error(`Failed to load stylesheet: ${url}`));
|
|
403
|
+
};
|
|
404
|
+
document4.head.appendChild(link);
|
|
405
|
+
});
|
|
406
|
+
}
|
|
350
407
|
var isPhoto = (format) => ["jpeg", "gif", "jpg", "png", "tiff", "woff"].includes(format);
|
|
351
408
|
var copyStringToClipboard = async (str) => {
|
|
352
409
|
try {
|
|
@@ -373,12 +430,9 @@ var require_cjs = __commonJS({
|
|
|
373
430
|
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
374
431
|
}).replaceAll(/\s+/g, "");
|
|
375
432
|
};
|
|
376
|
-
var toTitleCase = (str) => str && str.replace(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
380
|
-
}
|
|
381
|
-
);
|
|
433
|
+
var toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
|
|
434
|
+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
435
|
+
});
|
|
382
436
|
var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
383
437
|
var toDescriptionCase = (str = "") => {
|
|
384
438
|
if (typeof str !== "string") return;
|
|
@@ -404,16 +458,16 @@ __export(var_exports, {
|
|
|
404
458
|
});
|
|
405
459
|
module.exports = __toCommonJS(var_exports);
|
|
406
460
|
|
|
407
|
-
// ../../../domql/packages/utils/globals.js
|
|
461
|
+
// ../../../domql/packages/utils/dist/esm/globals.js
|
|
408
462
|
var window2 = globalThis;
|
|
409
463
|
var document2 = window2.document;
|
|
410
464
|
|
|
411
|
-
// ../../../domql/packages/utils/node.js
|
|
465
|
+
// ../../../domql/packages/utils/dist/esm/node.js
|
|
412
466
|
var isDOMNode = (obj) => {
|
|
413
467
|
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
414
468
|
};
|
|
415
469
|
|
|
416
|
-
// ../../../domql/packages/utils/types.js
|
|
470
|
+
// ../../../domql/packages/utils/dist/esm/types.js
|
|
417
471
|
var isFunction = (arg) => typeof arg === "function";
|
|
418
472
|
var isNull = (arg) => arg === null;
|
|
419
473
|
var isArray = (arg) => Array.isArray(arg);
|
|
@@ -425,7 +479,7 @@ var isUndefined = (arg) => {
|
|
|
425
479
|
return arg === void 0;
|
|
426
480
|
};
|
|
427
481
|
|
|
428
|
-
// ../../../domql/packages/utils/array.js
|
|
482
|
+
// ../../../domql/packages/utils/dist/esm/array.js
|
|
429
483
|
var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
430
484
|
return arr.reduce(
|
|
431
485
|
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
@@ -433,7 +487,7 @@ var unstackArrayOfObjects = (arr, exclude = []) => {
|
|
|
433
487
|
);
|
|
434
488
|
};
|
|
435
489
|
|
|
436
|
-
// ../../../domql/packages/utils/keys.js
|
|
490
|
+
// ../../../domql/packages/utils/dist/esm/keys.js
|
|
437
491
|
var STATE_METHODS = [
|
|
438
492
|
"update",
|
|
439
493
|
"parse",
|
|
@@ -504,11 +558,30 @@ var METHODS_EXL = [
|
|
|
504
558
|
...PROPS_METHODS
|
|
505
559
|
];
|
|
506
560
|
|
|
507
|
-
// ../../../domql/packages/utils/object.js
|
|
561
|
+
// ../../../domql/packages/utils/dist/esm/object.js
|
|
562
|
+
var __defProp2 = Object.defineProperty;
|
|
563
|
+
var __defProps = Object.defineProperties;
|
|
564
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
565
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
566
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
567
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
568
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
569
|
+
var __spreadValues = (a, b) => {
|
|
570
|
+
for (var prop in b || (b = {}))
|
|
571
|
+
if (__hasOwnProp2.call(b, prop))
|
|
572
|
+
__defNormalProp(a, prop, b[prop]);
|
|
573
|
+
if (__getOwnPropSymbols)
|
|
574
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
575
|
+
if (__propIsEnum.call(b, prop))
|
|
576
|
+
__defNormalProp(a, prop, b[prop]);
|
|
577
|
+
}
|
|
578
|
+
return a;
|
|
579
|
+
};
|
|
580
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
508
581
|
var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
509
582
|
for (const e in extend) {
|
|
510
|
-
const
|
|
511
|
-
if (!
|
|
583
|
+
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
584
|
+
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
|
|
512
585
|
continue;
|
|
513
586
|
}
|
|
514
587
|
const elementProp = element[e];
|
|
@@ -530,14 +603,15 @@ var deepClone = (obj, options = {}) => {
|
|
|
530
603
|
visited = /* @__PURE__ */ new WeakMap(),
|
|
531
604
|
handleExtends = false
|
|
532
605
|
} = options;
|
|
606
|
+
const contentWindow = targetWindow || window2 || globalThis;
|
|
533
607
|
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
534
608
|
return obj;
|
|
535
609
|
}
|
|
536
610
|
if (visited.has(obj)) {
|
|
537
611
|
return visited.get(obj);
|
|
538
612
|
}
|
|
539
|
-
const
|
|
540
|
-
visited.set(obj,
|
|
613
|
+
const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
|
|
614
|
+
visited.set(obj, clone2);
|
|
541
615
|
for (const key in obj) {
|
|
542
616
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
543
617
|
if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
|
|
@@ -548,30 +622,29 @@ var deepClone = (obj, options = {}) => {
|
|
|
548
622
|
continue;
|
|
549
623
|
}
|
|
550
624
|
if (isDOMNode(value)) {
|
|
551
|
-
|
|
625
|
+
clone2[key] = value;
|
|
552
626
|
continue;
|
|
553
627
|
}
|
|
554
628
|
if (handleExtends && key === "extends" && isArray(value)) {
|
|
555
|
-
|
|
629
|
+
clone2[key] = unstackArrayOfObjects(value, exclude);
|
|
556
630
|
continue;
|
|
557
631
|
}
|
|
558
|
-
if (isFunction(value) &&
|
|
559
|
-
|
|
632
|
+
if (isFunction(value) && options.window) {
|
|
633
|
+
clone2[key] = contentWindow.eval("(" + value.toString() + ")");
|
|
560
634
|
continue;
|
|
561
635
|
}
|
|
562
636
|
if (isObjectLike(value)) {
|
|
563
|
-
|
|
564
|
-
...options,
|
|
637
|
+
clone2[key] = deepClone(value, __spreadProps(__spreadValues({}, options), {
|
|
565
638
|
visited
|
|
566
|
-
});
|
|
639
|
+
}));
|
|
567
640
|
} else {
|
|
568
|
-
|
|
641
|
+
clone2[key] = value;
|
|
569
642
|
}
|
|
570
643
|
}
|
|
571
|
-
return
|
|
644
|
+
return clone2;
|
|
572
645
|
};
|
|
573
646
|
|
|
574
|
-
// ../../../domql/packages/utils/cookie.js
|
|
647
|
+
// ../../../domql/packages/utils/dist/esm/cookie.js
|
|
575
648
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
576
649
|
|
|
577
650
|
// ../../../domql/packages/event/dist/esm/keys.js
|
|
@@ -964,3 +1037,4 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
|
964
1037
|
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
965
1038
|
}
|
|
966
1039
|
};
|
|
1040
|
+
// @preserve-env
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.2.3",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"publishConfig": {},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
21
|
-
"build:esm": "npx esbuild ./src/*.js ./src/**/*.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
22
|
-
"build:cjs": "npx esbuild ./src/*.js ./src/**/*.js --target=node16 --format=cjs --outdir=dist/cjs --bundle",
|
|
23
|
-
"build:iife": "npx esbuild ./src/index.js --target=es2017 --format=iife --outdir=dist/iife --bundle --minify",
|
|
21
|
+
"build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild ./src/*.js ./src/**/*.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
22
|
+
"build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild ./src/*.js ./src/**/*.js --target=node16 --format=cjs --outdir=dist/cjs --bundle",
|
|
23
|
+
"build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild ./src/index.js --target=es2017 --format=iife --outdir=dist/iife --bundle --minify",
|
|
24
24
|
"build": "npm run build:cjs",
|
|
25
25
|
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@domql/utils": "^3.
|
|
29
|
-
"@symbo.ls/utils": "^3.
|
|
28
|
+
"@domql/utils": "^3.2.3",
|
|
29
|
+
"@symbo.ls/utils": "^3.2.3",
|
|
30
30
|
"color-contrast-checker": "^1.5.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681"
|
|
33
33
|
}
|
package/src/system/typography.js
CHANGED
|
@@ -23,15 +23,7 @@ export const runThroughMedia = FACTORY => {
|
|
|
23
23
|
const { mediaRegenerate } = FACTORY
|
|
24
24
|
const mediaName = prop.slice(1)
|
|
25
25
|
|
|
26
|
-
const {
|
|
27
|
-
type,
|
|
28
|
-
base,
|
|
29
|
-
ratio,
|
|
30
|
-
range,
|
|
31
|
-
subSequence,
|
|
32
|
-
h1Matches,
|
|
33
|
-
unit
|
|
34
|
-
} = FACTORY
|
|
26
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY
|
|
35
27
|
|
|
36
28
|
merge(mediaValue, {
|
|
37
29
|
type,
|
|
@@ -44,7 +36,8 @@ export const runThroughMedia = FACTORY => {
|
|
|
44
36
|
})
|
|
45
37
|
|
|
46
38
|
const query = MEDIA[mediaName]
|
|
47
|
-
const media =
|
|
39
|
+
const media =
|
|
40
|
+
'@media ' + (query === 'print' ? `${query}` : `screen and ${query}`)
|
|
48
41
|
TYPOGRAPHY.templates[media] = {
|
|
49
42
|
fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit
|
|
50
43
|
}
|
|
@@ -67,7 +60,7 @@ export const runThroughMedia = FACTORY => {
|
|
|
67
60
|
}
|
|
68
61
|
}
|
|
69
62
|
|
|
70
|
-
export const applyHeadings =
|
|
63
|
+
export const applyHeadings = props => {
|
|
71
64
|
const CONFIG = getActiveConfig()
|
|
72
65
|
if (props.h1Matches) {
|
|
73
66
|
const unit = props.unit
|
|
@@ -76,13 +69,16 @@ export const applyHeadings = (props) => {
|
|
|
76
69
|
for (const k in HEADINGS) {
|
|
77
70
|
const headerName = `h${parseInt(k) + 1}`
|
|
78
71
|
const headerStyle = templates[headerName]
|
|
79
|
-
if (!HEADINGS[k]) continue
|
|
80
72
|
templates[headerName] = {
|
|
81
|
-
fontSize: CONFIG.useVariable
|
|
73
|
+
fontSize: CONFIG.useVariable
|
|
74
|
+
? `var(${HEADINGS[k]?.variable})`
|
|
75
|
+
: `${HEADINGS[k]?.scaling}${unit}`,
|
|
82
76
|
margin: headerStyle ? headerStyle.margin : 0,
|
|
83
77
|
lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
|
|
84
|
-
letterSpacing: headerStyle
|
|
85
|
-
|
|
78
|
+
letterSpacing: headerStyle
|
|
79
|
+
? headerStyle.letterSpacing
|
|
80
|
+
: props.letterSpacing,
|
|
81
|
+
fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
}
|
|
@@ -101,9 +97,5 @@ export const applyTypographySequence = () => {
|
|
|
101
97
|
export const getFontSizeByKey = value => {
|
|
102
98
|
const CONFIG = getActiveConfig()
|
|
103
99
|
const { TYPOGRAPHY } = CONFIG
|
|
104
|
-
return getSequenceValuePropertyPair(
|
|
105
|
-
value,
|
|
106
|
-
'fontSize',
|
|
107
|
-
TYPOGRAPHY
|
|
108
|
-
)
|
|
100
|
+
return getSequenceValuePropertyPair(value, 'fontSize', TYPOGRAPHY)
|
|
109
101
|
}
|
package/src/utils/color.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
document,
|
|
5
|
+
window,
|
|
6
|
+
isString,
|
|
7
|
+
isNumber,
|
|
8
|
+
isNotProduction
|
|
9
|
+
} from '@domql/utils'
|
|
5
10
|
|
|
6
11
|
export const colorStringToRgbaArray = color => {
|
|
7
12
|
if (color === '') return [0, 0, 0, 0]
|
|
@@ -10,11 +15,22 @@ export const colorStringToRgbaArray = color => {
|
|
|
10
15
|
// convert #RGB and #RGBA to #RRGGBB and #RRGGBBAA
|
|
11
16
|
if (color[0] === '#') {
|
|
12
17
|
if (color.length < 7) {
|
|
13
|
-
color =
|
|
14
|
-
|
|
18
|
+
color =
|
|
19
|
+
'#' +
|
|
20
|
+
color[1] +
|
|
21
|
+
color[1] +
|
|
22
|
+
color[2] +
|
|
23
|
+
color[2] +
|
|
24
|
+
color[3] +
|
|
25
|
+
color[3] +
|
|
26
|
+
(color.length > 4 ? color[4] + color[4] : '')
|
|
27
|
+
}
|
|
28
|
+
return [
|
|
29
|
+
parseInt(color.substr(1, 2), 16),
|
|
15
30
|
parseInt(color.substr(3, 2), 16),
|
|
16
31
|
parseInt(color.substr(5, 2), 16),
|
|
17
|
-
color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
|
|
32
|
+
color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
|
|
33
|
+
]
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
// convert named colors
|
|
@@ -81,11 +97,7 @@ export const hexToRgba = (hex, alpha = 1) => {
|
|
|
81
97
|
export const mixTwoRgb = (colorA, colorB, range = 0.5) => {
|
|
82
98
|
const arr = []
|
|
83
99
|
for (let i = 0; i < 3; i++) {
|
|
84
|
-
arr[i] = ~~(
|
|
85
|
-
colorA[i] + (
|
|
86
|
-
(colorB[i] - colorA[i]) * range
|
|
87
|
-
)
|
|
88
|
-
)
|
|
100
|
+
arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range)
|
|
89
101
|
}
|
|
90
102
|
return `rgb(${arr})`
|
|
91
103
|
}
|
|
@@ -93,25 +105,27 @@ export const mixTwoRgb = (colorA, colorB, range = 0.5) => {
|
|
|
93
105
|
export const changeLightness = (delta, hsl) => {
|
|
94
106
|
const [hue, saturation, lightness] = hsl
|
|
95
107
|
|
|
96
|
-
const newLightness = Math.max(
|
|
97
|
-
0,
|
|
98
|
-
Math.min(100, lightness + parseFloat(delta))
|
|
99
|
-
)
|
|
108
|
+
const newLightness = Math.max(0, Math.min(100, lightness + parseFloat(delta)))
|
|
100
109
|
|
|
101
110
|
return [hue, saturation, newLightness]
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
export const rgbToHSL = (r, g, b) => {
|
|
105
|
-
const a = Math.max(r, g, b)
|
|
106
|
-
const
|
|
114
|
+
const a = Math.max(r, g, b)
|
|
115
|
+
const n = a - Math.min(r, g, b)
|
|
116
|
+
const f = 1 - Math.abs(a + a - n - 1)
|
|
117
|
+
const h =
|
|
118
|
+
n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n) //eslint-disable-line
|
|
107
119
|
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2]
|
|
108
120
|
}
|
|
109
121
|
|
|
110
|
-
export const hslToRgb = (
|
|
122
|
+
export const hslToRgb = (
|
|
123
|
+
h,
|
|
124
|
+
s,
|
|
125
|
+
l,
|
|
111
126
|
a = s * Math.min(l, 1 - l),
|
|
112
|
-
f = (n, k = (n + h / 30) % 12) =>
|
|
113
|
-
Math.min(k - 3, 9 - k, 1), -1
|
|
114
|
-
)
|
|
127
|
+
f = (n, k = (n + h / 30) % 12) =>
|
|
128
|
+
l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)
|
|
115
129
|
) => [f(0), f(8), f(4)]
|
|
116
130
|
|
|
117
131
|
export const getColorShade = (col, amt) => {
|
|
@@ -122,12 +136,12 @@ export const getColorShade = (col, amt) => {
|
|
|
122
136
|
if (r > 255) r = 255
|
|
123
137
|
else if (r < 0) r = 0
|
|
124
138
|
|
|
125
|
-
let b = ((num >> 8) &
|
|
139
|
+
let b = ((num >> 8) & 0x00ff) + amt
|
|
126
140
|
|
|
127
141
|
if (b > 255) b = 255
|
|
128
142
|
else if (b < 0) b = 0
|
|
129
143
|
|
|
130
|
-
let g = (num &
|
|
144
|
+
let g = (num & 0x0000ff) + amt
|
|
131
145
|
|
|
132
146
|
if (g > 255) g = 255
|
|
133
147
|
else if (g < 0) g = 0
|
|
@@ -138,12 +152,8 @@ export const getColorShade = (col, amt) => {
|
|
|
138
152
|
export const mixTwoRgba = (colorA, colorB, range = 0.5) => {
|
|
139
153
|
const arr = []
|
|
140
154
|
for (let i = 0; i < 4; i++) {
|
|
141
|
-
const round =
|
|
142
|
-
arr[i] = round(
|
|
143
|
-
(colorA[i] + (
|
|
144
|
-
(colorB[i] - colorA[i]) * range
|
|
145
|
-
))
|
|
146
|
-
)
|
|
155
|
+
const round = i === 3 ? x => x : Math.round
|
|
156
|
+
arr[i] = round(colorA[i] + (colorB[i] - colorA[i]) * range)
|
|
147
157
|
}
|
|
148
158
|
return `rgba(${arr})`
|
|
149
159
|
}
|
|
@@ -151,7 +161,7 @@ export const mixTwoRgba = (colorA, colorB, range = 0.5) => {
|
|
|
151
161
|
export const opacify = (color, opacity) => {
|
|
152
162
|
const arr = colorStringToRgbaArray(color)
|
|
153
163
|
if (!arr) {
|
|
154
|
-
if (
|
|
164
|
+
if (isNotProduction()) console.warn(color + ' color is not rgba')
|
|
155
165
|
return
|
|
156
166
|
}
|
|
157
167
|
arr[3] = opacity
|
|
@@ -159,7 +169,8 @@ export const opacify = (color, opacity) => {
|
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
export const getRgbTone = (rgb, tone) => {
|
|
162
|
-
if (isString(rgb) && rgb.includes('rgb'))
|
|
172
|
+
if (isString(rgb) && rgb.includes('rgb'))
|
|
173
|
+
rgb = colorStringToRgbaArray(rgb).join(', ')
|
|
163
174
|
if (isString(rgb)) rgb = rgb.split(',').map(v => parseFloat(v.trim()))
|
|
164
175
|
if (isNumber(tone)) tone += ''
|
|
165
176
|
const toHex = rgbArrayToHex(rgb)
|
|
@@ -172,7 +183,7 @@ export const getRgbTone = (rgb, tone) => {
|
|
|
172
183
|
const [r, g, b] = rgb
|
|
173
184
|
const hsl = rgbToHSL(r, g, b)
|
|
174
185
|
const [h, s, l] = hsl // eslint-disable-line
|
|
175
|
-
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255)
|
|
186
|
+
const newRgb = hslToRgb(h, s, (parseFloat(tone) / 100) * 255)
|
|
176
187
|
return newRgb
|
|
177
188
|
}
|
|
178
189
|
}
|