@symbo.ls/scratch 3.4.5 → 3.4.6

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.
Files changed (85) hide show
  1. package/dist/cjs/defaultConfig/animation.js +24 -0
  2. package/dist/cjs/defaultConfig/cases.js +24 -0
  3. package/dist/cjs/defaultConfig/class.js +25 -0
  4. package/dist/cjs/defaultConfig/color.js +31 -0
  5. package/dist/cjs/defaultConfig/document.js +24 -0
  6. package/dist/cjs/defaultConfig/font-family.js +38 -0
  7. package/dist/cjs/defaultConfig/font.js +33 -0
  8. package/dist/cjs/defaultConfig/grid.js +25 -0
  9. package/dist/cjs/defaultConfig/icons.js +26 -0
  10. package/dist/cjs/defaultConfig/index.js +45 -0
  11. package/dist/cjs/defaultConfig/media.js +29 -0
  12. package/dist/cjs/defaultConfig/responsive.js +50 -0
  13. package/dist/cjs/defaultConfig/sequence.js +49 -0
  14. package/dist/cjs/defaultConfig/shadow.js +29 -0
  15. package/dist/cjs/defaultConfig/spacing.js +38 -0
  16. package/dist/cjs/defaultConfig/svg.js +26 -0
  17. package/dist/cjs/defaultConfig/templates.js +24 -0
  18. package/dist/cjs/defaultConfig/theme.js +36 -0
  19. package/dist/cjs/defaultConfig/timing.js +37 -0
  20. package/dist/cjs/defaultConfig/typography.js +41 -0
  21. package/dist/cjs/defaultConfig/unit.js +26 -0
  22. package/dist/cjs/system/color.js +203 -0
  23. package/dist/cjs/system/document.js +36 -0
  24. package/dist/cjs/system/font.js +64 -0
  25. package/dist/cjs/system/index.js +27 -0
  26. package/dist/cjs/system/reset.js +87 -0
  27. package/dist/cjs/system/shadow.js +107 -0
  28. package/dist/cjs/system/spacing.js +134 -0
  29. package/dist/cjs/system/svg.js +97 -0
  30. package/dist/cjs/system/theme.js +234 -0
  31. package/dist/cjs/system/timing.js +48 -0
  32. package/dist/cjs/system/typography.js +99 -0
  33. package/dist/cjs/tests/index.js +28 -0
  34. package/dist/cjs/transforms/index.js +219 -0
  35. package/dist/cjs/utils/color.js +206 -0
  36. package/dist/cjs/utils/font.js +89 -0
  37. package/dist/cjs/utils/index.js +24 -0
  38. package/dist/cjs/utils/sequence.js +323 -0
  39. package/dist/cjs/utils/sprite.js +85 -0
  40. package/dist/cjs/utils/theme.js +29 -0
  41. package/dist/cjs/utils/unit.js +79 -0
  42. package/dist/cjs/utils/var.js +102 -0
  43. package/dist/esm/defaultConfig/animation.js +4 -0
  44. package/dist/esm/defaultConfig/cases.js +4 -0
  45. package/dist/esm/defaultConfig/class.js +5 -0
  46. package/dist/esm/defaultConfig/color.js +11 -0
  47. package/dist/esm/defaultConfig/document.js +4 -0
  48. package/dist/esm/defaultConfig/font-family.js +18 -0
  49. package/dist/esm/defaultConfig/font.js +13 -0
  50. package/dist/esm/defaultConfig/grid.js +5 -0
  51. package/dist/esm/defaultConfig/icons.js +6 -0
  52. package/dist/esm/defaultConfig/index.js +24 -0
  53. package/dist/esm/defaultConfig/media.js +9 -0
  54. package/dist/esm/defaultConfig/responsive.js +30 -0
  55. package/dist/esm/defaultConfig/sequence.js +29 -0
  56. package/dist/esm/defaultConfig/shadow.js +9 -0
  57. package/dist/esm/defaultConfig/spacing.js +18 -0
  58. package/dist/esm/defaultConfig/svg.js +6 -0
  59. package/dist/esm/defaultConfig/templates.js +4 -0
  60. package/dist/esm/defaultConfig/theme.js +16 -0
  61. package/dist/esm/defaultConfig/timing.js +17 -0
  62. package/dist/esm/defaultConfig/typography.js +21 -0
  63. package/dist/esm/defaultConfig/unit.js +6 -0
  64. package/dist/esm/system/color.js +188 -0
  65. package/dist/esm/system/document.js +16 -0
  66. package/dist/esm/system/font.js +50 -0
  67. package/dist/esm/system/index.js +10 -0
  68. package/dist/esm/system/reset.js +67 -0
  69. package/dist/esm/system/shadow.js +91 -0
  70. package/dist/esm/system/spacing.js +121 -0
  71. package/dist/esm/system/svg.js +77 -0
  72. package/dist/esm/system/theme.js +219 -0
  73. package/dist/esm/system/timing.js +32 -0
  74. package/dist/esm/system/typography.js +85 -0
  75. package/dist/esm/tests/index.js +8 -0
  76. package/dist/esm/transforms/index.js +216 -0
  77. package/dist/esm/utils/color.js +192 -0
  78. package/dist/esm/utils/font.js +69 -0
  79. package/dist/esm/utils/index.js +7 -0
  80. package/dist/esm/utils/sequence.js +303 -0
  81. package/dist/esm/utils/sprite.js +65 -0
  82. package/dist/esm/utils/theme.js +9 -0
  83. package/dist/esm/utils/unit.js +59 -0
  84. package/dist/esm/utils/var.js +82 -0
  85. package/package.json +7 -7
@@ -0,0 +1,323 @@
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("@domql/utils");
38
+ var import_smbls_utils = require("@symbo.ls/smbls-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
+ sequenceProps.vars[variable] = scaling + sequenceProps.unit;
83
+ };
84
+ const getFnPrefixAndValue = (val) => {
85
+ if (!val.includes("(")) return val;
86
+ const prefix = val.split("(")[0];
87
+ const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
88
+ return [prefix, value];
89
+ };
90
+ const setScalingVar = (key, sequenceProps) => {
91
+ const { base, type, unit } = sequenceProps;
92
+ const defaultVal = ((0, import_unit.isScalingUnit)(unit) ? 1 : base) + unit;
93
+ if (key === 0) return defaultVal;
94
+ const prefix = "--" + (type && type.replace(".", "-"));
95
+ const ratioVar = `${prefix}-ratio`;
96
+ if (key > 0) {
97
+ const prevLetterKey = numToLetterMap[key - 1];
98
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
99
+ }
100
+ if (key < 0) {
101
+ const nextLetterKey = numToLetterMap[key + 1];
102
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
103
+ }
104
+ };
105
+ const setSubScalingVar = (index, arr, variable, sequenceProps) => {
106
+ const { type } = sequenceProps;
107
+ const skipMiddle = index === 2 && arr.length === 2;
108
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
109
+ const prefix = "--" + (type && type.replace(".", "-"));
110
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
111
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
112
+ };
113
+ const getSubratioDifference = (base, ratio) => {
114
+ const diff = base * ratio - base;
115
+ const subRatio = diff / 1.618;
116
+ const first = base * ratio - subRatio;
117
+ const second = base + subRatio;
118
+ const middle = (first + second) / 2;
119
+ return [first, middle, second];
120
+ };
121
+ const getSubratio = (base, ratio) => {
122
+ return getSubratioDifference(base, ratio).map((v) => v / base);
123
+ };
124
+ const generateSubSequence = (props, sequenceProps) => {
125
+ const { key, base, value, ratio, variable, index } = props;
126
+ const next = value * ratio;
127
+ const diffRounded = ~~next - ~~value;
128
+ let arr;
129
+ const [first, middle, second] = getSubratioDifference(value, ratio);
130
+ if (diffRounded > 16) arr = [first, middle, second];
131
+ else arr = [first, second];
132
+ arr.forEach((v, k) => {
133
+ const scaling = ~~(v / base * 1e3) / 1e3;
134
+ const newVar = variable + (k + 1);
135
+ const newIndex = index + (k + 1) / 10;
136
+ const scalingVariable = setSubScalingVar(
137
+ k + 1,
138
+ arr,
139
+ variable,
140
+ sequenceProps
141
+ );
142
+ const props2 = {
143
+ key: key + (k + 1),
144
+ variable: newVar,
145
+ value: v,
146
+ scaling,
147
+ scalingVariable,
148
+ index: newIndex
149
+ };
150
+ setSequenceValue(props2, sequenceProps);
151
+ });
152
+ };
153
+ const switchSequenceOnNegative = (key, base, ratio) => {
154
+ return base * Math.pow(ratio, key);
155
+ };
156
+ const generateSequence = (sequenceProps) => {
157
+ const { type, base, ratio, range, subSequence } = sequenceProps;
158
+ const n = Math.abs(range[0]) + Math.abs(range[1]);
159
+ const prefix = "--" + (type && type.replace(".", "-")) + "-";
160
+ for (let i = 0; i <= n; i++) {
161
+ const key = range[1] - i;
162
+ const letterKey = numToLetterMap[key];
163
+ const value = switchSequenceOnNegative(key, base, ratio);
164
+ const scaling = ~~(value / base * 100) / 100;
165
+ const variable = prefix + letterKey;
166
+ const scalingVariable = setScalingVar(key, sequenceProps);
167
+ const props = {
168
+ key: letterKey,
169
+ variable,
170
+ value,
171
+ base,
172
+ scaling,
173
+ scalingVariable,
174
+ ratio,
175
+ index: key
176
+ };
177
+ setSequenceValue(props, sequenceProps);
178
+ if (subSequence) generateSubSequence(props, sequenceProps);
179
+ }
180
+ return sequenceProps;
181
+ };
182
+ const generateSequencePosition = (sequenceProps, position = 0) => {
183
+ const { type, base, ratio, subSequence } = sequenceProps;
184
+ const letterKey = (0, import_utils.isString)(position) ? position : numToLetterMap[position];
185
+ const index = (0, import_utils.isString)(position) ? Object.entries(numToLetterMap).find(
186
+ ([, value2]) => value2 === position
187
+ )?.[0] : position;
188
+ if (!letterKey) {
189
+ console.warn(`Position ${position} is out of range in numToLetterMap`);
190
+ return null;
191
+ }
192
+ const result = {
193
+ sequence: {},
194
+ scales: {},
195
+ vars: {},
196
+ ...sequenceProps
197
+ };
198
+ const value = base * Math.pow(ratio, index);
199
+ const scaling = ~~(value / base * 100) / 100;
200
+ const prefix = "--" + (type && type.replace(".", "-")) + "-";
201
+ const variable = prefix + letterKey;
202
+ const scalingVariable = setScalingVar(index, sequenceProps);
203
+ const props = {
204
+ key: letterKey,
205
+ variable,
206
+ value,
207
+ base,
208
+ scaling,
209
+ scalingVariable,
210
+ ratio,
211
+ index
212
+ };
213
+ setSequenceValue(props, result);
214
+ if (subSequence) {
215
+ generateSubSequence(props, result);
216
+ }
217
+ return result;
218
+ };
219
+ const getSequenceValue = (value = "A", sequenceProps) => {
220
+ const CONFIG = (0, import_factory.getActiveConfig)();
221
+ const { UNIT } = CONFIG;
222
+ if ((0, import_utils.isString)(value) && (0, import_color.isCSSVar)(value)) return `var(${value})`;
223
+ const { sequence, unit = UNIT.default, useVariable } = sequenceProps;
224
+ const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
225
+ const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
226
+ const hasUnits = import_unit.CSS_UNITS.some((unit2) => value.includes(unit2));
227
+ if (hasUnits || !startsWithDashOrLetter) return value;
228
+ const skipArr = [
229
+ "none",
230
+ "auto",
231
+ "max-content",
232
+ "min-content",
233
+ "fit-content",
234
+ "inherit",
235
+ "initial",
236
+ "unset",
237
+ "revert",
238
+ "revert-layer"
239
+ ];
240
+ if (skipArr.includes(value)) return value;
241
+ const prefix = `--${(0, import_smbls_utils.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
242
+ const letterVal = value.toUpperCase();
243
+ const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
244
+ let absValue = isNegative ? letterVal.slice(1) : letterVal;
245
+ let mediaName = "";
246
+ if (absValue.includes("_")) {
247
+ mediaName = "_" + absValue.split("_")[1].toLowerCase();
248
+ absValue = absValue.split("_")[0];
249
+ }
250
+ const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
251
+ if (absValue.includes("+")) {
252
+ const [first, second] = absValue.split("+");
253
+ const joint = `${varValue(first)} + ${varValue(second)}`;
254
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
255
+ } else if (absValue.includes("*")) {
256
+ const [first, second] = absValue.split("*");
257
+ const joint = `${varValue(first)} * ${varValue(second)}`;
258
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
259
+ } else if (absValue.includes("-")) {
260
+ const [first, second] = absValue.split("-");
261
+ const joint = `${varValue(first)} - ${varValue(second)}`;
262
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
263
+ }
264
+ if (!sequence[absValue] && absValue.length === 2) {
265
+ if (CONFIG.verbose)
266
+ console.warn(
267
+ absValue,
268
+ "- value is not found because `subSequence` is set to false"
269
+ );
270
+ absValue = absValue.slice(0, 1);
271
+ }
272
+ if (useVariable || CONFIG.useVariable) {
273
+ const varValue2 = `var(${prefix}${absValue}${mediaName})`;
274
+ return isNegative ? `calc(${varValue2} * -1)` : varValue2;
275
+ }
276
+ const sequenceItem = sequence ? sequence[absValue] : null;
277
+ if (!sequenceItem) return console.warn("can't find", sequence, absValue);
278
+ if (unit === "ms" || unit === "s") {
279
+ return isNegative + sequenceItem.val + unit;
280
+ }
281
+ return isNegative + sequenceItem.scaling + unit;
282
+ };
283
+ const getSequenceValueBySymbols = (value, sequenceProps) => {
284
+ const mathArr = ["+", "-", "*", "/", ","].filter(
285
+ (v) => value.includes(v + " ")
286
+ );
287
+ if (!mathArr.length) return value;
288
+ return mathArr.map((symbol) => {
289
+ const valuesArr = value.split(symbol + " ").map((v) => v.trim());
290
+ const transformedValues = valuesArr.map((v) => {
291
+ return getSequenceValue(v, sequenceProps);
292
+ });
293
+ return transformedValues.join(" " + symbol + " ");
294
+ }).join("");
295
+ };
296
+ const getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
297
+ if (typeof value !== "string") {
298
+ const CONFIG = (0, import_factory.getActiveConfig)();
299
+ if (CONFIG.verbose) console.warn(propertyName, value, "is not a string");
300
+ return { [propertyName]: value };
301
+ }
302
+ if (value === "-" || value === "") return {};
303
+ if (!fnPrefix && value.includes("(")) {
304
+ const fnArr = getFnPrefixAndValue(value);
305
+ fnPrefix = fnArr[0];
306
+ value = fnArr[1];
307
+ }
308
+ const mathArr = ["+", "-", "*", "/", ","].filter(
309
+ (v) => value.includes(v + " ")
310
+ );
311
+ if (mathArr.length) {
312
+ value = getSequenceValueBySymbols(value, sequenceProps);
313
+ } else value = getSequenceValue(value, sequenceProps);
314
+ return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
315
+ };
316
+ const findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
317
+ const findHeadings = (propertyNames) => {
318
+ const { h1Matches, sequence } = propertyNames;
319
+ return new Array(6).fill(null).map((_, i) => {
320
+ const findLetter = findHeadingLetter(h1Matches, i);
321
+ return sequence[findLetter];
322
+ });
323
+ };
@@ -0,0 +1,85 @@
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("@domql/utils");
26
+ var import_factory = require("../factory");
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.__svg_cache[key]) continue;
33
+ else CONFIG.__svg_cache[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
+ return symbol;
85
+ };
@@ -0,0 +1,29 @@
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
+ };
@@ -0,0 +1,79 @@
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
+ ];
@@ -0,0 +1,102 @@
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("@domql/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 { 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 } = CONFIG;
42
+ const unit = obj.unit || UNIT.default;
43
+ const { base, ratio, type } = obj;
44
+ const prefix = "--" + (type && type.replace(".", "-"));
45
+ vars[`${prefix}-base`] = base;
46
+ vars[`${prefix}-unit`] = unit;
47
+ const ratioVar = `${prefix}-ratio`;
48
+ vars[ratioVar] = ratio;
49
+ const [first, middle, second] = (0, import_sequence.getSubratio)(base, ratio);
50
+ vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
51
+ vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
52
+ vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
53
+ };
54
+ const applySequenceVars = (FACTORY, options = {}) => {
55
+ const CONFIG = (0, import_factory.getActiveConfig)();
56
+ const { UNIT, TIMING, CSS_VARS } = CONFIG;
57
+ const unit = FACTORY.unit || UNIT.default;
58
+ const { mediaRegenerate, sequence, scales } = FACTORY;
59
+ if (!mediaRegenerate) {
60
+ applySequenceGlobalVars(CSS_VARS, FACTORY, options);
61
+ }
62
+ for (const key in sequence) {
63
+ const item = sequence[key];
64
+ const value = (FACTORY.type === TIMING.type ? sequence[key].val : scales[key]) + unit;
65
+ if (!mediaRegenerate) {
66
+ CSS_VARS[item.variable + "_default"] = value;
67
+ CSS_VARS[item.variable] = item.scalingVariable;
68
+ continue;
69
+ }
70
+ if (options.useDefault === false) {
71
+ CSS_VARS[item.variable] = value;
72
+ } else {
73
+ CSS_VARS[item.variable + "_default"] = value;
74
+ CSS_VARS[item.variable] = `var(${item.variable + "_default"})`;
75
+ }
76
+ }
77
+ };
78
+ const applyMediaSequenceVars = (FACTORY, media, options = {}) => {
79
+ const CONFIG = (0, import_factory.getActiveConfig)();
80
+ const { UNIT, MEDIA, CSS_VARS } = CONFIG;
81
+ const mediaName = media.slice(1);
82
+ const unit = FACTORY.unit || UNIT.default;
83
+ const { mediaRegenerate } = FACTORY;
84
+ const { sequence, scales } = FACTORY[media];
85
+ const query = MEDIA[mediaName];
86
+ if (!query && CONFIG.verbose) console.warn("Can't find media query ", query);
87
+ if (!mediaRegenerate) {
88
+ let underMediaQuery = CSS_VARS[`@media ${query}`];
89
+ if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
90
+ applySequenceGlobalVars(underMediaQuery, FACTORY[media], options);
91
+ return;
92
+ }
93
+ for (const key in sequence) {
94
+ const item = sequence[key];
95
+ const value = ((0, import_unit.isScalingUnit)(unit) ? scales[key] : sequence[key].val) + unit;
96
+ if (!query && CONFIG.verbose) console.warn("Can't find query ", query);
97
+ let underMediaQuery = CSS_VARS[`@media ${query}`];
98
+ if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
99
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
100
+ CSS_VARS[item.variable + "_" + mediaName] = value;
101
+ }
102
+ };
@@ -0,0 +1,4 @@
1
+ const ANIMATION = {};
2
+ export {
3
+ ANIMATION
4
+ };
@@ -0,0 +1,4 @@
1
+ const CASES = {};
2
+ export {
3
+ CASES
4
+ };
@@ -0,0 +1,5 @@
1
+ const defaultProps = {};
2
+ const CLASS = defaultProps;
3
+ export {
4
+ CLASS
5
+ };
@@ -0,0 +1,11 @@
1
+ var proto = {
2
+ // eslint-disable-line
3
+ name: "",
4
+ value: ""
5
+ };
6
+ const COLOR = {};
7
+ const GRADIENT = {};
8
+ export {
9
+ COLOR,
10
+ GRADIENT
11
+ };
@@ -0,0 +1,4 @@
1
+ const DOCUMENT = {};
2
+ export {
3
+ DOCUMENT
4
+ };
@@ -0,0 +1,18 @@
1
+ var defaultFont = {
2
+ // eslint-disable-line
3
+ name: "",
4
+ family: "",
5
+ type: ""
6
+ };
7
+ const FONT_FAMILY = {};
8
+ const FONT_FAMILY_TYPES = {
9
+ "sans-serif": "Helvetica, Arial, sans-serif, --system-default",
10
+ serif: "Times New Roman, Georgia, serif, --system-default",
11
+ monospace: "Courier New, monospace, --system-default"
12
+ };
13
+ const FONT_FACE = {};
14
+ export {
15
+ FONT_FACE,
16
+ FONT_FAMILY,
17
+ FONT_FAMILY_TYPES
18
+ };
@@ -0,0 +1,13 @@
1
+ var defFont = {
2
+ // eslint-disable-line
3
+ name: "",
4
+ url: "",
5
+ fontStyle: "",
6
+ fontWeight: 500,
7
+ fontStretch: "normal",
8
+ fontOpticalSizing: "auto"
9
+ };
10
+ const FONT = {};
11
+ export {
12
+ FONT
13
+ };