css-in-props 3.8.9 → 3.14.1
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/{props/defaults.js → defaults.js} +2 -2
- package/dist/cjs/index.js +19 -2
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/props/animation.js +16 -80
- package/dist/cjs/props/block.js +71 -89
- package/dist/cjs/props/font.js +8 -7
- package/dist/cjs/props/index.js +0 -32
- package/dist/cjs/props/misc.js +9 -8
- package/dist/cjs/props/position.js +17 -14
- package/dist/cjs/props/theme.js +73 -70
- package/dist/cjs/props/timing.js +11 -11
- package/dist/cjs/registry.js +39 -0
- package/dist/cjs/set.js +1 -1
- package/dist/cjs/transform.js +80 -0
- 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/props/flex.js +0 -45
- package/dist/cjs/props/grid.js +0 -39
- package/dist/cjs/transform/executors.js +0 -124
- package/dist/cjs/transform/index.js +0 -19
- package/dist/cjs/transform/transformers.js +0 -107
- package/dist/esm/_transform.js +0 -10
- package/dist/esm/emotion.js +0 -9
- package/dist/esm/index.js +0 -4
- package/dist/esm/props/animation.js +0 -101
- package/dist/esm/props/block.js +0 -171
- package/dist/esm/props/defaults.js +0 -321
- package/dist/esm/props/flex.js +0 -25
- package/dist/esm/props/font.js +0 -16
- package/dist/esm/props/grid.js +0 -19
- package/dist/esm/props/index.js +0 -35
- package/dist/esm/props/misc.js +0 -15
- package/dist/esm/props/position.js +0 -31
- package/dist/esm/props/theme.js +0 -134
- package/dist/esm/props/timing.js +0 -26
- package/dist/esm/set.js +0 -9
- package/dist/esm/transform/executors.js +0 -104
- package/dist/esm/transform/index.js +0 -2
- package/dist/esm/transform/transformers.js +0 -87
- package/dist/iife/index.js +0 -1084
- 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 v3.14, 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
|
|
@@ -20,7 +20,7 @@ __export(defaults_exports, {
|
|
|
20
20
|
DEFAULT_CSS_PROPERTIES_LIST: () => DEFAULT_CSS_PROPERTIES_LIST
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(defaults_exports);
|
|
23
|
-
const DEFAULT_CSS_PROPERTIES_LIST =
|
|
23
|
+
const DEFAULT_CSS_PROPERTIES_LIST = [
|
|
24
24
|
"accentColor",
|
|
25
25
|
"alignContent",
|
|
26
26
|
"alignItems",
|
|
@@ -337,4 +337,4 @@ const DEFAULT_CSS_PROPERTIES_LIST = /* @__PURE__ */ new Set([
|
|
|
337
337
|
"wordWrap",
|
|
338
338
|
"writingMode",
|
|
339
339
|
"zIndex"
|
|
340
|
-
]
|
|
340
|
+
];
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -14,8 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
20
|
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
exetuteClassPerComponent: () => exetuteClassPerComponent
|
|
23
|
+
});
|
|
17
24
|
module.exports = __toCommonJS(index_exports);
|
|
18
25
|
__reExport(index_exports, require("./transform"), module.exports);
|
|
26
|
+
__reExport(index_exports, require("./set"), module.exports);
|
|
19
27
|
__reExport(index_exports, require("./emotion"), module.exports);
|
|
20
|
-
__reExport(index_exports, require("./
|
|
21
|
-
__reExport(index_exports, require("./
|
|
28
|
+
__reExport(index_exports, require("./registry"), module.exports);
|
|
29
|
+
__reExport(index_exports, require("./defaults"), module.exports);
|
|
30
|
+
const exetuteClassPerComponent = (component, element) => {
|
|
31
|
+
const classObj = {};
|
|
32
|
+
if (component.class) {
|
|
33
|
+
for (const classProp in component.class) {
|
|
34
|
+
classObj[classProp] = component.class[classProp](element);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return classObj;
|
|
38
|
+
};
|
|
@@ -24,11 +24,6 @@ module.exports = __toCommonJS(animation_exports);
|
|
|
24
24
|
var import_utils = require("@domql/utils");
|
|
25
25
|
var import_emotion = require("@symbo.ls/emotion");
|
|
26
26
|
var import_scratch = require("@symbo.ls/scratch");
|
|
27
|
-
const TIMING_FUNCTIONS = ["ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"];
|
|
28
|
-
const FILL_MODES = ["none", "forwards", "backwards", "both"];
|
|
29
|
-
const DIRECTIONS = ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
30
|
-
const PLAY_STATES = ["running", "paused"];
|
|
31
|
-
const isDuration = (v) => /^[\d.]+m?s$/.test(v);
|
|
32
27
|
const applyAnimationProps = (animation, element) => {
|
|
33
28
|
const { emotion: ctxEmotion } = element.context;
|
|
34
29
|
const { keyframes } = ctxEmotion || import_emotion.emotion;
|
|
@@ -37,85 +32,26 @@ const applyAnimationProps = (animation, element) => {
|
|
|
37
32
|
const record = ANIMATION[animation];
|
|
38
33
|
return keyframes(record);
|
|
39
34
|
};
|
|
40
|
-
const parseAnimationShorthand = (val, el) => {
|
|
41
|
-
const { ANIMATION } = el.context && el.context.designSystem || {};
|
|
42
|
-
const tokens = val.split(/\s+/);
|
|
43
|
-
let name = null;
|
|
44
|
-
const durations = [];
|
|
45
|
-
let timingFunction = null;
|
|
46
|
-
let iterationCount = null;
|
|
47
|
-
let direction = null;
|
|
48
|
-
let fillMode = null;
|
|
49
|
-
let playState = null;
|
|
50
|
-
for (const token of tokens) {
|
|
51
|
-
if (ANIMATION && ANIMATION[token]) {
|
|
52
|
-
name = token;
|
|
53
|
-
} else if (isDuration(token)) {
|
|
54
|
-
durations.push(token);
|
|
55
|
-
} else if (TIMING_FUNCTIONS.includes(token) || token.startsWith("cubic-bezier") || token.startsWith("steps(")) {
|
|
56
|
-
timingFunction = token;
|
|
57
|
-
} else if (token === "infinite" || /^\d+$/.test(token)) {
|
|
58
|
-
iterationCount = token === "infinite" ? token : Number(token);
|
|
59
|
-
} else if (DIRECTIONS.includes(token)) {
|
|
60
|
-
direction = token;
|
|
61
|
-
} else if (FILL_MODES.includes(token)) {
|
|
62
|
-
fillMode = token;
|
|
63
|
-
} else if (PLAY_STATES.includes(token)) {
|
|
64
|
-
playState = token;
|
|
65
|
-
} else if (!name) {
|
|
66
|
-
name = token;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return { name, durations, timingFunction, iterationCount, direction, fillMode, playState };
|
|
70
|
-
};
|
|
71
35
|
const ANIMATION_PROPS = {
|
|
72
|
-
animation: (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
animationFillMode: parsed.fillMode || el.props.animationFillMode || "both",
|
|
81
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.props.animationIterationCount || 1,
|
|
82
|
-
animationPlayState: parsed.playState || el.props.animationPlayState,
|
|
83
|
-
animationDirection: parsed.direction || el.props.animationDirection
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
animationName: applyAnimationProps(val, el),
|
|
88
|
-
animationDuration: (0, import_scratch.getTimingByKey)(el.props.animationDuration || "A").timing,
|
|
89
|
-
animationDelay: (0, import_scratch.getTimingByKey)(el.props.animationDelay || "0s").timing,
|
|
90
|
-
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.props.animationTimingFunction || "ease"),
|
|
91
|
-
animationFillMode: el.props.animationFillMode || "both",
|
|
92
|
-
animationIterationCount: el.props.animationIterationCount || 1,
|
|
93
|
-
animationPlayState: el.props.animationPlayState,
|
|
94
|
-
animationDirection: el.props.animationDirection
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
animationName: (val, el) => ({
|
|
98
|
-
animationName: applyAnimationProps(val, el)
|
|
99
|
-
}),
|
|
100
|
-
animationDuration: (val) => ({
|
|
101
|
-
animationDuration: (0, import_scratch.getTimingByKey)(val).timing
|
|
102
|
-
}),
|
|
103
|
-
animationDelay: (val) => ({
|
|
104
|
-
animationDelay: (0, import_scratch.getTimingByKey)(val).timing
|
|
105
|
-
}),
|
|
106
|
-
animationTimingFunction: (val) => ({
|
|
107
|
-
animationTimingFunction: (0, import_scratch.getTimingFunction)(val)
|
|
36
|
+
animation: (el) => ({
|
|
37
|
+
animationName: applyAnimationProps(el.props.animation, el),
|
|
38
|
+
animationDuration: (0, import_scratch.getTimingByKey)(el.props.animationDuration || "A").timing,
|
|
39
|
+
animationDelay: (0, import_scratch.getTimingByKey)(el.props.animationDelay || "0s").timing,
|
|
40
|
+
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.props.animationTimingFunction || "ease"),
|
|
41
|
+
animationFillMode: el.props.animationFillMode || "both",
|
|
42
|
+
animationPlayState: el.props.animationPlayState,
|
|
43
|
+
animationDirection: el.props.animationDirection
|
|
108
44
|
}),
|
|
109
|
-
|
|
110
|
-
|
|
45
|
+
animationName: (el) => ({
|
|
46
|
+
animationName: applyAnimationProps(el.props.animationName, el)
|
|
111
47
|
}),
|
|
112
|
-
|
|
113
|
-
|
|
48
|
+
animationDuration: ({ props, deps }) => ({
|
|
49
|
+
animationDuration: deps.getTimingByKey(props.animationDuration).timing
|
|
114
50
|
}),
|
|
115
|
-
|
|
116
|
-
|
|
51
|
+
animationDelay: ({ props, deps }) => ({
|
|
52
|
+
animationDelay: deps.getTimingByKey(props.animationDelay).timing
|
|
117
53
|
}),
|
|
118
|
-
|
|
119
|
-
|
|
54
|
+
animationTimingFunction: ({ props, deps }) => ({
|
|
55
|
+
animationTimingFunction: deps.getTimingFunction(props.animationTimingFunction)
|
|
120
56
|
})
|
|
121
57
|
};
|
package/dist/cjs/props/block.js
CHANGED
|
@@ -24,116 +24,106 @@ module.exports = __toCommonJS(block_exports);
|
|
|
24
24
|
var import_utils = require("@domql/utils");
|
|
25
25
|
var import_scratch = require("@symbo.ls/scratch");
|
|
26
26
|
const BLOCK_PROPS = {
|
|
27
|
-
show: (
|
|
27
|
+
show: (el, s, ctx) => !!(ctx.utils.exec(el.props.show, el, s) === false) && {
|
|
28
28
|
display: "none !important"
|
|
29
29
|
},
|
|
30
|
-
hide: (
|
|
30
|
+
hide: (el, s, ctx) => !!ctx.utils.exec(el.props.hide, el, s) && {
|
|
31
31
|
display: "none !important"
|
|
32
32
|
},
|
|
33
|
-
height: (
|
|
34
|
-
width: (
|
|
35
|
-
boxSizing: (
|
|
36
|
-
boxSize: (
|
|
37
|
-
if (!(0, import_utils.isString)(
|
|
38
|
-
const [height, width] =
|
|
33
|
+
height: ({ props }) => (0, import_scratch.transformSizeRatio)("height", props),
|
|
34
|
+
width: ({ props }) => (0, import_scratch.transformSizeRatio)("width", props),
|
|
35
|
+
boxSizing: ({ props }) => !(0, import_utils.isUndefined)(props.boxSizing) ? { boxSizing: props.boxSizing } : { boxSizing: "border-box" },
|
|
36
|
+
boxSize: ({ props }) => {
|
|
37
|
+
if (!(0, import_utils.isString)(props.boxSize)) return;
|
|
38
|
+
const [height, width] = props.boxSize.split(" ");
|
|
39
39
|
return {
|
|
40
40
|
...(0, import_scratch.transformSize)("height", height),
|
|
41
41
|
...(0, import_scratch.transformSize)("width", width || height)
|
|
42
42
|
};
|
|
43
43
|
},
|
|
44
|
-
inlineSize: (
|
|
45
|
-
blockSize: (
|
|
46
|
-
minWidth: (
|
|
47
|
-
maxWidth: (
|
|
48
|
-
widthRange: (
|
|
49
|
-
if (!(0, import_utils.isString)(
|
|
50
|
-
const [minWidth, maxWidth] =
|
|
44
|
+
inlineSize: ({ props }) => (0, import_scratch.transformSizeRatio)("inlineSize", props),
|
|
45
|
+
blockSize: ({ props }) => (0, import_scratch.transformSizeRatio)("blockSize", props),
|
|
46
|
+
minWidth: ({ props }) => (0, import_scratch.transformSizeRatio)("minWidth", props),
|
|
47
|
+
maxWidth: ({ props }) => (0, import_scratch.transformSizeRatio)("maxWidth", props),
|
|
48
|
+
widthRange: ({ props }) => {
|
|
49
|
+
if (!(0, import_utils.isString)(props.widthRange)) return;
|
|
50
|
+
const [minWidth, maxWidth] = props.widthRange.split(" ");
|
|
51
51
|
return {
|
|
52
52
|
...(0, import_scratch.transformSize)("minWidth", minWidth),
|
|
53
53
|
...(0, import_scratch.transformSize)("maxWidth", maxWidth || minWidth)
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
|
-
minHeight: (
|
|
57
|
-
maxHeight: (
|
|
58
|
-
heightRange: (
|
|
59
|
-
if (!(0, import_utils.isString)(
|
|
60
|
-
const [minHeight, maxHeight] =
|
|
56
|
+
minHeight: ({ props }) => (0, import_scratch.transformSizeRatio)("minHeight", props),
|
|
57
|
+
maxHeight: ({ props }) => (0, import_scratch.transformSizeRatio)("maxHeight", props),
|
|
58
|
+
heightRange: ({ props }) => {
|
|
59
|
+
if (!(0, import_utils.isString)(props.heightRange)) return;
|
|
60
|
+
const [minHeight, maxHeight] = props.heightRange.split(" ");
|
|
61
61
|
return {
|
|
62
62
|
...(0, import_scratch.transformSize)("minHeight", minHeight),
|
|
63
63
|
...(0, import_scratch.transformSize)("maxHeight", maxHeight || minHeight)
|
|
64
64
|
};
|
|
65
65
|
},
|
|
66
|
-
size: (
|
|
67
|
-
if (!(0, import_utils.isString)(
|
|
68
|
-
const [inlineSize, blockSize] =
|
|
66
|
+
size: ({ props }) => {
|
|
67
|
+
if (!(0, import_utils.isString)(props.size)) return;
|
|
68
|
+
const [inlineSize, blockSize] = props.size.split(" ");
|
|
69
69
|
return {
|
|
70
70
|
...(0, import_scratch.transformSizeRatio)("inlineSize", inlineSize),
|
|
71
71
|
...(0, import_scratch.transformSizeRatio)("blockSize", blockSize || inlineSize)
|
|
72
72
|
};
|
|
73
73
|
},
|
|
74
|
-
minBlockSize: (
|
|
75
|
-
minInlineSize: (
|
|
76
|
-
maxBlockSize: (
|
|
77
|
-
maxInlineSize: (
|
|
78
|
-
minSize: (
|
|
79
|
-
if (!(0, import_utils.isString)(
|
|
80
|
-
const [minInlineSize, minBlockSize] =
|
|
74
|
+
minBlockSize: ({ props }) => (0, import_scratch.transformSizeRatio)("minBlockSize", props),
|
|
75
|
+
minInlineSize: ({ props }) => (0, import_scratch.transformSizeRatio)("minInlineSize", props),
|
|
76
|
+
maxBlockSize: ({ props }) => (0, import_scratch.transformSizeRatio)("maxBlockSize", props),
|
|
77
|
+
maxInlineSize: ({ props }) => (0, import_scratch.transformSizeRatio)("maxInlineSize", props),
|
|
78
|
+
minSize: ({ props }) => {
|
|
79
|
+
if (!(0, import_utils.isString)(props.minSize)) return;
|
|
80
|
+
const [minInlineSize, minBlockSize] = props.minSize.split(" ");
|
|
81
81
|
return {
|
|
82
82
|
...(0, import_scratch.transformSize)("minInlineSize", minInlineSize),
|
|
83
83
|
...(0, import_scratch.transformSize)("minBlockSize", minBlockSize || minInlineSize)
|
|
84
84
|
};
|
|
85
85
|
},
|
|
86
|
-
maxSize: (
|
|
87
|
-
if (!(0, import_utils.isString)(
|
|
88
|
-
const [maxInlineSize, maxBlockSize] =
|
|
86
|
+
maxSize: ({ props }) => {
|
|
87
|
+
if (!(0, import_utils.isString)(props.maxSize)) return;
|
|
88
|
+
const [maxInlineSize, maxBlockSize] = props.maxSize.split(" ");
|
|
89
89
|
return {
|
|
90
90
|
...(0, import_scratch.transformSize)("maxInlineSize", maxInlineSize),
|
|
91
91
|
...(0, import_scratch.transformSize)("maxBlockSize", maxBlockSize || maxInlineSize)
|
|
92
92
|
};
|
|
93
93
|
},
|
|
94
|
-
borderWidth: (
|
|
95
|
-
padding: (
|
|
96
|
-
scrollPadding: (
|
|
97
|
-
paddingInline: (
|
|
98
|
-
if (!(0, import_utils.isString)(
|
|
99
|
-
const [paddingInlineStart, paddingInlineEnd] =
|
|
94
|
+
borderWidth: ({ props }) => (0, import_scratch.transformSizeRatio)("borderWidth", props),
|
|
95
|
+
padding: ({ props }) => (0, import_scratch.transformSizeRatio)("padding", props),
|
|
96
|
+
scrollPadding: ({ props }) => (0, import_scratch.transformSizeRatio)("scrollPadding", props),
|
|
97
|
+
paddingInline: ({ props }) => {
|
|
98
|
+
if (!(0, import_utils.isString)(props.paddingInline)) return;
|
|
99
|
+
const [paddingInlineStart, paddingInlineEnd] = props.paddingInline.split(" ");
|
|
100
100
|
return {
|
|
101
101
|
...(0, import_scratch.transformSize)("paddingInlineStart", paddingInlineStart),
|
|
102
102
|
...(0, import_scratch.transformSize)("paddingInlineEnd", paddingInlineEnd || paddingInlineStart)
|
|
103
103
|
};
|
|
104
104
|
},
|
|
105
|
-
paddingBlock: (
|
|
106
|
-
if (!(0, import_utils.isString)(
|
|
107
|
-
const [paddingBlockStart, paddingBlockEnd] =
|
|
105
|
+
paddingBlock: ({ props }) => {
|
|
106
|
+
if (!(0, import_utils.isString)(props.paddingBlock)) return;
|
|
107
|
+
const [paddingBlockStart, paddingBlockEnd] = props.paddingBlock.split(" ");
|
|
108
108
|
return {
|
|
109
109
|
...(0, import_scratch.transformSize)("paddingBlockStart", paddingBlockStart),
|
|
110
110
|
...(0, import_scratch.transformSize)("paddingBlockEnd", paddingBlockEnd || paddingBlockStart)
|
|
111
111
|
};
|
|
112
112
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
paddingBlockEnd: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingBlockEnd", val, props),
|
|
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),
|
|
128
|
-
marginInline: (val) => {
|
|
129
|
-
if (!(0, import_utils.isString)(val)) return;
|
|
130
|
-
const [marginInlineStart, marginInlineEnd] = val.split(" ");
|
|
113
|
+
paddingInlineStart: ({ props }) => (0, import_scratch.transformSizeRatio)("paddingInlineStart", props),
|
|
114
|
+
paddingInlineEnd: ({ props }) => (0, import_scratch.transformSizeRatio)("paddingInlineEnd", props),
|
|
115
|
+
paddingBlockStart: ({ props }) => (0, import_scratch.transformSizeRatio)("paddingBlockStart", props),
|
|
116
|
+
paddingBlockEnd: ({ props }) => (0, import_scratch.transformSizeRatio)("paddingBlockEnd", props),
|
|
117
|
+
margin: ({ props }) => (0, import_scratch.transformSizeRatio)("margin", props),
|
|
118
|
+
marginInline: ({ props }) => {
|
|
119
|
+
if (!(0, import_utils.isString)(props.marginInline)) return;
|
|
120
|
+
const [marginInlineStart, marginInlineEnd] = props.marginInline.split(" ");
|
|
131
121
|
return {
|
|
132
122
|
...(0, import_scratch.transformSize)("marginInlineStart", marginInlineStart),
|
|
133
123
|
...(0, import_scratch.transformSize)("marginInlineEnd", marginInlineEnd || marginInlineStart)
|
|
134
124
|
};
|
|
135
125
|
},
|
|
136
|
-
marginBlock: (
|
|
126
|
+
marginBlock: ({ props }) => {
|
|
137
127
|
if (!(0, import_utils.isString)(props.marginBlock)) return;
|
|
138
128
|
const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(" ");
|
|
139
129
|
return {
|
|
@@ -141,45 +131,37 @@ const BLOCK_PROPS = {
|
|
|
141
131
|
...(0, import_scratch.transformSize)("marginBlockEnd", marginBlockEnd || marginBlockStart)
|
|
142
132
|
};
|
|
143
133
|
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
marginInlineStart: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginInlineStart", val, props),
|
|
151
|
-
marginInlineEnd: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginInlineEnd", val, props),
|
|
152
|
-
marginBlockStart: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockStart", val, props),
|
|
153
|
-
marginBlockEnd: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", val, props),
|
|
154
|
-
gap: (val) => ({
|
|
155
|
-
gap: (0, import_scratch.transfromGap)(val)
|
|
134
|
+
marginInlineStart: ({ props }) => (0, import_scratch.transformSizeRatio)("marginInlineStart", props),
|
|
135
|
+
marginInlineEnd: ({ props }) => (0, import_scratch.transformSizeRatio)("marginInlineEnd", props),
|
|
136
|
+
marginBlockStart: ({ props }) => (0, import_scratch.transformSizeRatio)("marginBlockStart", props),
|
|
137
|
+
marginBlockEnd: ({ props }) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", props),
|
|
138
|
+
gap: ({ props }) => ({
|
|
139
|
+
gap: (0, import_scratch.transfromGap)(props.gap)
|
|
156
140
|
}),
|
|
157
|
-
columnGap: (
|
|
158
|
-
rowGap: (
|
|
159
|
-
flexWrap: (
|
|
141
|
+
columnGap: ({ props }) => (0, import_scratch.getSpacingBasedOnRatio)(props, "columnGap"),
|
|
142
|
+
rowGap: ({ props }) => (0, import_scratch.getSpacingBasedOnRatio)(props, "rowGap"),
|
|
143
|
+
flexWrap: ({ props }) => ({
|
|
160
144
|
display: "flex",
|
|
161
|
-
flexFlow: (
|
|
145
|
+
flexFlow: (props.flexFlow || "row").split(" ")[0] + " " + props.flexWrap
|
|
162
146
|
}),
|
|
163
|
-
flexFlow: (
|
|
164
|
-
const { reverse } = props;
|
|
165
|
-
if (!(0, import_utils.isString)(
|
|
166
|
-
let [direction, wrap] = (
|
|
167
|
-
if (
|
|
168
|
-
if (
|
|
147
|
+
flexFlow: ({ props }) => {
|
|
148
|
+
const { flexFlow, reverse } = props;
|
|
149
|
+
if (!(0, import_utils.isString)(flexFlow)) return;
|
|
150
|
+
let [direction, wrap] = (flexFlow || "row").split(" ");
|
|
151
|
+
if (flexFlow.startsWith("x") || flexFlow === "row") direction = "row";
|
|
152
|
+
if (flexFlow.startsWith("y") || flexFlow === "column") direction = "column";
|
|
169
153
|
return {
|
|
170
154
|
display: "flex",
|
|
171
155
|
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
172
156
|
};
|
|
173
157
|
},
|
|
174
|
-
flexAlign: (
|
|
175
|
-
if (!(0, import_utils.isString)(
|
|
176
|
-
const [alignItems, justifyContent] =
|
|
158
|
+
flexAlign: ({ props }) => {
|
|
159
|
+
if (!(0, import_utils.isString)(props.flexAlign)) return;
|
|
160
|
+
const [alignItems, justifyContent] = props.flexAlign.split(" ");
|
|
177
161
|
return {
|
|
178
162
|
display: "flex",
|
|
179
163
|
alignItems,
|
|
180
164
|
justifyContent
|
|
181
165
|
};
|
|
182
|
-
}
|
|
183
|
-
round: (val, { props }) => (0, import_scratch.transformBorderRadius)(val || props.borderRadius, props, "round"),
|
|
184
|
-
borderRadius: (val, { props }) => (0, import_scratch.transformBorderRadius)(val || props.round, props, "borderRadius")
|
|
166
|
+
}
|
|
185
167
|
};
|
package/dist/cjs/props/font.js
CHANGED
|
@@ -23,14 +23,15 @@ __export(font_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(font_exports);
|
|
24
24
|
var import_scratch = require("@symbo.ls/scratch");
|
|
25
25
|
const FONT_PROPS = {
|
|
26
|
-
fontSize: (
|
|
27
|
-
|
|
26
|
+
fontSize: (el) => {
|
|
27
|
+
const { props } = el;
|
|
28
|
+
return props.fontSize ? (0, import_scratch.getFontSizeByKey)(props.fontSize) : null;
|
|
28
29
|
},
|
|
29
|
-
fontFamily: (
|
|
30
|
-
fontFamily: (0, import_scratch.getFontFamily)(
|
|
30
|
+
fontFamily: ({ props }) => ({
|
|
31
|
+
fontFamily: (0, import_scratch.getFontFamily)(props.fontFamily) || props.fontFamily
|
|
31
32
|
}),
|
|
32
|
-
fontWeight: (
|
|
33
|
-
fontWeight:
|
|
34
|
-
fontVariationSettings: '"wght" ' +
|
|
33
|
+
fontWeight: ({ props }) => ({
|
|
34
|
+
fontWeight: props.fontWeight,
|
|
35
|
+
fontVariationSettings: '"wght" ' + props.fontWeight
|
|
35
36
|
})
|
|
36
37
|
};
|
package/dist/cjs/props/index.js
CHANGED
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -18,20 +14,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
16
|
var props_exports = {};
|
|
21
|
-
__export(props_exports, {
|
|
22
|
-
CSS_PROPS_REGISTRY: () => CSS_PROPS_REGISTRY,
|
|
23
|
-
default: () => props_default
|
|
24
|
-
});
|
|
25
17
|
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
18
|
__reExport(props_exports, require("./animation"), module.exports);
|
|
36
19
|
__reExport(props_exports, require("./block"), module.exports);
|
|
37
20
|
__reExport(props_exports, require("./font"), module.exports);
|
|
@@ -39,18 +22,3 @@ __reExport(props_exports, require("./misc"), module.exports);
|
|
|
39
22
|
__reExport(props_exports, require("./position"), module.exports);
|
|
40
23
|
__reExport(props_exports, require("./theme"), module.exports);
|
|
41
24
|
__reExport(props_exports, require("./timing"), module.exports);
|
|
42
|
-
__reExport(props_exports, require("./flex"), module.exports);
|
|
43
|
-
__reExport(props_exports, require("./grid"), module.exports);
|
|
44
|
-
const CSS_PROPS_REGISTRY = {
|
|
45
|
-
...import_animation.ANIMATION_PROPS,
|
|
46
|
-
...import_block.BLOCK_PROPS,
|
|
47
|
-
...import_font.FONT_PROPS,
|
|
48
|
-
...import_misc.MISC_PROPS,
|
|
49
|
-
...import_misc.MISC_PROPS,
|
|
50
|
-
...import_position.POSITION_PROPS,
|
|
51
|
-
...import_theme.THEME_PROPS,
|
|
52
|
-
...import_timing.TIMING_PROPS,
|
|
53
|
-
...import_flex.FLEX_PROPS,
|
|
54
|
-
...import_grid.GRID_PROPS
|
|
55
|
-
};
|
|
56
|
-
var props_default = CSS_PROPS_REGISTRY;
|
package/dist/cjs/props/misc.js
CHANGED
|
@@ -22,14 +22,15 @@ __export(misc_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(misc_exports);
|
|
24
24
|
const MISC_PROPS = {
|
|
25
|
-
overflow: (
|
|
26
|
-
overflow:
|
|
25
|
+
overflow: ({ props, deps }) => !deps.isUndefined(props.overflow) && {
|
|
26
|
+
overflow: props.overflow,
|
|
27
27
|
scrollBehavior: "smooth"
|
|
28
|
-
}
|
|
29
|
-
cursor: (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
},
|
|
29
|
+
cursor: (el, s, ctx) => {
|
|
30
|
+
let val = el.props.cursor;
|
|
31
|
+
if (!val) return;
|
|
32
|
+
const file = ctx.files && ctx.files[val];
|
|
33
|
+
if (file && file.content) val = `url(${file.content.src})`;
|
|
34
|
+
return { cursor: val };
|
|
34
35
|
}
|
|
35
36
|
};
|
|
@@ -23,26 +23,29 @@ __export(position_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(position_exports);
|
|
24
24
|
var import_scratch = require("@symbo.ls/scratch");
|
|
25
25
|
const POSITION_PROPS = {
|
|
26
|
-
inset: (
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
26
|
+
inset: ({ props, context }) => {
|
|
27
|
+
const { inset } = props;
|
|
28
|
+
if (context.utils.isNumber(inset)) return { inset };
|
|
29
|
+
if (!context.utils.isString(inset)) return;
|
|
30
|
+
return { inset: inset.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k).join(" ") };
|
|
30
31
|
},
|
|
31
|
-
left: (
|
|
32
|
-
top: (
|
|
33
|
-
right: (
|
|
34
|
-
bottom: (
|
|
35
|
-
verticalInset: (
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
left: ({ props }) => (0, import_scratch.getSpacingByKey)(props.left, "left"),
|
|
33
|
+
top: ({ props }) => (0, import_scratch.getSpacingByKey)(props.top, "top"),
|
|
34
|
+
right: ({ props }) => (0, import_scratch.getSpacingByKey)(props.right, "right"),
|
|
35
|
+
bottom: ({ props }) => (0, import_scratch.getSpacingByKey)(props.bottom, "bottom"),
|
|
36
|
+
verticalInset: ({ props }) => {
|
|
37
|
+
const { verticalInset } = props;
|
|
38
|
+
if (typeof verticalInset !== "string") return;
|
|
39
|
+
const vi = verticalInset.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k);
|
|
38
40
|
return {
|
|
39
41
|
top: vi[0],
|
|
40
42
|
bottom: vi[1] || vi[0]
|
|
41
43
|
};
|
|
42
44
|
},
|
|
43
|
-
horizontalInset: (
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
horizontalInset: ({ props }) => {
|
|
46
|
+
const { horizontalInset } = props;
|
|
47
|
+
if (typeof horizontalInset !== "string") return;
|
|
48
|
+
const vi = horizontalInset.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k);
|
|
46
49
|
return {
|
|
47
50
|
left: vi[0],
|
|
48
51
|
right: vi[1] || vi[0]
|