@symbo.ls/scratch 3.14.0 → 3.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/utils/sprite.js +29 -12
- package/dist/cjs/defaultConfig/animation.js +0 -24
- package/dist/cjs/defaultConfig/cases.js +0 -24
- package/dist/cjs/defaultConfig/class.js +0 -24
- package/dist/cjs/defaultConfig/color.js +0 -31
- package/dist/cjs/defaultConfig/document.js +0 -24
- package/dist/cjs/defaultConfig/font-family.js +0 -38
- package/dist/cjs/defaultConfig/font.js +0 -33
- package/dist/cjs/defaultConfig/grid.js +0 -25
- package/dist/cjs/defaultConfig/icons.js +0 -26
- package/dist/cjs/defaultConfig/index.js +0 -46
- package/dist/cjs/defaultConfig/media.js +0 -29
- package/dist/cjs/defaultConfig/responsive.js +0 -50
- package/dist/cjs/defaultConfig/sequence.js +0 -49
- package/dist/cjs/defaultConfig/shadow.js +0 -24
- package/dist/cjs/defaultConfig/spacing.js +0 -38
- package/dist/cjs/defaultConfig/svg.js +0 -26
- package/dist/cjs/defaultConfig/templates.js +0 -24
- package/dist/cjs/defaultConfig/theme.js +0 -36
- package/dist/cjs/defaultConfig/timing.js +0 -37
- package/dist/cjs/defaultConfig/typography.js +0 -41
- package/dist/cjs/defaultConfig/unit.js +0 -26
- package/dist/cjs/factory.js +0 -145
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/set.js +0 -286
- package/dist/cjs/system/color.js +0 -268
- package/dist/cjs/system/document.js +0 -36
- package/dist/cjs/system/font.js +0 -71
- package/dist/cjs/system/index.js +0 -27
- package/dist/cjs/system/reset.js +0 -114
- package/dist/cjs/system/shadow.js +0 -108
- package/dist/cjs/system/spacing.js +0 -134
- package/dist/cjs/system/svg.js +0 -133
- package/dist/cjs/system/theme.js +0 -496
- package/dist/cjs/system/timing.js +0 -48
- package/dist/cjs/system/typography.js +0 -108
- package/dist/cjs/tests/index.js +0 -28
- package/dist/cjs/transforms/index.js +0 -219
- package/dist/cjs/utils/color.js +0 -206
- package/dist/cjs/utils/font.js +0 -114
- package/dist/cjs/utils/index.js +0 -24
- package/dist/cjs/utils/sequence.js +0 -342
- package/dist/cjs/utils/sprite.js +0 -92
- package/dist/cjs/utils/theme.js +0 -29
- package/dist/cjs/utils/unit.js +0 -79
- package/dist/cjs/utils/var.js +0 -116
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/class.js +0 -4
- 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 -120
- package/dist/esm/index.js +0 -14
- package/dist/esm/set.js +0 -280
- package/dist/esm/system/color.js +0 -253
- 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 -94
- package/dist/esm/system/shadow.js +0 -92
- package/dist/esm/system/spacing.js +0 -121
- package/dist/esm/system/svg.js +0 -113
- package/dist/esm/system/theme.js +0 -481
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -94
- 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 -94
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/sequence.js +0 -322
- package/dist/esm/utils/sprite.js +0 -72
- package/dist/esm/utils/theme.js +0 -9
- package/dist/esm/utils/unit.js +0 -59
- package/dist/esm/utils/var.js +0 -96
- package/dist/iife/index.js +0 -3630
|
@@ -1,342 +0,0 @@
|
|
|
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
|
-
var sequence_exports = {};
|
|
20
|
-
__export(sequence_exports, {
|
|
21
|
-
findHeadingLetter: () => findHeadingLetter,
|
|
22
|
-
findHeadings: () => findHeadings,
|
|
23
|
-
generateSequence: () => generateSequence,
|
|
24
|
-
generateSequencePosition: () => generateSequencePosition,
|
|
25
|
-
generateSubSequence: () => generateSubSequence,
|
|
26
|
-
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
27
|
-
getSequenceValue: () => getSequenceValue,
|
|
28
|
-
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
29
|
-
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
30
|
-
getSubratio: () => getSubratio,
|
|
31
|
-
getSubratioDifference: () => getSubratioDifference,
|
|
32
|
-
numToLetterMap: () => numToLetterMap,
|
|
33
|
-
setScalingVar: () => setScalingVar,
|
|
34
|
-
setSubScalingVar: () => setSubScalingVar
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(sequence_exports);
|
|
37
|
-
var import_utils = require("@symbo.ls/utils");
|
|
38
|
-
var import_utils2 = require("@symbo.ls/utils");
|
|
39
|
-
var import_factory = require("../factory.js");
|
|
40
|
-
var import_unit = require("./unit.js");
|
|
41
|
-
var import_color = require("./color.js");
|
|
42
|
-
const numToLetterMap = {
|
|
43
|
-
"-6": "U",
|
|
44
|
-
"-5": "V",
|
|
45
|
-
"-4": "W",
|
|
46
|
-
"-3": "X",
|
|
47
|
-
"-2": "Y",
|
|
48
|
-
"-1": "Z",
|
|
49
|
-
0: "A",
|
|
50
|
-
1: "B",
|
|
51
|
-
2: "C",
|
|
52
|
-
3: "D",
|
|
53
|
-
4: "E",
|
|
54
|
-
5: "F",
|
|
55
|
-
6: "G",
|
|
56
|
-
7: "H",
|
|
57
|
-
8: "I",
|
|
58
|
-
9: "J",
|
|
59
|
-
10: "K",
|
|
60
|
-
11: "L",
|
|
61
|
-
12: "M",
|
|
62
|
-
13: "N",
|
|
63
|
-
14: "O",
|
|
64
|
-
15: "P",
|
|
65
|
-
16: "Q",
|
|
66
|
-
17: "R",
|
|
67
|
-
18: "S",
|
|
68
|
-
19: "T"
|
|
69
|
-
};
|
|
70
|
-
const setSequenceValue = (props, sequenceProps) => {
|
|
71
|
-
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
72
|
-
sequenceProps.sequence[key] = {
|
|
73
|
-
key,
|
|
74
|
-
decimal: ~~(value * 100) / 100,
|
|
75
|
-
val: ~~value,
|
|
76
|
-
scaling,
|
|
77
|
-
index,
|
|
78
|
-
scalingVariable,
|
|
79
|
-
variable
|
|
80
|
-
};
|
|
81
|
-
sequenceProps.scales[key] = scaling;
|
|
82
|
-
const varUnit = VIEWPORT_UNITS.has(sequenceProps.unit) ? "rem" : sequenceProps.unit;
|
|
83
|
-
sequenceProps.vars[variable] = scaling + varUnit;
|
|
84
|
-
};
|
|
85
|
-
const getFnPrefixAndValue = (val) => {
|
|
86
|
-
if (!val.includes("(")) return val;
|
|
87
|
-
const prefix = val.split("(")[0];
|
|
88
|
-
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
89
|
-
return [prefix, value];
|
|
90
|
-
};
|
|
91
|
-
const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
|
|
92
|
-
const setScalingVar = (key, sequenceProps) => {
|
|
93
|
-
const { base, type, unit: rawUnit } = sequenceProps;
|
|
94
|
-
const unit = VIEWPORT_UNITS.has(rawUnit) ? "rem" : rawUnit;
|
|
95
|
-
const defaultVal = ((0, import_unit.isScalingUnit)(unit) ? 1 : base) + unit;
|
|
96
|
-
if (key === 0) return defaultVal;
|
|
97
|
-
const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
|
|
98
|
-
const prefix = "--" + vp + (type && type.replace(".", "-"));
|
|
99
|
-
const ratioVar = `${prefix}-ratio`;
|
|
100
|
-
if (key > 0) {
|
|
101
|
-
const prevLetterKey = numToLetterMap[key - 1];
|
|
102
|
-
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
103
|
-
}
|
|
104
|
-
if (key < 0) {
|
|
105
|
-
const nextLetterKey = numToLetterMap[key + 1];
|
|
106
|
-
const absKey = Math.abs(key);
|
|
107
|
-
const phiPow = Math.pow(PHI, 2 * absKey);
|
|
108
|
-
const prevAscKey = numToLetterMap[absKey];
|
|
109
|
-
if (prevAscKey) {
|
|
110
|
-
return `max(calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar})), calc(var(${prefix}-${prevAscKey}) / ${phiPow.toFixed(4)}))`;
|
|
111
|
-
}
|
|
112
|
-
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
116
|
-
const { type } = sequenceProps;
|
|
117
|
-
const skipMiddle = index === 2 && arr.length === 2;
|
|
118
|
-
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
119
|
-
const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
|
|
120
|
-
const prefix = "--" + vp + (type && type.replace(".", "-"));
|
|
121
|
-
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
122
|
-
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
123
|
-
};
|
|
124
|
-
const getSubratioDifference = (base, ratio) => {
|
|
125
|
-
const diff = base * ratio - base;
|
|
126
|
-
const subRatio = diff / 1.618;
|
|
127
|
-
const first = base * ratio - subRatio;
|
|
128
|
-
const second = base + subRatio;
|
|
129
|
-
const middle = (first + second) / 2;
|
|
130
|
-
return [first, middle, second];
|
|
131
|
-
};
|
|
132
|
-
const getSubratio = (base, ratio) => {
|
|
133
|
-
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
134
|
-
};
|
|
135
|
-
const generateSubSequence = (props, sequenceProps) => {
|
|
136
|
-
const { key, base, value, ratio, variable, index } = props;
|
|
137
|
-
const next = value * ratio;
|
|
138
|
-
const diffRounded = ~~next - ~~value;
|
|
139
|
-
let arr;
|
|
140
|
-
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
141
|
-
if (diffRounded > 16) arr = [first, middle, second];
|
|
142
|
-
else arr = [first, second];
|
|
143
|
-
arr.forEach((v, k) => {
|
|
144
|
-
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
145
|
-
const newVar = variable + (k + 1);
|
|
146
|
-
const newIndex = index + (k + 1) / 10;
|
|
147
|
-
const scalingVariable = setSubScalingVar(
|
|
148
|
-
k + 1,
|
|
149
|
-
arr,
|
|
150
|
-
variable,
|
|
151
|
-
sequenceProps
|
|
152
|
-
);
|
|
153
|
-
const props2 = {
|
|
154
|
-
key: key + (k + 1),
|
|
155
|
-
variable: newVar,
|
|
156
|
-
value: v,
|
|
157
|
-
scaling,
|
|
158
|
-
scalingVariable,
|
|
159
|
-
index: newIndex
|
|
160
|
-
};
|
|
161
|
-
setSequenceValue(props2, sequenceProps);
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
const PHI = 1.618;
|
|
165
|
-
const switchSequenceOnNegative = (key, base, ratio) => {
|
|
166
|
-
if (key >= 0) return base * Math.pow(ratio, key);
|
|
167
|
-
const absKey = Math.abs(key);
|
|
168
|
-
const current = base * Math.pow(ratio, key);
|
|
169
|
-
const normalized = base * Math.pow(ratio, absKey) / Math.pow(PHI, 2 * absKey);
|
|
170
|
-
return Math.max(current, normalized);
|
|
171
|
-
};
|
|
172
|
-
const generateSequence = (sequenceProps) => {
|
|
173
|
-
const { type, base, ratio, range, subSequence } = sequenceProps;
|
|
174
|
-
const n = Math.abs(range[0]) + Math.abs(range[1]);
|
|
175
|
-
const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
|
|
176
|
-
const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
|
|
177
|
-
for (let i = 0; i <= n; i++) {
|
|
178
|
-
const key = range[1] - i;
|
|
179
|
-
const letterKey = numToLetterMap[key];
|
|
180
|
-
const value = switchSequenceOnNegative(key, base, ratio);
|
|
181
|
-
const scaling = ~~(value / base * 100) / 100;
|
|
182
|
-
const variable = prefix + letterKey;
|
|
183
|
-
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
184
|
-
const props = {
|
|
185
|
-
key: letterKey,
|
|
186
|
-
variable,
|
|
187
|
-
value,
|
|
188
|
-
base,
|
|
189
|
-
scaling,
|
|
190
|
-
scalingVariable,
|
|
191
|
-
ratio,
|
|
192
|
-
index: key
|
|
193
|
-
};
|
|
194
|
-
setSequenceValue(props, sequenceProps);
|
|
195
|
-
if (subSequence) generateSubSequence(props, sequenceProps);
|
|
196
|
-
}
|
|
197
|
-
return sequenceProps;
|
|
198
|
-
};
|
|
199
|
-
const generateSequencePosition = (sequenceProps, position = 0) => {
|
|
200
|
-
const { type, base, ratio, subSequence } = sequenceProps;
|
|
201
|
-
const letterKey = (0, import_utils.isString)(position) ? position : numToLetterMap[position];
|
|
202
|
-
const index = (0, import_utils.isString)(position) ? Object.entries(numToLetterMap).find(
|
|
203
|
-
([, value2]) => value2 === position
|
|
204
|
-
)?.[0] : position;
|
|
205
|
-
if (!letterKey) {
|
|
206
|
-
console.warn(`Position ${position} is out of range in numToLetterMap`);
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
const result = {
|
|
210
|
-
sequence: {},
|
|
211
|
-
scales: {},
|
|
212
|
-
vars: {},
|
|
213
|
-
...sequenceProps
|
|
214
|
-
};
|
|
215
|
-
const value = base * Math.pow(ratio, index);
|
|
216
|
-
const scaling = ~~(value / base * 100) / 100;
|
|
217
|
-
const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
|
|
218
|
-
const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
|
|
219
|
-
const variable = prefix + letterKey;
|
|
220
|
-
const scalingVariable = setScalingVar(index, sequenceProps);
|
|
221
|
-
const props = {
|
|
222
|
-
key: letterKey,
|
|
223
|
-
variable,
|
|
224
|
-
value,
|
|
225
|
-
base,
|
|
226
|
-
scaling,
|
|
227
|
-
scalingVariable,
|
|
228
|
-
ratio,
|
|
229
|
-
index
|
|
230
|
-
};
|
|
231
|
-
setSequenceValue(props, result);
|
|
232
|
-
if (subSequence) {
|
|
233
|
-
generateSubSequence(props, result);
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
};
|
|
237
|
-
const getSequenceValue = (value = "A", sequenceProps) => {
|
|
238
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
239
|
-
const { unit: UNIT } = CONFIG;
|
|
240
|
-
if ((0, import_utils.isString)(value) && (0, import_color.isCSSVar)(value)) return `var(${value})`;
|
|
241
|
-
const { sequence, unit = UNIT.default, useVariable } = sequenceProps;
|
|
242
|
-
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
243
|
-
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
244
|
-
const hasUnits = import_unit.CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
245
|
-
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
246
|
-
const skipArr = [
|
|
247
|
-
"none",
|
|
248
|
-
"auto",
|
|
249
|
-
"max-content",
|
|
250
|
-
"min-content",
|
|
251
|
-
"fit-content",
|
|
252
|
-
"inherit",
|
|
253
|
-
"initial",
|
|
254
|
-
"unset",
|
|
255
|
-
"revert",
|
|
256
|
-
"revert-layer"
|
|
257
|
-
];
|
|
258
|
-
if (skipArr.includes(value)) return value;
|
|
259
|
-
const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
|
|
260
|
-
const prefix = `--${vp}${(0, import_utils2.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
261
|
-
const letterVal = value.toUpperCase();
|
|
262
|
-
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
263
|
-
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
264
|
-
let mediaName = "";
|
|
265
|
-
if (absValue.includes("_")) {
|
|
266
|
-
mediaName = "_" + absValue.split("_")[1].toLowerCase();
|
|
267
|
-
absValue = absValue.split("_")[0];
|
|
268
|
-
}
|
|
269
|
-
const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
|
|
270
|
-
if (absValue.includes("+")) {
|
|
271
|
-
const [first, second] = absValue.split("+");
|
|
272
|
-
const joint = `${varValue(first)} + ${varValue(second)}`;
|
|
273
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
274
|
-
} else if (absValue.includes("*")) {
|
|
275
|
-
const [first, second] = absValue.split("*");
|
|
276
|
-
const joint = `${varValue(first)} * ${varValue(second)}`;
|
|
277
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
278
|
-
} else if (absValue.includes("-")) {
|
|
279
|
-
const [first, second] = absValue.split("-");
|
|
280
|
-
const joint = `${varValue(first)} - ${varValue(second)}`;
|
|
281
|
-
return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
|
|
282
|
-
}
|
|
283
|
-
if (!sequence[absValue] && absValue.length === 2) {
|
|
284
|
-
if (CONFIG.verbose)
|
|
285
|
-
console.warn(
|
|
286
|
-
absValue,
|
|
287
|
-
"- value is not found because `subSequence` is set to false"
|
|
288
|
-
);
|
|
289
|
-
absValue = absValue.slice(0, 1);
|
|
290
|
-
}
|
|
291
|
-
if (useVariable || CONFIG.useVariable) {
|
|
292
|
-
const varValue2 = `var(${prefix}${absValue}${mediaName})`;
|
|
293
|
-
return isNegative ? `calc(${varValue2} * -1)` : varValue2;
|
|
294
|
-
}
|
|
295
|
-
const sequenceItem = sequence ? sequence[absValue] : null;
|
|
296
|
-
if (!sequenceItem) return console.warn("can't find", sequence, absValue);
|
|
297
|
-
if (unit === "ms" || unit === "s") {
|
|
298
|
-
return isNegative + sequenceItem.val + unit;
|
|
299
|
-
}
|
|
300
|
-
return isNegative + sequenceItem.scaling + unit;
|
|
301
|
-
};
|
|
302
|
-
const getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
303
|
-
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
304
|
-
(v) => value.includes(v + " ")
|
|
305
|
-
);
|
|
306
|
-
if (!mathArr.length) return value;
|
|
307
|
-
const symbolRegex = /(\s*[+\-*/,]\s*)/;
|
|
308
|
-
const tokens = value.split(symbolRegex);
|
|
309
|
-
return tokens.map((token) => {
|
|
310
|
-
const trimmed = token.trim();
|
|
311
|
-
if (!trimmed || ["+", "-", "*", "/", ","].includes(trimmed)) return token;
|
|
312
|
-
return getSequenceValue(trimmed, sequenceProps);
|
|
313
|
-
}).join("");
|
|
314
|
-
};
|
|
315
|
-
const getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
316
|
-
if (typeof value !== "string") {
|
|
317
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
318
|
-
if (CONFIG.verbose) console.warn(propertyName, value, "is not a string");
|
|
319
|
-
return { [propertyName]: value };
|
|
320
|
-
}
|
|
321
|
-
if (value === "-" || value === "") return {};
|
|
322
|
-
if (!fnPrefix && value.includes("(")) {
|
|
323
|
-
const fnArr = getFnPrefixAndValue(value);
|
|
324
|
-
fnPrefix = fnArr[0];
|
|
325
|
-
value = fnArr[1];
|
|
326
|
-
}
|
|
327
|
-
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
328
|
-
(v) => value.includes(v + " ")
|
|
329
|
-
);
|
|
330
|
-
if (mathArr.length) {
|
|
331
|
-
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
332
|
-
} else value = getSequenceValue(value, sequenceProps);
|
|
333
|
-
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
334
|
-
};
|
|
335
|
-
const findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
336
|
-
const findHeadings = (propertyNames) => {
|
|
337
|
-
const { h1Matches, sequence } = propertyNames;
|
|
338
|
-
return new Array(6).fill(null).map((_, i) => {
|
|
339
|
-
const findLetter = findHeadingLetter(h1Matches, i);
|
|
340
|
-
return sequence[findLetter];
|
|
341
|
-
});
|
|
342
|
-
};
|
package/dist/cjs/utils/sprite.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
var sprite_exports = {};
|
|
20
|
-
__export(sprite_exports, {
|
|
21
|
-
convertSvgToSymbol: () => convertSvgToSymbol,
|
|
22
|
-
generateSprite: () => generateSprite
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(sprite_exports);
|
|
25
|
-
var import_utils = require("@symbo.ls/utils");
|
|
26
|
-
var import_factory = require("../factory.js");
|
|
27
|
-
const isDev = (0, import_utils.isNotProduction)();
|
|
28
|
-
const generateSprite = (icons) => {
|
|
29
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
30
|
-
let sprite = "";
|
|
31
|
-
for (const key in icons) {
|
|
32
|
-
if (CONFIG.__svgCache[key]) continue;
|
|
33
|
-
else CONFIG.__svgCache[key] = true;
|
|
34
|
-
sprite += icons[key];
|
|
35
|
-
}
|
|
36
|
-
return sprite;
|
|
37
|
-
};
|
|
38
|
-
const parseRootAttributes = (htmlString) => {
|
|
39
|
-
const val = htmlString.default || htmlString;
|
|
40
|
-
if (!(0, import_utils.isString)(val)) {
|
|
41
|
-
if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const match = val.match(/<svg\s+(.*?)>/);
|
|
45
|
-
if (!match || !match[1]) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
const attrString = match[1];
|
|
49
|
-
const attrs = attrString.match(
|
|
50
|
-
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
51
|
-
);
|
|
52
|
-
return attrs.reduce((acc, attr) => {
|
|
53
|
-
const [key, value] = attr.split("=");
|
|
54
|
-
acc[key] = value.replace(/['"]/g, "");
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
};
|
|
58
|
-
const replaceIdsAndUrls = (code, key) => {
|
|
59
|
-
const idRegex = /id="([^"]*)"/;
|
|
60
|
-
const urlRegex = /url\(#([^)]*)\)/g;
|
|
61
|
-
const matches = code.match(/id="([^"]*)"/g);
|
|
62
|
-
let replacedCode = code;
|
|
63
|
-
if ((0, import_utils.isArray)(matches)) {
|
|
64
|
-
matches.forEach(() => {
|
|
65
|
-
const randomKey = Math.floor(Math.random() * 1e5);
|
|
66
|
-
replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return replacedCode;
|
|
70
|
-
};
|
|
71
|
-
const convertSvgToSymbol = (key, code) => {
|
|
72
|
-
const extractAttrs = parseRootAttributes(code);
|
|
73
|
-
const { width, height } = extractAttrs;
|
|
74
|
-
const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`;
|
|
75
|
-
const xmlns = "http://www.w3.org/2000/svg";
|
|
76
|
-
const replacedCode = replaceIdsAndUrls(code, key);
|
|
77
|
-
let symbol = replacedCode.replace(
|
|
78
|
-
"<svg",
|
|
79
|
-
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
80
|
-
);
|
|
81
|
-
symbol = symbol.replace(/width="[^"]*"/, "");
|
|
82
|
-
symbol = symbol.replace(/height="[^"]*"/, "");
|
|
83
|
-
symbol = symbol.replace("</svg", "</symbol");
|
|
84
|
-
symbol = expandSvgSelfClosing(symbol);
|
|
85
|
-
return symbol;
|
|
86
|
-
};
|
|
87
|
-
const SVG_VOID_TAGS = "line|circle|ellipse|rect|polyline|polygon|path|stop|use|image";
|
|
88
|
-
const SVG_SELF_CLOSING_RE = new RegExp(
|
|
89
|
-
`<(${SVG_VOID_TAGS})\\b([^>]*?)\\s*/>`,
|
|
90
|
-
"g"
|
|
91
|
-
);
|
|
92
|
-
const expandSvgSelfClosing = (str) => str.replace(SVG_SELF_CLOSING_RE, "<$1$2></$1>");
|
package/dist/cjs/utils/theme.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
var theme_exports = {};
|
|
20
|
-
__export(theme_exports, {
|
|
21
|
-
returnSubThemeOrDefault: () => returnSubThemeOrDefault
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(theme_exports);
|
|
24
|
-
const returnSubThemeOrDefault = (orig, theme) => {
|
|
25
|
-
if (!orig) return;
|
|
26
|
-
if (orig.themes && orig.themes[theme]) return orig.themes[theme];
|
|
27
|
-
if (orig[theme]) return [orig, orig[theme]];
|
|
28
|
-
return orig;
|
|
29
|
-
};
|
package/dist/cjs/utils/unit.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
var unit_exports = {};
|
|
20
|
-
__export(unit_exports, {
|
|
21
|
-
CSS_UNITS: () => CSS_UNITS,
|
|
22
|
-
isScalingUnit: () => isScalingUnit
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(unit_exports);
|
|
25
|
-
const isScalingUnit = (unit) => {
|
|
26
|
-
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
27
|
-
};
|
|
28
|
-
const CSS_UNITS = [
|
|
29
|
-
// Absolute
|
|
30
|
-
"px",
|
|
31
|
-
"cm",
|
|
32
|
-
"mm",
|
|
33
|
-
"in",
|
|
34
|
-
"pt",
|
|
35
|
-
"pc",
|
|
36
|
-
// Font-relative
|
|
37
|
-
"em",
|
|
38
|
-
"rem",
|
|
39
|
-
"ex",
|
|
40
|
-
"cap",
|
|
41
|
-
"ch",
|
|
42
|
-
"ic",
|
|
43
|
-
"lh",
|
|
44
|
-
"rlh",
|
|
45
|
-
// Viewport-relative
|
|
46
|
-
"%",
|
|
47
|
-
"vw",
|
|
48
|
-
"vh",
|
|
49
|
-
"vmin",
|
|
50
|
-
"vmax",
|
|
51
|
-
"svw",
|
|
52
|
-
"svh",
|
|
53
|
-
"lvw",
|
|
54
|
-
"lvh",
|
|
55
|
-
"dvw",
|
|
56
|
-
"dvh",
|
|
57
|
-
// Container query units
|
|
58
|
-
"cqw",
|
|
59
|
-
"cqh",
|
|
60
|
-
"cqi",
|
|
61
|
-
"cqb",
|
|
62
|
-
"cqmin",
|
|
63
|
-
"cqmax",
|
|
64
|
-
// Angle
|
|
65
|
-
"deg",
|
|
66
|
-
"rad",
|
|
67
|
-
"grad",
|
|
68
|
-
"turn",
|
|
69
|
-
// Time
|
|
70
|
-
"s",
|
|
71
|
-
"ms",
|
|
72
|
-
// Resolution
|
|
73
|
-
"dpi",
|
|
74
|
-
"dpcm",
|
|
75
|
-
"dppx",
|
|
76
|
-
// Grid fractional
|
|
77
|
-
"fr",
|
|
78
|
-
"auto"
|
|
79
|
-
];
|
package/dist/cjs/utils/var.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
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
|
-
var var_exports = {};
|
|
20
|
-
__export(var_exports, {
|
|
21
|
-
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
22
|
-
applySequenceGlobalVars: () => applySequenceGlobalVars,
|
|
23
|
-
applySequenceVars: () => applySequenceVars,
|
|
24
|
-
setVariables: () => setVariables
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(var_exports);
|
|
27
|
-
var import_utils = require("@symbo.ls/utils");
|
|
28
|
-
var import_factory = require("../factory.js");
|
|
29
|
-
var import_sequence = require("./sequence.js");
|
|
30
|
-
var import_unit = require("./unit.js");
|
|
31
|
-
const setVariables = (result, key) => {
|
|
32
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
33
|
-
const { cssVars: CSS_VARS } = CONFIG;
|
|
34
|
-
if ((0, import_utils.isObjectLike)(result.value)) {
|
|
35
|
-
} else {
|
|
36
|
-
CSS_VARS[result.var] = result.value;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const applySequenceGlobalVars = (vars, obj, options) => {
|
|
40
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
41
|
-
const { unit: UNIT } = CONFIG;
|
|
42
|
-
const unit = obj.unit || UNIT.default;
|
|
43
|
-
const { base, ratio, type } = obj;
|
|
44
|
-
const vp = obj.varPrefix ? obj.varPrefix + "-" : "";
|
|
45
|
-
const prefix = "--" + vp + (type && type.replace(".", "-"));
|
|
46
|
-
vars[`${prefix}-base`] = base;
|
|
47
|
-
vars[`${prefix}-unit`] = unit;
|
|
48
|
-
const ratioVar = `${prefix}-ratio`;
|
|
49
|
-
vars[ratioVar] = ratio;
|
|
50
|
-
const [first, middle, second] = (0, import_sequence.getSubratio)(base, ratio);
|
|
51
|
-
vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
|
|
52
|
-
vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
|
|
53
|
-
vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
|
|
54
|
-
};
|
|
55
|
-
const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
|
|
56
|
-
const applySequenceVars = (FACTORY, options = {}) => {
|
|
57
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
58
|
-
const { unit: UNIT, timing: TIMING, cssVars: CSS_VARS } = CONFIG;
|
|
59
|
-
const rawUnit = FACTORY.unit || UNIT.default;
|
|
60
|
-
const unit = VIEWPORT_UNITS.has(rawUnit) ? "rem" : rawUnit;
|
|
61
|
-
const { mediaRegenerate, sequence, scales } = FACTORY;
|
|
62
|
-
if (!mediaRegenerate) {
|
|
63
|
-
applySequenceGlobalVars(CSS_VARS, FACTORY, options);
|
|
64
|
-
}
|
|
65
|
-
for (const key in sequence) {
|
|
66
|
-
const item = sequence[key];
|
|
67
|
-
const value = (FACTORY.type === TIMING.type ? sequence[key].val : scales[key]) + unit;
|
|
68
|
-
if (!mediaRegenerate) {
|
|
69
|
-
CSS_VARS[item.variable + "_default"] = value;
|
|
70
|
-
CSS_VARS[item.variable] = item.scalingVariable;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (options.useDefault === false) {
|
|
74
|
-
CSS_VARS[item.variable] = value;
|
|
75
|
-
} else {
|
|
76
|
-
CSS_VARS[item.variable + "_default"] = value;
|
|
77
|
-
CSS_VARS[item.variable] = `var(${item.variable + "_default"})`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const applyMediaSequenceVars = (FACTORY, media, options = {}) => {
|
|
82
|
-
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
83
|
-
const { unit: UNIT, media: MEDIA, cssVars: CSS_VARS } = CONFIG;
|
|
84
|
-
const mediaName = media.slice(1);
|
|
85
|
-
const mediaConfig = FACTORY[media];
|
|
86
|
-
const rawMediaUnit = mediaConfig.unit || FACTORY.unit || UNIT.default;
|
|
87
|
-
const unit = VIEWPORT_UNITS.has(rawMediaUnit) ? "rem" : rawMediaUnit;
|
|
88
|
-
const { mediaRegenerate } = FACTORY;
|
|
89
|
-
const { sequence, scales } = mediaConfig;
|
|
90
|
-
const query = MEDIA[mediaName];
|
|
91
|
-
if (!query && CONFIG.verbose) console.warn("Can't find media query ", query);
|
|
92
|
-
if (!mediaRegenerate) {
|
|
93
|
-
let underMediaQuery = CSS_VARS[`@media ${query}`];
|
|
94
|
-
if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
|
|
95
|
-
applySequenceGlobalVars(underMediaQuery, mediaConfig, options);
|
|
96
|
-
const parentUnit = FACTORY.unit || UNIT.default;
|
|
97
|
-
if (unit !== parentUnit && sequence) {
|
|
98
|
-
for (const key in sequence) {
|
|
99
|
-
const item = sequence[key];
|
|
100
|
-
const value = scales[key] + unit;
|
|
101
|
-
underMediaQuery[item.variable + "_default"] = value;
|
|
102
|
-
underMediaQuery[item.variable] = value;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
for (const key in sequence) {
|
|
108
|
-
const item = sequence[key];
|
|
109
|
-
const value = ((0, import_unit.isScalingUnit)(unit) ? scales[key] : sequence[key].val) + unit;
|
|
110
|
-
if (!query && CONFIG.verbose) console.warn("Can't find query ", query);
|
|
111
|
-
let underMediaQuery = CSS_VARS[`@media ${query}`];
|
|
112
|
-
if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
|
|
113
|
-
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
114
|
-
CSS_VARS[item.variable + "_" + mediaName] = value;
|
|
115
|
-
}
|
|
116
|
-
};
|