@symbo.ls/scratch 3.8.9 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/defaultConfig/animation.js +4 -2
- package/dist/cjs/defaultConfig/cases.js +4 -2
- package/dist/cjs/defaultConfig/class.js +4 -2
- package/dist/cjs/defaultConfig/color.js +6 -9
- package/dist/cjs/defaultConfig/document.js +4 -2
- package/dist/cjs/defaultConfig/font-family.js +8 -12
- package/dist/cjs/defaultConfig/font.js +4 -11
- package/dist/cjs/defaultConfig/grid.js +5 -3
- package/dist/cjs/defaultConfig/icons.js +6 -4
- package/dist/cjs/defaultConfig/index.js +200 -24
- package/dist/cjs/defaultConfig/media.js +4 -2
- package/dist/cjs/defaultConfig/responsive.js +6 -4
- package/dist/cjs/defaultConfig/sequence.js +4 -2
- package/dist/cjs/defaultConfig/shadow.js +4 -2
- package/dist/cjs/defaultConfig/spacing.js +56 -7
- package/dist/cjs/defaultConfig/svg.js +6 -4
- package/dist/cjs/defaultConfig/templates.js +4 -2
- package/dist/cjs/defaultConfig/theme.js +4 -14
- package/dist/cjs/defaultConfig/timing.js +36 -5
- package/dist/cjs/defaultConfig/typography.js +36 -5
- package/dist/cjs/defaultConfig/unit.js +4 -2
- package/dist/cjs/factory.js +341 -40
- package/dist/cjs/index.js +6333 -11
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/set.js +5614 -158
- package/dist/cjs/system/color.js +4481 -104
- package/dist/cjs/system/document.js +4371 -11
- package/dist/cjs/system/font.js +4401 -28
- package/dist/cjs/system/index.js +5748 -11
- package/dist/cjs/system/reset.js +4445 -21
- package/dist/cjs/system/shadow.js +4832 -41
- package/dist/cjs/system/spacing.js +4752 -39
- package/dist/cjs/system/svg.js +4437 -47
- package/dist/cjs/system/theme.js +4526 -335
- package/dist/cjs/system/timing.js +4695 -19
- package/dist/cjs/system/typography.js +4755 -33
- package/dist/cjs/tests/index.js +4 -2
- package/dist/cjs/transforms/index.js +5019 -134
- package/dist/cjs/utils/color.js +47 -66
- package/dist/cjs/utils/font.js +25 -46
- package/dist/cjs/utils/index.js +5068 -8
- package/dist/cjs/utils/sequence.js +4423 -35
- package/dist/cjs/utils/sprite.js +353 -12
- package/dist/cjs/utils/theme.js +3 -1
- package/dist/cjs/utils/unit.js +4 -2
- package/dist/cjs/utils/var.js +4390 -42
- package/index.js +1 -0
- package/package.json +11 -14
- package/src/defaultConfig/class.js +2 -1
- package/src/defaultConfig/font-family.js +3 -3
- package/src/defaultConfig/icons.js +1 -1
- package/src/defaultConfig/svg.js +1 -1
- package/src/defaultConfig/timing.js +1 -1
- package/src/factory.js +85 -13
- package/src/index.js +16 -5
- package/src/set.js +156 -63
- package/src/system/color.js +113 -12
- package/src/system/document.js +3 -3
- package/src/system/font.js +5 -5
- package/src/system/reset.js +41 -8
- package/src/system/shadow.js +4 -3
- package/src/system/spacing.js +3 -3
- package/src/system/svg.js +42 -5
- package/src/system/theme.js +87 -64
- package/src/system/timing.js +2 -2
- package/src/system/typography.js +12 -3
- package/src/transforms/index.js +4 -4
- package/src/utils/color.js +2 -1
- package/src/utils/font.js +7 -1
- package/src/utils/sequence.js +46 -29
- package/src/utils/sprite.js +44 -16
- package/src/utils/var.js +27 -9
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/class.js +0 -5
- package/dist/esm/defaultConfig/color.js +0 -11
- package/dist/esm/defaultConfig/document.js +0 -4
- package/dist/esm/defaultConfig/font-family.js +0 -18
- package/dist/esm/defaultConfig/font.js +0 -13
- package/dist/esm/defaultConfig/grid.js +0 -5
- package/dist/esm/defaultConfig/icons.js +0 -6
- package/dist/esm/defaultConfig/index.js +0 -25
- package/dist/esm/defaultConfig/media.js +0 -9
- package/dist/esm/defaultConfig/responsive.js +0 -30
- package/dist/esm/defaultConfig/sequence.js +0 -29
- package/dist/esm/defaultConfig/shadow.js +0 -4
- package/dist/esm/defaultConfig/spacing.js +0 -18
- package/dist/esm/defaultConfig/svg.js +0 -6
- package/dist/esm/defaultConfig/templates.js +0 -4
- package/dist/esm/defaultConfig/theme.js +0 -16
- package/dist/esm/defaultConfig/timing.js +0 -17
- package/dist/esm/defaultConfig/typography.js +0 -21
- package/dist/esm/defaultConfig/unit.js +0 -6
- package/dist/esm/factory.js +0 -60
- package/dist/esm/index.js +0 -12
- package/dist/esm/set.js +0 -219
- package/dist/esm/system/color.js +0 -193
- package/dist/esm/system/document.js +0 -16
- package/dist/esm/system/font.js +0 -58
- package/dist/esm/system/index.js +0 -10
- package/dist/esm/system/reset.js +0 -67
- package/dist/esm/system/shadow.js +0 -91
- package/dist/esm/system/spacing.js +0 -121
- package/dist/esm/system/svg.js +0 -86
- package/dist/esm/system/theme.js +0 -480
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -85
- package/dist/esm/tests/index.js +0 -8
- package/dist/esm/transforms/index.js +0 -216
- package/dist/esm/utils/color.js +0 -192
- package/dist/esm/utils/font.js +0 -92
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/sequence.js +0 -303
- package/dist/esm/utils/sprite.js +0 -65
- package/dist/esm/utils/theme.js +0 -9
- package/dist/esm/utils/unit.js +0 -59
- package/dist/esm/utils/var.js +0 -82
- package/dist/iife/index.js +0 -3204
package/dist/iife/index.js
DELETED
|
@@ -1,3204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var SmblsScratch = (() => {
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __esm = (fn, res) => function __init() {
|
|
8
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
-
};
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
|
|
24
|
-
// ../utils/dist/esm/globals.js
|
|
25
|
-
var window2, document2;
|
|
26
|
-
var init_globals = __esm({
|
|
27
|
-
"../utils/dist/esm/globals.js"() {
|
|
28
|
-
window2 = globalThis;
|
|
29
|
-
document2 = window2.document;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// ../utils/dist/esm/node.js
|
|
34
|
-
var isDOMNode;
|
|
35
|
-
var init_node = __esm({
|
|
36
|
-
"../utils/dist/esm/node.js"() {
|
|
37
|
-
init_globals();
|
|
38
|
-
isDOMNode = (obj) => {
|
|
39
|
-
return typeof window2 !== "undefined" && (window2.Node && obj instanceof window2.Node || window2.Window && obj instanceof window2.Window || obj === window2 || obj === document);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// ../utils/dist/esm/types.js
|
|
45
|
-
var isObject, isString, isNumber, isFunction, isArray, isObjectLike, isDefined;
|
|
46
|
-
var init_types = __esm({
|
|
47
|
-
"../utils/dist/esm/types.js"() {
|
|
48
|
-
isObject = (arg) => {
|
|
49
|
-
if (arg === null) return false;
|
|
50
|
-
return typeof arg === "object" && arg.constructor === Object;
|
|
51
|
-
};
|
|
52
|
-
isString = (arg) => typeof arg === "string";
|
|
53
|
-
isNumber = (arg) => typeof arg === "number";
|
|
54
|
-
isFunction = (arg) => typeof arg === "function";
|
|
55
|
-
isArray = (arg) => Array.isArray(arg);
|
|
56
|
-
isObjectLike = (arg) => {
|
|
57
|
-
if (arg === null) return false;
|
|
58
|
-
return typeof arg === "object";
|
|
59
|
-
};
|
|
60
|
-
isDefined = (arg) => arg !== void 0;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// ../utils/dist/esm/array.js
|
|
65
|
-
var unstackArrayOfObjects;
|
|
66
|
-
var init_array = __esm({
|
|
67
|
-
"../utils/dist/esm/array.js"() {
|
|
68
|
-
init_object();
|
|
69
|
-
unstackArrayOfObjects = (arr, exclude = []) => {
|
|
70
|
-
return arr.reduce(
|
|
71
|
-
(a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
|
|
72
|
-
{}
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// ../utils/dist/esm/string.js
|
|
79
|
-
var init_string = __esm({
|
|
80
|
-
"../utils/dist/esm/string.js"() {
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// ../utils/dist/esm/keys.js
|
|
85
|
-
var STATE_METHODS, PROPS_METHODS, METHODS, METHODS_EXL;
|
|
86
|
-
var init_keys = __esm({
|
|
87
|
-
"../utils/dist/esm/keys.js"() {
|
|
88
|
-
STATE_METHODS = /* @__PURE__ */ new Set([
|
|
89
|
-
"update",
|
|
90
|
-
"parse",
|
|
91
|
-
"clean",
|
|
92
|
-
"create",
|
|
93
|
-
"destroy",
|
|
94
|
-
"add",
|
|
95
|
-
"toggle",
|
|
96
|
-
"remove",
|
|
97
|
-
"apply",
|
|
98
|
-
"set",
|
|
99
|
-
"reset",
|
|
100
|
-
"replace",
|
|
101
|
-
"quietReplace",
|
|
102
|
-
"quietUpdate",
|
|
103
|
-
"applyReplace",
|
|
104
|
-
"applyFunction",
|
|
105
|
-
"keys",
|
|
106
|
-
"values",
|
|
107
|
-
"ref",
|
|
108
|
-
"rootUpdate",
|
|
109
|
-
"parentUpdate",
|
|
110
|
-
"parent",
|
|
111
|
-
"__element",
|
|
112
|
-
"__depends",
|
|
113
|
-
"__ref",
|
|
114
|
-
"__children",
|
|
115
|
-
"root",
|
|
116
|
-
"setByPath",
|
|
117
|
-
"setPathCollection",
|
|
118
|
-
"removeByPath",
|
|
119
|
-
"removePathCollection",
|
|
120
|
-
"getByPath"
|
|
121
|
-
]);
|
|
122
|
-
PROPS_METHODS = /* @__PURE__ */ new Set(["update", "__element"]);
|
|
123
|
-
METHODS = /* @__PURE__ */ new Set([
|
|
124
|
-
"set",
|
|
125
|
-
"reset",
|
|
126
|
-
"update",
|
|
127
|
-
"remove",
|
|
128
|
-
"updateContent",
|
|
129
|
-
"removeContent",
|
|
130
|
-
"lookup",
|
|
131
|
-
"lookdown",
|
|
132
|
-
"lookdownAll",
|
|
133
|
-
"getRef",
|
|
134
|
-
"getPath",
|
|
135
|
-
"setNodeStyles",
|
|
136
|
-
"spotByPath",
|
|
137
|
-
"keys",
|
|
138
|
-
"parse",
|
|
139
|
-
"setProps",
|
|
140
|
-
"parseDeep",
|
|
141
|
-
"variables",
|
|
142
|
-
"if",
|
|
143
|
-
"log",
|
|
144
|
-
"verbose",
|
|
145
|
-
"warn",
|
|
146
|
-
"error",
|
|
147
|
-
"call",
|
|
148
|
-
"nextElement",
|
|
149
|
-
"previousElement",
|
|
150
|
-
"getRootState",
|
|
151
|
-
"getRoot",
|
|
152
|
-
"getRootData",
|
|
153
|
-
"getRootContext",
|
|
154
|
-
"getContext",
|
|
155
|
-
"getQuery",
|
|
156
|
-
"getDB",
|
|
157
|
-
"getChildren"
|
|
158
|
-
]);
|
|
159
|
-
METHODS_EXL = /* @__PURE__ */ new Set([
|
|
160
|
-
"node",
|
|
161
|
-
"context",
|
|
162
|
-
"extends",
|
|
163
|
-
"__element",
|
|
164
|
-
"__ref",
|
|
165
|
-
...METHODS,
|
|
166
|
-
...STATE_METHODS,
|
|
167
|
-
...PROPS_METHODS
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// ../utils/dist/esm/object.js
|
|
173
|
-
var _startsWithDunder, exec, merge, deepMerge, deepClone, overwriteDeep;
|
|
174
|
-
var init_object = __esm({
|
|
175
|
-
"../utils/dist/esm/object.js"() {
|
|
176
|
-
init_globals();
|
|
177
|
-
init_types();
|
|
178
|
-
init_array();
|
|
179
|
-
init_node();
|
|
180
|
-
init_keys();
|
|
181
|
-
_startsWithDunder = (e) => e.charCodeAt(0) === 95 && e.charCodeAt(1) === 95;
|
|
182
|
-
exec = (param, element, state, context) => {
|
|
183
|
-
if (isFunction(param)) {
|
|
184
|
-
if (!element) return;
|
|
185
|
-
if (typeof param.call !== "function") return param;
|
|
186
|
-
const result = param.call(
|
|
187
|
-
element,
|
|
188
|
-
element,
|
|
189
|
-
state || element.state,
|
|
190
|
-
context || element.context
|
|
191
|
-
);
|
|
192
|
-
if (result && typeof result.then === "function") {
|
|
193
|
-
let resolved;
|
|
194
|
-
result.then((value) => {
|
|
195
|
-
resolved = value;
|
|
196
|
-
});
|
|
197
|
-
return resolved;
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
if (param != null && element?.context?.plugins && (isArray(param) || isObject(param) && !isDOMNode(param))) {
|
|
202
|
-
const plugins = element.context.plugins;
|
|
203
|
-
for (const plugin of plugins) {
|
|
204
|
-
if (plugin.resolveHandler) {
|
|
205
|
-
const resolved = plugin.resolveHandler(param, element);
|
|
206
|
-
if (typeof resolved === "function") {
|
|
207
|
-
return exec(resolved, element, state, context);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return param;
|
|
213
|
-
};
|
|
214
|
-
merge = (element, obj, excludeFrom = []) => {
|
|
215
|
-
const useSet = excludeFrom instanceof Set;
|
|
216
|
-
for (const e in obj) {
|
|
217
|
-
if (!Object.prototype.hasOwnProperty.call(obj, e)) continue;
|
|
218
|
-
if (_startsWithDunder(e)) continue;
|
|
219
|
-
if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
|
|
220
|
-
if (element[e] === void 0) {
|
|
221
|
-
element[e] = obj[e];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return element;
|
|
225
|
-
};
|
|
226
|
-
deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
|
|
227
|
-
const useSet = excludeFrom instanceof Set;
|
|
228
|
-
for (const e in extend) {
|
|
229
|
-
if (!Object.prototype.hasOwnProperty.call(extend, e)) continue;
|
|
230
|
-
if (_startsWithDunder(e)) continue;
|
|
231
|
-
if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
|
|
232
|
-
const elementProp = element[e];
|
|
233
|
-
const extendProp = extend[e];
|
|
234
|
-
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
235
|
-
deepMerge(elementProp, extendProp, excludeFrom);
|
|
236
|
-
} else if (elementProp === void 0) {
|
|
237
|
-
element[e] = extendProp;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return element;
|
|
241
|
-
};
|
|
242
|
-
deepClone = (obj, options = {}) => {
|
|
243
|
-
const {
|
|
244
|
-
exclude = [],
|
|
245
|
-
cleanUndefined = false,
|
|
246
|
-
cleanNull = false,
|
|
247
|
-
window: targetWindow,
|
|
248
|
-
visited = /* @__PURE__ */ new WeakMap(),
|
|
249
|
-
handleExtends = false
|
|
250
|
-
} = options;
|
|
251
|
-
const contentWindow = targetWindow || window2 || globalThis;
|
|
252
|
-
if (!isObjectLike(obj) || isDOMNode(obj)) {
|
|
253
|
-
return obj;
|
|
254
|
-
}
|
|
255
|
-
if (visited.has(obj)) {
|
|
256
|
-
return visited.get(obj);
|
|
257
|
-
}
|
|
258
|
-
const isArr = isArray(obj);
|
|
259
|
-
const clone2 = isArr ? [] : {};
|
|
260
|
-
visited.set(obj, clone2);
|
|
261
|
-
const excludeSet = exclude instanceof Set ? exclude : exclude.length > 3 ? new Set(exclude) : null;
|
|
262
|
-
for (const key in obj) {
|
|
263
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
264
|
-
if (_startsWithDunder(key) || key === "__proto__") continue;
|
|
265
|
-
if (excludeSet ? excludeSet.has(key) : exclude.includes(key)) continue;
|
|
266
|
-
const value = obj[key];
|
|
267
|
-
if (cleanUndefined && value === void 0) continue;
|
|
268
|
-
if (cleanNull && value === null) continue;
|
|
269
|
-
if (isDOMNode(value)) {
|
|
270
|
-
clone2[key] = value;
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
if (handleExtends && key === "extends" && isArray(value)) {
|
|
274
|
-
clone2[key] = unstackArrayOfObjects(value, exclude);
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
if (isFunction(value) && options.window) {
|
|
278
|
-
clone2[key] = contentWindow.eval("(" + value.toString() + ")");
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (isObjectLike(value)) {
|
|
282
|
-
clone2[key] = deepClone(value, {
|
|
283
|
-
...options,
|
|
284
|
-
visited
|
|
285
|
-
});
|
|
286
|
-
} else {
|
|
287
|
-
clone2[key] = value;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return clone2;
|
|
291
|
-
};
|
|
292
|
-
overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
|
|
293
|
-
if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
|
|
294
|
-
return params;
|
|
295
|
-
}
|
|
296
|
-
if (visited.has(obj)) return visited.get(obj);
|
|
297
|
-
visited.set(obj, obj);
|
|
298
|
-
const excl = opts.exclude;
|
|
299
|
-
const exclSet = excl ? excl instanceof Set ? excl : new Set(excl) : null;
|
|
300
|
-
const forcedExclude = !opts.preventForce;
|
|
301
|
-
for (const e in params) {
|
|
302
|
-
if (!Object.prototype.hasOwnProperty.call(params, e)) continue;
|
|
303
|
-
if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e)) continue;
|
|
304
|
-
const objProp = obj[e];
|
|
305
|
-
const paramsProp = params[e];
|
|
306
|
-
if (isDOMNode(paramsProp)) {
|
|
307
|
-
obj[e] = paramsProp;
|
|
308
|
-
} else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
|
|
309
|
-
obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
|
|
310
|
-
} else if (paramsProp !== void 0) {
|
|
311
|
-
obj[e] = paramsProp;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return obj;
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// ../utils/dist/esm/key.js
|
|
320
|
-
var init_key = __esm({
|
|
321
|
-
"../utils/dist/esm/key.js"() {
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// ../utils/dist/esm/env.js
|
|
326
|
-
var NODE_ENV, isProduction, isNotProduction;
|
|
327
|
-
var init_env = __esm({
|
|
328
|
-
"../utils/dist/esm/env.js"() {
|
|
329
|
-
NODE_ENV = process.env.NODE_ENV;
|
|
330
|
-
isProduction = (env = NODE_ENV) => env === "production";
|
|
331
|
-
isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// ../utils/dist/esm/function.js
|
|
336
|
-
var init_function = __esm({
|
|
337
|
-
"../utils/dist/esm/function.js"() {
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
// ../utils/dist/esm/if.js
|
|
342
|
-
var init_if = __esm({
|
|
343
|
-
"../utils/dist/esm/if.js"() {
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// ../utils/dist/esm/log.js
|
|
348
|
-
var init_log = __esm({
|
|
349
|
-
"../utils/dist/esm/log.js"() {
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// ../utils/dist/esm/cookie.js
|
|
354
|
-
var isMobile;
|
|
355
|
-
var init_cookie = __esm({
|
|
356
|
-
"../utils/dist/esm/cookie.js"() {
|
|
357
|
-
isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// ../utils/dist/esm/tags.js
|
|
362
|
-
var init_tags = __esm({
|
|
363
|
-
"../utils/dist/esm/tags.js"() {
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// ../utils/dist/esm/extends.js
|
|
368
|
-
var init_extends = __esm({
|
|
369
|
-
"../utils/dist/esm/extends.js"() {
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
// ../utils/dist/esm/component.js
|
|
374
|
-
var init_component = __esm({
|
|
375
|
-
"../utils/dist/esm/component.js"() {
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
// ../utils/dist/esm/props.js
|
|
380
|
-
var init_props = __esm({
|
|
381
|
-
"../utils/dist/esm/props.js"() {
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// ../utils/dist/esm/element.js
|
|
386
|
-
var init_element = __esm({
|
|
387
|
-
"../utils/dist/esm/element.js"() {
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
// ../utils/dist/esm/state.js
|
|
392
|
-
var init_state = __esm({
|
|
393
|
-
"../utils/dist/esm/state.js"() {
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
// ../utils/dist/esm/scope.js
|
|
398
|
-
var init_scope = __esm({
|
|
399
|
-
"../utils/dist/esm/scope.js"() {
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// ../utils/dist/esm/triggerEvent.js
|
|
404
|
-
var init_triggerEvent = __esm({
|
|
405
|
-
"../utils/dist/esm/triggerEvent.js"() {
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
// ../utils/dist/esm/cache.js
|
|
410
|
-
var init_cache = __esm({
|
|
411
|
-
"../utils/dist/esm/cache.js"() {
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
// ../utils/dist/esm/methods.js
|
|
416
|
-
var init_methods = __esm({
|
|
417
|
-
"../utils/dist/esm/methods.js"() {
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// ../utils/dist/esm/update.js
|
|
422
|
-
var init_update = __esm({
|
|
423
|
-
"../utils/dist/esm/update.js"() {
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
// ../utils/dist/esm/index.js
|
|
428
|
-
var init_esm = __esm({
|
|
429
|
-
"../utils/dist/esm/index.js"() {
|
|
430
|
-
init_key();
|
|
431
|
-
init_env();
|
|
432
|
-
init_types();
|
|
433
|
-
init_object();
|
|
434
|
-
init_function();
|
|
435
|
-
init_array();
|
|
436
|
-
init_node();
|
|
437
|
-
init_if();
|
|
438
|
-
init_log();
|
|
439
|
-
init_string();
|
|
440
|
-
init_globals();
|
|
441
|
-
init_cookie();
|
|
442
|
-
init_tags();
|
|
443
|
-
init_component();
|
|
444
|
-
init_props();
|
|
445
|
-
init_extends();
|
|
446
|
-
init_element();
|
|
447
|
-
init_state();
|
|
448
|
-
init_keys();
|
|
449
|
-
init_scope();
|
|
450
|
-
init_methods();
|
|
451
|
-
init_cache();
|
|
452
|
-
init_update();
|
|
453
|
-
init_triggerEvent();
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
// src/index.js
|
|
458
|
-
var index_exports = {};
|
|
459
|
-
__export(index_exports, {
|
|
460
|
-
CLASS: () => CLASS,
|
|
461
|
-
CONFIG: () => CONFIG,
|
|
462
|
-
CSS_MEDIA_VARS: () => CSS_MEDIA_VARS,
|
|
463
|
-
CSS_NATIVE_COLOR_REGEX: () => CSS_NATIVE_COLOR_REGEX,
|
|
464
|
-
CSS_UNITS: () => CSS_UNITS,
|
|
465
|
-
CSS_VARS: () => CSS_VARS,
|
|
466
|
-
FACTORY: () => FACTORY,
|
|
467
|
-
VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
|
|
468
|
-
activateConfig: () => activateConfig,
|
|
469
|
-
animation: () => animation,
|
|
470
|
-
appendSVGSprite: () => appendSVGSprite,
|
|
471
|
-
appendSvgIconsSprite: () => appendSvgIconsSprite,
|
|
472
|
-
applyDocument: () => applyDocument,
|
|
473
|
-
applyHeadings: () => applyHeadings,
|
|
474
|
-
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
475
|
-
applyReset: () => applyReset,
|
|
476
|
-
applySequenceGlobalVars: () => applySequenceGlobalVars,
|
|
477
|
-
applySequenceVars: () => applySequenceVars,
|
|
478
|
-
applySpacingSequence: () => applySpacingSequence,
|
|
479
|
-
applyTimingSequence: () => applyTimingSequence,
|
|
480
|
-
applyTypographySequence: () => applyTypographySequence,
|
|
481
|
-
breakpoints: () => breakpoints,
|
|
482
|
-
changeGlobalTheme: () => changeGlobalTheme,
|
|
483
|
-
changeLightness: () => changeLightness,
|
|
484
|
-
checkIfBoxSize: () => checkIfBoxSize,
|
|
485
|
-
color: () => color,
|
|
486
|
-
colorStringToRgbaArray: () => colorStringToRgbaArray,
|
|
487
|
-
convertSvgToSymbol: () => convertSvgToSymbol,
|
|
488
|
-
devices: () => devices,
|
|
489
|
-
document: () => document3,
|
|
490
|
-
findHeadingLetter: () => findHeadingLetter,
|
|
491
|
-
findHeadings: () => findHeadings,
|
|
492
|
-
font: () => font,
|
|
493
|
-
font_face: () => font_face,
|
|
494
|
-
font_family: () => font_family,
|
|
495
|
-
font_family_types: () => font_family_types,
|
|
496
|
-
generateSequence: () => generateSequence,
|
|
497
|
-
generateSequencePosition: () => generateSequencePosition,
|
|
498
|
-
generateSprite: () => generateSprite,
|
|
499
|
-
generateSubSequence: () => generateSubSequence,
|
|
500
|
-
getActiveConfig: () => getActiveConfig,
|
|
501
|
-
getColor: () => getColor,
|
|
502
|
-
getColorShade: () => getColorShade,
|
|
503
|
-
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
504
|
-
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
505
|
-
getFontFace: () => getFontFace,
|
|
506
|
-
getFontFaceEach: () => getFontFaceEach,
|
|
507
|
-
getFontFaceEachString: () => getFontFaceEachString,
|
|
508
|
-
getFontFaceString: () => getFontFaceString,
|
|
509
|
-
getFontFamily: () => getFontFamily,
|
|
510
|
-
getFontFormat: () => getFontFormat,
|
|
511
|
-
getFontSizeByKey: () => getFontSizeByKey,
|
|
512
|
-
getMediaColor: () => getMediaColor,
|
|
513
|
-
getMediaTheme: () => getMediaTheme,
|
|
514
|
-
getRgbTone: () => getRgbTone,
|
|
515
|
-
getSequenceValue: () => getSequenceValue,
|
|
516
|
-
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
517
|
-
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
518
|
-
getShadow: () => getShadow,
|
|
519
|
-
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
520
|
-
getSpacingByKey: () => getSpacingByKey,
|
|
521
|
-
getSubratio: () => getSubratio,
|
|
522
|
-
getSubratioDifference: () => getSubratioDifference,
|
|
523
|
-
getTheme: () => getTheme,
|
|
524
|
-
getTimingByKey: () => getTimingByKey,
|
|
525
|
-
getTimingFunction: () => getTimingFunction,
|
|
526
|
-
gradient: () => gradient,
|
|
527
|
-
grid: () => grid,
|
|
528
|
-
hexToRgb: () => hexToRgb,
|
|
529
|
-
hexToRgbArray: () => hexToRgbArray,
|
|
530
|
-
hexToRgba: () => hexToRgba,
|
|
531
|
-
hslToRgb: () => hslToRgb,
|
|
532
|
-
icons: () => icons,
|
|
533
|
-
isCSSVar: () => isCSSVar,
|
|
534
|
-
isGoogleFontsUrl: () => isGoogleFontsUrl,
|
|
535
|
-
isResolvedColor: () => isResolvedColor,
|
|
536
|
-
isScalingUnit: () => isScalingUnit,
|
|
537
|
-
media: () => media,
|
|
538
|
-
mixTwoColors: () => mixTwoColors,
|
|
539
|
-
mixTwoRgb: () => mixTwoRgb,
|
|
540
|
-
mixTwoRgba: () => mixTwoRgba,
|
|
541
|
-
numToLetterMap: () => numToLetterMap,
|
|
542
|
-
opacify: () => opacify,
|
|
543
|
-
parseColorToken: () => parseColorToken,
|
|
544
|
-
reset: () => reset,
|
|
545
|
-
resolveColorsInGradient: () => resolveColorsInGradient,
|
|
546
|
-
resolveFileUrl: () => resolveFileUrl,
|
|
547
|
-
returnSubThemeOrDefault: () => returnSubThemeOrDefault,
|
|
548
|
-
rgbArrayToHex: () => rgbArrayToHex,
|
|
549
|
-
rgbToHSL: () => rgbToHSL,
|
|
550
|
-
rgbToHex: () => rgbToHex,
|
|
551
|
-
runThroughMedia: () => runThroughMedia,
|
|
552
|
-
scratchSystem: () => system_exports,
|
|
553
|
-
scratchUtils: () => utils_exports,
|
|
554
|
-
semantic_icons: () => semantic_icons,
|
|
555
|
-
sequence: () => sequence,
|
|
556
|
-
set: () => set,
|
|
557
|
-
setActiveConfig: () => setActiveConfig,
|
|
558
|
-
setColor: () => setColor,
|
|
559
|
-
setCustomFont: () => setCustomFont,
|
|
560
|
-
setCustomFontMedia: () => setCustomFontMedia,
|
|
561
|
-
setEach: () => setEach,
|
|
562
|
-
setFont: () => setFont,
|
|
563
|
-
setFontFamily: () => setFontFamily,
|
|
564
|
-
setFontImport: () => setFontImport,
|
|
565
|
-
setGradient: () => setGradient,
|
|
566
|
-
setInCustomFontMedia: () => setInCustomFontMedia,
|
|
567
|
-
setMediaTheme: () => setMediaTheme,
|
|
568
|
-
setSVG: () => setSVG,
|
|
569
|
-
setScalingVar: () => setScalingVar,
|
|
570
|
-
setShadow: () => setShadow,
|
|
571
|
-
setSubScalingVar: () => setSubScalingVar,
|
|
572
|
-
setSvgIcon: () => setSvgIcon,
|
|
573
|
-
setTheme: () => setTheme,
|
|
574
|
-
setValue: () => setValue,
|
|
575
|
-
setVariables: () => setVariables,
|
|
576
|
-
shadow: () => shadow,
|
|
577
|
-
spacing: () => spacing,
|
|
578
|
-
splitSpacedValue: () => splitSpacedValue,
|
|
579
|
-
splitTopLevelCommas: () => splitTopLevelCommas,
|
|
580
|
-
splitTransition: () => splitTransition,
|
|
581
|
-
svg: () => svg,
|
|
582
|
-
svg_data: () => svg_data,
|
|
583
|
-
templates: () => templates,
|
|
584
|
-
theme: () => theme,
|
|
585
|
-
timing: () => timing,
|
|
586
|
-
transformBackgroundImage: () => transformBackgroundImage,
|
|
587
|
-
transformBorder: () => transformBorder,
|
|
588
|
-
transformBorderRadius: () => transformBorderRadius,
|
|
589
|
-
transformBoxShadow: () => transformBoxShadow,
|
|
590
|
-
transformDuration: () => transformDuration,
|
|
591
|
-
transformShadow: () => transformShadow,
|
|
592
|
-
transformSize: () => transformSize,
|
|
593
|
-
transformSizeRatio: () => transformSizeRatio,
|
|
594
|
-
transformTextStroke: () => transformTextStroke,
|
|
595
|
-
transformTransition: () => transformTransition,
|
|
596
|
-
transfromGap: () => transfromGap,
|
|
597
|
-
typography: () => typography,
|
|
598
|
-
unit: () => unit,
|
|
599
|
-
vars: () => vars
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// src/utils/index.js
|
|
603
|
-
var utils_exports = {};
|
|
604
|
-
__export(utils_exports, {
|
|
605
|
-
CSS_NATIVE_COLOR_REGEX: () => CSS_NATIVE_COLOR_REGEX,
|
|
606
|
-
CSS_UNITS: () => CSS_UNITS,
|
|
607
|
-
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
608
|
-
applySequenceGlobalVars: () => applySequenceGlobalVars,
|
|
609
|
-
applySequenceVars: () => applySequenceVars,
|
|
610
|
-
changeLightness: () => changeLightness,
|
|
611
|
-
colorStringToRgbaArray: () => colorStringToRgbaArray,
|
|
612
|
-
convertSvgToSymbol: () => convertSvgToSymbol,
|
|
613
|
-
findHeadingLetter: () => findHeadingLetter,
|
|
614
|
-
findHeadings: () => findHeadings,
|
|
615
|
-
generateSequence: () => generateSequence,
|
|
616
|
-
generateSequencePosition: () => generateSequencePosition,
|
|
617
|
-
generateSprite: () => generateSprite,
|
|
618
|
-
generateSubSequence: () => generateSubSequence,
|
|
619
|
-
getColorShade: () => getColorShade,
|
|
620
|
-
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
621
|
-
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
622
|
-
getFontFace: () => getFontFace,
|
|
623
|
-
getFontFaceEach: () => getFontFaceEach,
|
|
624
|
-
getFontFaceEachString: () => getFontFaceEachString,
|
|
625
|
-
getFontFaceString: () => getFontFaceString,
|
|
626
|
-
getFontFormat: () => getFontFormat,
|
|
627
|
-
getRgbTone: () => getRgbTone,
|
|
628
|
-
getSequenceValue: () => getSequenceValue,
|
|
629
|
-
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
630
|
-
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
631
|
-
getSubratio: () => getSubratio,
|
|
632
|
-
getSubratioDifference: () => getSubratioDifference,
|
|
633
|
-
hexToRgb: () => hexToRgb,
|
|
634
|
-
hexToRgbArray: () => hexToRgbArray,
|
|
635
|
-
hexToRgba: () => hexToRgba,
|
|
636
|
-
hslToRgb: () => hslToRgb,
|
|
637
|
-
isCSSVar: () => isCSSVar,
|
|
638
|
-
isGoogleFontsUrl: () => isGoogleFontsUrl,
|
|
639
|
-
isResolvedColor: () => isResolvedColor,
|
|
640
|
-
isScalingUnit: () => isScalingUnit,
|
|
641
|
-
mixTwoColors: () => mixTwoColors,
|
|
642
|
-
mixTwoRgb: () => mixTwoRgb,
|
|
643
|
-
mixTwoRgba: () => mixTwoRgba,
|
|
644
|
-
numToLetterMap: () => numToLetterMap,
|
|
645
|
-
opacify: () => opacify,
|
|
646
|
-
parseColorToken: () => parseColorToken,
|
|
647
|
-
resolveFileUrl: () => resolveFileUrl,
|
|
648
|
-
returnSubThemeOrDefault: () => returnSubThemeOrDefault,
|
|
649
|
-
rgbArrayToHex: () => rgbArrayToHex,
|
|
650
|
-
rgbToHSL: () => rgbToHSL,
|
|
651
|
-
rgbToHex: () => rgbToHex,
|
|
652
|
-
setCustomFont: () => setCustomFont,
|
|
653
|
-
setCustomFontMedia: () => setCustomFontMedia,
|
|
654
|
-
setFontImport: () => setFontImport,
|
|
655
|
-
setInCustomFontMedia: () => setInCustomFontMedia,
|
|
656
|
-
setScalingVar: () => setScalingVar,
|
|
657
|
-
setSubScalingVar: () => setSubScalingVar,
|
|
658
|
-
setVariables: () => setVariables,
|
|
659
|
-
splitTopLevelCommas: () => splitTopLevelCommas
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
// src/utils/unit.js
|
|
663
|
-
var isScalingUnit = (unit2) => {
|
|
664
|
-
return unit2 === "em" || unit2 === "rem" || unit2 === "vw" || unit2 === "vh" || unit2 === "vmax" || unit2 === "vmin";
|
|
665
|
-
};
|
|
666
|
-
var CSS_UNITS = [
|
|
667
|
-
// Absolute
|
|
668
|
-
"px",
|
|
669
|
-
"cm",
|
|
670
|
-
"mm",
|
|
671
|
-
"in",
|
|
672
|
-
"pt",
|
|
673
|
-
"pc",
|
|
674
|
-
// Font-relative
|
|
675
|
-
"em",
|
|
676
|
-
"rem",
|
|
677
|
-
"ex",
|
|
678
|
-
"cap",
|
|
679
|
-
"ch",
|
|
680
|
-
"ic",
|
|
681
|
-
"lh",
|
|
682
|
-
"rlh",
|
|
683
|
-
// Viewport-relative
|
|
684
|
-
"%",
|
|
685
|
-
"vw",
|
|
686
|
-
"vh",
|
|
687
|
-
"vmin",
|
|
688
|
-
"vmax",
|
|
689
|
-
"svw",
|
|
690
|
-
"svh",
|
|
691
|
-
"lvw",
|
|
692
|
-
"lvh",
|
|
693
|
-
"dvw",
|
|
694
|
-
"dvh",
|
|
695
|
-
// Container query units
|
|
696
|
-
"cqw",
|
|
697
|
-
"cqh",
|
|
698
|
-
"cqi",
|
|
699
|
-
"cqb",
|
|
700
|
-
"cqmin",
|
|
701
|
-
"cqmax",
|
|
702
|
-
// Angle
|
|
703
|
-
"deg",
|
|
704
|
-
"rad",
|
|
705
|
-
"grad",
|
|
706
|
-
"turn",
|
|
707
|
-
// Time
|
|
708
|
-
"s",
|
|
709
|
-
"ms",
|
|
710
|
-
// Resolution
|
|
711
|
-
"dpi",
|
|
712
|
-
"dpcm",
|
|
713
|
-
"dppx",
|
|
714
|
-
// Grid fractional
|
|
715
|
-
"fr",
|
|
716
|
-
"auto"
|
|
717
|
-
];
|
|
718
|
-
|
|
719
|
-
// src/utils/color.js
|
|
720
|
-
init_esm();
|
|
721
|
-
var colorStringToRgbaArray = (color2) => {
|
|
722
|
-
if (color2 === "") return [0, 0, 0, 0];
|
|
723
|
-
if (color2.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
|
724
|
-
if (color2[0] === "#") {
|
|
725
|
-
if (color2.length < 7) {
|
|
726
|
-
color2 = "#" + color2[1] + color2[1] + color2[2] + color2[2] + color2[3] + color2[3] + (color2.length > 4 ? color2[4] + color2[4] : "");
|
|
727
|
-
}
|
|
728
|
-
return [
|
|
729
|
-
parseInt(color2.substr(1, 2), 16),
|
|
730
|
-
parseInt(color2.substr(3, 2), 16),
|
|
731
|
-
parseInt(color2.substr(5, 2), 16),
|
|
732
|
-
color2.length > 7 ? parseInt(color2.substr(7, 2), 16) / 255 : 1
|
|
733
|
-
];
|
|
734
|
-
}
|
|
735
|
-
if (color2.indexOf("rgb") === -1) {
|
|
736
|
-
if (document2 && window2) {
|
|
737
|
-
const elem = document2.body.appendChild(document2.createElement("fictum"));
|
|
738
|
-
const flag = "rgb(1, 2, 3)";
|
|
739
|
-
elem.style.color = flag;
|
|
740
|
-
if (elem.style.color !== flag) {
|
|
741
|
-
document2.body.removeChild(elem);
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
elem.style.color = color2;
|
|
745
|
-
if (elem.style.color === flag || elem.style.color === "") {
|
|
746
|
-
document2.body.removeChild(elem);
|
|
747
|
-
return [0, 0, 0, 0];
|
|
748
|
-
}
|
|
749
|
-
color2 = window2.getComputedStyle(elem).color;
|
|
750
|
-
document2.body.removeChild(elem);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (color2.indexOf("rgb") === 0) {
|
|
754
|
-
if (color2.indexOf("rgba") === -1) color2 = `${color2}, 1`;
|
|
755
|
-
return color2.match(/[\.\d]+/g).map((a) => +a);
|
|
756
|
-
}
|
|
757
|
-
return [0, 0, 0, 0];
|
|
758
|
-
};
|
|
759
|
-
var mixTwoColors = (colorA, colorB, range = 0.5) => {
|
|
760
|
-
colorA = colorStringToRgbaArray(colorA);
|
|
761
|
-
colorB = colorStringToRgbaArray(colorB);
|
|
762
|
-
return mixTwoRgba(colorA, colorB, range);
|
|
763
|
-
};
|
|
764
|
-
var hexToRgb = (hex, alpha = 1) => {
|
|
765
|
-
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
766
|
-
return `rgb(${r},${g},${b})`;
|
|
767
|
-
};
|
|
768
|
-
var hexToRgbArray = (hex, alpha = 1) => {
|
|
769
|
-
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
770
|
-
return [r, g, b];
|
|
771
|
-
};
|
|
772
|
-
var rgbToHex = (r, g, b) => {
|
|
773
|
-
return "#" + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);
|
|
774
|
-
};
|
|
775
|
-
var rgbArrayToHex = ([r, g, b]) => {
|
|
776
|
-
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
777
|
-
};
|
|
778
|
-
var hexToRgba = (hex, alpha = 1) => {
|
|
779
|
-
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
780
|
-
return `rgba(${r},${g},${b},${alpha})`;
|
|
781
|
-
};
|
|
782
|
-
var mixTwoRgb = (colorA, colorB, range = 0.5) => {
|
|
783
|
-
const arr = [];
|
|
784
|
-
for (let i = 0; i < 3; i++) {
|
|
785
|
-
arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range);
|
|
786
|
-
}
|
|
787
|
-
return `rgb(${arr})`;
|
|
788
|
-
};
|
|
789
|
-
var changeLightness = (delta, hsl) => {
|
|
790
|
-
const [hue, saturation, lightness] = hsl;
|
|
791
|
-
const newLightness = Math.max(0, Math.min(100, lightness + parseFloat(delta)));
|
|
792
|
-
return [hue, saturation, newLightness];
|
|
793
|
-
};
|
|
794
|
-
var rgbToHSL = (r, g, b) => {
|
|
795
|
-
const a = Math.max(r, g, b);
|
|
796
|
-
const n = a - Math.min(r, g, b);
|
|
797
|
-
const f = 1 - Math.abs(a + a - n - 1);
|
|
798
|
-
const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
|
|
799
|
-
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
|
|
800
|
-
};
|
|
801
|
-
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)];
|
|
802
|
-
var getColorShade = (col, amt) => {
|
|
803
|
-
const num = parseInt(col, 16);
|
|
804
|
-
let r = (num >> 16) + amt;
|
|
805
|
-
if (r > 255) r = 255;
|
|
806
|
-
else if (r < 0) r = 0;
|
|
807
|
-
let b = (num >> 8 & 255) + amt;
|
|
808
|
-
if (b > 255) b = 255;
|
|
809
|
-
else if (b < 0) b = 0;
|
|
810
|
-
let g = (num & 255) + amt;
|
|
811
|
-
if (g > 255) g = 255;
|
|
812
|
-
else if (g < 0) g = 0;
|
|
813
|
-
return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
|
|
814
|
-
};
|
|
815
|
-
var mixTwoRgba = (colorA, colorB, range = 0.5) => {
|
|
816
|
-
const arr = [];
|
|
817
|
-
for (let i = 0; i < 4; i++) {
|
|
818
|
-
const round = i === 3 ? (x) => x : Math.round;
|
|
819
|
-
arr[i] = round(colorA[i] + (colorB[i] - colorA[i]) * range);
|
|
820
|
-
}
|
|
821
|
-
return `rgba(${arr})`;
|
|
822
|
-
};
|
|
823
|
-
var opacify = (color2, opacity) => {
|
|
824
|
-
const arr = colorStringToRgbaArray(color2);
|
|
825
|
-
if (!arr) {
|
|
826
|
-
if (isNotProduction()) console.warn(color2 + " color is not rgba");
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
arr[3] = opacity;
|
|
830
|
-
return `rgba(${arr})`;
|
|
831
|
-
};
|
|
832
|
-
var isCSSVar = (v) => v.charCodeAt(0) === 45 && v.charCodeAt(1) === 45;
|
|
833
|
-
var CSS_NATIVE_COLOR_REGEX = /(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/;
|
|
834
|
-
var COLOR_TOKEN_REGEX = /^([a-zA-Z]\w*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/;
|
|
835
|
-
var parseColorToken = (value) => {
|
|
836
|
-
if (!isString(value)) return null;
|
|
837
|
-
if (CSS_NATIVE_COLOR_REGEX.test(value)) return { passthrough: value };
|
|
838
|
-
if (isCSSVar(value)) return { cssVar: value };
|
|
839
|
-
const match = value.match(COLOR_TOKEN_REGEX);
|
|
840
|
-
if (!match) return null;
|
|
841
|
-
const [, name, alphaDigits, rawTone] = match;
|
|
842
|
-
const alpha = alphaDigits !== void 0 ? `0.${alphaDigits}` : void 0;
|
|
843
|
-
const tone = rawTone && rawTone[0] === "=" ? rawTone.slice(1) : rawTone;
|
|
844
|
-
return { name, alpha, tone };
|
|
845
|
-
};
|
|
846
|
-
var isResolvedColor = (result) => {
|
|
847
|
-
return isString(result) && (result.includes("rgb") || result.includes("var(") || result.includes("#"));
|
|
848
|
-
};
|
|
849
|
-
var splitTopLevelCommas = (value) => {
|
|
850
|
-
const result = [];
|
|
851
|
-
let current = "";
|
|
852
|
-
let depth = 0;
|
|
853
|
-
for (const char of value) {
|
|
854
|
-
if (char === "(") depth += 1;
|
|
855
|
-
else if (char === ")" && depth > 0) depth -= 1;
|
|
856
|
-
if (char === "," && depth === 0) {
|
|
857
|
-
result.push(current);
|
|
858
|
-
current = "";
|
|
859
|
-
continue;
|
|
860
|
-
}
|
|
861
|
-
current += char;
|
|
862
|
-
}
|
|
863
|
-
if (current.length || !result.length) result.push(current);
|
|
864
|
-
return result;
|
|
865
|
-
};
|
|
866
|
-
var getRgbTone = (rgb, tone) => {
|
|
867
|
-
if (isString(rgb) && rgb.includes("rgb"))
|
|
868
|
-
rgb = colorStringToRgbaArray(rgb).join(", ");
|
|
869
|
-
if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
|
|
870
|
-
if (isNumber(tone)) tone += "";
|
|
871
|
-
const toHex = rgbArrayToHex(rgb);
|
|
872
|
-
const abs = tone.slice(0, 1);
|
|
873
|
-
if (abs === "-" || abs === "+") {
|
|
874
|
-
const colorShade = getColorShade(toHex, parseFloat(tone));
|
|
875
|
-
return hexToRgbArray(colorShade).join(", ");
|
|
876
|
-
} else {
|
|
877
|
-
const [r, g, b] = rgb;
|
|
878
|
-
const hsl = rgbToHSL(r, g, b);
|
|
879
|
-
const [h, s, l] = hsl;
|
|
880
|
-
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
|
|
881
|
-
return newRgb;
|
|
882
|
-
}
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
// src/utils/theme.js
|
|
886
|
-
var returnSubThemeOrDefault = (orig, theme2) => {
|
|
887
|
-
if (!orig) return;
|
|
888
|
-
if (orig.themes && orig.themes[theme2]) return orig.themes[theme2];
|
|
889
|
-
if (orig[theme2]) return [orig, orig[theme2]];
|
|
890
|
-
return orig;
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
// src/utils/font.js
|
|
894
|
-
var resolveFileUrl = (url, files) => {
|
|
895
|
-
if (!url || !files) return null;
|
|
896
|
-
try {
|
|
897
|
-
new URL(url);
|
|
898
|
-
return null;
|
|
899
|
-
} catch (e) {
|
|
900
|
-
}
|
|
901
|
-
const file = files[url];
|
|
902
|
-
if (file) return file.content && file.content.src;
|
|
903
|
-
return null;
|
|
904
|
-
};
|
|
905
|
-
var getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
906
|
-
if (LIBRARY[key]) return LIBRARY[key].value;
|
|
907
|
-
if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
|
|
908
|
-
const hasValue = Object.keys(LIBRARY)[0];
|
|
909
|
-
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
|
|
910
|
-
};
|
|
911
|
-
var getFontFormat = (url) => {
|
|
912
|
-
const ext = url.split(/[#?]/)[0].split(".").pop().trim();
|
|
913
|
-
if (["woff2", "woff", "ttf", "otf", "eot"].includes(ext)) return ext;
|
|
914
|
-
return null;
|
|
915
|
-
};
|
|
916
|
-
var isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") || url.includes("fonts.gstatic.com"));
|
|
917
|
-
var setFontImport = (url) => `@import url('${url}');`;
|
|
918
|
-
var setInCustomFontMedia = (str) => `@font-face { ${str} }`;
|
|
919
|
-
var setCustomFont = (name, url, weight, options = {}) => {
|
|
920
|
-
const urls = Array.isArray(url) ? url : [url];
|
|
921
|
-
const srcList = urls.map((u) => {
|
|
922
|
-
const format = getFontFormat(u);
|
|
923
|
-
const formatStr = format ? ` format('${format}')` : "";
|
|
924
|
-
return `url('${u}')${formatStr}`;
|
|
925
|
-
}).join(",\n ");
|
|
926
|
-
return `
|
|
927
|
-
font-family: '${name}';
|
|
928
|
-
font-style: ${options.fontStyle || "normal"};${weight ? `
|
|
929
|
-
font-weight: ${weight};` : ""}${options.fontStretch ? `
|
|
930
|
-
font-stretch: ${options.fontStretch};` : ""}${options.fontDisplay ? `
|
|
931
|
-
font-display: ${options.fontDisplay};` : ""}
|
|
932
|
-
src: ${srcList};`;
|
|
933
|
-
};
|
|
934
|
-
var setCustomFontMedia = (name, url, weight, options) => `@font-face {${setCustomFont(name, url, weight, options)}
|
|
935
|
-
}`;
|
|
936
|
-
var getFontFaceEach = (name, weights, files) => {
|
|
937
|
-
const keys = Object.keys(weights);
|
|
938
|
-
return keys.map((key) => {
|
|
939
|
-
const { url, fontWeight, fontStyle, fontDisplay, fontStretch } = weights[key];
|
|
940
|
-
const resolvedUrl = Array.isArray(url) ? url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(url, files) || url;
|
|
941
|
-
return setCustomFont(name, resolvedUrl, fontWeight, { fontStyle, fontDisplay, fontStretch });
|
|
942
|
-
});
|
|
943
|
-
};
|
|
944
|
-
var getFontFace = (LIBRARY) => {
|
|
945
|
-
const keys = Object.keys(LIBRARY);
|
|
946
|
-
return keys.map((key) => getFontFaceEach(key, LIBRARY[key].value));
|
|
947
|
-
};
|
|
948
|
-
var getFontFaceEachString = (name, weights, files) => {
|
|
949
|
-
if (weights && weights.isVariable) {
|
|
950
|
-
const url2 = resolveFileUrl(weights.url, files) || weights.url;
|
|
951
|
-
if (isGoogleFontsUrl(url2)) {
|
|
952
|
-
return setFontImport(url2);
|
|
953
|
-
}
|
|
954
|
-
return setCustomFontMedia(name, url2, weights.fontWeight, {
|
|
955
|
-
fontStretch: weights.fontStretch,
|
|
956
|
-
fontDisplay: weights.fontDisplay || "swap"
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
const isArr = weights[0];
|
|
960
|
-
if (isArr) return getFontFaceEach(name, weights, files).map(setInCustomFontMedia);
|
|
961
|
-
const url = Array.isArray(weights.url) ? weights.url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(weights.url, files) || weights.url;
|
|
962
|
-
return setCustomFontMedia(name, url, weights.fontWeight, {
|
|
963
|
-
fontStyle: weights.fontStyle,
|
|
964
|
-
fontDisplay: weights.fontDisplay,
|
|
965
|
-
fontStretch: weights.fontStretch
|
|
966
|
-
});
|
|
967
|
-
};
|
|
968
|
-
var getFontFaceString = (LIBRARY, files) => {
|
|
969
|
-
const keys = Object.keys(LIBRARY);
|
|
970
|
-
return keys.map((key) => getFontFaceEachString(key, LIBRARY[key].value, files));
|
|
971
|
-
};
|
|
972
|
-
|
|
973
|
-
// src/utils/sequence.js
|
|
974
|
-
init_esm();
|
|
975
|
-
|
|
976
|
-
// ../smbls-utils/dist/esm/index.js
|
|
977
|
-
init_esm();
|
|
978
|
-
var toCamelCase = (str) => {
|
|
979
|
-
if (typeof str !== "string") str = String(str || "");
|
|
980
|
-
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
981
|
-
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
982
|
-
}).replace(/\s+/g, "");
|
|
983
|
-
};
|
|
984
|
-
var toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
985
|
-
var arrayzeValue = (val) => {
|
|
986
|
-
if (isArray(val)) return val;
|
|
987
|
-
if (isString(val)) return val.split(" ");
|
|
988
|
-
if (isObject(val)) return Object.values(val);
|
|
989
|
-
if (isNumber(val)) return [val];
|
|
990
|
-
};
|
|
991
|
-
|
|
992
|
-
// src/factory.js
|
|
993
|
-
init_esm();
|
|
994
|
-
|
|
995
|
-
// src/defaultConfig/index.js
|
|
996
|
-
var defaultConfig_exports = {};
|
|
997
|
-
__export(defaultConfig_exports, {
|
|
998
|
-
CLASS: () => CLASS,
|
|
999
|
-
animation: () => animation,
|
|
1000
|
-
breakpoints: () => breakpoints,
|
|
1001
|
-
color: () => color,
|
|
1002
|
-
devices: () => devices,
|
|
1003
|
-
document: () => document3,
|
|
1004
|
-
font: () => font,
|
|
1005
|
-
font_face: () => font_face,
|
|
1006
|
-
font_family: () => font_family,
|
|
1007
|
-
font_family_types: () => font_family_types,
|
|
1008
|
-
gradient: () => gradient,
|
|
1009
|
-
grid: () => grid,
|
|
1010
|
-
icons: () => icons,
|
|
1011
|
-
media: () => media,
|
|
1012
|
-
reset: () => reset,
|
|
1013
|
-
semantic_icons: () => semantic_icons,
|
|
1014
|
-
sequence: () => sequence,
|
|
1015
|
-
shadow: () => shadow,
|
|
1016
|
-
spacing: () => spacing,
|
|
1017
|
-
svg: () => svg,
|
|
1018
|
-
svg_data: () => svg_data,
|
|
1019
|
-
templates: () => templates,
|
|
1020
|
-
theme: () => theme,
|
|
1021
|
-
timing: () => timing,
|
|
1022
|
-
typography: () => typography,
|
|
1023
|
-
unit: () => unit,
|
|
1024
|
-
vars: () => vars
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
|
-
// src/defaultConfig/sequence.js
|
|
1028
|
-
var sequence = {
|
|
1029
|
-
"minor-second": 1.067,
|
|
1030
|
-
"major-second": 1.125,
|
|
1031
|
-
"minor-third": 1.2,
|
|
1032
|
-
"major-third": 1.25,
|
|
1033
|
-
"perfect-fourth": 1.333,
|
|
1034
|
-
"augmented-fourth": 1.414,
|
|
1035
|
-
"perfect-fifth": 1.5,
|
|
1036
|
-
"minor-sixth": 1.6,
|
|
1037
|
-
phi: 1.618,
|
|
1038
|
-
// golden-ratio
|
|
1039
|
-
"major-sixth": 1.667,
|
|
1040
|
-
"square-root-3": 1.732,
|
|
1041
|
-
// theodorus
|
|
1042
|
-
"minor-seventh": 1.778,
|
|
1043
|
-
"major-seventh": 1.875,
|
|
1044
|
-
octave: 2,
|
|
1045
|
-
"square-root-5": 2.23,
|
|
1046
|
-
// pythagoras
|
|
1047
|
-
"major-tenth": 2.5,
|
|
1048
|
-
"major-eleventh": 2.667,
|
|
1049
|
-
"major-twelfth": 3,
|
|
1050
|
-
pi: 3.14,
|
|
1051
|
-
// archimedes
|
|
1052
|
-
"double-octave": 4
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
// src/defaultConfig/unit.js
|
|
1056
|
-
var unit = {
|
|
1057
|
-
default: "em"
|
|
1058
|
-
};
|
|
1059
|
-
|
|
1060
|
-
// src/defaultConfig/typography.js
|
|
1061
|
-
var defaultProps = {
|
|
1062
|
-
browserDefault: 16,
|
|
1063
|
-
base: 16,
|
|
1064
|
-
type: "font-size",
|
|
1065
|
-
ratio: sequence["minor-third"],
|
|
1066
|
-
range: [-3, 12],
|
|
1067
|
-
h1Matches: 6,
|
|
1068
|
-
lineHeight: 1.5,
|
|
1069
|
-
subSequence: true,
|
|
1070
|
-
mediaRegenerate: false,
|
|
1071
|
-
unit: "em",
|
|
1072
|
-
templates: {},
|
|
1073
|
-
sequence: {},
|
|
1074
|
-
scales: {},
|
|
1075
|
-
vars: {}
|
|
1076
|
-
};
|
|
1077
|
-
var typography = defaultProps;
|
|
1078
|
-
|
|
1079
|
-
// src/defaultConfig/font.js
|
|
1080
|
-
var font = {};
|
|
1081
|
-
|
|
1082
|
-
// src/defaultConfig/font-family.js
|
|
1083
|
-
var font_family = {};
|
|
1084
|
-
var font_family_types = {
|
|
1085
|
-
"sans-serif": "Helvetica, Arial, sans-serif, --system-default",
|
|
1086
|
-
serif: "Times New Roman, Georgia, serif, --system-default",
|
|
1087
|
-
monospace: "Courier New, monospace, --system-default"
|
|
1088
|
-
};
|
|
1089
|
-
var font_face = {};
|
|
1090
|
-
|
|
1091
|
-
// src/defaultConfig/media.js
|
|
1092
|
-
var media = {
|
|
1093
|
-
tv: "(min-width: 2780px)",
|
|
1094
|
-
light: "(prefers-color-scheme: light)",
|
|
1095
|
-
dark: "(prefers-color-scheme: dark)",
|
|
1096
|
-
print: "print"
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
// src/defaultConfig/spacing.js
|
|
1100
|
-
var defaultProps2 = {
|
|
1101
|
-
base: typography.base,
|
|
1102
|
-
type: "spacing",
|
|
1103
|
-
ratio: sequence.phi,
|
|
1104
|
-
range: [-5, 15],
|
|
1105
|
-
subSequence: true,
|
|
1106
|
-
mediaRegenerate: false,
|
|
1107
|
-
unit: "em",
|
|
1108
|
-
sequence: {},
|
|
1109
|
-
scales: {},
|
|
1110
|
-
vars: {}
|
|
1111
|
-
};
|
|
1112
|
-
var spacing = defaultProps2;
|
|
1113
|
-
|
|
1114
|
-
// src/defaultConfig/color.js
|
|
1115
|
-
var color = {};
|
|
1116
|
-
var gradient = {};
|
|
1117
|
-
|
|
1118
|
-
// src/defaultConfig/theme.js
|
|
1119
|
-
var theme = {};
|
|
1120
|
-
|
|
1121
|
-
// src/defaultConfig/shadow.js
|
|
1122
|
-
var shadow = {};
|
|
1123
|
-
|
|
1124
|
-
// src/defaultConfig/icons.js
|
|
1125
|
-
var icons = {};
|
|
1126
|
-
var semantic_icons = {};
|
|
1127
|
-
|
|
1128
|
-
// src/defaultConfig/timing.js
|
|
1129
|
-
var defaultProps3 = {
|
|
1130
|
-
default: 150,
|
|
1131
|
-
base: 150,
|
|
1132
|
-
type: "timing",
|
|
1133
|
-
ratio: sequence["perfect-fourth"],
|
|
1134
|
-
range: [-3, 12],
|
|
1135
|
-
mediaRegenerate: false,
|
|
1136
|
-
unit: "ms",
|
|
1137
|
-
sequence: {},
|
|
1138
|
-
scales: {},
|
|
1139
|
-
vars: {}
|
|
1140
|
-
};
|
|
1141
|
-
var timing = defaultProps3;
|
|
1142
|
-
|
|
1143
|
-
// src/defaultConfig/document.js
|
|
1144
|
-
var document3 = {};
|
|
1145
|
-
|
|
1146
|
-
// src/defaultConfig/responsive.js
|
|
1147
|
-
var breakpoints = {
|
|
1148
|
-
screenL: 1920,
|
|
1149
|
-
screenM: 1680,
|
|
1150
|
-
screenS: 1440,
|
|
1151
|
-
tabletL: 1366,
|
|
1152
|
-
tabletM: 1280,
|
|
1153
|
-
tabletS: 1024,
|
|
1154
|
-
mobileL: 768,
|
|
1155
|
-
mobileM: 560,
|
|
1156
|
-
mobileS: 480,
|
|
1157
|
-
mobileXS: 375
|
|
1158
|
-
};
|
|
1159
|
-
var devices = {
|
|
1160
|
-
screenXXL: [2560, 1440],
|
|
1161
|
-
screenXL: [2240, 1260],
|
|
1162
|
-
screenL: [1920, 1024],
|
|
1163
|
-
screenM: [1680, 1024],
|
|
1164
|
-
screenS: [1440, 720],
|
|
1165
|
-
tabletL: [1366, 926],
|
|
1166
|
-
tabletM: [1280, 768],
|
|
1167
|
-
tabletS: [1024, 768],
|
|
1168
|
-
mobileL: [768, 375],
|
|
1169
|
-
mobileM: [560, 768],
|
|
1170
|
-
mobileS: [480, 768],
|
|
1171
|
-
mobileXS: [375, 768]
|
|
1172
|
-
};
|
|
1173
|
-
|
|
1174
|
-
// src/defaultConfig/animation.js
|
|
1175
|
-
var animation = {};
|
|
1176
|
-
|
|
1177
|
-
// src/defaultConfig/svg.js
|
|
1178
|
-
var svg = {};
|
|
1179
|
-
var svg_data = {};
|
|
1180
|
-
|
|
1181
|
-
// src/defaultConfig/templates.js
|
|
1182
|
-
var templates = {};
|
|
1183
|
-
|
|
1184
|
-
// src/defaultConfig/grid.js
|
|
1185
|
-
var defaultProps4 = {};
|
|
1186
|
-
var grid = defaultProps4;
|
|
1187
|
-
|
|
1188
|
-
// src/defaultConfig/class.js
|
|
1189
|
-
var defaultProps5 = {};
|
|
1190
|
-
var CLASS = defaultProps5;
|
|
1191
|
-
|
|
1192
|
-
// src/defaultConfig/index.js
|
|
1193
|
-
var reset = {};
|
|
1194
|
-
var vars = {};
|
|
1195
|
-
|
|
1196
|
-
// src/factory.js
|
|
1197
|
-
var CSS_VARS = {};
|
|
1198
|
-
var CSS_MEDIA_VARS = {};
|
|
1199
|
-
var _CONF = defaultConfig_exports;
|
|
1200
|
-
var _confLower = {};
|
|
1201
|
-
var toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
1202
|
-
var toUpper = (s) => s.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
1203
|
-
for (const key in _CONF) {
|
|
1204
|
-
const lower = key.toLowerCase();
|
|
1205
|
-
_confLower[lower] = _CONF[key];
|
|
1206
|
-
const camel = toCamel(lower);
|
|
1207
|
-
if (camel !== lower) _confLower[camel] = _CONF[key];
|
|
1208
|
-
if (lower !== key) _confLower[key] = _CONF[key];
|
|
1209
|
-
const upper = toUpper(key);
|
|
1210
|
-
if (upper !== key) _confLower[upper] = _CONF[key];
|
|
1211
|
-
}
|
|
1212
|
-
var CONFIG = {
|
|
1213
|
-
verbose: false,
|
|
1214
|
-
useVariable: true,
|
|
1215
|
-
useReset: true,
|
|
1216
|
-
globalTheme: "auto",
|
|
1217
|
-
CSS_VARS,
|
|
1218
|
-
CSS_MEDIA_VARS,
|
|
1219
|
-
..._confLower
|
|
1220
|
-
};
|
|
1221
|
-
var cachedConfig = deepClone(CONFIG);
|
|
1222
|
-
var FACTORY = {
|
|
1223
|
-
active: "0",
|
|
1224
|
-
0: CONFIG
|
|
1225
|
-
};
|
|
1226
|
-
var activateConfig = (def) => {
|
|
1227
|
-
if (isDefined(def)) {
|
|
1228
|
-
FACTORY.active = def;
|
|
1229
|
-
}
|
|
1230
|
-
return FACTORY[def || FACTORY.active];
|
|
1231
|
-
};
|
|
1232
|
-
var getActiveConfig = (def) => {
|
|
1233
|
-
return FACTORY[def || FACTORY.active] || CONFIG;
|
|
1234
|
-
};
|
|
1235
|
-
var setActiveConfig = (newConfig) => {
|
|
1236
|
-
if (!isObject(newConfig)) return;
|
|
1237
|
-
FACTORY.active = "1";
|
|
1238
|
-
FACTORY["1"] = deepMerge(newConfig, deepClone(cachedConfig));
|
|
1239
|
-
return newConfig;
|
|
1240
|
-
};
|
|
1241
|
-
|
|
1242
|
-
// src/utils/sequence.js
|
|
1243
|
-
var numToLetterMap = {
|
|
1244
|
-
"-6": "U",
|
|
1245
|
-
"-5": "V",
|
|
1246
|
-
"-4": "W",
|
|
1247
|
-
"-3": "X",
|
|
1248
|
-
"-2": "Y",
|
|
1249
|
-
"-1": "Z",
|
|
1250
|
-
0: "A",
|
|
1251
|
-
1: "B",
|
|
1252
|
-
2: "C",
|
|
1253
|
-
3: "D",
|
|
1254
|
-
4: "E",
|
|
1255
|
-
5: "F",
|
|
1256
|
-
6: "G",
|
|
1257
|
-
7: "H",
|
|
1258
|
-
8: "I",
|
|
1259
|
-
9: "J",
|
|
1260
|
-
10: "K",
|
|
1261
|
-
11: "L",
|
|
1262
|
-
12: "M",
|
|
1263
|
-
13: "N",
|
|
1264
|
-
14: "O",
|
|
1265
|
-
15: "P",
|
|
1266
|
-
16: "Q",
|
|
1267
|
-
17: "R",
|
|
1268
|
-
18: "S",
|
|
1269
|
-
19: "T"
|
|
1270
|
-
};
|
|
1271
|
-
var setSequenceValue = (props, sequenceProps) => {
|
|
1272
|
-
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
1273
|
-
sequenceProps.sequence[key] = {
|
|
1274
|
-
key,
|
|
1275
|
-
decimal: ~~(value * 100) / 100,
|
|
1276
|
-
val: ~~value,
|
|
1277
|
-
scaling,
|
|
1278
|
-
index,
|
|
1279
|
-
scalingVariable,
|
|
1280
|
-
variable
|
|
1281
|
-
};
|
|
1282
|
-
sequenceProps.scales[key] = scaling;
|
|
1283
|
-
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1284
|
-
};
|
|
1285
|
-
var getFnPrefixAndValue = (val) => {
|
|
1286
|
-
if (!val.includes("(")) return val;
|
|
1287
|
-
const prefix = val.split("(")[0];
|
|
1288
|
-
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
1289
|
-
return [prefix, value];
|
|
1290
|
-
};
|
|
1291
|
-
var setScalingVar = (key, sequenceProps) => {
|
|
1292
|
-
const { base, type, unit: unit2 } = sequenceProps;
|
|
1293
|
-
const defaultVal = (isScalingUnit(unit2) ? 1 : base) + unit2;
|
|
1294
|
-
if (key === 0) return defaultVal;
|
|
1295
|
-
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1296
|
-
const ratioVar = `${prefix}-ratio`;
|
|
1297
|
-
if (key > 0) {
|
|
1298
|
-
const prevLetterKey = numToLetterMap[key - 1];
|
|
1299
|
-
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
1300
|
-
}
|
|
1301
|
-
if (key < 0) {
|
|
1302
|
-
const nextLetterKey = numToLetterMap[key + 1];
|
|
1303
|
-
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
1304
|
-
}
|
|
1305
|
-
};
|
|
1306
|
-
var setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
1307
|
-
const { type } = sequenceProps;
|
|
1308
|
-
const skipMiddle = index === 2 && arr.length === 2;
|
|
1309
|
-
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
1310
|
-
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1311
|
-
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
1312
|
-
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
1313
|
-
};
|
|
1314
|
-
var getSubratioDifference = (base, ratio) => {
|
|
1315
|
-
const diff = base * ratio - base;
|
|
1316
|
-
const subRatio = diff / 1.618;
|
|
1317
|
-
const first = base * ratio - subRatio;
|
|
1318
|
-
const second = base + subRatio;
|
|
1319
|
-
const middle = (first + second) / 2;
|
|
1320
|
-
return [first, middle, second];
|
|
1321
|
-
};
|
|
1322
|
-
var getSubratio = (base, ratio) => {
|
|
1323
|
-
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
1324
|
-
};
|
|
1325
|
-
var generateSubSequence = (props, sequenceProps) => {
|
|
1326
|
-
const { key, base, value, ratio, variable, index } = props;
|
|
1327
|
-
const next = value * ratio;
|
|
1328
|
-
const diffRounded = ~~next - ~~value;
|
|
1329
|
-
let arr;
|
|
1330
|
-
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
1331
|
-
if (diffRounded > 16) arr = [first, middle, second];
|
|
1332
|
-
else arr = [first, second];
|
|
1333
|
-
arr.forEach((v, k) => {
|
|
1334
|
-
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
1335
|
-
const newVar = variable + (k + 1);
|
|
1336
|
-
const newIndex = index + (k + 1) / 10;
|
|
1337
|
-
const scalingVariable = setSubScalingVar(
|
|
1338
|
-
k + 1,
|
|
1339
|
-
arr,
|
|
1340
|
-
variable,
|
|
1341
|
-
sequenceProps
|
|
1342
|
-
);
|
|
1343
|
-
const props2 = {
|
|
1344
|
-
key: key + (k + 1),
|
|
1345
|
-
variable: newVar,
|
|
1346
|
-
value: v,
|
|
1347
|
-
scaling,
|
|
1348
|
-
scalingVariable,
|
|
1349
|
-
index: newIndex
|
|
1350
|
-
};
|
|
1351
|
-
setSequenceValue(props2, sequenceProps);
|
|
1352
|
-
});
|
|
1353
|
-
};
|
|
1354
|
-
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
1355
|
-
return base * Math.pow(ratio, key);
|
|
1356
|
-
};
|
|
1357
|
-
var generateSequence = (sequenceProps) => {
|
|
1358
|
-
const { type, base, ratio, range, subSequence } = sequenceProps;
|
|
1359
|
-
const n = Math.abs(range[0]) + Math.abs(range[1]);
|
|
1360
|
-
const prefix = "--" + (type && type.replace(".", "-")) + "-";
|
|
1361
|
-
for (let i = 0; i <= n; i++) {
|
|
1362
|
-
const key = range[1] - i;
|
|
1363
|
-
const letterKey = numToLetterMap[key];
|
|
1364
|
-
const value = switchSequenceOnNegative(key, base, ratio);
|
|
1365
|
-
const scaling = ~~(value / base * 100) / 100;
|
|
1366
|
-
const variable = prefix + letterKey;
|
|
1367
|
-
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
1368
|
-
const props = {
|
|
1369
|
-
key: letterKey,
|
|
1370
|
-
variable,
|
|
1371
|
-
value,
|
|
1372
|
-
base,
|
|
1373
|
-
scaling,
|
|
1374
|
-
scalingVariable,
|
|
1375
|
-
ratio,
|
|
1376
|
-
index: key
|
|
1377
|
-
};
|
|
1378
|
-
setSequenceValue(props, sequenceProps);
|
|
1379
|
-
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
1380
|
-
}
|
|
1381
|
-
return sequenceProps;
|
|
1382
|
-
};
|
|
1383
|
-
var generateSequencePosition = (sequenceProps, position = 0) => {
|
|
1384
|
-
const { type, base, ratio, subSequence } = sequenceProps;
|
|
1385
|
-
const letterKey = isString(position) ? position : numToLetterMap[position];
|
|
1386
|
-
const index = isString(position) ? Object.entries(numToLetterMap).find(
|
|
1387
|
-
([, value2]) => value2 === position
|
|
1388
|
-
)?.[0] : position;
|
|
1389
|
-
if (!letterKey) {
|
|
1390
|
-
console.warn(`Position ${position} is out of range in numToLetterMap`);
|
|
1391
|
-
return null;
|
|
1392
|
-
}
|
|
1393
|
-
const result = {
|
|
1394
|
-
sequence: {},
|
|
1395
|
-
scales: {},
|
|
1396
|
-
vars: {},
|
|
1397
|
-
...sequenceProps
|
|
1398
|
-
};
|
|
1399
|
-
const value = base * Math.pow(ratio, index);
|
|
1400
|
-
const scaling = ~~(value / base * 100) / 100;
|
|
1401
|
-
const prefix = "--" + (type && type.replace(".", "-")) + "-";
|
|
1402
|
-
const variable = prefix + letterKey;
|
|
1403
|
-
const scalingVariable = setScalingVar(index, sequenceProps);
|
|
1404
|
-
const props = {
|
|
1405
|
-
key: letterKey,
|
|
1406
|
-
variable,
|
|
1407
|
-
value,
|
|
1408
|
-
base,
|
|
1409
|
-
scaling,
|
|
1410
|
-
scalingVariable,
|
|
1411
|
-
ratio,
|
|
1412
|
-
index
|
|
1413
|
-
};
|
|
1414
|
-
setSequenceValue(props, result);
|
|
1415
|
-
if (subSequence) {
|
|
1416
|
-
generateSubSequence(props, result);
|
|
1417
|
-
}
|
|
1418
|
-
return result;
|
|
1419
|
-
};
|
|
1420
|
-
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
1421
|
-
const CONFIG2 = getActiveConfig();
|
|
1422
|
-
const { unit: UNIT } = CONFIG2;
|
|
1423
|
-
if (isString(value) && isCSSVar(value)) return `var(${value})`;
|
|
1424
|
-
const { sequence: sequence2, unit: unit2 = UNIT.default, useVariable } = sequenceProps;
|
|
1425
|
-
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
1426
|
-
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
1427
|
-
const hasUnits = CSS_UNITS.some((unit3) => value.includes(unit3));
|
|
1428
|
-
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
1429
|
-
const skipArr = [
|
|
1430
|
-
"none",
|
|
1431
|
-
"auto",
|
|
1432
|
-
"max-content",
|
|
1433
|
-
"min-content",
|
|
1434
|
-
"fit-content",
|
|
1435
|
-
"inherit",
|
|
1436
|
-
"initial",
|
|
1437
|
-
"unset",
|
|
1438
|
-
"revert",
|
|
1439
|
-
"revert-layer"
|
|
1440
|
-
];
|
|
1441
|
-
if (skipArr.includes(value)) return value;
|
|
1442
|
-
const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
|
|
1443
|
-
const letterVal = value.toUpperCase();
|
|
1444
|
-
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
1445
|
-
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
1446
|
-
let mediaName = "";
|
|
1447
|
-
if (absValue.includes("_")) {
|
|
1448
|
-
mediaName = "_" + absValue.split("_")[1].toLowerCase();
|
|
1449
|
-
absValue = absValue.split("_")[0];
|
|
1450
|
-
}
|
|
1451
|
-
const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
|
|
1452
|
-
if (absValue.includes("+")) {
|
|
1453
|
-
const [first, second] = absValue.split("+");
|
|
1454
|
-
const joint = `${varValue(first)} + ${varValue(second)}`;
|
|
1455
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1456
|
-
} else if (absValue.includes("*")) {
|
|
1457
|
-
const [first, second] = absValue.split("*");
|
|
1458
|
-
const joint = `${varValue(first)} * ${varValue(second)}`;
|
|
1459
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1460
|
-
} else if (absValue.includes("-")) {
|
|
1461
|
-
const [first, second] = absValue.split("-");
|
|
1462
|
-
const joint = `${varValue(first)} - ${varValue(second)}`;
|
|
1463
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
1464
|
-
}
|
|
1465
|
-
if (!sequence2[absValue] && absValue.length === 2) {
|
|
1466
|
-
if (CONFIG2.verbose)
|
|
1467
|
-
console.warn(
|
|
1468
|
-
absValue,
|
|
1469
|
-
"- value is not found because `subSequence` is set to false"
|
|
1470
|
-
);
|
|
1471
|
-
absValue = absValue.slice(0, 1);
|
|
1472
|
-
}
|
|
1473
|
-
if (useVariable || CONFIG2.useVariable) {
|
|
1474
|
-
const varValue2 = `var(${prefix}${absValue}${mediaName})`;
|
|
1475
|
-
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
1476
|
-
}
|
|
1477
|
-
const sequenceItem = sequence2 ? sequence2[absValue] : null;
|
|
1478
|
-
if (!sequenceItem) return console.warn("can't find", sequence2, absValue);
|
|
1479
|
-
if (unit2 === "ms" || unit2 === "s") {
|
|
1480
|
-
return isNegative + sequenceItem.val + unit2;
|
|
1481
|
-
}
|
|
1482
|
-
return isNegative + sequenceItem.scaling + unit2;
|
|
1483
|
-
};
|
|
1484
|
-
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
1485
|
-
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1486
|
-
(v) => value.includes(v + " ")
|
|
1487
|
-
);
|
|
1488
|
-
if (!mathArr.length) return value;
|
|
1489
|
-
return mathArr.map((symbol) => {
|
|
1490
|
-
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
1491
|
-
const transformedValues = valuesArr.map((v) => {
|
|
1492
|
-
return getSequenceValue(v, sequenceProps);
|
|
1493
|
-
});
|
|
1494
|
-
return transformedValues.join(" " + symbol + " ");
|
|
1495
|
-
}).join("");
|
|
1496
|
-
};
|
|
1497
|
-
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
1498
|
-
if (typeof value !== "string") {
|
|
1499
|
-
const CONFIG2 = getActiveConfig();
|
|
1500
|
-
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
1501
|
-
return { [propertyName]: value };
|
|
1502
|
-
}
|
|
1503
|
-
if (value === "-" || value === "") return {};
|
|
1504
|
-
if (!fnPrefix && value.includes("(")) {
|
|
1505
|
-
const fnArr = getFnPrefixAndValue(value);
|
|
1506
|
-
fnPrefix = fnArr[0];
|
|
1507
|
-
value = fnArr[1];
|
|
1508
|
-
}
|
|
1509
|
-
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1510
|
-
(v) => value.includes(v + " ")
|
|
1511
|
-
);
|
|
1512
|
-
if (mathArr.length) {
|
|
1513
|
-
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
1514
|
-
} else value = getSequenceValue(value, sequenceProps);
|
|
1515
|
-
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
1516
|
-
};
|
|
1517
|
-
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
1518
|
-
var findHeadings = (propertyNames) => {
|
|
1519
|
-
const { h1Matches, sequence: sequence2 } = propertyNames;
|
|
1520
|
-
return new Array(6).fill(null).map((_, i) => {
|
|
1521
|
-
const findLetter = findHeadingLetter(h1Matches, i);
|
|
1522
|
-
return sequence2[findLetter];
|
|
1523
|
-
});
|
|
1524
|
-
};
|
|
1525
|
-
|
|
1526
|
-
// src/utils/var.js
|
|
1527
|
-
init_esm();
|
|
1528
|
-
var setVariables = (result, key) => {
|
|
1529
|
-
const CONFIG2 = getActiveConfig();
|
|
1530
|
-
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1531
|
-
if (isObjectLike(result.value)) {
|
|
1532
|
-
} else {
|
|
1533
|
-
CSS_VARS2[result.var] = result.value;
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
var applySequenceGlobalVars = (vars2, obj, options) => {
|
|
1537
|
-
const CONFIG2 = getActiveConfig();
|
|
1538
|
-
const { unit: UNIT } = CONFIG2;
|
|
1539
|
-
const unit2 = obj.unit || UNIT.default;
|
|
1540
|
-
const { base, ratio, type } = obj;
|
|
1541
|
-
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1542
|
-
vars2[`${prefix}-base`] = base;
|
|
1543
|
-
vars2[`${prefix}-unit`] = unit2;
|
|
1544
|
-
const ratioVar = `${prefix}-ratio`;
|
|
1545
|
-
vars2[ratioVar] = ratio;
|
|
1546
|
-
const [first, middle, second] = getSubratio(base, ratio);
|
|
1547
|
-
vars2[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
|
|
1548
|
-
vars2[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
|
|
1549
|
-
vars2[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
|
|
1550
|
-
};
|
|
1551
|
-
var applySequenceVars = (FACTORY2, options = {}) => {
|
|
1552
|
-
const CONFIG2 = getActiveConfig();
|
|
1553
|
-
const { unit: UNIT, timing: TIMING, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1554
|
-
const unit2 = FACTORY2.unit || UNIT.default;
|
|
1555
|
-
const { mediaRegenerate, sequence: sequence2, scales } = FACTORY2;
|
|
1556
|
-
if (!mediaRegenerate) {
|
|
1557
|
-
applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
|
|
1558
|
-
}
|
|
1559
|
-
for (const key in sequence2) {
|
|
1560
|
-
const item = sequence2[key];
|
|
1561
|
-
const value = (FACTORY2.type === TIMING.type ? sequence2[key].val : scales[key]) + unit2;
|
|
1562
|
-
if (!mediaRegenerate) {
|
|
1563
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1564
|
-
CSS_VARS2[item.variable] = item.scalingVariable;
|
|
1565
|
-
continue;
|
|
1566
|
-
}
|
|
1567
|
-
if (options.useDefault === false) {
|
|
1568
|
-
CSS_VARS2[item.variable] = value;
|
|
1569
|
-
} else {
|
|
1570
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1571
|
-
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
var applyMediaSequenceVars = (FACTORY2, media2, options = {}) => {
|
|
1576
|
-
const CONFIG2 = getActiveConfig();
|
|
1577
|
-
const { unit: UNIT, media: MEDIA, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1578
|
-
const mediaName = media2.slice(1);
|
|
1579
|
-
const unit2 = FACTORY2.unit || UNIT.default;
|
|
1580
|
-
const { mediaRegenerate } = FACTORY2;
|
|
1581
|
-
const { sequence: sequence2, scales } = FACTORY2[media2];
|
|
1582
|
-
const query = MEDIA[mediaName];
|
|
1583
|
-
if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
|
|
1584
|
-
if (!mediaRegenerate) {
|
|
1585
|
-
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1586
|
-
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1587
|
-
applySequenceGlobalVars(underMediaQuery, FACTORY2[media2], options);
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
for (const key in sequence2) {
|
|
1591
|
-
const item = sequence2[key];
|
|
1592
|
-
const value = (isScalingUnit(unit2) ? scales[key] : sequence2[key].val) + unit2;
|
|
1593
|
-
if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
|
|
1594
|
-
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1595
|
-
if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1596
|
-
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
1597
|
-
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
1598
|
-
}
|
|
1599
|
-
};
|
|
1600
|
-
|
|
1601
|
-
// src/utils/sprite.js
|
|
1602
|
-
init_esm();
|
|
1603
|
-
var isDev = isNotProduction();
|
|
1604
|
-
var generateSprite = (icons2) => {
|
|
1605
|
-
const CONFIG2 = getActiveConfig();
|
|
1606
|
-
let sprite = "";
|
|
1607
|
-
for (const key in icons2) {
|
|
1608
|
-
if (CONFIG2.__svg_cache[key]) continue;
|
|
1609
|
-
else CONFIG2.__svg_cache[key] = true;
|
|
1610
|
-
sprite += icons2[key];
|
|
1611
|
-
}
|
|
1612
|
-
return sprite;
|
|
1613
|
-
};
|
|
1614
|
-
var parseRootAttributes = (htmlString) => {
|
|
1615
|
-
const val = htmlString.default || htmlString;
|
|
1616
|
-
if (!isString(val)) {
|
|
1617
|
-
if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
const match = val.match(/<svg\s+(.*?)>/);
|
|
1621
|
-
if (!match || !match[1]) {
|
|
1622
|
-
return {};
|
|
1623
|
-
}
|
|
1624
|
-
const attrString = match[1];
|
|
1625
|
-
const attrs = attrString.match(
|
|
1626
|
-
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
1627
|
-
);
|
|
1628
|
-
return attrs.reduce((acc, attr) => {
|
|
1629
|
-
const [key, value] = attr.split("=");
|
|
1630
|
-
acc[key] = value.replace(/['"]/g, "");
|
|
1631
|
-
return acc;
|
|
1632
|
-
}, {});
|
|
1633
|
-
};
|
|
1634
|
-
var replaceIdsAndUrls = (code, key) => {
|
|
1635
|
-
const idRegex = /id="([^"]*)"/;
|
|
1636
|
-
const urlRegex = /url\(#([^)]*)\)/g;
|
|
1637
|
-
const matches = code.match(/id="([^"]*)"/g);
|
|
1638
|
-
let replacedCode = code;
|
|
1639
|
-
if (isArray(matches)) {
|
|
1640
|
-
matches.forEach(() => {
|
|
1641
|
-
const randomKey = Math.floor(Math.random() * 1e5);
|
|
1642
|
-
replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`);
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
return replacedCode;
|
|
1646
|
-
};
|
|
1647
|
-
var convertSvgToSymbol = (key, code) => {
|
|
1648
|
-
const extractAttrs = parseRootAttributes(code);
|
|
1649
|
-
const { width, height } = extractAttrs;
|
|
1650
|
-
const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`;
|
|
1651
|
-
const xmlns = "http://www.w3.org/2000/svg";
|
|
1652
|
-
const replacedCode = replaceIdsAndUrls(code, key);
|
|
1653
|
-
let symbol = replacedCode.replace(
|
|
1654
|
-
"<svg",
|
|
1655
|
-
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
1656
|
-
);
|
|
1657
|
-
symbol = symbol.replace(/width="[^"]*"/, "");
|
|
1658
|
-
symbol = symbol.replace(/height="[^"]*"/, "");
|
|
1659
|
-
symbol = symbol.replace("</svg", "</symbol");
|
|
1660
|
-
return symbol;
|
|
1661
|
-
};
|
|
1662
|
-
|
|
1663
|
-
// src/system/index.js
|
|
1664
|
-
var system_exports = {};
|
|
1665
|
-
__export(system_exports, {
|
|
1666
|
-
appendSVGSprite: () => appendSVGSprite,
|
|
1667
|
-
appendSvgIconsSprite: () => appendSvgIconsSprite,
|
|
1668
|
-
applyDocument: () => applyDocument,
|
|
1669
|
-
applyHeadings: () => applyHeadings,
|
|
1670
|
-
applyReset: () => applyReset,
|
|
1671
|
-
applySpacingSequence: () => applySpacingSequence,
|
|
1672
|
-
applyTimingSequence: () => applyTimingSequence,
|
|
1673
|
-
applyTypographySequence: () => applyTypographySequence,
|
|
1674
|
-
checkIfBoxSize: () => checkIfBoxSize,
|
|
1675
|
-
getColor: () => getColor,
|
|
1676
|
-
getFontFamily: () => getFontFamily,
|
|
1677
|
-
getFontSizeByKey: () => getFontSizeByKey,
|
|
1678
|
-
getMediaColor: () => getMediaColor,
|
|
1679
|
-
getMediaTheme: () => getMediaTheme,
|
|
1680
|
-
getShadow: () => getShadow,
|
|
1681
|
-
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
1682
|
-
getSpacingByKey: () => getSpacingByKey,
|
|
1683
|
-
getTheme: () => getTheme,
|
|
1684
|
-
getTimingByKey: () => getTimingByKey,
|
|
1685
|
-
getTimingFunction: () => getTimingFunction,
|
|
1686
|
-
runThroughMedia: () => runThroughMedia,
|
|
1687
|
-
setColor: () => setColor,
|
|
1688
|
-
setFont: () => setFont,
|
|
1689
|
-
setFontFamily: () => setFontFamily,
|
|
1690
|
-
setGradient: () => setGradient,
|
|
1691
|
-
setMediaTheme: () => setMediaTheme,
|
|
1692
|
-
setSVG: () => setSVG,
|
|
1693
|
-
setShadow: () => setShadow,
|
|
1694
|
-
setSvgIcon: () => setSvgIcon,
|
|
1695
|
-
setTheme: () => setTheme,
|
|
1696
|
-
splitSpacedValue: () => splitSpacedValue
|
|
1697
|
-
});
|
|
1698
|
-
|
|
1699
|
-
// src/system/color.js
|
|
1700
|
-
init_esm();
|
|
1701
|
-
var getColor = (value, key, config) => {
|
|
1702
|
-
const CONFIG2 = config || getActiveConfig();
|
|
1703
|
-
if (!isString(value)) {
|
|
1704
|
-
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
1705
|
-
return;
|
|
1706
|
-
}
|
|
1707
|
-
if (isCSSVar(value)) return `var(${value})`;
|
|
1708
|
-
if (key && value[key]) value = value[key];
|
|
1709
|
-
let name, alpha, tone;
|
|
1710
|
-
if (isArray(value)) {
|
|
1711
|
-
[name, alpha, tone] = value;
|
|
1712
|
-
} else {
|
|
1713
|
-
const parsed = parseColorToken(value);
|
|
1714
|
-
if (!parsed) {
|
|
1715
|
-
const { color: COLOR2, gradient: GRADIENT2 } = CONFIG2;
|
|
1716
|
-
const directVal = GRADIENT2[value] || COLOR2[value];
|
|
1717
|
-
if (directVal) return CONFIG2.useVariable ? `var(${directVal.var})` : directVal.value;
|
|
1718
|
-
return value;
|
|
1719
|
-
}
|
|
1720
|
-
if (parsed.passthrough) return parsed.passthrough;
|
|
1721
|
-
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
1722
|
-
name = parsed.name;
|
|
1723
|
-
alpha = parsed.alpha;
|
|
1724
|
-
tone = parsed.tone;
|
|
1725
|
-
}
|
|
1726
|
-
const { color: COLOR, gradient: GRADIENT } = CONFIG2;
|
|
1727
|
-
let val = COLOR[name] || GRADIENT[name];
|
|
1728
|
-
if (!val) {
|
|
1729
|
-
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
1730
|
-
return value;
|
|
1731
|
-
}
|
|
1732
|
-
if (key) {
|
|
1733
|
-
if (val[key]) val = val[key];
|
|
1734
|
-
else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
|
|
1735
|
-
}
|
|
1736
|
-
let rgb = val.rgb;
|
|
1737
|
-
if (!rgb) {
|
|
1738
|
-
return CONFIG2.useVariable ? `var(${val.var})` : val.value;
|
|
1739
|
-
}
|
|
1740
|
-
if (tone && !val[tone]) {
|
|
1741
|
-
rgb = getRgbTone(rgb, tone);
|
|
1742
|
-
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
1743
|
-
}
|
|
1744
|
-
if (val[tone]) rgb = val[tone].rgb;
|
|
1745
|
-
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
1746
|
-
if (tone) return `rgba(${rgb}, 1)`;
|
|
1747
|
-
return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
1748
|
-
};
|
|
1749
|
-
var getMediaColor = (value, globalTheme, config) => {
|
|
1750
|
-
const CONFIG2 = config || getActiveConfig();
|
|
1751
|
-
if (!globalTheme) globalTheme = CONFIG2.globalTheme === "auto" ? null : CONFIG2.globalTheme;
|
|
1752
|
-
if (!isString(value)) {
|
|
1753
|
-
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
1754
|
-
return;
|
|
1755
|
-
}
|
|
1756
|
-
if (isCSSVar(value)) return `var(${value})`;
|
|
1757
|
-
let name;
|
|
1758
|
-
if (isArray(value)) {
|
|
1759
|
-
name = value[0];
|
|
1760
|
-
} else {
|
|
1761
|
-
const parsed = parseColorToken(value);
|
|
1762
|
-
if (!parsed) return value;
|
|
1763
|
-
if (parsed.passthrough) return parsed.passthrough;
|
|
1764
|
-
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
1765
|
-
name = parsed.name;
|
|
1766
|
-
}
|
|
1767
|
-
const { color: COLOR, gradient: GRADIENT } = CONFIG2;
|
|
1768
|
-
const val = COLOR[name] || GRADIENT[name];
|
|
1769
|
-
const isObj = isObject(val);
|
|
1770
|
-
if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
|
|
1771
|
-
else if (isObj) {
|
|
1772
|
-
if (globalTheme) return getColor(value, `@${globalTheme}`, config);
|
|
1773
|
-
else {
|
|
1774
|
-
const obj = {};
|
|
1775
|
-
for (const mediaName in val) {
|
|
1776
|
-
const query = CONFIG2.media[mediaName.slice(1)];
|
|
1777
|
-
const media2 = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
1778
|
-
obj[media2] = getColor(value, mediaName, config);
|
|
1779
|
-
}
|
|
1780
|
-
return obj;
|
|
1781
|
-
}
|
|
1782
|
-
} else {
|
|
1783
|
-
if (CONFIG2.verbose) console.warn("Can't find color", value);
|
|
1784
|
-
return value;
|
|
1785
|
-
}
|
|
1786
|
-
};
|
|
1787
|
-
var setColor = (val, key, suffix) => {
|
|
1788
|
-
const CONFIG2 = getActiveConfig();
|
|
1789
|
-
if (isString(val) && isCSSVar(val)) {
|
|
1790
|
-
const rawRef = val.slice(2);
|
|
1791
|
-
val = getColor(rawRef);
|
|
1792
|
-
if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
|
|
1793
|
-
const parts = rawRef.split(" ");
|
|
1794
|
-
const refColor = CONFIG2.color[parts[0]];
|
|
1795
|
-
if (refColor && refColor.value) {
|
|
1796
|
-
let rgb2 = refColor.rgb;
|
|
1797
|
-
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
1798
|
-
const tone = parts[2];
|
|
1799
|
-
if (tone) {
|
|
1800
|
-
rgb2 = getRgbTone(rgb2, tone);
|
|
1801
|
-
}
|
|
1802
|
-
val = `rgba(${rgb2}, ${alpha2})`;
|
|
1803
|
-
} else {
|
|
1804
|
-
const tone = parts[2];
|
|
1805
|
-
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
1806
|
-
if (tone) {
|
|
1807
|
-
try {
|
|
1808
|
-
const rgb2 = colorStringToRgbaArray(parts[0]);
|
|
1809
|
-
if (rgb2 && rgb2.length >= 3) {
|
|
1810
|
-
const tonedRgb = getRgbTone(rgb2.slice(0, 3).join(", "), tone);
|
|
1811
|
-
val = `rgba(${tonedRgb}, ${alpha2})`;
|
|
1812
|
-
} else {
|
|
1813
|
-
val = parts[0];
|
|
1814
|
-
}
|
|
1815
|
-
} catch (e) {
|
|
1816
|
-
val = parts[0];
|
|
1817
|
-
}
|
|
1818
|
-
} else {
|
|
1819
|
-
val = parts[0];
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
if (isArray(val)) {
|
|
1825
|
-
return {
|
|
1826
|
-
"@light": setColor(val[0], key, "light"),
|
|
1827
|
-
"@dark": setColor(val[1], key, "dark")
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
if (isObject(val)) {
|
|
1831
|
-
const obj = {};
|
|
1832
|
-
for (const variant in val) {
|
|
1833
|
-
obj[variant] = setColor(
|
|
1834
|
-
val[variant],
|
|
1835
|
-
key,
|
|
1836
|
-
variant.slice(0, 1) === "@" ? variant.slice(1) : variant
|
|
1837
|
-
);
|
|
1838
|
-
}
|
|
1839
|
-
return obj;
|
|
1840
|
-
}
|
|
1841
|
-
const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
|
|
1842
|
-
const colorArr = colorStringToRgbaArray(val.value || val);
|
|
1843
|
-
const [r, g, b, a = 1] = colorArr;
|
|
1844
|
-
const alpha = parseFloat(a.toFixed(2));
|
|
1845
|
-
const rgb = `${r}, ${g}, ${b}`;
|
|
1846
|
-
const value = `rgba(${rgb}, ${alpha})`;
|
|
1847
|
-
if (CONFIG2.useVariable) {
|
|
1848
|
-
CONFIG2.CSS_VARS[CSSVar] = value;
|
|
1849
|
-
}
|
|
1850
|
-
return {
|
|
1851
|
-
var: CSSVar,
|
|
1852
|
-
rgb,
|
|
1853
|
-
alpha,
|
|
1854
|
-
value
|
|
1855
|
-
};
|
|
1856
|
-
};
|
|
1857
|
-
var setGradient = (val, key, suffix) => {
|
|
1858
|
-
const CONFIG2 = getActiveConfig();
|
|
1859
|
-
if (isString(val) && isCSSVar(val)) val = getColor(val.slice(2));
|
|
1860
|
-
if (isArray(val)) {
|
|
1861
|
-
return {
|
|
1862
|
-
"@light": setGradient(val[0], key, "light"),
|
|
1863
|
-
"@dark": setGradient(val[0], key, "dark")
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
if (isObject(val)) {
|
|
1867
|
-
const obj = {};
|
|
1868
|
-
for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
1869
|
-
return obj;
|
|
1870
|
-
}
|
|
1871
|
-
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
|
|
1872
|
-
if (CONFIG2.useVariable) {
|
|
1873
|
-
CONFIG2.CSS_VARS[CSSVar] = val.value || val;
|
|
1874
|
-
}
|
|
1875
|
-
return {
|
|
1876
|
-
var: CSSVar,
|
|
1877
|
-
value: val.value || val
|
|
1878
|
-
};
|
|
1879
|
-
};
|
|
1880
|
-
|
|
1881
|
-
// src/system/theme.js
|
|
1882
|
-
init_esm();
|
|
1883
|
-
var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
1884
|
-
"black",
|
|
1885
|
-
"white",
|
|
1886
|
-
"red",
|
|
1887
|
-
"green",
|
|
1888
|
-
"blue",
|
|
1889
|
-
"yellow",
|
|
1890
|
-
"orange",
|
|
1891
|
-
"purple",
|
|
1892
|
-
"pink",
|
|
1893
|
-
"brown",
|
|
1894
|
-
"gray",
|
|
1895
|
-
"grey",
|
|
1896
|
-
"cyan",
|
|
1897
|
-
"magenta",
|
|
1898
|
-
"lime",
|
|
1899
|
-
"olive",
|
|
1900
|
-
"navy",
|
|
1901
|
-
"teal",
|
|
1902
|
-
"aqua",
|
|
1903
|
-
"maroon",
|
|
1904
|
-
"silver",
|
|
1905
|
-
"fuchsia",
|
|
1906
|
-
"transparent",
|
|
1907
|
-
"currentColor",
|
|
1908
|
-
"currentcolor",
|
|
1909
|
-
"inherit",
|
|
1910
|
-
"initial",
|
|
1911
|
-
"unset",
|
|
1912
|
-
"none",
|
|
1913
|
-
"aliceblue",
|
|
1914
|
-
"antiquewhite",
|
|
1915
|
-
"aquamarine",
|
|
1916
|
-
"azure",
|
|
1917
|
-
"beige",
|
|
1918
|
-
"bisque",
|
|
1919
|
-
"blanchedalmond",
|
|
1920
|
-
"blueviolet",
|
|
1921
|
-
"burlywood",
|
|
1922
|
-
"cadetblue",
|
|
1923
|
-
"chartreuse",
|
|
1924
|
-
"chocolate",
|
|
1925
|
-
"coral",
|
|
1926
|
-
"cornflowerblue",
|
|
1927
|
-
"cornsilk",
|
|
1928
|
-
"crimson",
|
|
1929
|
-
"darkblue",
|
|
1930
|
-
"darkcyan",
|
|
1931
|
-
"darkgoldenrod",
|
|
1932
|
-
"darkgray",
|
|
1933
|
-
"darkgreen",
|
|
1934
|
-
"darkgrey",
|
|
1935
|
-
"darkkhaki",
|
|
1936
|
-
"darkmagenta",
|
|
1937
|
-
"darkolivegreen",
|
|
1938
|
-
"darkorange",
|
|
1939
|
-
"darkorchid",
|
|
1940
|
-
"darkred",
|
|
1941
|
-
"darksalmon",
|
|
1942
|
-
"darkseagreen",
|
|
1943
|
-
"darkslateblue",
|
|
1944
|
-
"darkslategray",
|
|
1945
|
-
"darkslategrey",
|
|
1946
|
-
"darkturquoise",
|
|
1947
|
-
"darkviolet",
|
|
1948
|
-
"deeppink",
|
|
1949
|
-
"deepskyblue",
|
|
1950
|
-
"dimgray",
|
|
1951
|
-
"dimgrey",
|
|
1952
|
-
"dodgerblue",
|
|
1953
|
-
"firebrick",
|
|
1954
|
-
"floralwhite",
|
|
1955
|
-
"forestgreen",
|
|
1956
|
-
"gainsboro",
|
|
1957
|
-
"ghostwhite",
|
|
1958
|
-
"gold",
|
|
1959
|
-
"goldenrod",
|
|
1960
|
-
"greenyellow",
|
|
1961
|
-
"honeydew",
|
|
1962
|
-
"hotpink",
|
|
1963
|
-
"indianred",
|
|
1964
|
-
"indigo",
|
|
1965
|
-
"ivory",
|
|
1966
|
-
"khaki",
|
|
1967
|
-
"lavender",
|
|
1968
|
-
"lavenderblush",
|
|
1969
|
-
"lawngreen",
|
|
1970
|
-
"lemonchiffon",
|
|
1971
|
-
"lightblue",
|
|
1972
|
-
"lightcoral",
|
|
1973
|
-
"lightcyan",
|
|
1974
|
-
"lightgoldenrodyellow",
|
|
1975
|
-
"lightgray",
|
|
1976
|
-
"lightgreen",
|
|
1977
|
-
"lightgrey",
|
|
1978
|
-
"lightpink",
|
|
1979
|
-
"lightsalmon",
|
|
1980
|
-
"lightseagreen",
|
|
1981
|
-
"lightskyblue",
|
|
1982
|
-
"lightslategray",
|
|
1983
|
-
"lightslategrey",
|
|
1984
|
-
"lightsteelblue",
|
|
1985
|
-
"lightyellow",
|
|
1986
|
-
"limegreen",
|
|
1987
|
-
"linen",
|
|
1988
|
-
"mediumaquamarine",
|
|
1989
|
-
"mediumblue",
|
|
1990
|
-
"mediumorchid",
|
|
1991
|
-
"mediumpurple",
|
|
1992
|
-
"mediumseagreen",
|
|
1993
|
-
"mediumslateblue",
|
|
1994
|
-
"mediumspringgreen",
|
|
1995
|
-
"mediumturquoise",
|
|
1996
|
-
"mediumvioletred",
|
|
1997
|
-
"midnightblue",
|
|
1998
|
-
"mintcream",
|
|
1999
|
-
"mistyrose",
|
|
2000
|
-
"moccasin",
|
|
2001
|
-
"navajowhite",
|
|
2002
|
-
"oldlace",
|
|
2003
|
-
"olivedrab",
|
|
2004
|
-
"orangered",
|
|
2005
|
-
"orchid",
|
|
2006
|
-
"palegoldenrod",
|
|
2007
|
-
"palegreen",
|
|
2008
|
-
"paleturquoise",
|
|
2009
|
-
"palevioletred",
|
|
2010
|
-
"papayawhip",
|
|
2011
|
-
"peachpuff",
|
|
2012
|
-
"peru",
|
|
2013
|
-
"plum",
|
|
2014
|
-
"powderblue",
|
|
2015
|
-
"rosybrown",
|
|
2016
|
-
"royalblue",
|
|
2017
|
-
"saddlebrown",
|
|
2018
|
-
"salmon",
|
|
2019
|
-
"sandybrown",
|
|
2020
|
-
"seagreen",
|
|
2021
|
-
"seashell",
|
|
2022
|
-
"sienna",
|
|
2023
|
-
"skyblue",
|
|
2024
|
-
"slateblue",
|
|
2025
|
-
"slategray",
|
|
2026
|
-
"slategrey",
|
|
2027
|
-
"snow",
|
|
2028
|
-
"springgreen",
|
|
2029
|
-
"steelblue",
|
|
2030
|
-
"tan",
|
|
2031
|
-
"thistle",
|
|
2032
|
-
"tomato",
|
|
2033
|
-
"turquoise",
|
|
2034
|
-
"violet",
|
|
2035
|
-
"wheat",
|
|
2036
|
-
"whitesmoke",
|
|
2037
|
-
"yellowgreen",
|
|
2038
|
-
"rebeccapurple"
|
|
2039
|
-
]);
|
|
2040
|
-
var setThemeValue = (theme2) => {
|
|
2041
|
-
const value = {};
|
|
2042
|
-
const { state, media: media2, helpers, ...rest } = theme2;
|
|
2043
|
-
const keys = Object.keys(rest);
|
|
2044
|
-
keys.map((key) => {
|
|
2045
|
-
const conditions = ["color", "Color", "background", "border"];
|
|
2046
|
-
const isColor = conditions.some((k) => key.includes(k));
|
|
2047
|
-
return value[key] = isColor ? getColor(theme2[key]) : theme2[key];
|
|
2048
|
-
});
|
|
2049
|
-
return value;
|
|
2050
|
-
};
|
|
2051
|
-
var getThemeValue = (theme2) => {
|
|
2052
|
-
if (theme2.value) return theme2.value;
|
|
2053
|
-
theme2.value = setThemeValue(theme2);
|
|
2054
|
-
return theme2.value;
|
|
2055
|
-
};
|
|
2056
|
-
var getTheme = (value, modifier) => {
|
|
2057
|
-
const CONFIG2 = getActiveConfig();
|
|
2058
|
-
if (CONFIG2.useVariable) return getMediaTheme(value, modifier);
|
|
2059
|
-
const THEME = CONFIG2.theme;
|
|
2060
|
-
if (isString(value)) {
|
|
2061
|
-
const [theme2, subtheme] = value.split(" ");
|
|
2062
|
-
const isOurTheme = THEME[theme2];
|
|
2063
|
-
if (isOurTheme) {
|
|
2064
|
-
if (!subtheme && !modifier) return getThemeValue(isOurTheme);
|
|
2065
|
-
value = [theme2, subtheme || modifier];
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
if (isObjectLike(value) && value[1]) {
|
|
2069
|
-
const themeName = value[0];
|
|
2070
|
-
const subThemeName = value[1];
|
|
2071
|
-
const { helpers, media: media2, state } = THEME[themeName];
|
|
2072
|
-
if (media2 && media2[subThemeName]) return getThemeValue(media2[subThemeName]);
|
|
2073
|
-
if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
|
|
2074
|
-
if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
|
|
2075
|
-
} else if (isObject(value)) return setThemeValue(value);
|
|
2076
|
-
};
|
|
2077
|
-
var setInverseTheme = (theme2, variant, value) => {
|
|
2078
|
-
if (isObject(variant)) {
|
|
2079
|
-
theme2.variants.inverse.value = setThemeValue(variant);
|
|
2080
|
-
} else if (variant === true) {
|
|
2081
|
-
const { color: color2, background } = value;
|
|
2082
|
-
theme2.variants.inverse = {
|
|
2083
|
-
value: {
|
|
2084
|
-
color: background,
|
|
2085
|
-
background: color2
|
|
2086
|
-
}
|
|
2087
|
-
};
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
var setPseudo = (theme2, key, variant, themeValue) => {
|
|
2091
|
-
const result = getTheme(variant);
|
|
2092
|
-
themeValue[`&:${key}`] = result;
|
|
2093
|
-
if (isObject(variant) && !variant.value) variant.value = result;
|
|
2094
|
-
};
|
|
2095
|
-
var setSelectors = (theme2, value) => {
|
|
2096
|
-
const { state } = theme2;
|
|
2097
|
-
if (!state) return;
|
|
2098
|
-
const keys = Object.keys(state);
|
|
2099
|
-
keys.map((key) => {
|
|
2100
|
-
const variant = state[key];
|
|
2101
|
-
setPseudo(theme2, key, variant, value);
|
|
2102
|
-
return theme2;
|
|
2103
|
-
});
|
|
2104
|
-
return theme2;
|
|
2105
|
-
};
|
|
2106
|
-
var setPrefersScheme = (theme2, key, variant, themeValue) => {
|
|
2107
|
-
const result = getTheme(variant);
|
|
2108
|
-
themeValue[`@media (prefers-color-scheme: ${key})`] = result;
|
|
2109
|
-
if (isObject(variant) && !variant.value) variant.value = result;
|
|
2110
|
-
};
|
|
2111
|
-
var setMedia = (theme2, value) => {
|
|
2112
|
-
const { media: media2 } = theme2;
|
|
2113
|
-
if (!media2) return;
|
|
2114
|
-
const keys = Object.keys(media2);
|
|
2115
|
-
keys.map((key) => {
|
|
2116
|
-
const variant = media2[key];
|
|
2117
|
-
if (key === "dark" || key === "light") setPrefersScheme(theme2, key, variant, value);
|
|
2118
|
-
if (key === "inverse") setInverseTheme(theme2, variant, value);
|
|
2119
|
-
return theme2;
|
|
2120
|
-
});
|
|
2121
|
-
return theme2;
|
|
2122
|
-
};
|
|
2123
|
-
var setHelpers = (theme2, value) => {
|
|
2124
|
-
const CONFIG2 = getActiveConfig();
|
|
2125
|
-
const { helpers } = theme2;
|
|
2126
|
-
if (!helpers) return;
|
|
2127
|
-
const keys = Object.keys(helpers);
|
|
2128
|
-
keys.map((key) => {
|
|
2129
|
-
const helper = helpers[key];
|
|
2130
|
-
if (isString(helper)) helpers[key] = CONFIG2.theme[helper];
|
|
2131
|
-
else getThemeValue(helpers[key]);
|
|
2132
|
-
return theme2;
|
|
2133
|
-
});
|
|
2134
|
-
return theme2;
|
|
2135
|
-
};
|
|
2136
|
-
var setTheme = (val, key) => {
|
|
2137
|
-
const CONFIG2 = getActiveConfig();
|
|
2138
|
-
if (CONFIG2.useVariable) return setMediaTheme(val, key);
|
|
2139
|
-
const { state, media: media2, helpers } = val;
|
|
2140
|
-
const value = setThemeValue(val, key);
|
|
2141
|
-
const CSSvar = `--theme-${key}`;
|
|
2142
|
-
setSelectors(val, value);
|
|
2143
|
-
setMedia(val, value);
|
|
2144
|
-
setHelpers(val, value);
|
|
2145
|
-
return { var: CSSvar, value, state, media: media2, helpers };
|
|
2146
|
-
};
|
|
2147
|
-
var generateAutoVars = (schemes, varPrefix, CONFIG2) => {
|
|
2148
|
-
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
2149
|
-
if (!CONFIG2.CSS_MEDIA_VARS) CONFIG2.CSS_MEDIA_VARS = {};
|
|
2150
|
-
const MEDIA_VARS = CONFIG2.CSS_MEDIA_VARS;
|
|
2151
|
-
const globalTheme = CONFIG2.globalTheme !== void 0 ? CONFIG2.globalTheme : "auto";
|
|
2152
|
-
const result = {};
|
|
2153
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
2154
|
-
for (const scheme in schemes) {
|
|
2155
|
-
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
2156
|
-
}
|
|
2157
|
-
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
2158
|
-
if (globalTheme === "auto") {
|
|
2159
|
-
for (const param of allKeys) {
|
|
2160
|
-
const symb = param.slice(0, 1);
|
|
2161
|
-
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
2162
|
-
for (const scheme in schemes) {
|
|
2163
|
-
if (brokenSchemes.has(scheme)) continue;
|
|
2164
|
-
const val = schemes[scheme]?.[param];
|
|
2165
|
-
if (val === void 0) continue;
|
|
2166
|
-
const color2 = getColor(val, `@${scheme}`);
|
|
2167
|
-
if (color2 === void 0) continue;
|
|
2168
|
-
if (isString(color2) && /^[a-z][a-zA-Z]+$/.test(color2) && !CSS_NAMED_COLORS.has(color2)) {
|
|
2169
|
-
brokenSchemes.add(scheme);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
for (const param of allKeys) {
|
|
2175
|
-
const symb = param.slice(0, 1);
|
|
2176
|
-
const hasObject = Object.values(schemes).some((s) => isObjectLike(s?.[param]));
|
|
2177
|
-
if (symb === "." && hasObject) {
|
|
2178
|
-
const helperName = param.slice(1);
|
|
2179
|
-
const subSchemes = {};
|
|
2180
|
-
for (const scheme in schemes) {
|
|
2181
|
-
if (isObjectLike(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
|
|
2182
|
-
}
|
|
2183
|
-
result[param] = generateAutoVars(subSchemes, `${varPrefix}-${helperName}`, CONFIG2);
|
|
2184
|
-
} else if (symb === ":" && hasObject) {
|
|
2185
|
-
const pseudoName = param.replace(/^:+/, "");
|
|
2186
|
-
const subSchemes = {};
|
|
2187
|
-
for (const scheme in schemes) {
|
|
2188
|
-
if (isObjectLike(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
|
|
2189
|
-
}
|
|
2190
|
-
result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG2);
|
|
2191
|
-
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
2192
|
-
const autoVar = `--theme-${varPrefix}-${param}`;
|
|
2193
|
-
if (globalTheme === "auto") {
|
|
2194
|
-
let fallbackColor;
|
|
2195
|
-
for (const scheme in schemes) {
|
|
2196
|
-
if (brokenSchemes.has(scheme)) continue;
|
|
2197
|
-
const val = schemes[scheme]?.[param];
|
|
2198
|
-
if (val === void 0) continue;
|
|
2199
|
-
const color2 = getColor(val, `@${scheme}`);
|
|
2200
|
-
if (color2 === void 0) continue;
|
|
2201
|
-
if (scheme === "light" || fallbackColor === void 0) {
|
|
2202
|
-
fallbackColor = color2;
|
|
2203
|
-
}
|
|
2204
|
-
const selector = `[data-theme="${scheme}"]`;
|
|
2205
|
-
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
2206
|
-
MEDIA_VARS[selector][autoVar] = color2;
|
|
2207
|
-
if (scheme === "dark" || scheme === "light") {
|
|
2208
|
-
const mq = `@media (prefers-color-scheme: ${scheme})`;
|
|
2209
|
-
if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
|
|
2210
|
-
MEDIA_VARS[mq][autoVar] = color2;
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
if (fallbackColor !== void 0) {
|
|
2214
|
-
CSS_VARS2[autoVar] = fallbackColor;
|
|
2215
|
-
}
|
|
2216
|
-
} else {
|
|
2217
|
-
const forced = String(globalTheme).replace(/^'|'$/g, "");
|
|
2218
|
-
const source = schemes[forced]?.[param];
|
|
2219
|
-
if (source !== void 0) {
|
|
2220
|
-
const color2 = getColor(source, `@${forced}`);
|
|
2221
|
-
if (color2 !== void 0) CSS_VARS2[autoVar] = color2;
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
result[param] = `var(${autoVar})`;
|
|
2225
|
-
result[`.${param}`] = { [param]: result[param] };
|
|
2226
|
-
}
|
|
2227
|
-
}
|
|
2228
|
-
if (result.background || result.color || result.backgroundColor) {
|
|
2229
|
-
result[".inversed"] = {
|
|
2230
|
-
color: result.background || result.backgroundColor,
|
|
2231
|
-
background: result.color
|
|
2232
|
-
};
|
|
2233
|
-
}
|
|
2234
|
-
return result;
|
|
2235
|
-
};
|
|
2236
|
-
var setMediaTheme = (val, key, suffix, prefers) => {
|
|
2237
|
-
const CONFIG2 = getActiveConfig();
|
|
2238
|
-
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
2239
|
-
const theme2 = { value: val };
|
|
2240
|
-
const isTopLevel = !suffix && !prefers;
|
|
2241
|
-
if (isObjectLike(val)) {
|
|
2242
|
-
if (isTopLevel && CONFIG2.useVariable) {
|
|
2243
|
-
const schemes = {};
|
|
2244
|
-
for (const param in val) {
|
|
2245
|
-
if (param.startsWith("@") && isObjectLike(val[param])) {
|
|
2246
|
-
schemes[param.slice(1)] = val[param];
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
if (Object.keys(schemes).length) {
|
|
2250
|
-
const autoResult = generateAutoVars(schemes, key, CONFIG2);
|
|
2251
|
-
Object.assign(theme2, autoResult);
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
for (const param in val) {
|
|
2255
|
-
const symb = param.slice(0, 1);
|
|
2256
|
-
const value = val[param];
|
|
2257
|
-
if (symb === "@" || symb === ":" || symb === ".") {
|
|
2258
|
-
const hasPrefers = symb === "@" && param;
|
|
2259
|
-
theme2[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
|
|
2260
|
-
} else if (!isTopLevel) {
|
|
2261
|
-
const color2 = getColor(value, prefers);
|
|
2262
|
-
const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
|
|
2263
|
-
const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
|
|
2264
|
-
const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
|
|
2265
|
-
if (CONFIG2.useVariable) {
|
|
2266
|
-
if (CONFIG2.useThemeSuffixedVars) CSS_VARS2[CSSVar] = color2;
|
|
2267
|
-
theme2[param] = `var(${CSSVar})`;
|
|
2268
|
-
} else {
|
|
2269
|
-
theme2[param] = color2;
|
|
2270
|
-
}
|
|
2271
|
-
theme2[`.${param}`] = { [param]: theme2[param] };
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
if (!theme2[".inversed"] && (theme2.background || theme2.color || theme2.backgroundColor)) {
|
|
2275
|
-
theme2[".inversed"] = {
|
|
2276
|
-
color: theme2.background || theme2.backgroundColor,
|
|
2277
|
-
background: theme2.color
|
|
2278
|
-
};
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
if (isString(val) && isCSSVar(val)) {
|
|
2282
|
-
const THEME = CONFIG2.theme;
|
|
2283
|
-
const value = THEME[val.slice(2)];
|
|
2284
|
-
const getReferenced = getMediaTheme(value, prefers);
|
|
2285
|
-
return getReferenced;
|
|
2286
|
-
}
|
|
2287
|
-
return theme2;
|
|
2288
|
-
};
|
|
2289
|
-
var recursiveTheme = (val) => {
|
|
2290
|
-
const CONFIG2 = getActiveConfig();
|
|
2291
|
-
const obj = {};
|
|
2292
|
-
for (const param in val) {
|
|
2293
|
-
const symb = param.slice(0, 1);
|
|
2294
|
-
if (isObjectLike(val[param])) {
|
|
2295
|
-
if (symb === "@") {
|
|
2296
|
-
continue;
|
|
2297
|
-
} else if (symb === ":") {
|
|
2298
|
-
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
2299
|
-
} else if (symb === ".") {
|
|
2300
|
-
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
2301
|
-
}
|
|
2302
|
-
} else obj[param] = val[param];
|
|
2303
|
-
}
|
|
2304
|
-
return obj;
|
|
2305
|
-
};
|
|
2306
|
-
var findModifierFromArray = (val, modifierArray) => {
|
|
2307
|
-
const currentMod = modifierArray.shift();
|
|
2308
|
-
if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
|
|
2309
|
-
return val;
|
|
2310
|
-
};
|
|
2311
|
-
var findModifier = (val, modifier) => {
|
|
2312
|
-
if (isArray(modifier)) return findModifierFromArray(val, modifier);
|
|
2313
|
-
else if (isString(modifier) && val[modifier]) return val[modifier];
|
|
2314
|
-
else return val;
|
|
2315
|
-
};
|
|
2316
|
-
var getMediaTheme = (value, modifier) => {
|
|
2317
|
-
const activeConfig = getActiveConfig();
|
|
2318
|
-
if (isString(value) && isCSSVar(value)) {
|
|
2319
|
-
value = getMediaTheme(value.slice(2));
|
|
2320
|
-
}
|
|
2321
|
-
if (!value || !isString(value)) {
|
|
2322
|
-
if (activeConfig.verbose) {
|
|
2323
|
-
console.warn(`${value} - Theme is not a string`);
|
|
2324
|
-
}
|
|
2325
|
-
return;
|
|
2326
|
-
}
|
|
2327
|
-
const [themeName, ...themeModifiers] = isArray(value) ? value : value.split(" ");
|
|
2328
|
-
let themeValue = activeConfig.theme[themeName];
|
|
2329
|
-
if (themeValue && themeModifiers.length) {
|
|
2330
|
-
themeValue = findModifier(themeValue, themeModifiers);
|
|
2331
|
-
} else if (themeValue && modifier) {
|
|
2332
|
-
themeValue = findModifier(themeValue, modifier);
|
|
2333
|
-
}
|
|
2334
|
-
const resolvedTheme = recursiveTheme(themeValue);
|
|
2335
|
-
return resolvedTheme;
|
|
2336
|
-
};
|
|
2337
|
-
|
|
2338
|
-
// src/system/font.js
|
|
2339
|
-
init_esm();
|
|
2340
|
-
var setFont = (val, key) => {
|
|
2341
|
-
const CONFIG2 = getActiveConfig();
|
|
2342
|
-
const CSSvar = `--font-${key}`;
|
|
2343
|
-
if (!val || isArray(val) && !val[0]) return;
|
|
2344
|
-
let fontFace;
|
|
2345
|
-
if (val.isVariable) {
|
|
2346
|
-
const url = resolveFileUrl(val.url, CONFIG2.files) || val.url;
|
|
2347
|
-
if (isGoogleFontsUrl(url)) {
|
|
2348
|
-
fontFace = setFontImport(url);
|
|
2349
|
-
} else {
|
|
2350
|
-
fontFace = setCustomFontMedia(key, url, val.fontWeight, {
|
|
2351
|
-
fontStretch: val.fontStretch,
|
|
2352
|
-
fontDisplay: val.fontDisplay || "swap"
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
} else if (val[0]) {
|
|
2356
|
-
fontFace = getFontFaceEach(key, val, CONFIG2.files);
|
|
2357
|
-
} else {
|
|
2358
|
-
const url = Array.isArray(val.url) ? val.url.map((u) => resolveFileUrl(u, CONFIG2.files) || u) : resolveFileUrl(val.url, CONFIG2.files) || val.url;
|
|
2359
|
-
fontFace = setCustomFontMedia(key, url, val.fontWeight, {
|
|
2360
|
-
fontStyle: val.fontStyle,
|
|
2361
|
-
fontDisplay: val.fontDisplay,
|
|
2362
|
-
fontStretch: val.fontStretch
|
|
2363
|
-
});
|
|
2364
|
-
}
|
|
2365
|
-
return { var: CSSvar, value: val, fontFace };
|
|
2366
|
-
};
|
|
2367
|
-
var getFontFamily = (key, factory) => {
|
|
2368
|
-
const CONFIG2 = getActiveConfig();
|
|
2369
|
-
const { font_family: FONT_FAMILY } = CONFIG2;
|
|
2370
|
-
return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
|
|
2371
|
-
};
|
|
2372
|
-
var setFontFamily = (val, key) => {
|
|
2373
|
-
const CONFIG2 = getActiveConfig();
|
|
2374
|
-
const { font_family: FONT_FAMILY, font_family_types: FONT_FAMILY_TYPES } = CONFIG2;
|
|
2375
|
-
let { value, type } = val;
|
|
2376
|
-
if (val.isDefault) FONT_FAMILY.default = key;
|
|
2377
|
-
if (isObject(value)) value = arrayzeValue(value);
|
|
2378
|
-
const CSSvar = `--font-family-${key}`;
|
|
2379
|
-
const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
|
|
2380
|
-
return { var: CSSvar, value: str, arr: value, type };
|
|
2381
|
-
};
|
|
2382
|
-
|
|
2383
|
-
// src/system/typography.js
|
|
2384
|
-
init_esm();
|
|
2385
|
-
var runThroughMedia = (FACTORY2) => {
|
|
2386
|
-
const CONFIG2 = getActiveConfig();
|
|
2387
|
-
const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG2;
|
|
2388
|
-
for (const prop in FACTORY2) {
|
|
2389
|
-
const isPropMedia = prop.slice(0, 1) === "@";
|
|
2390
|
-
const mediaValue = FACTORY2[prop];
|
|
2391
|
-
if (!isPropMedia) continue;
|
|
2392
|
-
const { mediaRegenerate } = FACTORY2;
|
|
2393
|
-
const mediaName = prop.slice(1);
|
|
2394
|
-
const { type, base, ratio, range, subSequence, h1Matches, unit: unit2 } = FACTORY2;
|
|
2395
|
-
merge(mediaValue, {
|
|
2396
|
-
type,
|
|
2397
|
-
base,
|
|
2398
|
-
ratio,
|
|
2399
|
-
range,
|
|
2400
|
-
subSequence,
|
|
2401
|
-
h1Matches,
|
|
2402
|
-
unit: unit2
|
|
2403
|
-
});
|
|
2404
|
-
const query = MEDIA[mediaName];
|
|
2405
|
-
const media2 = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
2406
|
-
TYPOGRAPHY.templates[media2] = {
|
|
2407
|
-
fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit2
|
|
2408
|
-
};
|
|
2409
|
-
if (!mediaRegenerate) {
|
|
2410
|
-
applyMediaSequenceVars(FACTORY2, prop);
|
|
2411
|
-
continue;
|
|
2412
|
-
}
|
|
2413
|
-
merge(mediaValue, {
|
|
2414
|
-
sequence: {},
|
|
2415
|
-
scales: {},
|
|
2416
|
-
templates: {},
|
|
2417
|
-
vars: {}
|
|
2418
|
-
});
|
|
2419
|
-
generateSequence(mediaValue);
|
|
2420
|
-
applyMediaSequenceVars(FACTORY2, prop);
|
|
2421
|
-
}
|
|
2422
|
-
};
|
|
2423
|
-
var applyHeadings = (props) => {
|
|
2424
|
-
const CONFIG2 = getActiveConfig();
|
|
2425
|
-
if (props.h1Matches) {
|
|
2426
|
-
const unit2 = props.unit;
|
|
2427
|
-
const HEADINGS = findHeadings(props);
|
|
2428
|
-
const { templates: templates2 } = props;
|
|
2429
|
-
for (const k in HEADINGS) {
|
|
2430
|
-
const headerName = `h${parseInt(k) + 1}`;
|
|
2431
|
-
const headerStyle = templates2[headerName];
|
|
2432
|
-
templates2[headerName] = {
|
|
2433
|
-
fontSize: CONFIG2.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k]?.scaling}${unit2}`,
|
|
2434
|
-
margin: headerStyle ? headerStyle.margin : 0,
|
|
2435
|
-
lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
|
|
2436
|
-
letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
|
|
2437
|
-
fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
|
|
2438
|
-
};
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
};
|
|
2442
|
-
var applyTypographySequence = () => {
|
|
2443
|
-
const CONFIG2 = getActiveConfig();
|
|
2444
|
-
const { typography: TYPOGRAPHY } = CONFIG2;
|
|
2445
|
-
generateSequence(TYPOGRAPHY);
|
|
2446
|
-
applyHeadings(TYPOGRAPHY);
|
|
2447
|
-
applySequenceVars(TYPOGRAPHY);
|
|
2448
|
-
runThroughMedia(TYPOGRAPHY);
|
|
2449
|
-
};
|
|
2450
|
-
var getFontSizeByKey = (value) => {
|
|
2451
|
-
const CONFIG2 = getActiveConfig();
|
|
2452
|
-
const { typography: TYPOGRAPHY } = CONFIG2;
|
|
2453
|
-
return getSequenceValuePropertyPair(value, "fontSize", TYPOGRAPHY);
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
// src/system/spacing.js
|
|
2457
|
-
init_esm();
|
|
2458
|
-
var runThroughMedia2 = (FACTORY2) => {
|
|
2459
|
-
for (const prop in FACTORY2) {
|
|
2460
|
-
const mediaProps = FACTORY2[prop];
|
|
2461
|
-
const isMediaName = prop.slice(0, 1) === "@";
|
|
2462
|
-
if (!isMediaName) continue;
|
|
2463
|
-
const { type, base, ratio, range, subSequence, h1Matches, unit: unit2 } = FACTORY2;
|
|
2464
|
-
merge(mediaProps, {
|
|
2465
|
-
type,
|
|
2466
|
-
base,
|
|
2467
|
-
ratio,
|
|
2468
|
-
range,
|
|
2469
|
-
subSequence,
|
|
2470
|
-
h1Matches,
|
|
2471
|
-
unit: unit2,
|
|
2472
|
-
sequence: {},
|
|
2473
|
-
scales: {},
|
|
2474
|
-
templates: {},
|
|
2475
|
-
vars: {}
|
|
2476
|
-
});
|
|
2477
|
-
generateSequence(mediaProps);
|
|
2478
|
-
applyMediaSequenceVars(FACTORY2, prop);
|
|
2479
|
-
}
|
|
2480
|
-
};
|
|
2481
|
-
var checkIfBoxSize = (propertyName) => {
|
|
2482
|
-
const prop = propertyName.toLowerCase();
|
|
2483
|
-
const includesWidth = prop.includes("width") || prop.includes("height");
|
|
2484
|
-
const includesBorder = prop.includes("border") || prop.includes("outline");
|
|
2485
|
-
return includesWidth && !includesBorder;
|
|
2486
|
-
};
|
|
2487
|
-
var applySpacingSequence = () => {
|
|
2488
|
-
const CONFIG2 = getActiveConfig();
|
|
2489
|
-
const { spacing: SPACING } = CONFIG2;
|
|
2490
|
-
generateSequence(SPACING);
|
|
2491
|
-
applySequenceVars(SPACING);
|
|
2492
|
-
runThroughMedia2(SPACING);
|
|
2493
|
-
};
|
|
2494
|
-
var getSequence = (sequenceProps) => {
|
|
2495
|
-
const CONFIG2 = getActiveConfig();
|
|
2496
|
-
const { spacing: SPACING } = CONFIG2;
|
|
2497
|
-
if (!sequenceProps || !sequenceProps.sequence) return SPACING;
|
|
2498
|
-
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
2499
|
-
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
2500
|
-
};
|
|
2501
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
2502
|
-
const sequence2 = getSequence(sequenceProps);
|
|
2503
|
-
if (isString(value)) {
|
|
2504
|
-
if (!fnPrefix && value.includes("(")) {
|
|
2505
|
-
const fnArray = getFnPrefixAndValue(value);
|
|
2506
|
-
fnPrefix = fnArray[0];
|
|
2507
|
-
value = fnArray[1];
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
const stack = fnPrefix ? [value] : arrayzeValue(value);
|
|
2511
|
-
if (!isArray(stack)) return;
|
|
2512
|
-
if (stack.length > 1) {
|
|
2513
|
-
let suffix = "";
|
|
2514
|
-
if (propertyName === "borderWidth") {
|
|
2515
|
-
propertyName = "border";
|
|
2516
|
-
suffix = "Width";
|
|
2517
|
-
}
|
|
2518
|
-
const directions = {
|
|
2519
|
-
2: ["Block", "Inline"],
|
|
2520
|
-
3: ["BlockStart", "Inline", "BlockEnd"],
|
|
2521
|
-
4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
|
|
2522
|
-
};
|
|
2523
|
-
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
2524
|
-
stack[i],
|
|
2525
|
-
propertyName + direction + suffix,
|
|
2526
|
-
sequence2,
|
|
2527
|
-
fnPrefix
|
|
2528
|
-
);
|
|
2529
|
-
return directions[stack.length].map(
|
|
2530
|
-
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
2531
|
-
);
|
|
2532
|
-
}
|
|
2533
|
-
return getSequenceValuePropertyPair(value, propertyName, sequence2, fnPrefix);
|
|
2534
|
-
};
|
|
2535
|
-
var getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
2536
|
-
const CONFIG2 = getActiveConfig();
|
|
2537
|
-
const { spacing: SPACING } = CONFIG2;
|
|
2538
|
-
let value = val || props[propertyName];
|
|
2539
|
-
if (!fnPrefix && isString(value) && value.includes("(")) {
|
|
2540
|
-
const fnArr = getFnPrefixAndValue(value);
|
|
2541
|
-
fnPrefix = fnArr[0];
|
|
2542
|
-
value = fnArr[1];
|
|
2543
|
-
}
|
|
2544
|
-
if (props.spacingRatio) {
|
|
2545
|
-
const sequenceProps = applyCustomSequence(props);
|
|
2546
|
-
return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
|
|
2547
|
-
}
|
|
2548
|
-
return getSpacingByKey(value, propertyName, SPACING, fnPrefix);
|
|
2549
|
-
};
|
|
2550
|
-
var splitSpacedValue = (val) => {
|
|
2551
|
-
const addDefault = (v) => {
|
|
2552
|
-
const isSymbol = ["+", "-", "*", "/"].includes(v);
|
|
2553
|
-
const hasUnits = CSS_UNITS.some((unit2) => val.includes(unit2));
|
|
2554
|
-
if (isSymbol || hasUnits) return v;
|
|
2555
|
-
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
2556
|
-
if (isSingleLetter) return v + "_default";
|
|
2557
|
-
return v;
|
|
2558
|
-
};
|
|
2559
|
-
return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
|
|
2560
|
-
};
|
|
2561
|
-
|
|
2562
|
-
// src/system/shadow.js
|
|
2563
|
-
init_esm();
|
|
2564
|
-
var setShadow = (value, key, suffix, prefers) => {
|
|
2565
|
-
const CONFIG2 = getActiveConfig();
|
|
2566
|
-
if (isArray(value)) {
|
|
2567
|
-
return {
|
|
2568
|
-
"@light": setShadow(value[0], key, "light"),
|
|
2569
|
-
"@dark": setShadow(value[1], key, "dark")
|
|
2570
|
-
};
|
|
2571
|
-
}
|
|
2572
|
-
if (isObject(value)) {
|
|
2573
|
-
const obj = {};
|
|
2574
|
-
for (const variant in value) {
|
|
2575
|
-
obj[variant] = setShadow(
|
|
2576
|
-
value[variant],
|
|
2577
|
-
key,
|
|
2578
|
-
variant.startsWith("@") ? variant.slice(1) : variant
|
|
2579
|
-
);
|
|
2580
|
-
}
|
|
2581
|
-
return obj;
|
|
2582
|
-
}
|
|
2583
|
-
if (isString(value) && !CSS_NATIVE_COLOR_REGEX.test(value)) {
|
|
2584
|
-
value = splitTopLevelCommas(value).map((shadow2) => {
|
|
2585
|
-
shadow2 = shadow2.trim();
|
|
2586
|
-
return shadow2.split(/\s+/).map((v) => {
|
|
2587
|
-
v = v.trim();
|
|
2588
|
-
if (!v) return "";
|
|
2589
|
-
if (v.startsWith("--")) return `var(${v})`;
|
|
2590
|
-
const color2 = getColor(v);
|
|
2591
|
-
if (isResolvedColor(color2)) return color2;
|
|
2592
|
-
if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
|
|
2593
|
-
if (v === "inset" || v === "none") return v;
|
|
2594
|
-
const spacing2 = getSpacingByKey(v, "shadow");
|
|
2595
|
-
if (spacing2 && spacing2.shadow) return spacing2.shadow;
|
|
2596
|
-
return v;
|
|
2597
|
-
}).join(" ");
|
|
2598
|
-
}).join(", ");
|
|
2599
|
-
}
|
|
2600
|
-
const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
|
|
2601
|
-
if (CONFIG2.useVariable) {
|
|
2602
|
-
CONFIG2.CSS_VARS[CSSVar] = value;
|
|
2603
|
-
}
|
|
2604
|
-
return {
|
|
2605
|
-
var: CSSVar,
|
|
2606
|
-
value
|
|
2607
|
-
};
|
|
2608
|
-
};
|
|
2609
|
-
var getShadow = (value, globalTheme) => {
|
|
2610
|
-
const CONFIG2 = getActiveConfig();
|
|
2611
|
-
if (!globalTheme) globalTheme = CONFIG2.globalTheme;
|
|
2612
|
-
if (!isString(value)) {
|
|
2613
|
-
if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
|
|
2614
|
-
return;
|
|
2615
|
-
}
|
|
2616
|
-
if (isCSSVar(value)) return `var(${value})`;
|
|
2617
|
-
const [name] = isArray(value) ? value : value.split(" ");
|
|
2618
|
-
const SHADOW = CONFIG2.shadow;
|
|
2619
|
-
const val = SHADOW[name];
|
|
2620
|
-
const isObj = isObject(val);
|
|
2621
|
-
if (!val) {
|
|
2622
|
-
if (CONFIG2.verbose) console.warn("Can't find color ", name);
|
|
2623
|
-
return value;
|
|
2624
|
-
}
|
|
2625
|
-
if (globalTheme) {
|
|
2626
|
-
if (val[globalTheme]) return val[globalTheme].value;
|
|
2627
|
-
else if (CONFIG2.verbose) console.warn(value, " - does not have ", globalTheme);
|
|
2628
|
-
}
|
|
2629
|
-
if (isObj && val.value) return val.value;
|
|
2630
|
-
if (isObj) {
|
|
2631
|
-
const obj = {};
|
|
2632
|
-
for (const mediaName in val) {
|
|
2633
|
-
const query = CONFIG2.media[mediaName.slice(1)];
|
|
2634
|
-
const media2 = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
2635
|
-
obj[media2] = val.value;
|
|
2636
|
-
}
|
|
2637
|
-
return obj;
|
|
2638
|
-
}
|
|
2639
|
-
if (CONFIG2.verbose) console.warn("Can't find color", value);
|
|
2640
|
-
return value;
|
|
2641
|
-
};
|
|
2642
|
-
|
|
2643
|
-
// src/system/timing.js
|
|
2644
|
-
var applyTimingSequence = () => {
|
|
2645
|
-
const CONFIG2 = getActiveConfig();
|
|
2646
|
-
const { timing: TIMING } = CONFIG2;
|
|
2647
|
-
generateSequence(TIMING);
|
|
2648
|
-
applySequenceVars(TIMING);
|
|
2649
|
-
};
|
|
2650
|
-
var getTimingFunction = (value) => {
|
|
2651
|
-
const CONFIG2 = getActiveConfig();
|
|
2652
|
-
const { timing: TIMING } = CONFIG2;
|
|
2653
|
-
return TIMING[value] || TIMING[toCamelCase(value)] || value;
|
|
2654
|
-
};
|
|
2655
|
-
var getTimingByKey = (value, property = "timing") => {
|
|
2656
|
-
const CONFIG2 = getActiveConfig();
|
|
2657
|
-
const { timing: TIMING } = CONFIG2;
|
|
2658
|
-
return getSequenceValuePropertyPair(
|
|
2659
|
-
value,
|
|
2660
|
-
property,
|
|
2661
|
-
TIMING
|
|
2662
|
-
);
|
|
2663
|
-
};
|
|
2664
|
-
|
|
2665
|
-
// src/system/document.js
|
|
2666
|
-
init_esm();
|
|
2667
|
-
var applyDocument = () => {
|
|
2668
|
-
const CONFIG2 = getActiveConfig();
|
|
2669
|
-
const { document: DOCUMENT, font_family: FONT_FAMILY, theme: THEME, typography: TYPOGRAPHY } = CONFIG2;
|
|
2670
|
-
return merge(DOCUMENT, {
|
|
2671
|
-
theme: THEME.document,
|
|
2672
|
-
fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
|
|
2673
|
-
fontSize: TYPOGRAPHY.base,
|
|
2674
|
-
lineHeight: TYPOGRAPHY.lineHeight
|
|
2675
|
-
});
|
|
2676
|
-
};
|
|
2677
|
-
|
|
2678
|
-
// src/system/svg.js
|
|
2679
|
-
init_esm();
|
|
2680
|
-
var DEF_OPTIONS = {
|
|
2681
|
-
document: document2
|
|
2682
|
-
};
|
|
2683
|
-
var setSVG = (val, key) => {
|
|
2684
|
-
const CONFIG2 = getActiveConfig();
|
|
2685
|
-
if (!val) {
|
|
2686
|
-
if (CONFIG2.verbose) console.warn("setSVG: val is not defined", key);
|
|
2687
|
-
return;
|
|
2688
|
-
}
|
|
2689
|
-
if (CONFIG2.useSvgSprite) {
|
|
2690
|
-
return convertSvgToSymbol(key, val);
|
|
2691
|
-
}
|
|
2692
|
-
return val;
|
|
2693
|
-
};
|
|
2694
|
-
var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
2695
|
-
const CONFIG2 = getActiveConfig();
|
|
2696
|
-
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.svg;
|
|
2697
|
-
for (const key in LIBRARY) lib[key] = LIBRARY[key];
|
|
2698
|
-
appendSVG(lib, options);
|
|
2699
|
-
};
|
|
2700
|
-
var setSvgIcon = (val, key) => {
|
|
2701
|
-
const CONFIG2 = getActiveConfig();
|
|
2702
|
-
if (CONFIG2.useIconSprite && !CONFIG2.semantic_icons?.[key]) {
|
|
2703
|
-
return setSVG(val, key);
|
|
2704
|
-
}
|
|
2705
|
-
return val;
|
|
2706
|
-
};
|
|
2707
|
-
var appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
2708
|
-
const CONFIG2 = getActiveConfig();
|
|
2709
|
-
const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.icons;
|
|
2710
|
-
for (const key in LIBRARY) lib[key] = LIBRARY[key];
|
|
2711
|
-
appendSVG(lib, options);
|
|
2712
|
-
};
|
|
2713
|
-
var createSVGSpriteElement = (doc, options = { isRoot: true }) => {
|
|
2714
|
-
if (!doc || !doc.createElementNS) return;
|
|
2715
|
-
const svgElem = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2716
|
-
if (options.isRoot) {
|
|
2717
|
-
svgElem.setAttribute("aria-hidden", "true");
|
|
2718
|
-
svgElem.setAttribute("width", "0");
|
|
2719
|
-
svgElem.setAttribute("height", "0");
|
|
2720
|
-
svgElem.setAttribute("style", "position:absolute");
|
|
2721
|
-
svgElem.setAttribute("id", "svgSprite");
|
|
2722
|
-
}
|
|
2723
|
-
return svgElem;
|
|
2724
|
-
};
|
|
2725
|
-
var appendSVG = (lib, options = DEF_OPTIONS) => {
|
|
2726
|
-
const CONFIG2 = getActiveConfig();
|
|
2727
|
-
const doc = options.document || document2;
|
|
2728
|
-
if (!doc || !doc.documentElement) {
|
|
2729
|
-
if (CONFIG2.verbose) {
|
|
2730
|
-
console.warn("To append SVG sprites it should be run in browser environment");
|
|
2731
|
-
}
|
|
2732
|
-
return generateSprite(lib);
|
|
2733
|
-
}
|
|
2734
|
-
const exists = doc.querySelector("#svgSprite");
|
|
2735
|
-
const SVGsprite = generateSprite(lib);
|
|
2736
|
-
const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
|
|
2737
|
-
if (exists) {
|
|
2738
|
-
if (doc.body.insertAdjacentHTML) {
|
|
2739
|
-
exists.insertAdjacentHTML("beforeend", SVGsprite);
|
|
2740
|
-
} else {
|
|
2741
|
-
const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
|
|
2742
|
-
tempSVG.innerHTML = SVGsprite;
|
|
2743
|
-
exists.append(...tempSVG.children);
|
|
2744
|
-
}
|
|
2745
|
-
} else {
|
|
2746
|
-
if (doc.body.insertAdjacentHTML) {
|
|
2747
|
-
doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
|
|
2748
|
-
} else {
|
|
2749
|
-
const svgSpriteDOM = createSVGSpriteElement(doc);
|
|
2750
|
-
if (svgSpriteDOM && svgSpriteDOM.nodeType) {
|
|
2751
|
-
svgSpriteDOM.innerHTML = SVGsprite;
|
|
2752
|
-
doc.body.prepend(svgSpriteDOM);
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
};
|
|
2757
|
-
|
|
2758
|
-
// src/system/reset.js
|
|
2759
|
-
init_esm();
|
|
2760
|
-
var applyReset = (reset2 = {}) => {
|
|
2761
|
-
const CONFIG2 = getActiveConfig();
|
|
2762
|
-
const { reset: RESET, typography: TYPOGRAPHY, document: DOCUMENT } = CONFIG2;
|
|
2763
|
-
if (RESET) {
|
|
2764
|
-
if (RESET[":root"]) {
|
|
2765
|
-
const configReset = RESET;
|
|
2766
|
-
const configTemplates = TYPOGRAPHY.templates;
|
|
2767
|
-
configReset.body = {
|
|
2768
|
-
...CONFIG2.useDocumentTheme ? getMediaTheme("document") : {},
|
|
2769
|
-
...configTemplates.body
|
|
2770
|
-
};
|
|
2771
|
-
configReset.h1 = configTemplates.h1;
|
|
2772
|
-
configReset.h2 = configTemplates.h2;
|
|
2773
|
-
configReset.h3 = configTemplates.h3;
|
|
2774
|
-
configReset.h4 = configTemplates.h4;
|
|
2775
|
-
configReset.h5 = configTemplates.h5;
|
|
2776
|
-
configReset.h6 = configTemplates.h6;
|
|
2777
|
-
}
|
|
2778
|
-
const { body, ...templates2 } = TYPOGRAPHY.templates;
|
|
2779
|
-
const globalTheme = CONFIG2.useDocumentTheme ? getMediaTheme("document") : {};
|
|
2780
|
-
if (RESET.html) overwriteDeep(RESET.html, globalTheme);
|
|
2781
|
-
return deepMerge(merge(RESET, reset2), {
|
|
2782
|
-
html: {
|
|
2783
|
-
position: "absolute",
|
|
2784
|
-
// overflow: 'hidden',
|
|
2785
|
-
width: "100%",
|
|
2786
|
-
height: "100%",
|
|
2787
|
-
top: "0",
|
|
2788
|
-
left: "0",
|
|
2789
|
-
margin: "0",
|
|
2790
|
-
WebkitFontSmoothing: "subpixel-antialiased",
|
|
2791
|
-
scrollBehavior: "smooth",
|
|
2792
|
-
...globalTheme,
|
|
2793
|
-
fontSize: TYPOGRAPHY.browserDefault + "px",
|
|
2794
|
-
fontFamily: DOCUMENT.fontFamily,
|
|
2795
|
-
lineHeight: DOCUMENT.lineHeight
|
|
2796
|
-
},
|
|
2797
|
-
body: {
|
|
2798
|
-
boxSizing: "border-box",
|
|
2799
|
-
height: "100%",
|
|
2800
|
-
margin: 0,
|
|
2801
|
-
fontFamily: DOCUMENT.fontFamily,
|
|
2802
|
-
fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG2.unit.default,
|
|
2803
|
-
...templates2,
|
|
2804
|
-
...body
|
|
2805
|
-
},
|
|
2806
|
-
a: {
|
|
2807
|
-
color: "currentColor"
|
|
2808
|
-
},
|
|
2809
|
-
// form elements
|
|
2810
|
-
fieldset: {
|
|
2811
|
-
border: 0,
|
|
2812
|
-
padding: 0,
|
|
2813
|
-
margin: 0
|
|
2814
|
-
},
|
|
2815
|
-
"select, input": {
|
|
2816
|
-
fontFamily: DOCUMENT.fontFamily
|
|
2817
|
-
}
|
|
2818
|
-
});
|
|
2819
|
-
}
|
|
2820
|
-
};
|
|
2821
|
-
|
|
2822
|
-
// src/transforms/index.js
|
|
2823
|
-
init_esm();
|
|
2824
|
-
var BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
2825
|
-
"none",
|
|
2826
|
-
"hidden",
|
|
2827
|
-
"dotted",
|
|
2828
|
-
"dashed",
|
|
2829
|
-
"solid",
|
|
2830
|
-
"double",
|
|
2831
|
-
"groove",
|
|
2832
|
-
"ridge",
|
|
2833
|
-
"inset",
|
|
2834
|
-
"outset",
|
|
2835
|
-
"initial"
|
|
2836
|
-
]);
|
|
2837
|
-
var GRADIENT_KEYWORDS = /* @__PURE__ */ new Set([
|
|
2838
|
-
"to",
|
|
2839
|
-
"top",
|
|
2840
|
-
"bottom",
|
|
2841
|
-
"left",
|
|
2842
|
-
"right",
|
|
2843
|
-
"center",
|
|
2844
|
-
"at",
|
|
2845
|
-
"circle",
|
|
2846
|
-
"ellipse",
|
|
2847
|
-
"closest-side",
|
|
2848
|
-
"farthest-side",
|
|
2849
|
-
"closest-corner",
|
|
2850
|
-
"farthest-corner"
|
|
2851
|
-
]);
|
|
2852
|
-
var isBorderStyle = (str) => BORDER_STYLES.has(str);
|
|
2853
|
-
var transformBorder = (border) => {
|
|
2854
|
-
const str = border + "";
|
|
2855
|
-
if (CSS_NATIVE_COLOR_REGEX.test(str)) return str;
|
|
2856
|
-
const trimmed = str.trim();
|
|
2857
|
-
if (trimmed === "none" || trimmed === "0" || trimmed === "initial" || trimmed === "inherit" || trimmed === "unset") return str;
|
|
2858
|
-
const tokens = str.split(/\s+/);
|
|
2859
|
-
return tokens.map((v) => {
|
|
2860
|
-
v = v.trim();
|
|
2861
|
-
if (!v) return "";
|
|
2862
|
-
if (isCSSVar(v)) return `var(${v})`;
|
|
2863
|
-
if (isBorderStyle(v)) return v;
|
|
2864
|
-
if (/^\d/.test(v) || v === "0") return v;
|
|
2865
|
-
const color2 = getColor(v);
|
|
2866
|
-
if (isResolvedColor(color2)) return color2;
|
|
2867
|
-
const spacing2 = getSpacingByKey(v, "border");
|
|
2868
|
-
if (spacing2 && spacing2.border) return spacing2.border;
|
|
2869
|
-
return v;
|
|
2870
|
-
}).join(" ");
|
|
2871
|
-
};
|
|
2872
|
-
var transformTextStroke = (stroke) => {
|
|
2873
|
-
if (CSS_NATIVE_COLOR_REGEX.test(stroke)) return stroke;
|
|
2874
|
-
return stroke.split(/\s+/).map((v) => {
|
|
2875
|
-
v = v.trim();
|
|
2876
|
-
if (!v) return "";
|
|
2877
|
-
if (isCSSVar(v)) return `var(${v})`;
|
|
2878
|
-
if (/^\d/.test(v) || v.includes("px") || v === "0") return v;
|
|
2879
|
-
const color2 = getColor(v);
|
|
2880
|
-
if (isResolvedColor(color2)) return color2;
|
|
2881
|
-
return v;
|
|
2882
|
-
}).join(" ");
|
|
2883
|
-
};
|
|
2884
|
-
var transformShadow = (sh, globalTheme) => getShadow(sh, globalTheme);
|
|
2885
|
-
var transformBoxShadow = (shadows, globalTheme) => {
|
|
2886
|
-
if (CSS_NATIVE_COLOR_REGEX.test(shadows)) return shadows;
|
|
2887
|
-
return splitTopLevelCommas(shadows).map((shadow2) => {
|
|
2888
|
-
shadow2 = shadow2.trim();
|
|
2889
|
-
if (!shadow2) return "";
|
|
2890
|
-
return shadow2.split(/\s+/).map((v) => {
|
|
2891
|
-
v = v.trim();
|
|
2892
|
-
if (!v) return "";
|
|
2893
|
-
if (isCSSVar(v)) return `var(${v})`;
|
|
2894
|
-
if (v === "inset" || v === "none") return v;
|
|
2895
|
-
const color2 = getColor(v);
|
|
2896
|
-
if (isResolvedColor(color2)) {
|
|
2897
|
-
const mediaColor = getMediaColor(v, globalTheme);
|
|
2898
|
-
if (isObject(mediaColor))
|
|
2899
|
-
return Object.values(mediaColor).filter(
|
|
2900
|
-
(c) => c.includes(": " + globalTheme)
|
|
2901
|
-
)[0];
|
|
2902
|
-
return mediaColor;
|
|
2903
|
-
}
|
|
2904
|
-
if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
|
|
2905
|
-
const spacing2 = getSpacingByKey(v, "shadow");
|
|
2906
|
-
if (spacing2 && spacing2.shadow) return spacing2.shadow;
|
|
2907
|
-
return v;
|
|
2908
|
-
}).join(" ");
|
|
2909
|
-
}).join(", ");
|
|
2910
|
-
};
|
|
2911
|
-
var resolveColorsInGradient = (gradient2, globalTheme) => {
|
|
2912
|
-
const parenStart = gradient2.indexOf("(");
|
|
2913
|
-
if (parenStart === -1) return gradient2;
|
|
2914
|
-
const prefix = gradient2.slice(0, parenStart + 1);
|
|
2915
|
-
const inner = gradient2.slice(parenStart + 1, gradient2.lastIndexOf(")"));
|
|
2916
|
-
const suffix = ")";
|
|
2917
|
-
const segments = splitTopLevelCommas(inner);
|
|
2918
|
-
const resolved = segments.map((segment) => {
|
|
2919
|
-
segment = segment.trim();
|
|
2920
|
-
const tokens = segment.split(/\s+/);
|
|
2921
|
-
return tokens.map((token) => {
|
|
2922
|
-
if (!token) return token;
|
|
2923
|
-
if (/^\d/.test(token) || token === "0") return token;
|
|
2924
|
-
if (GRADIENT_KEYWORDS.has(token)) return token;
|
|
2925
|
-
if (token === "transparent") return token;
|
|
2926
|
-
if (CSS_NATIVE_COLOR_REGEX.test(token)) return token;
|
|
2927
|
-
const color2 = getColor(token);
|
|
2928
|
-
if (isResolvedColor(color2)) return color2;
|
|
2929
|
-
return token;
|
|
2930
|
-
}).join(" ");
|
|
2931
|
-
});
|
|
2932
|
-
return prefix + resolved.join(", ") + suffix;
|
|
2933
|
-
};
|
|
2934
|
-
var transformBackgroundImage = (backgroundImage, globalTheme) => {
|
|
2935
|
-
const CONFIG2 = getActiveConfig();
|
|
2936
|
-
return backgroundImage.split(", ").map((v) => {
|
|
2937
|
-
if (isCSSVar(v)) return `var(${v})`;
|
|
2938
|
-
if (v.includes("url")) return v;
|
|
2939
|
-
if (v.includes("gradient")) return resolveColorsInGradient(v, globalTheme);
|
|
2940
|
-
else if (CONFIG2.gradient[backgroundImage]) {
|
|
2941
|
-
return {
|
|
2942
|
-
backgroundImage: getMediaColor(
|
|
2943
|
-
backgroundImage,
|
|
2944
|
-
globalTheme || CONFIG2.globalTheme
|
|
2945
|
-
)
|
|
2946
|
-
};
|
|
2947
|
-
} else if (v.includes("/") || v.startsWith("http") || v.includes(".") && !parseColorToken(v))
|
|
2948
|
-
return `url(${v})`;
|
|
2949
|
-
return v;
|
|
2950
|
-
}).join(" ");
|
|
2951
|
-
};
|
|
2952
|
-
var transfromGap = (gap) => isString(gap) && gap.split(" ").map((v) => getSpacingByKey(v, "gap").gap).join(" ");
|
|
2953
|
-
var transformTransition = (transition) => {
|
|
2954
|
-
const arr = transition.split(" ");
|
|
2955
|
-
if (!arr.length) return transition;
|
|
2956
|
-
return arr.map((v) => {
|
|
2957
|
-
if (isCSSVar(v)) return `var(${v})`;
|
|
2958
|
-
if (v.length < 3 || v.includes("ms")) {
|
|
2959
|
-
const mapWithSequence = getTimingByKey(v);
|
|
2960
|
-
return mapWithSequence.timing || v;
|
|
2961
|
-
}
|
|
2962
|
-
if (getTimingFunction(v)) return getTimingFunction(v);
|
|
2963
|
-
return v;
|
|
2964
|
-
}).join(" ");
|
|
2965
|
-
};
|
|
2966
|
-
var transformDuration = (duration, props, propertyName) => {
|
|
2967
|
-
if (!isString(duration)) return;
|
|
2968
|
-
return duration.split(",").map((v) => getTimingByKey(v).timing || v).join(",");
|
|
2969
|
-
};
|
|
2970
|
-
var splitTransition = (transition) => {
|
|
2971
|
-
const arr = transition.split(",");
|
|
2972
|
-
if (!arr.length) return;
|
|
2973
|
-
return arr.map(transformTransition).join(",");
|
|
2974
|
-
};
|
|
2975
|
-
function transformSize(propertyName, val, props = {}, opts = {}) {
|
|
2976
|
-
let value = exec.call(this, val || props[propertyName]);
|
|
2977
|
-
if (value === void 0 || value === null) return;
|
|
2978
|
-
let fnPrefix;
|
|
2979
|
-
if (isString(value)) {
|
|
2980
|
-
if (value.includes("(")) {
|
|
2981
|
-
const fnArr = getFnPrefixAndValue(value);
|
|
2982
|
-
fnPrefix = fnArr[0];
|
|
2983
|
-
value = fnArr[1];
|
|
2984
|
-
}
|
|
2985
|
-
const shouldScaleBoxSize = props.scaleBoxSize;
|
|
2986
|
-
const isBoxSize = checkIfBoxSize(propertyName);
|
|
2987
|
-
if (!shouldScaleBoxSize && isBoxSize && !opts.ratio) {
|
|
2988
|
-
value = splitSpacedValue(value);
|
|
2989
|
-
}
|
|
2990
|
-
}
|
|
2991
|
-
return opts.ratio ? getSpacingBasedOnRatio(props, propertyName, value, fnPrefix) : getSpacingByKey(value, propertyName, void 0, fnPrefix);
|
|
2992
|
-
}
|
|
2993
|
-
var transformSizeRatio = (propertyName, val = null, props) => {
|
|
2994
|
-
return transformSize(propertyName, val, props, {
|
|
2995
|
-
ratio: true
|
|
2996
|
-
});
|
|
2997
|
-
};
|
|
2998
|
-
var transformBorderRadius = (radius, props, propertyName) => {
|
|
2999
|
-
if (!isString(radius)) return;
|
|
3000
|
-
return {
|
|
3001
|
-
borderRadius: radius.split(" ").map((v, k) => getSpacingBasedOnRatio(props, propertyName, v)[propertyName]).join(" ")
|
|
3002
|
-
};
|
|
3003
|
-
};
|
|
3004
|
-
|
|
3005
|
-
// src/set.js
|
|
3006
|
-
init_esm();
|
|
3007
|
-
var setVars = (val, key) => {
|
|
3008
|
-
const CONFIG2 = getActiveConfig();
|
|
3009
|
-
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
3010
|
-
const varName = key.startsWith("--") ? key : `--${key}`;
|
|
3011
|
-
CSS_VARS2[varName] = val;
|
|
3012
|
-
return val;
|
|
3013
|
-
};
|
|
3014
|
-
var asIs = (val) => val;
|
|
3015
|
-
var VALUE_TRANSFORMERS = {
|
|
3016
|
-
color: setColor,
|
|
3017
|
-
gradient: setGradient,
|
|
3018
|
-
font: setFont,
|
|
3019
|
-
font_family: setFontFamily,
|
|
3020
|
-
fontfamily: setFontFamily,
|
|
3021
|
-
theme: setTheme,
|
|
3022
|
-
icons: setSvgIcon,
|
|
3023
|
-
semantic_icons: asIs,
|
|
3024
|
-
semanticicons: asIs,
|
|
3025
|
-
svg: setSVG,
|
|
3026
|
-
svg_data: asIs,
|
|
3027
|
-
typography: asIs,
|
|
3028
|
-
shadow: setShadow,
|
|
3029
|
-
spacing: asIs,
|
|
3030
|
-
media: asIs,
|
|
3031
|
-
grid: asIs,
|
|
3032
|
-
class: asIs,
|
|
3033
|
-
timing: asIs,
|
|
3034
|
-
reset: asIs,
|
|
3035
|
-
unit: asIs,
|
|
3036
|
-
animation: asIs,
|
|
3037
|
-
vars: setVars
|
|
3038
|
-
};
|
|
3039
|
-
var setValue = (factoryName, value, key) => {
|
|
3040
|
-
const CONFIG2 = getActiveConfig();
|
|
3041
|
-
const lowerName = factoryName.toLowerCase();
|
|
3042
|
-
const FACTORY2 = CONFIG2[lowerName] || CONFIG2[factoryName];
|
|
3043
|
-
if (VALUE_TRANSFORMERS[lowerName]) {
|
|
3044
|
-
try {
|
|
3045
|
-
const result = VALUE_TRANSFORMERS[lowerName](value, key);
|
|
3046
|
-
FACTORY2[key] = result;
|
|
3047
|
-
return FACTORY2;
|
|
3048
|
-
} catch (error) {
|
|
3049
|
-
if (CONFIG2.verbose)
|
|
3050
|
-
console.warn("Error setting", lowerName, "value", value, key, error);
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
if (CONFIG2.verbose)
|
|
3054
|
-
console.warn("Can not find", lowerName, "method in scratch");
|
|
3055
|
-
};
|
|
3056
|
-
var setEach = (factoryName, props) => {
|
|
3057
|
-
const CONFIG2 = getActiveConfig();
|
|
3058
|
-
const lowerName = factoryName.toLowerCase();
|
|
3059
|
-
const keys = Object.keys(props);
|
|
3060
|
-
keys.forEach((key) => {
|
|
3061
|
-
try {
|
|
3062
|
-
return setValue(lowerName, props[key], key);
|
|
3063
|
-
} catch (error) {
|
|
3064
|
-
if (CONFIG2.verbose)
|
|
3065
|
-
console.warn(
|
|
3066
|
-
"Error setting",
|
|
3067
|
-
lowerName,
|
|
3068
|
-
"value",
|
|
3069
|
-
props[key],
|
|
3070
|
-
key,
|
|
3071
|
-
error
|
|
3072
|
-
);
|
|
3073
|
-
}
|
|
3074
|
-
});
|
|
3075
|
-
return CONFIG2[lowerName] || CONFIG2[factoryName];
|
|
3076
|
-
};
|
|
3077
|
-
var changeGlobalTheme = (newTheme) => {
|
|
3078
|
-
const CONFIG2 = getActiveConfig();
|
|
3079
|
-
CONFIG2.globalTheme = newTheme;
|
|
3080
|
-
if (typeof document !== "undefined" && newTheme && newTheme !== "auto") {
|
|
3081
|
-
document.documentElement.setAttribute("data-theme", newTheme);
|
|
3082
|
-
}
|
|
3083
|
-
for (const key in CONFIG2.CSS_VARS) {
|
|
3084
|
-
if (key.startsWith("--theme-")) delete CONFIG2.CSS_VARS[key];
|
|
3085
|
-
}
|
|
3086
|
-
for (const key in CONFIG2.CSS_MEDIA_VARS) {
|
|
3087
|
-
delete CONFIG2.CSS_MEDIA_VARS[key];
|
|
3088
|
-
}
|
|
3089
|
-
const source = CONFIG2._originalTheme || CONFIG2.theme;
|
|
3090
|
-
if (source) {
|
|
3091
|
-
const fresh = JSON.parse(JSON.stringify(source));
|
|
3092
|
-
CONFIG2.theme = fresh;
|
|
3093
|
-
setEach("theme", fresh);
|
|
3094
|
-
}
|
|
3095
|
-
if (typeof document !== "undefined" && CONFIG2.CSS_VARS) {
|
|
3096
|
-
const sheets = document.styleSheets;
|
|
3097
|
-
for (let i = 0; i < sheets.length; i++) {
|
|
3098
|
-
try {
|
|
3099
|
-
const rules = sheets[i].cssRules;
|
|
3100
|
-
for (let j = 0; j < rules.length; j++) {
|
|
3101
|
-
if (rules[j].selectorText === ":root") {
|
|
3102
|
-
for (const key in CONFIG2.CSS_VARS) {
|
|
3103
|
-
rules[j].style.setProperty(key, CONFIG2.CSS_VARS[key]);
|
|
3104
|
-
}
|
|
3105
|
-
return CONFIG2;
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
} catch (e) {
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
}
|
|
3112
|
-
return CONFIG2;
|
|
3113
|
-
};
|
|
3114
|
-
var SET_OPTIONS = {};
|
|
3115
|
-
var set = (recivedConfig, options = SET_OPTIONS) => {
|
|
3116
|
-
let CONFIG2 = getActiveConfig();
|
|
3117
|
-
const {
|
|
3118
|
-
version,
|
|
3119
|
-
verbose,
|
|
3120
|
-
useVariable,
|
|
3121
|
-
useReset,
|
|
3122
|
-
useSvgSprite,
|
|
3123
|
-
useFontImport,
|
|
3124
|
-
useIconSprite,
|
|
3125
|
-
globalTheme,
|
|
3126
|
-
useDocumentTheme,
|
|
3127
|
-
useDefaultConfig,
|
|
3128
|
-
semanticIcons,
|
|
3129
|
-
SEMANTIC_ICONS,
|
|
3130
|
-
// deprecated
|
|
3131
|
-
semantic_icons: semantic_icons2,
|
|
3132
|
-
files,
|
|
3133
|
-
...config
|
|
3134
|
-
} = recivedConfig;
|
|
3135
|
-
if (options.newConfig) {
|
|
3136
|
-
CONFIG2 = setActiveConfig(options.newConfig);
|
|
3137
|
-
}
|
|
3138
|
-
if (files !== void 0) CONFIG2.files = files;
|
|
3139
|
-
if (verbose !== void 0) CONFIG2.verbose = verbose;
|
|
3140
|
-
if (useVariable !== void 0) CONFIG2.useVariable = useVariable;
|
|
3141
|
-
if (useReset !== void 0) CONFIG2.useReset = useReset;
|
|
3142
|
-
if (useFontImport !== void 0) CONFIG2.useFontImport = useFontImport;
|
|
3143
|
-
if (useSvgSprite !== void 0) CONFIG2.useSvgSprite = useSvgSprite;
|
|
3144
|
-
if (useIconSprite !== void 0) CONFIG2.useIconSprite = useIconSprite;
|
|
3145
|
-
if (useDocumentTheme !== void 0) CONFIG2.useDocumentTheme = useDocumentTheme;
|
|
3146
|
-
if (globalTheme !== void 0) CONFIG2.globalTheme = globalTheme;
|
|
3147
|
-
if (recivedConfig.useThemeSuffixedVars !== void 0)
|
|
3148
|
-
CONFIG2.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
|
|
3149
|
-
if (useDefaultConfig !== void 0) CONFIG2.useDefaultConfig = useDefaultConfig;
|
|
3150
|
-
const _semanticIcons = semanticIcons || SEMANTIC_ICONS || semantic_icons2;
|
|
3151
|
-
if (_semanticIcons !== void 0) {
|
|
3152
|
-
CONFIG2.semantic_icons = _semanticIcons;
|
|
3153
|
-
CONFIG2.semanticIcons = CONFIG2.semantic_icons;
|
|
3154
|
-
CONFIG2.SEMANTIC_ICONS = CONFIG2.semantic_icons;
|
|
3155
|
-
}
|
|
3156
|
-
if (CONFIG2.verbose) console.log(CONFIG2);
|
|
3157
|
-
if (typeof document !== "undefined" && CONFIG2.globalTheme && CONFIG2.globalTheme !== "auto") {
|
|
3158
|
-
document.documentElement.setAttribute("data-theme", CONFIG2.globalTheme);
|
|
3159
|
-
}
|
|
3160
|
-
if (!CONFIG2.__svg_cache) CONFIG2.__svg_cache = {};
|
|
3161
|
-
const keys = Object.keys(config);
|
|
3162
|
-
const keySet = new Set(keys);
|
|
3163
|
-
keys.forEach((key) => {
|
|
3164
|
-
const lower = key.toLowerCase();
|
|
3165
|
-
if (lower !== key && keySet.has(lower)) {
|
|
3166
|
-
deepMerge(config[lower], config[key]);
|
|
3167
|
-
}
|
|
3168
|
-
});
|
|
3169
|
-
if (config.theme && !CONFIG2._originalTheme) {
|
|
3170
|
-
CONFIG2._originalTheme = JSON.parse(JSON.stringify(config.theme));
|
|
3171
|
-
}
|
|
3172
|
-
keys.map((key) => {
|
|
3173
|
-
const lower = key.toLowerCase();
|
|
3174
|
-
if (lower !== key && keySet.has(lower)) return;
|
|
3175
|
-
return setEach(key, config[key]);
|
|
3176
|
-
});
|
|
3177
|
-
if (config.typography || config.TYPOGRAPHY) {
|
|
3178
|
-
try {
|
|
3179
|
-
applyTypographySequence();
|
|
3180
|
-
} catch (e) {
|
|
3181
|
-
if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
|
|
3182
|
-
}
|
|
3183
|
-
}
|
|
3184
|
-
if (config.spacing || config.SPACING) {
|
|
3185
|
-
try {
|
|
3186
|
-
applySpacingSequence();
|
|
3187
|
-
} catch (e) {
|
|
3188
|
-
if (CONFIG2.verbose) console.warn("Error applying spacing sequence", e);
|
|
3189
|
-
}
|
|
3190
|
-
}
|
|
3191
|
-
if (config.timing || config.TIMING) {
|
|
3192
|
-
try {
|
|
3193
|
-
applyTimingSequence();
|
|
3194
|
-
} catch (e) {
|
|
3195
|
-
if (CONFIG2.verbose) console.warn("Error applying timing sequence", e);
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
applyDocument();
|
|
3199
|
-
applyReset();
|
|
3200
|
-
return CONFIG2;
|
|
3201
|
-
};
|
|
3202
|
-
return __toCommonJS(index_exports);
|
|
3203
|
-
})();
|
|
3204
|
-
// @preserve-env
|