@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.
- package/README.md +2 -2
- package/dist/cjs/defaultConfig/class.js +1 -2
- package/dist/cjs/defaultConfig/font-family.js +6 -6
- package/dist/cjs/defaultConfig/icons.js +2 -2
- package/dist/cjs/defaultConfig/svg.js +2 -2
- package/dist/cjs/defaultConfig/timing.js +1 -1
- package/dist/cjs/factory.js +72 -12
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/set.js +113 -52
- package/dist/cjs/system/color.js +72 -12
- package/dist/cjs/system/document.js +3 -3
- package/dist/cjs/system/font.js +14 -14
- package/dist/cjs/system/reset.js +34 -7
- package/dist/cjs/system/shadow.js +4 -3
- package/dist/cjs/system/spacing.js +18 -18
- package/dist/cjs/system/svg.js +34 -7
- package/dist/cjs/system/theme.js +51 -50
- package/dist/cjs/system/timing.js +6 -6
- package/dist/cjs/system/typography.js +12 -3
- package/dist/cjs/transforms/index.js +4 -4
- package/dist/cjs/utils/color.js +1 -1
- package/dist/cjs/utils/font.js +3 -1
- package/dist/cjs/utils/sequence.js +35 -16
- package/dist/cjs/utils/sprite.js +11 -4
- package/dist/cjs/utils/var.js +23 -9
- package/dist/esm/defaultConfig/class.js +1 -2
- package/dist/esm/defaultConfig/font-family.js +6 -6
- package/dist/esm/defaultConfig/icons.js +2 -2
- package/dist/esm/defaultConfig/svg.js +2 -2
- package/dist/esm/defaultConfig/timing.js +1 -1
- package/dist/esm/factory.js +72 -12
- package/dist/esm/index.js +6 -4
- package/dist/esm/set.js +114 -53
- package/dist/esm/system/color.js +72 -12
- package/dist/esm/system/document.js +3 -3
- package/dist/esm/system/font.js +5 -5
- package/dist/esm/system/reset.js +34 -7
- package/dist/esm/system/shadow.js +4 -3
- package/dist/esm/system/spacing.js +3 -3
- package/dist/esm/system/svg.js +34 -7
- package/dist/esm/system/theme.js +51 -50
- package/dist/esm/system/timing.js +2 -2
- package/dist/esm/system/typography.js +12 -3
- package/dist/esm/transforms/index.js +4 -4
- package/dist/esm/utils/color.js +1 -1
- package/dist/esm/utils/font.js +3 -1
- package/dist/esm/utils/sequence.js +35 -16
- package/dist/esm/utils/sprite.js +11 -4
- package/dist/esm/utils/var.js +23 -9
- package/dist/iife/index.js +728 -302
- package/index.js +1 -0
- package/package.json +11 -14
- package/src/defaultConfig/class.js +2 -1
- package/src/defaultConfig/font-family.js +3 -3
- package/src/defaultConfig/icons.js +1 -1
- package/src/defaultConfig/svg.js +1 -1
- package/src/defaultConfig/timing.js +1 -1
- package/src/factory.js +85 -13
- package/src/index.js +16 -5
- package/src/set.js +156 -63
- package/src/system/color.js +113 -12
- package/src/system/document.js +3 -3
- package/src/system/font.js +5 -5
- package/src/system/reset.js +41 -8
- package/src/system/shadow.js +4 -3
- package/src/system/spacing.js +3 -3
- package/src/system/svg.js +44 -7
- package/src/system/theme.js +87 -64
- package/src/system/timing.js +2 -2
- package/src/system/typography.js +12 -3
- package/src/transforms/index.js +4 -4
- package/src/utils/color.js +2 -1
- package/src/utils/font.js +7 -1
- package/src/utils/sequence.js +46 -29
- package/src/utils/sprite.js +15 -4
- package/src/utils/var.js +27 -9
package/dist/cjs/system/font.js
CHANGED
|
@@ -23,30 +23,30 @@ __export(font_exports, {
|
|
|
23
23
|
setFontFamily: () => setFontFamily
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(font_exports);
|
|
26
|
-
var import_utils = require("@
|
|
27
|
-
var
|
|
26
|
+
var import_utils = require("@symbo.ls/utils");
|
|
27
|
+
var import_utils2 = require("@symbo.ls/utils");
|
|
28
28
|
var import_factory = require("../factory.js");
|
|
29
|
-
var
|
|
29
|
+
var import_utils3 = require("../utils/index.js");
|
|
30
30
|
const setFont = (val, key) => {
|
|
31
31
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
32
32
|
const CSSvar = `--font-${key}`;
|
|
33
33
|
if (!val || (0, import_utils.isArray)(val) && !val[0]) return;
|
|
34
34
|
let fontFace;
|
|
35
35
|
if (val.isVariable) {
|
|
36
|
-
const url = (0,
|
|
37
|
-
if ((0,
|
|
38
|
-
fontFace = (0,
|
|
36
|
+
const url = (0, import_utils3.resolveFileUrl)(val.url, CONFIG.files) || val.url;
|
|
37
|
+
if ((0, import_utils3.isGoogleFontsUrl)(url)) {
|
|
38
|
+
fontFace = (0, import_utils3.setFontImport)(url);
|
|
39
39
|
} else {
|
|
40
|
-
fontFace = (0,
|
|
40
|
+
fontFace = (0, import_utils3.setCustomFontMedia)(key, url, val.fontWeight, {
|
|
41
41
|
fontStretch: val.fontStretch,
|
|
42
42
|
fontDisplay: val.fontDisplay || "swap"
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
} else if (val[0]) {
|
|
46
|
-
fontFace = (0,
|
|
46
|
+
fontFace = (0, import_utils3.getFontFaceEach)(key, val, CONFIG.files);
|
|
47
47
|
} else {
|
|
48
|
-
const url = Array.isArray(val.url) ? val.url.map((u) => (0,
|
|
49
|
-
fontFace = (0,
|
|
48
|
+
const url = Array.isArray(val.url) ? val.url.map((u) => (0, import_utils3.resolveFileUrl)(u, CONFIG.files) || u) : (0, import_utils3.resolveFileUrl)(val.url, CONFIG.files) || val.url;
|
|
49
|
+
fontFace = (0, import_utils3.setCustomFontMedia)(key, url, val.fontWeight, {
|
|
50
50
|
fontStyle: val.fontStyle,
|
|
51
51
|
fontDisplay: val.fontDisplay,
|
|
52
52
|
fontStretch: val.fontStretch
|
|
@@ -56,15 +56,15 @@ const setFont = (val, key) => {
|
|
|
56
56
|
};
|
|
57
57
|
const getFontFamily = (key, factory) => {
|
|
58
58
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
59
|
-
const {
|
|
60
|
-
return (0,
|
|
59
|
+
const { fontFamily: FONT_FAMILY } = CONFIG;
|
|
60
|
+
return (0, import_utils3.getDefaultOrFirstKey)(factory || FONT_FAMILY, key);
|
|
61
61
|
};
|
|
62
62
|
const setFontFamily = (val, key) => {
|
|
63
63
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
64
|
-
const {
|
|
64
|
+
const { fontFamily: FONT_FAMILY, fontFamilyTypes: FONT_FAMILY_TYPES } = CONFIG;
|
|
65
65
|
let { value, type } = val;
|
|
66
66
|
if (val.isDefault) FONT_FAMILY.default = key;
|
|
67
|
-
if ((0, import_utils.isObject)(value)) value = (0,
|
|
67
|
+
if ((0, import_utils.isObject)(value)) value = (0, import_utils2.arrayzeValue)(value);
|
|
68
68
|
const CSSvar = `--font-family-${key}`;
|
|
69
69
|
const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
|
|
70
70
|
return { var: CSSvar, value: str, arr: value, type };
|
package/dist/cjs/system/reset.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(reset_exports, {
|
|
|
21
21
|
applyReset: () => applyReset
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(reset_exports);
|
|
24
|
-
var import_utils = require("@
|
|
24
|
+
var import_utils = require("@symbo.ls/utils");
|
|
25
25
|
var import_factory = require("../factory.js");
|
|
26
26
|
var import_theme = require("./theme.js");
|
|
27
27
|
const applyReset = (reset = {}) => {
|
|
@@ -45,10 +45,28 @@ const applyReset = (reset = {}) => {
|
|
|
45
45
|
const { body, ...templates } = TYPOGRAPHY.templates;
|
|
46
46
|
const globalTheme = CONFIG.useDocumentTheme ? (0, import_theme.getMediaTheme)("document") : {};
|
|
47
47
|
if (RESET.html) (0, import_utils.overwriteDeep)(RESET.html, globalTheme);
|
|
48
|
+
if (TYPOGRAPHY.unit) {
|
|
49
|
+
const { media: MEDIA } = CONFIG;
|
|
50
|
+
for (const key in TYPOGRAPHY) {
|
|
51
|
+
if (key.charAt(0) !== "@") continue;
|
|
52
|
+
const mediaTypo = TYPOGRAPHY[key];
|
|
53
|
+
if (!mediaTypo) continue;
|
|
54
|
+
if (mediaTypo.unit === TYPOGRAPHY.unit || !mediaTypo.unit) continue;
|
|
55
|
+
const mediaUnit = mediaTypo.unit;
|
|
56
|
+
const mediaBase = mediaTypo.base || TYPOGRAPHY.base;
|
|
57
|
+
const mediaBrowserDefault = mediaTypo.browserDefault || TYPOGRAPHY.browserDefault;
|
|
58
|
+
const mediaName = key.slice(1);
|
|
59
|
+
const query = MEDIA[mediaName];
|
|
60
|
+
if (!query) continue;
|
|
61
|
+
const mediaKey = "@media " + (query === "print" ? query : "screen and " + query);
|
|
62
|
+
if (!RESET[mediaKey]) RESET[mediaKey] = {};
|
|
63
|
+
if (!RESET[mediaKey].html) RESET[mediaKey].html = {};
|
|
64
|
+
RESET[mediaKey].html.fontSize = mediaBase / mediaBrowserDefault + mediaUnit;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
48
67
|
return (0, import_utils.deepMerge)((0, import_utils.merge)(RESET, reset), {
|
|
49
68
|
html: {
|
|
50
69
|
position: "absolute",
|
|
51
|
-
// overflow: 'hidden',
|
|
52
70
|
width: "100%",
|
|
53
71
|
height: "100%",
|
|
54
72
|
top: "0",
|
|
@@ -57,7 +75,7 @@ const applyReset = (reset = {}) => {
|
|
|
57
75
|
WebkitFontSmoothing: "subpixel-antialiased",
|
|
58
76
|
scrollBehavior: "smooth",
|
|
59
77
|
...globalTheme,
|
|
60
|
-
fontSize: TYPOGRAPHY.browserDefault + "px",
|
|
78
|
+
fontSize: TYPOGRAPHY.unit ? TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + TYPOGRAPHY.unit : TYPOGRAPHY.browserDefault + "px",
|
|
61
79
|
fontFamily: DOCUMENT.fontFamily,
|
|
62
80
|
lineHeight: DOCUMENT.lineHeight
|
|
63
81
|
},
|
|
@@ -73,14 +91,23 @@ const applyReset = (reset = {}) => {
|
|
|
73
91
|
a: {
|
|
74
92
|
color: "currentColor"
|
|
75
93
|
},
|
|
76
|
-
|
|
94
|
+
button: {
|
|
95
|
+
color: "inherit",
|
|
96
|
+
font: "inherit",
|
|
97
|
+
background: "transparent",
|
|
98
|
+
border: "none",
|
|
99
|
+
cursor: "pointer",
|
|
100
|
+
appearance: "none",
|
|
101
|
+
WebkitAppearance: "none"
|
|
102
|
+
},
|
|
103
|
+
"input, select, textarea": {
|
|
104
|
+
color: "inherit",
|
|
105
|
+
font: "inherit"
|
|
106
|
+
},
|
|
77
107
|
fieldset: {
|
|
78
108
|
border: 0,
|
|
79
109
|
padding: 0,
|
|
80
110
|
margin: 0
|
|
81
|
-
},
|
|
82
|
-
"select, input": {
|
|
83
|
-
fontFamily: DOCUMENT.fontFamily
|
|
84
111
|
}
|
|
85
112
|
});
|
|
86
113
|
}
|
|
@@ -26,7 +26,7 @@ var import_factory = require("../factory.js");
|
|
|
26
26
|
var import_color = require("./color.js");
|
|
27
27
|
var import_spacing = require("./spacing.js");
|
|
28
28
|
var import_color2 = require("../utils/color.js");
|
|
29
|
-
var import_utils = require("@
|
|
29
|
+
var import_utils = require("@symbo.ls/utils");
|
|
30
30
|
const setShadow = (value, key, suffix, prefers) => {
|
|
31
31
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
32
32
|
if ((0, import_utils.isArray)(value)) {
|
|
@@ -63,9 +63,10 @@ const setShadow = (value, key, suffix, prefers) => {
|
|
|
63
63
|
}).join(" ");
|
|
64
64
|
}).join(", ");
|
|
65
65
|
}
|
|
66
|
-
const
|
|
66
|
+
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
67
|
+
const CSSVar = `--${vp}shadow-${key}` + (suffix ? `-${suffix}` : "");
|
|
67
68
|
if (CONFIG.useVariable) {
|
|
68
|
-
CONFIG.
|
|
69
|
+
CONFIG.cssVars[CSSVar] = value;
|
|
69
70
|
}
|
|
70
71
|
return {
|
|
71
72
|
var: CSSVar,
|
|
@@ -25,17 +25,17 @@ __export(spacing_exports, {
|
|
|
25
25
|
splitSpacedValue: () => splitSpacedValue
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(spacing_exports);
|
|
28
|
-
var
|
|
29
|
-
var
|
|
28
|
+
var import_utils = require("@symbo.ls/utils");
|
|
29
|
+
var import_utils2 = require("@symbo.ls/utils");
|
|
30
30
|
var import_factory = require("../factory.js");
|
|
31
|
-
var
|
|
31
|
+
var import_utils3 = require("../utils/index.js");
|
|
32
32
|
const runThroughMedia = (FACTORY) => {
|
|
33
33
|
for (const prop in FACTORY) {
|
|
34
34
|
const mediaProps = FACTORY[prop];
|
|
35
35
|
const isMediaName = prop.slice(0, 1) === "@";
|
|
36
36
|
if (!isMediaName) continue;
|
|
37
37
|
const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
|
|
38
|
-
(0,
|
|
38
|
+
(0, import_utils2.merge)(mediaProps, {
|
|
39
39
|
type,
|
|
40
40
|
base,
|
|
41
41
|
ratio,
|
|
@@ -48,8 +48,8 @@ const runThroughMedia = (FACTORY) => {
|
|
|
48
48
|
templates: {},
|
|
49
49
|
vars: {}
|
|
50
50
|
});
|
|
51
|
-
(0,
|
|
52
|
-
(0,
|
|
51
|
+
(0, import_utils3.generateSequence)(mediaProps);
|
|
52
|
+
(0, import_utils3.applyMediaSequenceVars)(FACTORY, prop);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
const checkIfBoxSize = (propertyName) => {
|
|
@@ -61,8 +61,8 @@ const checkIfBoxSize = (propertyName) => {
|
|
|
61
61
|
const applySpacingSequence = () => {
|
|
62
62
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
63
63
|
const { spacing: SPACING } = CONFIG;
|
|
64
|
-
(0,
|
|
65
|
-
(0,
|
|
64
|
+
(0, import_utils3.generateSequence)(SPACING);
|
|
65
|
+
(0, import_utils3.applySequenceVars)(SPACING);
|
|
66
66
|
runThroughMedia(SPACING);
|
|
67
67
|
};
|
|
68
68
|
const getSequence = (sequenceProps) => {
|
|
@@ -70,19 +70,19 @@ const getSequence = (sequenceProps) => {
|
|
|
70
70
|
const { spacing: SPACING } = CONFIG;
|
|
71
71
|
if (!sequenceProps || !sequenceProps.sequence) return SPACING;
|
|
72
72
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
|
|
73
|
-
return hasGenerated ? sequenceProps : (0,
|
|
73
|
+
return hasGenerated ? sequenceProps : (0, import_utils3.generateSequence)(sequenceProps);
|
|
74
74
|
};
|
|
75
75
|
const getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
|
|
76
76
|
const sequence = getSequence(sequenceProps);
|
|
77
|
-
if ((0,
|
|
77
|
+
if ((0, import_utils2.isString)(value)) {
|
|
78
78
|
if (!fnPrefix && value.includes("(")) {
|
|
79
|
-
const fnArray = (0,
|
|
79
|
+
const fnArray = (0, import_utils3.getFnPrefixAndValue)(value);
|
|
80
80
|
fnPrefix = fnArray[0];
|
|
81
81
|
value = fnArray[1];
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
const stack = fnPrefix ? [value] : (0,
|
|
85
|
-
if (!(0,
|
|
84
|
+
const stack = fnPrefix ? [value] : (0, import_utils.arrayzeValue)(value);
|
|
85
|
+
if (!(0, import_utils2.isArray)(stack)) return;
|
|
86
86
|
if (stack.length > 1) {
|
|
87
87
|
let suffix = "";
|
|
88
88
|
if (propertyName === "borderWidth") {
|
|
@@ -94,7 +94,7 @@ const getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefi
|
|
|
94
94
|
3: ["BlockStart", "Inline", "BlockEnd"],
|
|
95
95
|
4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
|
|
96
96
|
};
|
|
97
|
-
const wrapSequenceValueByDirection = (direction, i) => (0,
|
|
97
|
+
const wrapSequenceValueByDirection = (direction, i) => (0, import_utils3.getSequenceValuePropertyPair)(
|
|
98
98
|
stack[i],
|
|
99
99
|
propertyName + direction + suffix,
|
|
100
100
|
sequence,
|
|
@@ -104,14 +104,14 @@ const getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefi
|
|
|
104
104
|
(dir, key) => wrapSequenceValueByDirection(dir, key)
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
|
-
return (0,
|
|
107
|
+
return (0, import_utils3.getSequenceValuePropertyPair)(value, propertyName, sequence, fnPrefix);
|
|
108
108
|
};
|
|
109
109
|
const getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
110
110
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
111
111
|
const { spacing: SPACING } = CONFIG;
|
|
112
112
|
let value = val || props[propertyName];
|
|
113
|
-
if (!fnPrefix && (0,
|
|
114
|
-
const fnArr = (0,
|
|
113
|
+
if (!fnPrefix && (0, import_utils2.isString)(value) && value.includes("(")) {
|
|
114
|
+
const fnArr = (0, import_utils3.getFnPrefixAndValue)(value);
|
|
115
115
|
fnPrefix = fnArr[0];
|
|
116
116
|
value = fnArr[1];
|
|
117
117
|
}
|
|
@@ -124,7 +124,7 @@ const getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
|
|
|
124
124
|
const splitSpacedValue = (val) => {
|
|
125
125
|
const addDefault = (v) => {
|
|
126
126
|
const isSymbol = ["+", "-", "*", "/"].includes(v);
|
|
127
|
-
const hasUnits =
|
|
127
|
+
const hasUnits = import_utils3.CSS_UNITS.some((unit) => val.includes(unit));
|
|
128
128
|
if (isSymbol || hasUnits) return v;
|
|
129
129
|
const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
|
|
130
130
|
if (isSingleLetter) return v + "_default";
|
package/dist/cjs/system/svg.js
CHANGED
|
@@ -24,8 +24,8 @@ __export(svg_exports, {
|
|
|
24
24
|
setSvgIcon: () => setSvgIcon
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(svg_exports);
|
|
27
|
-
var import_utils = require("@
|
|
28
|
-
var import_utils2 = require("../utils");
|
|
27
|
+
var import_utils = require("@symbo.ls/utils");
|
|
28
|
+
var import_utils2 = require("../utils/index.js");
|
|
29
29
|
var import_factory = require("../factory.js");
|
|
30
30
|
const DEF_OPTIONS = {
|
|
31
31
|
document: import_utils.document
|
|
@@ -44,12 +44,12 @@ const setSVG = (val, key) => {
|
|
|
44
44
|
const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
45
45
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
46
46
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG.svg;
|
|
47
|
-
for (const key in LIBRARY) lib[key] =
|
|
47
|
+
for (const key in LIBRARY) lib[key] = LIBRARY[key];
|
|
48
48
|
appendSVG(lib, options);
|
|
49
49
|
};
|
|
50
50
|
const setSvgIcon = (val, key) => {
|
|
51
51
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
52
|
-
if (CONFIG.useIconSprite && !CONFIG.
|
|
52
|
+
if (CONFIG.useIconSprite && !CONFIG.semanticIcons?.[key]) {
|
|
53
53
|
return setSVG(val, key);
|
|
54
54
|
}
|
|
55
55
|
return val;
|
|
@@ -57,7 +57,7 @@ const setSvgIcon = (val, key) => {
|
|
|
57
57
|
const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
58
58
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
59
59
|
const lib = Object.keys(LIBRARY).length ? {} : CONFIG.icons;
|
|
60
|
-
for (const key in LIBRARY) lib[key] =
|
|
60
|
+
for (const key in LIBRARY) lib[key] = LIBRARY[key];
|
|
61
61
|
appendSVG(lib, options);
|
|
62
62
|
};
|
|
63
63
|
const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
|
|
@@ -72,6 +72,24 @@ const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
|
|
|
72
72
|
}
|
|
73
73
|
return svgElem;
|
|
74
74
|
};
|
|
75
|
+
const parseSVGSprite = (doc, svgString) => {
|
|
76
|
+
const DOMParserCtor = typeof DOMParser !== "undefined" ? DOMParser : null;
|
|
77
|
+
if (DOMParserCtor) {
|
|
78
|
+
const wrapped = `<svg xmlns="http://www.w3.org/2000/svg">${svgString}</svg>`;
|
|
79
|
+
const parser = new DOMParserCtor();
|
|
80
|
+
const parsed = parser.parseFromString(wrapped, "image/svg+xml");
|
|
81
|
+
if (parsed.querySelector("parsererror")) return null;
|
|
82
|
+
return parsed.documentElement;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
86
|
+
const moveChildren = (doc, from, to) => {
|
|
87
|
+
while (from.firstChild) {
|
|
88
|
+
const child = from.firstChild;
|
|
89
|
+
to.appendChild(doc.importNode(child, true));
|
|
90
|
+
child.remove();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
75
93
|
const appendSVG = (lib, options = DEF_OPTIONS) => {
|
|
76
94
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
77
95
|
const doc = options.document || import_utils.document;
|
|
@@ -84,8 +102,11 @@ const appendSVG = (lib, options = DEF_OPTIONS) => {
|
|
|
84
102
|
const exists = doc.querySelector("#svgSprite");
|
|
85
103
|
const SVGsprite = (0, import_utils2.generateSprite)(lib);
|
|
86
104
|
const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
|
|
105
|
+
const parsed = parseSVGSprite(doc, SVGsprite);
|
|
87
106
|
if (exists) {
|
|
88
|
-
if (
|
|
107
|
+
if (parsed) {
|
|
108
|
+
moveChildren(doc, parsed, exists);
|
|
109
|
+
} else if (doc.body.insertAdjacentHTML) {
|
|
89
110
|
exists.insertAdjacentHTML("beforeend", SVGsprite);
|
|
90
111
|
} else {
|
|
91
112
|
const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
|
|
@@ -93,7 +114,13 @@ const appendSVG = (lib, options = DEF_OPTIONS) => {
|
|
|
93
114
|
exists.append(...tempSVG.children);
|
|
94
115
|
}
|
|
95
116
|
} else {
|
|
96
|
-
if (
|
|
117
|
+
if (parsed) {
|
|
118
|
+
const svgSpriteDOM = createSVGSpriteElement(doc);
|
|
119
|
+
if (svgSpriteDOM && svgSpriteDOM.nodeType) {
|
|
120
|
+
moveChildren(doc, parsed, svgSpriteDOM);
|
|
121
|
+
doc.body.prepend(svgSpriteDOM);
|
|
122
|
+
}
|
|
123
|
+
} else if (doc.body.insertAdjacentHTML) {
|
|
97
124
|
doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
|
|
98
125
|
} else {
|
|
99
126
|
const svgSpriteDOM = createSVGSpriteElement(doc);
|
package/dist/cjs/system/theme.js
CHANGED
|
@@ -24,10 +24,10 @@ __export(theme_exports, {
|
|
|
24
24
|
setTheme: () => setTheme
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(theme_exports);
|
|
27
|
-
var import_color = require("./color");
|
|
27
|
+
var import_color = require("./color.js");
|
|
28
28
|
var import_factory = require("../factory.js");
|
|
29
29
|
var import_color2 = require("../utils/color.js");
|
|
30
|
-
var import_utils = require("@
|
|
30
|
+
var import_utils = require("@symbo.ls/utils");
|
|
31
31
|
const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
32
32
|
"black",
|
|
33
33
|
"white",
|
|
@@ -185,6 +185,13 @@ const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
|
185
185
|
"yellowgreen",
|
|
186
186
|
"rebeccapurple"
|
|
187
187
|
]);
|
|
188
|
+
const COLOR_PARAM_TOKENS = ["color", "Color", "background", "Background", "fill", "Fill", "stroke", "Stroke"];
|
|
189
|
+
const isColorParam = (param) => {
|
|
190
|
+
for (let i = 0; i < COLOR_PARAM_TOKENS.length; i++) {
|
|
191
|
+
if (param.includes(COLOR_PARAM_TOKENS[i])) return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
};
|
|
188
195
|
const setThemeValue = (theme) => {
|
|
189
196
|
const value = {};
|
|
190
197
|
const { state, media, helpers, ...rest } = theme;
|
|
@@ -286,7 +293,8 @@ const setTheme = (val, key) => {
|
|
|
286
293
|
if (CONFIG.useVariable) return setMediaTheme(val, key);
|
|
287
294
|
const { state, media, helpers } = val;
|
|
288
295
|
const value = setThemeValue(val, key);
|
|
289
|
-
const
|
|
296
|
+
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
297
|
+
const CSSvar = `--${vp}theme-${key}`;
|
|
290
298
|
setSelectors(val, value);
|
|
291
299
|
setMedia(val, value);
|
|
292
300
|
setHelpers(val, value);
|
|
@@ -299,9 +307,9 @@ const keySetters = {
|
|
|
299
307
|
".": (theme, value) => setHelpers(theme, value)
|
|
300
308
|
};
|
|
301
309
|
const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
302
|
-
const { CSS_VARS } = CONFIG;
|
|
303
|
-
if (!CONFIG.
|
|
304
|
-
const MEDIA_VARS = CONFIG.
|
|
310
|
+
const { cssVars: CSS_VARS } = CONFIG;
|
|
311
|
+
if (!CONFIG.cssMediaVars) CONFIG.cssMediaVars = {};
|
|
312
|
+
const MEDIA_VARS = CONFIG.cssMediaVars;
|
|
305
313
|
const globalTheme = CONFIG.globalTheme !== void 0 ? CONFIG.globalTheme : "auto";
|
|
306
314
|
const result = {};
|
|
307
315
|
const allKeys = /* @__PURE__ */ new Set();
|
|
@@ -309,19 +317,18 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
309
317
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
310
318
|
}
|
|
311
319
|
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
320
|
+
for (const param of allKeys) {
|
|
321
|
+
const symb = param.slice(0, 1);
|
|
322
|
+
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
323
|
+
if (!isColorParam(param)) continue;
|
|
324
|
+
for (const scheme in schemes) {
|
|
325
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
326
|
+
const val = schemes[scheme]?.[param];
|
|
327
|
+
if (val === void 0) continue;
|
|
328
|
+
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
329
|
+
if (color === void 0) continue;
|
|
330
|
+
if ((0, import_utils.isString)(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
331
|
+
brokenSchemes.add(scheme);
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
334
|
}
|
|
@@ -343,38 +350,31 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
343
350
|
}
|
|
344
351
|
result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG);
|
|
345
352
|
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const selector = `[data-theme="${scheme}"]`;
|
|
359
|
-
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
360
|
-
MEDIA_VARS[selector][autoVar] = color;
|
|
361
|
-
if (scheme === "dark" || scheme === "light") {
|
|
362
|
-
const mq = `@media (prefers-color-scheme: ${scheme})`;
|
|
363
|
-
if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
|
|
364
|
-
MEDIA_VARS[mq][autoVar] = color;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if (fallbackColor !== void 0) {
|
|
368
|
-
CSS_VARS[autoVar] = fallbackColor;
|
|
353
|
+
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
354
|
+
const autoVar = `--${vp}theme-${varPrefix}-${param}`;
|
|
355
|
+
const forced = globalTheme && globalTheme !== "auto" ? String(globalTheme).replace(/^'|'$/g, "") : null;
|
|
356
|
+
let fallbackColor;
|
|
357
|
+
for (const scheme in schemes) {
|
|
358
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
359
|
+
const val = schemes[scheme]?.[param];
|
|
360
|
+
if (val === void 0) continue;
|
|
361
|
+
const color = (0, import_color.getColor)(val, `@${scheme}`);
|
|
362
|
+
if (color === void 0) continue;
|
|
363
|
+
if (forced && scheme === forced || !forced && (scheme === "light" || fallbackColor === void 0)) {
|
|
364
|
+
fallbackColor = color;
|
|
369
365
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
366
|
+
const selector = `[data-theme="${scheme}"]`;
|
|
367
|
+
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
368
|
+
MEDIA_VARS[selector][autoVar] = color;
|
|
369
|
+
if (scheme === "dark" || scheme === "light") {
|
|
370
|
+
const mq = `@media (prefers-color-scheme: ${scheme})`;
|
|
371
|
+
if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
|
|
372
|
+
MEDIA_VARS[mq][autoVar] = color;
|
|
376
373
|
}
|
|
377
374
|
}
|
|
375
|
+
if (fallbackColor !== void 0) {
|
|
376
|
+
CSS_VARS[autoVar] = fallbackColor;
|
|
377
|
+
}
|
|
378
378
|
result[param] = `var(${autoVar})`;
|
|
379
379
|
result[`.${param}`] = { [param]: result[param] };
|
|
380
380
|
}
|
|
@@ -389,7 +389,7 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
389
389
|
};
|
|
390
390
|
const setMediaTheme = (val, key, suffix, prefers) => {
|
|
391
391
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
392
|
-
const { CSS_VARS } = CONFIG;
|
|
392
|
+
const { cssVars: CSS_VARS } = CONFIG;
|
|
393
393
|
const theme = { value: val };
|
|
394
394
|
const isTopLevel = !suffix && !prefers;
|
|
395
395
|
if ((0, import_utils.isObjectLike)(val)) {
|
|
@@ -415,7 +415,8 @@ const setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
415
415
|
const color = (0, import_color.getColor)(value, prefers);
|
|
416
416
|
const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
|
|
417
417
|
const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
|
|
418
|
-
const
|
|
418
|
+
const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
|
|
419
|
+
const CSSVar = `--${vp}theme-${key}${varmetaSuffixName}-${param}`;
|
|
419
420
|
if (CONFIG.useVariable) {
|
|
420
421
|
if (CONFIG.useThemeSuffixedVars) CSS_VARS[CSSVar] = color;
|
|
421
422
|
theme[param] = `var(${CSSVar})`;
|
|
@@ -23,24 +23,24 @@ __export(timing_exports, {
|
|
|
23
23
|
getTimingFunction: () => getTimingFunction
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(timing_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_utils = require("@symbo.ls/utils");
|
|
27
27
|
var import_factory = require("../factory.js");
|
|
28
|
-
var
|
|
28
|
+
var import_utils2 = require("../utils/index.js");
|
|
29
29
|
const applyTimingSequence = () => {
|
|
30
30
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
31
31
|
const { timing: TIMING } = CONFIG;
|
|
32
|
-
(0,
|
|
33
|
-
(0,
|
|
32
|
+
(0, import_utils2.generateSequence)(TIMING);
|
|
33
|
+
(0, import_utils2.applySequenceVars)(TIMING);
|
|
34
34
|
};
|
|
35
35
|
const getTimingFunction = (value) => {
|
|
36
36
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
37
37
|
const { timing: TIMING } = CONFIG;
|
|
38
|
-
return TIMING[value] || TIMING[(0,
|
|
38
|
+
return TIMING[value] || TIMING[(0, import_utils.toCamelCase)(value)] || value;
|
|
39
39
|
};
|
|
40
40
|
const getTimingByKey = (value, property = "timing") => {
|
|
41
41
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
42
42
|
const { timing: TIMING } = CONFIG;
|
|
43
|
-
return (0,
|
|
43
|
+
return (0, import_utils2.getSequenceValuePropertyPair)(
|
|
44
44
|
value,
|
|
45
45
|
property,
|
|
46
46
|
TIMING
|
|
@@ -24,9 +24,9 @@ __export(typography_exports, {
|
|
|
24
24
|
runThroughMedia: () => runThroughMedia
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(typography_exports);
|
|
27
|
-
var import_utils = require("@
|
|
27
|
+
var import_utils = require("@symbo.ls/utils");
|
|
28
28
|
var import_factory = require("../factory.js");
|
|
29
|
-
var import_utils2 = require("../utils");
|
|
29
|
+
var import_utils2 = require("../utils/index.js");
|
|
30
30
|
const runThroughMedia = (FACTORY) => {
|
|
31
31
|
const CONFIG = (0, import_factory.getActiveConfig)();
|
|
32
32
|
const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG;
|
|
@@ -46,12 +46,21 @@ const runThroughMedia = (FACTORY) => {
|
|
|
46
46
|
h1Matches,
|
|
47
47
|
unit
|
|
48
48
|
});
|
|
49
|
+
const VIEWPORT_UNITS = /* @__PURE__ */ new Set(["vw", "vh", "vmin", "vmax", "svw", "svh", "lvw", "lvh", "dvw", "dvh"]);
|
|
50
|
+
const inheritedUnit = mediaValue.unit || unit;
|
|
51
|
+
const mediaUnit = !mediaValue.unit && VIEWPORT_UNITS.has(unit) ? "rem" : inheritedUnit;
|
|
49
52
|
const query = MEDIA[mediaName];
|
|
50
53
|
const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
51
54
|
TYPOGRAPHY.templates[media] = {
|
|
52
|
-
fontSize: mediaValue.base / TYPOGRAPHY.browserDefault +
|
|
55
|
+
fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + mediaUnit
|
|
53
56
|
};
|
|
54
57
|
if (!mediaRegenerate) {
|
|
58
|
+
(0, import_utils.merge)(mediaValue, {
|
|
59
|
+
sequence: {},
|
|
60
|
+
scales: {},
|
|
61
|
+
vars: {}
|
|
62
|
+
});
|
|
63
|
+
(0, import_utils2.generateSequence)(mediaValue);
|
|
55
64
|
(0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
|
|
56
65
|
continue;
|
|
57
66
|
}
|
|
@@ -33,10 +33,10 @@ __export(transforms_exports, {
|
|
|
33
33
|
transfromGap: () => transfromGap
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(transforms_exports);
|
|
36
|
-
var import_utils = require("@
|
|
37
|
-
var import_factory = require("../factory");
|
|
38
|
-
var import_system = require("../system");
|
|
39
|
-
var import_utils2 = require("../utils");
|
|
36
|
+
var import_utils = require("@symbo.ls/utils");
|
|
37
|
+
var import_factory = require("../factory.js");
|
|
38
|
+
var import_system = require("../system/index.js");
|
|
39
|
+
var import_utils2 = require("../utils/index.js");
|
|
40
40
|
const BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
41
41
|
"none",
|
|
42
42
|
"hidden",
|
package/dist/cjs/utils/color.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(color_exports, {
|
|
|
40
40
|
splitTopLevelCommas: () => splitTopLevelCommas
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(color_exports);
|
|
43
|
-
var import_utils = require("@
|
|
43
|
+
var import_utils = require("@symbo.ls/utils");
|
|
44
44
|
const colorStringToRgbaArray = (color) => {
|
|
45
45
|
if (color === "") return [0, 0, 0, 0];
|
|
46
46
|
if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
|
package/dist/cjs/utils/font.js
CHANGED
|
@@ -50,6 +50,7 @@ const getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
|
50
50
|
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
|
|
51
51
|
};
|
|
52
52
|
const getFontFormat = (url) => {
|
|
53
|
+
if (typeof url !== "string" || !url) return null;
|
|
53
54
|
const ext = url.split(/[#?]/)[0].split(".").pop().trim();
|
|
54
55
|
if (["woff2", "woff", "ttf", "otf", "eot"].includes(ext)) return ext;
|
|
55
56
|
return null;
|
|
@@ -58,7 +59,8 @@ const isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") |
|
|
|
58
59
|
const setFontImport = (url) => `@import url('${url}');`;
|
|
59
60
|
const setInCustomFontMedia = (str) => `@font-face { ${str} }`;
|
|
60
61
|
const setCustomFont = (name, url, weight, options = {}) => {
|
|
61
|
-
const
|
|
62
|
+
const rawUrls = Array.isArray(url) ? url : [url];
|
|
63
|
+
const urls = rawUrls.filter((u) => typeof u === "string" && u);
|
|
62
64
|
const srcList = urls.map((u) => {
|
|
63
65
|
const format = getFontFormat(u);
|
|
64
66
|
const formatStr = format ? ` format('${format}')` : "";
|