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.
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/package.json CHANGED
@@ -2,20 +2,18 @@
2
2
  "name": "css-in-props",
3
3
  "description": "Utilize props as CSS methods",
4
4
  "author": "symbo.ls",
5
- "version": "3.8.9",
5
+ "version": "3.14.0",
6
6
  "repository": "https://github.com/symbo-ls/smbls",
7
7
  "type": "module",
8
- "module": "./dist/esm/index.js",
8
+ "module": "./index.js",
9
9
  "unpkg": "./dist/iife/index.js",
10
10
  "jsdelivr": "./dist/iife/index.js",
11
- "main": "./dist/cjs/index.js",
11
+ "main": "./index.js",
12
12
  "exports": {
13
- ".": {
14
- "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
16
- },
13
+ ".": "./index.js",
17
14
  "./src/*": "./src/*.js",
18
- "./src/props": "./src/props/index.js"
15
+ "./src/props": "./src/props/index.js",
16
+ "./package.json": "./package.json"
19
17
  },
20
18
  "source": "src/index.js",
21
19
  "publishConfig": {
@@ -23,9 +21,9 @@
23
21
  },
24
22
  "scripts": {
25
23
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
26
- "build:esm": "cross-env NODE_ENV=$NODE_ENV esbuild $(find src -name '*.js') --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
27
- "build:cjs": "cross-env NODE_ENV=$NODE_ENV esbuild $(find src -name '*.js') --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
28
- "build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild src/index.js --bundle --target=es2020 --format=iife --global-name=CssInProps --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV --external:@symbo.ls/* --external:@domql/* --external:smbls",
24
+ "build:esm": "NODE_ENV=$NODE_ENV esbuild $(find src -name '*.js') --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
25
+ "build:cjs": "NODE_ENV=$NODE_ENV esbuild $(find src -name '*.js') --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
26
+ "build:iife": "NODE_ENV=$NODE_ENV esbuild src/index.js --bundle --target=es2020 --format=iife --global-name=CssInProps --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV --external:@symbo.ls/* --external:@symbo.ls/* --external:smbls",
29
27
  "build": "node ../../build/build.js",
30
28
  "prepublish": "npm run build && npm run copy:package:cjs"
31
29
  },
@@ -35,12 +33,12 @@
35
33
  "src"
36
34
  ],
37
35
  "dependencies": {
38
- "@domql/utils": "^3.8.9",
39
- "@symbo.ls/emotion": "^3.8.9",
40
- "@symbo.ls/scratch": "^3.8.9"
36
+ "@symbo.ls/css": "^3.14.0",
37
+ "@symbo.ls/utils": "^3.14.0",
38
+ "@symbo.ls/scratch": "^3.14.0"
41
39
  },
42
40
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
43
- "browser": "./dist/esm/index.js",
41
+ "browser": "./index.js",
44
42
  "sideEffects": false,
45
43
  "devDependencies": {
46
44
  "@babel/core": "^7.29.0"
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- export * from './transform'
4
- export * from './emotion'
5
- export * from './props'
6
- export * from './props/defaults'
3
+ export * from './transform/index.js'
4
+ export * from './set.js'
5
+ export * from './props/index.js'
6
+ export * from './props/defaults.js'
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { isObject, isString } from '@domql/utils'
4
- import { emotion } from '@symbo.ls/emotion'
3
+ import { isObject, isString } from '@symbo.ls/utils'
4
+ import { keyframes as cssKeyframes } from '@symbo.ls/css'
5
5
  import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
6
6
 
7
7
  const TIMING_FUNCTIONS = ['ease', 'linear', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end']
@@ -10,13 +10,18 @@ const DIRECTIONS = ['normal', 'reverse', 'alternate', 'alternate-reverse']
10
10
  const PLAY_STATES = ['running', 'paused']
11
11
  const isDuration = v => /^[\d.]+m?s$/.test(v)
12
12
 
13
+ let _animCounter = 0
13
14
  const applyAnimationProps = (animation, element) => {
14
- const { emotion: ctxEmotion } = element.context
15
- const { keyframes } = ctxEmotion || emotion
16
- if (isObject(animation)) return { animationName: keyframes(animation) }
17
- const { ANIMATION } = element.context && element.context.designSystem
18
- const record = ANIMATION[animation]
19
- return keyframes(record)
15
+ const { animation: ANIMATION } = (element.context && element.context.designSystem) || {}
16
+ if (isObject(animation)) {
17
+ const name = `smbls-anim-${_animCounter++}`
18
+ return { animationName: cssKeyframes(name, animation) }
19
+ }
20
+ const record = ANIMATION && ANIMATION[animation]
21
+ if (isObject(record)) {
22
+ return cssKeyframes(animation, record)
23
+ }
24
+ return animation
20
25
  }
21
26
 
22
27
  /**
@@ -25,7 +30,7 @@ const applyAnimationProps = (animation, element) => {
25
30
  * Other tokens are classified by type: duration, timing-function, iteration-count, etc.
26
31
  */
27
32
  const parseAnimationShorthand = (val, el) => {
28
- const { ANIMATION } = el.context && el.context.designSystem || {}
33
+ const { animation: ANIMATION } = el.context && el.context.designSystem || {}
29
34
  const tokens = val.split(/\s+/)
30
35
  let name = null
31
36
  const durations = []
@@ -66,25 +71,25 @@ export const ANIMATION_PROPS = {
66
71
  const parsed = parseAnimationShorthand(val, el)
67
72
  return {
68
73
  animationName: applyAnimationProps(parsed.name || val, el),
69
- animationDuration: parsed.durations[0] || getTimingByKey(el.props.animationDuration || 'A').timing,
70
- animationDelay: parsed.durations[1] || getTimingByKey(el.props.animationDelay || '0s').timing,
71
- animationTimingFunction: parsed.timingFunction || getTimingFunction(el.props.animationTimingFunction || 'ease'),
72
- animationFillMode: parsed.fillMode || el.props.animationFillMode || 'both',
73
- animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : (el.props.animationIterationCount || 1),
74
- animationPlayState: parsed.playState || el.props.animationPlayState,
75
- animationDirection: parsed.direction || el.props.animationDirection
74
+ animationDuration: parsed.durations[0] || getTimingByKey(el.animationDuration || 'A').timing,
75
+ animationDelay: parsed.durations[1] || getTimingByKey(el.animationDelay || '0s').timing,
76
+ animationTimingFunction: parsed.timingFunction || getTimingFunction(el.animationTimingFunction || 'ease'),
77
+ animationFillMode: parsed.fillMode || el.animationFillMode || 'both',
78
+ animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : (el.animationIterationCount || 1),
79
+ animationPlayState: parsed.playState || el.animationPlayState,
80
+ animationDirection: parsed.direction || el.animationDirection
76
81
  }
77
82
  }
78
83
  // Single name (no spaces) — original behavior
79
84
  return {
80
85
  animationName: applyAnimationProps(val, el),
81
- animationDuration: getTimingByKey(el.props.animationDuration || 'A').timing,
82
- animationDelay: getTimingByKey(el.props.animationDelay || '0s').timing,
83
- animationTimingFunction: getTimingFunction(el.props.animationTimingFunction || 'ease'),
84
- animationFillMode: el.props.animationFillMode || 'both',
85
- animationIterationCount: el.props.animationIterationCount || 1,
86
- animationPlayState: el.props.animationPlayState,
87
- animationDirection: el.props.animationDirection
86
+ animationDuration: getTimingByKey(el.animationDuration || 'A').timing,
87
+ animationDelay: getTimingByKey(el.animationDelay || '0s').timing,
88
+ animationTimingFunction: getTimingFunction(el.animationTimingFunction || 'ease'),
89
+ animationFillMode: el.animationFillMode || 'both',
90
+ animationIterationCount: el.animationIterationCount || 1,
91
+ animationPlayState: el.animationPlayState,
92
+ animationDirection: el.animationDirection
88
93
  }
89
94
  },
90
95
  animationName: (val, el) => ({
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { isUndefined, isString } from '@domql/utils'
3
+ import { isUndefined, isString } from '@symbo.ls/utils'
4
4
 
5
5
  import {
6
6
  getSpacingBasedOnRatio,
@@ -11,16 +11,12 @@ import {
11
11
  } from '@symbo.ls/scratch'
12
12
 
13
13
  export const BLOCK_PROPS = {
14
- show: (val, el, s, ctx) => !!(ctx.utils.exec(val, el, s) === false) && ({
15
- display: 'none !important'
16
- }),
14
+ show: (val) => !val ? ({ display: 'none !important' }) : undefined,
17
15
 
18
- hide: (val, el, s, ctx) => !!ctx.utils.exec(val, el, s) && ({
19
- display: 'none !important'
20
- }),
16
+ hide: (val) => val ? ({ display: 'none !important' }) : undefined,
21
17
 
22
- height: (val, { props }) => transformSizeRatio('height', val, props),
23
- width: (val, { props }) => transformSizeRatio('width', val, props),
18
+ height: (val, el) => transformSizeRatio('height', val, el),
19
+ width: (val, el) => transformSizeRatio('width', val, el),
24
20
 
25
21
  boxSizing: (val) => !isUndefined(val)
26
22
  ? ({ boxSizing: val })
@@ -35,11 +31,11 @@ export const BLOCK_PROPS = {
35
31
  }
36
32
  },
37
33
 
38
- inlineSize: (val, { props }) => transformSizeRatio('inlineSize', val, props),
39
- blockSize: (val, { props }) => transformSizeRatio('blockSize', val, props),
34
+ inlineSize: (val, el) => transformSizeRatio('inlineSize', val, el),
35
+ blockSize: (val, el) => transformSizeRatio('blockSize', val, el),
40
36
 
41
- minWidth: (val, { props }) => transformSizeRatio('minWidth', val, props),
42
- maxWidth: (val, { props }) => transformSizeRatio('maxWidth', val, props),
37
+ minWidth: (val, el) => transformSizeRatio('minWidth', val, el),
38
+ maxWidth: (val, el) => transformSizeRatio('maxWidth', val, el),
43
39
  widthRange: (val) => {
44
40
  if (!isString(val)) return
45
41
  const [minWidth, maxWidth] = val.split(' ')
@@ -49,8 +45,8 @@ export const BLOCK_PROPS = {
49
45
  }
50
46
  },
51
47
 
52
- minHeight: (val, { props }) => transformSizeRatio('minHeight', val, props),
53
- maxHeight: (val, { props }) => transformSizeRatio('maxHeight', val, props),
48
+ minHeight: (val, el) => transformSizeRatio('minHeight', val, el),
49
+ maxHeight: (val, el) => transformSizeRatio('maxHeight', val, el),
54
50
  heightRange: (val) => {
55
51
  if (!isString(val)) return
56
52
  const [minHeight, maxHeight] = val.split(' ')
@@ -69,11 +65,11 @@ export const BLOCK_PROPS = {
69
65
  }
70
66
  },
71
67
 
72
- minBlockSize: (val, { props }) => transformSizeRatio('minBlockSize', val, props),
73
- minInlineSize: (val, { props }) => transformSizeRatio('minInlineSize', val, props),
68
+ minBlockSize: (val, el) => transformSizeRatio('minBlockSize', val, el),
69
+ minInlineSize: (val, el) => transformSizeRatio('minInlineSize', val, el),
74
70
 
75
- maxBlockSize: (val, { props }) => transformSizeRatio('maxBlockSize', val, props),
76
- maxInlineSize: (val, { props }) => transformSizeRatio('maxInlineSize', val, props),
71
+ maxBlockSize: (val, el) => transformSizeRatio('maxBlockSize', val, el),
72
+ maxInlineSize: (val, el) => transformSizeRatio('maxInlineSize', val, el),
77
73
 
78
74
  minSize: (val) => {
79
75
  if (!isString(val)) return
@@ -93,10 +89,10 @@ export const BLOCK_PROPS = {
93
89
  }
94
90
  },
95
91
 
96
- borderWidth: (val, { props }) => transformSizeRatio('borderWidth', val, props),
92
+ borderWidth: (val, el) => transformSizeRatio('borderWidth', val, el),
97
93
 
98
- padding: (val, { props }) => transformSizeRatio('padding', val, props),
99
- scrollPadding: (val, { props }) => transformSizeRatio('scrollPadding', val, props),
94
+ padding: (val, el) => transformSizeRatio('padding', val, el),
95
+ scrollPadding: (val, el) => transformSizeRatio('scrollPadding', val, el),
100
96
  paddingInline: (val) => {
101
97
  if (!isString(val)) return
102
98
  const [paddingInlineStart, paddingInlineEnd] = val.split(' ')
@@ -113,19 +109,17 @@ export const BLOCK_PROPS = {
113
109
  ...transformSize('paddingBlockEnd', paddingBlockEnd || paddingBlockStart)
114
110
  }
115
111
  },
116
- // Traditional directional padding
117
- paddingTop: (val, { props }) => transformSizeRatio('paddingBlockStart', val, props),
118
- paddingBottom: (val, { props }) => transformSizeRatio('paddingBlockEnd', val, props),
119
- paddingLeft: (val, { props }) => transformSizeRatio('paddingInlineStart', val, props),
120
- paddingRight: (val, { props }) => transformSizeRatio('paddingInlineEnd', val, props),
121
-
122
- // Logical properties (for reference)
123
- paddingBlockStart: (val, { props }) => transformSizeRatio('paddingBlockStart', val, props), // maps to top
124
- paddingBlockEnd: (val, { props }) => transformSizeRatio('paddingBlockEnd', val, props), // maps to bottom
125
- paddingInlineStart: (val, { props }) => transformSizeRatio('paddingInlineStart', val, props), // maps to left
126
- paddingInlineEnd: (val, { props }) => transformSizeRatio('paddingInlineEnd', val, props), // maps to right
127
-
128
- margin: (val, { props }) => transformSizeRatio('margin', val, props),
112
+ paddingTop: (val, el) => transformSizeRatio('paddingBlockStart', val, el),
113
+ paddingBottom: (val, el) => transformSizeRatio('paddingBlockEnd', val, el),
114
+ paddingLeft: (val, el) => transformSizeRatio('paddingInlineStart', val, el),
115
+ paddingRight: (val, el) => transformSizeRatio('paddingInlineEnd', val, el),
116
+
117
+ paddingBlockStart: (val, el) => transformSizeRatio('paddingBlockStart', val, el),
118
+ paddingBlockEnd: (val, el) => transformSizeRatio('paddingBlockEnd', val, el),
119
+ paddingInlineStart: (val, el) => transformSizeRatio('paddingInlineStart', val, el),
120
+ paddingInlineEnd: (val, el) => transformSizeRatio('paddingInlineEnd', val, el),
121
+
122
+ margin: (val, el) => transformSizeRatio('margin', val, el),
129
123
  marginInline: (val) => {
130
124
  if (!isString(val)) return
131
125
  const [marginInlineStart, marginInlineEnd] = val.split(' ')
@@ -134,39 +128,37 @@ export const BLOCK_PROPS = {
134
128
  ...transformSize('marginInlineEnd', marginInlineEnd || marginInlineStart)
135
129
  }
136
130
  },
137
- marginBlock: (val, { props }) => {
138
- if (!isString(props.marginBlock)) return
139
- const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(' ')
131
+ marginBlock: (val, el) => {
132
+ if (!isString(el.marginBlock)) return
133
+ const [marginBlockStart, marginBlockEnd] = el.marginBlock.split(' ')
140
134
  return {
141
135
  ...transformSize('marginBlockStart', marginBlockStart),
142
136
  ...transformSize('marginBlockEnd', marginBlockEnd || marginBlockStart)
143
137
  }
144
138
  },
145
- // Traditional directional margin
146
- marginTop: (val, { props }) => transformSizeRatio('marginBlockStart', val, props),
147
- marginBottom: (val, { props }) => transformSizeRatio('marginBlockEnd', val, props),
148
- marginLeft: (val, { props }) => transformSizeRatio('marginInlineStart', val, props),
149
- marginRight: (val, { props }) => transformSizeRatio('marginInlineEnd', val, props),
150
-
151
- // Logical properties
152
- marginInlineStart: (val, { props }) => transformSizeRatio('marginInlineStart', val, props),
153
- marginInlineEnd: (val, { props }) => transformSizeRatio('marginInlineEnd', val, props),
154
- marginBlockStart: (val, { props }) => transformSizeRatio('marginBlockStart', val, props),
155
- marginBlockEnd: (val, { props }) => transformSizeRatio('marginBlockEnd', val, props),
139
+ marginTop: (val, el) => transformSizeRatio('marginBlockStart', val, el),
140
+ marginBottom: (val, el) => transformSizeRatio('marginBlockEnd', val, el),
141
+ marginLeft: (val, el) => transformSizeRatio('marginInlineStart', val, el),
142
+ marginRight: (val, el) => transformSizeRatio('marginInlineEnd', val, el),
143
+
144
+ marginInlineStart: (val, el) => transformSizeRatio('marginInlineStart', val, el),
145
+ marginInlineEnd: (val, el) => transformSizeRatio('marginInlineEnd', val, el),
146
+ marginBlockStart: (val, el) => transformSizeRatio('marginBlockStart', val, el),
147
+ marginBlockEnd: (val, el) => transformSizeRatio('marginBlockEnd', val, el),
156
148
 
157
149
  gap: (val) => ({
158
150
  gap: transfromGap(val)
159
151
  }),
160
152
 
161
- columnGap: (val, { props }) => getSpacingBasedOnRatio(props, 'columnGap', val),
162
- rowGap: (val, { props }) => getSpacingBasedOnRatio(props, 'rowGap', val),
153
+ columnGap: (val, el) => getSpacingBasedOnRatio(el, 'columnGap', val),
154
+ rowGap: (val, el) => getSpacingBasedOnRatio(el, 'rowGap', val),
163
155
 
164
- flexWrap: (val, { props }) => ({
156
+ flexWrap: (val) => ({
165
157
  display: 'flex',
166
- flexFlow: (val || 'row').split(' ')[0] + ' ' + props.flexWrap
158
+ flexWrap: val
167
159
  }),
168
- flexFlow: (val, { props }) => {
169
- const { reverse } = props
160
+ flexFlow: (val, el) => {
161
+ const reverse = el.reverse
170
162
  if (!isString(val)) return
171
163
  let [direction, wrap] = (val || 'row').split(' ')
172
164
  if (val.startsWith('x') || val === 'row') direction = 'row'
@@ -186,6 +178,6 @@ export const BLOCK_PROPS = {
186
178
  }
187
179
  },
188
180
 
189
- round: (val, { props }) => transformBorderRadius(val || props.borderRadius, props, 'round'),
190
- borderRadius: (val, { props }) => transformBorderRadius(val || props.round, props, 'borderRadius')
181
+ round: (val, el) => transformBorderRadius(val ?? el.borderRadius, el, 'round'),
182
+ borderRadius: (val, el) => transformBorderRadius(val ?? el.round, el, 'borderRadius')
191
183
  }
package/src/props/flex.js CHANGED
@@ -1,11 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { isString } from '@domql/utils'
3
+ import { isString } from '@symbo.ls/utils'
4
4
 
5
5
  export const FLEX_PROPS = {
6
6
  flow: (value, el) => {
7
- const { props } = el
8
- const { reverse } = props
7
+ const reverse = el.reverse
9
8
  if (!isString(value)) return
10
9
  let [direction, wrap] = (value || 'row').split(' ')
11
10
  if (value.startsWith('x') || value === 'row') direction = 'row'
@@ -20,11 +19,11 @@ export const FLEX_PROPS = {
20
19
  }
21
20
  },
22
21
 
23
- wrap: (value, { props }) => {
22
+ wrap: (value, el) => {
24
23
  return { display: 'flex', flexWrap: value }
25
24
  },
26
25
 
27
- align: (value, { props }) => {
26
+ align: (value, el) => {
28
27
  const [alignItems, justifyContent] = value.split(' ')
29
28
  return { display: 'flex', alignItems, justifyContent }
30
29
  }
@@ -1,31 +1,30 @@
1
1
  'use strict'
2
2
 
3
- import { ANIMATION_PROPS } from './animation'
4
- import { BLOCK_PROPS } from './block'
5
- import { FONT_PROPS } from './font'
6
- import { MISC_PROPS } from './misc'
7
- import { POSITION_PROPS } from './position'
8
- import { THEME_PROPS } from './theme'
9
- import { TIMING_PROPS } from './timing'
10
- import { FLEX_PROPS } from './flex'
11
- import { GRID_PROPS } from './grid'
3
+ import { ANIMATION_PROPS } from './animation.js'
4
+ import { BLOCK_PROPS } from './block.js'
5
+ import { FONT_PROPS } from './font.js'
6
+ import { MISC_PROPS } from './misc.js'
7
+ import { POSITION_PROPS } from './position.js'
8
+ import { THEME_PROPS } from './theme.js'
9
+ import { TIMING_PROPS } from './timing.js'
10
+ import { FLEX_PROPS } from './flex.js'
11
+ import { GRID_PROPS } from './grid.js'
12
12
 
13
- export * from './animation'
14
- export * from './block'
15
- export * from './font'
16
- export * from './misc'
17
- export * from './position'
18
- export * from './theme'
19
- export * from './timing'
20
- export * from './flex'
21
- export * from './grid'
13
+ export * from './animation.js'
14
+ export * from './block.js'
15
+ export * from './font.js'
16
+ export * from './misc.js'
17
+ export * from './position.js'
18
+ export * from './theme.js'
19
+ export * from './timing.js'
20
+ export * from './flex.js'
21
+ export * from './grid.js'
22
22
 
23
23
  export const CSS_PROPS_REGISTRY = {
24
24
  ...ANIMATION_PROPS,
25
25
  ...BLOCK_PROPS,
26
26
  ...FONT_PROPS,
27
27
  ...MISC_PROPS,
28
- ...MISC_PROPS,
29
28
  ...POSITION_PROPS,
30
29
  ...THEME_PROPS,
31
30
  ...TIMING_PROPS,
package/src/props/misc.js CHANGED
@@ -8,9 +8,16 @@ export const MISC_PROPS = {
8
8
  cursor: (value, el, s, ctx) => {
9
9
  if (!value) return
10
10
 
11
- const file = ctx.files && ctx.files[value]
12
- if (file && file.content) value = `url(${file.content.src})`
11
+ const asset = ctx.assets && ctx.assets[value]
12
+ if (asset && asset.content) value = `url(${asset.content.src})`
13
+ else {
14
+ const file = ctx.files && ctx.files[value]
15
+ if (file && file.content) value = `url(${file.content.src})`
16
+ }
13
17
 
14
18
  return ({ cursor: value })
15
- }
19
+ },
20
+ opacity: (value) => value != null ? ({ opacity: String(value) }) : undefined,
21
+ visibility: (value) => value != null ? ({ visibility: value }) : undefined,
22
+ pointerEvents: (value) => value != null ? ({ pointerEvents: value }) : undefined
16
23
  }
@@ -12,7 +12,7 @@ import {
12
12
  transformSizeRatio
13
13
  } from '@symbo.ls/scratch'
14
14
 
15
- import { isDefined, isString } from '@domql/utils'
15
+ import { isDefined, isString } from '@symbo.ls/utils'
16
16
 
17
17
  export const getSystemGlobalTheme = ({ context, state }) => {
18
18
  const theme = state?.root?.globalTheme || context.designSystem?.globalTheme
@@ -21,12 +21,11 @@ export const getSystemGlobalTheme = ({ context, state }) => {
21
21
 
22
22
  export const THEME_PROPS = {
23
23
  theme: (val, element) => {
24
- const { props } = element
25
24
  if (!val) return
26
25
 
27
26
  // themeModifier explicitly forces a scheme on this component
28
- if (props.themeModifier) {
29
- return getMediaTheme(val, `@${props.themeModifier}`)
27
+ if (element.themeModifier) {
28
+ return getMediaTheme(val, `@${element.themeModifier}`)
30
29
  }
31
30
 
32
31
  // CSS vars handle dark/light switching — no modifier needed, no DOMQL re-render
@@ -63,8 +62,12 @@ export const THEME_PROPS = {
63
62
  backgroundImage: (val, element, s, ctx) => {
64
63
  const globalTheme = getSystemGlobalTheme(element)
65
64
  if (!val) return
66
- const file = ctx.files && ctx.files[val]
67
- if (file && file.content) val = file.content.src
65
+ const asset = ctx.assets && ctx.assets[val]
66
+ if (asset && asset.content) val = asset.content.src
67
+ else {
68
+ const file = ctx.files && ctx.files[val]
69
+ if (file && file.content) val = file.content.src
70
+ }
68
71
  return {
69
72
  backgroundImage: transformBackgroundImage(val, globalTheme)
70
73
  }
@@ -78,7 +81,7 @@ export const THEME_PROPS = {
78
81
  outline: transformBorder(val)
79
82
  }),
80
83
 
81
- outlineOffset: (val, { props }) => transformSizeRatio('outlineOffset', val, props),
84
+ outlineOffset: (val, el) => transformSizeRatio('outlineOffset', val, el),
82
85
 
83
86
  border: (val) => ({
84
87
  border: transformBorder(val)
package/src/set.js CHANGED
@@ -1,9 +1,16 @@
1
1
  'use strict'
2
2
 
3
- import { transformClassname } from './_transform'
4
- import { transformEmotion } from './emotion'
3
+ import { isObject } from '@symbo.ls/utils'
4
+ import { useCssInProps } from './transform/index.js'
5
+ import { css } from '@symbo.ls/css'
5
6
 
6
- export const setClassname = (props, emotionCss) => {
7
+ export const transformClassname = (element) => {
8
+ if (!isObject(element)) return
9
+ return useCssInProps(element, element)
10
+ }
11
+
12
+ export const setClassname = (props, cssEngine) => {
7
13
  const transform = transformClassname(props)
8
- return transformEmotion(transform, emotionCss)
14
+ if (typeof cssEngine === 'function') return cssEngine(transform)
15
+ return css(transform)
9
16
  }
@@ -1,9 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { exec, isArray, isFunction, isObject, isProduction, merge, overwrite, overwriteDeep } from '@domql/utils'
4
- import { CSS_PROPS_REGISTRY } from '../props'
5
- import { DEFAULT_CSS_PROPERTIES_LIST } from '../props/defaults'
6
- import { applyTrueProps, transformersByPrefix } from './transformers'
3
+ import { exec, isArray, isFunction, isObject, isProduction, merge, overwrite, overwriteDeep } from '@symbo.ls/utils'
4
+ import { pushConfig, popConfig } from '@symbo.ls/scratch'
5
+ import { CSS_PROPS_REGISTRY } from '../props/index.js'
6
+ import { DEFAULT_CSS_PROPERTIES_LIST } from '../props/defaults.js'
7
+ import { applyTrueProps, transformersByPrefix } from './transformers.js'
7
8
 
8
9
  /**
9
10
  * CLASS ASSIGNMENT
@@ -14,60 +15,67 @@ const isProd = isProduction()
14
15
 
15
16
  // Process non-setter properties and return remaining props
16
17
  export const usePropsAsCSS = (sourceObj, element, opts) => {
17
- let obj = {}
18
- const rest = {}
18
+ const ds = element?.context?.designSystem
19
+ if (ds) pushConfig(ds)
19
20
 
20
- const setToObj = (key, val) => {
21
- if (opts.unpack) {
22
- obj = { ...obj, ...val }
23
- return
24
- }
25
- obj[key] = val
26
- }
21
+ try {
22
+ let obj = {}
23
+ const rest = {}
27
24
 
28
- for (const key in sourceObj) {
29
- const value = sourceObj[key]
30
- if (key === 'class' && element.call('isString', sourceObj.class)) {
31
- const val = value.split(' ')
32
- if (val.length) {
33
- const CLASS = element.context.designSystem.class
34
- const result = val
35
- .reduce((acc, curr) => merge(acc, CLASS[curr]), {})
36
- obj.designSystemClass = result
25
+ const setToObj = (key, val) => {
26
+ if (opts.unpack) {
27
+ obj = { ...obj, ...val }
28
+ return
37
29
  }
38
- } else if (key === 'true') {
39
- const val = exec(value, element)
40
- merge(obj, applyTrueProps(val, element))
41
- } else if (element.classlist[key]) {
42
- const originalFromClass = element.classlist[key]
43
- const result = isFunction(originalFromClass)
44
- ? originalFromClass(element, element.state, element.context)
45
- : originalFromClass
46
- if (result) setToObj(key, result)
47
- if (!isProd && isObject(obj[key])) obj[key].label = key
48
- } else if (CSS_PROPS_REGISTRY[key]) {
49
- let val = exec(value, element)
50
- if (isArray(val)) {
51
- val = val.reduce((a, c) => merge(a, c), {})
52
- }
53
- let result = CSS_PROPS_REGISTRY[key](val, element, element.state, element.context)
54
- if (isArray(result)) result = result.reduce((a, c) => merge(a, c), {})
55
- if (result) setToObj(key, result)
56
- if (!isProd && isObject(obj[key])) obj[key].label = key
57
- } else if (DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
58
- // they can be grouped
59
- let result = exec(value, element)
60
- if (typeof result === 'string' && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
61
- result = `var(${result})`
30
+ obj[key] = val
31
+ }
32
+
33
+ for (const key in sourceObj) {
34
+ const value = sourceObj[key]
35
+ if (key === 'class' && element.call('isString', sourceObj.class)) {
36
+ const val = value.split(' ')
37
+ if (val.length) {
38
+ const CLASS = element.context.designSystem.class
39
+ const result = val
40
+ .reduce((acc, curr) => merge(acc, CLASS[curr]), {})
41
+ obj.designSystemClass = result
42
+ }
43
+ } else if (key === 'true') {
44
+ const val = exec(value, element)
45
+ merge(obj, applyTrueProps(val, element))
46
+ } else if (element.classlist[key]) {
47
+ const originalFromClass = element.classlist[key]
48
+ const result = isFunction(originalFromClass)
49
+ ? originalFromClass(element, element.state, element.context)
50
+ : originalFromClass
51
+ if (result) setToObj(key, result)
52
+ if (!isProd && isObject(obj[key])) obj[key].label = key
53
+ } else if (CSS_PROPS_REGISTRY[key]) {
54
+ let val = exec(value, element)
55
+ if (isArray(val)) {
56
+ val = val.reduce((a, c) => merge(a, c), {})
57
+ }
58
+ let result = CSS_PROPS_REGISTRY[key](val, element, element.state, element.context)
59
+ if (isArray(result)) result = result.reduce((a, c) => merge(a, c), {})
60
+ if (result) setToObj(key, result)
61
+ if (!isProd && isObject(obj[key])) obj[key].label = key
62
+ } else if (DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
63
+ // they can be grouped
64
+ let result = exec(value, element)
65
+ if (typeof result === 'string' && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
66
+ result = `var(${result})`
67
+ }
68
+ setToObj(key, { [key]: result })
69
+ if (!isProd && isObject(obj[key])) obj[key].label = key
70
+ } else {
71
+ rest[key] = value
62
72
  }
63
- setToObj(key, { [key]: result })
64
- if (!isProd && isObject(obj[key])) obj[key].label = key
65
- } else {
66
- rest[key] = value
67
73
  }
68
- }
69
74
 
70
- return [obj, rest]
75
+ return [obj, rest]
76
+ } finally {
77
+ if (ds) popConfig()
78
+ }
71
79
  }
72
80
 
73
81
  export const useSelectorsAsCSS = (sourceObj, element) => {