css-in-props 2.11.453 → 2.11.455

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.
@@ -0,0 +1,340 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var defaults_exports = {};
19
+ __export(defaults_exports, {
20
+ DEFAULT_CSS_PROPERTIES_LIST: () => DEFAULT_CSS_PROPERTIES_LIST
21
+ });
22
+ module.exports = __toCommonJS(defaults_exports);
23
+ const DEFAULT_CSS_PROPERTIES_LIST = [
24
+ "accentColor",
25
+ "alignContent",
26
+ "alignItems",
27
+ "alignSelf",
28
+ "alignmentBaseline",
29
+ "all",
30
+ "animation",
31
+ "animationDelay",
32
+ "animationDirection",
33
+ "animationDuration",
34
+ "animationFillMode",
35
+ "animationIterationCount",
36
+ "animationName",
37
+ "animationPlayState",
38
+ "animationTimingFunction",
39
+ "appearance",
40
+ "aspectRatio",
41
+ "backdropFilter",
42
+ "backfaceVisibility",
43
+ "background",
44
+ "backgroundAttachment",
45
+ "backgroundBlendMode",
46
+ "backgroundClip",
47
+ "backgroundColor",
48
+ "backgroundImage",
49
+ "backgroundOrigin",
50
+ "backgroundPosition",
51
+ "backgroundPositionX",
52
+ "backgroundPositionY",
53
+ "backgroundRepeat",
54
+ "backgroundRepeatX",
55
+ "backgroundRepeatY",
56
+ "backgroundSize",
57
+ "baselineShift",
58
+ "blockSize",
59
+ "border",
60
+ "borderBlock",
61
+ "borderBlockColor",
62
+ "borderBlockEnd",
63
+ "borderBlockEndColor",
64
+ "borderBlockEndStyle",
65
+ "borderBlockEndWidth",
66
+ "borderBlockStart",
67
+ "borderBlockStartColor",
68
+ "borderBlockStartStyle",
69
+ "borderBlockStartWidth",
70
+ "borderBlockStyle",
71
+ "borderBlockWidth",
72
+ "borderBottom",
73
+ "borderBottomColor",
74
+ "borderBottomLeftRadius",
75
+ "borderBottomRightRadius",
76
+ "borderBottomStyle",
77
+ "borderBottomWidth",
78
+ "borderCollapse",
79
+ "borderColor",
80
+ "borderImage",
81
+ "borderImageOutset",
82
+ "borderImageRepeat",
83
+ "borderImageSlice",
84
+ "borderImageSource",
85
+ "borderImageWidth",
86
+ "borderLeft",
87
+ "borderLeftColor",
88
+ "borderLeftStyle",
89
+ "borderLeftWidth",
90
+ "borderRadius",
91
+ "borderRight",
92
+ "borderRightColor",
93
+ "borderRightStyle",
94
+ "borderRightWidth",
95
+ "borderSpacing",
96
+ "borderStyle",
97
+ "borderTop",
98
+ "borderTopColor",
99
+ "borderTopLeftRadius",
100
+ "borderTopRightRadius",
101
+ "borderTopStyle",
102
+ "borderTopWidth",
103
+ "borderWidth",
104
+ "bottom",
105
+ "boxDecorationBreak",
106
+ "boxShadow",
107
+ "boxSizing",
108
+ "breakAfter",
109
+ "breakBefore",
110
+ "breakInside",
111
+ "captionSide",
112
+ "caretColor",
113
+ "clear",
114
+ "clip",
115
+ "clipPath",
116
+ "color",
117
+ "colorAdjust",
118
+ "colorInterpolation",
119
+ "colorInterpolationFilters",
120
+ "colorRendering",
121
+ "columnCount",
122
+ "columnFill",
123
+ "columnGap",
124
+ "columnRule",
125
+ "columnRuleColor",
126
+ "columnRuleStyle",
127
+ "columnRuleWidth",
128
+ "columnSpan",
129
+ "columnWidth",
130
+ "columns",
131
+ "contain",
132
+ "content",
133
+ "counterIncrement",
134
+ "counterReset",
135
+ "cursor",
136
+ "direction",
137
+ "display",
138
+ "emptyCells",
139
+ "filter",
140
+ "flex",
141
+ "flexBasis",
142
+ "flexDirection",
143
+ "flexFlow",
144
+ "flexGrow",
145
+ "flexShrink",
146
+ "flexWrap",
147
+ "float",
148
+ "font",
149
+ "fontFamily",
150
+ "fontFeatureSettings",
151
+ "fontKerning",
152
+ "fontLanguageOverride",
153
+ "fontSize",
154
+ "fontSizeAdjust",
155
+ "fontStretch",
156
+ "fontStyle",
157
+ "fontVariant",
158
+ "fontVariantAlternates",
159
+ "fontVariantCaps",
160
+ "fontVariantEastAsian",
161
+ "fontVariantNumeric",
162
+ "fontVariantPosition",
163
+ "fontWeight",
164
+ "fontVariationSettings",
165
+ "fontSynthesis",
166
+ "forcedColorAdjust",
167
+ "gap",
168
+ "grid",
169
+ "gridArea",
170
+ "gridAutoColumns",
171
+ "gridAutoFlow",
172
+ "gridAutoRows",
173
+ "gridColumn",
174
+ "gridColumnEnd",
175
+ "gridColumnGap",
176
+ "gridColumnStart",
177
+ "gridGap",
178
+ "gridRow",
179
+ "gridRowEnd",
180
+ "gridRowGap",
181
+ "gridRowStart",
182
+ "gridTemplate",
183
+ "gridTemplateAreas",
184
+ "gridTemplateColumns",
185
+ "gridTemplateRows",
186
+ "height",
187
+ "hyphens",
188
+ "imageOrientation",
189
+ "imageRendering",
190
+ "imeMode",
191
+ "inset",
192
+ "insetBlock",
193
+ "insetBlockEnd",
194
+ "insetBlockStart",
195
+ "insetInline",
196
+ "insetInlineEnd",
197
+ "insetInlineStart",
198
+ "initialLetter",
199
+ "isolation",
200
+ "justifyContent",
201
+ "justifyItems",
202
+ "justifySelf",
203
+ "left",
204
+ "letterSpacing",
205
+ "lineBreak",
206
+ "lineClamp",
207
+ "lineHeight",
208
+ "listStyle",
209
+ "listStyleImage",
210
+ "listStylePosition",
211
+ "listStyleType",
212
+ "margin",
213
+ "marginBottom",
214
+ "marginLeft",
215
+ "marginRight",
216
+ "marginTop",
217
+ "marginBlock",
218
+ "marginBlockEnd",
219
+ "marginBlockStart",
220
+ "marginInline",
221
+ "marginInlineEnd",
222
+ "marginInlineStart",
223
+ "mask",
224
+ "maskBorder",
225
+ "maskBorderImage",
226
+ "maskBorderOutset",
227
+ "maskBorderRepeat",
228
+ "maskBorderSlice",
229
+ "maskBorderSource",
230
+ "maskBorderWidth",
231
+ "maskClip",
232
+ "maskComposite",
233
+ "maskImage",
234
+ "maskOrigin",
235
+ "maskPosition",
236
+ "maskRepeat",
237
+ "maskSize",
238
+ "maskType",
239
+ "maxBlockSize",
240
+ "maxHeight",
241
+ "maxInlineSize",
242
+ "maxWidth",
243
+ "minBlockSize",
244
+ "minHeight",
245
+ "minInlineSize",
246
+ "minWidth",
247
+ "mixBlendMode",
248
+ "objectFit",
249
+ "objectPosition",
250
+ "objectViewBox",
251
+ "offset",
252
+ "offsetDistance",
253
+ "offsetPath",
254
+ "offsetRotate",
255
+ "opacity",
256
+ "order",
257
+ "orientation",
258
+ "outline",
259
+ "outlineColor",
260
+ "outlineOffset",
261
+ "outlineStyle",
262
+ "outlineWidth",
263
+ "overflow",
264
+ "overflowAnchor",
265
+ "overflowClip",
266
+ "overflowScrolling",
267
+ "overflowWrap",
268
+ "overflowX",
269
+ "overflowY",
270
+ "padding",
271
+ "paddingBottom",
272
+ "paddingLeft",
273
+ "paddingRight",
274
+ "paddingTop",
275
+ "pageBreakAfter",
276
+ "pageBreakBefore",
277
+ "pageBreakInside",
278
+ "paintOrder",
279
+ "perspective",
280
+ "perspectiveOrigin",
281
+ "placeContent",
282
+ "placeItems",
283
+ "placeSelf",
284
+ "pointerEvents",
285
+ "position",
286
+ "resize",
287
+ "right",
288
+ "rotate",
289
+ "rowGap",
290
+ "scrollBehavior",
291
+ "scrollPadding",
292
+ "scrollSnapAlign",
293
+ "scrollSnapType",
294
+ "scrollbarColor",
295
+ "scrollbarWidth",
296
+ "shapeImageThreshold",
297
+ "shapeMargin",
298
+ "shapeOutside",
299
+ "tabSize",
300
+ "tableLayout",
301
+ "textAlign",
302
+ "textAlignLast",
303
+ "textDecoration",
304
+ "textDecorationColor",
305
+ "textDecorationLine",
306
+ "textDecorationSkipInk",
307
+ "textDecorationStyle",
308
+ "textDecorationThickness",
309
+ "textIndent",
310
+ "textOverflow",
311
+ "textShadow",
312
+ "textTransform",
313
+ "textUnderlineOffset",
314
+ "top",
315
+ "transform",
316
+ "transformOrigin",
317
+ "transformStyle",
318
+ "transition",
319
+ "transitionDelay",
320
+ "transitionDuration",
321
+ "transitionProperty",
322
+ "transitionTimingFunction",
323
+ "translate",
324
+ "translateX",
325
+ "translateY",
326
+ "translateZ",
327
+ "unicodeBidi",
328
+ "userSelect",
329
+ "verticalAlign",
330
+ "visibility",
331
+ "whiteSpace",
332
+ "widows",
333
+ "width",
334
+ "willChange",
335
+ "wordBreak",
336
+ "wordSpacing",
337
+ "wordWrap",
338
+ "writingMode",
339
+ "zIndex"
340
+ ];
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,13 +17,23 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var registry_exports = {};
20
30
  __export(registry_exports, {
31
+ CSS_PREPROCS_DEFAULTS: () => CSS_PREPROCS_DEFAULTS,
21
32
  CSS_PROPS_REGISTRY: () => CSS_PROPS_REGISTRY
22
33
  });
23
34
  module.exports = __toCommonJS(registry_exports);
24
35
  var import_utils = require("@domql/utils");
36
+ var preprocs = __toESM(require("./props"), 1);
25
37
  var import_atoms = require("@symbo.ls/atoms");
26
38
  const CSS_PROPS_REGISTRY = (0, import_utils.mergeArray)([
27
39
  import_atoms.Shape,
@@ -37,3 +49,4 @@ const CSS_PROPS_REGISTRY = (0, import_utils.mergeArray)([
37
49
  import_atoms.XYZ,
38
50
  import_atoms.Animation
39
51
  ]).class;
52
+ const CSS_PREPROCS_DEFAULTS = (0, import_utils.mergeArray)(Object.values(preprocs));
@@ -18,35 +18,66 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var transform_exports = {};
20
20
  __export(transform_exports, {
21
+ extractCSSfromProps: () => extractCSSfromProps,
21
22
  transformClassname: () => transformClassname
22
23
  });
23
24
  module.exports = __toCommonJS(transform_exports);
24
25
  var import_utils = require("@domql/utils");
25
26
  var import_atoms = require("@symbo.ls/atoms");
26
27
  var import_registry = require("./registry");
27
- const transformClassname = (props, context = {}, registry = import_registry.CSS_PROPS_REGISTRY, excludedProps = {}, element) => {
28
- const CLASS_NAMES = {};
28
+ var import_defaults = require("./defaults");
29
+ const transformClassname = (element, restProps = {}) => {
30
+ const classCss = {};
31
+ const { props, class: elementClass } = element;
29
32
  if (!(0, import_utils.isObject)(props))
30
33
  return;
31
- (0, import_utils.merge)(element.class, registry);
32
- if (Object.keys(registry)[0] !== Object.keys(import_registry.CSS_PROPS_REGISTRY)[0]) {
33
- (0, import_utils.merge)(element.class, import_registry.CSS_PROPS_REGISTRY);
34
- }
35
34
  for (const key in props) {
36
35
  const setter = import_atoms.keySetters[key.slice(0, 1)];
37
- const hasCSS = registry[key];
36
+ const hasCSS = elementClass[key];
38
37
  if (setter)
39
- setter(key, props[key], CLASS_NAMES, element, true);
38
+ setter(key, props[key], classCss, element, true);
40
39
  else if ((0, import_utils.isFunction)(hasCSS)) {
41
- const stack = hasCSS({ ...element, props, context });
40
+ const stack = hasCSS(element, element.state, element.context);
42
41
  const exec = (0, import_utils.isArray)(stack) ? stack.reduce((a, c) => {
43
42
  return (0, import_utils.merge)(a, c);
44
43
  }, {}) : stack;
45
- (0, import_utils.deepMerge)(CLASS_NAMES, exec);
44
+ (0, import_utils.deepMerge)(classCss, exec);
46
45
  } else if (key === "style") {
47
- (0, import_utils.deepMerge)(CLASS_NAMES, props[key]);
46
+ (0, import_utils.deepMerge)(classCss, props[key]);
48
47
  } else
49
- excludedProps[key] = props[key];
48
+ restProps[key] = props[key];
49
+ }
50
+ return classCss;
51
+ };
52
+ const extractCSSfromProps = (element) => {
53
+ const { props: defProps } = element;
54
+ const css = {};
55
+ const props = {};
56
+ for (const key in defProps) {
57
+ const val = defProps[key];
58
+ const mediaProp = import_atoms.keySetters[key.slice(0, 1)];
59
+ if (mediaProp) {
60
+ mediaProp(key, defProps[key], css, element, true);
61
+ continue;
62
+ }
63
+ const preprop = import_registry.CSS_PREPROCS_DEFAULTS[key];
64
+ if (preprop) {
65
+ const stack = preprop(element, element.state, element.context);
66
+ const exec = (0, import_utils.isArray)(stack) ? stack.reduce((a, c) => {
67
+ return (0, import_utils.merge)(a, c);
68
+ }, {}) : stack;
69
+ (0, import_utils.deepMerge)(css, exec);
70
+ continue;
71
+ }
72
+ if (key === "style") {
73
+ (0, import_utils.deepMerge)(css, defProps[key]);
74
+ continue;
75
+ }
76
+ if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.includes(key)) {
77
+ css[key] = val;
78
+ continue;
79
+ }
80
+ props[key] = val;
50
81
  }
51
- return CLASS_NAMES;
82
+ return { css, props };
52
83
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "css-in-props",
3
3
  "description": "Utilize props as CSS methods",
4
4
  "author": "symbo.ls",
5
- "version": "2.11.453",
5
+ "version": "2.11.455",
6
6
  "repository": "https://github.com/symbo-ls/smbls",
7
7
  "type": "module",
8
8
  "module": "src/index.js",
@@ -26,9 +26,9 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@domql/utils": "^2.5.0",
29
- "@symbo.ls/atoms": "^2.11.453",
29
+ "@symbo.ls/atoms": "^2.11.455",
30
30
  "@symbo.ls/emotion": "^2.11.453",
31
31
  "@symbo.ls/scratch": "^2.11.453"
32
32
  },
33
- "gitHead": "8e5458a957b9d2c75944023e2c31bab157034314"
33
+ "gitHead": "2ec12ac36ba08a2d424a3806dba7ccb6f7bddfba"
34
34
  }
@@ -0,0 +1,318 @@
1
+ export const DEFAULT_CSS_PROPERTIES_LIST = [
2
+ 'accentColor',
3
+ 'alignContent',
4
+ 'alignItems',
5
+ 'alignSelf',
6
+ 'alignmentBaseline',
7
+ 'all',
8
+ 'animation',
9
+ 'animationDelay',
10
+ 'animationDirection',
11
+ 'animationDuration',
12
+ 'animationFillMode',
13
+ 'animationIterationCount',
14
+ 'animationName',
15
+ 'animationPlayState',
16
+ 'animationTimingFunction',
17
+ 'appearance',
18
+ 'aspectRatio',
19
+ 'backdropFilter',
20
+ 'backfaceVisibility',
21
+ 'background',
22
+ 'backgroundAttachment',
23
+ 'backgroundBlendMode',
24
+ 'backgroundClip',
25
+ 'backgroundColor',
26
+ 'backgroundImage',
27
+ 'backgroundOrigin',
28
+ 'backgroundPosition',
29
+ 'backgroundPositionX',
30
+ 'backgroundPositionY',
31
+ 'backgroundRepeat',
32
+ 'backgroundRepeatX',
33
+ 'backgroundRepeatY',
34
+ 'backgroundSize',
35
+ 'baselineShift',
36
+ 'blockSize',
37
+ 'border',
38
+ 'borderBlock',
39
+ 'borderBlockColor',
40
+ 'borderBlockEnd',
41
+ 'borderBlockEndColor',
42
+ 'borderBlockEndStyle',
43
+ 'borderBlockEndWidth',
44
+ 'borderBlockStart',
45
+ 'borderBlockStartColor',
46
+ 'borderBlockStartStyle',
47
+ 'borderBlockStartWidth',
48
+ 'borderBlockStyle',
49
+ 'borderBlockWidth',
50
+ 'borderBottom',
51
+ 'borderBottomColor',
52
+ 'borderBottomLeftRadius',
53
+ 'borderBottomRightRadius',
54
+ 'borderBottomStyle',
55
+ 'borderBottomWidth',
56
+ 'borderCollapse',
57
+ 'borderColor',
58
+ 'borderImage',
59
+ 'borderImageOutset',
60
+ 'borderImageRepeat',
61
+ 'borderImageSlice',
62
+ 'borderImageSource',
63
+ 'borderImageWidth',
64
+ 'borderLeft',
65
+ 'borderLeftColor',
66
+ 'borderLeftStyle',
67
+ 'borderLeftWidth',
68
+ 'borderRadius',
69
+ 'borderRight',
70
+ 'borderRightColor',
71
+ 'borderRightStyle',
72
+ 'borderRightWidth',
73
+ 'borderSpacing',
74
+ 'borderStyle',
75
+ 'borderTop',
76
+ 'borderTopColor',
77
+ 'borderTopLeftRadius',
78
+ 'borderTopRightRadius',
79
+ 'borderTopStyle',
80
+ 'borderTopWidth',
81
+ 'borderWidth',
82
+ 'bottom',
83
+ 'boxDecorationBreak',
84
+ 'boxShadow',
85
+ 'boxSizing',
86
+ 'breakAfter',
87
+ 'breakBefore',
88
+ 'breakInside',
89
+ 'captionSide',
90
+ 'caretColor',
91
+ 'clear',
92
+ 'clip',
93
+ 'clipPath',
94
+ 'color',
95
+ 'colorAdjust',
96
+ 'colorInterpolation',
97
+ 'colorInterpolationFilters',
98
+ 'colorRendering',
99
+ 'columnCount',
100
+ 'columnFill',
101
+ 'columnGap',
102
+ 'columnRule',
103
+ 'columnRuleColor',
104
+ 'columnRuleStyle',
105
+ 'columnRuleWidth',
106
+ 'columnSpan',
107
+ 'columnWidth',
108
+ 'columns',
109
+ 'contain',
110
+ 'content',
111
+ 'counterIncrement',
112
+ 'counterReset',
113
+ 'cursor',
114
+ 'direction',
115
+ 'display',
116
+ 'emptyCells',
117
+ 'filter',
118
+ 'flex',
119
+ 'flexBasis',
120
+ 'flexDirection',
121
+ 'flexFlow',
122
+ 'flexGrow',
123
+ 'flexShrink',
124
+ 'flexWrap',
125
+ 'float',
126
+ 'font',
127
+ 'fontFamily',
128
+ 'fontFeatureSettings',
129
+ 'fontKerning',
130
+ 'fontLanguageOverride',
131
+ 'fontSize',
132
+ 'fontSizeAdjust',
133
+ 'fontStretch',
134
+ 'fontStyle',
135
+ 'fontVariant',
136
+ 'fontVariantAlternates',
137
+ 'fontVariantCaps',
138
+ 'fontVariantEastAsian',
139
+ 'fontVariantNumeric',
140
+ 'fontVariantPosition',
141
+ 'fontWeight',
142
+ 'fontVariationSettings',
143
+ 'fontSynthesis',
144
+ 'forcedColorAdjust',
145
+ 'gap',
146
+ 'grid',
147
+ 'gridArea',
148
+ 'gridAutoColumns',
149
+ 'gridAutoFlow',
150
+ 'gridAutoRows',
151
+ 'gridColumn',
152
+ 'gridColumnEnd',
153
+ 'gridColumnGap',
154
+ 'gridColumnStart',
155
+ 'gridGap',
156
+ 'gridRow',
157
+ 'gridRowEnd',
158
+ 'gridRowGap',
159
+ 'gridRowStart',
160
+ 'gridTemplate',
161
+ 'gridTemplateAreas',
162
+ 'gridTemplateColumns',
163
+ 'gridTemplateRows',
164
+ 'height',
165
+ 'hyphens',
166
+ 'imageOrientation',
167
+ 'imageRendering',
168
+ 'imeMode',
169
+ 'inset',
170
+ 'insetBlock',
171
+ 'insetBlockEnd',
172
+ 'insetBlockStart',
173
+ 'insetInline',
174
+ 'insetInlineEnd',
175
+ 'insetInlineStart',
176
+ 'initialLetter',
177
+ 'isolation',
178
+ 'justifyContent',
179
+ 'justifyItems',
180
+ 'justifySelf',
181
+ 'left',
182
+ 'letterSpacing',
183
+ 'lineBreak',
184
+ 'lineClamp',
185
+ 'lineHeight',
186
+ 'listStyle',
187
+ 'listStyleImage',
188
+ 'listStylePosition',
189
+ 'listStyleType',
190
+ 'margin',
191
+ 'marginBottom',
192
+ 'marginLeft',
193
+ 'marginRight',
194
+ 'marginTop',
195
+ 'marginBlock',
196
+ 'marginBlockEnd',
197
+ 'marginBlockStart',
198
+ 'marginInline',
199
+ 'marginInlineEnd',
200
+ 'marginInlineStart',
201
+ 'mask',
202
+ 'maskBorder',
203
+ 'maskBorderImage',
204
+ 'maskBorderOutset',
205
+ 'maskBorderRepeat',
206
+ 'maskBorderSlice',
207
+ 'maskBorderSource',
208
+ 'maskBorderWidth',
209
+ 'maskClip',
210
+ 'maskComposite',
211
+ 'maskImage',
212
+ 'maskOrigin',
213
+ 'maskPosition',
214
+ 'maskRepeat',
215
+ 'maskSize',
216
+ 'maskType',
217
+ 'maxBlockSize',
218
+ 'maxHeight',
219
+ 'maxInlineSize',
220
+ 'maxWidth',
221
+ 'minBlockSize',
222
+ 'minHeight',
223
+ 'minInlineSize',
224
+ 'minWidth',
225
+ 'mixBlendMode',
226
+ 'objectFit',
227
+ 'objectPosition',
228
+ 'objectViewBox',
229
+ 'offset',
230
+ 'offsetDistance',
231
+ 'offsetPath',
232
+ 'offsetRotate',
233
+ 'opacity',
234
+ 'order',
235
+ 'orientation',
236
+ 'outline',
237
+ 'outlineColor',
238
+ 'outlineOffset',
239
+ 'outlineStyle',
240
+ 'outlineWidth',
241
+ 'overflow',
242
+ 'overflowAnchor',
243
+ 'overflowClip',
244
+ 'overflowScrolling',
245
+ 'overflowWrap',
246
+ 'overflowX',
247
+ 'overflowY',
248
+ 'padding',
249
+ 'paddingBottom',
250
+ 'paddingLeft',
251
+ 'paddingRight',
252
+ 'paddingTop',
253
+ 'pageBreakAfter',
254
+ 'pageBreakBefore',
255
+ 'pageBreakInside',
256
+ 'paintOrder',
257
+ 'perspective',
258
+ 'perspectiveOrigin',
259
+ 'placeContent',
260
+ 'placeItems',
261
+ 'placeSelf',
262
+ 'pointerEvents',
263
+ 'position',
264
+ 'resize',
265
+ 'right',
266
+ 'rotate',
267
+ 'rowGap',
268
+ 'scrollBehavior',
269
+ 'scrollPadding',
270
+ 'scrollSnapAlign',
271
+ 'scrollSnapType',
272
+ 'scrollbarColor',
273
+ 'scrollbarWidth',
274
+ 'shapeImageThreshold',
275
+ 'shapeMargin',
276
+ 'shapeOutside',
277
+ 'tabSize',
278
+ 'tableLayout',
279
+ 'textAlign',
280
+ 'textAlignLast',
281
+ 'textDecoration',
282
+ 'textDecorationColor',
283
+ 'textDecorationLine',
284
+ 'textDecorationSkipInk',
285
+ 'textDecorationStyle',
286
+ 'textDecorationThickness',
287
+ 'textIndent',
288
+ 'textOverflow',
289
+ 'textShadow',
290
+ 'textTransform',
291
+ 'textUnderlineOffset',
292
+ 'top',
293
+ 'transform',
294
+ 'transformOrigin',
295
+ 'transformStyle',
296
+ 'transition',
297
+ 'transitionDelay',
298
+ 'transitionDuration',
299
+ 'transitionProperty',
300
+ 'transitionTimingFunction',
301
+ 'translate',
302
+ 'translateX',
303
+ 'translateY',
304
+ 'translateZ',
305
+ 'unicodeBidi',
306
+ 'userSelect',
307
+ 'verticalAlign',
308
+ 'visibility',
309
+ 'whiteSpace',
310
+ 'widows',
311
+ 'width',
312
+ 'willChange',
313
+ 'wordBreak',
314
+ 'wordSpacing',
315
+ 'wordWrap',
316
+ 'writingMode',
317
+ 'zIndex'
318
+ ]
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ import { isObject } from '@domql/utils'
4
+ import { emotion } from '@symbo.ls/emotion'
5
+ import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
6
+
7
+ const applyAnimationProps = (animation, element) => {
8
+ const { emotion: ctxEmotion } = element.context
9
+ const { keyframes } = ctxEmotion || emotion
10
+ if (isObject(animation)) return { animationName: keyframes(animation) }
11
+ const { ANIMATION } = element.context && element.context.designSystem
12
+ const record = ANIMATION[animation]
13
+ return keyframes(record)
14
+ }
15
+
16
+ export const ANIMATION_PROPS = {
17
+ animation: (el) => ({
18
+ animationName: applyAnimationProps(el.props.animation, el),
19
+ animationDuration: getTimingByKey(el.props.animationDuration || 'A').timing,
20
+ animationDelay: getTimingByKey(el.props.animationDelay || '0s').timing,
21
+ animationTimingFunction: getTimingFunction(el.props.animationTimingFunction || 'ease'),
22
+ animationFillMode: el.props.animationFillMode || 'both',
23
+ animationPlayState: el.props.animationPlayState,
24
+ animationDirection: el.props.animationDirection
25
+ }),
26
+ animationName: (el) => ({
27
+ animationName: applyAnimationProps(el.props.animationName, el)
28
+ }),
29
+ animationDuration: ({ props, deps }) => ({
30
+ animationDuration: deps.getTimingByKey(props.animationDuration).timing
31
+ }),
32
+ animationDelay: ({ props, deps }) => ({
33
+ animationDelay: deps.getTimingByKey(props.animationDelay).timing
34
+ }),
35
+ animationTimingFunction: ({ props, deps }) => ({
36
+ animationTimingFunction: deps.getTimingFunction(props.animationTimingFunction)
37
+ })
38
+ }
@@ -0,0 +1,174 @@
1
+ 'use strict'
2
+
3
+ import { isUndefined, isString } from '@domql/utils'
4
+
5
+ import {
6
+ getSpacingBasedOnRatio,
7
+ transformSize,
8
+ transformSizeRatio,
9
+ transfromGap
10
+ } from '@symbo.ls/scratch'
11
+
12
+ export const BLOCK_PROPS = {
13
+ show: (el, s, ctx) => !!(ctx.utils.exec(el.props.show, el, s) === false) && ({
14
+ display: 'none !important'
15
+ }),
16
+
17
+ hide: (el, s, ctx) => !!ctx.utils.exec(el.props.hide, el, s) && ({
18
+ display: 'none !important'
19
+ }),
20
+
21
+ height: ({ props }) => transformSizeRatio('height', props),
22
+ width: ({ props }) => transformSizeRatio('width', props),
23
+
24
+ boxSizing: ({ props }) => !isUndefined(props.boxSizing)
25
+ ? ({ boxSizing: props.boxSizing })
26
+ : { boxSizing: 'border-box' },
27
+
28
+ boxSize: ({ props }) => {
29
+ if (!isString(props.boxSize)) return
30
+ const [height, width] = props.boxSize.split(' ')
31
+ return {
32
+ ...transformSize('height', height),
33
+ ...transformSize('width', width || height)
34
+ }
35
+ },
36
+
37
+ inlineSize: ({ props }) => transformSizeRatio('inlineSize', props),
38
+ blockSize: ({ props }) => transformSizeRatio('blockSize', props),
39
+
40
+ minWidth: ({ props }) => transformSizeRatio('minWidth', props),
41
+ maxWidth: ({ props }) => transformSizeRatio('maxWidth', props),
42
+ widthRange: ({ props }) => {
43
+ if (!isString(props.widthRange)) return
44
+ const [minWidth, maxWidth] = props.widthRange.split(' ')
45
+ return {
46
+ ...transformSize('minWidth', minWidth),
47
+ ...transformSize('maxWidth', maxWidth || minWidth)
48
+ }
49
+ },
50
+
51
+ minHeight: ({ props }) => transformSizeRatio('minHeight', props),
52
+ maxHeight: ({ props }) => transformSizeRatio('maxHeight', props),
53
+ heightRange: ({ props }) => {
54
+ if (!isString(props.heightRange)) return
55
+ const [minHeight, maxHeight] = props.heightRange.split(' ')
56
+ return {
57
+ ...transformSize('minHeight', minHeight),
58
+ ...transformSize('maxHeight', maxHeight || minHeight)
59
+ }
60
+ },
61
+
62
+ size: ({ props }) => {
63
+ if (!isString(props.size)) return
64
+ const [inlineSize, blockSize] = props.size.split(' ')
65
+ return {
66
+ ...transformSizeRatio('inlineSize', inlineSize),
67
+ ...transformSizeRatio('blockSize', blockSize || inlineSize)
68
+ }
69
+ },
70
+
71
+ minBlockSize: ({ props }) => transformSizeRatio('minBlockSize', props),
72
+ minInlineSize: ({ props }) => transformSizeRatio('minInlineSize', props),
73
+
74
+ maxBlockSize: ({ props }) => transformSizeRatio('maxBlockSize', props),
75
+ maxInlineSize: ({ props }) => transformSizeRatio('maxInlineSize', props),
76
+
77
+ minSize: ({ props }) => {
78
+ if (!isString(props.minSize)) return
79
+ const [minInlineSize, minBlockSize] = props.minSize.split(' ')
80
+ return {
81
+ ...transformSize('minInlineSize', minInlineSize),
82
+ ...transformSize('minBlockSize', minBlockSize || minInlineSize)
83
+ }
84
+ },
85
+
86
+ maxSize: ({ props }) => {
87
+ if (!isString(props.maxSize)) return
88
+ const [maxInlineSize, maxBlockSize] = props.maxSize.split(' ')
89
+ return {
90
+ ...transformSize('maxInlineSize', maxInlineSize),
91
+ ...transformSize('maxBlockSize', maxBlockSize || maxInlineSize)
92
+ }
93
+ },
94
+
95
+ borderWidth: ({ props }) => transformSizeRatio('borderWidth', props),
96
+
97
+ padding: ({ props }) => transformSizeRatio('padding', props),
98
+ scrollPadding: ({ props }) => transformSizeRatio('scrollPadding', props),
99
+ paddingInline: ({ props }) => {
100
+ if (!isString(props.paddingInline)) return
101
+ const [paddingInlineStart, paddingInlineEnd] = props.paddingInline.split(' ')
102
+ return {
103
+ ...transformSize('paddingInlineStart', paddingInlineStart),
104
+ ...transformSize('paddingInlineEnd', paddingInlineEnd || paddingInlineStart)
105
+ }
106
+ },
107
+ paddingBlock: ({ props }) => {
108
+ if (!isString(props.paddingBlock)) return
109
+ const [paddingBlockStart, paddingBlockEnd] = props.paddingBlock.split(' ')
110
+ return {
111
+ ...transformSize('paddingBlockStart', paddingBlockStart),
112
+ ...transformSize('paddingBlockEnd', paddingBlockEnd || paddingBlockStart)
113
+ }
114
+ },
115
+ paddingInlineStart: ({ props }) => transformSizeRatio('paddingInlineStart', props),
116
+ paddingInlineEnd: ({ props }) => transformSizeRatio('paddingInlineEnd', props),
117
+ paddingBlockStart: ({ props }) => transformSizeRatio('paddingBlockStart', props),
118
+ paddingBlockEnd: ({ props }) => transformSizeRatio('paddingBlockEnd', props),
119
+
120
+ margin: ({ props }) => transformSizeRatio('margin', props),
121
+ marginInline: ({ props }) => {
122
+ if (!isString(props.marginInline)) return
123
+ const [marginInlineStart, marginInlineEnd] = props.marginInline.split(' ')
124
+ return {
125
+ ...transformSize('marginInlineStart', marginInlineStart),
126
+ ...transformSize('marginInlineEnd', marginInlineEnd || marginInlineStart)
127
+ }
128
+ },
129
+ marginBlock: ({ props }) => {
130
+ if (!isString(props.marginBlock)) return
131
+ const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(' ')
132
+ return {
133
+ ...transformSize('marginBlockStart', marginBlockStart),
134
+ ...transformSize('marginBlockEnd', marginBlockEnd || marginBlockStart)
135
+ }
136
+ },
137
+ marginInlineStart: ({ props }) => transformSizeRatio('marginInlineStart', props),
138
+ marginInlineEnd: ({ props }) => transformSizeRatio('marginInlineEnd', props),
139
+ marginBlockStart: ({ props }) => transformSizeRatio('marginBlockStart', props),
140
+ marginBlockEnd: ({ props }) => transformSizeRatio('marginBlockEnd', props),
141
+
142
+ gap: ({ props }) => ({
143
+ gap: transfromGap(props.gap)
144
+ }),
145
+
146
+ columnGap: ({ props }) => getSpacingBasedOnRatio(props, 'columnGap'),
147
+ rowGap: ({ props }) => getSpacingBasedOnRatio(props, 'rowGap'),
148
+
149
+ flexWrap: ({ props }) => ({
150
+ display: 'flex',
151
+ flexFlow: (props.flexFlow || 'row').split(' ')[0] + ' ' + props.flexWrap
152
+ }),
153
+ flexFlow: ({ props }) => {
154
+ const { flexFlow, reverse } = props
155
+ if (!isString(flexFlow)) return
156
+ let [direction, wrap] = (flexFlow || 'row').split(' ')
157
+ if (flexFlow.startsWith('x') || flexFlow === 'row') direction = 'row'
158
+ if (flexFlow.startsWith('y') || flexFlow === 'column') direction = 'column'
159
+ return {
160
+ display: 'flex',
161
+ flexFlow: (direction || '') + (!direction.includes('-reverse') && reverse ? '-reverse' : '') + ' ' + (wrap || '')
162
+ }
163
+ },
164
+ flexAlign: ({ props }) => {
165
+ if (!isString(props.flexAlign)) return
166
+ const [alignItems, justifyContent] = props.flexAlign.split(' ')
167
+ return {
168
+ display: 'flex',
169
+ alignItems,
170
+ justifyContent
171
+ }
172
+ }
173
+
174
+ }
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ import { getFontSizeByKey, getFontFamily } from '@symbo.ls/scratch'
4
+
5
+ export const FONT_PROPS = {
6
+ fontSize: (el) => {
7
+ const { props } = el
8
+ return props.fontSize ? getFontSizeByKey(props.fontSize) : null
9
+ },
10
+ fontFamily: ({ props }) => ({
11
+ fontFamily: getFontFamily(props.fontFamily) || props.fontFamily
12
+ }),
13
+ fontWeight: ({ props }) => ({
14
+ fontWeight: props.fontWeight,
15
+ fontVariationSettings: '"wght" ' + props.fontWeight
16
+ })
17
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ export * from './animation'
4
+ export * from './block'
5
+ export * from './font'
6
+ export * from './misc'
7
+ export * from './position'
8
+ export * from './theme'
9
+ export * from './timing'
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ export const MISC_PROPS = {
4
+ overflow: ({ props, deps }) => !deps.isUndefined(props.overflow) && ({
5
+ overflow: props.overflow,
6
+ scrollBehavior: 'smooth'
7
+ }),
8
+ cursor: (el, s, ctx) => {
9
+ let val = el.props.cursor
10
+ if (!val) return
11
+
12
+ const file = ctx.files && ctx.files[val]
13
+ if (file && file.content) val = `url(${file.content.src})`
14
+
15
+ return ({ cursor: val })
16
+ }
17
+ }
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ import { getSpacingByKey } from '@symbo.ls/scratch'
4
+
5
+ export const POSITION_PROPS = {
6
+ inset: ({ props, context }) => {
7
+ const { inset } = props
8
+ if (context.utils.isNumber(inset)) return ({ inset })
9
+ if (!context.utils.isString(inset)) return
10
+ return { inset: inset.split(' ').map(v => getSpacingByKey(v, 'k').k).join(' ') }
11
+ },
12
+
13
+ left: ({ props }) => getSpacingByKey(props.left, 'left'),
14
+ top: ({ props }) => getSpacingByKey(props.top, 'top'),
15
+ right: ({ props }) => getSpacingByKey(props.right, 'right'),
16
+ bottom: ({ props }) => getSpacingByKey(props.bottom, 'bottom'),
17
+
18
+ verticalInset: ({ props }) => {
19
+ const { verticalInset } = props
20
+ if (typeof verticalInset !== 'string') return
21
+ const vi = verticalInset.split(' ').map(v => getSpacingByKey(v, 'k').k)
22
+ return {
23
+ top: vi[0],
24
+ bottom: vi[1] || vi[0]
25
+ }
26
+ },
27
+
28
+ horizontalInset: ({ props }) => {
29
+ const { horizontalInset } = props
30
+ if (typeof horizontalInset !== 'string') return
31
+ const vi = horizontalInset.split(' ').map(v => getSpacingByKey(v, 'k').k)
32
+ return {
33
+ left: vi[0],
34
+ right: vi[1] || vi[0]
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,149 @@
1
+ 'use strict'
2
+
3
+ import {
4
+ getMediaTheme,
5
+ getMediaColor,
6
+ transformTextStroke,
7
+ transformShadow,
8
+ transformBoxShadow,
9
+ transformBorder,
10
+ transformBackgroundImage,
11
+ transformSizeRatio
12
+ } from '@symbo.ls/scratch'
13
+
14
+ import { isString } from '@domql/utils'
15
+
16
+ export const getSystemGlobalTheme = ({ context, state }) => {
17
+ const rootState = state && state.root
18
+ return rootState && rootState.globalTheme ? rootState.globalTheme : context.designSystem && context.designSystem.globalTheme
19
+ }
20
+
21
+ export const THEME_PROPS = {
22
+ theme: (element) => {
23
+ const { props } = element
24
+ const globalTheme = getSystemGlobalTheme(element)
25
+ if (!props.theme) return
26
+ const hasSubtheme = props.theme.includes(' ') && !props.theme.includes('@')
27
+ const globalThemeForced = `@${props.themeModifier || globalTheme}`
28
+ if (hasSubtheme) {
29
+ const themeAppliedInVal = props.theme.split(' ')
30
+ themeAppliedInVal.splice(1, 0, globalThemeForced)
31
+ return getMediaTheme(themeAppliedInVal)
32
+ } else if (props.theme.includes('@{globalTheme}')) props.theme.replace('@{globalTheme}', globalThemeForced)
33
+ return getMediaTheme(props.theme, `@${props.themeModifier || globalTheme}`)
34
+ },
35
+
36
+ color: (element) => {
37
+ const { props } = element
38
+ const globalTheme = getSystemGlobalTheme(element)
39
+ if (!props.color) return
40
+ return {
41
+ color: getMediaColor(props.color, globalTheme)
42
+ }
43
+ },
44
+
45
+ background: (element) => {
46
+ const { props } = element
47
+ const globalTheme = getSystemGlobalTheme(element)
48
+ if (!props.background) return
49
+ return {
50
+ background: getMediaColor(props.background, globalTheme)
51
+ }
52
+ },
53
+
54
+ backgroundColor: (element) => {
55
+ const { props } = element
56
+ const globalTheme = getSystemGlobalTheme(element)
57
+ if (!props.backgroundColor) return
58
+ return {
59
+ backgroundColor: getMediaColor(props.backgroundColor, globalTheme)
60
+ }
61
+ },
62
+
63
+ backgroundImage: (element, s, ctx) => {
64
+ const { props } = element
65
+ const globalTheme = getSystemGlobalTheme(element)
66
+ let val = props.backgroundImage
67
+ if (!val) return
68
+ const file = ctx.files && ctx.files[val]
69
+ if (file && file.content) val = file.content.src
70
+ return ({
71
+ backgroundImage: transformBackgroundImage(val, globalTheme)
72
+ })
73
+ },
74
+
75
+ backgroundSize: ({ props }) => ({
76
+ backgroundSize: props.backgroundSize
77
+ }),
78
+
79
+ backgroundPosition: ({ props }) => ({
80
+ backgroundPosition: props.backgroundPosition
81
+ }),
82
+
83
+ backgroundRepeat: ({ props }) => ({
84
+ backgroundRepeat: props.backgroundRepeat
85
+ }),
86
+
87
+ textStroke: ({ props }) => ({
88
+ WebkitTextStroke: transformTextStroke(props.textStroke)
89
+ }),
90
+
91
+ outline: ({ props }) => ({
92
+ outline: transformBorder(props.outline)
93
+ }),
94
+
95
+ outlineOffset: ({ props }) => transformSizeRatio('outlineOffset', props),
96
+
97
+ border: ({ props }) => ({
98
+ border: transformBorder(props.border)
99
+ }),
100
+
101
+ borderColor: (element) => {
102
+ const { props } = element
103
+ const globalTheme = getSystemGlobalTheme(element)
104
+ if (!props.borderColor) return
105
+ return {
106
+ borderColor: getMediaColor(props.borderColor, globalTheme)
107
+ }
108
+ },
109
+ borderLeft: ({ props }) => ({
110
+ borderLeft: transformBorder(props.borderLeft)
111
+ }),
112
+ borderTop: ({ props }) => ({
113
+ borderTop: transformBorder(props.borderTop)
114
+ }),
115
+ borderRight: ({ props }) => ({
116
+ borderRight: transformBorder(props.borderRight)
117
+ }),
118
+ borderBottom: ({ props }) => ({
119
+ borderBottom: transformBorder(props.borderBottom)
120
+ }),
121
+
122
+ shadow: (element) => {
123
+ const { props } = element
124
+ const globalTheme = getSystemGlobalTheme(element)
125
+ if (!props.backgroundImage) return
126
+ return ({
127
+ boxShadow: transformShadow(props.shadow, globalTheme)
128
+ })
129
+ },
130
+
131
+ boxShadow: (element, state, context) => {
132
+ const { props } = element
133
+ if (!isString(props.boxShadow)) return
134
+ const [val, hasImportant] = props.boxShadow.split('!importan')
135
+ const globalTheme = getSystemGlobalTheme(element)
136
+ const important = hasImportant ? ' !important' : ''
137
+ return {
138
+ boxShadow: transformBoxShadow(val.trim(), globalTheme) + important
139
+ }
140
+ },
141
+
142
+ textShadow: ({ props, context }) => ({
143
+ textShadow: transformBoxShadow(props.textShadow, context.designSystem.globalTheme)
144
+ }),
145
+
146
+ columnRule: ({ props }) => ({
147
+ columnRule: transformBorder(props.columnRule)
148
+ })
149
+ }
@@ -0,0 +1,26 @@
1
+ 'use strict'
2
+
3
+ import {
4
+ getTimingFunction,
5
+ splitTransition,
6
+ transformDuration
7
+ } from '@symbo.ls/scratch'
8
+
9
+ export const TIMING_PROPS = {
10
+ transition: ({ props }) => ({
11
+ transition: splitTransition(props.transition)
12
+ }),
13
+ transitionDuration: ({ props }) => ({
14
+ transitionDuration: transformDuration(props.transitionDuration)
15
+ }),
16
+ transitionDelay: ({ props }) => ({
17
+ transitionDelay: transformDuration(props.transitionDelay)
18
+ }),
19
+ transitionTimingFunction: ({ props }) => ({
20
+ transitionTimingFunction: getTimingFunction(props.transitionTimingFunction)
21
+ }),
22
+ transitionProperty: ({ props }) => ({
23
+ transitionProperty: props.transitionProperty,
24
+ willChange: props.transitionProperty
25
+ })
26
+ }
package/src/registry.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { mergeArray } from '@domql/utils'
4
+ import * as preprocs from './props'
4
5
 
5
6
  import {
6
7
  Shape,
@@ -31,3 +32,5 @@ export const CSS_PROPS_REGISTRY = mergeArray([
31
32
  XYZ,
32
33
  Animation
33
34
  ]).class
35
+
36
+ export const CSS_PREPROCS_DEFAULTS = mergeArray(Object.values(preprocs))
package/src/transform.js CHANGED
@@ -3,35 +3,84 @@
3
3
  import { merge, deepMerge, isFunction, isObject, isArray } from '@domql/utils'
4
4
  import { keySetters } from '@symbo.ls/atoms'
5
5
 
6
- import { CSS_PROPS_REGISTRY } from './registry'
6
+ import { CSS_PREPROCS_DEFAULTS } from './registry'
7
+ import { DEFAULT_CSS_PROPERTIES_LIST } from './defaults'
8
+
9
+ export const transformClassname = (
10
+ element,
11
+ restProps = {}
12
+ ) => {
13
+ const classCss = {}
14
+ const { props, class: elementClass } = element
7
15
 
8
- export const transformClassname = (props, context = {}, registry = CSS_PROPS_REGISTRY, excludedProps = {}, element) => {
9
- const CLASS_NAMES = {}
10
16
  if (!isObject(props)) return
11
17
 
12
- merge(element.class, registry)
13
- if (Object.keys(registry)[0] !== Object.keys(CSS_PROPS_REGISTRY)[0]) {
14
- merge(element.class, CSS_PROPS_REGISTRY)
15
- }
18
+ // merge(elementClass, registry)
19
+ // if (registry && Object.keys(registry)[0] !== Object.keys(CSS_PROPS_REGISTRY)[0]) {
20
+ // merge(elementClass, CSS_PROPS_REGISTRY)
21
+ // }
16
22
 
17
23
  for (const key in props) {
18
24
  const setter = keySetters[key.slice(0, 1)]
19
- const hasCSS = registry[key]
25
+ const hasCSS = elementClass[key]
20
26
 
21
- if (setter) setter(key, props[key], CLASS_NAMES, element, true)
27
+ if (setter) setter(key, props[key], classCss, element, true)
22
28
  else if (isFunction(hasCSS)) {
23
29
  // const stack = hasCSS(element)
24
- const stack = hasCSS({ ...element, props, context })
30
+ const stack = hasCSS(element, element.state, element.context)
25
31
  const exec = isArray(stack)
26
32
  ? stack.reduce((a, c) => {
27
33
  return merge(a, c)
28
34
  }, {})
29
35
  : stack
30
- deepMerge(CLASS_NAMES, exec)
36
+ deepMerge(classCss, exec)
31
37
  } else if (key === 'style') {
32
- deepMerge(CLASS_NAMES, props[key])
33
- } else excludedProps[key] = props[key]
38
+ deepMerge(classCss, props[key])
39
+ } else restProps[key] = props[key]
40
+ }
41
+
42
+ return classCss
43
+ }
44
+
45
+ export const extractCSSfromProps = (element) => {
46
+ const { props: defProps } = element
47
+ const css = {}
48
+ const props = {}
49
+
50
+ for (const key in defProps) {
51
+ const val = defProps[key]
52
+
53
+ const mediaProp = keySetters[key.slice(0, 1)]
54
+ if (mediaProp) {
55
+ mediaProp(key, defProps[key], css, element, true)
56
+ continue
57
+ }
58
+
59
+ const preprop = CSS_PREPROCS_DEFAULTS[key]
60
+ if (preprop) {
61
+ // const stack = hasCSS(element)
62
+ const stack = preprop(element, element.state, element.context)
63
+ const exec = isArray(stack)
64
+ ? stack.reduce((a, c) => {
65
+ return merge(a, c)
66
+ }, {})
67
+ : stack
68
+ deepMerge(css, exec)
69
+ continue
70
+ }
71
+
72
+ if (key === 'style') {
73
+ deepMerge(css, defProps[key])
74
+ continue
75
+ }
76
+
77
+ if (DEFAULT_CSS_PROPERTIES_LIST.includes(key)) {
78
+ css[key] = val
79
+ continue
80
+ }
81
+
82
+ props[key] = val
34
83
  }
35
84
 
36
- return CLASS_NAMES
85
+ return { css, props }
37
86
  }