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.
Files changed (43) hide show
  1. package/README.md +6 -22
  2. package/dist/cjs/index.js +4 -4
  3. package/dist/cjs/props/animation.js +28 -23
  4. package/dist/cjs/props/block.js +46 -58
  5. package/dist/cjs/props/flex.js +4 -5
  6. package/dist/cjs/props/index.js +18 -19
  7. package/dist/cjs/props/misc.js +10 -3
  8. package/dist/cjs/props/theme.js +10 -7
  9. package/dist/cjs/set.js +13 -6
  10. package/dist/cjs/transform/executors.js +54 -47
  11. package/dist/cjs/transform/index.js +2 -2
  12. package/dist/cjs/transform/transformers.js +69 -20
  13. package/dist/esm/index.js +4 -4
  14. package/dist/esm/props/animation.js +28 -23
  15. package/dist/esm/props/block.js +46 -58
  16. package/dist/esm/props/flex.js +4 -5
  17. package/dist/esm/props/index.js +18 -19
  18. package/dist/esm/props/misc.js +10 -3
  19. package/dist/esm/props/theme.js +10 -7
  20. package/dist/esm/set.js +12 -5
  21. package/dist/esm/transform/executors.js +54 -47
  22. package/dist/esm/transform/index.js +2 -2
  23. package/dist/esm/transform/transformers.js +69 -20
  24. package/dist/iife/index.js +230 -167
  25. package/index.js +1 -0
  26. package/package.json +13 -15
  27. package/src/index.js +4 -4
  28. package/src/props/animation.js +28 -23
  29. package/src/props/block.js +49 -57
  30. package/src/props/flex.js +4 -5
  31. package/src/props/index.js +18 -19
  32. package/src/props/misc.js +10 -3
  33. package/src/props/theme.js +10 -7
  34. package/src/set.js +11 -4
  35. package/src/transform/executors.js +60 -52
  36. package/src/transform/index.js +2 -2
  37. package/src/transform/transformers.js +85 -23
  38. package/dist/cjs/_transform.js +0 -30
  39. package/dist/cjs/emotion.js +0 -29
  40. package/dist/esm/_transform.js +0 -10
  41. package/dist/esm/emotion.js +0 -9
  42. package/src/_transform.js +0 -10
  43. 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 Emotion.
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 Emotion CSS classes for optimized rendering
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`, and deprecated v2 handlers like `$propsCollection`, `$collection`). The propertization layer in `@domql/utils/props.js` uses `CSS_SELECTOR_PREFIXES` to decide which keys to move into `props`.
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
- **The `$` prefix requires special handling:**
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.props[key]`.
114
- - **`.` prefix**: Checks `element.props[key]` / `element.state[key]` / `element[key]` first. Falls back to `context.cases[key]`.
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("./emotion"), module.exports);
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("@domql/utils");
25
- var import_emotion = require("@symbo.ls/emotion");
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 { emotion: ctxEmotion } = element.context;
34
- const { keyframes } = ctxEmotion || import_emotion.emotion;
35
- if ((0, import_utils.isObject)(animation)) return { animationName: keyframes(animation) };
36
- const { ANIMATION } = element.context && element.context.designSystem;
37
- const record = ANIMATION[animation];
38
- return keyframes(record);
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.props.animationDuration || "A").timing,
78
- animationDelay: parsed.durations[1] || (0, import_scratch.getTimingByKey)(el.props.animationDelay || "0s").timing,
79
- animationTimingFunction: parsed.timingFunction || (0, import_scratch.getTimingFunction)(el.props.animationTimingFunction || "ease"),
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
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.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
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) => ({
@@ -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("@domql/utils");
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, el, s, ctx) => !!(ctx.utils.exec(val, el, s) === false) && {
28
- display: "none !important"
29
- },
30
- hide: (val, el, s, ctx) => !!ctx.utils.exec(val, el, s) && {
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, { props }) => (0, import_scratch.transformSizeRatio)("inlineSize", val, props),
45
- blockSize: (val, { props }) => (0, import_scratch.transformSizeRatio)("blockSize", val, props),
46
- minWidth: (val, { props }) => (0, import_scratch.transformSizeRatio)("minWidth", val, props),
47
- maxWidth: (val, { props }) => (0, import_scratch.transformSizeRatio)("maxWidth", val, props),
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, { props }) => (0, import_scratch.transformSizeRatio)("minHeight", val, props),
57
- maxHeight: (val, { props }) => (0, import_scratch.transformSizeRatio)("maxHeight", val, props),
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, { props }) => (0, import_scratch.transformSizeRatio)("minBlockSize", val, props),
75
- minInlineSize: (val, { props }) => (0, import_scratch.transformSizeRatio)("minInlineSize", val, props),
76
- maxBlockSize: (val, { props }) => (0, import_scratch.transformSizeRatio)("maxBlockSize", val, props),
77
- maxInlineSize: (val, { props }) => (0, import_scratch.transformSizeRatio)("maxInlineSize", val, props),
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, { props }) => (0, import_scratch.transformSizeRatio)("borderWidth", val, props),
95
- padding: (val, { props }) => (0, import_scratch.transformSizeRatio)("padding", val, props),
96
- scrollPadding: (val, { props }) => (0, import_scratch.transformSizeRatio)("scrollPadding", val, props),
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
- // Traditional directional padding
114
- paddingTop: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingBlockStart", val, props),
115
- paddingBottom: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingBlockEnd", val, props),
116
- paddingLeft: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingInlineStart", val, props),
117
- paddingRight: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingInlineEnd", val, props),
118
- // Logical properties (for reference)
119
- paddingBlockStart: (val, { props }) => (0, import_scratch.transformSizeRatio)("paddingBlockStart", val, props),
120
- // maps to top
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),
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, { props }) => {
137
- if (!(0, import_utils.isString)(props.marginBlock)) return;
138
- const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(" ");
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
- // Traditional directional margin
145
- marginTop: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockStart", val, props),
146
- marginBottom: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginBlockEnd", val, props),
147
- marginLeft: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginInlineStart", val, props),
148
- marginRight: (val, { props }) => (0, import_scratch.transformSizeRatio)("marginInlineEnd", val, props),
149
- // Logical properties
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),
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, { props }) => (0, import_scratch.getSpacingBasedOnRatio)(props, "columnGap", val),
158
- rowGap: (val, { props }) => (0, import_scratch.getSpacingBasedOnRatio)(props, "rowGap", val),
159
- flexWrap: (val, { props }) => ({
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
- flexFlow: (val || "row").split(" ")[0] + " " + props.flexWrap
149
+ flexWrap: val
162
150
  }),
163
- flexFlow: (val, { props }) => {
164
- const { reverse } = props;
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, { props }) => (0, import_scratch.transformBorderRadius)(val || props.borderRadius, props, "round"),
184
- borderRadius: (val, { props }) => (0, import_scratch.transformBorderRadius)(val || props.round, props, "borderRadius")
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
  };
@@ -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("@domql/utils");
24
+ var import_utils = require("@symbo.ls/utils");
25
25
  const FLEX_PROPS = {
26
26
  flow: (value, el) => {
27
- const { props } = el;
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, { props }) => {
37
+ wrap: (value, el) => {
39
38
  return { display: "flex", flexWrap: value };
40
39
  },
41
- align: (value, { props }) => {
40
+ align: (value, el) => {
42
41
  const [alignItems, justifyContent] = value.split(" ");
43
42
  return { display: "flex", alignItems, justifyContent };
44
43
  }
@@ -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,
@@ -28,8 +28,15 @@ const MISC_PROPS = {
28
28
  }),
29
29
  cursor: (value, el, s, ctx) => {
30
30
  if (!value) return;
31
- const file = ctx.files && ctx.files[value];
32
- if (file && file.content) value = `url(${file.content.src})`;
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
  };
@@ -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("@domql/utils");
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 (props.themeModifier) {
36
- return (0, import_scratch.getMediaTheme)(val, `@${props.themeModifier}`);
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 file = ctx.files && ctx.files[val];
68
- if (file && file.content) val = file.content.src;
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, { props }) => (0, import_scratch.transformSizeRatio)("outlineOffset", val, props),
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 import_transform = require("./_transform");
25
- var import_emotion = require("./emotion");
26
- const setClassname = (props, emotionCss) => {
27
- const transform = (0, import_transform.transformClassname)(props);
28
- return (0, import_emotion.transformEmotion)(transform, emotionCss);
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("@domql/utils");
28
- var import_props = require("../props");
29
- var import_defaults = require("../props/defaults");
30
- var import_transformers = require("./transformers");
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
- let obj = {};
34
- const rest = {};
35
- const setToObj = (key, val) => {
36
- if (opts.unpack) {
37
- obj = { ...obj, ...val };
38
- return;
39
- }
40
- obj[key] = val;
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
- let result = import_props.CSS_PROPS_REGISTRY[key](val, element, element.state, element.context);
65
- if ((0, import_utils.isArray)(result)) result = result.reduce((a, c) => (0, import_utils.merge)(a, c), {});
66
- if (result) setToObj(key, result);
67
- if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
68
- } else if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
69
- let result = (0, import_utils.exec)(value, element);
70
- if (typeof result === "string" && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
71
- result = `var(${result})`;
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);