@symbo.ls/scratch 3.8.8 → 3.14.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.
Files changed (76) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/defaultConfig/class.js +1 -2
  3. package/dist/cjs/defaultConfig/font-family.js +6 -6
  4. package/dist/cjs/defaultConfig/icons.js +2 -2
  5. package/dist/cjs/defaultConfig/svg.js +2 -2
  6. package/dist/cjs/defaultConfig/timing.js +1 -1
  7. package/dist/cjs/factory.js +72 -12
  8. package/dist/cjs/index.js +6 -4
  9. package/dist/cjs/set.js +113 -52
  10. package/dist/cjs/system/color.js +72 -12
  11. package/dist/cjs/system/document.js +3 -3
  12. package/dist/cjs/system/font.js +14 -14
  13. package/dist/cjs/system/reset.js +34 -7
  14. package/dist/cjs/system/shadow.js +4 -3
  15. package/dist/cjs/system/spacing.js +18 -18
  16. package/dist/cjs/system/svg.js +34 -7
  17. package/dist/cjs/system/theme.js +51 -50
  18. package/dist/cjs/system/timing.js +6 -6
  19. package/dist/cjs/system/typography.js +12 -3
  20. package/dist/cjs/transforms/index.js +4 -4
  21. package/dist/cjs/utils/color.js +1 -1
  22. package/dist/cjs/utils/font.js +3 -1
  23. package/dist/cjs/utils/sequence.js +35 -16
  24. package/dist/cjs/utils/sprite.js +11 -4
  25. package/dist/cjs/utils/var.js +23 -9
  26. package/dist/esm/defaultConfig/class.js +1 -2
  27. package/dist/esm/defaultConfig/font-family.js +6 -6
  28. package/dist/esm/defaultConfig/icons.js +2 -2
  29. package/dist/esm/defaultConfig/svg.js +2 -2
  30. package/dist/esm/defaultConfig/timing.js +1 -1
  31. package/dist/esm/factory.js +72 -12
  32. package/dist/esm/index.js +6 -4
  33. package/dist/esm/set.js +114 -53
  34. package/dist/esm/system/color.js +72 -12
  35. package/dist/esm/system/document.js +3 -3
  36. package/dist/esm/system/font.js +5 -5
  37. package/dist/esm/system/reset.js +34 -7
  38. package/dist/esm/system/shadow.js +4 -3
  39. package/dist/esm/system/spacing.js +3 -3
  40. package/dist/esm/system/svg.js +34 -7
  41. package/dist/esm/system/theme.js +51 -50
  42. package/dist/esm/system/timing.js +2 -2
  43. package/dist/esm/system/typography.js +12 -3
  44. package/dist/esm/transforms/index.js +4 -4
  45. package/dist/esm/utils/color.js +1 -1
  46. package/dist/esm/utils/font.js +3 -1
  47. package/dist/esm/utils/sequence.js +35 -16
  48. package/dist/esm/utils/sprite.js +11 -4
  49. package/dist/esm/utils/var.js +23 -9
  50. package/dist/iife/index.js +728 -302
  51. package/index.js +1 -0
  52. package/package.json +11 -14
  53. package/src/defaultConfig/class.js +2 -1
  54. package/src/defaultConfig/font-family.js +3 -3
  55. package/src/defaultConfig/icons.js +1 -1
  56. package/src/defaultConfig/svg.js +1 -1
  57. package/src/defaultConfig/timing.js +1 -1
  58. package/src/factory.js +85 -13
  59. package/src/index.js +16 -5
  60. package/src/set.js +156 -63
  61. package/src/system/color.js +113 -12
  62. package/src/system/document.js +3 -3
  63. package/src/system/font.js +5 -5
  64. package/src/system/reset.js +41 -8
  65. package/src/system/shadow.js +4 -3
  66. package/src/system/spacing.js +3 -3
  67. package/src/system/svg.js +44 -7
  68. package/src/system/theme.js +87 -64
  69. package/src/system/timing.js +2 -2
  70. package/src/system/typography.js +12 -3
  71. package/src/transforms/index.js +4 -4
  72. package/src/utils/color.js +2 -1
  73. package/src/utils/font.js +7 -1
  74. package/src/utils/sequence.js +46 -29
  75. package/src/utils/sprite.js +15 -4
  76. package/src/utils/var.js +27 -9
@@ -1,4 +1,4 @@
1
- import { getColor } from "./color";
1
+ import { getColor } from "./color.js";
2
2
  import { getActiveConfig } from "../factory.js";
3
3
  import { isCSSVar } from "../utils/color.js";
4
4
  import {
@@ -6,7 +6,7 @@ import {
6
6
  isString,
7
7
  isObjectLike,
8
8
  isArray
9
- } from "@domql/utils";
9
+ } from "@symbo.ls/utils";
10
10
  const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
11
11
  "black",
12
12
  "white",
@@ -164,6 +164,13 @@ const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
164
164
  "yellowgreen",
165
165
  "rebeccapurple"
166
166
  ]);
167
+ const COLOR_PARAM_TOKENS = ["color", "Color", "background", "Background", "fill", "Fill", "stroke", "Stroke"];
168
+ const isColorParam = (param) => {
169
+ for (let i = 0; i < COLOR_PARAM_TOKENS.length; i++) {
170
+ if (param.includes(COLOR_PARAM_TOKENS[i])) return true;
171
+ }
172
+ return false;
173
+ };
167
174
  const setThemeValue = (theme) => {
168
175
  const value = {};
169
176
  const { state, media, helpers, ...rest } = theme;
@@ -265,7 +272,8 @@ const setTheme = (val, key) => {
265
272
  if (CONFIG.useVariable) return setMediaTheme(val, key);
266
273
  const { state, media, helpers } = val;
267
274
  const value = setThemeValue(val, key);
268
- const CSSvar = `--theme-${key}`;
275
+ const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
276
+ const CSSvar = `--${vp}theme-${key}`;
269
277
  setSelectors(val, value);
270
278
  setMedia(val, value);
271
279
  setHelpers(val, value);
@@ -278,9 +286,9 @@ const keySetters = {
278
286
  ".": (theme, value) => setHelpers(theme, value)
279
287
  };
280
288
  const generateAutoVars = (schemes, varPrefix, CONFIG) => {
281
- const { CSS_VARS } = CONFIG;
282
- if (!CONFIG.CSS_MEDIA_VARS) CONFIG.CSS_MEDIA_VARS = {};
283
- const MEDIA_VARS = CONFIG.CSS_MEDIA_VARS;
289
+ const { cssVars: CSS_VARS } = CONFIG;
290
+ if (!CONFIG.cssMediaVars) CONFIG.cssMediaVars = {};
291
+ const MEDIA_VARS = CONFIG.cssMediaVars;
284
292
  const globalTheme = CONFIG.globalTheme !== void 0 ? CONFIG.globalTheme : "auto";
285
293
  const result = {};
286
294
  const allKeys = /* @__PURE__ */ new Set();
@@ -288,19 +296,18 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
288
296
  if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
289
297
  }
290
298
  const brokenSchemes = /* @__PURE__ */ new Set();
291
- if (globalTheme === "auto") {
292
- for (const param of allKeys) {
293
- const symb = param.slice(0, 1);
294
- if (symb === "@" || symb === "." || symb === ":") continue;
295
- for (const scheme in schemes) {
296
- if (brokenSchemes.has(scheme)) continue;
297
- const val = schemes[scheme]?.[param];
298
- if (val === void 0) continue;
299
- const color = getColor(val, `@${scheme}`);
300
- if (color === void 0) continue;
301
- if (isString(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
302
- brokenSchemes.add(scheme);
303
- }
299
+ for (const param of allKeys) {
300
+ const symb = param.slice(0, 1);
301
+ if (symb === "@" || symb === "." || symb === ":") continue;
302
+ if (!isColorParam(param)) continue;
303
+ for (const scheme in schemes) {
304
+ if (brokenSchemes.has(scheme)) continue;
305
+ const val = schemes[scheme]?.[param];
306
+ if (val === void 0) continue;
307
+ const color = getColor(val, `@${scheme}`);
308
+ if (color === void 0) continue;
309
+ if (isString(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
310
+ brokenSchemes.add(scheme);
304
311
  }
305
312
  }
306
313
  }
@@ -322,38 +329,31 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
322
329
  }
323
330
  result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG);
324
331
  } else if (symb !== "@" && symb !== "." && symb !== ":") {
325
- const autoVar = `--theme-${varPrefix}-${param}`;
326
- if (globalTheme === "auto") {
327
- let fallbackColor;
328
- for (const scheme in schemes) {
329
- if (brokenSchemes.has(scheme)) continue;
330
- const val = schemes[scheme]?.[param];
331
- if (val === void 0) continue;
332
- const color = getColor(val, `@${scheme}`);
333
- if (color === void 0) continue;
334
- if (scheme === "light" || fallbackColor === void 0) {
335
- fallbackColor = color;
336
- }
337
- const selector = `[data-theme="${scheme}"]`;
338
- if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
339
- MEDIA_VARS[selector][autoVar] = color;
340
- if (scheme === "dark" || scheme === "light") {
341
- const mq = `@media (prefers-color-scheme: ${scheme})`;
342
- if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
343
- MEDIA_VARS[mq][autoVar] = color;
344
- }
345
- }
346
- if (fallbackColor !== void 0) {
347
- CSS_VARS[autoVar] = fallbackColor;
332
+ const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
333
+ const autoVar = `--${vp}theme-${varPrefix}-${param}`;
334
+ const forced = globalTheme && globalTheme !== "auto" ? String(globalTheme).replace(/^'|'$/g, "") : null;
335
+ let fallbackColor;
336
+ for (const scheme in schemes) {
337
+ if (brokenSchemes.has(scheme)) continue;
338
+ const val = schemes[scheme]?.[param];
339
+ if (val === void 0) continue;
340
+ const color = getColor(val, `@${scheme}`);
341
+ if (color === void 0) continue;
342
+ if (forced && scheme === forced || !forced && (scheme === "light" || fallbackColor === void 0)) {
343
+ fallbackColor = color;
348
344
  }
349
- } else {
350
- const forced = String(globalTheme).replace(/^'|'$/g, "");
351
- const source = schemes[forced]?.[param];
352
- if (source !== void 0) {
353
- const color = getColor(source, `@${forced}`);
354
- if (color !== void 0) CSS_VARS[autoVar] = color;
345
+ const selector = `[data-theme="${scheme}"]`;
346
+ if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
347
+ MEDIA_VARS[selector][autoVar] = color;
348
+ if (scheme === "dark" || scheme === "light") {
349
+ const mq = `@media (prefers-color-scheme: ${scheme})`;
350
+ if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
351
+ MEDIA_VARS[mq][autoVar] = color;
355
352
  }
356
353
  }
354
+ if (fallbackColor !== void 0) {
355
+ CSS_VARS[autoVar] = fallbackColor;
356
+ }
357
357
  result[param] = `var(${autoVar})`;
358
358
  result[`.${param}`] = { [param]: result[param] };
359
359
  }
@@ -368,7 +368,7 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
368
368
  };
369
369
  const setMediaTheme = (val, key, suffix, prefers) => {
370
370
  const CONFIG = getActiveConfig();
371
- const { CSS_VARS } = CONFIG;
371
+ const { cssVars: CSS_VARS } = CONFIG;
372
372
  const theme = { value: val };
373
373
  const isTopLevel = !suffix && !prefers;
374
374
  if (isObjectLike(val)) {
@@ -394,7 +394,8 @@ const setMediaTheme = (val, key, suffix, prefers) => {
394
394
  const color = getColor(value, prefers);
395
395
  const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
396
396
  const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
397
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
397
+ const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
398
+ const CSSVar = `--${vp}theme-${key}${varmetaSuffixName}-${param}`;
398
399
  if (CONFIG.useVariable) {
399
400
  if (CONFIG.useThemeSuffixedVars) CSS_VARS[CSSVar] = color;
400
401
  theme[param] = `var(${CSSVar})`;
@@ -1,10 +1,10 @@
1
- import { toCamelCase } from "@symbo.ls/smbls-utils";
1
+ import { toCamelCase } from "@symbo.ls/utils";
2
2
  import { getActiveConfig } from "../factory.js";
3
3
  import {
4
4
  applySequenceVars,
5
5
  generateSequence,
6
6
  getSequenceValuePropertyPair
7
- } from "../utils";
7
+ } from "../utils/index.js";
8
8
  const applyTimingSequence = () => {
9
9
  const CONFIG = getActiveConfig();
10
10
  const { timing: TIMING } = CONFIG;
@@ -1,4 +1,4 @@
1
- import { merge } from "@domql/utils";
1
+ import { merge } from "@symbo.ls/utils";
2
2
  import { getActiveConfig } from "../factory.js";
3
3
  import {
4
4
  applyMediaSequenceVars,
@@ -6,7 +6,7 @@ import {
6
6
  findHeadings,
7
7
  generateSequence,
8
8
  getSequenceValuePropertyPair
9
- } from "../utils";
9
+ } from "../utils/index.js";
10
10
  const runThroughMedia = (FACTORY) => {
11
11
  const CONFIG = getActiveConfig();
12
12
  const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG;
@@ -26,12 +26,21 @@ const runThroughMedia = (FACTORY) => {
26
26
  h1Matches,
27
27
  unit
28
28
  });
29
+ const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
30
+ const inheritedUnit = mediaValue.unit || unit;
31
+ const mediaUnit = !mediaValue.unit && VIEWPORT_UNITS.has(unit) ? "rem" : inheritedUnit;
29
32
  const query = MEDIA[mediaName];
30
33
  const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
31
34
  TYPOGRAPHY.templates[media] = {
32
- fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit
35
+ fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + mediaUnit
33
36
  };
34
37
  if (!mediaRegenerate) {
38
+ merge(mediaValue, {
39
+ sequence: {},
40
+ scales: {},
41
+ vars: {}
42
+ });
43
+ generateSequence(mediaValue);
35
44
  applyMediaSequenceVars(FACTORY, prop);
36
45
  continue;
37
46
  }
@@ -1,5 +1,5 @@
1
- import { isString, isObject, exec } from "@domql/utils";
2
- import { getActiveConfig } from "../factory";
1
+ import { isString, isObject, exec } from "@symbo.ls/utils";
2
+ import { getActiveConfig } from "../factory.js";
3
3
  import {
4
4
  getSpacingByKey,
5
5
  getColor,
@@ -10,7 +10,7 @@ import {
10
10
  getSpacingBasedOnRatio,
11
11
  checkIfBoxSize,
12
12
  splitSpacedValue
13
- } from "../system";
13
+ } from "../system/index.js";
14
14
  import {
15
15
  getFnPrefixAndValue,
16
16
  isResolvedColor,
@@ -18,7 +18,7 @@ import {
18
18
  CSS_NATIVE_COLOR_REGEX,
19
19
  splitTopLevelCommas,
20
20
  parseColorToken
21
- } from "../utils";
21
+ } from "../utils/index.js";
22
22
  const BORDER_STYLES = /* @__PURE__ */ new Set([
23
23
  "none",
24
24
  "hidden",
@@ -4,7 +4,7 @@ import {
4
4
  isString,
5
5
  isNumber,
6
6
  isNotProduction
7
- } from "@domql/utils";
7
+ } from "@symbo.ls/utils";
8
8
  const colorStringToRgbaArray = (color) => {
9
9
  if (color === "") return [0, 0, 0, 0];
10
10
  if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
@@ -16,6 +16,7 @@ const getDefaultOrFirstKey = (LIBRARY, key) => {
16
16
  return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
17
17
  };
18
18
  const getFontFormat = (url) => {
19
+ if (typeof url !== "string" || !url) return null;
19
20
  const ext = url.split(/[#?]/)[0].split(".").pop().trim();
20
21
  if (["woff2", "woff", "ttf", "otf", "eot"].includes(ext)) return ext;
21
22
  return null;
@@ -24,7 +25,8 @@ const isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") |
24
25
  const setFontImport = (url) => `@import url('${url}');`;
25
26
  const setInCustomFontMedia = (str) => `@font-face { ${str} }`;
26
27
  const setCustomFont = (name, url, weight, options = {}) => {
27
- const urls = Array.isArray(url) ? url : [url];
28
+ const rawUrls = Array.isArray(url) ? url : [url];
29
+ const urls = rawUrls.filter((u) => typeof u === "string" && u);
28
30
  const srcList = urls.map((u) => {
29
31
  const format = getFontFormat(u);
30
32
  const formatStr = format ? ` format('${format}')` : "";
@@ -1,5 +1,5 @@
1
- import { isString } from "@domql/utils";
2
- import { toDashCase } from "@symbo.ls/smbls-utils";
1
+ import { isString } from "@symbo.ls/utils";
2
+ import { toDashCase } from "@symbo.ls/utils";
3
3
  import { getActiveConfig } from "../factory.js";
4
4
  import { CSS_UNITS, isScalingUnit } from "./unit.js";
5
5
  import { isCSSVar } from "./color.js";
@@ -43,7 +43,8 @@ const setSequenceValue = (props, sequenceProps) => {
43
43
  variable
44
44
  };
45
45
  sequenceProps.scales[key] = scaling;
46
- sequenceProps.vars[variable] = scaling + sequenceProps.unit;
46
+ const varUnit = VIEWPORT_UNITS.has(sequenceProps.unit) ? "rem" : sequenceProps.unit;
47
+ sequenceProps.vars[variable] = scaling + varUnit;
47
48
  };
48
49
  const getFnPrefixAndValue = (val) => {
49
50
  if (!val.includes("(")) return val;
@@ -51,11 +52,14 @@ const getFnPrefixAndValue = (val) => {
51
52
  const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
52
53
  return [prefix, value];
53
54
  };
55
+ const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
54
56
  const setScalingVar = (key, sequenceProps) => {
55
- const { base, type, unit } = sequenceProps;
57
+ const { base, type, unit: rawUnit } = sequenceProps;
58
+ const unit = VIEWPORT_UNITS.has(rawUnit) ? "rem" : rawUnit;
56
59
  const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
57
60
  if (key === 0) return defaultVal;
58
- const prefix = "--" + (type && type.replace(".", "-"));
61
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
62
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
59
63
  const ratioVar = `${prefix}-ratio`;
60
64
  if (key > 0) {
61
65
  const prevLetterKey = numToLetterMap[key - 1];
@@ -63,6 +67,12 @@ const setScalingVar = (key, sequenceProps) => {
63
67
  }
64
68
  if (key < 0) {
65
69
  const nextLetterKey = numToLetterMap[key + 1];
70
+ const absKey = Math.abs(key);
71
+ const phiPow = Math.pow(PHI, 2 * absKey);
72
+ const prevAscKey = numToLetterMap[absKey];
73
+ if (prevAscKey) {
74
+ return `max(calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar})), calc(var(${prefix}-${prevAscKey}) / ${phiPow.toFixed(4)}))`;
75
+ }
66
76
  return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
67
77
  }
68
78
  };
@@ -70,7 +80,8 @@ const setSubScalingVar = (index, arr, variable, sequenceProps) => {
70
80
  const { type } = sequenceProps;
71
81
  const skipMiddle = index === 2 && arr.length === 2;
72
82
  const indexMapWithLength = skipMiddle ? index + 1 : index;
73
- const prefix = "--" + (type && type.replace(".", "-"));
83
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
84
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
74
85
  const subRatioVarPrefix = `${prefix}-sub-ratio-`;
75
86
  return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
76
87
  };
@@ -114,13 +125,19 @@ const generateSubSequence = (props, sequenceProps) => {
114
125
  setSequenceValue(props2, sequenceProps);
115
126
  });
116
127
  };
128
+ const PHI = 1.618;
117
129
  const switchSequenceOnNegative = (key, base, ratio) => {
118
- return base * Math.pow(ratio, key);
130
+ if (key >= 0) return base * Math.pow(ratio, key);
131
+ const absKey = Math.abs(key);
132
+ const current = base * Math.pow(ratio, key);
133
+ const normalized = base * Math.pow(ratio, absKey) / Math.pow(PHI, 2 * absKey);
134
+ return Math.max(current, normalized);
119
135
  };
120
136
  const generateSequence = (sequenceProps) => {
121
137
  const { type, base, ratio, range, subSequence } = sequenceProps;
122
138
  const n = Math.abs(range[0]) + Math.abs(range[1]);
123
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
139
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
140
+ const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
124
141
  for (let i = 0; i <= n; i++) {
125
142
  const key = range[1] - i;
126
143
  const letterKey = numToLetterMap[key];
@@ -161,7 +178,8 @@ const generateSequencePosition = (sequenceProps, position = 0) => {
161
178
  };
162
179
  const value = base * Math.pow(ratio, index);
163
180
  const scaling = ~~(value / base * 100) / 100;
164
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
181
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
182
+ const prefix = "--" + vp + (type && type.replace(".", "-")) + "-";
165
183
  const variable = prefix + letterKey;
166
184
  const scalingVariable = setScalingVar(index, sequenceProps);
167
185
  const props = {
@@ -202,7 +220,8 @@ const getSequenceValue = (value = "A", sequenceProps) => {
202
220
  "revert-layer"
203
221
  ];
204
222
  if (skipArr.includes(value)) return value;
205
- const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
223
+ const vp = sequenceProps.varPrefix ? sequenceProps.varPrefix + "-" : "";
224
+ const prefix = `--${vp}${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
206
225
  const letterVal = value.toUpperCase();
207
226
  const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
208
227
  let absValue = isNegative ? letterVal.slice(1) : letterVal;
@@ -249,12 +268,12 @@ const getSequenceValueBySymbols = (value, sequenceProps) => {
249
268
  (v) => value.includes(v + " ")
250
269
  );
251
270
  if (!mathArr.length) return value;
252
- return mathArr.map((symbol) => {
253
- const valuesArr = value.split(symbol + " ").map((v) => v.trim());
254
- const transformedValues = valuesArr.map((v) => {
255
- return getSequenceValue(v, sequenceProps);
256
- });
257
- return transformedValues.join(" " + symbol + " ");
271
+ const symbolRegex = /(\s*[+\-*/,]\s*)/;
272
+ const tokens = value.split(symbolRegex);
273
+ return tokens.map((token) => {
274
+ const trimmed = token.trim();
275
+ if (!trimmed || ["+", "-", "*", "/", ","].includes(trimmed)) return token;
276
+ return getSequenceValue(trimmed, sequenceProps);
258
277
  }).join("");
259
278
  };
260
279
  const getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
@@ -1,12 +1,12 @@
1
- import { isArray, isNotProduction, isString } from "@domql/utils";
2
- import { getActiveConfig } from "../factory";
1
+ import { isArray, isNotProduction, isString } from "@symbo.ls/utils";
2
+ import { getActiveConfig } from "../factory.js";
3
3
  const isDev = isNotProduction();
4
4
  const generateSprite = (icons) => {
5
5
  const CONFIG = getActiveConfig();
6
6
  let sprite = "";
7
7
  for (const key in icons) {
8
- if (CONFIG.__svg_cache[key]) continue;
9
- else CONFIG.__svg_cache[key] = true;
8
+ if (CONFIG.__svgCache[key]) continue;
9
+ else CONFIG.__svgCache[key] = true;
10
10
  sprite += icons[key];
11
11
  }
12
12
  return sprite;
@@ -57,8 +57,15 @@ const convertSvgToSymbol = (key, code) => {
57
57
  symbol = symbol.replace(/width="[^"]*"/, "");
58
58
  symbol = symbol.replace(/height="[^"]*"/, "");
59
59
  symbol = symbol.replace("</svg", "</symbol");
60
+ symbol = expandSvgSelfClosing(symbol);
60
61
  return symbol;
61
62
  };
63
+ const SVG_VOID_TAGS = "line|circle|ellipse|rect|polyline|polygon|path|stop|use|image";
64
+ const SVG_SELF_CLOSING_RE = new RegExp(
65
+ `<(${SVG_VOID_TAGS})\\b([^>]*?)\\s*/>`,
66
+ "g"
67
+ );
68
+ const expandSvgSelfClosing = (str) => str.replace(SVG_SELF_CLOSING_RE, "<$1$2></$1>");
62
69
  export {
63
70
  convertSvgToSymbol,
64
71
  generateSprite
@@ -1,10 +1,10 @@
1
- import { isObjectLike } from "@domql/utils";
1
+ import { isObjectLike } from "@symbo.ls/utils";
2
2
  import { getActiveConfig } from "../factory.js";
3
3
  import { getSubratio } from "./sequence.js";
4
4
  import { isScalingUnit } from "./unit.js";
5
5
  const setVariables = (result, key) => {
6
6
  const CONFIG = getActiveConfig();
7
- const { CSS_VARS } = CONFIG;
7
+ const { cssVars: CSS_VARS } = CONFIG;
8
8
  if (isObjectLike(result.value)) {
9
9
  } else {
10
10
  CSS_VARS[result.var] = result.value;
@@ -15,7 +15,8 @@ const applySequenceGlobalVars = (vars, obj, options) => {
15
15
  const { unit: UNIT } = CONFIG;
16
16
  const unit = obj.unit || UNIT.default;
17
17
  const { base, ratio, type } = obj;
18
- const prefix = "--" + (type && type.replace(".", "-"));
18
+ const vp = obj.varPrefix ? obj.varPrefix + "-" : "";
19
+ const prefix = "--" + vp + (type && type.replace(".", "-"));
19
20
  vars[`${prefix}-base`] = base;
20
21
  vars[`${prefix}-unit`] = unit;
21
22
  const ratioVar = `${prefix}-ratio`;
@@ -25,10 +26,12 @@ const applySequenceGlobalVars = (vars, obj, options) => {
25
26
  vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
26
27
  vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
27
28
  };
29
+ const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
28
30
  const applySequenceVars = (FACTORY, options = {}) => {
29
31
  const CONFIG = getActiveConfig();
30
- const { unit: UNIT, timing: TIMING, CSS_VARS } = CONFIG;
31
- const unit = FACTORY.unit || UNIT.default;
32
+ const { unit: UNIT, timing: TIMING, cssVars: CSS_VARS } = CONFIG;
33
+ const rawUnit = FACTORY.unit || UNIT.default;
34
+ const unit = VIEWPORT_UNITS.has(rawUnit) ? "rem" : rawUnit;
32
35
  const { mediaRegenerate, sequence, scales } = FACTORY;
33
36
  if (!mediaRegenerate) {
34
37
  applySequenceGlobalVars(CSS_VARS, FACTORY, options);
@@ -51,17 +54,28 @@ const applySequenceVars = (FACTORY, options = {}) => {
51
54
  };
52
55
  const applyMediaSequenceVars = (FACTORY, media, options = {}) => {
53
56
  const CONFIG = getActiveConfig();
54
- const { unit: UNIT, media: MEDIA, CSS_VARS } = CONFIG;
57
+ const { unit: UNIT, media: MEDIA, cssVars: CSS_VARS } = CONFIG;
55
58
  const mediaName = media.slice(1);
56
- const unit = FACTORY.unit || UNIT.default;
59
+ const mediaConfig = FACTORY[media];
60
+ const rawMediaUnit = mediaConfig.unit || FACTORY.unit || UNIT.default;
61
+ const unit = VIEWPORT_UNITS.has(rawMediaUnit) ? "rem" : rawMediaUnit;
57
62
  const { mediaRegenerate } = FACTORY;
58
- const { sequence, scales } = FACTORY[media];
63
+ const { sequence, scales } = mediaConfig;
59
64
  const query = MEDIA[mediaName];
60
65
  if (!query && CONFIG.verbose) console.warn("Can't find media query ", query);
61
66
  if (!mediaRegenerate) {
62
67
  let underMediaQuery = CSS_VARS[`@media ${query}`];
63
68
  if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {};
64
- applySequenceGlobalVars(underMediaQuery, FACTORY[media], options);
69
+ applySequenceGlobalVars(underMediaQuery, mediaConfig, options);
70
+ const parentUnit = FACTORY.unit || UNIT.default;
71
+ if (unit !== parentUnit && sequence) {
72
+ for (const key in sequence) {
73
+ const item = sequence[key];
74
+ const value = scales[key] + unit;
75
+ underMediaQuery[item.variable + "_default"] = value;
76
+ underMediaQuery[item.variable] = value;
77
+ }
78
+ }
65
79
  return;
66
80
  }
67
81
  for (const key in sequence) {