@symbo.ls/scratch 2.9.3 → 2.9.7-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1548 -0
- package/package.json +5 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1548 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.js
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
ANIMATION: () => ANIMATION,
|
|
24
|
+
BREAKPOINTS: () => BREAKPOINTS,
|
|
25
|
+
CASES: () => CASES,
|
|
26
|
+
COLOR: () => COLOR,
|
|
27
|
+
CONFIG: () => CONFIG,
|
|
28
|
+
CSS_VARS: () => CSS_VARS,
|
|
29
|
+
DEVICES: () => DEVICES,
|
|
30
|
+
DOCUMENT: () => DOCUMENT,
|
|
31
|
+
FACTORY: () => FACTORY,
|
|
32
|
+
FONT: () => FONT,
|
|
33
|
+
FONT_FACE: () => FONT_FACE,
|
|
34
|
+
FONT_FAMILY: () => FONT_FAMILY,
|
|
35
|
+
FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
|
|
36
|
+
GRADIENT: () => GRADIENT,
|
|
37
|
+
ICONS: () => ICONS,
|
|
38
|
+
MEDIA: () => MEDIA,
|
|
39
|
+
RESET: () => RESET,
|
|
40
|
+
SEQUENCE: () => SEQUENCE,
|
|
41
|
+
SETTERS: () => SETTERS,
|
|
42
|
+
SPACING: () => SPACING,
|
|
43
|
+
THEME: () => THEME,
|
|
44
|
+
TIMING: () => TIMING,
|
|
45
|
+
TYPOGRAPHY: () => TYPOGRAPHY,
|
|
46
|
+
UNIT: () => UNIT,
|
|
47
|
+
activateConfig: () => activateConfig,
|
|
48
|
+
applyDocument: () => applyDocument,
|
|
49
|
+
applyHeadings: () => applyHeadings,
|
|
50
|
+
applyReset: () => applyReset,
|
|
51
|
+
applySequenceVars: () => applySequenceVars,
|
|
52
|
+
applySpacingSequence: () => applySpacingSequence,
|
|
53
|
+
applyTimingSequence: () => applyTimingSequence,
|
|
54
|
+
applyTypographySequence: () => applyTypographySequence,
|
|
55
|
+
arrayze: () => arrayze,
|
|
56
|
+
changeLightness: () => changeLightness,
|
|
57
|
+
colorStringToRgbaArray: () => colorStringToRgbaArray,
|
|
58
|
+
deepMerge: () => deepMerge2,
|
|
59
|
+
findHeadingLetter: () => findHeadingLetter,
|
|
60
|
+
findHeadings: () => findHeadings,
|
|
61
|
+
generateSequence: () => generateSequence,
|
|
62
|
+
generateSubSequence: () => generateSubSequence,
|
|
63
|
+
getActiveConfig: () => getActiveConfig,
|
|
64
|
+
getColor: () => getColor,
|
|
65
|
+
getColorShade: () => getColorShade,
|
|
66
|
+
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
67
|
+
getFontFace: () => getFontFace,
|
|
68
|
+
getFontFaceEach: () => getFontFaceEach,
|
|
69
|
+
getFontFaceEachString: () => getFontFaceEachString,
|
|
70
|
+
getFontFaceString: () => getFontFaceString,
|
|
71
|
+
getFontFamily: () => getFontFamily,
|
|
72
|
+
getFontFormat: () => getFontFormat,
|
|
73
|
+
getFontSizeByKey: () => getFontSizeByKey,
|
|
74
|
+
getMediaColor: () => getMediaColor,
|
|
75
|
+
getMediaTheme: () => getMediaTheme,
|
|
76
|
+
getSequenceValue: () => getSequenceValue,
|
|
77
|
+
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
78
|
+
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
79
|
+
getSpacingByKey: () => getSpacingByKey,
|
|
80
|
+
getTheme: () => getTheme,
|
|
81
|
+
getTimingByKey: () => getTimingByKey,
|
|
82
|
+
getTimingFunction: () => getTimingFunction,
|
|
83
|
+
hexToRgb: () => hexToRgb,
|
|
84
|
+
hexToRgbArray: () => hexToRgbArray,
|
|
85
|
+
hexToRgba: () => hexToRgba,
|
|
86
|
+
hslToRgb: () => hslToRgb,
|
|
87
|
+
isArray: () => isArray2,
|
|
88
|
+
isFunction: () => isFunction2,
|
|
89
|
+
isObject: () => isObject2,
|
|
90
|
+
isObjectLike: () => isObjectLike2,
|
|
91
|
+
isString: () => isString2,
|
|
92
|
+
merge: () => merge2,
|
|
93
|
+
mixTwoColors: () => mixTwoColors,
|
|
94
|
+
mixTwoRgb: () => mixTwoRgb,
|
|
95
|
+
mixTwoRgba: () => mixTwoRgba,
|
|
96
|
+
numToLetterMap: () => numToLetterMap,
|
|
97
|
+
opacify: () => opacify,
|
|
98
|
+
rgbArrayToHex: () => rgbArrayToHex,
|
|
99
|
+
rgbToHSL: () => rgbToHSL,
|
|
100
|
+
rgbToHex: () => rgbToHex,
|
|
101
|
+
runThroughMedia: () => runThroughMedia,
|
|
102
|
+
set: () => set,
|
|
103
|
+
setColor: () => setColor,
|
|
104
|
+
setCustomFont: () => setCustomFont,
|
|
105
|
+
setCustomFontMedia: () => setCustomFontMedia,
|
|
106
|
+
setEach: () => setEach,
|
|
107
|
+
setFont: () => setFont,
|
|
108
|
+
setFontFamily: () => setFontFamily,
|
|
109
|
+
setGradient: () => setGradient,
|
|
110
|
+
setInCustomFontMedia: () => setInCustomFontMedia,
|
|
111
|
+
setMediaTheme: () => setMediaTheme,
|
|
112
|
+
setTheme: () => setTheme,
|
|
113
|
+
setValue: () => setValue,
|
|
114
|
+
setVariables: () => setVariables
|
|
115
|
+
});
|
|
116
|
+
module.exports = __toCommonJS(src_exports);
|
|
117
|
+
|
|
118
|
+
// ../../node_modules/@domql/globals/index.js
|
|
119
|
+
var window2 = globalThis;
|
|
120
|
+
var document2 = window2.document;
|
|
121
|
+
|
|
122
|
+
// ../../node_modules/@domql/utils/types.js
|
|
123
|
+
var isObject = (arg) => {
|
|
124
|
+
if (arg === null)
|
|
125
|
+
return false;
|
|
126
|
+
return typeof arg === "object" && arg.constructor === Object;
|
|
127
|
+
};
|
|
128
|
+
var isString = (arg) => typeof arg === "string";
|
|
129
|
+
var isNumber = (arg) => typeof arg === "number";
|
|
130
|
+
var isFunction = (arg) => typeof arg === "function";
|
|
131
|
+
var isBoolean = (arg) => arg === true || arg === false;
|
|
132
|
+
var isNull = (arg) => arg === null;
|
|
133
|
+
var isArray = (arg) => Array.isArray(arg);
|
|
134
|
+
var isObjectLike = (arg) => {
|
|
135
|
+
if (arg === null)
|
|
136
|
+
return false;
|
|
137
|
+
return typeof arg === "object";
|
|
138
|
+
};
|
|
139
|
+
var isDefined = (arg) => {
|
|
140
|
+
return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// ../../node_modules/@domql/utils/object.js
|
|
144
|
+
var merge = (element, obj) => {
|
|
145
|
+
for (const e in obj) {
|
|
146
|
+
const elementProp = element[e];
|
|
147
|
+
const objProp = obj[e];
|
|
148
|
+
if (elementProp === void 0) {
|
|
149
|
+
element[e] = objProp;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return element;
|
|
153
|
+
};
|
|
154
|
+
var deepMerge = (element, extend) => {
|
|
155
|
+
for (const e in extend) {
|
|
156
|
+
const elementProp = element[e];
|
|
157
|
+
const extendProp = extend[e];
|
|
158
|
+
if (e === "parent" || e === "props")
|
|
159
|
+
continue;
|
|
160
|
+
if (elementProp === void 0) {
|
|
161
|
+
element[e] = extendProp;
|
|
162
|
+
} else if (isObjectLike(elementProp) && isObject(extendProp)) {
|
|
163
|
+
deepMerge(elementProp, extendProp);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return element;
|
|
167
|
+
};
|
|
168
|
+
var deepClone = (obj) => {
|
|
169
|
+
if (isArray(obj)) {
|
|
170
|
+
return obj.map(deepClone);
|
|
171
|
+
}
|
|
172
|
+
const o = {};
|
|
173
|
+
for (const prop in obj) {
|
|
174
|
+
let objProp = obj[prop];
|
|
175
|
+
if (prop === "extend" && isArray(objProp)) {
|
|
176
|
+
objProp = mergeArray(objProp);
|
|
177
|
+
}
|
|
178
|
+
if (isArray(objProp)) {
|
|
179
|
+
o[prop] = objProp.map(deepClone);
|
|
180
|
+
} else if (isObject(objProp)) {
|
|
181
|
+
o[prop] = deepClone(objProp);
|
|
182
|
+
} else
|
|
183
|
+
o[prop] = objProp;
|
|
184
|
+
}
|
|
185
|
+
return o;
|
|
186
|
+
};
|
|
187
|
+
var mergeArray = (arr) => {
|
|
188
|
+
return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// ../../node_modules/@domql/utils/node.js
|
|
192
|
+
var createID = function* () {
|
|
193
|
+
let index = 1;
|
|
194
|
+
while (index < index + 1) {
|
|
195
|
+
yield index++;
|
|
196
|
+
}
|
|
197
|
+
}();
|
|
198
|
+
|
|
199
|
+
// src/defaultConfig/index.js
|
|
200
|
+
var defaultConfig_exports = {};
|
|
201
|
+
__export(defaultConfig_exports, {
|
|
202
|
+
ANIMATION: () => ANIMATION,
|
|
203
|
+
BREAKPOINTS: () => BREAKPOINTS,
|
|
204
|
+
CASES: () => CASES,
|
|
205
|
+
COLOR: () => COLOR,
|
|
206
|
+
DEVICES: () => DEVICES,
|
|
207
|
+
DOCUMENT: () => DOCUMENT,
|
|
208
|
+
FONT: () => FONT,
|
|
209
|
+
FONT_FACE: () => FONT_FACE,
|
|
210
|
+
FONT_FAMILY: () => FONT_FAMILY,
|
|
211
|
+
FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
|
|
212
|
+
GRADIENT: () => GRADIENT,
|
|
213
|
+
ICONS: () => ICONS,
|
|
214
|
+
MEDIA: () => MEDIA,
|
|
215
|
+
RESET: () => RESET,
|
|
216
|
+
SEQUENCE: () => SEQUENCE,
|
|
217
|
+
SPACING: () => SPACING,
|
|
218
|
+
THEME: () => THEME,
|
|
219
|
+
TIMING: () => TIMING,
|
|
220
|
+
TYPOGRAPHY: () => TYPOGRAPHY,
|
|
221
|
+
UNIT: () => UNIT
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// src/defaultConfig/sequence.js
|
|
225
|
+
var SEQUENCE = {
|
|
226
|
+
"minor-second": 1.067,
|
|
227
|
+
"major-second": 1.125,
|
|
228
|
+
"minor-third": 1.2,
|
|
229
|
+
"major-third": 1.25,
|
|
230
|
+
"perfect-fourth": 1.333,
|
|
231
|
+
"augmented-fourth": 1.414,
|
|
232
|
+
"perfect-fifth": 1.5,
|
|
233
|
+
"minor-sixth": 1.6,
|
|
234
|
+
phi: 1.618,
|
|
235
|
+
// golden-ratio
|
|
236
|
+
"major-sixth": 1.667,
|
|
237
|
+
"square-root-3": 1.732,
|
|
238
|
+
// theodorus
|
|
239
|
+
"minor-seventh": 1.778,
|
|
240
|
+
"major-seventh": 1.875,
|
|
241
|
+
octave: 2,
|
|
242
|
+
"square-root-5": 2.23,
|
|
243
|
+
// pythagoras
|
|
244
|
+
"major-tenth": 2.5,
|
|
245
|
+
"major-eleventh": 2.667,
|
|
246
|
+
"major-twelfth": 3,
|
|
247
|
+
pi: 3.14,
|
|
248
|
+
// archimedes
|
|
249
|
+
"double-octave": 4
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// src/defaultConfig/unit.js
|
|
253
|
+
var UNIT = {
|
|
254
|
+
default: "em"
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/defaultConfig/typography.js
|
|
258
|
+
var defaultProps = {
|
|
259
|
+
browserDefault: 16,
|
|
260
|
+
base: 16,
|
|
261
|
+
type: "font-size",
|
|
262
|
+
ratio: SEQUENCE["minor-third"],
|
|
263
|
+
range: [-3, 12],
|
|
264
|
+
h1Matches: 6,
|
|
265
|
+
lineHeight: 1.5,
|
|
266
|
+
unit: "em",
|
|
267
|
+
styles: {},
|
|
268
|
+
sequence: {},
|
|
269
|
+
scales: {},
|
|
270
|
+
vars: {}
|
|
271
|
+
};
|
|
272
|
+
var TYPOGRAPHY = defaultProps;
|
|
273
|
+
|
|
274
|
+
// src/defaultConfig/font.js
|
|
275
|
+
var FONT = {};
|
|
276
|
+
|
|
277
|
+
// src/utils/object.js
|
|
278
|
+
var isString2 = (arg) => typeof arg === "string";
|
|
279
|
+
var isArray2 = (arg) => Array.isArray(arg);
|
|
280
|
+
var isObject2 = (arg) => {
|
|
281
|
+
if (arg === null)
|
|
282
|
+
return false;
|
|
283
|
+
return typeof arg === "object" && arg.constructor === Object;
|
|
284
|
+
};
|
|
285
|
+
var isObjectLike2 = (arg) => {
|
|
286
|
+
if (arg === null)
|
|
287
|
+
return false;
|
|
288
|
+
return typeof arg === "object";
|
|
289
|
+
};
|
|
290
|
+
var merge2 = (obj, original) => {
|
|
291
|
+
for (const e in original) {
|
|
292
|
+
const objProp = obj[e];
|
|
293
|
+
const originalProp = original[e];
|
|
294
|
+
if (objProp === void 0) {
|
|
295
|
+
obj[e] = originalProp;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return obj;
|
|
299
|
+
};
|
|
300
|
+
var deepMerge2 = (obj, obj2) => {
|
|
301
|
+
for (const e in obj2) {
|
|
302
|
+
const objProp = obj[e];
|
|
303
|
+
const obj2Prop = obj2[e];
|
|
304
|
+
if (objProp === void 0) {
|
|
305
|
+
obj[e] = obj2Prop;
|
|
306
|
+
} else if (isObjectLike2(objProp) && isObject2(obj2Prop)) {
|
|
307
|
+
deepMerge2(objProp, obj2Prop);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return obj;
|
|
311
|
+
};
|
|
312
|
+
var arrayze = (val) => {
|
|
313
|
+
if (isString2(val))
|
|
314
|
+
return val.split(" ");
|
|
315
|
+
if (isObject2(val))
|
|
316
|
+
return Object.keys(val).map((v) => val[v]);
|
|
317
|
+
if (isArray2(val))
|
|
318
|
+
return val;
|
|
319
|
+
};
|
|
320
|
+
var isFunction2 = (arg) => typeof arg === "function";
|
|
321
|
+
|
|
322
|
+
// src/utils/color.js
|
|
323
|
+
var ENV = "development";
|
|
324
|
+
var colorStringToRgbaArray = (color) => {
|
|
325
|
+
if (color === "")
|
|
326
|
+
return;
|
|
327
|
+
if (color.toLowerCase() === "transparent")
|
|
328
|
+
return [0, 0, 0, 0];
|
|
329
|
+
if (color[0] === "#") {
|
|
330
|
+
if (color.length < 7) {
|
|
331
|
+
color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
|
|
332
|
+
}
|
|
333
|
+
return [
|
|
334
|
+
parseInt(color.substr(1, 2), 16),
|
|
335
|
+
parseInt(color.substr(3, 2), 16),
|
|
336
|
+
parseInt(color.substr(5, 2), 16),
|
|
337
|
+
color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
if (color.indexOf("rgb") === -1) {
|
|
341
|
+
const elem = document.body.appendChild(document.createElement("fictum"));
|
|
342
|
+
const flag = "rgb(1, 2, 3)";
|
|
343
|
+
elem.style.color = flag;
|
|
344
|
+
if (elem.style.color !== flag)
|
|
345
|
+
return;
|
|
346
|
+
elem.style.color = color;
|
|
347
|
+
if (elem.style.color === flag || elem.style.color === "")
|
|
348
|
+
return;
|
|
349
|
+
color = window.getComputedStyle(elem).color;
|
|
350
|
+
document.body.removeChild(elem);
|
|
351
|
+
}
|
|
352
|
+
if (color.indexOf("rgb") === 0) {
|
|
353
|
+
if (color.indexOf("rgba") === -1)
|
|
354
|
+
color = `${color}, 1`;
|
|
355
|
+
return color.match(/[\.\d]+/g).map((a) => +a);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var mixTwoColors = (colorA, colorB, range = 0.5) => {
|
|
359
|
+
colorA = colorStringToRgbaArray(colorA);
|
|
360
|
+
colorB = colorStringToRgbaArray(colorB);
|
|
361
|
+
return mixTwoRgba(colorA, colorB, range);
|
|
362
|
+
};
|
|
363
|
+
var hexToRgb = (hex, alpha = 1) => {
|
|
364
|
+
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
365
|
+
return `rgb(${r},${g},${b})`;
|
|
366
|
+
};
|
|
367
|
+
var hexToRgbArray = (hex, alpha = 1) => {
|
|
368
|
+
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
369
|
+
return [r, g, b];
|
|
370
|
+
};
|
|
371
|
+
var rgbToHex = (r, g, b) => {
|
|
372
|
+
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
373
|
+
};
|
|
374
|
+
var rgbArrayToHex = ([r, g, b]) => {
|
|
375
|
+
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
376
|
+
};
|
|
377
|
+
var hexToRgba = (hex, alpha = 1) => {
|
|
378
|
+
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
379
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
380
|
+
};
|
|
381
|
+
var mixTwoRgb = (colorA, colorB, range = 0.5) => {
|
|
382
|
+
const arr = [];
|
|
383
|
+
for (let i = 0; i < 3; i++) {
|
|
384
|
+
arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range);
|
|
385
|
+
}
|
|
386
|
+
return `rgb(${arr})`;
|
|
387
|
+
};
|
|
388
|
+
var changeLightness = (delta, hsl) => {
|
|
389
|
+
const [hue, saturation, lightness] = hsl;
|
|
390
|
+
const newLightness = Math.max(
|
|
391
|
+
0,
|
|
392
|
+
Math.min(100, lightness + parseFloat(delta))
|
|
393
|
+
);
|
|
394
|
+
return [hue, saturation, newLightness];
|
|
395
|
+
};
|
|
396
|
+
var rgbToHSL = (r, g, b) => {
|
|
397
|
+
const a = Math.max(r, g, b);
|
|
398
|
+
const n = a - Math.min(r, g, b);
|
|
399
|
+
const f = 1 - Math.abs(a + a - n - 1);
|
|
400
|
+
const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
|
|
401
|
+
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
|
|
402
|
+
};
|
|
403
|
+
var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(
|
|
404
|
+
Math.min(k - 3, 9 - k, 1),
|
|
405
|
+
-1
|
|
406
|
+
)) => [f(0), f(8), f(4)];
|
|
407
|
+
var getColorShade = (col, amt) => {
|
|
408
|
+
const num = parseInt(col, 16);
|
|
409
|
+
let r = (num >> 16) + amt;
|
|
410
|
+
if (r > 255)
|
|
411
|
+
r = 255;
|
|
412
|
+
else if (r < 0)
|
|
413
|
+
r = 0;
|
|
414
|
+
let b = (num >> 8 & 255) + amt;
|
|
415
|
+
if (b > 255)
|
|
416
|
+
b = 255;
|
|
417
|
+
else if (b < 0)
|
|
418
|
+
b = 0;
|
|
419
|
+
let g = (num & 255) + amt;
|
|
420
|
+
if (g > 255)
|
|
421
|
+
g = 255;
|
|
422
|
+
else if (g < 0)
|
|
423
|
+
g = 0;
|
|
424
|
+
return (g | b << 8 | r << 16).toString(16);
|
|
425
|
+
};
|
|
426
|
+
var mixTwoRgba = (colorA, colorB, range = 0.5) => {
|
|
427
|
+
const arr = [];
|
|
428
|
+
for (let i = 0; i < 4; i++) {
|
|
429
|
+
const round = i === 3 ? (x) => x : Math.round;
|
|
430
|
+
arr[i] = round(
|
|
431
|
+
colorA[i] + (colorB[i] - colorA[i]) * range
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
return `rgba(${arr})`;
|
|
435
|
+
};
|
|
436
|
+
var opacify = (color, opacity) => {
|
|
437
|
+
const arr = colorStringToRgbaArray(color);
|
|
438
|
+
if (!arr) {
|
|
439
|
+
if (ENV === "test" || ENV === "development")
|
|
440
|
+
console.warn(color + "color is not rgba");
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
arr[3] = opacity;
|
|
444
|
+
return `rgba(${arr})`;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/utils/font.js
|
|
448
|
+
var getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
449
|
+
if (LIBRARY[key])
|
|
450
|
+
return LIBRARY[key].value;
|
|
451
|
+
if (LIBRARY.default)
|
|
452
|
+
return LIBRARY[LIBRARY.default].value;
|
|
453
|
+
const hasValue = Object.keys(LIBRARY)[0];
|
|
454
|
+
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
|
|
455
|
+
};
|
|
456
|
+
var getFontFormat = (url) => url.split(/[#?]/)[0].split(".").pop().trim();
|
|
457
|
+
var setInCustomFontMedia = (str) => `@font-face { ${str} }`;
|
|
458
|
+
var setCustomFont = (name, url, weight) => `
|
|
459
|
+
font-family: '${name}';
|
|
460
|
+
font-style: normal;
|
|
461
|
+
${weight && `font-weight: ${weight};`}
|
|
462
|
+
src: url('${url}') format('${getFontFormat(url)}');`;
|
|
463
|
+
var setCustomFontMedia = (name, url, weight) => `@font-face {
|
|
464
|
+
${setCustomFont(name, url, weight)}
|
|
465
|
+
}`;
|
|
466
|
+
var getFontFaceEach = (name, weights) => {
|
|
467
|
+
const keys = Object.keys(weights);
|
|
468
|
+
return keys.map((key) => {
|
|
469
|
+
const { url, fontWeight } = weights[key];
|
|
470
|
+
return setCustomFont(name, url, fontWeight);
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
var getFontFace = (LIBRARY) => {
|
|
474
|
+
const keys = Object.keys(LIBRARY);
|
|
475
|
+
return keys.map((key) => getFontFaceEach(key, LIBRARY[key].value));
|
|
476
|
+
};
|
|
477
|
+
var getFontFaceEachString = (name, weights) => {
|
|
478
|
+
const isArr = weights[0];
|
|
479
|
+
if (isArr)
|
|
480
|
+
return getFontFaceEach(name, weights).map(setInCustomFontMedia);
|
|
481
|
+
return setCustomFontMedia(name, weights.url);
|
|
482
|
+
};
|
|
483
|
+
var getFontFaceString = (LIBRARY) => {
|
|
484
|
+
const keys = Object.keys(LIBRARY);
|
|
485
|
+
return keys.map((key) => getFontFaceEachString(key, LIBRARY[key].value));
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// ../../node_modules/@symbo.ls/utils/src/index.js
|
|
489
|
+
var toCamelCase = (str) => {
|
|
490
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
|
|
491
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
492
|
+
}).replace(/\s+/g, "");
|
|
493
|
+
};
|
|
494
|
+
var toDashCase = (val) => val.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase()).replace(".", "-");
|
|
495
|
+
|
|
496
|
+
// src/utils/sequence.js
|
|
497
|
+
var numToLetterMap = {
|
|
498
|
+
"-6": "U",
|
|
499
|
+
"-5": "V",
|
|
500
|
+
"-4": "W",
|
|
501
|
+
"-3": "X",
|
|
502
|
+
"-2": "Y",
|
|
503
|
+
"-1": "Z",
|
|
504
|
+
0: "A",
|
|
505
|
+
1: "B",
|
|
506
|
+
2: "C",
|
|
507
|
+
3: "D",
|
|
508
|
+
4: "E",
|
|
509
|
+
5: "F",
|
|
510
|
+
6: "G",
|
|
511
|
+
7: "H",
|
|
512
|
+
8: "I",
|
|
513
|
+
9: "J",
|
|
514
|
+
10: "K",
|
|
515
|
+
11: "L",
|
|
516
|
+
12: "M",
|
|
517
|
+
13: "N",
|
|
518
|
+
14: "O",
|
|
519
|
+
15: "P",
|
|
520
|
+
16: "Q",
|
|
521
|
+
17: "R",
|
|
522
|
+
18: "S",
|
|
523
|
+
19: "T"
|
|
524
|
+
};
|
|
525
|
+
var setSequenceValue = (props, sequenceProps) => {
|
|
526
|
+
const { key, variable, value, scaling, index } = props;
|
|
527
|
+
sequenceProps.sequence[key] = {
|
|
528
|
+
key,
|
|
529
|
+
decimal: ~~(value * 100) / 100,
|
|
530
|
+
val: ~~value,
|
|
531
|
+
scaling,
|
|
532
|
+
index,
|
|
533
|
+
variable
|
|
534
|
+
};
|
|
535
|
+
sequenceProps.scales[key] = scaling;
|
|
536
|
+
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
537
|
+
};
|
|
538
|
+
var generateSubSequence = (props, sequenceProps) => {
|
|
539
|
+
const { key, base, value, ratio, variable, index } = props;
|
|
540
|
+
const next = value * ratio;
|
|
541
|
+
const diff = next - value;
|
|
542
|
+
const smallscale = diff / 1.618;
|
|
543
|
+
const valueRounded = ~~value;
|
|
544
|
+
const nextRounded = ~~next;
|
|
545
|
+
const diffRounded = nextRounded - valueRounded;
|
|
546
|
+
let arr = [];
|
|
547
|
+
const first = next - smallscale;
|
|
548
|
+
const second = value + smallscale;
|
|
549
|
+
const middle = (first + second) / 2;
|
|
550
|
+
if (diffRounded > 16)
|
|
551
|
+
arr = [first, middle, second];
|
|
552
|
+
else
|
|
553
|
+
arr = [first, second];
|
|
554
|
+
arr.map((v, k) => {
|
|
555
|
+
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
556
|
+
const newVar = variable + (k + 1);
|
|
557
|
+
const props2 = {
|
|
558
|
+
key: key + (k + 1),
|
|
559
|
+
variable: newVar,
|
|
560
|
+
value: v,
|
|
561
|
+
scaling,
|
|
562
|
+
index: index + (k + 1) / 10
|
|
563
|
+
};
|
|
564
|
+
return setSequenceValue(props2, sequenceProps);
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
568
|
+
return base * Math.pow(ratio, key);
|
|
569
|
+
};
|
|
570
|
+
var generateSequence = (sequenceProps) => {
|
|
571
|
+
const { type, base, ratio, range, subSequence } = sequenceProps;
|
|
572
|
+
const n = Math.abs(range[0]) + Math.abs(range[1]);
|
|
573
|
+
const prefix = "--" + (type && type.replace(".", "-")) + "-";
|
|
574
|
+
for (let i = 0; i <= n; i++) {
|
|
575
|
+
const key = range[1] - i;
|
|
576
|
+
const letterKey = numToLetterMap[key];
|
|
577
|
+
const value = switchSequenceOnNegative(key, base, ratio);
|
|
578
|
+
const scaling = ~~(value / base * 100) / 100;
|
|
579
|
+
const variable = prefix + letterKey;
|
|
580
|
+
const props = {
|
|
581
|
+
key: letterKey,
|
|
582
|
+
variable,
|
|
583
|
+
value,
|
|
584
|
+
base,
|
|
585
|
+
scaling,
|
|
586
|
+
ratio,
|
|
587
|
+
index: key
|
|
588
|
+
};
|
|
589
|
+
setSequenceValue(props, sequenceProps);
|
|
590
|
+
if (subSequence)
|
|
591
|
+
generateSubSequence(props, sequenceProps);
|
|
592
|
+
}
|
|
593
|
+
return sequenceProps;
|
|
594
|
+
};
|
|
595
|
+
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
596
|
+
const CONFIG2 = getActiveConfig();
|
|
597
|
+
const { UNIT: UNIT2 } = CONFIG2;
|
|
598
|
+
const {
|
|
599
|
+
sequence,
|
|
600
|
+
unit = UNIT2.default,
|
|
601
|
+
useVariable
|
|
602
|
+
} = sequenceProps;
|
|
603
|
+
if (isString(value) && value.slice(0, 2) === "--")
|
|
604
|
+
return `var(${value})`;
|
|
605
|
+
const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
|
|
606
|
+
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
607
|
+
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
608
|
+
if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || !startsWithDashOrLetter)
|
|
609
|
+
return value;
|
|
610
|
+
const letterVal = value.toUpperCase();
|
|
611
|
+
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
612
|
+
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
613
|
+
let mediaName = "";
|
|
614
|
+
if (absValue.includes("-")) {
|
|
615
|
+
mediaName = "-" + absValue.split("-")[1].toLowerCase();
|
|
616
|
+
absValue = absValue.split("-")[0];
|
|
617
|
+
}
|
|
618
|
+
const varValue = (v) => `var(${prefix}${v}${mediaName})`;
|
|
619
|
+
if (absValue.includes("+")) {
|
|
620
|
+
const args = absValue.split("+");
|
|
621
|
+
const [first, second] = args;
|
|
622
|
+
const joint = `${varValue(first)} + ${varValue(second)}`;
|
|
623
|
+
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
624
|
+
} else if (absValue.includes("-")) {
|
|
625
|
+
const args = absValue.split("-");
|
|
626
|
+
const [first, second] = args;
|
|
627
|
+
const joint = `${varValue(first)} - ${varValue(second)}`;
|
|
628
|
+
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
629
|
+
}
|
|
630
|
+
if (!sequence[absValue] && absValue.length === 2) {
|
|
631
|
+
if (CONFIG2.verbose)
|
|
632
|
+
console.warn(absValue, "- value is not found because `subSequence` is set to false");
|
|
633
|
+
absValue = absValue.slice(0, 1);
|
|
634
|
+
}
|
|
635
|
+
if (useVariable || CONFIG2.useVariable) {
|
|
636
|
+
const varValue2 = `var(${prefix}${absValue}${mediaName})`;
|
|
637
|
+
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
638
|
+
}
|
|
639
|
+
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
640
|
+
if (!sequenceItem)
|
|
641
|
+
return console.warn("can't find", sequence, absValue);
|
|
642
|
+
if (unit === "ms" || unit === "s") {
|
|
643
|
+
return isNegative + sequenceItem.val + unit;
|
|
644
|
+
}
|
|
645
|
+
return isNegative + sequenceItem.scaling + unit;
|
|
646
|
+
};
|
|
647
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
|
|
648
|
+
if (typeof value !== "string") {
|
|
649
|
+
console.warn(propertyName, value, "is not a string");
|
|
650
|
+
return {};
|
|
651
|
+
}
|
|
652
|
+
if (value === "-" || value === "")
|
|
653
|
+
return {};
|
|
654
|
+
return { [propertyName]: getSequenceValue(value, sequenceProps) };
|
|
655
|
+
};
|
|
656
|
+
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
657
|
+
var findHeadings = (propertyNames) => {
|
|
658
|
+
const { h1Matches, sequence } = propertyNames;
|
|
659
|
+
return new Array(6).fill(null).map((_, i) => {
|
|
660
|
+
const findLetter = findHeadingLetter(h1Matches, i);
|
|
661
|
+
return sequence[findLetter];
|
|
662
|
+
});
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
// src/utils/var.js
|
|
666
|
+
var setVariables = (result, key) => {
|
|
667
|
+
const CONFIG2 = getActiveConfig();
|
|
668
|
+
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
669
|
+
if (isObjectLike(result.value)) {
|
|
670
|
+
} else {
|
|
671
|
+
CSS_VARS2[result.var] = result.value;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var applySequenceVars = (props, mediaName, options = {}) => {
|
|
675
|
+
const CONFIG2 = getActiveConfig();
|
|
676
|
+
const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
677
|
+
const unit = props.unit || UNIT2.default;
|
|
678
|
+
const { sequence, scales } = props;
|
|
679
|
+
for (const key in sequence) {
|
|
680
|
+
const item = sequence[key];
|
|
681
|
+
const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
682
|
+
if (mediaName) {
|
|
683
|
+
const query = MEDIA2[mediaName];
|
|
684
|
+
if (!query) {
|
|
685
|
+
if (CONFIG2.verbose)
|
|
686
|
+
console.warn("Can't find query ", query);
|
|
687
|
+
}
|
|
688
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
689
|
+
if (!underMediaQuery)
|
|
690
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
691
|
+
underMediaQuery[item.variable] = `var(${item.variable + "-" + mediaName})`;
|
|
692
|
+
CSS_VARS2[item.variable + "-" + mediaName] = value;
|
|
693
|
+
} else {
|
|
694
|
+
if (options.useDefault === false) {
|
|
695
|
+
CSS_VARS2[item.variable] = value;
|
|
696
|
+
} else {
|
|
697
|
+
CSS_VARS2[item.variable + "-default"] = value;
|
|
698
|
+
CSS_VARS2[item.variable] = `var(${item.variable + "-default"})`;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// src/defaultConfig/font-family.js
|
|
705
|
+
var FONT_FAMILY = {};
|
|
706
|
+
var FONT_FAMILY_TYPES = {
|
|
707
|
+
serif: "Helvetica, Arial, sans-serif, --system-default",
|
|
708
|
+
"sans-serif": "Times New Roman, Georgia, serif, --system-default",
|
|
709
|
+
monospace: "Courier New, monospace, --system-default"
|
|
710
|
+
};
|
|
711
|
+
var FONT_FACE = getFontFace(FONT_FAMILY);
|
|
712
|
+
|
|
713
|
+
// src/defaultConfig/media.js
|
|
714
|
+
var MEDIA = {
|
|
715
|
+
tv: "(min-width: 2780px)",
|
|
716
|
+
screenL: "(max-width: 1920px)",
|
|
717
|
+
screenM: "(max-width: 1680px)",
|
|
718
|
+
screenS: "(max-width: 1440px)",
|
|
719
|
+
tabletL: "(max-width: 1366px)",
|
|
720
|
+
tabletM: "(max-width: 1280px)",
|
|
721
|
+
tabletS: "(max-width: 1024px)",
|
|
722
|
+
mobileL: "(max-width: 768px)",
|
|
723
|
+
mobileM: "(max-width: 560px)",
|
|
724
|
+
mobileS: "(max-width: 480px)",
|
|
725
|
+
mobileXS: "(max-width: 375px)",
|
|
726
|
+
light: "(prefers-color-scheme: light)",
|
|
727
|
+
dark: "(prefers-color-scheme: dark)",
|
|
728
|
+
print: "print"
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// src/defaultConfig/spacing.js
|
|
732
|
+
var defaultProps2 = {
|
|
733
|
+
base: TYPOGRAPHY.base,
|
|
734
|
+
type: "spacing",
|
|
735
|
+
ratio: SEQUENCE.phi,
|
|
736
|
+
range: [-5, 15],
|
|
737
|
+
subSequence: true,
|
|
738
|
+
unit: "em",
|
|
739
|
+
sequence: {},
|
|
740
|
+
scales: {},
|
|
741
|
+
vars: {}
|
|
742
|
+
};
|
|
743
|
+
var SPACING = defaultProps2;
|
|
744
|
+
|
|
745
|
+
// src/defaultConfig/color.js
|
|
746
|
+
var COLOR = {};
|
|
747
|
+
var GRADIENT = {};
|
|
748
|
+
|
|
749
|
+
// src/defaultConfig/theme.js
|
|
750
|
+
var THEME = {};
|
|
751
|
+
|
|
752
|
+
// src/defaultConfig/icons.js
|
|
753
|
+
var ICONS = {};
|
|
754
|
+
|
|
755
|
+
// src/defaultConfig/timing.js
|
|
756
|
+
var defaultProps3 = {
|
|
757
|
+
default: 150,
|
|
758
|
+
base: 150,
|
|
759
|
+
type: "timing",
|
|
760
|
+
ratio: SEQUENCE["perfect-fourth"],
|
|
761
|
+
range: [-3, 12],
|
|
762
|
+
unit: "ms",
|
|
763
|
+
sequence: {},
|
|
764
|
+
scales: {},
|
|
765
|
+
vars: {}
|
|
766
|
+
};
|
|
767
|
+
var TIMING = defaultProps3;
|
|
768
|
+
|
|
769
|
+
// src/defaultConfig/document.js
|
|
770
|
+
var DOCUMENT = {};
|
|
771
|
+
|
|
772
|
+
// src/defaultConfig/responsive.js
|
|
773
|
+
var BREAKPOINTS = {
|
|
774
|
+
screenL: 1920,
|
|
775
|
+
screenM: 1680,
|
|
776
|
+
screenS: 1440,
|
|
777
|
+
tabletL: 1366,
|
|
778
|
+
tabletM: 1280,
|
|
779
|
+
tabletS: 1024,
|
|
780
|
+
mobileL: 768,
|
|
781
|
+
mobileM: 560,
|
|
782
|
+
mobileS: 480,
|
|
783
|
+
mobileXS: 375
|
|
784
|
+
};
|
|
785
|
+
var DEVICES = {
|
|
786
|
+
screenL: [1920, 1024],
|
|
787
|
+
screenM: [1680, 1024],
|
|
788
|
+
screenS: [1440, 978],
|
|
789
|
+
tabletL: [1366, 926],
|
|
790
|
+
tabletM: [1280, 768],
|
|
791
|
+
tabletS: [1024, 768],
|
|
792
|
+
mobileL: [768, 375],
|
|
793
|
+
mobileM: [560, 768],
|
|
794
|
+
mobileS: [480, 768],
|
|
795
|
+
mobileXS: [375, 768]
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// src/defaultConfig/cases.js
|
|
799
|
+
var CASES = {};
|
|
800
|
+
|
|
801
|
+
// src/defaultConfig/animation.js
|
|
802
|
+
var ANIMATION = {};
|
|
803
|
+
|
|
804
|
+
// src/defaultConfig/index.js
|
|
805
|
+
var RESET = {};
|
|
806
|
+
|
|
807
|
+
// src/factory.js
|
|
808
|
+
var CSS_VARS = {};
|
|
809
|
+
var CONFIG = {
|
|
810
|
+
verbose: false,
|
|
811
|
+
useVariable: true,
|
|
812
|
+
useReset: true,
|
|
813
|
+
CSS_VARS,
|
|
814
|
+
...defaultConfig_exports
|
|
815
|
+
};
|
|
816
|
+
var cachedConfig = deepClone(CONFIG);
|
|
817
|
+
var FACTORY = {
|
|
818
|
+
active: "0",
|
|
819
|
+
0: CONFIG
|
|
820
|
+
};
|
|
821
|
+
var activateConfig = (def) => {
|
|
822
|
+
if (isDefined(def)) {
|
|
823
|
+
FACTORY.active = def;
|
|
824
|
+
}
|
|
825
|
+
return FACTORY[def || FACTORY.active];
|
|
826
|
+
};
|
|
827
|
+
var getActiveConfig = (def) => {
|
|
828
|
+
if (isDefined(def) && !FACTORY[def]) {
|
|
829
|
+
FACTORY[def] = deepClone(cachedConfig);
|
|
830
|
+
return FACTORY[def];
|
|
831
|
+
}
|
|
832
|
+
return FACTORY[def || FACTORY.active];
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
// src/system/color.js
|
|
836
|
+
var getColor = (value, key) => {
|
|
837
|
+
const CONFIG2 = getActiveConfig();
|
|
838
|
+
if (!isString(value)) {
|
|
839
|
+
if (CONFIG2.verbose)
|
|
840
|
+
console.warn(value, "- type for color is not valid");
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (value.slice(0, 2) === "--")
|
|
844
|
+
return `var(${value})`;
|
|
845
|
+
if (key && value[key])
|
|
846
|
+
value = value[key];
|
|
847
|
+
const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
|
|
848
|
+
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
849
|
+
let val = COLOR2[name] || GRADIENT2[name];
|
|
850
|
+
if (!val) {
|
|
851
|
+
if (CONFIG2.verbose)
|
|
852
|
+
console.warn("Can't find color ", name);
|
|
853
|
+
return value;
|
|
854
|
+
}
|
|
855
|
+
if (key) {
|
|
856
|
+
if (val[key])
|
|
857
|
+
val = val[key];
|
|
858
|
+
else if (CONFIG2.verbose)
|
|
859
|
+
console.warn(value, " - does not have ", key);
|
|
860
|
+
}
|
|
861
|
+
let rgb = val.rgb;
|
|
862
|
+
if (rgb) {
|
|
863
|
+
if (tone) {
|
|
864
|
+
if (!val[tone]) {
|
|
865
|
+
const toHex = rgbArrayToHex(rgb.split(", ").map((v) => parseFloat(v)));
|
|
866
|
+
if (tone.slice(0, 1) === "-" || tone.slice(0, 1) === "+") {
|
|
867
|
+
rgb = hexToRgbArray(getColorShade(toHex, parseFloat(tone))).join(", ");
|
|
868
|
+
} else {
|
|
869
|
+
const [r, g, b] = [...rgb.split(", ").map((v) => parseInt(v))];
|
|
870
|
+
const hsl = rgbToHSL(r, g, b);
|
|
871
|
+
const [h, s, l] = hsl;
|
|
872
|
+
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
|
|
873
|
+
rgb = newRgb;
|
|
874
|
+
}
|
|
875
|
+
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
876
|
+
} else
|
|
877
|
+
rgb = val[tone].rgb;
|
|
878
|
+
}
|
|
879
|
+
if (alpha)
|
|
880
|
+
return `rgba(${rgb}, ${alpha})`;
|
|
881
|
+
return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
882
|
+
} else
|
|
883
|
+
return CONFIG2.useVariable ? `var(${val.var})` : val.value;
|
|
884
|
+
};
|
|
885
|
+
var getMediaColor = (value, property, globalTheme) => {
|
|
886
|
+
const CONFIG2 = getActiveConfig();
|
|
887
|
+
if (!globalTheme)
|
|
888
|
+
globalTheme = CONFIG2.globalTheme;
|
|
889
|
+
if (!isString(value)) {
|
|
890
|
+
if (CONFIG2.verbose)
|
|
891
|
+
console.warn(value, "- type for color is not valid");
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (value.slice(0, 2) === "--")
|
|
895
|
+
return { [property]: `var(${value})` };
|
|
896
|
+
const [name] = isArray(value) ? value : value.split(" ");
|
|
897
|
+
const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
|
|
898
|
+
const val = COLOR2[name] || GRADIENT2[name];
|
|
899
|
+
const isObj = isObject(val);
|
|
900
|
+
if (isObj && val.value)
|
|
901
|
+
return { [property]: getColor(value, globalTheme) };
|
|
902
|
+
else if (isObj) {
|
|
903
|
+
if (globalTheme)
|
|
904
|
+
return { [property]: getColor(value, `@${globalTheme}`) };
|
|
905
|
+
else {
|
|
906
|
+
const obj = {};
|
|
907
|
+
for (const mediaName in val) {
|
|
908
|
+
const query = CONFIG2.MEDIA[mediaName.slice(1)];
|
|
909
|
+
const media = `@media screen and ${query}`;
|
|
910
|
+
obj[media] = { [property]: getColor(value, mediaName) };
|
|
911
|
+
}
|
|
912
|
+
return obj;
|
|
913
|
+
}
|
|
914
|
+
} else {
|
|
915
|
+
if (CONFIG2.verbose)
|
|
916
|
+
console.warn("Can't find color", value);
|
|
917
|
+
return { [property]: value };
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
var setColor = (val, key, suffix) => {
|
|
921
|
+
const CONFIG2 = getActiveConfig();
|
|
922
|
+
if (isString(val) && val.slice(0, 2) === "--")
|
|
923
|
+
val = getColor(val.slice(2));
|
|
924
|
+
if (isArray(val)) {
|
|
925
|
+
return {
|
|
926
|
+
"@light": setColor(val[0], key, "light"),
|
|
927
|
+
"@dark": setColor(val[1], key, "dark")
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
if (isObject(val)) {
|
|
931
|
+
const obj = {};
|
|
932
|
+
for (const variant in val)
|
|
933
|
+
obj[variant] = setColor(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
934
|
+
return obj;
|
|
935
|
+
}
|
|
936
|
+
const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
|
|
937
|
+
const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val);
|
|
938
|
+
const alpha = parseFloat(a.toFixed(2));
|
|
939
|
+
const rgb = `${r}, ${g}, ${b}`;
|
|
940
|
+
const value = `rgba(${rgb}, ${alpha})`;
|
|
941
|
+
if (CONFIG2.useVariable) {
|
|
942
|
+
CONFIG2.CSS_VARS[CSSVar] = value;
|
|
943
|
+
}
|
|
944
|
+
return {
|
|
945
|
+
var: CSSVar,
|
|
946
|
+
rgb,
|
|
947
|
+
alpha,
|
|
948
|
+
value
|
|
949
|
+
};
|
|
950
|
+
};
|
|
951
|
+
var setGradient = (val, key, suffix) => {
|
|
952
|
+
const CONFIG2 = getActiveConfig();
|
|
953
|
+
if (isString(val) && val.slice(0, 2) === "--")
|
|
954
|
+
val = getColor(val.slice(2));
|
|
955
|
+
if (isArray(val)) {
|
|
956
|
+
return {
|
|
957
|
+
"@light": setGradient(val[0], key, "light"),
|
|
958
|
+
"@dark": setGradient(val[0], key, "dark")
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
if (isObject(val)) {
|
|
962
|
+
const obj = {};
|
|
963
|
+
for (const variant in val)
|
|
964
|
+
obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
965
|
+
return obj;
|
|
966
|
+
}
|
|
967
|
+
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
|
|
968
|
+
if (CONFIG2.useVariable) {
|
|
969
|
+
CONFIG2.CSS_VARS[CSSVar] = val.value || val;
|
|
970
|
+
}
|
|
971
|
+
return {
|
|
972
|
+
var: CSSVar,
|
|
973
|
+
value: val.value || val
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/system/theme.js
|
|
978
|
+
var setThemeValue = (theme) => {
|
|
979
|
+
const value = {};
|
|
980
|
+
const { state, media, helpers, ...rest } = theme;
|
|
981
|
+
const keys = Object.keys(rest);
|
|
982
|
+
keys.map((key) => {
|
|
983
|
+
const conditions = ["color", "Color", "background", "border"];
|
|
984
|
+
const isColor = conditions.some((k) => key.includes(k));
|
|
985
|
+
return value[key] = isColor ? getColor(theme[key]) : theme[key];
|
|
986
|
+
});
|
|
987
|
+
return value;
|
|
988
|
+
};
|
|
989
|
+
var getThemeValue = (theme) => {
|
|
990
|
+
if (theme.value)
|
|
991
|
+
return theme.value;
|
|
992
|
+
theme.value = setThemeValue(theme);
|
|
993
|
+
return theme.value;
|
|
994
|
+
};
|
|
995
|
+
var getTheme = (value, modifier) => {
|
|
996
|
+
const CONFIG2 = getActiveConfig();
|
|
997
|
+
if (CONFIG2.useVariable)
|
|
998
|
+
return getMediaTheme(value, modifier);
|
|
999
|
+
const { THEME: THEME2 } = CONFIG2;
|
|
1000
|
+
if (isString(value)) {
|
|
1001
|
+
const [theme, subtheme] = value.split(" ");
|
|
1002
|
+
const isOurTheme = THEME2[theme];
|
|
1003
|
+
if (isOurTheme) {
|
|
1004
|
+
if (!subtheme && !modifier)
|
|
1005
|
+
return getThemeValue(isOurTheme);
|
|
1006
|
+
value = [theme, subtheme || modifier];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (isObjectLike(value) && value[1]) {
|
|
1010
|
+
const themeName = value[0];
|
|
1011
|
+
const subThemeName = value[1];
|
|
1012
|
+
const { helpers, media, state } = THEME2[themeName];
|
|
1013
|
+
if (media && media[subThemeName])
|
|
1014
|
+
return getThemeValue(media[subThemeName]);
|
|
1015
|
+
if (helpers && helpers[subThemeName])
|
|
1016
|
+
return getThemeValue(helpers[subThemeName]);
|
|
1017
|
+
if (state && state[subThemeName])
|
|
1018
|
+
return getThemeValue(state[subThemeName]);
|
|
1019
|
+
} else if (isObject(value))
|
|
1020
|
+
return setThemeValue(value);
|
|
1021
|
+
};
|
|
1022
|
+
var setInverseTheme = (theme, variant, value) => {
|
|
1023
|
+
if (isObject(variant)) {
|
|
1024
|
+
theme.variants.inverse.value = setThemeValue(variant);
|
|
1025
|
+
} else if (variant === true) {
|
|
1026
|
+
const { color, background } = value;
|
|
1027
|
+
theme.variants.inverse = {
|
|
1028
|
+
value: {
|
|
1029
|
+
color: background,
|
|
1030
|
+
background: color
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
var setPseudo = (theme, key, variant, themeValue) => {
|
|
1036
|
+
const result = getTheme(variant);
|
|
1037
|
+
themeValue[`&:${key}`] = result;
|
|
1038
|
+
if (isObject(variant) && !variant.value)
|
|
1039
|
+
variant.value = result;
|
|
1040
|
+
};
|
|
1041
|
+
var setSelectors = (theme, value) => {
|
|
1042
|
+
const { state } = theme;
|
|
1043
|
+
if (!state)
|
|
1044
|
+
return;
|
|
1045
|
+
const keys = Object.keys(state);
|
|
1046
|
+
keys.map((key) => {
|
|
1047
|
+
const variant = state[key];
|
|
1048
|
+
setPseudo(theme, key, variant, value);
|
|
1049
|
+
return theme;
|
|
1050
|
+
});
|
|
1051
|
+
return theme;
|
|
1052
|
+
};
|
|
1053
|
+
var setPrefersScheme = (theme, key, variant, themeValue) => {
|
|
1054
|
+
const result = getTheme(variant);
|
|
1055
|
+
themeValue[`@media (prefers-color-scheme: ${key})`] = result;
|
|
1056
|
+
if (isObject(variant) && !variant.value)
|
|
1057
|
+
variant.value = result;
|
|
1058
|
+
};
|
|
1059
|
+
var setMedia = (theme, value) => {
|
|
1060
|
+
const { media } = theme;
|
|
1061
|
+
if (!media)
|
|
1062
|
+
return;
|
|
1063
|
+
const keys = Object.keys(media);
|
|
1064
|
+
keys.map((key) => {
|
|
1065
|
+
const variant = media[key];
|
|
1066
|
+
if (key === "dark" || key === "light")
|
|
1067
|
+
setPrefersScheme(theme, key, variant, value);
|
|
1068
|
+
if (key === "inverse")
|
|
1069
|
+
setInverseTheme(theme, variant, value);
|
|
1070
|
+
return theme;
|
|
1071
|
+
});
|
|
1072
|
+
return theme;
|
|
1073
|
+
};
|
|
1074
|
+
var setHelpers = (theme, value) => {
|
|
1075
|
+
const CONFIG2 = getActiveConfig();
|
|
1076
|
+
const { helpers } = theme;
|
|
1077
|
+
if (!helpers)
|
|
1078
|
+
return;
|
|
1079
|
+
const keys = Object.keys(helpers);
|
|
1080
|
+
keys.map((key) => {
|
|
1081
|
+
const helper = helpers[key];
|
|
1082
|
+
if (isString(helper))
|
|
1083
|
+
helpers[key] = CONFIG2.THEME[helper];
|
|
1084
|
+
else
|
|
1085
|
+
getThemeValue(helpers[key]);
|
|
1086
|
+
return theme;
|
|
1087
|
+
});
|
|
1088
|
+
return theme;
|
|
1089
|
+
};
|
|
1090
|
+
var setTheme = (val, key) => {
|
|
1091
|
+
const CONFIG2 = getActiveConfig();
|
|
1092
|
+
if (CONFIG2.useVariable)
|
|
1093
|
+
return setMediaTheme(val, key);
|
|
1094
|
+
const { state, media, helpers } = val;
|
|
1095
|
+
const value = setThemeValue(val, key);
|
|
1096
|
+
const CSSvar = `--theme-${key}`;
|
|
1097
|
+
setSelectors(val, value);
|
|
1098
|
+
setMedia(val, value);
|
|
1099
|
+
setHelpers(val, value);
|
|
1100
|
+
return { var: CSSvar, value, state, media, helpers };
|
|
1101
|
+
};
|
|
1102
|
+
var setMediaTheme = (val, key, suffix, prefers) => {
|
|
1103
|
+
const CONFIG2 = getActiveConfig();
|
|
1104
|
+
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1105
|
+
const theme = { value: val };
|
|
1106
|
+
if (isObjectLike(val)) {
|
|
1107
|
+
for (const param in val) {
|
|
1108
|
+
const symb = param.slice(0, 1);
|
|
1109
|
+
const value = val[param];
|
|
1110
|
+
if (symb === "@" || symb === ":" || symb === ".") {
|
|
1111
|
+
const hasPrefers = symb === "@" && param;
|
|
1112
|
+
theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
|
|
1113
|
+
} else {
|
|
1114
|
+
const color = getColor(value, prefers);
|
|
1115
|
+
const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
|
|
1116
|
+
const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
|
|
1117
|
+
const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
|
|
1118
|
+
if (CONFIG2.useVariable) {
|
|
1119
|
+
CSS_VARS2[CSSVar] = color;
|
|
1120
|
+
theme[param] = `var(${CSSVar})`;
|
|
1121
|
+
} else {
|
|
1122
|
+
theme[param] = color;
|
|
1123
|
+
}
|
|
1124
|
+
theme[`.${param}`] = { [param]: theme[param] };
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (theme["background"] || theme["color"] || theme["backgroundColor"]) {
|
|
1128
|
+
theme[".inversed"] = {
|
|
1129
|
+
color: theme["background"] || theme["backgroundColor"],
|
|
1130
|
+
background: theme["color"]
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if (isString(val) && val.slice(0, 2) === "--") {
|
|
1135
|
+
const { THEME: THEME2 } = CONFIG2;
|
|
1136
|
+
const value = THEME2[val.slice(2)];
|
|
1137
|
+
const getReferenced = getMediaTheme(value);
|
|
1138
|
+
return getReferenced;
|
|
1139
|
+
}
|
|
1140
|
+
return theme;
|
|
1141
|
+
};
|
|
1142
|
+
var recursiveTheme = (val) => {
|
|
1143
|
+
const CONFIG2 = getActiveConfig();
|
|
1144
|
+
const obj = {};
|
|
1145
|
+
for (const param in val) {
|
|
1146
|
+
const symb = param.slice(0, 1);
|
|
1147
|
+
if (isObjectLike(val[param])) {
|
|
1148
|
+
if (symb === "@") {
|
|
1149
|
+
const query = CONFIG2.MEDIA[param.slice(1)];
|
|
1150
|
+
const media = `@media screen and ${query}`;
|
|
1151
|
+
obj[media] = recursiveTheme(val[param]);
|
|
1152
|
+
} else if (symb === ":") {
|
|
1153
|
+
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
1154
|
+
}
|
|
1155
|
+
} else
|
|
1156
|
+
obj[param] = val[param];
|
|
1157
|
+
}
|
|
1158
|
+
return obj;
|
|
1159
|
+
};
|
|
1160
|
+
var findModifierFromArray = (val, modifierArray) => {
|
|
1161
|
+
const currentMod = modifierArray.shift();
|
|
1162
|
+
if (val[currentMod])
|
|
1163
|
+
return findModifierFromArray(val[currentMod], modifierArray);
|
|
1164
|
+
return val;
|
|
1165
|
+
};
|
|
1166
|
+
var findModifier = (val, modifier) => {
|
|
1167
|
+
if (isArray(modifier))
|
|
1168
|
+
return findModifierFromArray(val, modifier);
|
|
1169
|
+
else if (isString(modifier) && val[modifier])
|
|
1170
|
+
return val[modifier];
|
|
1171
|
+
else
|
|
1172
|
+
return val;
|
|
1173
|
+
};
|
|
1174
|
+
var getMediaTheme = (val, mod) => {
|
|
1175
|
+
const CONFIG2 = getActiveConfig();
|
|
1176
|
+
if (isString(val) && val.slice(0, 2) === "--")
|
|
1177
|
+
val = getMediaTheme(val.slice(2));
|
|
1178
|
+
if (!val || !isString(val)) {
|
|
1179
|
+
if (CONFIG2.verbose)
|
|
1180
|
+
console.warn(val, "- theme is not string");
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
const [name, ...modifier] = isArray(val) ? val : val.split(" ");
|
|
1184
|
+
let value = CONFIG2.THEME[name];
|
|
1185
|
+
if (value && (modifier || mod)) {
|
|
1186
|
+
value = findModifier(value, modifier.length ? modifier : mod);
|
|
1187
|
+
}
|
|
1188
|
+
const r = recursiveTheme(value);
|
|
1189
|
+
return r;
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/system/font.js
|
|
1193
|
+
var setFont = (val, key) => {
|
|
1194
|
+
const CSSvar = `--font-${key}`;
|
|
1195
|
+
const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
|
|
1196
|
+
return { var: CSSvar, value: val, fontFace };
|
|
1197
|
+
};
|
|
1198
|
+
var getFontFamily = (key, factory) => {
|
|
1199
|
+
const CONFIG2 = getActiveConfig();
|
|
1200
|
+
const { FONT_FAMILY: FONT_FAMILY2 } = CONFIG2;
|
|
1201
|
+
return getDefaultOrFirstKey(factory || FONT_FAMILY2, key);
|
|
1202
|
+
};
|
|
1203
|
+
var setFontFamily = (val, key) => {
|
|
1204
|
+
const CONFIG2 = getActiveConfig();
|
|
1205
|
+
const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
|
|
1206
|
+
let { value, type } = val;
|
|
1207
|
+
if (val.isDefault)
|
|
1208
|
+
FONT_FAMILY2.default = key;
|
|
1209
|
+
if (isObject(value))
|
|
1210
|
+
value = arrayze(value);
|
|
1211
|
+
const CSSvar = `--font-family-${key}`;
|
|
1212
|
+
const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES2[type]}`;
|
|
1213
|
+
return { var: CSSvar, value: str, arr: value, type };
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// src/system/typography.js
|
|
1217
|
+
var runThroughMedia = (props) => {
|
|
1218
|
+
const CONFIG2 = getActiveConfig();
|
|
1219
|
+
const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
|
|
1220
|
+
for (const prop in props) {
|
|
1221
|
+
const mediaProps = props[prop];
|
|
1222
|
+
if (prop.slice(0, 1) === "@") {
|
|
1223
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
|
|
1224
|
+
merge2(mediaProps, {
|
|
1225
|
+
type,
|
|
1226
|
+
base,
|
|
1227
|
+
ratio,
|
|
1228
|
+
range,
|
|
1229
|
+
subSequence,
|
|
1230
|
+
h1Matches,
|
|
1231
|
+
unit,
|
|
1232
|
+
sequence: {},
|
|
1233
|
+
scales: {},
|
|
1234
|
+
styles: {},
|
|
1235
|
+
vars: {}
|
|
1236
|
+
});
|
|
1237
|
+
generateSequence(mediaProps);
|
|
1238
|
+
const mediaName = prop.slice(1);
|
|
1239
|
+
applySequenceVars(mediaProps, mediaName);
|
|
1240
|
+
const query = MEDIA2[mediaName];
|
|
1241
|
+
TYPOGRAPHY2.styles[`@media screen and ${query}`] = {
|
|
1242
|
+
fontSize: mediaProps.base / TYPOGRAPHY2.browserDefault + unit
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
var applyHeadings = (props) => {
|
|
1248
|
+
const CONFIG2 = getActiveConfig();
|
|
1249
|
+
if (props.h1Matches) {
|
|
1250
|
+
const unit = props.unit;
|
|
1251
|
+
const HEADINGS = findHeadings(props);
|
|
1252
|
+
const { styles } = props;
|
|
1253
|
+
for (const k in HEADINGS) {
|
|
1254
|
+
const headerName = `h${parseInt(k) + 1}`;
|
|
1255
|
+
const headerStyle = styles[headerName];
|
|
1256
|
+
styles[headerName] = {
|
|
1257
|
+
fontSize: CONFIG2.useVariable ? `var(${HEADINGS[k].variable})` : `${HEADINGS[k].scaling}${unit}`,
|
|
1258
|
+
margin: headerStyle ? headerStyle.margin : 0,
|
|
1259
|
+
lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
|
|
1260
|
+
letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
|
|
1261
|
+
fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var applyTypographySequence = () => {
|
|
1267
|
+
const CONFIG2 = getActiveConfig();
|
|
1268
|
+
const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
|
|
1269
|
+
generateSequence(TYPOGRAPHY2);
|
|
1270
|
+
applyHeadings(TYPOGRAPHY2);
|
|
1271
|
+
applySequenceVars(TYPOGRAPHY2);
|
|
1272
|
+
runThroughMedia(TYPOGRAPHY2);
|
|
1273
|
+
};
|
|
1274
|
+
var getFontSizeByKey = (value) => {
|
|
1275
|
+
const CONFIG2 = getActiveConfig();
|
|
1276
|
+
const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
|
|
1277
|
+
return getSequenceValuePropertyPair(
|
|
1278
|
+
value,
|
|
1279
|
+
"fontSize",
|
|
1280
|
+
TYPOGRAPHY2
|
|
1281
|
+
);
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
// src/system/spacing.js
|
|
1285
|
+
var runThroughMedia2 = (sequenceProps) => {
|
|
1286
|
+
for (const prop in sequenceProps) {
|
|
1287
|
+
const mediaProps = sequenceProps[prop];
|
|
1288
|
+
if (prop.slice(0, 1) === "@") {
|
|
1289
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
|
|
1290
|
+
merge2(mediaProps, {
|
|
1291
|
+
type,
|
|
1292
|
+
base,
|
|
1293
|
+
ratio,
|
|
1294
|
+
range,
|
|
1295
|
+
subSequence,
|
|
1296
|
+
h1Matches,
|
|
1297
|
+
unit,
|
|
1298
|
+
sequence: {},
|
|
1299
|
+
scales: {},
|
|
1300
|
+
styles: {},
|
|
1301
|
+
vars: {}
|
|
1302
|
+
});
|
|
1303
|
+
generateSequence(mediaProps);
|
|
1304
|
+
const mediaName = prop.slice(1);
|
|
1305
|
+
applySequenceVars(mediaProps, mediaName);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
var applySpacingSequence = () => {
|
|
1310
|
+
const CONFIG2 = getActiveConfig();
|
|
1311
|
+
const { SPACING: SPACING2 } = CONFIG2;
|
|
1312
|
+
generateSequence(SPACING2);
|
|
1313
|
+
applySequenceVars(SPACING2);
|
|
1314
|
+
runThroughMedia2(SPACING2);
|
|
1315
|
+
};
|
|
1316
|
+
var getSequence = (sequenceProps) => {
|
|
1317
|
+
const CONFIG2 = getActiveConfig();
|
|
1318
|
+
const { SPACING: SPACING2 } = CONFIG2;
|
|
1319
|
+
if (!sequenceProps)
|
|
1320
|
+
return SPACING2;
|
|
1321
|
+
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1322
|
+
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1323
|
+
};
|
|
1324
|
+
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
1325
|
+
const sequence = getSequence(sequenceProps);
|
|
1326
|
+
const stack = arrayze(value);
|
|
1327
|
+
if (!stack)
|
|
1328
|
+
return;
|
|
1329
|
+
if (isString(value) && value.includes("calc")) {
|
|
1330
|
+
return { [propertyName]: value };
|
|
1331
|
+
}
|
|
1332
|
+
if (stack.length > 1) {
|
|
1333
|
+
let suffix = "";
|
|
1334
|
+
if (propertyName === "borderWidth") {
|
|
1335
|
+
propertyName = "border";
|
|
1336
|
+
suffix = "Width";
|
|
1337
|
+
}
|
|
1338
|
+
const directions = {
|
|
1339
|
+
2: ["Block", "Inline"],
|
|
1340
|
+
3: ["BlockStart", "Inline", "BlockEnd"],
|
|
1341
|
+
4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
|
|
1342
|
+
};
|
|
1343
|
+
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
1344
|
+
stack[i],
|
|
1345
|
+
propertyName + direction + suffix,
|
|
1346
|
+
sequence
|
|
1347
|
+
);
|
|
1348
|
+
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
1349
|
+
}
|
|
1350
|
+
return getSequenceValuePropertyPair(
|
|
1351
|
+
value,
|
|
1352
|
+
propertyName,
|
|
1353
|
+
sequence
|
|
1354
|
+
);
|
|
1355
|
+
};
|
|
1356
|
+
var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
1357
|
+
const CONFIG2 = getActiveConfig();
|
|
1358
|
+
const { SPACING: SPACING2 } = CONFIG2;
|
|
1359
|
+
const { spacingRatio, unit } = props;
|
|
1360
|
+
const value = val || props[propertyName];
|
|
1361
|
+
if (spacingRatio) {
|
|
1362
|
+
let sequenceProps = SPACING2[spacingRatio];
|
|
1363
|
+
if (!sequenceProps) {
|
|
1364
|
+
const { type, base, range, subSequence } = SPACING2;
|
|
1365
|
+
sequenceProps = SPACING2[spacingRatio] = merge2({
|
|
1366
|
+
ratio: spacingRatio,
|
|
1367
|
+
type: type + "-" + spacingRatio,
|
|
1368
|
+
unit,
|
|
1369
|
+
sequence: {},
|
|
1370
|
+
scales: {},
|
|
1371
|
+
styles: {},
|
|
1372
|
+
vars: {}
|
|
1373
|
+
}, {
|
|
1374
|
+
base,
|
|
1375
|
+
range,
|
|
1376
|
+
subSequence,
|
|
1377
|
+
ratio: SPACING2.ratio,
|
|
1378
|
+
unit: SPACING2.unit
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
applySequenceVars(sequenceProps, null, { useDefault: false });
|
|
1382
|
+
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
1383
|
+
}
|
|
1384
|
+
return getSpacingByKey(value, propertyName);
|
|
1385
|
+
};
|
|
1386
|
+
|
|
1387
|
+
// src/system/timing.js
|
|
1388
|
+
var applyTimingSequence = () => {
|
|
1389
|
+
const CONFIG2 = getActiveConfig();
|
|
1390
|
+
const { TIMING: TIMING2 } = CONFIG2;
|
|
1391
|
+
generateSequence(TIMING2);
|
|
1392
|
+
applySequenceVars(TIMING2);
|
|
1393
|
+
};
|
|
1394
|
+
var getTimingFunction = (value) => {
|
|
1395
|
+
const CONFIG2 = getActiveConfig();
|
|
1396
|
+
const { TIMING: TIMING2 } = CONFIG2;
|
|
1397
|
+
return TIMING2[value] || TIMING2[toCamelCase(value)] || value;
|
|
1398
|
+
};
|
|
1399
|
+
var getTimingByKey = (value, property = "timing") => {
|
|
1400
|
+
const CONFIG2 = getActiveConfig();
|
|
1401
|
+
const { TIMING: TIMING2 } = CONFIG2;
|
|
1402
|
+
return getSequenceValuePropertyPair(
|
|
1403
|
+
value,
|
|
1404
|
+
property,
|
|
1405
|
+
TIMING2
|
|
1406
|
+
);
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
// src/system/document.js
|
|
1410
|
+
var applyDocument = () => {
|
|
1411
|
+
const CONFIG2 = getActiveConfig();
|
|
1412
|
+
const { DOCUMENT: DOCUMENT2, FONT_FAMILY: FONT_FAMILY2, THEME: THEME2, TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
|
|
1413
|
+
return merge2(DOCUMENT2, {
|
|
1414
|
+
theme: THEME2.document,
|
|
1415
|
+
fontFamily: getDefaultOrFirstKey(FONT_FAMILY2),
|
|
1416
|
+
fontSize: TYPOGRAPHY2.base,
|
|
1417
|
+
lineHeight: TYPOGRAPHY2.lineHeight
|
|
1418
|
+
});
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
// src/system/reset.js
|
|
1422
|
+
var applyReset = (reset = {}) => {
|
|
1423
|
+
const CONFIG2 = getActiveConfig();
|
|
1424
|
+
const { CSS_VARS: CSS_VARS2, RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
|
|
1425
|
+
if (RESET2) {
|
|
1426
|
+
if (RESET2[":root"]) {
|
|
1427
|
+
const configReset = RESET2;
|
|
1428
|
+
const configStyles = TYPOGRAPHY2.styles;
|
|
1429
|
+
configReset.body = {
|
|
1430
|
+
...getMediaTheme("document", `@${CONFIG2.globalTheme}`),
|
|
1431
|
+
...configStyles.body
|
|
1432
|
+
};
|
|
1433
|
+
configReset.h1 = configStyles.h1;
|
|
1434
|
+
configReset.h2 = configStyles.h2;
|
|
1435
|
+
configReset.h3 = configStyles.h3;
|
|
1436
|
+
configReset.h4 = configStyles.h4;
|
|
1437
|
+
configReset.h5 = configStyles.h5;
|
|
1438
|
+
configReset.h6 = configStyles.h6;
|
|
1439
|
+
}
|
|
1440
|
+
const { body, ...styles } = TYPOGRAPHY2.styles;
|
|
1441
|
+
return deepMerge(merge(RESET2, reset), {
|
|
1442
|
+
html: {
|
|
1443
|
+
position: "absolute",
|
|
1444
|
+
overflow: "hidden",
|
|
1445
|
+
width: "100%",
|
|
1446
|
+
height: "100%",
|
|
1447
|
+
top: "0",
|
|
1448
|
+
left: "0",
|
|
1449
|
+
margin: "0",
|
|
1450
|
+
WebkitFontSmoothing: "antialiased",
|
|
1451
|
+
transform: "translate3d(0, 0, 1px)",
|
|
1452
|
+
scrollBehavior: "smooth",
|
|
1453
|
+
fontSize: TYPOGRAPHY2.browserDefault + "px",
|
|
1454
|
+
fontFamily: DOCUMENT2.fontFamily,
|
|
1455
|
+
lineHeight: DOCUMENT2.lineHeight
|
|
1456
|
+
},
|
|
1457
|
+
body: {
|
|
1458
|
+
boxSizing: "border-box",
|
|
1459
|
+
height: "100%",
|
|
1460
|
+
margin: 0,
|
|
1461
|
+
fontFamily: DOCUMENT2.fontFamily,
|
|
1462
|
+
fontSize: TYPOGRAPHY2.base / TYPOGRAPHY2.browserDefault + CONFIG2.UNIT.default,
|
|
1463
|
+
...getMediaTheme("document", `@${CONFIG2.globalTheme}`),
|
|
1464
|
+
...styles,
|
|
1465
|
+
...body
|
|
1466
|
+
},
|
|
1467
|
+
// form elements
|
|
1468
|
+
fieldset: {
|
|
1469
|
+
border: 0,
|
|
1470
|
+
padding: 0,
|
|
1471
|
+
margin: 0
|
|
1472
|
+
},
|
|
1473
|
+
"select, input": {
|
|
1474
|
+
fontFamily: DOCUMENT2.fontFamily
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
|
|
1480
|
+
// src/set.js
|
|
1481
|
+
var setCases = (val, key) => {
|
|
1482
|
+
if (isFunction2(val))
|
|
1483
|
+
return val();
|
|
1484
|
+
return val;
|
|
1485
|
+
};
|
|
1486
|
+
var setSameValue = (val, key) => val;
|
|
1487
|
+
var SETTERS = {
|
|
1488
|
+
color: setColor,
|
|
1489
|
+
gradient: setGradient,
|
|
1490
|
+
font: setFont,
|
|
1491
|
+
font_family: setFontFamily,
|
|
1492
|
+
theme: setTheme,
|
|
1493
|
+
typography: setSameValue,
|
|
1494
|
+
cases: setCases,
|
|
1495
|
+
spacing: setSameValue,
|
|
1496
|
+
media: setSameValue,
|
|
1497
|
+
timing: setSameValue,
|
|
1498
|
+
icons: setSameValue,
|
|
1499
|
+
reset: setSameValue,
|
|
1500
|
+
unit: setSameValue,
|
|
1501
|
+
animation: setSameValue
|
|
1502
|
+
};
|
|
1503
|
+
var setValue = (FACTORY_NAME, value, key) => {
|
|
1504
|
+
const CONFIG2 = getActiveConfig();
|
|
1505
|
+
const factoryName = FACTORY_NAME.toLowerCase();
|
|
1506
|
+
const FACTORY2 = CONFIG2[FACTORY_NAME];
|
|
1507
|
+
if (SETTERS[factoryName]) {
|
|
1508
|
+
const result = SETTERS[factoryName](value, key);
|
|
1509
|
+
FACTORY2[key] = result;
|
|
1510
|
+
return FACTORY2;
|
|
1511
|
+
}
|
|
1512
|
+
if (CONFIG2.verbose)
|
|
1513
|
+
console.warn("Can not find", factoryName, "method in scratch");
|
|
1514
|
+
};
|
|
1515
|
+
var setEach = (factoryName, props) => {
|
|
1516
|
+
const CONFIG2 = getActiveConfig();
|
|
1517
|
+
const FACTORY_NAME = factoryName.toUpperCase();
|
|
1518
|
+
const keys = Object.keys(props);
|
|
1519
|
+
keys.map((key) => setValue(FACTORY_NAME, props[key], key));
|
|
1520
|
+
return CONFIG2[FACTORY_NAME];
|
|
1521
|
+
};
|
|
1522
|
+
var SET_OPTIONS = {};
|
|
1523
|
+
var set = (recivedConfig, options = SET_OPTIONS) => {
|
|
1524
|
+
let CONFIG2 = getActiveConfig();
|
|
1525
|
+
const { version, verbose, useVariable, useReset, globalTheme, ...config } = recivedConfig;
|
|
1526
|
+
if (options.newConfig) {
|
|
1527
|
+
FACTORY["active"] = options.newConfig;
|
|
1528
|
+
CONFIG2 = getActiveConfig(options.newConfig);
|
|
1529
|
+
}
|
|
1530
|
+
if (verbose !== void 0)
|
|
1531
|
+
CONFIG2.verbose = verbose;
|
|
1532
|
+
if (useVariable !== void 0)
|
|
1533
|
+
CONFIG2.useVariable = useVariable;
|
|
1534
|
+
if (useReset !== void 0)
|
|
1535
|
+
CONFIG2.useReset = useReset;
|
|
1536
|
+
if (globalTheme !== void 0)
|
|
1537
|
+
CONFIG2.globalTheme = globalTheme;
|
|
1538
|
+
if (CONFIG2.verbose)
|
|
1539
|
+
console.log(CONFIG2);
|
|
1540
|
+
const keys = Object.keys(config);
|
|
1541
|
+
keys.map((key) => setEach(key, config[key]));
|
|
1542
|
+
applyTypographySequence();
|
|
1543
|
+
applySpacingSequence();
|
|
1544
|
+
applyTimingSequence();
|
|
1545
|
+
applyDocument();
|
|
1546
|
+
applyReset();
|
|
1547
|
+
return CONFIG2;
|
|
1548
|
+
};
|