css-in-props 3.8.9 → 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
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# css-in-props
|
|
2
2
|
|
|
3
|
-
CSS properties as component props for DOMQL elements. Transforms design-system-aware props into CSS classes via
|
|
3
|
+
CSS properties as component props for DOMQL elements. Transforms design-system-aware props into CSS classes via the atomic CSS engine (`@symbo.ls/css`).
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
7
|
- Transforms component props (`theme`, `color`, `background`, `border`, `shadow`, etc.) into resolved CSS
|
|
8
8
|
- Resolves design system tokens (colors, spacing, typography, themes) from `@symbo.ls/scratch`
|
|
9
9
|
- Handles media queries (`@dark`, `@mobileS`, etc.) and pseudo selectors (`:hover`, `:focus`) as prop prefixes
|
|
10
|
-
- Generates
|
|
10
|
+
- Generates atomic CSS classes for optimized rendering (one class per property-value pair)
|
|
11
11
|
|
|
12
12
|
## Theme prop
|
|
13
13
|
|
|
@@ -69,25 +69,9 @@ import { transformersByPrefix } from 'css-in-props'
|
|
|
69
69
|
|
|
70
70
|
## Interaction with the define system
|
|
71
71
|
|
|
72
|
-
The `$` prefix is used both by css-in-props (`$isActive` case conditional) and by the define system (e.g. `$router
|
|
72
|
+
The `$` prefix is used both by css-in-props (`$isActive` case conditional) and by the define system (e.g. `$router`). The framework resolves this by checking for define handlers before applying prefix rules. Keys with matching define handlers stay at the element root; only `$`-prefixed keys without define handlers are processed by css-in-props.
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Keys starting with `$` that have a matching define handler (either `element.define[key]` or `context.define[key]`) must **stay at the element root** so that `throughInitialDefine` can process them. Only `$`-prefixed keys without define handlers should be moved into `props` for css-in-props processing. This matters for the built-in `$router` handler and for backwards compatibility with older v2 projects using deprecated collection handlers.
|
|
77
|
-
|
|
78
|
-
```javascript
|
|
79
|
-
// In props.js — check define handlers BEFORE checking CSS_SELECTOR_PREFIXES
|
|
80
|
-
const defineValue = this.define?.[key]
|
|
81
|
-
const globalDefineValue = this.context?.define?.[key]
|
|
82
|
-
if (isFunction(defineValue) || isFunction(globalDefineValue)) continue
|
|
83
|
-
|
|
84
|
-
// Only then check the prefix
|
|
85
|
-
if (CSS_SELECTOR_PREFIXES.has(firstChar)) {
|
|
86
|
-
obj.props[key] = value // move to props for css-in-props
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
> **Lesson learned:** Without the define-awareness check, keys like `$propsCollection` were moved into `props` and became invisible to the define system, breaking collection-based rendering in projects like Rosi and BigBrother.
|
|
74
|
+
> In v4, properties go directly on the element (no `props:` wrapper). The CSS engine processes design token properties internally.
|
|
91
75
|
|
|
92
76
|
## Global Cases
|
|
93
77
|
|
|
@@ -110,8 +94,8 @@ export default { cases, /* ...other context */ }
|
|
|
110
94
|
|
|
111
95
|
### Resolution order
|
|
112
96
|
|
|
113
|
-
- **`$` prefix**: Checks `context.cases[key]` first (call if function, check truthiness if value). Falls back to `element
|
|
114
|
-
- **`.` prefix**: Checks `element
|
|
97
|
+
- **`$` prefix**: Checks `context.cases[key]` first (call if function, check truthiness if value). Falls back to `element[key]`.
|
|
98
|
+
- **`.` prefix**: Checks `element[key]` / `element.state[key]` first. Falls back to `context.cases[key]`.
|
|
115
99
|
- **`!` prefix**: Same as `.` but inverted — applies when condition is falsy.
|
|
116
100
|
|
|
117
101
|
```javascript
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var index_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./transform"), module.exports);
|
|
19
|
-
__reExport(index_exports, require("./
|
|
20
|
-
__reExport(index_exports, require("./props"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./props/defaults"), module.exports);
|
|
18
|
+
__reExport(index_exports, require("./transform/index.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./set.js"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./props/index.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./props/defaults.js"), module.exports);
|
|
@@ -21,24 +21,29 @@ __export(animation_exports, {
|
|
|
21
21
|
ANIMATION_PROPS: () => ANIMATION_PROPS
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(animation_exports);
|
|
24
|
-
var import_utils = require("@
|
|
25
|
-
var
|
|
24
|
+
var import_utils = require("@symbo.ls/utils");
|
|
25
|
+
var import_css = require("@symbo.ls/css");
|
|
26
26
|
var import_scratch = require("@symbo.ls/scratch");
|
|
27
27
|
const TIMING_FUNCTIONS = ["ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"];
|
|
28
28
|
const FILL_MODES = ["none", "forwards", "backwards", "both"];
|
|
29
29
|
const DIRECTIONS = ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
30
30
|
const PLAY_STATES = ["running", "paused"];
|
|
31
31
|
const isDuration = (v) => /^[\d.]+m?s$/.test(v);
|
|
32
|
+
let _animCounter = 0;
|
|
32
33
|
const applyAnimationProps = (animation, element) => {
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const { animation: ANIMATION } = element.context && element.context.designSystem || {};
|
|
35
|
+
if ((0, import_utils.isObject)(animation)) {
|
|
36
|
+
const name = `smbls-anim-${_animCounter++}`;
|
|
37
|
+
return { animationName: (0, import_css.keyframes)(name, animation) };
|
|
38
|
+
}
|
|
39
|
+
const record = ANIMATION && ANIMATION[animation];
|
|
40
|
+
if ((0, import_utils.isObject)(record)) {
|
|
41
|
+
return (0, import_css.keyframes)(animation, record);
|
|
42
|
+
}
|
|
43
|
+
return animation;
|
|
39
44
|
};
|
|
40
45
|
const parseAnimationShorthand = (val, el) => {
|
|
41
|
-
const { ANIMATION } = el.context && el.context.designSystem || {};
|
|
46
|
+
const { animation: ANIMATION } = el.context && el.context.designSystem || {};
|
|
42
47
|
const tokens = val.split(/\s+/);
|
|
43
48
|
let name = null;
|
|
44
49
|
const durations = [];
|
|
@@ -74,24 +79,24 @@ const ANIMATION_PROPS = {
|
|
|
74
79
|
const parsed = parseAnimationShorthand(val, el);
|
|
75
80
|
return {
|
|
76
81
|
animationName: applyAnimationProps(parsed.name || val, el),
|
|
77
|
-
animationDuration: parsed.durations[0] || (0, import_scratch.getTimingByKey)(el.
|
|
78
|
-
animationDelay: parsed.durations[1] || (0, import_scratch.getTimingByKey)(el.
|
|
79
|
-
animationTimingFunction: parsed.timingFunction || (0, import_scratch.getTimingFunction)(el.
|
|
80
|
-
animationFillMode: parsed.fillMode || el.
|
|
81
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.
|
|
82
|
-
animationPlayState: parsed.playState || el.
|
|
83
|
-
animationDirection: parsed.direction || el.
|
|
82
|
+
animationDuration: parsed.durations[0] || (0, import_scratch.getTimingByKey)(el.animationDuration || "A").timing,
|
|
83
|
+
animationDelay: parsed.durations[1] || (0, import_scratch.getTimingByKey)(el.animationDelay || "0s").timing,
|
|
84
|
+
animationTimingFunction: parsed.timingFunction || (0, import_scratch.getTimingFunction)(el.animationTimingFunction || "ease"),
|
|
85
|
+
animationFillMode: parsed.fillMode || el.animationFillMode || "both",
|
|
86
|
+
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.animationIterationCount || 1,
|
|
87
|
+
animationPlayState: parsed.playState || el.animationPlayState,
|
|
88
|
+
animationDirection: parsed.direction || el.animationDirection
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
return {
|
|
87
92
|
animationName: applyAnimationProps(val, el),
|
|
88
|
-
animationDuration: (0, import_scratch.getTimingByKey)(el.
|
|
89
|
-
animationDelay: (0, import_scratch.getTimingByKey)(el.
|
|
90
|
-
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.
|
|
91
|
-
animationFillMode: el.
|
|
92
|
-
animationIterationCount: el.
|
|
93
|
-
animationPlayState: el.
|
|
94
|
-
animationDirection: el.
|
|
93
|
+
animationDuration: (0, import_scratch.getTimingByKey)(el.animationDuration || "A").timing,
|
|
94
|
+
animationDelay: (0, import_scratch.getTimingByKey)(el.animationDelay || "0s").timing,
|
|
95
|
+
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.animationTimingFunction || "ease"),
|
|
96
|
+
animationFillMode: el.animationFillMode || "both",
|
|
97
|
+
animationIterationCount: el.animationIterationCount || 1,
|
|
98
|
+
animationPlayState: el.animationPlayState,
|
|
99
|
+
animationDirection: el.animationDirection
|
|
95
100
|
};
|
|
96
101
|
},
|
|
97
102
|
animationName: (val, el) => ({
|
package/dist/cjs/props/block.js
CHANGED
|
@@ -21,17 +21,13 @@ __export(block_exports, {
|
|
|
21
21
|
BLOCK_PROPS: () => BLOCK_PROPS
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(block_exports);
|
|
24
|
-
var import_utils = require("@
|
|
24
|
+
var import_utils = require("@symbo.ls/utils");
|
|
25
25
|
var import_scratch = require("@symbo.ls/scratch");
|
|
26
26
|
const BLOCK_PROPS = {
|
|
27
|
-
show: (val
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
display: "none !important"
|
|
32
|
-
},
|
|
33
|
-
height: (val, { props }) => (0, import_scratch.transformSizeRatio)("height", val, props),
|
|
34
|
-
width: (val, { props }) => (0, import_scratch.transformSizeRatio)("width", val, props),
|
|
27
|
+
show: (val) => !val ? { display: "none !important" } : void 0,
|
|
28
|
+
hide: (val) => val ? { display: "none !important" } : void 0,
|
|
29
|
+
height: (val, el) => (0, import_scratch.transformSizeRatio)("height", val, el),
|
|
30
|
+
width: (val, el) => (0, import_scratch.transformSizeRatio)("width", val, el),
|
|
35
31
|
boxSizing: (val) => !(0, import_utils.isUndefined)(val) ? { boxSizing: val } : { boxSizing: "border-box" },
|
|
36
32
|
boxSize: (val) => {
|
|
37
33
|
if (!(0, import_utils.isString)(val)) return;
|
|
@@ -41,10 +37,10 @@ const BLOCK_PROPS = {
|
|
|
41
37
|
...(0, import_scratch.transformSize)("width", width || height)
|
|
42
38
|
};
|
|
43
39
|
},
|
|
44
|
-
inlineSize: (val,
|
|
45
|
-
blockSize: (val,
|
|
46
|
-
minWidth: (val,
|
|
47
|
-
maxWidth: (val,
|
|
40
|
+
inlineSize: (val, el) => (0, import_scratch.transformSizeRatio)("inlineSize", val, el),
|
|
41
|
+
blockSize: (val, el) => (0, import_scratch.transformSizeRatio)("blockSize", val, el),
|
|
42
|
+
minWidth: (val, el) => (0, import_scratch.transformSizeRatio)("minWidth", val, el),
|
|
43
|
+
maxWidth: (val, el) => (0, import_scratch.transformSizeRatio)("maxWidth", val, el),
|
|
48
44
|
widthRange: (val) => {
|
|
49
45
|
if (!(0, import_utils.isString)(val)) return;
|
|
50
46
|
const [minWidth, maxWidth] = val.split(" ");
|
|
@@ -53,8 +49,8 @@ const BLOCK_PROPS = {
|
|
|
53
49
|
...(0, import_scratch.transformSize)("maxWidth", maxWidth || minWidth)
|
|
54
50
|
};
|
|
55
51
|
},
|
|
56
|
-
minHeight: (val,
|
|
57
|
-
maxHeight: (val,
|
|
52
|
+
minHeight: (val, el) => (0, import_scratch.transformSizeRatio)("minHeight", val, el),
|
|
53
|
+
maxHeight: (val, el) => (0, import_scratch.transformSizeRatio)("maxHeight", val, el),
|
|
58
54
|
heightRange: (val) => {
|
|
59
55
|
if (!(0, import_utils.isString)(val)) return;
|
|
60
56
|
const [minHeight, maxHeight] = val.split(" ");
|
|
@@ -71,10 +67,10 @@ const BLOCK_PROPS = {
|
|
|
71
67
|
...(0, import_scratch.transformSizeRatio)("blockSize", blockSize || inlineSize)
|
|
72
68
|
};
|
|
73
69
|
},
|
|
74
|
-
minBlockSize: (val,
|
|
75
|
-
minInlineSize: (val,
|
|
76
|
-
maxBlockSize: (val,
|
|
77
|
-
maxInlineSize: (val,
|
|
70
|
+
minBlockSize: (val, el) => (0, import_scratch.transformSizeRatio)("minBlockSize", val, el),
|
|
71
|
+
minInlineSize: (val, el) => (0, import_scratch.transformSizeRatio)("minInlineSize", val, el),
|
|
72
|
+
maxBlockSize: (val, el) => (0, import_scratch.transformSizeRatio)("maxBlockSize", val, el),
|
|
73
|
+
maxInlineSize: (val, el) => (0, import_scratch.transformSizeRatio)("maxInlineSize", val, el),
|
|
78
74
|
minSize: (val) => {
|
|
79
75
|
if (!(0, import_utils.isString)(val)) return;
|
|
80
76
|
const [minInlineSize, minBlockSize] = val.split(" ");
|
|
@@ -91,9 +87,9 @@ const BLOCK_PROPS = {
|
|
|
91
87
|
...(0, import_scratch.transformSize)("maxBlockSize", maxBlockSize || maxInlineSize)
|
|
92
88
|
};
|
|
93
89
|
},
|
|
94
|
-
borderWidth: (val,
|
|
95
|
-
padding: (val,
|
|
96
|
-
scrollPadding: (val,
|
|
90
|
+
borderWidth: (val, el) => (0, import_scratch.transformSizeRatio)("borderWidth", val, el),
|
|
91
|
+
padding: (val, el) => (0, import_scratch.transformSizeRatio)("padding", val, el),
|
|
92
|
+
scrollPadding: (val, el) => (0, import_scratch.transformSizeRatio)("scrollPadding", val, el),
|
|
97
93
|
paddingInline: (val) => {
|
|
98
94
|
if (!(0, import_utils.isString)(val)) return;
|
|
99
95
|
const [paddingInlineStart, paddingInlineEnd] = val.split(" ");
|
|
@@ -110,21 +106,15 @@ const BLOCK_PROPS = {
|
|
|
110
106
|
...(0, import_scratch.transformSize)("paddingBlockEnd", paddingBlockEnd || paddingBlockStart)
|
|
111
107
|
};
|
|
112
108
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// maps to bottom
|
|
123
|
-
paddingInlineStart: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingInlineStart", val, props),
|
|
124
|
-
// maps to left
|
|
125
|
-
paddingInlineEnd: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingInlineEnd", val, props),
|
|
126
|
-
// maps to right
|
|
127
|
-
margin: (val, { props }) => (0, import_scratch.transformSizeRatio)("margin", val, props),
|
|
109
|
+
paddingTop: (val, el) => (0, import_scratch.transformSizeRatio)("paddingBlockStart", val, el),
|
|
110
|
+
paddingBottom: (val, el) => (0, import_scratch.transformSizeRatio)("paddingBlockEnd", val, el),
|
|
111
|
+
paddingLeft: (val, el) => (0, import_scratch.transformSizeRatio)("paddingInlineStart", val, el),
|
|
112
|
+
paddingRight: (val, el) => (0, import_scratch.transformSizeRatio)("paddingInlineEnd", val, el),
|
|
113
|
+
paddingBlockStart: (val, el) => (0, import_scratch.transformSizeRatio)("paddingBlockStart", val, el),
|
|
114
|
+
paddingBlockEnd: (val, el) => (0, import_scratch.transformSizeRatio)("paddingBlockEnd", val, el),
|
|
115
|
+
paddingInlineStart: (val, el) => (0, import_scratch.transformSizeRatio)("paddingInlineStart", val, el),
|
|
116
|
+
paddingInlineEnd: (val, el) => (0, import_scratch.transformSizeRatio)("paddingInlineEnd", val, el),
|
|
117
|
+
margin: (val, el) => (0, import_scratch.transformSizeRatio)("margin", val, el),
|
|
128
118
|
marginInline: (val) => {
|
|
129
119
|
if (!(0, import_utils.isString)(val)) return;
|
|
130
120
|
const [marginInlineStart, marginInlineEnd] = val.split(" ");
|
|
@@ -133,35 +123,33 @@ const BLOCK_PROPS = {
|
|
|
133
123
|
...(0, import_scratch.transformSize)("marginInlineEnd", marginInlineEnd || marginInlineStart)
|
|
134
124
|
};
|
|
135
125
|
},
|
|
136
|
-
marginBlock: (val,
|
|
137
|
-
if (!(0, import_utils.isString)(
|
|
138
|
-
const [marginBlockStart, marginBlockEnd] =
|
|
126
|
+
marginBlock: (val, el) => {
|
|
127
|
+
if (!(0, import_utils.isString)(el.marginBlock)) return;
|
|
128
|
+
const [marginBlockStart, marginBlockEnd] = el.marginBlock.split(" ");
|
|
139
129
|
return {
|
|
140
130
|
...(0, import_scratch.transformSize)("marginBlockStart", marginBlockStart),
|
|
141
131
|
...(0, import_scratch.transformSize)("marginBlockEnd", marginBlockEnd || marginBlockStart)
|
|
142
132
|
};
|
|
143
133
|
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
marginBlockStart: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockStart", val, props),
|
|
153
|
-
marginBlockEnd: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", val, props),
|
|
134
|
+
marginTop: (val, el) => (0, import_scratch.transformSizeRatio)("marginBlockStart", val, el),
|
|
135
|
+
marginBottom: (val, el) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", val, el),
|
|
136
|
+
marginLeft: (val, el) => (0, import_scratch.transformSizeRatio)("marginInlineStart", val, el),
|
|
137
|
+
marginRight: (val, el) => (0, import_scratch.transformSizeRatio)("marginInlineEnd", val, el),
|
|
138
|
+
marginInlineStart: (val, el) => (0, import_scratch.transformSizeRatio)("marginInlineStart", val, el),
|
|
139
|
+
marginInlineEnd: (val, el) => (0, import_scratch.transformSizeRatio)("marginInlineEnd", val, el),
|
|
140
|
+
marginBlockStart: (val, el) => (0, import_scratch.transformSizeRatio)("marginBlockStart", val, el),
|
|
141
|
+
marginBlockEnd: (val, el) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", val, el),
|
|
154
142
|
gap: (val) => ({
|
|
155
143
|
gap: (0, import_scratch.transfromGap)(val)
|
|
156
144
|
}),
|
|
157
|
-
columnGap: (val,
|
|
158
|
-
rowGap: (val,
|
|
159
|
-
flexWrap: (val
|
|
145
|
+
columnGap: (val, el) => (0, import_scratch.getSpacingBasedOnRatio)(el, "columnGap", val),
|
|
146
|
+
rowGap: (val, el) => (0, import_scratch.getSpacingBasedOnRatio)(el, "rowGap", val),
|
|
147
|
+
flexWrap: (val) => ({
|
|
160
148
|
display: "flex",
|
|
161
|
-
|
|
149
|
+
flexWrap: val
|
|
162
150
|
}),
|
|
163
|
-
flexFlow: (val,
|
|
164
|
-
const
|
|
151
|
+
flexFlow: (val, el) => {
|
|
152
|
+
const reverse = el.reverse;
|
|
165
153
|
if (!(0, import_utils.isString)(val)) return;
|
|
166
154
|
let [direction, wrap] = (val || "row").split(" ");
|
|
167
155
|
if (val.startsWith("x") || val === "row") direction = "row";
|
|
@@ -180,6 +168,6 @@ const BLOCK_PROPS = {
|
|
|
180
168
|
justifyContent
|
|
181
169
|
};
|
|
182
170
|
},
|
|
183
|
-
round: (val,
|
|
184
|
-
borderRadius: (val,
|
|
171
|
+
round: (val, el) => (0, import_scratch.transformBorderRadius)(val ?? el.borderRadius, el, "round"),
|
|
172
|
+
borderRadius: (val, el) => (0, import_scratch.transformBorderRadius)(val ?? el.round, el, "borderRadius")
|
|
185
173
|
};
|
package/dist/cjs/props/flex.js
CHANGED
|
@@ -21,11 +21,10 @@ __export(flex_exports, {
|
|
|
21
21
|
FLEX_PROPS: () => FLEX_PROPS
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(flex_exports);
|
|
24
|
-
var import_utils = require("@
|
|
24
|
+
var import_utils = require("@symbo.ls/utils");
|
|
25
25
|
const FLEX_PROPS = {
|
|
26
26
|
flow: (value, el) => {
|
|
27
|
-
const
|
|
28
|
-
const { reverse } = props;
|
|
27
|
+
const reverse = el.reverse;
|
|
29
28
|
if (!(0, import_utils.isString)(value)) return;
|
|
30
29
|
let [direction, wrap] = (value || "row").split(" ");
|
|
31
30
|
if (value.startsWith("x") || value === "row") direction = "row";
|
|
@@ -35,10 +34,10 @@ const FLEX_PROPS = {
|
|
|
35
34
|
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
36
35
|
};
|
|
37
36
|
},
|
|
38
|
-
wrap: (value,
|
|
37
|
+
wrap: (value, el) => {
|
|
39
38
|
return { display: "flex", flexWrap: value };
|
|
40
39
|
},
|
|
41
|
-
align: (value,
|
|
40
|
+
align: (value, el) => {
|
|
42
41
|
const [alignItems, justifyContent] = value.split(" ");
|
|
43
42
|
return { display: "flex", alignItems, justifyContent };
|
|
44
43
|
}
|
package/dist/cjs/props/index.js
CHANGED
|
@@ -23,30 +23,29 @@ __export(props_exports, {
|
|
|
23
23
|
default: () => props_default
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(props_exports);
|
|
26
|
-
var import_animation = require("./animation");
|
|
27
|
-
var import_block = require("./block");
|
|
28
|
-
var import_font = require("./font");
|
|
29
|
-
var import_misc = require("./misc");
|
|
30
|
-
var import_position = require("./position");
|
|
31
|
-
var import_theme = require("./theme");
|
|
32
|
-
var import_timing = require("./timing");
|
|
33
|
-
var import_flex = require("./flex");
|
|
34
|
-
var import_grid = require("./grid");
|
|
35
|
-
__reExport(props_exports, require("./animation"), module.exports);
|
|
36
|
-
__reExport(props_exports, require("./block"), module.exports);
|
|
37
|
-
__reExport(props_exports, require("./font"), module.exports);
|
|
38
|
-
__reExport(props_exports, require("./misc"), module.exports);
|
|
39
|
-
__reExport(props_exports, require("./position"), module.exports);
|
|
40
|
-
__reExport(props_exports, require("./theme"), module.exports);
|
|
41
|
-
__reExport(props_exports, require("./timing"), module.exports);
|
|
42
|
-
__reExport(props_exports, require("./flex"), module.exports);
|
|
43
|
-
__reExport(props_exports, require("./grid"), module.exports);
|
|
26
|
+
var import_animation = require("./animation.js");
|
|
27
|
+
var import_block = require("./block.js");
|
|
28
|
+
var import_font = require("./font.js");
|
|
29
|
+
var import_misc = require("./misc.js");
|
|
30
|
+
var import_position = require("./position.js");
|
|
31
|
+
var import_theme = require("./theme.js");
|
|
32
|
+
var import_timing = require("./timing.js");
|
|
33
|
+
var import_flex = require("./flex.js");
|
|
34
|
+
var import_grid = require("./grid.js");
|
|
35
|
+
__reExport(props_exports, require("./animation.js"), module.exports);
|
|
36
|
+
__reExport(props_exports, require("./block.js"), module.exports);
|
|
37
|
+
__reExport(props_exports, require("./font.js"), module.exports);
|
|
38
|
+
__reExport(props_exports, require("./misc.js"), module.exports);
|
|
39
|
+
__reExport(props_exports, require("./position.js"), module.exports);
|
|
40
|
+
__reExport(props_exports, require("./theme.js"), module.exports);
|
|
41
|
+
__reExport(props_exports, require("./timing.js"), module.exports);
|
|
42
|
+
__reExport(props_exports, require("./flex.js"), module.exports);
|
|
43
|
+
__reExport(props_exports, require("./grid.js"), module.exports);
|
|
44
44
|
const CSS_PROPS_REGISTRY = {
|
|
45
45
|
...import_animation.ANIMATION_PROPS,
|
|
46
46
|
...import_block.BLOCK_PROPS,
|
|
47
47
|
...import_font.FONT_PROPS,
|
|
48
48
|
...import_misc.MISC_PROPS,
|
|
49
|
-
...import_misc.MISC_PROPS,
|
|
50
49
|
...import_position.POSITION_PROPS,
|
|
51
50
|
...import_theme.THEME_PROPS,
|
|
52
51
|
...import_timing.TIMING_PROPS,
|
package/dist/cjs/props/misc.js
CHANGED
|
@@ -28,8 +28,15 @@ const MISC_PROPS = {
|
|
|
28
28
|
}),
|
|
29
29
|
cursor: (value, el, s, ctx) => {
|
|
30
30
|
if (!value) return;
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
31
|
+
const asset = ctx.assets && ctx.assets[value];
|
|
32
|
+
if (asset && asset.content) value = `url(${asset.content.src})`;
|
|
33
|
+
else {
|
|
34
|
+
const file = ctx.files && ctx.files[value];
|
|
35
|
+
if (file && file.content) value = `url(${file.content.src})`;
|
|
36
|
+
}
|
|
33
37
|
return { cursor: value };
|
|
34
|
-
}
|
|
38
|
+
},
|
|
39
|
+
opacity: (value) => value != null ? { opacity: String(value) } : void 0,
|
|
40
|
+
visibility: (value) => value != null ? { visibility: value } : void 0,
|
|
41
|
+
pointerEvents: (value) => value != null ? { pointerEvents: value } : void 0
|
|
35
42
|
};
|
package/dist/cjs/props/theme.js
CHANGED
|
@@ -23,17 +23,16 @@ __export(theme_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(theme_exports);
|
|
25
25
|
var import_scratch = require("@symbo.ls/scratch");
|
|
26
|
-
var import_utils = require("@
|
|
26
|
+
var import_utils = require("@symbo.ls/utils");
|
|
27
27
|
const getSystemGlobalTheme = ({ context, state }) => {
|
|
28
28
|
const theme = state?.root?.globalTheme || context.designSystem?.globalTheme;
|
|
29
29
|
return theme === "auto" ? null : theme;
|
|
30
30
|
};
|
|
31
31
|
const THEME_PROPS = {
|
|
32
32
|
theme: (val, element) => {
|
|
33
|
-
const { props } = element;
|
|
34
33
|
if (!val) return;
|
|
35
|
-
if (
|
|
36
|
-
return (0, import_scratch.getMediaTheme)(val, `@${
|
|
34
|
+
if (element.themeModifier) {
|
|
35
|
+
return (0, import_scratch.getMediaTheme)(val, `@${element.themeModifier}`);
|
|
37
36
|
}
|
|
38
37
|
return (0, import_scratch.getMediaTheme)(val);
|
|
39
38
|
},
|
|
@@ -64,8 +63,12 @@ const THEME_PROPS = {
|
|
|
64
63
|
backgroundImage: (val, element, s, ctx) => {
|
|
65
64
|
const globalTheme = getSystemGlobalTheme(element);
|
|
66
65
|
if (!val) return;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
66
|
+
const asset = ctx.assets && ctx.assets[val];
|
|
67
|
+
if (asset && asset.content) val = asset.content.src;
|
|
68
|
+
else {
|
|
69
|
+
const file = ctx.files && ctx.files[val];
|
|
70
|
+
if (file && file.content) val = file.content.src;
|
|
71
|
+
}
|
|
69
72
|
return {
|
|
70
73
|
backgroundImage: (0, import_scratch.transformBackgroundImage)(val, globalTheme)
|
|
71
74
|
};
|
|
@@ -76,7 +79,7 @@ const THEME_PROPS = {
|
|
|
76
79
|
outline: (val) => ({
|
|
77
80
|
outline: (0, import_scratch.transformBorder)(val)
|
|
78
81
|
}),
|
|
79
|
-
outlineOffset: (val,
|
|
82
|
+
outlineOffset: (val, el) => (0, import_scratch.transformSizeRatio)("outlineOffset", val, el),
|
|
80
83
|
border: (val) => ({
|
|
81
84
|
border: (0, import_scratch.transformBorder)(val)
|
|
82
85
|
}),
|
package/dist/cjs/set.js
CHANGED
|
@@ -18,12 +18,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var set_exports = {};
|
|
20
20
|
__export(set_exports, {
|
|
21
|
-
setClassname: () => setClassname
|
|
21
|
+
setClassname: () => setClassname,
|
|
22
|
+
transformClassname: () => transformClassname
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(set_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
var import_utils = require("@symbo.ls/utils");
|
|
26
|
+
var import_transform = require("./transform/index.js");
|
|
27
|
+
var import_css = require("@symbo.ls/css");
|
|
28
|
+
const transformClassname = (element) => {
|
|
29
|
+
if (!(0, import_utils.isObject)(element)) return;
|
|
30
|
+
return (0, import_transform.useCssInProps)(element, element);
|
|
31
|
+
};
|
|
32
|
+
const setClassname = (props, cssEngine) => {
|
|
33
|
+
const transform = transformClassname(props);
|
|
34
|
+
if (typeof cssEngine === "function") return cssEngine(transform);
|
|
35
|
+
return (0, import_css.css)(transform);
|
|
29
36
|
};
|
|
@@ -24,59 +24,66 @@ __export(executors_exports, {
|
|
|
24
24
|
useSelectorsAsCSS: () => useSelectorsAsCSS
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(executors_exports);
|
|
27
|
-
var import_utils = require("@
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
27
|
+
var import_utils = require("@symbo.ls/utils");
|
|
28
|
+
var import_scratch = require("@symbo.ls/scratch");
|
|
29
|
+
var import_props = require("../props/index.js");
|
|
30
|
+
var import_defaults = require("../props/defaults.js");
|
|
31
|
+
var import_transformers = require("./transformers.js");
|
|
31
32
|
const isProd = (0, import_utils.isProduction)();
|
|
32
33
|
const usePropsAsCSS = (sourceObj, element, opts) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
for (const key in sourceObj) {
|
|
43
|
-
const value = sourceObj[key];
|
|
44
|
-
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
45
|
-
const val = value.split(" ");
|
|
46
|
-
if (val.length) {
|
|
47
|
-
const CLASS = element.context.designSystem.class;
|
|
48
|
-
const result = val.reduce((acc, curr) => (0, import_utils.merge)(acc, CLASS[curr]), {});
|
|
49
|
-
obj.designSystemClass = result;
|
|
50
|
-
}
|
|
51
|
-
} else if (key === "true") {
|
|
52
|
-
const val = (0, import_utils.exec)(value, element);
|
|
53
|
-
(0, import_utils.merge)(obj, (0, import_transformers.applyTrueProps)(val, element));
|
|
54
|
-
} else if (element.classlist[key]) {
|
|
55
|
-
const originalFromClass = element.classlist[key];
|
|
56
|
-
const result = (0, import_utils.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
57
|
-
if (result) setToObj(key, result);
|
|
58
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
59
|
-
} else if (import_props.CSS_PROPS_REGISTRY[key]) {
|
|
60
|
-
let val = (0, import_utils.exec)(value, element);
|
|
61
|
-
if ((0, import_utils.isArray)(val)) {
|
|
62
|
-
val = val.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
34
|
+
const ds = element?.context?.designSystem;
|
|
35
|
+
if (ds) (0, import_scratch.pushConfig)(ds);
|
|
36
|
+
try {
|
|
37
|
+
let obj = {};
|
|
38
|
+
const rest = {};
|
|
39
|
+
const setToObj = (key, val) => {
|
|
40
|
+
if (opts.unpack) {
|
|
41
|
+
obj = { ...obj, ...val };
|
|
42
|
+
return;
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
obj[key] = val;
|
|
45
|
+
};
|
|
46
|
+
for (const key in sourceObj) {
|
|
47
|
+
const value = sourceObj[key];
|
|
48
|
+
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
49
|
+
const val = value.split(" ");
|
|
50
|
+
if (val.length) {
|
|
51
|
+
const CLASS = element.context.designSystem.class;
|
|
52
|
+
const result = val.reduce((acc, curr) => (0, import_utils.merge)(acc, CLASS[curr]), {});
|
|
53
|
+
obj.designSystemClass = result;
|
|
54
|
+
}
|
|
55
|
+
} else if (key === "true") {
|
|
56
|
+
const val = (0, import_utils.exec)(value, element);
|
|
57
|
+
(0, import_utils.merge)(obj, (0, import_transformers.applyTrueProps)(val, element));
|
|
58
|
+
} else if (element.classlist[key]) {
|
|
59
|
+
const originalFromClass = element.classlist[key];
|
|
60
|
+
const result = (0, import_utils.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
61
|
+
if (result) setToObj(key, result);
|
|
62
|
+
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
63
|
+
} else if (import_props.CSS_PROPS_REGISTRY[key]) {
|
|
64
|
+
let val = (0, import_utils.exec)(value, element);
|
|
65
|
+
if ((0, import_utils.isArray)(val)) {
|
|
66
|
+
val = val.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
67
|
+
}
|
|
68
|
+
let result = import_props.CSS_PROPS_REGISTRY[key](val, element, element.state, element.context);
|
|
69
|
+
if ((0, import_utils.isArray)(result)) result = result.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
70
|
+
if (result) setToObj(key, result);
|
|
71
|
+
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
72
|
+
} else if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
|
|
73
|
+
let result = (0, import_utils.exec)(value, element);
|
|
74
|
+
if (typeof result === "string" && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
|
|
75
|
+
result = `var(${result})`;
|
|
76
|
+
}
|
|
77
|
+
setToObj(key, { [key]: result });
|
|
78
|
+
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
79
|
+
} else {
|
|
80
|
+
rest[key] = value;
|
|
72
81
|
}
|
|
73
|
-
setToObj(key, { [key]: result });
|
|
74
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
75
|
-
} else {
|
|
76
|
-
rest[key] = value;
|
|
77
82
|
}
|
|
83
|
+
return [obj, rest];
|
|
84
|
+
} finally {
|
|
85
|
+
if (ds) (0, import_scratch.popConfig)();
|
|
78
86
|
}
|
|
79
|
-
return [obj, rest];
|
|
80
87
|
};
|
|
81
88
|
const useSelectorsAsCSS = (sourceObj, element) => {
|
|
82
89
|
const obj = {};
|
|
@@ -15,5 +15,5 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var transform_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(transform_exports);
|
|
18
|
-
__reExport(transform_exports, require("./executors"), module.exports);
|
|
19
|
-
__reExport(transform_exports, require("./transformers"), module.exports);
|
|
18
|
+
__reExport(transform_exports, require("./executors.js"), module.exports);
|
|
19
|
+
__reExport(transform_exports, require("./transformers.js"), module.exports);
|