css-in-props 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 +6 -22
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/props/animation.js +28 -23
- package/dist/cjs/props/block.js +46 -58
- package/dist/cjs/props/flex.js +4 -5
- package/dist/cjs/props/index.js +18 -19
- package/dist/cjs/props/misc.js +10 -3
- package/dist/cjs/props/theme.js +10 -7
- package/dist/cjs/set.js +13 -6
- package/dist/cjs/transform/executors.js +54 -47
- package/dist/cjs/transform/index.js +2 -2
- package/dist/cjs/transform/transformers.js +69 -20
- package/dist/esm/index.js +4 -4
- package/dist/esm/props/animation.js +28 -23
- package/dist/esm/props/block.js +46 -58
- package/dist/esm/props/flex.js +4 -5
- package/dist/esm/props/index.js +18 -19
- package/dist/esm/props/misc.js +10 -3
- package/dist/esm/props/theme.js +10 -7
- package/dist/esm/set.js +12 -5
- package/dist/esm/transform/executors.js +54 -47
- package/dist/esm/transform/index.js +2 -2
- package/dist/esm/transform/transformers.js +69 -20
- package/dist/iife/index.js +230 -167
- package/index.js +1 -0
- package/package.json +13 -15
- package/src/index.js +4 -4
- package/src/props/animation.js +28 -23
- package/src/props/block.js +49 -57
- package/src/props/flex.js +4 -5
- package/src/props/index.js +18 -19
- package/src/props/misc.js +10 -3
- package/src/props/theme.js +10 -7
- package/src/set.js +11 -4
- package/src/transform/executors.js +60 -52
- package/src/transform/index.js +2 -2
- package/src/transform/transformers.js +85 -23
- package/dist/cjs/_transform.js +0 -30
- package/dist/cjs/emotion.js +0 -29
- package/dist/esm/_transform.js +0 -10
- package/dist/esm/emotion.js +0 -9
- package/src/_transform.js +0 -10
- package/src/emotion.js +0 -9
|
@@ -22,31 +22,66 @@ __export(transformers_exports, {
|
|
|
22
22
|
transformersByPrefix: () => transformersByPrefix
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(transformers_exports);
|
|
25
|
-
var import_utils = require("@
|
|
26
|
-
var import_executors = require("./executors");
|
|
25
|
+
var import_utils = require("@symbo.ls/utils");
|
|
26
|
+
var import_executors = require("./executors.js");
|
|
27
|
+
const DATA_THEME_RE = /^\[data-theme=(?:"([^"]+)"|'([^']+)')\]$/;
|
|
27
28
|
const applyMediaProps = (key, selectorProps, element) => {
|
|
28
29
|
const { context } = element;
|
|
29
30
|
if (!context.designSystem?.media) return;
|
|
30
|
-
const
|
|
31
|
+
const schemeKey = key.slice(1);
|
|
32
|
+
const mediaValue = context.designSystem.media[schemeKey];
|
|
31
33
|
const generatedClass = (0, import_executors.useCssInProps)(selectorProps, element);
|
|
32
|
-
let mediaKey;
|
|
33
34
|
if (!mediaValue) {
|
|
34
|
-
|
|
35
|
-
} else if (mediaValue === "print") {
|
|
36
|
-
mediaKey = "@media print";
|
|
37
|
-
} else if (mediaValue[0] === "(") {
|
|
38
|
-
mediaKey = `@media screen and ${mediaValue}`;
|
|
39
|
-
} else {
|
|
40
|
-
mediaKey = `${mediaValue} &`;
|
|
35
|
+
return { [key]: generatedClass };
|
|
41
36
|
}
|
|
42
|
-
|
|
37
|
+
if (mediaValue === "print") {
|
|
38
|
+
return { "@media print": generatedClass };
|
|
39
|
+
}
|
|
40
|
+
if (mediaValue[0] === "(") {
|
|
41
|
+
return { [`@media screen and ${mediaValue}`]: generatedClass };
|
|
42
|
+
}
|
|
43
|
+
const match = mediaValue.match(DATA_THEME_RE);
|
|
44
|
+
const scheme = match ? match[1] || match[2] : schemeKey;
|
|
45
|
+
const result = { [`${mediaValue} &`]: generatedClass };
|
|
46
|
+
if (scheme === "dark" || scheme === "light") {
|
|
47
|
+
const scopeSelector = context.designSystem?.scopeSelector || ":root";
|
|
48
|
+
const guard = scopeSelector === ":root" ? ":root:not([data-theme])" : `${scopeSelector}:not([data-theme])`;
|
|
49
|
+
result[`@media (prefers-color-scheme: ${scheme})`] = {
|
|
50
|
+
[`${guard} &`]: generatedClass
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
43
54
|
};
|
|
44
55
|
const applyAndProps = (key, selectorProps, element) => {
|
|
45
56
|
return { [key]: (0, import_executors.useCssInProps)(selectorProps, element) };
|
|
46
57
|
};
|
|
47
58
|
const applySelectorProps = (key, selectorProps, element) => {
|
|
48
59
|
const selectorKey = `&${key}`;
|
|
49
|
-
|
|
60
|
+
const resolved = (0, import_executors.useCssInProps)(selectorProps, element);
|
|
61
|
+
if (key.includes(",") && resolved) {
|
|
62
|
+
const flat = {};
|
|
63
|
+
const nested = {};
|
|
64
|
+
for (const k in resolved) {
|
|
65
|
+
if (typeof resolved[k] === "object" && resolved[k] !== null) {
|
|
66
|
+
nested[k] = resolved[k];
|
|
67
|
+
} else {
|
|
68
|
+
flat[k] = resolved[k];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (Object.keys(nested).length) {
|
|
72
|
+
const parts = selectorKey.split(",").map((p) => p.trim());
|
|
73
|
+
const result = {};
|
|
74
|
+
if (Object.keys(flat).length) {
|
|
75
|
+
result[selectorKey] = flat;
|
|
76
|
+
}
|
|
77
|
+
for (const nestedKey in nested) {
|
|
78
|
+
const distributed = parts.map((p) => `${p} ${nestedKey}`).join(", ");
|
|
79
|
+
result[distributed] = nested[nestedKey];
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { [selectorKey]: resolved };
|
|
50
85
|
};
|
|
51
86
|
const resolveCase = (caseKey, element) => {
|
|
52
87
|
const caseFn = element.context?.cases?.[caseKey];
|
|
@@ -58,7 +93,7 @@ const applyCaseProps = (key, selectorProps, element) => {
|
|
|
58
93
|
const caseKey = key.slice(1);
|
|
59
94
|
let isCaseTrue = resolveCase(caseKey, element);
|
|
60
95
|
if (isCaseTrue === void 0) {
|
|
61
|
-
isCaseTrue = !!element
|
|
96
|
+
isCaseTrue = !!element[caseKey];
|
|
62
97
|
}
|
|
63
98
|
if (!isCaseTrue) return;
|
|
64
99
|
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
@@ -68,20 +103,34 @@ const applyVariableProps = (key, selectorVal, element) => {
|
|
|
68
103
|
};
|
|
69
104
|
const applyConditionalCaseProps = (key, selectorProps, element) => {
|
|
70
105
|
const caseKey = key.slice(1);
|
|
71
|
-
let isCaseTrue = element
|
|
106
|
+
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
72
107
|
if (!isCaseTrue) {
|
|
73
|
-
|
|
74
|
-
|
|
108
|
+
if (typeof element[caseKey] === "function") {
|
|
109
|
+
try {
|
|
110
|
+
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
const caseResult = resolveCase(caseKey, element);
|
|
115
|
+
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
116
|
+
}
|
|
75
117
|
}
|
|
76
118
|
if (!isCaseTrue) return;
|
|
77
119
|
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
78
120
|
};
|
|
79
121
|
const applyConditionalFalsyProps = (key, selectorProps, element) => {
|
|
80
122
|
const caseKey = key.slice(1);
|
|
81
|
-
let isCaseTrue = element
|
|
123
|
+
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
82
124
|
if (!isCaseTrue) {
|
|
83
|
-
|
|
84
|
-
|
|
125
|
+
if (typeof element[caseKey] === "function") {
|
|
126
|
+
try {
|
|
127
|
+
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
const caseResult = resolveCase(caseKey, element);
|
|
132
|
+
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
133
|
+
}
|
|
85
134
|
}
|
|
86
135
|
if (isCaseTrue) return;
|
|
87
136
|
return (0, import_executors.useCssInProps)(selectorProps, element);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./transform";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./props";
|
|
4
|
-
export * from "./props/defaults";
|
|
1
|
+
export * from "./transform/index.js";
|
|
2
|
+
export * from "./set.js";
|
|
3
|
+
export * from "./props/index.js";
|
|
4
|
+
export * from "./props/defaults.js";
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { isObject, isString } from "@
|
|
2
|
-
import {
|
|
1
|
+
import { isObject, isString } from "@symbo.ls/utils";
|
|
2
|
+
import { keyframes as cssKeyframes } from "@symbo.ls/css";
|
|
3
3
|
import { getTimingByKey, getTimingFunction } from "@symbo.ls/scratch";
|
|
4
4
|
const TIMING_FUNCTIONS = ["ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"];
|
|
5
5
|
const FILL_MODES = ["none", "forwards", "backwards", "both"];
|
|
6
6
|
const DIRECTIONS = ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
7
7
|
const PLAY_STATES = ["running", "paused"];
|
|
8
8
|
const isDuration = (v) => /^[\d.]+m?s$/.test(v);
|
|
9
|
+
let _animCounter = 0;
|
|
9
10
|
const applyAnimationProps = (animation, element) => {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const { animation: ANIMATION } = element.context && element.context.designSystem || {};
|
|
12
|
+
if (isObject(animation)) {
|
|
13
|
+
const name = `smbls-anim-${_animCounter++}`;
|
|
14
|
+
return { animationName: cssKeyframes(name, animation) };
|
|
15
|
+
}
|
|
16
|
+
const record = ANIMATION && ANIMATION[animation];
|
|
17
|
+
if (isObject(record)) {
|
|
18
|
+
return cssKeyframes(animation, record);
|
|
19
|
+
}
|
|
20
|
+
return animation;
|
|
16
21
|
};
|
|
17
22
|
const parseAnimationShorthand = (val, el) => {
|
|
18
|
-
const { ANIMATION } = el.context && el.context.designSystem || {};
|
|
23
|
+
const { animation: ANIMATION } = el.context && el.context.designSystem || {};
|
|
19
24
|
const tokens = val.split(/\s+/);
|
|
20
25
|
let name = null;
|
|
21
26
|
const durations = [];
|
|
@@ -51,24 +56,24 @@ const ANIMATION_PROPS = {
|
|
|
51
56
|
const parsed = parseAnimationShorthand(val, el);
|
|
52
57
|
return {
|
|
53
58
|
animationName: applyAnimationProps(parsed.name || val, el),
|
|
54
|
-
animationDuration: parsed.durations[0] || getTimingByKey(el.
|
|
55
|
-
animationDelay: parsed.durations[1] || getTimingByKey(el.
|
|
56
|
-
animationTimingFunction: parsed.timingFunction || getTimingFunction(el.
|
|
57
|
-
animationFillMode: parsed.fillMode || el.
|
|
58
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.
|
|
59
|
-
animationPlayState: parsed.playState || el.
|
|
60
|
-
animationDirection: parsed.direction || el.
|
|
59
|
+
animationDuration: parsed.durations[0] || getTimingByKey(el.animationDuration || "A").timing,
|
|
60
|
+
animationDelay: parsed.durations[1] || getTimingByKey(el.animationDelay || "0s").timing,
|
|
61
|
+
animationTimingFunction: parsed.timingFunction || getTimingFunction(el.animationTimingFunction || "ease"),
|
|
62
|
+
animationFillMode: parsed.fillMode || el.animationFillMode || "both",
|
|
63
|
+
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.animationIterationCount || 1,
|
|
64
|
+
animationPlayState: parsed.playState || el.animationPlayState,
|
|
65
|
+
animationDirection: parsed.direction || el.animationDirection
|
|
61
66
|
};
|
|
62
67
|
}
|
|
63
68
|
return {
|
|
64
69
|
animationName: applyAnimationProps(val, el),
|
|
65
|
-
animationDuration: getTimingByKey(el.
|
|
66
|
-
animationDelay: getTimingByKey(el.
|
|
67
|
-
animationTimingFunction: getTimingFunction(el.
|
|
68
|
-
animationFillMode: el.
|
|
69
|
-
animationIterationCount: el.
|
|
70
|
-
animationPlayState: el.
|
|
71
|
-
animationDirection: el.
|
|
70
|
+
animationDuration: getTimingByKey(el.animationDuration || "A").timing,
|
|
71
|
+
animationDelay: getTimingByKey(el.animationDelay || "0s").timing,
|
|
72
|
+
animationTimingFunction: getTimingFunction(el.animationTimingFunction || "ease"),
|
|
73
|
+
animationFillMode: el.animationFillMode || "both",
|
|
74
|
+
animationIterationCount: el.animationIterationCount || 1,
|
|
75
|
+
animationPlayState: el.animationPlayState,
|
|
76
|
+
animationDirection: el.animationDirection
|
|
72
77
|
};
|
|
73
78
|
},
|
|
74
79
|
animationName: (val, el) => ({
|
package/dist/esm/props/block.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isUndefined, isString } from "@
|
|
1
|
+
import { isUndefined, isString } from "@symbo.ls/utils";
|
|
2
2
|
import {
|
|
3
3
|
getSpacingBasedOnRatio,
|
|
4
4
|
transformSize,
|
|
@@ -7,14 +7,10 @@ import {
|
|
|
7
7
|
transfromGap
|
|
8
8
|
} from "@symbo.ls/scratch";
|
|
9
9
|
const BLOCK_PROPS = {
|
|
10
|
-
show: (val
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
display: "none !important"
|
|
15
|
-
},
|
|
16
|
-
height: (val, { props }) => transformSizeRatio("height", val, props),
|
|
17
|
-
width: (val, { props }) => transformSizeRatio("width", val, props),
|
|
10
|
+
show: (val) => !val ? { display: "none !important" } : void 0,
|
|
11
|
+
hide: (val) => val ? { display: "none !important" } : void 0,
|
|
12
|
+
height: (val, el) => transformSizeRatio("height", val, el),
|
|
13
|
+
width: (val, el) => transformSizeRatio("width", val, el),
|
|
18
14
|
boxSizing: (val) => !isUndefined(val) ? { boxSizing: val } : { boxSizing: "border-box" },
|
|
19
15
|
boxSize: (val) => {
|
|
20
16
|
if (!isString(val)) return;
|
|
@@ -24,10 +20,10 @@ const BLOCK_PROPS = {
|
|
|
24
20
|
...transformSize("width", width || height)
|
|
25
21
|
};
|
|
26
22
|
},
|
|
27
|
-
inlineSize: (val,
|
|
28
|
-
blockSize: (val,
|
|
29
|
-
minWidth: (val,
|
|
30
|
-
maxWidth: (val,
|
|
23
|
+
inlineSize: (val, el) => transformSizeRatio("inlineSize", val, el),
|
|
24
|
+
blockSize: (val, el) => transformSizeRatio("blockSize", val, el),
|
|
25
|
+
minWidth: (val, el) => transformSizeRatio("minWidth", val, el),
|
|
26
|
+
maxWidth: (val, el) => transformSizeRatio("maxWidth", val, el),
|
|
31
27
|
widthRange: (val) => {
|
|
32
28
|
if (!isString(val)) return;
|
|
33
29
|
const [minWidth, maxWidth] = val.split(" ");
|
|
@@ -36,8 +32,8 @@ const BLOCK_PROPS = {
|
|
|
36
32
|
...transformSize("maxWidth", maxWidth || minWidth)
|
|
37
33
|
};
|
|
38
34
|
},
|
|
39
|
-
minHeight: (val,
|
|
40
|
-
maxHeight: (val,
|
|
35
|
+
minHeight: (val, el) => transformSizeRatio("minHeight", val, el),
|
|
36
|
+
maxHeight: (val, el) => transformSizeRatio("maxHeight", val, el),
|
|
41
37
|
heightRange: (val) => {
|
|
42
38
|
if (!isString(val)) return;
|
|
43
39
|
const [minHeight, maxHeight] = val.split(" ");
|
|
@@ -54,10 +50,10 @@ const BLOCK_PROPS = {
|
|
|
54
50
|
...transformSizeRatio("blockSize", blockSize || inlineSize)
|
|
55
51
|
};
|
|
56
52
|
},
|
|
57
|
-
minBlockSize: (val,
|
|
58
|
-
minInlineSize: (val,
|
|
59
|
-
maxBlockSize: (val,
|
|
60
|
-
maxInlineSize: (val,
|
|
53
|
+
minBlockSize: (val, el) => transformSizeRatio("minBlockSize", val, el),
|
|
54
|
+
minInlineSize: (val, el) => transformSizeRatio("minInlineSize", val, el),
|
|
55
|
+
maxBlockSize: (val, el) => transformSizeRatio("maxBlockSize", val, el),
|
|
56
|
+
maxInlineSize: (val, el) => transformSizeRatio("maxInlineSize", val, el),
|
|
61
57
|
minSize: (val) => {
|
|
62
58
|
if (!isString(val)) return;
|
|
63
59
|
const [minInlineSize, minBlockSize] = val.split(" ");
|
|
@@ -74,9 +70,9 @@ const BLOCK_PROPS = {
|
|
|
74
70
|
...transformSize("maxBlockSize", maxBlockSize || maxInlineSize)
|
|
75
71
|
};
|
|
76
72
|
},
|
|
77
|
-
borderWidth: (val,
|
|
78
|
-
padding: (val,
|
|
79
|
-
scrollPadding: (val,
|
|
73
|
+
borderWidth: (val, el) => transformSizeRatio("borderWidth", val, el),
|
|
74
|
+
padding: (val, el) => transformSizeRatio("padding", val, el),
|
|
75
|
+
scrollPadding: (val, el) => transformSizeRatio("scrollPadding", val, el),
|
|
80
76
|
paddingInline: (val) => {
|
|
81
77
|
if (!isString(val)) return;
|
|
82
78
|
const [paddingInlineStart, paddingInlineEnd] = val.split(" ");
|
|
@@ -93,21 +89,15 @@ const BLOCK_PROPS = {
|
|
|
93
89
|
...transformSize("paddingBlockEnd", paddingBlockEnd || paddingBlockStart)
|
|
94
90
|
};
|
|
95
91
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// maps to bottom
|
|
106
|
-
paddingInlineStart: (val, { props }) => transformSizeRatio("paddingInlineStart", val, props),
|
|
107
|
-
// maps to left
|
|
108
|
-
paddingInlineEnd: (val, { props }) => transformSizeRatio("paddingInlineEnd", val, props),
|
|
109
|
-
// maps to right
|
|
110
|
-
margin: (val, { props }) => transformSizeRatio("margin", val, props),
|
|
92
|
+
paddingTop: (val, el) => transformSizeRatio("paddingBlockStart", val, el),
|
|
93
|
+
paddingBottom: (val, el) => transformSizeRatio("paddingBlockEnd", val, el),
|
|
94
|
+
paddingLeft: (val, el) => transformSizeRatio("paddingInlineStart", val, el),
|
|
95
|
+
paddingRight: (val, el) => transformSizeRatio("paddingInlineEnd", val, el),
|
|
96
|
+
paddingBlockStart: (val, el) => transformSizeRatio("paddingBlockStart", val, el),
|
|
97
|
+
paddingBlockEnd: (val, el) => transformSizeRatio("paddingBlockEnd", val, el),
|
|
98
|
+
paddingInlineStart: (val, el) => transformSizeRatio("paddingInlineStart", val, el),
|
|
99
|
+
paddingInlineEnd: (val, el) => transformSizeRatio("paddingInlineEnd", val, el),
|
|
100
|
+
margin: (val, el) => transformSizeRatio("margin", val, el),
|
|
111
101
|
marginInline: (val) => {
|
|
112
102
|
if (!isString(val)) return;
|
|
113
103
|
const [marginInlineStart, marginInlineEnd] = val.split(" ");
|
|
@@ -116,35 +106,33 @@ const BLOCK_PROPS = {
|
|
|
116
106
|
...transformSize("marginInlineEnd", marginInlineEnd || marginInlineStart)
|
|
117
107
|
};
|
|
118
108
|
},
|
|
119
|
-
marginBlock: (val,
|
|
120
|
-
if (!isString(
|
|
121
|
-
const [marginBlockStart, marginBlockEnd] =
|
|
109
|
+
marginBlock: (val, el) => {
|
|
110
|
+
if (!isString(el.marginBlock)) return;
|
|
111
|
+
const [marginBlockStart, marginBlockEnd] = el.marginBlock.split(" ");
|
|
122
112
|
return {
|
|
123
113
|
...transformSize("marginBlockStart", marginBlockStart),
|
|
124
114
|
...transformSize("marginBlockEnd", marginBlockEnd || marginBlockStart)
|
|
125
115
|
};
|
|
126
116
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
marginBlockStart: (val, { props }) => transformSizeRatio("marginBlockStart", val, props),
|
|
136
|
-
marginBlockEnd: (val, { props }) => transformSizeRatio("marginBlockEnd", val, props),
|
|
117
|
+
marginTop: (val, el) => transformSizeRatio("marginBlockStart", val, el),
|
|
118
|
+
marginBottom: (val, el) => transformSizeRatio("marginBlockEnd", val, el),
|
|
119
|
+
marginLeft: (val, el) => transformSizeRatio("marginInlineStart", val, el),
|
|
120
|
+
marginRight: (val, el) => transformSizeRatio("marginInlineEnd", val, el),
|
|
121
|
+
marginInlineStart: (val, el) => transformSizeRatio("marginInlineStart", val, el),
|
|
122
|
+
marginInlineEnd: (val, el) => transformSizeRatio("marginInlineEnd", val, el),
|
|
123
|
+
marginBlockStart: (val, el) => transformSizeRatio("marginBlockStart", val, el),
|
|
124
|
+
marginBlockEnd: (val, el) => transformSizeRatio("marginBlockEnd", val, el),
|
|
137
125
|
gap: (val) => ({
|
|
138
126
|
gap: transfromGap(val)
|
|
139
127
|
}),
|
|
140
|
-
columnGap: (val,
|
|
141
|
-
rowGap: (val,
|
|
142
|
-
flexWrap: (val
|
|
128
|
+
columnGap: (val, el) => getSpacingBasedOnRatio(el, "columnGap", val),
|
|
129
|
+
rowGap: (val, el) => getSpacingBasedOnRatio(el, "rowGap", val),
|
|
130
|
+
flexWrap: (val) => ({
|
|
143
131
|
display: "flex",
|
|
144
|
-
|
|
132
|
+
flexWrap: val
|
|
145
133
|
}),
|
|
146
|
-
flexFlow: (val,
|
|
147
|
-
const
|
|
134
|
+
flexFlow: (val, el) => {
|
|
135
|
+
const reverse = el.reverse;
|
|
148
136
|
if (!isString(val)) return;
|
|
149
137
|
let [direction, wrap] = (val || "row").split(" ");
|
|
150
138
|
if (val.startsWith("x") || val === "row") direction = "row";
|
|
@@ -163,8 +151,8 @@ const BLOCK_PROPS = {
|
|
|
163
151
|
justifyContent
|
|
164
152
|
};
|
|
165
153
|
},
|
|
166
|
-
round: (val,
|
|
167
|
-
borderRadius: (val,
|
|
154
|
+
round: (val, el) => transformBorderRadius(val ?? el.borderRadius, el, "round"),
|
|
155
|
+
borderRadius: (val, el) => transformBorderRadius(val ?? el.round, el, "borderRadius")
|
|
168
156
|
};
|
|
169
157
|
export {
|
|
170
158
|
BLOCK_PROPS
|
package/dist/esm/props/flex.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { isString } from "@
|
|
1
|
+
import { isString } from "@symbo.ls/utils";
|
|
2
2
|
const FLEX_PROPS = {
|
|
3
3
|
flow: (value, el) => {
|
|
4
|
-
const
|
|
5
|
-
const { reverse } = props;
|
|
4
|
+
const reverse = el.reverse;
|
|
6
5
|
if (!isString(value)) return;
|
|
7
6
|
let [direction, wrap] = (value || "row").split(" ");
|
|
8
7
|
if (value.startsWith("x") || value === "row") direction = "row";
|
|
@@ -12,10 +11,10 @@ const FLEX_PROPS = {
|
|
|
12
11
|
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
13
12
|
};
|
|
14
13
|
},
|
|
15
|
-
wrap: (value,
|
|
14
|
+
wrap: (value, el) => {
|
|
16
15
|
return { display: "flex", flexWrap: value };
|
|
17
16
|
},
|
|
18
|
-
align: (value,
|
|
17
|
+
align: (value, el) => {
|
|
19
18
|
const [alignItems, justifyContent] = value.split(" ");
|
|
20
19
|
return { display: "flex", alignItems, justifyContent };
|
|
21
20
|
}
|
package/dist/esm/props/index.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { ANIMATION_PROPS } from "./animation";
|
|
2
|
-
import { BLOCK_PROPS } from "./block";
|
|
3
|
-
import { FONT_PROPS } from "./font";
|
|
4
|
-
import { MISC_PROPS } from "./misc";
|
|
5
|
-
import { POSITION_PROPS } from "./position";
|
|
6
|
-
import { THEME_PROPS } from "./theme";
|
|
7
|
-
import { TIMING_PROPS } from "./timing";
|
|
8
|
-
import { FLEX_PROPS } from "./flex";
|
|
9
|
-
import { GRID_PROPS } from "./grid";
|
|
10
|
-
export * from "./animation";
|
|
11
|
-
export * from "./block";
|
|
12
|
-
export * from "./font";
|
|
13
|
-
export * from "./misc";
|
|
14
|
-
export * from "./position";
|
|
15
|
-
export * from "./theme";
|
|
16
|
-
export * from "./timing";
|
|
17
|
-
export * from "./flex";
|
|
18
|
-
export * from "./grid";
|
|
1
|
+
import { ANIMATION_PROPS } from "./animation.js";
|
|
2
|
+
import { BLOCK_PROPS } from "./block.js";
|
|
3
|
+
import { FONT_PROPS } from "./font.js";
|
|
4
|
+
import { MISC_PROPS } from "./misc.js";
|
|
5
|
+
import { POSITION_PROPS } from "./position.js";
|
|
6
|
+
import { THEME_PROPS } from "./theme.js";
|
|
7
|
+
import { TIMING_PROPS } from "./timing.js";
|
|
8
|
+
import { FLEX_PROPS } from "./flex.js";
|
|
9
|
+
import { GRID_PROPS } from "./grid.js";
|
|
10
|
+
export * from "./animation.js";
|
|
11
|
+
export * from "./block.js";
|
|
12
|
+
export * from "./font.js";
|
|
13
|
+
export * from "./misc.js";
|
|
14
|
+
export * from "./position.js";
|
|
15
|
+
export * from "./theme.js";
|
|
16
|
+
export * from "./timing.js";
|
|
17
|
+
export * from "./flex.js";
|
|
18
|
+
export * from "./grid.js";
|
|
19
19
|
const CSS_PROPS_REGISTRY = {
|
|
20
20
|
...ANIMATION_PROPS,
|
|
21
21
|
...BLOCK_PROPS,
|
|
22
22
|
...FONT_PROPS,
|
|
23
23
|
...MISC_PROPS,
|
|
24
|
-
...MISC_PROPS,
|
|
25
24
|
...POSITION_PROPS,
|
|
26
25
|
...THEME_PROPS,
|
|
27
26
|
...TIMING_PROPS,
|
package/dist/esm/props/misc.js
CHANGED
|
@@ -5,10 +5,17 @@ const MISC_PROPS = {
|
|
|
5
5
|
}),
|
|
6
6
|
cursor: (value, el, s, ctx) => {
|
|
7
7
|
if (!value) return;
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
8
|
+
const asset = ctx.assets && ctx.assets[value];
|
|
9
|
+
if (asset && asset.content) value = `url(${asset.content.src})`;
|
|
10
|
+
else {
|
|
11
|
+
const file = ctx.files && ctx.files[value];
|
|
12
|
+
if (file && file.content) value = `url(${file.content.src})`;
|
|
13
|
+
}
|
|
10
14
|
return { cursor: value };
|
|
11
|
-
}
|
|
15
|
+
},
|
|
16
|
+
opacity: (value) => value != null ? { opacity: String(value) } : void 0,
|
|
17
|
+
visibility: (value) => value != null ? { visibility: value } : void 0,
|
|
18
|
+
pointerEvents: (value) => value != null ? { pointerEvents: value } : void 0
|
|
12
19
|
};
|
|
13
20
|
export {
|
|
14
21
|
MISC_PROPS
|
package/dist/esm/props/theme.js
CHANGED
|
@@ -9,17 +9,16 @@ import {
|
|
|
9
9
|
resolveColorsInGradient,
|
|
10
10
|
transformSizeRatio
|
|
11
11
|
} from "@symbo.ls/scratch";
|
|
12
|
-
import { isDefined, isString } from "@
|
|
12
|
+
import { isDefined, isString } from "@symbo.ls/utils";
|
|
13
13
|
const getSystemGlobalTheme = ({ context, state }) => {
|
|
14
14
|
const theme = state?.root?.globalTheme || context.designSystem?.globalTheme;
|
|
15
15
|
return theme === "auto" ? null : theme;
|
|
16
16
|
};
|
|
17
17
|
const THEME_PROPS = {
|
|
18
18
|
theme: (val, element) => {
|
|
19
|
-
const { props } = element;
|
|
20
19
|
if (!val) return;
|
|
21
|
-
if (
|
|
22
|
-
return getMediaTheme(val, `@${
|
|
20
|
+
if (element.themeModifier) {
|
|
21
|
+
return getMediaTheme(val, `@${element.themeModifier}`);
|
|
23
22
|
}
|
|
24
23
|
return getMediaTheme(val);
|
|
25
24
|
},
|
|
@@ -50,8 +49,12 @@ const THEME_PROPS = {
|
|
|
50
49
|
backgroundImage: (val, element, s, ctx) => {
|
|
51
50
|
const globalTheme = getSystemGlobalTheme(element);
|
|
52
51
|
if (!val) return;
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
52
|
+
const asset = ctx.assets && ctx.assets[val];
|
|
53
|
+
if (asset && asset.content) val = asset.content.src;
|
|
54
|
+
else {
|
|
55
|
+
const file = ctx.files && ctx.files[val];
|
|
56
|
+
if (file && file.content) val = file.content.src;
|
|
57
|
+
}
|
|
55
58
|
return {
|
|
56
59
|
backgroundImage: transformBackgroundImage(val, globalTheme)
|
|
57
60
|
};
|
|
@@ -62,7 +65,7 @@ const THEME_PROPS = {
|
|
|
62
65
|
outline: (val) => ({
|
|
63
66
|
outline: transformBorder(val)
|
|
64
67
|
}),
|
|
65
|
-
outlineOffset: (val,
|
|
68
|
+
outlineOffset: (val, el) => transformSizeRatio("outlineOffset", val, el),
|
|
66
69
|
border: (val) => ({
|
|
67
70
|
border: transformBorder(val)
|
|
68
71
|
}),
|
package/dist/esm/set.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { isObject } from "@symbo.ls/utils";
|
|
2
|
+
import { useCssInProps } from "./transform/index.js";
|
|
3
|
+
import { css } from "@symbo.ls/css";
|
|
4
|
+
const transformClassname = (element) => {
|
|
5
|
+
if (!isObject(element)) return;
|
|
6
|
+
return useCssInProps(element, element);
|
|
7
|
+
};
|
|
8
|
+
const setClassname = (props, cssEngine) => {
|
|
4
9
|
const transform = transformClassname(props);
|
|
5
|
-
return
|
|
10
|
+
if (typeof cssEngine === "function") return cssEngine(transform);
|
|
11
|
+
return css(transform);
|
|
6
12
|
};
|
|
7
13
|
export {
|
|
8
|
-
setClassname
|
|
14
|
+
setClassname,
|
|
15
|
+
transformClassname
|
|
9
16
|
};
|