@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
|
@@ -312,8 +312,10 @@ var require_cjs = __commonJS({
|
|
|
312
312
|
var spacing_exports = {};
|
|
313
313
|
__export(spacing_exports, {
|
|
314
314
|
applySpacingSequence: () => applySpacingSequence,
|
|
315
|
+
checkIfBoxSize: () => checkIfBoxSize,
|
|
315
316
|
getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
|
|
316
|
-
getSpacingByKey: () => getSpacingByKey
|
|
317
|
+
getSpacingByKey: () => getSpacingByKey,
|
|
318
|
+
splitSpacedValue: () => splitSpacedValue
|
|
317
319
|
});
|
|
318
320
|
module.exports = __toCommonJS(spacing_exports);
|
|
319
321
|
var import_utils7 = __toESM(require_cjs(), 1);
|
|
@@ -691,6 +693,58 @@ var getActiveConfig = (def) => {
|
|
|
691
693
|
var isScalingUnit = (unit) => {
|
|
692
694
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
693
695
|
};
|
|
696
|
+
var CSS_UNITS = [
|
|
697
|
+
// Absolute
|
|
698
|
+
"px",
|
|
699
|
+
"cm",
|
|
700
|
+
"mm",
|
|
701
|
+
"in",
|
|
702
|
+
"pt",
|
|
703
|
+
"pc",
|
|
704
|
+
// Font-relative
|
|
705
|
+
"em",
|
|
706
|
+
"rem",
|
|
707
|
+
"ex",
|
|
708
|
+
"cap",
|
|
709
|
+
"ch",
|
|
710
|
+
"ic",
|
|
711
|
+
"lh",
|
|
712
|
+
"rlh",
|
|
713
|
+
// Viewport-relative
|
|
714
|
+
"%",
|
|
715
|
+
"vw",
|
|
716
|
+
"vh",
|
|
717
|
+
"vmin",
|
|
718
|
+
"vmax",
|
|
719
|
+
"svw",
|
|
720
|
+
"svh",
|
|
721
|
+
"lvw",
|
|
722
|
+
"lvh",
|
|
723
|
+
"dvw",
|
|
724
|
+
"dvh",
|
|
725
|
+
// Container query units
|
|
726
|
+
"cqw",
|
|
727
|
+
"cqh",
|
|
728
|
+
"cqi",
|
|
729
|
+
"cqb",
|
|
730
|
+
"cqmin",
|
|
731
|
+
"cqmax",
|
|
732
|
+
// Angle
|
|
733
|
+
"deg",
|
|
734
|
+
"rad",
|
|
735
|
+
"grad",
|
|
736
|
+
"turn",
|
|
737
|
+
// Time
|
|
738
|
+
"s",
|
|
739
|
+
"ms",
|
|
740
|
+
// Resolution
|
|
741
|
+
"dpi",
|
|
742
|
+
"dpcm",
|
|
743
|
+
"dppx",
|
|
744
|
+
// Grid fractional
|
|
745
|
+
"fr",
|
|
746
|
+
"auto"
|
|
747
|
+
];
|
|
694
748
|
|
|
695
749
|
// src/utils/sequence.js
|
|
696
750
|
var import_utils4 = __toESM(require_cjs(), 1);
|
|
@@ -736,6 +790,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
736
790
|
sequenceProps.scales[key] = scaling;
|
|
737
791
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
738
792
|
};
|
|
793
|
+
var getFnPrefixAndValue = (val) => {
|
|
794
|
+
if (!val.includes("(")) return val;
|
|
795
|
+
const prefix = val.split("(")[0];
|
|
796
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
797
|
+
return [prefix, value];
|
|
798
|
+
};
|
|
739
799
|
var setScalingVar = (key, sequenceProps) => {
|
|
740
800
|
const { base, type, unit } = sequenceProps;
|
|
741
801
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -831,13 +891,26 @@ var generateSequence = (sequenceProps) => {
|
|
|
831
891
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
832
892
|
const CONFIG2 = getActiveConfig();
|
|
833
893
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
834
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
835
894
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
836
|
-
const
|
|
895
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
837
896
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
838
897
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
839
|
-
|
|
840
|
-
|
|
898
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
899
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
900
|
+
const skipArr = [
|
|
901
|
+
"none",
|
|
902
|
+
"auto",
|
|
903
|
+
"max-content",
|
|
904
|
+
"min-content",
|
|
905
|
+
"fit-content",
|
|
906
|
+
"inherit",
|
|
907
|
+
"initial",
|
|
908
|
+
"unset",
|
|
909
|
+
"revert",
|
|
910
|
+
"revert-layer"
|
|
911
|
+
];
|
|
912
|
+
if (skipArr.includes(value)) return value;
|
|
913
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
841
914
|
const letterVal = value.toUpperCase();
|
|
842
915
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
843
916
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -879,14 +952,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
879
952
|
}
|
|
880
953
|
return isNegative + sequenceItem.scaling + unit;
|
|
881
954
|
};
|
|
882
|
-
var
|
|
955
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
956
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
957
|
+
(v) => value.includes(v + " ")
|
|
958
|
+
);
|
|
959
|
+
if (!mathArr.length) return value;
|
|
960
|
+
return mathArr.map((symbol) => {
|
|
961
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
962
|
+
const transformedValues = valuesArr.map((v) => {
|
|
963
|
+
return getSequenceValue(v, sequenceProps);
|
|
964
|
+
});
|
|
965
|
+
return transformedValues.join(symbol + " ");
|
|
966
|
+
}).join("");
|
|
967
|
+
};
|
|
968
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
883
969
|
if (typeof value !== "string") {
|
|
884
970
|
const CONFIG2 = getActiveConfig();
|
|
885
971
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
886
972
|
return { [propertyName]: value };
|
|
887
973
|
}
|
|
888
974
|
if (value === "-" || value === "") return {};
|
|
889
|
-
|
|
975
|
+
if (!fnPrefix && value.includes("(")) {
|
|
976
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
977
|
+
fnPrefix = fnArr[0];
|
|
978
|
+
value = fnArr[1];
|
|
979
|
+
}
|
|
980
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
981
|
+
(v) => value.includes(v + " ")
|
|
982
|
+
);
|
|
983
|
+
if (mathArr.length) {
|
|
984
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
985
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
986
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
890
987
|
};
|
|
891
988
|
|
|
892
989
|
// src/utils/var.js
|
|
@@ -964,15 +1061,7 @@ var runThroughMedia = (FACTORY2) => {
|
|
|
964
1061
|
const mediaProps = FACTORY2[prop];
|
|
965
1062
|
const isMediaName = prop.slice(0, 1) === "@";
|
|
966
1063
|
if (!isMediaName) continue;
|
|
967
|
-
const {
|
|
968
|
-
type,
|
|
969
|
-
base,
|
|
970
|
-
ratio,
|
|
971
|
-
range,
|
|
972
|
-
subSequence,
|
|
973
|
-
h1Matches,
|
|
974
|
-
unit
|
|
975
|
-
} = FACTORY2;
|
|
1064
|
+
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
|
|
976
1065
|
merge(mediaProps, {
|
|
977
1066
|
type,
|
|
978
1067
|
base,
|
|
@@ -990,6 +1079,12 @@ var runThroughMedia = (FACTORY2) => {
|
|
|
990
1079
|
applyMediaSequenceVars(FACTORY2, prop);
|
|
991
1080
|
}
|
|
992
1081
|
};
|
|
1082
|
+
var checkIfBoxSize = (propertyName) => {
|
|
1083
|
+
const prop = propertyName.toLowerCase();
|
|
1084
|
+
const includesWidth = prop.includes("width") || prop.includes("height");
|
|
1085
|
+
const includesBorder = prop.includes("border") || prop.includes("outline");
|
|
1086
|
+
return includesWidth && !includesBorder;
|
|
1087
|
+
};
|
|
993
1088
|
var applySpacingSequence = () => {
|
|
994
1089
|
const CONFIG2 = getActiveConfig();
|
|
995
1090
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
@@ -1004,12 +1099,16 @@ var getSequence = (sequenceProps) => {
|
|
|
1004
1099
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
1005
1100
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
|
|
1006
1101
|
};
|
|
1007
|
-
var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
1102
|
+
var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
1008
1103
|
const sequence = getSequence(sequenceProps);
|
|
1009
|
-
if (isString(value)
|
|
1010
|
-
|
|
1104
|
+
if (isString(value)) {
|
|
1105
|
+
if (!fnPrefix && value.includes("(")) {
|
|
1106
|
+
const fnArray = getFnPrefixAndValue(value);
|
|
1107
|
+
fnPrefix = fnArray[0];
|
|
1108
|
+
value = fnArray[1];
|
|
1109
|
+
}
|
|
1011
1110
|
}
|
|
1012
|
-
const stack = (0, import_utils7.arrayzeValue)(value);
|
|
1111
|
+
const stack = fnPrefix ? [value] : (0, import_utils7.arrayzeValue)(value);
|
|
1013
1112
|
if (!isArray(stack)) return;
|
|
1014
1113
|
if (stack.length > 1) {
|
|
1015
1114
|
let suffix = "";
|
|
@@ -1025,44 +1124,39 @@ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
|
|
|
1025
1124
|
const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
|
|
1026
1125
|
stack[i],
|
|
1027
1126
|
propertyName + direction + suffix,
|
|
1028
|
-
sequence
|
|
1127
|
+
sequence,
|
|
1128
|
+
fnPrefix
|
|
1129
|
+
);
|
|
1130
|
+
return directions[stack.length].map(
|
|
1131
|
+
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
1029
1132
|
);
|
|
1030
|
-
return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
|
|
1031
1133
|
}
|
|
1032
|
-
return getSequenceValuePropertyPair(
|
|
1033
|
-
value,
|
|
1034
|
-
propertyName,
|
|
1035
|
-
sequence
|
|
1036
|
-
);
|
|
1134
|
+
return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
|
|
1037
1135
|
};
|
|
1038
|
-
var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
1136
|
+
var getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
1039
1137
|
const CONFIG2 = getActiveConfig();
|
|
1040
1138
|
const { SPACING: SPACING2 } = CONFIG2;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
const { type, base, range, subSequence } = SPACING2;
|
|
1047
|
-
sequenceProps = SPACING2[spacingRatio] = merge({
|
|
1048
|
-
ratio: spacingRatio,
|
|
1049
|
-
type: type + "-" + spacingRatio,
|
|
1050
|
-
unit,
|
|
1051
|
-
sequence: {},
|
|
1052
|
-
scales: {},
|
|
1053
|
-
templates: {},
|
|
1054
|
-
vars: {}
|
|
1055
|
-
}, {
|
|
1056
|
-
base,
|
|
1057
|
-
range,
|
|
1058
|
-
subSequence,
|
|
1059
|
-
ratio: SPACING2.ratio,
|
|
1060
|
-
unit: SPACING2.unit
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
applySequenceVars(sequenceProps, { useDefault: false });
|
|
1064
|
-
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
1139
|
+
let value = val || props[propertyName];
|
|
1140
|
+
if (!fnPrefix && isString(value) && value.includes("(")) {
|
|
1141
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
1142
|
+
fnPrefix = fnArr[0];
|
|
1143
|
+
value = fnArr[1];
|
|
1065
1144
|
}
|
|
1066
|
-
|
|
1145
|
+
if (props.spacingRatio) {
|
|
1146
|
+
const sequenceProps = applyCustomSequence(props);
|
|
1147
|
+
return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
|
|
1148
|
+
}
|
|
1149
|
+
return getSpacingByKey(value, propertyName, SPACING2, fnPrefix);
|
|
1150
|
+
};
|
|
1151
|
+
var splitSpacedValue = (val) => {
|
|
1152
|
+
const addDefault = (v) => {
|
|
1153
|
+
const isSymbol = ["+", "-", "*", "/"].includes(v);
|
|
1154
|
+
const hasUnits = CSS_UNITS.some((unit) => val.includes(unit));
|
|
1155
|
+
if (isSymbol || hasUnits) return v;
|
|
1156
|
+
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
1157
|
+
if (isSingleLetter) return v + "_default";
|
|
1158
|
+
return v;
|
|
1159
|
+
};
|
|
1160
|
+
return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
|
|
1067
1161
|
};
|
|
1068
1162
|
// @preserve-env
|
|
@@ -678,6 +678,58 @@ var getActiveConfig = (def) => {
|
|
|
678
678
|
var isScalingUnit = (unit) => {
|
|
679
679
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
680
680
|
};
|
|
681
|
+
var CSS_UNITS = [
|
|
682
|
+
// Absolute
|
|
683
|
+
"px",
|
|
684
|
+
"cm",
|
|
685
|
+
"mm",
|
|
686
|
+
"in",
|
|
687
|
+
"pt",
|
|
688
|
+
"pc",
|
|
689
|
+
// Font-relative
|
|
690
|
+
"em",
|
|
691
|
+
"rem",
|
|
692
|
+
"ex",
|
|
693
|
+
"cap",
|
|
694
|
+
"ch",
|
|
695
|
+
"ic",
|
|
696
|
+
"lh",
|
|
697
|
+
"rlh",
|
|
698
|
+
// Viewport-relative
|
|
699
|
+
"%",
|
|
700
|
+
"vw",
|
|
701
|
+
"vh",
|
|
702
|
+
"vmin",
|
|
703
|
+
"vmax",
|
|
704
|
+
"svw",
|
|
705
|
+
"svh",
|
|
706
|
+
"lvw",
|
|
707
|
+
"lvh",
|
|
708
|
+
"dvw",
|
|
709
|
+
"dvh",
|
|
710
|
+
// Container query units
|
|
711
|
+
"cqw",
|
|
712
|
+
"cqh",
|
|
713
|
+
"cqi",
|
|
714
|
+
"cqb",
|
|
715
|
+
"cqmin",
|
|
716
|
+
"cqmax",
|
|
717
|
+
// Angle
|
|
718
|
+
"deg",
|
|
719
|
+
"rad",
|
|
720
|
+
"grad",
|
|
721
|
+
"turn",
|
|
722
|
+
// Time
|
|
723
|
+
"s",
|
|
724
|
+
"ms",
|
|
725
|
+
// Resolution
|
|
726
|
+
"dpi",
|
|
727
|
+
"dpcm",
|
|
728
|
+
"dppx",
|
|
729
|
+
// Grid fractional
|
|
730
|
+
"fr",
|
|
731
|
+
"auto"
|
|
732
|
+
];
|
|
681
733
|
|
|
682
734
|
// src/utils/sequence.js
|
|
683
735
|
var import_utils4 = __toESM(require_cjs(), 1);
|
|
@@ -723,6 +775,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
723
775
|
sequenceProps.scales[key] = scaling;
|
|
724
776
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
725
777
|
};
|
|
778
|
+
var getFnPrefixAndValue = (val) => {
|
|
779
|
+
if (!val.includes("(")) return val;
|
|
780
|
+
const prefix = val.split("(")[0];
|
|
781
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
782
|
+
return [prefix, value];
|
|
783
|
+
};
|
|
726
784
|
var setScalingVar = (key, sequenceProps) => {
|
|
727
785
|
const { base, type, unit } = sequenceProps;
|
|
728
786
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -818,13 +876,26 @@ var generateSequence = (sequenceProps) => {
|
|
|
818
876
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
819
877
|
const CONFIG2 = getActiveConfig();
|
|
820
878
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
821
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
822
879
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
823
|
-
const
|
|
880
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
824
881
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
825
882
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
826
|
-
|
|
827
|
-
|
|
883
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
884
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
885
|
+
const skipArr = [
|
|
886
|
+
"none",
|
|
887
|
+
"auto",
|
|
888
|
+
"max-content",
|
|
889
|
+
"min-content",
|
|
890
|
+
"fit-content",
|
|
891
|
+
"inherit",
|
|
892
|
+
"initial",
|
|
893
|
+
"unset",
|
|
894
|
+
"revert",
|
|
895
|
+
"revert-layer"
|
|
896
|
+
];
|
|
897
|
+
if (skipArr.includes(value)) return value;
|
|
898
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
828
899
|
const letterVal = value.toUpperCase();
|
|
829
900
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
830
901
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -866,14 +937,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
866
937
|
}
|
|
867
938
|
return isNegative + sequenceItem.scaling + unit;
|
|
868
939
|
};
|
|
869
|
-
var
|
|
940
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
941
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
942
|
+
(v) => value.includes(v + " ")
|
|
943
|
+
);
|
|
944
|
+
if (!mathArr.length) return value;
|
|
945
|
+
return mathArr.map((symbol) => {
|
|
946
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
947
|
+
const transformedValues = valuesArr.map((v) => {
|
|
948
|
+
return getSequenceValue(v, sequenceProps);
|
|
949
|
+
});
|
|
950
|
+
return transformedValues.join(symbol + " ");
|
|
951
|
+
}).join("");
|
|
952
|
+
};
|
|
953
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
870
954
|
if (typeof value !== "string") {
|
|
871
955
|
const CONFIG2 = getActiveConfig();
|
|
872
956
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
873
957
|
return { [propertyName]: value };
|
|
874
958
|
}
|
|
875
959
|
if (value === "-" || value === "") return {};
|
|
876
|
-
|
|
960
|
+
if (!fnPrefix && value.includes("(")) {
|
|
961
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
962
|
+
fnPrefix = fnArr[0];
|
|
963
|
+
value = fnArr[1];
|
|
964
|
+
}
|
|
965
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
966
|
+
(v) => value.includes(v + " ")
|
|
967
|
+
);
|
|
968
|
+
if (mathArr.length) {
|
|
969
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
970
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
971
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
877
972
|
};
|
|
878
973
|
|
|
879
974
|
// src/utils/var.js
|
|
@@ -691,6 +691,58 @@ var getActiveConfig = (def) => {
|
|
|
691
691
|
var isScalingUnit = (unit) => {
|
|
692
692
|
return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
|
|
693
693
|
};
|
|
694
|
+
var CSS_UNITS = [
|
|
695
|
+
// Absolute
|
|
696
|
+
"px",
|
|
697
|
+
"cm",
|
|
698
|
+
"mm",
|
|
699
|
+
"in",
|
|
700
|
+
"pt",
|
|
701
|
+
"pc",
|
|
702
|
+
// Font-relative
|
|
703
|
+
"em",
|
|
704
|
+
"rem",
|
|
705
|
+
"ex",
|
|
706
|
+
"cap",
|
|
707
|
+
"ch",
|
|
708
|
+
"ic",
|
|
709
|
+
"lh",
|
|
710
|
+
"rlh",
|
|
711
|
+
// Viewport-relative
|
|
712
|
+
"%",
|
|
713
|
+
"vw",
|
|
714
|
+
"vh",
|
|
715
|
+
"vmin",
|
|
716
|
+
"vmax",
|
|
717
|
+
"svw",
|
|
718
|
+
"svh",
|
|
719
|
+
"lvw",
|
|
720
|
+
"lvh",
|
|
721
|
+
"dvw",
|
|
722
|
+
"dvh",
|
|
723
|
+
// Container query units
|
|
724
|
+
"cqw",
|
|
725
|
+
"cqh",
|
|
726
|
+
"cqi",
|
|
727
|
+
"cqb",
|
|
728
|
+
"cqmin",
|
|
729
|
+
"cqmax",
|
|
730
|
+
// Angle
|
|
731
|
+
"deg",
|
|
732
|
+
"rad",
|
|
733
|
+
"grad",
|
|
734
|
+
"turn",
|
|
735
|
+
// Time
|
|
736
|
+
"s",
|
|
737
|
+
"ms",
|
|
738
|
+
// Resolution
|
|
739
|
+
"dpi",
|
|
740
|
+
"dpcm",
|
|
741
|
+
"dppx",
|
|
742
|
+
// Grid fractional
|
|
743
|
+
"fr",
|
|
744
|
+
"auto"
|
|
745
|
+
];
|
|
694
746
|
|
|
695
747
|
// src/utils/sequence.js
|
|
696
748
|
var import_utils4 = __toESM(require_cjs(), 1);
|
|
@@ -736,6 +788,12 @@ var setSequenceValue = (props, sequenceProps) => {
|
|
|
736
788
|
sequenceProps.scales[key] = scaling;
|
|
737
789
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
738
790
|
};
|
|
791
|
+
var getFnPrefixAndValue = (val) => {
|
|
792
|
+
if (!val.includes("(")) return val;
|
|
793
|
+
const prefix = val.split("(")[0];
|
|
794
|
+
const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
|
|
795
|
+
return [prefix, value];
|
|
796
|
+
};
|
|
739
797
|
var setScalingVar = (key, sequenceProps) => {
|
|
740
798
|
const { base, type, unit } = sequenceProps;
|
|
741
799
|
const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
|
|
@@ -831,13 +889,26 @@ var generateSequence = (sequenceProps) => {
|
|
|
831
889
|
var getSequenceValue = (value = "A", sequenceProps) => {
|
|
832
890
|
const CONFIG2 = getActiveConfig();
|
|
833
891
|
const { UNIT: UNIT2 } = CONFIG2;
|
|
834
|
-
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
835
892
|
if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
|
|
836
|
-
const
|
|
893
|
+
const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
|
|
837
894
|
const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
|
|
838
895
|
const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
|
|
839
|
-
|
|
840
|
-
|
|
896
|
+
const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
|
|
897
|
+
if (hasUnits || !startsWithDashOrLetter) return value;
|
|
898
|
+
const skipArr = [
|
|
899
|
+
"none",
|
|
900
|
+
"auto",
|
|
901
|
+
"max-content",
|
|
902
|
+
"min-content",
|
|
903
|
+
"fit-content",
|
|
904
|
+
"inherit",
|
|
905
|
+
"initial",
|
|
906
|
+
"unset",
|
|
907
|
+
"revert",
|
|
908
|
+
"revert-layer"
|
|
909
|
+
];
|
|
910
|
+
if (skipArr.includes(value)) return value;
|
|
911
|
+
const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
|
|
841
912
|
const letterVal = value.toUpperCase();
|
|
842
913
|
const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
|
|
843
914
|
let absValue = isNegative ? letterVal.slice(1) : letterVal;
|
|
@@ -879,14 +950,38 @@ var getSequenceValue = (value = "A", sequenceProps) => {
|
|
|
879
950
|
}
|
|
880
951
|
return isNegative + sequenceItem.scaling + unit;
|
|
881
952
|
};
|
|
882
|
-
var
|
|
953
|
+
var getSequenceValueBySymbols = (value, sequenceProps) => {
|
|
954
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
955
|
+
(v) => value.includes(v + " ")
|
|
956
|
+
);
|
|
957
|
+
if (!mathArr.length) return value;
|
|
958
|
+
return mathArr.map((symbol) => {
|
|
959
|
+
const valuesArr = value.split(symbol + " ").map((v) => v.trim());
|
|
960
|
+
const transformedValues = valuesArr.map((v) => {
|
|
961
|
+
return getSequenceValue(v, sequenceProps);
|
|
962
|
+
});
|
|
963
|
+
return transformedValues.join(symbol + " ");
|
|
964
|
+
}).join("");
|
|
965
|
+
};
|
|
966
|
+
var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
|
|
883
967
|
if (typeof value !== "string") {
|
|
884
968
|
const CONFIG2 = getActiveConfig();
|
|
885
969
|
if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
|
|
886
970
|
return { [propertyName]: value };
|
|
887
971
|
}
|
|
888
972
|
if (value === "-" || value === "") return {};
|
|
889
|
-
|
|
973
|
+
if (!fnPrefix && value.includes("(")) {
|
|
974
|
+
const fnArr = getFnPrefixAndValue(value);
|
|
975
|
+
fnPrefix = fnArr[0];
|
|
976
|
+
value = fnArr[1];
|
|
977
|
+
}
|
|
978
|
+
const mathArr = ["+", "-", "*", "/", ","].filter(
|
|
979
|
+
(v) => value.includes(v + " ")
|
|
980
|
+
);
|
|
981
|
+
if (mathArr.length) {
|
|
982
|
+
value = getSequenceValueBySymbols(value, sequenceProps);
|
|
983
|
+
} else value = getSequenceValue(value, sequenceProps);
|
|
984
|
+
return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
|
|
890
985
|
};
|
|
891
986
|
var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
|
|
892
987
|
var findHeadings = (propertyNames) => {
|