@symbo.ls/scratch 2.33.14 → 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
|
@@ -311,7 +311,6 @@ var require_cjs = __commonJS({
|
|
|
311
311
|
// src/transforms/index.js
|
|
312
312
|
var transforms_exports = {};
|
|
313
313
|
__export(transforms_exports, {
|
|
314
|
-
checkIfBoxSize: () => checkIfBoxSize,
|
|
315
314
|
splitTransition: () => splitTransition,
|
|
316
315
|
transformBackgroundImage: () => transformBackgroundImage,
|
|
317
316
|
transformBorder: () => transformBorder,
|
|
@@ -386,19 +385,6 @@ var __spreadValues = (a, b) => {
|
|
|
386
385
|
return a;
|
|
387
386
|
};
|
|
388
387
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
389
|
-
var merge = (element, obj, excludeFrom = []) => {
|
|
390
|
-
for (const e in obj) {
|
|
391
|
-
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
|
|
392
|
-
if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
|
|
393
|
-
continue;
|
|
394
|
-
const elementProp = element[e];
|
|
395
|
-
const objProp = obj[e];
|
|
396
|
-
if (elementProp === void 0) {
|
|
397
|
-
element[e] = objProp;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return element;
|
|
401
|
-
};
|
|
402
388
|
var deepMerge = (element, extend, excludeFrom = [], level = Infinity) => {
|
|
403
389
|
for (const e in extend) {
|
|
404
390
|
const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
|
|
@@ -704,6 +690,58 @@ var getActiveConfig = (def) => {
|
|
|
704
690
|
var isScalingUnit = (unit) => {
|
|
705
691
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
706
692
|
};
|
|
693
|
+
var CSS_UNITS = [
|
|
694
|
+
// Absolute
|
|
695
|
+
"px",
|
|
696
|
+
"cm",
|
|
697
|
+
"mm",
|
|
698
|
+
"in",
|
|
699
|
+
"pt",
|
|
700
|
+
"pc",
|
|
701
|
+
// Font-relative
|
|
702
|
+
"em",
|
|
703
|
+
"rem",
|
|
704
|
+
"ex",
|
|
705
|
+
"cap",
|
|
706
|
+
"ch",
|
|
707
|
+
"ic",
|
|
708
|
+
"lh",
|
|
709
|
+
"rlh",
|
|
710
|
+
// Viewport-relative
|
|
711
|
+
"%",
|
|
712
|
+
"vw",
|
|
713
|
+
"vh",
|
|
714
|
+
"vmin",
|
|
715
|
+
"vmax",
|
|
716
|
+
"svw",
|
|
717
|
+
"svh",
|
|
718
|
+
"lvw",
|
|
719
|
+
"lvh",
|
|
720
|
+
"dvw",
|
|
721
|
+
"dvh",
|
|
722
|
+
// Container query units
|
|
723
|
+
"cqw",
|
|
724
|
+
"cqh",
|
|
725
|
+
"cqi",
|
|
726
|
+
"cqb",
|
|
727
|
+
"cqmin",
|
|
728
|
+
"cqmax",
|
|
729
|
+
// Angle
|
|
730
|
+
"deg",
|
|
731
|
+
"rad",
|
|
732
|
+
"grad",
|
|
733
|
+
"turn",
|
|
734
|
+
// Time
|
|
735
|
+
"s",
|
|
736
|
+
"ms",
|
|
737
|
+
// Resolution
|
|
738
|
+
"dpi",
|
|
739
|
+
"dpcm",
|
|
740
|
+
"dppx",
|
|
741
|
+
// Grid fractional
|
|
742
|
+
"fr",
|
|
743
|
+
"auto"
|
|
744
|
+
];
|
|
707
745
|
|
|
708
746
|
// src/utils/color.js
|
|
709
747
|
var colorStringToRgbaArray = (color) => {
|
|
@@ -835,6 +873,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
835
873
|
sequenceProps.scales[key] = scaling;
|
|
836
874
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
837
875
|
};
|
|
876
|
+
var getFnPrefixAndValue = (val) => {
|
|
877
|
+
if (!val.includes("(")) return val;
|
|
878
|
+
const prefix = val.split("(")[0];
|
|
879
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
880
|
+
return [prefix, value];
|
|
881
|
+
};
|
|
838
882
|
var setScalingVar = (key, sequenceProps) => {
|
|
839
883
|
const { base, type, unit } = sequenceProps;
|
|
840
884
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -866,9 +910,6 @@ var getSubratioDifference = (base, ratio) => {
|
|
|
866
910
|
const middle = (first + second) / 2;
|
|
867
911
|
return [first, middle, second];
|
|
868
912
|
};
|
|
869
|
-
var getSubratio = (base, ratio) => {
|
|
870
|
-
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
871
|
-
};
|
|
872
913
|
var generateSubSequence = (props, sequenceProps) => {
|
|
873
914
|
const { key, base, value, ratio, variable, index } = props;
|
|
874
915
|
const next = value * ratio;
|
|
@@ -930,13 +971,26 @@ var generateSequence = (sequenceProps) => {
|
|
|
930
971
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
931
972
|
const CONFIG2 = getActiveConfig();
|
|
932
973
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
933
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
934
974
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
935
|
-
const
|
|
975
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
936
976
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
937
977
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
938
|
-
|
|
939
|
-
|
|
978
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
979
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
980
|
+
const skipArr = [
|
|
981
|
+
"none",
|
|
982
|
+
"auto",
|
|
983
|
+
"max-content",
|
|
984
|
+
"min-content",
|
|
985
|
+
"fit-content",
|
|
986
|
+
"inherit",
|
|
987
|
+
"initial",
|
|
988
|
+
"unset",
|
|
989
|
+
"revert",
|
|
990
|
+
"revert-layer"
|
|
991
|
+
];
|
|
992
|
+
if (skipArr.includes(value)) return value;
|
|
993
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
940
994
|
const letterVal = value.toUpperCase();
|
|
941
995
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
942
996
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -978,55 +1032,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
978
1032
|
}
|
|
979
1033
|
return isNegative + sequenceItem.scaling + unit;
|
|
980
1034
|
};
|
|
981
|
-
var
|
|
1035
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
1036
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1037
|
+
(v) => value.includes(v + " ")
|
|
1038
|
+
);
|
|
1039
|
+
if (!mathArr.length) return value;
|
|
1040
|
+
return mathArr.map((symbol) => {
|
|
1041
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
1042
|
+
const transformedValues = valuesArr.map((v) => {
|
|
1043
|
+
return getSequenceValue(v, sequenceProps);
|
|
1044
|
+
});
|
|
1045
|
+
return transformedValues.join(symbol + " ");
|
|
1046
|
+
}).join("");
|
|
1047
|
+
};
|
|
1048
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
982
1049
|
if (typeof value !== "string") {
|
|
983
1050
|
const CONFIG2 = getActiveConfig();
|
|
984
1051
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
985
1052
|
return { [propertyName]: value };
|
|
986
1053
|
}
|
|
987
1054
|
if (value === "-" || value === "") return {};
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
var applySequenceGlobalVars = (vars, obj, options) => {
|
|
993
|
-
const CONFIG2 = getActiveConfig();
|
|
994
|
-
const { UNIT: UNIT2 } = CONFIG2;
|
|
995
|
-
const unit = obj.unit || UNIT2.default;
|
|
996
|
-
const { base, ratio, type } = obj;
|
|
997
|
-
const prefix = "--" + (type && type.replace(".", "-"));
|
|
998
|
-
vars[`${prefix}-base`] = base;
|
|
999
|
-
vars[`${prefix}-unit`] = unit;
|
|
1000
|
-
const ratioVar = `${prefix}-ratio`;
|
|
1001
|
-
vars[ratioVar] = ratio;
|
|
1002
|
-
const [first, middle, second] = getSubratio(base, ratio);
|
|
1003
|
-
vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
|
|
1004
|
-
vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
|
|
1005
|
-
vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
|
|
1006
|
-
};
|
|
1007
|
-
var applySequenceVars = (FACTORY2, options = {}) => {
|
|
1008
|
-
const CONFIG2 = getActiveConfig();
|
|
1009
|
-
const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1010
|
-
const unit = FACTORY2.unit || UNIT2.default;
|
|
1011
|
-
const { mediaRegenerate, sequence, scales } = FACTORY2;
|
|
1012
|
-
if (!mediaRegenerate) {
|
|
1013
|
-
applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
|
|
1014
|
-
}
|
|
1015
|
-
for (const key in sequence) {
|
|
1016
|
-
const item = sequence[key];
|
|
1017
|
-
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
1018
|
-
if (!mediaRegenerate) {
|
|
1019
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1020
|
-
CSS_VARS2[item.variable] = item.scalingVariable;
|
|
1021
|
-
continue;
|
|
1022
|
-
}
|
|
1023
|
-
if (options.useDefault === false) {
|
|
1024
|
-
CSS_VARS2[item.variable] = value;
|
|
1025
|
-
} else {
|
|
1026
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1027
|
-
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1028
|
-
}
|
|
1055
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1056
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1057
|
+
fnPrefix = fnArr[0];
|
|
1058
|
+
value = fnArr[1];
|
|
1029
1059
|
}
|
|
1060
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1061
|
+
(v) => value.includes(v + " ")
|
|
1062
|
+
);
|
|
1063
|
+
if (mathArr.length) {
|
|
1064
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
1065
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
1066
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
1030
1067
|
};
|
|
1031
1068
|
|
|
1032
1069
|
// src/utils/sprite.js
|
|
@@ -1099,6 +1136,12 @@ var import_utils11 = __toESM(require_cjs(), 1);
|
|
|
1099
1136
|
|
|
1100
1137
|
// src/system/spacing.js
|
|
1101
1138
|
var import_utils15 = __toESM(require_cjs(), 1);
|
|
1139
|
+
var checkIfBoxSize = (propertyName) => {
|
|
1140
|
+
const prop = propertyName.toLowerCase();
|
|
1141
|
+
const includesWidth = prop.includes("width") || prop.includes("height");
|
|
1142
|
+
const includesBorder = prop.includes("border") || prop.includes("outline");
|
|
1143
|
+
return includesWidth && !includesBorder;
|
|
1144
|
+
};
|
|
1102
1145
|
var getSequence = (sequenceProps) => {
|
|
1103
1146
|
const CONFIG2 = getActiveConfig();
|
|
1104
1147
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
@@ -1106,12 +1149,16 @@ var getSequence = (sequenceProps) => {
|
|
|
1106
1149
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1107
1150
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1108
1151
|
};
|
|
1109
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
1152
|
+
var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
1110
1153
|
const sequence = getSequence(sequenceProps);
|
|
1111
|
-
if (isString(value)
|
|
1112
|
-
|
|
1154
|
+
if (isString(value)) {
|
|
1155
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1156
|
+
const fnArray = getFnPrefixAndValue(value);
|
|
1157
|
+
fnPrefix = fnArray[0];
|
|
1158
|
+
value = fnArray[1];
|
|
1159
|
+
}
|
|
1113
1160
|
}
|
|
1114
|
-
const stack = (0, import_utils15.arrayzeValue)(value);
|
|
1161
|
+
const stack = fnPrefix ? [value] : (0, import_utils15.arrayzeValue)(value);
|
|
1115
1162
|
if (!isArray(stack)) return;
|
|
1116
1163
|
if (stack.length > 1) {
|
|
1117
1164
|
let suffix = "";
|
|
@@ -1127,45 +1174,40 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1127
1174
|
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
1128
1175
|
stack[i],
|
|
1129
1176
|
propertyName + direction + suffix,
|
|
1130
|
-
sequence
|
|
1177
|
+
sequence,
|
|
1178
|
+
fnPrefix
|
|
1179
|
+
);
|
|
1180
|
+
return directions[stack.length].map(
|
|
1181
|
+
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
1131
1182
|
);
|
|
1132
|
-
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
1133
1183
|
}
|
|
1134
|
-
return getSequenceValuePropertyPair(
|
|
1135
|
-
value,
|
|
1136
|
-
propertyName,
|
|
1137
|
-
sequence
|
|
1138
|
-
);
|
|
1184
|
+
return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
|
|
1139
1185
|
};
|
|
1140
|
-
var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
1186
|
+
var getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
1141
1187
|
const CONFIG2 = getActiveConfig();
|
|
1142
1188
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
unit,
|
|
1153
|
-
sequence: {},
|
|
1154
|
-
scales: {},
|
|
1155
|
-
templates: {},
|
|
1156
|
-
vars: {}
|
|
1157
|
-
}, {
|
|
1158
|
-
base,
|
|
1159
|
-
range,
|
|
1160
|
-
subSequence,
|
|
1161
|
-
ratio: SPACING2.ratio,
|
|
1162
|
-
unit: SPACING2.unit
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
applySequenceVars(sequenceProps, { useDefault: false });
|
|
1166
|
-
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
1189
|
+
let value = val || props[propertyName];
|
|
1190
|
+
if (!fnPrefix && isString(value) && value.includes("(")) {
|
|
1191
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1192
|
+
fnPrefix = fnArr[0];
|
|
1193
|
+
value = fnArr[1];
|
|
1194
|
+
}
|
|
1195
|
+
if (props.spacingRatio) {
|
|
1196
|
+
const sequenceProps = applyCustomSequence(props);
|
|
1197
|
+
return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
|
|
1167
1198
|
}
|
|
1168
|
-
return getSpacingByKey(value, propertyName);
|
|
1199
|
+
return getSpacingByKey(value, propertyName, SPACING2, fnPrefix);
|
|
1200
|
+
};
|
|
1201
|
+
var splitSpacedValue = (val) => {
|
|
1202
|
+
const addDefault = (v) => {
|
|
1203
|
+
const isSymbol = ["+", "-", "*", "/"].includes(v);
|
|
1204
|
+
const hasUnits = CSS_UNITS.some((unit) => val.includes(unit));
|
|
1205
|
+
if (isSymbol || hasUnits) return v;
|
|
1206
|
+
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
1207
|
+
if (isSingleLetter) return v + "_default";
|
|
1208
|
+
return v;
|
|
1209
|
+
};
|
|
1210
|
+
return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
|
|
1169
1211
|
};
|
|
1170
1212
|
|
|
1171
1213
|
// src/system/shadow.js
|
|
@@ -1313,30 +1355,23 @@ var splitTransition = (transition) => {
|
|
|
1313
1355
|
if (!arr.length) return;
|
|
1314
1356
|
return arr.map(transformTransition).join(",");
|
|
1315
1357
|
};
|
|
1316
|
-
var checkIfBoxSize = (propertyName) => {
|
|
1317
|
-
const prop = propertyName.toLowerCase();
|
|
1318
|
-
return (prop.includes("width") || prop.includes("height")) && !prop.includes("border");
|
|
1319
|
-
};
|
|
1320
1358
|
var transformSize = (propertyName, val, props = {}, opts = {}) => {
|
|
1321
1359
|
let value = val || props[propertyName];
|
|
1322
1360
|
if (isUndefined(value) && isNull(value)) return;
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
if (opts.ratio) {
|
|
1336
|
-
return getSpacingBasedOnRatio(props, propertyName, value);
|
|
1337
|
-
} else {
|
|
1338
|
-
return getSpacingByKey(value, propertyName);
|
|
1361
|
+
let fnPrefix;
|
|
1362
|
+
if (isString(value)) {
|
|
1363
|
+
if (value.includes("(")) {
|
|
1364
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1365
|
+
fnPrefix = fnArr[0];
|
|
1366
|
+
value = fnArr[1];
|
|
1367
|
+
}
|
|
1368
|
+
const shouldScaleBoxSize = props.scaleBoxSize;
|
|
1369
|
+
const isBoxSize = checkIfBoxSize(propertyName);
|
|
1370
|
+
if (!shouldScaleBoxSize && isBoxSize) {
|
|
1371
|
+
value = splitSpacedValue(value);
|
|
1372
|
+
}
|
|
1339
1373
|
}
|
|
1374
|
+
return opts.ratio ? getSpacingBasedOnRatio(props, propertyName, value, fnPrefix) : getSpacingByKey(value, propertyName, void 0, fnPrefix);
|
|
1340
1375
|
};
|
|
1341
1376
|
var transformSizeRatio = (propertyName, props) => {
|
|
1342
1377
|
return transformSize(propertyName, null, props, {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -311,6 +311,7 @@ var require_cjs = __commonJS({
|
|
|
311
311
|
// src/utils/index.js
|
|
312
312
|
var utils_exports = {};
|
|
313
313
|
__export(utils_exports, {
|
|
314
|
+
CSS_UNITS: () => CSS_UNITS,
|
|
314
315
|
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
315
316
|
applySequenceGlobalVars: () => applySequenceGlobalVars,
|
|
316
317
|
applySequenceVars: () => applySequenceVars,
|
|
@@ -325,6 +326,7 @@ __export(utils_exports, {
|
|
|
325
326
|
generateSubSequence: () => generateSubSequence,
|
|
326
327
|
getColorShade: () => getColorShade,
|
|
327
328
|
getDefaultOrFirstKey: () => getDefaultOrFirstKey,
|
|
329
|
+
getFnPrefixAndValue: () => getFnPrefixAndValue,
|
|
328
330
|
getFontFace: () => getFontFace,
|
|
329
331
|
getFontFaceEach: () => getFontFaceEach,
|
|
330
332
|
getFontFaceEachString: () => getFontFaceEachString,
|
|
@@ -332,6 +334,7 @@ __export(utils_exports, {
|
|
|
332
334
|
getFontFormat: () => getFontFormat,
|
|
333
335
|
getRgbTone: () => getRgbTone,
|
|
334
336
|
getSequenceValue: () => getSequenceValue,
|
|
337
|
+
getSequenceValueBySymbols: () => getSequenceValueBySymbols,
|
|
335
338
|
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
336
339
|
getSubratio: () => getSubratio,
|
|
337
340
|
getSubratioDifference: () => getSubratioDifference,
|
|
@@ -362,6 +365,58 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
362
365
|
var isScalingUnit = (unit) => {
|
|
363
366
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
364
367
|
};
|
|
368
|
+
var CSS_UNITS = [
|
|
369
|
+
// Absolute
|
|
370
|
+
"px",
|
|
371
|
+
"cm",
|
|
372
|
+
"mm",
|
|
373
|
+
"in",
|
|
374
|
+
"pt",
|
|
375
|
+
"pc",
|
|
376
|
+
// Font-relative
|
|
377
|
+
"em",
|
|
378
|
+
"rem",
|
|
379
|
+
"ex",
|
|
380
|
+
"cap",
|
|
381
|
+
"ch",
|
|
382
|
+
"ic",
|
|
383
|
+
"lh",
|
|
384
|
+
"rlh",
|
|
385
|
+
// Viewport-relative
|
|
386
|
+
"%",
|
|
387
|
+
"vw",
|
|
388
|
+
"vh",
|
|
389
|
+
"vmin",
|
|
390
|
+
"vmax",
|
|
391
|
+
"svw",
|
|
392
|
+
"svh",
|
|
393
|
+
"lvw",
|
|
394
|
+
"lvh",
|
|
395
|
+
"dvw",
|
|
396
|
+
"dvh",
|
|
397
|
+
// Container query units
|
|
398
|
+
"cqw",
|
|
399
|
+
"cqh",
|
|
400
|
+
"cqi",
|
|
401
|
+
"cqb",
|
|
402
|
+
"cqmin",
|
|
403
|
+
"cqmax",
|
|
404
|
+
// Angle
|
|
405
|
+
"deg",
|
|
406
|
+
"rad",
|
|
407
|
+
"grad",
|
|
408
|
+
"turn",
|
|
409
|
+
// Time
|
|
410
|
+
"s",
|
|
411
|
+
"ms",
|
|
412
|
+
// Resolution
|
|
413
|
+
"dpi",
|
|
414
|
+
"dpcm",
|
|
415
|
+
"dppx",
|
|
416
|
+
// Grid fractional
|
|
417
|
+
"fr",
|
|
418
|
+
"auto"
|
|
419
|
+
];
|
|
365
420
|
|
|
366
421
|
// ../../../domql/packages/utils/dist/esm/env.js
|
|
367
422
|
var NODE_ENV = "development";
|
|
@@ -943,6 +998,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
943
998
|
sequenceProps.scales[key] = scaling;
|
|
944
999
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
945
1000
|
};
|
|
1001
|
+
var getFnPrefixAndValue = (val) => {
|
|
1002
|
+
if (!val.includes("(")) return val;
|
|
1003
|
+
const prefix = val.split("(")[0];
|
|
1004
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
1005
|
+
return [prefix, value];
|
|
1006
|
+
};
|
|
946
1007
|
var setScalingVar = (key, sequenceProps) => {
|
|
947
1008
|
const { base, type, unit } = sequenceProps;
|
|
948
1009
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -1076,13 +1137,26 @@ var generateSequencePosition = (sequenceProps, position = 0) => {
|
|
|
1076
1137
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
1077
1138
|
const CONFIG2 = getActiveConfig();
|
|
1078
1139
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
1079
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
1080
1140
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
1081
|
-
const
|
|
1141
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
1082
1142
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
1083
1143
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
1084
|
-
|
|
1085
|
-
|
|
1144
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
1145
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
1146
|
+
const skipArr = [
|
|
1147
|
+
"none",
|
|
1148
|
+
"auto",
|
|
1149
|
+
"max-content",
|
|
1150
|
+
"min-content",
|
|
1151
|
+
"fit-content",
|
|
1152
|
+
"inherit",
|
|
1153
|
+
"initial",
|
|
1154
|
+
"unset",
|
|
1155
|
+
"revert",
|
|
1156
|
+
"revert-layer"
|
|
1157
|
+
];
|
|
1158
|
+
if (skipArr.includes(value)) return value;
|
|
1159
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
1086
1160
|
const letterVal = value.toUpperCase();
|
|
1087
1161
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
1088
1162
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -1124,14 +1198,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
1124
1198
|
}
|
|
1125
1199
|
return isNegative + sequenceItem.scaling + unit;
|
|
1126
1200
|
};
|
|
1127
|
-
var
|
|
1201
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
1202
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1203
|
+
(v) => value.includes(v + " ")
|
|
1204
|
+
);
|
|
1205
|
+
if (!mathArr.length) return value;
|
|
1206
|
+
return mathArr.map((symbol) => {
|
|
1207
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
1208
|
+
const transformedValues = valuesArr.map((v) => {
|
|
1209
|
+
return getSequenceValue(v, sequenceProps);
|
|
1210
|
+
});
|
|
1211
|
+
return transformedValues.join(symbol + " ");
|
|
1212
|
+
}).join("");
|
|
1213
|
+
};
|
|
1214
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
1128
1215
|
if (typeof value !== "string") {
|
|
1129
1216
|
const CONFIG2 = getActiveConfig();
|
|
1130
1217
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
1131
1218
|
return { [propertyName]: value };
|
|
1132
1219
|
}
|
|
1133
1220
|
if (value === "-" || value === "") return {};
|
|
1134
|
-
|
|
1221
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1222
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1223
|
+
fnPrefix = fnArr[0];
|
|
1224
|
+
value = fnArr[1];
|
|
1225
|
+
}
|
|
1226
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
1227
|
+
(v) => value.includes(v + " ")
|
|
1228
|
+
);
|
|
1229
|
+
if (mathArr.length) {
|
|
1230
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
1231
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
1232
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
1135
1233
|
};
|
|
1136
1234
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
1137
1235
|
var findHeadings = (propertyNames) => {
|