@symbo.ls/scratch 2.33.13 → 2.33.17
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/cjs/index.js +168 -74
- package/dist/cjs/set.js +116 -26
- package/dist/cjs/system/index.js +148 -54
- package/dist/cjs/system/shadow.js +115 -17
- package/dist/cjs/system/spacing.js +147 -53
- package/dist/cjs/system/timing.js +101 -6
- package/dist/cjs/system/typography.js +101 -6
- package/dist/cjs/transforms/index.js +155 -120
- package/dist/cjs/utils/index.js +104 -6
- package/dist/cjs/utils/sequence.js +103 -6
- package/dist/cjs/utils/unit.js +53 -0
- package/package.json +4 -4
- package/src/system/spacing.js +61 -54
- package/src/transforms/index.js +21 -29
- package/src/utils/sequence.js +61 -19
- package/src/utils/unit.js +69 -2
package/dist/cjs/index.js
CHANGED
|
@@ -317,6 +317,7 @@ __export(index_exports, {
|
|
|
317
317
|
CLASS: () => CLASS,
|
|
318
318
|
COLOR: () => COLOR,
|
|
319
319
|
CONFIG: () => CONFIG,
|
|
320
|
+
CSS_UNITS: () => CSS_UNITS,
|
|
320
321
|
CSS_VARS: () => CSS_VARS,
|
|
321
322
|
DEVICES: () => DEVICES,
|
|
322
323
|
DOCUMENT: () => DOCUMENT,
|
|
@@ -368,6 +369,7 @@ __export(index_exports, {
|
|
|
368
369
|
getColor: () => getColor,
|
|
369
370
|
getColorShade: () => getColorShade,
|
|
370
371
|
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
372
|
+
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
371
373
|
getFontFace: () => getFontFace,
|
|
372
374
|
getFontFaceEach: () => getFontFaceEach,
|
|
373
375
|
getFontFaceEachString: () => getFontFaceEachString,
|
|
@@ -379,6 +381,7 @@ __export(index_exports, {
|
|
|
379
381
|
getMediaTheme: () => getMediaTheme,
|
|
380
382
|
getRgbTone: () => getRgbTone,
|
|
381
383
|
getSequenceValue: () => getSequenceValue,
|
|
384
|
+
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
382
385
|
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
383
386
|
getShadow: () => getShadow,
|
|
384
387
|
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
@@ -424,6 +427,7 @@ __export(index_exports, {
|
|
|
424
427
|
setTheme: () => setTheme,
|
|
425
428
|
setValue: () => setValue,
|
|
426
429
|
setVariables: () => setVariables,
|
|
430
|
+
splitSpacedValue: () => splitSpacedValue,
|
|
427
431
|
splitTransition: () => splitTransition,
|
|
428
432
|
transformBackgroundImage: () => transformBackgroundImage,
|
|
429
433
|
transformBorder: () => transformBorder,
|
|
@@ -441,6 +445,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
441
445
|
// src/utils/index.js
|
|
442
446
|
var utils_exports = {};
|
|
443
447
|
__export(utils_exports, {
|
|
448
|
+
CSS_UNITS: () => CSS_UNITS,
|
|
444
449
|
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
445
450
|
applySequenceGlobalVars: () => applySequenceGlobalVars,
|
|
446
451
|
applySequenceVars: () => applySequenceVars,
|
|
@@ -455,6 +460,7 @@ __export(utils_exports, {
|
|
|
455
460
|
generateSubSequence: () => generateSubSequence,
|
|
456
461
|
getColorShade: () => getColorShade,
|
|
457
462
|
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
463
|
+
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
458
464
|
getFontFace: () => getFontFace,
|
|
459
465
|
getFontFaceEach: () => getFontFaceEach,
|
|
460
466
|
getFontFaceEachString: () => getFontFaceEachString,
|
|
@@ -462,6 +468,7 @@ __export(utils_exports, {
|
|
|
462
468
|
getFontFormat: () => getFontFormat,
|
|
463
469
|
getRgbTone: () => getRgbTone,
|
|
464
470
|
getSequenceValue: () => getSequenceValue,
|
|
471
|
+
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
465
472
|
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
466
473
|
getSubratio: () => getSubratio,
|
|
467
474
|
getSubratioDifference: () => getSubratioDifference,
|
|
@@ -491,6 +498,58 @@ __export(utils_exports, {
|
|
|
491
498
|
var isScalingUnit = (unit) => {
|
|
492
499
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
493
500
|
};
|
|
501
|
+
var CSS_UNITS = [
|
|
502
|
+
// Absolute
|
|
503
|
+
"px",
|
|
504
|
+
"cm",
|
|
505
|
+
"mm",
|
|
506
|
+
"in",
|
|
507
|
+
"pt",
|
|
508
|
+
"pc",
|
|
509
|
+
// Font-relative
|
|
510
|
+
"em",
|
|
511
|
+
"rem",
|
|
512
|
+
"ex",
|
|
513
|
+
"cap",
|
|
514
|
+
"ch",
|
|
515
|
+
"ic",
|
|
516
|
+
"lh",
|
|
517
|
+
"rlh",
|
|
518
|
+
// Viewport-relative
|
|
519
|
+
"%",
|
|
520
|
+
"vw",
|
|
521
|
+
"vh",
|
|
522
|
+
"vmin",
|
|
523
|
+
"vmax",
|
|
524
|
+
"svw",
|
|
525
|
+
"svh",
|
|
526
|
+
"lvw",
|
|
527
|
+
"lvh",
|
|
528
|
+
"dvw",
|
|
529
|
+
"dvh",
|
|
530
|
+
// Container query units
|
|
531
|
+
"cqw",
|
|
532
|
+
"cqh",
|
|
533
|
+
"cqi",
|
|
534
|
+
"cqb",
|
|
535
|
+
"cqmin",
|
|
536
|
+
"cqmax",
|
|
537
|
+
// Angle
|
|
538
|
+
"deg",
|
|
539
|
+
"rad",
|
|
540
|
+
"grad",
|
|
541
|
+
"turn",
|
|
542
|
+
// Time
|
|
543
|
+
"s",
|
|
544
|
+
"ms",
|
|
545
|
+
// Resolution
|
|
546
|
+
"dpi",
|
|
547
|
+
"dpcm",
|
|
548
|
+
"dppx",
|
|
549
|
+
// Grid fractional
|
|
550
|
+
"fr",
|
|
551
|
+
"auto"
|
|
552
|
+
];
|
|
494
553
|
|
|
495
554
|
// ../../../domql/packages/utils/dist/esm/env.js
|
|
496
555
|
var NODE_ENV = "development";
|
|
@@ -1129,6 +1188,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
1129
1188
|
sequenceProps.scales[key] = scaling;
|
|
1130
1189
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1131
1190
|
};
|
|
1191
|
+
var getFnPrefixAndValue = (val) => {
|
|
1192
|
+
if (!val.includes("(")) return val;
|
|
1193
|
+
const prefix = val.split("(")[0];
|
|
1194
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
1195
|
+
return [prefix, value];
|
|
1196
|
+
};
|
|
1132
1197
|
var setScalingVar = (key, sequenceProps) => {
|
|
1133
1198
|
const { base, type, unit } = sequenceProps;
|
|
1134
1199
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -1262,13 +1327,26 @@ var generateSequencePosition = (sequenceProps, position = 0) => {
|
|
|
1262
1327
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
1263
1328
|
const CONFIG2 = getActiveConfig();
|
|
1264
1329
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
1265
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
1266
1330
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
1267
|
-
const
|
|
1331
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
1268
1332
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
1269
1333
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
1270
|
-
|
|
1271
|
-
|
|
1334
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
1335
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
1336
|
+
const skipArr = [
|
|
1337
|
+
"none",
|
|
1338
|
+
"auto",
|
|
1339
|
+
"max-content",
|
|
1340
|
+
"min-content",
|
|
1341
|
+
"fit-content",
|
|
1342
|
+
"inherit",
|
|
1343
|
+
"initial",
|
|
1344
|
+
"unset",
|
|
1345
|
+
"revert",
|
|
1346
|
+
"revert-layer"
|
|
1347
|
+
];
|
|
1348
|
+
if (skipArr.includes(value)) return value;
|
|
1349
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
1272
1350
|
const letterVal = value.toUpperCase();
|
|
1273
1351
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
1274
1352
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -1310,14 +1388,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1310
1388
|
}
|
|
1311
1389
|
return isNegative + sequenceItem.scaling + unit;
|
|
1312
1390
|
};
|
|
1313
|
-
var
|
|
1391
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
1392
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1393
|
+
(v) => value.includes(v + " ")
|
|
1394
|
+
);
|
|
1395
|
+
if (!mathArr.length) return value;
|
|
1396
|
+
return mathArr.map((symbol) => {
|
|
1397
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
1398
|
+
const transformedValues = valuesArr.map((v) => {
|
|
1399
|
+
return getSequenceValue(v, sequenceProps);
|
|
1400
|
+
});
|
|
1401
|
+
return transformedValues.join(symbol + " ");
|
|
1402
|
+
}).join("");
|
|
1403
|
+
};
|
|
1404
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
1314
1405
|
if (typeof value !== "string") {
|
|
1315
1406
|
const CONFIG2 = getActiveConfig();
|
|
1316
1407
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
1317
1408
|
return { [propertyName]: value };
|
|
1318
1409
|
}
|
|
1319
1410
|
if (value === "-" || value === "") return {};
|
|
1320
|
-
|
|
1411
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1412
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1413
|
+
fnPrefix = fnArr[0];
|
|
1414
|
+
value = fnArr[1];
|
|
1415
|
+
}
|
|
1416
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1417
|
+
(v) => value.includes(v + " ")
|
|
1418
|
+
);
|
|
1419
|
+
if (mathArr.length) {
|
|
1420
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
1421
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
1422
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
1321
1423
|
};
|
|
1322
1424
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
1323
1425
|
var findHeadings = (propertyNames) => {
|
|
@@ -1474,6 +1576,7 @@ __export(system_exports, {
|
|
|
1474
1576
|
applySpacingSequence: () => applySpacingSequence,
|
|
1475
1577
|
applyTimingSequence: () => applyTimingSequence,
|
|
1476
1578
|
applyTypographySequence: () => applyTypographySequence,
|
|
1579
|
+
checkIfBoxSize: () => checkIfBoxSize,
|
|
1477
1580
|
getColor: () => getColor,
|
|
1478
1581
|
getFontFamily: () => getFontFamily,
|
|
1479
1582
|
getFontSizeByKey: () => getFontSizeByKey,
|
|
@@ -1494,7 +1597,8 @@ __export(system_exports, {
|
|
|
1494
1597
|
setSVG: () => setSVG,
|
|
1495
1598
|
setShadow: () => setShadow,
|
|
1496
1599
|
setSvgIcon: () => setSvgIcon,
|
|
1497
|
-
setTheme: () => setTheme
|
|
1600
|
+
setTheme: () => setTheme,
|
|
1601
|
+
splitSpacedValue: () => splitSpacedValue
|
|
1498
1602
|
});
|
|
1499
1603
|
|
|
1500
1604
|
// src/system/color.js
|
|
@@ -1923,15 +2027,7 @@ var runThroughMedia2 = (FACTORY2) => {
|
|
|
1923
2027
|
const mediaProps = FACTORY2[prop];
|
|
1924
2028
|
const isMediaName = prop.slice(0, 1) === "@";
|
|
1925
2029
|
if (!isMediaName) continue;
|
|
1926
|
-
const {
|
|
1927
|
-
type,
|
|
1928
|
-
base,
|
|
1929
|
-
ratio,
|
|
1930
|
-
range,
|
|
1931
|
-
subSequence,
|
|
1932
|
-
h1Matches,
|
|
1933
|
-
unit
|
|
1934
|
-
} = FACTORY2;
|
|
2030
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
|
|
1935
2031
|
merge(mediaProps, {
|
|
1936
2032
|
type,
|
|
1937
2033
|
base,
|
|
@@ -1949,6 +2045,12 @@ var runThroughMedia2 = (FACTORY2) => {
|
|
|
1949
2045
|
applyMediaSequenceVars(FACTORY2, prop);
|
|
1950
2046
|
}
|
|
1951
2047
|
};
|
|
2048
|
+
var checkIfBoxSize = (propertyName) => {
|
|
2049
|
+
const prop = propertyName.toLowerCase();
|
|
2050
|
+
const includesWidth = prop.includes("width") || prop.includes("height");
|
|
2051
|
+
const includesBorder = prop.includes("border") || prop.includes("outline");
|
|
2052
|
+
return includesWidth && !includesBorder;
|
|
2053
|
+
};
|
|
1952
2054
|
var applySpacingSequence = () => {
|
|
1953
2055
|
const CONFIG2 = getActiveConfig();
|
|
1954
2056
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
@@ -1963,12 +2065,16 @@ var getSequence = (sequenceProps) => {
|
|
|
1963
2065
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1964
2066
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1965
2067
|
};
|
|
1966
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
2068
|
+
var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
1967
2069
|
const sequence = getSequence(sequenceProps);
|
|
1968
|
-
if (isString(value)
|
|
1969
|
-
|
|
2070
|
+
if (isString(value)) {
|
|
2071
|
+
if (!fnPrefix && value.includes("(")) {
|
|
2072
|
+
const fnArray = getFnPrefixAndValue(value);
|
|
2073
|
+
fnPrefix = fnArray[0];
|
|
2074
|
+
value = fnArray[1];
|
|
2075
|
+
}
|
|
1970
2076
|
}
|
|
1971
|
-
const stack = (0, import_utils15.arrayzeValue)(value);
|
|
2077
|
+
const stack = fnPrefix ? [value] : (0, import_utils15.arrayzeValue)(value);
|
|
1972
2078
|
if (!isArray(stack)) return;
|
|
1973
2079
|
if (stack.length > 1) {
|
|
1974
2080
|
let suffix = "";
|
|
@@ -1984,45 +2090,40 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1984
2090
|
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
1985
2091
|
stack[i],
|
|
1986
2092
|
propertyName + direction + suffix,
|
|
1987
|
-
sequence
|
|
2093
|
+
sequence,
|
|
2094
|
+
fnPrefix
|
|
2095
|
+
);
|
|
2096
|
+
return directions[stack.length].map(
|
|
2097
|
+
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
1988
2098
|
);
|
|
1989
|
-
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
1990
2099
|
}
|
|
1991
|
-
return getSequenceValuePropertyPair(
|
|
1992
|
-
value,
|
|
1993
|
-
propertyName,
|
|
1994
|
-
sequence
|
|
1995
|
-
);
|
|
2100
|
+
return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
|
|
1996
2101
|
};
|
|
1997
|
-
var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
2102
|
+
var getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
1998
2103
|
const CONFIG2 = getActiveConfig();
|
|
1999
2104
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
applySequenceVars(sequenceProps, { useDefault: false });
|
|
2023
|
-
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
2024
|
-
}
|
|
2025
|
-
return getSpacingByKey(value, propertyName);
|
|
2105
|
+
let value = val || props[propertyName];
|
|
2106
|
+
if (!fnPrefix && isString(value) && value.includes("(")) {
|
|
2107
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
2108
|
+
fnPrefix = fnArr[0];
|
|
2109
|
+
value = fnArr[1];
|
|
2110
|
+
}
|
|
2111
|
+
if (props.spacingRatio) {
|
|
2112
|
+
const sequenceProps = applyCustomSequence(props);
|
|
2113
|
+
return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
|
|
2114
|
+
}
|
|
2115
|
+
return getSpacingByKey(value, propertyName, SPACING2, fnPrefix);
|
|
2116
|
+
};
|
|
2117
|
+
var splitSpacedValue = (val) => {
|
|
2118
|
+
const addDefault = (v) => {
|
|
2119
|
+
const isSymbol = ["+", "-", "*", "/"].includes(v);
|
|
2120
|
+
const hasUnits = CSS_UNITS.some((unit) => val.includes(unit));
|
|
2121
|
+
if (isSymbol || hasUnits) return v;
|
|
2122
|
+
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
2123
|
+
if (isSingleLetter) return v + "_default";
|
|
2124
|
+
return v;
|
|
2125
|
+
};
|
|
2126
|
+
return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
|
|
2026
2127
|
};
|
|
2027
2128
|
|
|
2028
2129
|
// src/system/shadow.js
|
|
@@ -2358,30 +2459,23 @@ var splitTransition = (transition) => {
|
|
|
2358
2459
|
if (!arr.length) return;
|
|
2359
2460
|
return arr.map(transformTransition).join(",");
|
|
2360
2461
|
};
|
|
2361
|
-
var checkIfBoxSize = (propertyName) => {
|
|
2362
|
-
const prop = propertyName.toLowerCase();
|
|
2363
|
-
return (prop.includes("width") || prop.includes("height")) && !prop.includes("border");
|
|
2364
|
-
};
|
|
2365
2462
|
var transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
2366
2463
|
let value = val || props[propertyName];
|
|
2367
2464
|
if (isUndefined(value) && isNull(value)) return;
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
if (opts.ratio) {
|
|
2381
|
-
return getSpacingBasedOnRatio(props, propertyName, value);
|
|
2382
|
-
} else {
|
|
2383
|
-
return getSpacingByKey(value, propertyName);
|
|
2465
|
+
let fnPrefix;
|
|
2466
|
+
if (isString(value)) {
|
|
2467
|
+
if (value.includes("(")) {
|
|
2468
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
2469
|
+
fnPrefix = fnArr[0];
|
|
2470
|
+
value = fnArr[1];
|
|
2471
|
+
}
|
|
2472
|
+
const shouldScaleBoxSize = props.scaleBoxSize;
|
|
2473
|
+
const isBoxSize = checkIfBoxSize(propertyName);
|
|
2474
|
+
if (!shouldScaleBoxSize && isBoxSize) {
|
|
2475
|
+
value = splitSpacedValue(value);
|
|
2476
|
+
}
|
|
2384
2477
|
}
|
|
2478
|
+
return opts.ratio ? getSpacingBasedOnRatio(props, propertyName, value, fnPrefix) : getSpacingByKey(value, propertyName, void 0, fnPrefix);
|
|
2385
2479
|
};
|
|
2386
2480
|
var transformSizeRatio = (propertyName, props) => {
|
|
2387
2481
|
return transformSize(propertyName, null, props, {
|
package/dist/cjs/set.js
CHANGED
|
@@ -725,6 +725,58 @@ var setActiveConfig = (newConfig) => {
|
|
|
725
725
|
var isScalingUnit = (unit) => {
|
|
726
726
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
727
727
|
};
|
|
728
|
+
var CSS_UNITS = [
|
|
729
|
+
// Absolute
|
|
730
|
+
"px",
|
|
731
|
+
"cm",
|
|
732
|
+
"mm",
|
|
733
|
+
"in",
|
|
734
|
+
"pt",
|
|
735
|
+
"pc",
|
|
736
|
+
// Font-relative
|
|
737
|
+
"em",
|
|
738
|
+
"rem",
|
|
739
|
+
"ex",
|
|
740
|
+
"cap",
|
|
741
|
+
"ch",
|
|
742
|
+
"ic",
|
|
743
|
+
"lh",
|
|
744
|
+
"rlh",
|
|
745
|
+
// Viewport-relative
|
|
746
|
+
"%",
|
|
747
|
+
"vw",
|
|
748
|
+
"vh",
|
|
749
|
+
"vmin",
|
|
750
|
+
"vmax",
|
|
751
|
+
"svw",
|
|
752
|
+
"svh",
|
|
753
|
+
"lvw",
|
|
754
|
+
"lvh",
|
|
755
|
+
"dvw",
|
|
756
|
+
"dvh",
|
|
757
|
+
// Container query units
|
|
758
|
+
"cqw",
|
|
759
|
+
"cqh",
|
|
760
|
+
"cqi",
|
|
761
|
+
"cqb",
|
|
762
|
+
"cqmin",
|
|
763
|
+
"cqmax",
|
|
764
|
+
// Angle
|
|
765
|
+
"deg",
|
|
766
|
+
"rad",
|
|
767
|
+
"grad",
|
|
768
|
+
"turn",
|
|
769
|
+
// Time
|
|
770
|
+
"s",
|
|
771
|
+
"ms",
|
|
772
|
+
// Resolution
|
|
773
|
+
"dpi",
|
|
774
|
+
"dpcm",
|
|
775
|
+
"dppx",
|
|
776
|
+
// Grid fractional
|
|
777
|
+
"fr",
|
|
778
|
+
"auto"
|
|
779
|
+
];
|
|
728
780
|
|
|
729
781
|
// src/utils/color.js
|
|
730
782
|
var colorStringToRgbaArray = (color) => {
|
|
@@ -880,6 +932,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
880
932
|
sequenceProps.scales[key] = scaling;
|
|
881
933
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
882
934
|
};
|
|
935
|
+
var getFnPrefixAndValue = (val) => {
|
|
936
|
+
if (!val.includes("(")) return val;
|
|
937
|
+
const prefix = val.split("(")[0];
|
|
938
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
939
|
+
return [prefix, value];
|
|
940
|
+
};
|
|
883
941
|
var setScalingVar = (key, sequenceProps) => {
|
|
884
942
|
const { base, type, unit } = sequenceProps;
|
|
885
943
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -975,13 +1033,26 @@ var generateSequence = (sequenceProps) => {
|
|
|
975
1033
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
976
1034
|
const CONFIG2 = getActiveConfig();
|
|
977
1035
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
978
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
979
1036
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
980
|
-
const
|
|
1037
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
981
1038
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
982
1039
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
983
|
-
|
|
984
|
-
|
|
1040
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
1041
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
1042
|
+
const skipArr = [
|
|
1043
|
+
"none",
|
|
1044
|
+
"auto",
|
|
1045
|
+
"max-content",
|
|
1046
|
+
"min-content",
|
|
1047
|
+
"fit-content",
|
|
1048
|
+
"inherit",
|
|
1049
|
+
"initial",
|
|
1050
|
+
"unset",
|
|
1051
|
+
"revert",
|
|
1052
|
+
"revert-layer"
|
|
1053
|
+
];
|
|
1054
|
+
if (skipArr.includes(value)) return value;
|
|
1055
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
985
1056
|
const letterVal = value.toUpperCase();
|
|
986
1057
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
987
1058
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -1023,14 +1094,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1023
1094
|
}
|
|
1024
1095
|
return isNegative + sequenceItem.scaling + unit;
|
|
1025
1096
|
};
|
|
1026
|
-
var
|
|
1097
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
1098
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1099
|
+
(v) => value.includes(v + " ")
|
|
1100
|
+
);
|
|
1101
|
+
if (!mathArr.length) return value;
|
|
1102
|
+
return mathArr.map((symbol) => {
|
|
1103
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
1104
|
+
const transformedValues = valuesArr.map((v) => {
|
|
1105
|
+
return getSequenceValue(v, sequenceProps);
|
|
1106
|
+
});
|
|
1107
|
+
return transformedValues.join(symbol + " ");
|
|
1108
|
+
}).join("");
|
|
1109
|
+
};
|
|
1110
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
1027
1111
|
if (typeof value !== "string") {
|
|
1028
1112
|
const CONFIG2 = getActiveConfig();
|
|
1029
1113
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
1030
1114
|
return { [propertyName]: value };
|
|
1031
1115
|
}
|
|
1032
1116
|
if (value === "-" || value === "") return {};
|
|
1033
|
-
|
|
1117
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1118
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1119
|
+
fnPrefix = fnArr[0];
|
|
1120
|
+
value = fnArr[1];
|
|
1121
|
+
}
|
|
1122
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1123
|
+
(v) => value.includes(v + " ")
|
|
1124
|
+
);
|
|
1125
|
+
if (mathArr.length) {
|
|
1126
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
1127
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
1128
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
1034
1129
|
};
|
|
1035
1130
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
1036
1131
|
var findHeadings = (propertyNames) => {
|
|
@@ -1545,15 +1640,7 @@ var runThroughMedia2 = (FACTORY2) => {
|
|
|
1545
1640
|
const mediaProps = FACTORY2[prop];
|
|
1546
1641
|
const isMediaName = prop.slice(0, 1) === "@";
|
|
1547
1642
|
if (!isMediaName) continue;
|
|
1548
|
-
const {
|
|
1549
|
-
type,
|
|
1550
|
-
base,
|
|
1551
|
-
ratio,
|
|
1552
|
-
range,
|
|
1553
|
-
subSequence,
|
|
1554
|
-
h1Matches,
|
|
1555
|
-
unit
|
|
1556
|
-
} = FACTORY2;
|
|
1643
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
|
|
1557
1644
|
merge(mediaProps, {
|
|
1558
1645
|
type,
|
|
1559
1646
|
base,
|
|
@@ -1585,12 +1672,16 @@ var getSequence = (sequenceProps) => {
|
|
|
1585
1672
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1586
1673
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1587
1674
|
};
|
|
1588
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
1675
|
+
var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
1589
1676
|
const sequence = getSequence(sequenceProps);
|
|
1590
|
-
if (isString(value)
|
|
1591
|
-
|
|
1677
|
+
if (isString(value)) {
|
|
1678
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1679
|
+
const fnArray = getFnPrefixAndValue(value);
|
|
1680
|
+
fnPrefix = fnArray[0];
|
|
1681
|
+
value = fnArray[1];
|
|
1682
|
+
}
|
|
1592
1683
|
}
|
|
1593
|
-
const stack = (0, import_utils15.arrayzeValue)(value);
|
|
1684
|
+
const stack = fnPrefix ? [value] : (0, import_utils15.arrayzeValue)(value);
|
|
1594
1685
|
if (!isArray(stack)) return;
|
|
1595
1686
|
if (stack.length > 1) {
|
|
1596
1687
|
let suffix = "";
|
|
@@ -1606,15 +1697,14 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1606
1697
|
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
1607
1698
|
stack[i],
|
|
1608
1699
|
propertyName + direction + suffix,
|
|
1609
|
-
sequence
|
|
1700
|
+
sequence,
|
|
1701
|
+
fnPrefix
|
|
1702
|
+
);
|
|
1703
|
+
return directions[stack.length].map(
|
|
1704
|
+
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
1610
1705
|
);
|
|
1611
|
-
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
1612
1706
|
}
|
|
1613
|
-
return getSequenceValuePropertyPair(
|
|
1614
|
-
value,
|
|
1615
|
-
propertyName,
|
|
1616
|
-
sequence
|
|
1617
|
-
);
|
|
1707
|
+
return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
|
|
1618
1708
|
};
|
|
1619
1709
|
|
|
1620
1710
|
// src/system/shadow.js
|