css-in-props 3.8.8 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -22
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/props/animation.js +28 -23
- package/dist/cjs/props/block.js +46 -58
- package/dist/cjs/props/flex.js +4 -5
- package/dist/cjs/props/index.js +18 -19
- package/dist/cjs/props/misc.js +10 -3
- package/dist/cjs/props/theme.js +10 -7
- package/dist/cjs/set.js +13 -6
- package/dist/cjs/transform/executors.js +54 -47
- package/dist/cjs/transform/index.js +2 -2
- package/dist/cjs/transform/transformers.js +69 -20
- package/dist/esm/index.js +4 -4
- package/dist/esm/props/animation.js +28 -23
- package/dist/esm/props/block.js +46 -58
- package/dist/esm/props/flex.js +4 -5
- package/dist/esm/props/index.js +18 -19
- package/dist/esm/props/misc.js +10 -3
- package/dist/esm/props/theme.js +10 -7
- package/dist/esm/set.js +12 -5
- package/dist/esm/transform/executors.js +54 -47
- package/dist/esm/transform/index.js +2 -2
- package/dist/esm/transform/transformers.js +69 -20
- package/dist/iife/index.js +230 -167
- package/index.js +1 -0
- package/package.json +13 -15
- package/src/index.js +4 -4
- package/src/props/animation.js +28 -23
- package/src/props/block.js +49 -57
- package/src/props/flex.js +4 -5
- package/src/props/index.js +18 -19
- package/src/props/misc.js +10 -3
- package/src/props/theme.js +10 -7
- package/src/set.js +11 -4
- package/src/transform/executors.js +60 -52
- package/src/transform/index.js +2 -2
- package/src/transform/transformers.js +85 -23
- package/dist/cjs/_transform.js +0 -30
- package/dist/cjs/emotion.js +0 -29
- package/dist/esm/_transform.js +0 -10
- package/dist/esm/emotion.js +0 -9
- package/src/_transform.js +0 -10
- package/src/emotion.js +0 -9
package/dist/iife/index.js
CHANGED
|
@@ -41,7 +41,8 @@ var CssInProps = (() => {
|
|
|
41
41
|
applyTrueProps: () => applyTrueProps,
|
|
42
42
|
exetuteClassPerComponent: () => exetuteClassPerComponent,
|
|
43
43
|
getSystemGlobalTheme: () => getSystemGlobalTheme,
|
|
44
|
-
|
|
44
|
+
setClassname: () => setClassname,
|
|
45
|
+
transformClassname: () => transformClassname,
|
|
45
46
|
transformersByPrefix: () => transformersByPrefix,
|
|
46
47
|
useCssInProps: () => useCssInProps,
|
|
47
48
|
usePropsAsCSS: () => usePropsAsCSS,
|
|
@@ -49,27 +50,33 @@ var CssInProps = (() => {
|
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
// src/transform/executors.js
|
|
52
|
-
var import_utils6 = __require("@
|
|
53
|
+
var import_utils6 = __require("@symbo.ls/utils");
|
|
54
|
+
var import_scratch7 = __require("@symbo.ls/scratch");
|
|
53
55
|
|
|
54
56
|
// src/props/animation.js
|
|
55
|
-
var import_utils = __require("@
|
|
56
|
-
var
|
|
57
|
+
var import_utils = __require("@symbo.ls/utils");
|
|
58
|
+
var import_css = __require("@symbo.ls/css");
|
|
57
59
|
var import_scratch = __require("@symbo.ls/scratch");
|
|
58
60
|
var TIMING_FUNCTIONS = ["ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"];
|
|
59
61
|
var FILL_MODES = ["none", "forwards", "backwards", "both"];
|
|
60
62
|
var DIRECTIONS = ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
61
63
|
var PLAY_STATES = ["running", "paused"];
|
|
62
64
|
var isDuration = (v) => /^[\d.]+m?s$/.test(v);
|
|
65
|
+
var _animCounter = 0;
|
|
63
66
|
var applyAnimationProps = (animation, element) => {
|
|
64
|
-
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const { animation: ANIMATION } = element.context && element.context.designSystem || {};
|
|
68
|
+
if ((0, import_utils.isObject)(animation)) {
|
|
69
|
+
const name = `smbls-anim-${_animCounter++}`;
|
|
70
|
+
return { animationName: (0, import_css.keyframes)(name, animation) };
|
|
71
|
+
}
|
|
72
|
+
const record = ANIMATION && ANIMATION[animation];
|
|
73
|
+
if ((0, import_utils.isObject)(record)) {
|
|
74
|
+
return (0, import_css.keyframes)(animation, record);
|
|
75
|
+
}
|
|
76
|
+
return animation;
|
|
70
77
|
};
|
|
71
78
|
var parseAnimationShorthand = (val, el) => {
|
|
72
|
-
const { ANIMATION } = el.context && el.context.designSystem || {};
|
|
79
|
+
const { animation: ANIMATION } = el.context && el.context.designSystem || {};
|
|
73
80
|
const tokens = val.split(/\s+/);
|
|
74
81
|
let name = null;
|
|
75
82
|
const durations = [];
|
|
@@ -105,24 +112,24 @@ var CssInProps = (() => {
|
|
|
105
112
|
const parsed = parseAnimationShorthand(val, el);
|
|
106
113
|
return {
|
|
107
114
|
animationName: applyAnimationProps(parsed.name || val, el),
|
|
108
|
-
animationDuration: parsed.durations[0] || (0, import_scratch.getTimingByKey)(el.
|
|
109
|
-
animationDelay: parsed.durations[1] || (0, import_scratch.getTimingByKey)(el.
|
|
110
|
-
animationTimingFunction: parsed.timingFunction || (0, import_scratch.getTimingFunction)(el.
|
|
111
|
-
animationFillMode: parsed.fillMode || el.
|
|
112
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.
|
|
113
|
-
animationPlayState: parsed.playState || el.
|
|
114
|
-
animationDirection: parsed.direction || el.
|
|
115
|
+
animationDuration: parsed.durations[0] || (0, import_scratch.getTimingByKey)(el.animationDuration || "A").timing,
|
|
116
|
+
animationDelay: parsed.durations[1] || (0, import_scratch.getTimingByKey)(el.animationDelay || "0s").timing,
|
|
117
|
+
animationTimingFunction: parsed.timingFunction || (0, import_scratch.getTimingFunction)(el.animationTimingFunction || "ease"),
|
|
118
|
+
animationFillMode: parsed.fillMode || el.animationFillMode || "both",
|
|
119
|
+
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.animationIterationCount || 1,
|
|
120
|
+
animationPlayState: parsed.playState || el.animationPlayState,
|
|
121
|
+
animationDirection: parsed.direction || el.animationDirection
|
|
115
122
|
};
|
|
116
123
|
}
|
|
117
124
|
return {
|
|
118
125
|
animationName: applyAnimationProps(val, el),
|
|
119
|
-
animationDuration: (0, import_scratch.getTimingByKey)(el.
|
|
120
|
-
animationDelay: (0, import_scratch.getTimingByKey)(el.
|
|
121
|
-
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.
|
|
122
|
-
animationFillMode: el.
|
|
123
|
-
animationIterationCount: el.
|
|
124
|
-
animationPlayState: el.
|
|
125
|
-
animationDirection: el.
|
|
126
|
+
animationDuration: (0, import_scratch.getTimingByKey)(el.animationDuration || "A").timing,
|
|
127
|
+
animationDelay: (0, import_scratch.getTimingByKey)(el.animationDelay || "0s").timing,
|
|
128
|
+
animationTimingFunction: (0, import_scratch.getTimingFunction)(el.animationTimingFunction || "ease"),
|
|
129
|
+
animationFillMode: el.animationFillMode || "both",
|
|
130
|
+
animationIterationCount: el.animationIterationCount || 1,
|
|
131
|
+
animationPlayState: el.animationPlayState,
|
|
132
|
+
animationDirection: el.animationDirection
|
|
126
133
|
};
|
|
127
134
|
},
|
|
128
135
|
animationName: (val, el) => ({
|
|
@@ -152,17 +159,13 @@ var CssInProps = (() => {
|
|
|
152
159
|
};
|
|
153
160
|
|
|
154
161
|
// src/props/block.js
|
|
155
|
-
var import_utils2 = __require("@
|
|
162
|
+
var import_utils2 = __require("@symbo.ls/utils");
|
|
156
163
|
var import_scratch2 = __require("@symbo.ls/scratch");
|
|
157
164
|
var BLOCK_PROPS = {
|
|
158
|
-
show: (val
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
display: "none !important"
|
|
163
|
-
},
|
|
164
|
-
height: (val, { props }) => (0, import_scratch2.transformSizeRatio)("height", val, props),
|
|
165
|
-
width: (val, { props }) => (0, import_scratch2.transformSizeRatio)("width", val, props),
|
|
165
|
+
show: (val) => !val ? { display: "none !important" } : void 0,
|
|
166
|
+
hide: (val) => val ? { display: "none !important" } : void 0,
|
|
167
|
+
height: (val, el) => (0, import_scratch2.transformSizeRatio)("height", val, el),
|
|
168
|
+
width: (val, el) => (0, import_scratch2.transformSizeRatio)("width", val, el),
|
|
166
169
|
boxSizing: (val) => !(0, import_utils2.isUndefined)(val) ? { boxSizing: val } : { boxSizing: "border-box" },
|
|
167
170
|
boxSize: (val) => {
|
|
168
171
|
if (!(0, import_utils2.isString)(val)) return;
|
|
@@ -172,10 +175,10 @@ var CssInProps = (() => {
|
|
|
172
175
|
...(0, import_scratch2.transformSize)("width", width || height)
|
|
173
176
|
};
|
|
174
177
|
},
|
|
175
|
-
inlineSize: (val,
|
|
176
|
-
blockSize: (val,
|
|
177
|
-
minWidth: (val,
|
|
178
|
-
maxWidth: (val,
|
|
178
|
+
inlineSize: (val, el) => (0, import_scratch2.transformSizeRatio)("inlineSize", val, el),
|
|
179
|
+
blockSize: (val, el) => (0, import_scratch2.transformSizeRatio)("blockSize", val, el),
|
|
180
|
+
minWidth: (val, el) => (0, import_scratch2.transformSizeRatio)("minWidth", val, el),
|
|
181
|
+
maxWidth: (val, el) => (0, import_scratch2.transformSizeRatio)("maxWidth", val, el),
|
|
179
182
|
widthRange: (val) => {
|
|
180
183
|
if (!(0, import_utils2.isString)(val)) return;
|
|
181
184
|
const [minWidth, maxWidth] = val.split(" ");
|
|
@@ -184,8 +187,8 @@ var CssInProps = (() => {
|
|
|
184
187
|
...(0, import_scratch2.transformSize)("maxWidth", maxWidth || minWidth)
|
|
185
188
|
};
|
|
186
189
|
},
|
|
187
|
-
minHeight: (val,
|
|
188
|
-
maxHeight: (val,
|
|
190
|
+
minHeight: (val, el) => (0, import_scratch2.transformSizeRatio)("minHeight", val, el),
|
|
191
|
+
maxHeight: (val, el) => (0, import_scratch2.transformSizeRatio)("maxHeight", val, el),
|
|
189
192
|
heightRange: (val) => {
|
|
190
193
|
if (!(0, import_utils2.isString)(val)) return;
|
|
191
194
|
const [minHeight, maxHeight] = val.split(" ");
|
|
@@ -202,10 +205,10 @@ var CssInProps = (() => {
|
|
|
202
205
|
...(0, import_scratch2.transformSizeRatio)("blockSize", blockSize || inlineSize)
|
|
203
206
|
};
|
|
204
207
|
},
|
|
205
|
-
minBlockSize: (val,
|
|
206
|
-
minInlineSize: (val,
|
|
207
|
-
maxBlockSize: (val,
|
|
208
|
-
maxInlineSize: (val,
|
|
208
|
+
minBlockSize: (val, el) => (0, import_scratch2.transformSizeRatio)("minBlockSize", val, el),
|
|
209
|
+
minInlineSize: (val, el) => (0, import_scratch2.transformSizeRatio)("minInlineSize", val, el),
|
|
210
|
+
maxBlockSize: (val, el) => (0, import_scratch2.transformSizeRatio)("maxBlockSize", val, el),
|
|
211
|
+
maxInlineSize: (val, el) => (0, import_scratch2.transformSizeRatio)("maxInlineSize", val, el),
|
|
209
212
|
minSize: (val) => {
|
|
210
213
|
if (!(0, import_utils2.isString)(val)) return;
|
|
211
214
|
const [minInlineSize, minBlockSize] = val.split(" ");
|
|
@@ -222,9 +225,9 @@ var CssInProps = (() => {
|
|
|
222
225
|
...(0, import_scratch2.transformSize)("maxBlockSize", maxBlockSize || maxInlineSize)
|
|
223
226
|
};
|
|
224
227
|
},
|
|
225
|
-
borderWidth: (val,
|
|
226
|
-
padding: (val,
|
|
227
|
-
scrollPadding: (val,
|
|
228
|
+
borderWidth: (val, el) => (0, import_scratch2.transformSizeRatio)("borderWidth", val, el),
|
|
229
|
+
padding: (val, el) => (0, import_scratch2.transformSizeRatio)("padding", val, el),
|
|
230
|
+
scrollPadding: (val, el) => (0, import_scratch2.transformSizeRatio)("scrollPadding", val, el),
|
|
228
231
|
paddingInline: (val) => {
|
|
229
232
|
if (!(0, import_utils2.isString)(val)) return;
|
|
230
233
|
const [paddingInlineStart, paddingInlineEnd] = val.split(" ");
|
|
@@ -241,21 +244,15 @@ var CssInProps = (() => {
|
|
|
241
244
|
...(0, import_scratch2.transformSize)("paddingBlockEnd", paddingBlockEnd || paddingBlockStart)
|
|
242
245
|
};
|
|
243
246
|
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// maps to bottom
|
|
254
|
-
paddingInlineStart: (val, { props }) => (0, import_scratch2.transformSizeRatio)("paddingInlineStart", val, props),
|
|
255
|
-
// maps to left
|
|
256
|
-
paddingInlineEnd: (val, { props }) => (0, import_scratch2.transformSizeRatio)("paddingInlineEnd", val, props),
|
|
257
|
-
// maps to right
|
|
258
|
-
margin: (val, { props }) => (0, import_scratch2.transformSizeRatio)("margin", val, props),
|
|
247
|
+
paddingTop: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingBlockStart", val, el),
|
|
248
|
+
paddingBottom: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingBlockEnd", val, el),
|
|
249
|
+
paddingLeft: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingInlineStart", val, el),
|
|
250
|
+
paddingRight: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingInlineEnd", val, el),
|
|
251
|
+
paddingBlockStart: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingBlockStart", val, el),
|
|
252
|
+
paddingBlockEnd: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingBlockEnd", val, el),
|
|
253
|
+
paddingInlineStart: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingInlineStart", val, el),
|
|
254
|
+
paddingInlineEnd: (val, el) => (0, import_scratch2.transformSizeRatio)("paddingInlineEnd", val, el),
|
|
255
|
+
margin: (val, el) => (0, import_scratch2.transformSizeRatio)("margin", val, el),
|
|
259
256
|
marginInline: (val) => {
|
|
260
257
|
if (!(0, import_utils2.isString)(val)) return;
|
|
261
258
|
const [marginInlineStart, marginInlineEnd] = val.split(" ");
|
|
@@ -264,35 +261,33 @@ var CssInProps = (() => {
|
|
|
264
261
|
...(0, import_scratch2.transformSize)("marginInlineEnd", marginInlineEnd || marginInlineStart)
|
|
265
262
|
};
|
|
266
263
|
},
|
|
267
|
-
marginBlock: (val,
|
|
268
|
-
if (!(0, import_utils2.isString)(
|
|
269
|
-
const [marginBlockStart, marginBlockEnd] =
|
|
264
|
+
marginBlock: (val, el) => {
|
|
265
|
+
if (!(0, import_utils2.isString)(el.marginBlock)) return;
|
|
266
|
+
const [marginBlockStart, marginBlockEnd] = el.marginBlock.split(" ");
|
|
270
267
|
return {
|
|
271
268
|
...(0, import_scratch2.transformSize)("marginBlockStart", marginBlockStart),
|
|
272
269
|
...(0, import_scratch2.transformSize)("marginBlockEnd", marginBlockEnd || marginBlockStart)
|
|
273
270
|
};
|
|
274
271
|
},
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
marginBlockStart: (val, { props }) => (0, import_scratch2.transformSizeRatio)("marginBlockStart", val, props),
|
|
284
|
-
marginBlockEnd: (val, { props }) => (0, import_scratch2.transformSizeRatio)("marginBlockEnd", val, props),
|
|
272
|
+
marginTop: (val, el) => (0, import_scratch2.transformSizeRatio)("marginBlockStart", val, el),
|
|
273
|
+
marginBottom: (val, el) => (0, import_scratch2.transformSizeRatio)("marginBlockEnd", val, el),
|
|
274
|
+
marginLeft: (val, el) => (0, import_scratch2.transformSizeRatio)("marginInlineStart", val, el),
|
|
275
|
+
marginRight: (val, el) => (0, import_scratch2.transformSizeRatio)("marginInlineEnd", val, el),
|
|
276
|
+
marginInlineStart: (val, el) => (0, import_scratch2.transformSizeRatio)("marginInlineStart", val, el),
|
|
277
|
+
marginInlineEnd: (val, el) => (0, import_scratch2.transformSizeRatio)("marginInlineEnd", val, el),
|
|
278
|
+
marginBlockStart: (val, el) => (0, import_scratch2.transformSizeRatio)("marginBlockStart", val, el),
|
|
279
|
+
marginBlockEnd: (val, el) => (0, import_scratch2.transformSizeRatio)("marginBlockEnd", val, el),
|
|
285
280
|
gap: (val) => ({
|
|
286
281
|
gap: (0, import_scratch2.transfromGap)(val)
|
|
287
282
|
}),
|
|
288
|
-
columnGap: (val,
|
|
289
|
-
rowGap: (val,
|
|
290
|
-
flexWrap: (val
|
|
283
|
+
columnGap: (val, el) => (0, import_scratch2.getSpacingBasedOnRatio)(el, "columnGap", val),
|
|
284
|
+
rowGap: (val, el) => (0, import_scratch2.getSpacingBasedOnRatio)(el, "rowGap", val),
|
|
285
|
+
flexWrap: (val) => ({
|
|
291
286
|
display: "flex",
|
|
292
|
-
|
|
287
|
+
flexWrap: val
|
|
293
288
|
}),
|
|
294
|
-
flexFlow: (val,
|
|
295
|
-
const
|
|
289
|
+
flexFlow: (val, el) => {
|
|
290
|
+
const reverse = el.reverse;
|
|
296
291
|
if (!(0, import_utils2.isString)(val)) return;
|
|
297
292
|
let [direction, wrap] = (val || "row").split(" ");
|
|
298
293
|
if (val.startsWith("x") || val === "row") direction = "row";
|
|
@@ -311,8 +306,8 @@ var CssInProps = (() => {
|
|
|
311
306
|
justifyContent
|
|
312
307
|
};
|
|
313
308
|
},
|
|
314
|
-
round: (val,
|
|
315
|
-
borderRadius: (val,
|
|
309
|
+
round: (val, el) => (0, import_scratch2.transformBorderRadius)(val ?? el.borderRadius, el, "round"),
|
|
310
|
+
borderRadius: (val, el) => (0, import_scratch2.transformBorderRadius)(val ?? el.round, el, "borderRadius")
|
|
316
311
|
};
|
|
317
312
|
|
|
318
313
|
// src/props/font.js
|
|
@@ -338,10 +333,17 @@ var CssInProps = (() => {
|
|
|
338
333
|
}),
|
|
339
334
|
cursor: (value, el, s, ctx) => {
|
|
340
335
|
if (!value) return;
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
336
|
+
const asset = ctx.assets && ctx.assets[value];
|
|
337
|
+
if (asset && asset.content) value = `url(${asset.content.src})`;
|
|
338
|
+
else {
|
|
339
|
+
const file = ctx.files && ctx.files[value];
|
|
340
|
+
if (file && file.content) value = `url(${file.content.src})`;
|
|
341
|
+
}
|
|
343
342
|
return { cursor: value };
|
|
344
|
-
}
|
|
343
|
+
},
|
|
344
|
+
opacity: (value) => value != null ? { opacity: String(value) } : void 0,
|
|
345
|
+
visibility: (value) => value != null ? { visibility: value } : void 0,
|
|
346
|
+
pointerEvents: (value) => value != null ? { pointerEvents: value } : void 0
|
|
345
347
|
};
|
|
346
348
|
|
|
347
349
|
// src/props/position.js
|
|
@@ -376,17 +378,16 @@ var CssInProps = (() => {
|
|
|
376
378
|
|
|
377
379
|
// src/props/theme.js
|
|
378
380
|
var import_scratch5 = __require("@symbo.ls/scratch");
|
|
379
|
-
var import_utils3 = __require("@
|
|
381
|
+
var import_utils3 = __require("@symbo.ls/utils");
|
|
380
382
|
var getSystemGlobalTheme = ({ context, state }) => {
|
|
381
383
|
const theme = state?.root?.globalTheme || context.designSystem?.globalTheme;
|
|
382
384
|
return theme === "auto" ? null : theme;
|
|
383
385
|
};
|
|
384
386
|
var THEME_PROPS = {
|
|
385
387
|
theme: (val, element) => {
|
|
386
|
-
const { props } = element;
|
|
387
388
|
if (!val) return;
|
|
388
|
-
if (
|
|
389
|
-
return (0, import_scratch5.getMediaTheme)(val, `@${
|
|
389
|
+
if (element.themeModifier) {
|
|
390
|
+
return (0, import_scratch5.getMediaTheme)(val, `@${element.themeModifier}`);
|
|
390
391
|
}
|
|
391
392
|
return (0, import_scratch5.getMediaTheme)(val);
|
|
392
393
|
},
|
|
@@ -417,8 +418,12 @@ var CssInProps = (() => {
|
|
|
417
418
|
backgroundImage: (val, element, s, ctx) => {
|
|
418
419
|
const globalTheme = getSystemGlobalTheme(element);
|
|
419
420
|
if (!val) return;
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
421
|
+
const asset = ctx.assets && ctx.assets[val];
|
|
422
|
+
if (asset && asset.content) val = asset.content.src;
|
|
423
|
+
else {
|
|
424
|
+
const file = ctx.files && ctx.files[val];
|
|
425
|
+
if (file && file.content) val = file.content.src;
|
|
426
|
+
}
|
|
422
427
|
return {
|
|
423
428
|
backgroundImage: (0, import_scratch5.transformBackgroundImage)(val, globalTheme)
|
|
424
429
|
};
|
|
@@ -429,7 +434,7 @@ var CssInProps = (() => {
|
|
|
429
434
|
outline: (val) => ({
|
|
430
435
|
outline: (0, import_scratch5.transformBorder)(val)
|
|
431
436
|
}),
|
|
432
|
-
outlineOffset: (val,
|
|
437
|
+
outlineOffset: (val, el) => (0, import_scratch5.transformSizeRatio)("outlineOffset", val, el),
|
|
433
438
|
border: (val) => ({
|
|
434
439
|
border: (0, import_scratch5.transformBorder)(val)
|
|
435
440
|
}),
|
|
@@ -518,11 +523,10 @@ var CssInProps = (() => {
|
|
|
518
523
|
};
|
|
519
524
|
|
|
520
525
|
// src/props/flex.js
|
|
521
|
-
var import_utils4 = __require("@
|
|
526
|
+
var import_utils4 = __require("@symbo.ls/utils");
|
|
522
527
|
var FLEX_PROPS = {
|
|
523
528
|
flow: (value, el) => {
|
|
524
|
-
const
|
|
525
|
-
const { reverse } = props;
|
|
529
|
+
const reverse = el.reverse;
|
|
526
530
|
if (!(0, import_utils4.isString)(value)) return;
|
|
527
531
|
let [direction, wrap] = (value || "row").split(" ");
|
|
528
532
|
if (value.startsWith("x") || value === "row") direction = "row";
|
|
@@ -532,10 +536,10 @@ var CssInProps = (() => {
|
|
|
532
536
|
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
533
537
|
};
|
|
534
538
|
},
|
|
535
|
-
wrap: (value,
|
|
539
|
+
wrap: (value, el) => {
|
|
536
540
|
return { display: "flex", flexWrap: value };
|
|
537
541
|
},
|
|
538
|
-
align: (value,
|
|
542
|
+
align: (value, el) => {
|
|
539
543
|
const [alignItems, justifyContent] = value.split(" ");
|
|
540
544
|
return { display: "flex", alignItems, justifyContent };
|
|
541
545
|
}
|
|
@@ -565,7 +569,6 @@ var CssInProps = (() => {
|
|
|
565
569
|
...BLOCK_PROPS,
|
|
566
570
|
...FONT_PROPS,
|
|
567
571
|
...MISC_PROPS,
|
|
568
|
-
...MISC_PROPS,
|
|
569
572
|
...POSITION_PROPS,
|
|
570
573
|
...THEME_PROPS,
|
|
571
574
|
...TIMING_PROPS,
|
|
@@ -894,30 +897,65 @@ var CssInProps = (() => {
|
|
|
894
897
|
]);
|
|
895
898
|
|
|
896
899
|
// src/transform/transformers.js
|
|
897
|
-
var import_utils5 = __require("@
|
|
900
|
+
var import_utils5 = __require("@symbo.ls/utils");
|
|
901
|
+
var DATA_THEME_RE = /^\[data-theme=(?:"([^"]+)"|'([^']+)')\]$/;
|
|
898
902
|
var applyMediaProps = (key, selectorProps, element) => {
|
|
899
903
|
const { context } = element;
|
|
900
904
|
if (!context.designSystem?.media) return;
|
|
901
|
-
const
|
|
905
|
+
const schemeKey = key.slice(1);
|
|
906
|
+
const mediaValue = context.designSystem.media[schemeKey];
|
|
902
907
|
const generatedClass = useCssInProps(selectorProps, element);
|
|
903
|
-
let mediaKey;
|
|
904
908
|
if (!mediaValue) {
|
|
905
|
-
|
|
906
|
-
} else if (mediaValue === "print") {
|
|
907
|
-
mediaKey = "@media print";
|
|
908
|
-
} else if (mediaValue[0] === "(") {
|
|
909
|
-
mediaKey = `@media screen and ${mediaValue}`;
|
|
910
|
-
} else {
|
|
911
|
-
mediaKey = `${mediaValue} &`;
|
|
909
|
+
return { [key]: generatedClass };
|
|
912
910
|
}
|
|
913
|
-
|
|
911
|
+
if (mediaValue === "print") {
|
|
912
|
+
return { "@media print": generatedClass };
|
|
913
|
+
}
|
|
914
|
+
if (mediaValue[0] === "(") {
|
|
915
|
+
return { [`@media screen and ${mediaValue}`]: generatedClass };
|
|
916
|
+
}
|
|
917
|
+
const match = mediaValue.match(DATA_THEME_RE);
|
|
918
|
+
const scheme = match ? match[1] || match[2] : schemeKey;
|
|
919
|
+
const result = { [`${mediaValue} &`]: generatedClass };
|
|
920
|
+
if (scheme === "dark" || scheme === "light") {
|
|
921
|
+
const scopeSelector = context.designSystem?.scopeSelector || ":root";
|
|
922
|
+
const guard = scopeSelector === ":root" ? ":root:not([data-theme])" : `${scopeSelector}:not([data-theme])`;
|
|
923
|
+
result[`@media (prefers-color-scheme: ${scheme})`] = {
|
|
924
|
+
[`${guard} &`]: generatedClass
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
914
928
|
};
|
|
915
929
|
var applyAndProps = (key, selectorProps, element) => {
|
|
916
930
|
return { [key]: useCssInProps(selectorProps, element) };
|
|
917
931
|
};
|
|
918
932
|
var applySelectorProps = (key, selectorProps, element) => {
|
|
919
933
|
const selectorKey = `&${key}`;
|
|
920
|
-
|
|
934
|
+
const resolved = useCssInProps(selectorProps, element);
|
|
935
|
+
if (key.includes(",") && resolved) {
|
|
936
|
+
const flat = {};
|
|
937
|
+
const nested = {};
|
|
938
|
+
for (const k in resolved) {
|
|
939
|
+
if (typeof resolved[k] === "object" && resolved[k] !== null) {
|
|
940
|
+
nested[k] = resolved[k];
|
|
941
|
+
} else {
|
|
942
|
+
flat[k] = resolved[k];
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (Object.keys(nested).length) {
|
|
946
|
+
const parts = selectorKey.split(",").map((p) => p.trim());
|
|
947
|
+
const result = {};
|
|
948
|
+
if (Object.keys(flat).length) {
|
|
949
|
+
result[selectorKey] = flat;
|
|
950
|
+
}
|
|
951
|
+
for (const nestedKey in nested) {
|
|
952
|
+
const distributed = parts.map((p) => `${p} ${nestedKey}`).join(", ");
|
|
953
|
+
result[distributed] = nested[nestedKey];
|
|
954
|
+
}
|
|
955
|
+
return result;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return { [selectorKey]: resolved };
|
|
921
959
|
};
|
|
922
960
|
var resolveCase = (caseKey, element) => {
|
|
923
961
|
const caseFn = element.context?.cases?.[caseKey];
|
|
@@ -929,7 +967,7 @@ var CssInProps = (() => {
|
|
|
929
967
|
const caseKey = key.slice(1);
|
|
930
968
|
let isCaseTrue = resolveCase(caseKey, element);
|
|
931
969
|
if (isCaseTrue === void 0) {
|
|
932
|
-
isCaseTrue = !!element
|
|
970
|
+
isCaseTrue = !!element[caseKey];
|
|
933
971
|
}
|
|
934
972
|
if (!isCaseTrue) return;
|
|
935
973
|
return useCssInProps(selectorProps, element);
|
|
@@ -939,20 +977,34 @@ var CssInProps = (() => {
|
|
|
939
977
|
};
|
|
940
978
|
var applyConditionalCaseProps = (key, selectorProps, element) => {
|
|
941
979
|
const caseKey = key.slice(1);
|
|
942
|
-
let isCaseTrue = element
|
|
980
|
+
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
943
981
|
if (!isCaseTrue) {
|
|
944
|
-
|
|
945
|
-
|
|
982
|
+
if (typeof element[caseKey] === "function") {
|
|
983
|
+
try {
|
|
984
|
+
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
985
|
+
} catch (e) {
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
const caseResult = resolveCase(caseKey, element);
|
|
989
|
+
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
990
|
+
}
|
|
946
991
|
}
|
|
947
992
|
if (!isCaseTrue) return;
|
|
948
993
|
return useCssInProps(selectorProps, element);
|
|
949
994
|
};
|
|
950
995
|
var applyConditionalFalsyProps = (key, selectorProps, element) => {
|
|
951
996
|
const caseKey = key.slice(1);
|
|
952
|
-
let isCaseTrue = element
|
|
997
|
+
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
953
998
|
if (!isCaseTrue) {
|
|
954
|
-
|
|
955
|
-
|
|
999
|
+
if (typeof element[caseKey] === "function") {
|
|
1000
|
+
try {
|
|
1001
|
+
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
1002
|
+
} catch (e) {
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
const caseResult = resolveCase(caseKey, element);
|
|
1006
|
+
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
1007
|
+
}
|
|
956
1008
|
}
|
|
957
1009
|
if (isCaseTrue) return;
|
|
958
1010
|
return useCssInProps(selectorProps, element);
|
|
@@ -980,53 +1032,59 @@ var CssInProps = (() => {
|
|
|
980
1032
|
// src/transform/executors.js
|
|
981
1033
|
var isProd = (0, import_utils6.isProduction)();
|
|
982
1034
|
var usePropsAsCSS = (sourceObj, element, opts) => {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
for (const key in sourceObj) {
|
|
993
|
-
const value = sourceObj[key];
|
|
994
|
-
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
995
|
-
const val = value.split(" ");
|
|
996
|
-
if (val.length) {
|
|
997
|
-
const CLASS = element.context.designSystem.class;
|
|
998
|
-
const result = val.reduce((acc, curr) => (0, import_utils6.merge)(acc, CLASS[curr]), {});
|
|
999
|
-
obj.designSystemClass = result;
|
|
1000
|
-
}
|
|
1001
|
-
} else if (key === "true") {
|
|
1002
|
-
const val = (0, import_utils6.exec)(value, element);
|
|
1003
|
-
(0, import_utils6.merge)(obj, applyTrueProps(val, element));
|
|
1004
|
-
} else if (element.classlist[key]) {
|
|
1005
|
-
const originalFromClass = element.classlist[key];
|
|
1006
|
-
const result = (0, import_utils6.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
1007
|
-
if (result) setToObj(key, result);
|
|
1008
|
-
if (!isProd && (0, import_utils6.isObject)(obj[key])) obj[key].label = key;
|
|
1009
|
-
} else if (CSS_PROPS_REGISTRY[key]) {
|
|
1010
|
-
let val = (0, import_utils6.exec)(value, element);
|
|
1011
|
-
if ((0, import_utils6.isArray)(val)) {
|
|
1012
|
-
val = val.reduce((a, c) => (0, import_utils6.merge)(a, c), {});
|
|
1035
|
+
const ds = element?.context?.designSystem;
|
|
1036
|
+
if (ds) (0, import_scratch7.pushConfig)(ds);
|
|
1037
|
+
try {
|
|
1038
|
+
let obj = {};
|
|
1039
|
+
const rest = {};
|
|
1040
|
+
const setToObj = (key, val) => {
|
|
1041
|
+
if (opts.unpack) {
|
|
1042
|
+
obj = { ...obj, ...val };
|
|
1043
|
+
return;
|
|
1013
1044
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1045
|
+
obj[key] = val;
|
|
1046
|
+
};
|
|
1047
|
+
for (const key in sourceObj) {
|
|
1048
|
+
const value = sourceObj[key];
|
|
1049
|
+
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
1050
|
+
const val = value.split(" ");
|
|
1051
|
+
if (val.length) {
|
|
1052
|
+
const CLASS = element.context.designSystem.class;
|
|
1053
|
+
const result = val.reduce((acc, curr) => (0, import_utils6.merge)(acc, CLASS[curr]), {});
|
|
1054
|
+
obj.designSystemClass = result;
|
|
1055
|
+
}
|
|
1056
|
+
} else if (key === "true") {
|
|
1057
|
+
const val = (0, import_utils6.exec)(value, element);
|
|
1058
|
+
(0, import_utils6.merge)(obj, applyTrueProps(val, element));
|
|
1059
|
+
} else if (element.classlist[key]) {
|
|
1060
|
+
const originalFromClass = element.classlist[key];
|
|
1061
|
+
const result = (0, import_utils6.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
1062
|
+
if (result) setToObj(key, result);
|
|
1063
|
+
if (!isProd && (0, import_utils6.isObject)(obj[key])) obj[key].label = key;
|
|
1064
|
+
} else if (CSS_PROPS_REGISTRY[key]) {
|
|
1065
|
+
let val = (0, import_utils6.exec)(value, element);
|
|
1066
|
+
if ((0, import_utils6.isArray)(val)) {
|
|
1067
|
+
val = val.reduce((a, c) => (0, import_utils6.merge)(a, c), {});
|
|
1068
|
+
}
|
|
1069
|
+
let result = CSS_PROPS_REGISTRY[key](val, element, element.state, element.context);
|
|
1070
|
+
if ((0, import_utils6.isArray)(result)) result = result.reduce((a, c) => (0, import_utils6.merge)(a, c), {});
|
|
1071
|
+
if (result) setToObj(key, result);
|
|
1072
|
+
if (!isProd && (0, import_utils6.isObject)(obj[key])) obj[key].label = key;
|
|
1073
|
+
} else if (DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
|
|
1074
|
+
let result = (0, import_utils6.exec)(value, element);
|
|
1075
|
+
if (typeof result === "string" && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
|
|
1076
|
+
result = `var(${result})`;
|
|
1077
|
+
}
|
|
1078
|
+
setToObj(key, { [key]: result });
|
|
1079
|
+
if (!isProd && (0, import_utils6.isObject)(obj[key])) obj[key].label = key;
|
|
1080
|
+
} else {
|
|
1081
|
+
rest[key] = value;
|
|
1022
1082
|
}
|
|
1023
|
-
setToObj(key, { [key]: result });
|
|
1024
|
-
if (!isProd && (0, import_utils6.isObject)(obj[key])) obj[key].label = key;
|
|
1025
|
-
} else {
|
|
1026
|
-
rest[key] = value;
|
|
1027
1083
|
}
|
|
1084
|
+
return [obj, rest];
|
|
1085
|
+
} finally {
|
|
1086
|
+
if (ds) (0, import_scratch7.popConfig)();
|
|
1028
1087
|
}
|
|
1029
|
-
return [obj, rest];
|
|
1030
1088
|
};
|
|
1031
1089
|
var useSelectorsAsCSS = (sourceObj, element) => {
|
|
1032
1090
|
const obj = {};
|
|
@@ -1073,12 +1131,17 @@ var CssInProps = (() => {
|
|
|
1073
1131
|
return classObj;
|
|
1074
1132
|
};
|
|
1075
1133
|
|
|
1076
|
-
// src/
|
|
1077
|
-
var import_utils7 = __require("@
|
|
1078
|
-
var
|
|
1079
|
-
var
|
|
1080
|
-
|
|
1081
|
-
return (
|
|
1134
|
+
// src/set.js
|
|
1135
|
+
var import_utils7 = __require("@symbo.ls/utils");
|
|
1136
|
+
var import_css2 = __require("@symbo.ls/css");
|
|
1137
|
+
var transformClassname = (element) => {
|
|
1138
|
+
if (!(0, import_utils7.isObject)(element)) return;
|
|
1139
|
+
return useCssInProps(element, element);
|
|
1140
|
+
};
|
|
1141
|
+
var setClassname = (props, cssEngine) => {
|
|
1142
|
+
const transform = transformClassname(props);
|
|
1143
|
+
if (typeof cssEngine === "function") return cssEngine(transform);
|
|
1144
|
+
return (0, import_css2.css)(transform);
|
|
1082
1145
|
};
|
|
1083
1146
|
return __toCommonJS(index_exports);
|
|
1084
1147
|
})();
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/index.js'
|