css-in-props 3.8.9 → 3.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +6 -22
  2. package/dist/cjs/{props/defaults.js → defaults.js} +2 -2
  3. package/dist/cjs/index.js +19 -2
  4. package/dist/cjs/package.json +4 -0
  5. package/dist/cjs/props/animation.js +16 -80
  6. package/dist/cjs/props/block.js +71 -89
  7. package/dist/cjs/props/font.js +8 -7
  8. package/dist/cjs/props/index.js +0 -32
  9. package/dist/cjs/props/misc.js +9 -8
  10. package/dist/cjs/props/position.js +17 -14
  11. package/dist/cjs/props/theme.js +73 -70
  12. package/dist/cjs/props/timing.js +11 -11
  13. package/dist/cjs/registry.js +39 -0
  14. package/dist/cjs/set.js +1 -1
  15. package/dist/cjs/transform.js +80 -0
  16. package/index.js +1 -0
  17. package/package.json +13 -15
  18. package/src/index.js +4 -4
  19. package/src/props/animation.js +28 -23
  20. package/src/props/block.js +49 -57
  21. package/src/props/flex.js +4 -5
  22. package/src/props/index.js +18 -19
  23. package/src/props/misc.js +10 -3
  24. package/src/props/theme.js +10 -7
  25. package/src/set.js +11 -4
  26. package/src/transform/executors.js +60 -52
  27. package/src/transform/index.js +2 -2
  28. package/src/transform/transformers.js +85 -23
  29. package/dist/cjs/_transform.js +0 -30
  30. package/dist/cjs/props/flex.js +0 -45
  31. package/dist/cjs/props/grid.js +0 -39
  32. package/dist/cjs/transform/executors.js +0 -124
  33. package/dist/cjs/transform/index.js +0 -19
  34. package/dist/cjs/transform/transformers.js +0 -107
  35. package/dist/esm/_transform.js +0 -10
  36. package/dist/esm/emotion.js +0 -9
  37. package/dist/esm/index.js +0 -4
  38. package/dist/esm/props/animation.js +0 -101
  39. package/dist/esm/props/block.js +0 -171
  40. package/dist/esm/props/defaults.js +0 -321
  41. package/dist/esm/props/flex.js +0 -25
  42. package/dist/esm/props/font.js +0 -16
  43. package/dist/esm/props/grid.js +0 -19
  44. package/dist/esm/props/index.js +0 -35
  45. package/dist/esm/props/misc.js +0 -15
  46. package/dist/esm/props/position.js +0 -31
  47. package/dist/esm/props/theme.js +0 -134
  48. package/dist/esm/props/timing.js +0 -26
  49. package/dist/esm/set.js +0 -9
  50. package/dist/esm/transform/executors.js +0 -104
  51. package/dist/esm/transform/index.js +0 -2
  52. package/dist/esm/transform/transformers.js +0 -87
  53. package/dist/iife/index.js +0 -1084
  54. package/src/_transform.js +0 -10
  55. package/src/emotion.js +0 -9
@@ -25,44 +25,52 @@ module.exports = __toCommonJS(theme_exports);
25
25
  var import_scratch = require("@symbo.ls/scratch");
26
26
  var import_utils = require("@domql/utils");
27
27
  const getSystemGlobalTheme = ({ context, state }) => {
28
- const theme = state?.root?.globalTheme || context.designSystem?.globalTheme;
29
- return theme === "auto" ? null : theme;
28
+ const rootState = state && state.root;
29
+ return rootState && rootState.globalTheme ? rootState.globalTheme : context.designSystem && context.designSystem.globalTheme;
30
30
  };
31
31
  const THEME_PROPS = {
32
- theme: (val, element) => {
32
+ theme: (element) => {
33
33
  const { props } = element;
34
- if (!val) return;
35
- if (props.themeModifier) {
36
- return (0, import_scratch.getMediaTheme)(val, `@${props.themeModifier}`);
37
- }
38
- return (0, import_scratch.getMediaTheme)(val);
34
+ const globalTheme = getSystemGlobalTheme(element);
35
+ if (!props.theme) return;
36
+ const hasSubtheme = props.theme.includes(" ") && !props.theme.includes("@");
37
+ const globalThemeForced = `@${props.themeModifier || globalTheme}`;
38
+ if (hasSubtheme) {
39
+ const themeAppliedInVal = props.theme.split(" ");
40
+ themeAppliedInVal.splice(1, 0, globalThemeForced);
41
+ return (0, import_scratch.getMediaTheme)(themeAppliedInVal);
42
+ } else if (props.theme.includes("@{globalTheme}"))
43
+ props.theme.replace("@{globalTheme}", globalThemeForced);
44
+ return (0, import_scratch.getMediaTheme)(props.theme, `@${props.themeModifier || globalTheme}`);
39
45
  },
40
- color: (val, element) => {
46
+ color: (element) => {
47
+ const { props } = element;
41
48
  const globalTheme = getSystemGlobalTheme(element);
42
- if (!val) return;
49
+ if (!props.color) return;
43
50
  return {
44
- color: (0, import_scratch.getMediaColor)(val, globalTheme)
51
+ color: (0, import_scratch.getMediaColor)(props.color, globalTheme)
45
52
  };
46
53
  },
47
- background: (val, element) => {
54
+ background: (element) => {
55
+ const { props } = element;
48
56
  const globalTheme = getSystemGlobalTheme(element);
49
- if (!val) return;
50
- if ((0, import_utils.isString)(val) && val.includes("gradient")) {
51
- return { background: (0, import_scratch.resolveColorsInGradient)(val, globalTheme) };
52
- }
57
+ if (!props.background) return;
53
58
  return {
54
- background: (0, import_scratch.getMediaColor)(val, globalTheme)
59
+ background: (0, import_scratch.getMediaColor)(props.background, globalTheme)
55
60
  };
56
61
  },
57
- backgroundColor: (val, element) => {
62
+ backgroundColor: (element) => {
63
+ const { props } = element;
58
64
  const globalTheme = getSystemGlobalTheme(element);
59
- if (!val) return;
65
+ if (!props.backgroundColor) return;
60
66
  return {
61
- backgroundColor: (0, import_scratch.getMediaColor)(val, globalTheme)
67
+ backgroundColor: (0, import_scratch.getMediaColor)(props.backgroundColor, globalTheme)
62
68
  };
63
69
  },
64
- backgroundImage: (val, element, s, ctx) => {
70
+ backgroundImage: (element, s, ctx) => {
71
+ const { props } = element;
65
72
  const globalTheme = getSystemGlobalTheme(element);
73
+ let val = props.backgroundImage;
66
74
  if (!val) return;
67
75
  const file = ctx.files && ctx.files[val];
68
76
  if (file && file.content) val = file.content.src;
@@ -70,75 +78,70 @@ const THEME_PROPS = {
70
78
  backgroundImage: (0, import_scratch.transformBackgroundImage)(val, globalTheme)
71
79
  };
72
80
  },
73
- textStroke: (val) => ({
74
- WebkitTextStroke: (0, import_scratch.transformTextStroke)(val)
81
+ backgroundSize: ({ props }) => ({
82
+ backgroundSize: props.backgroundSize
75
83
  }),
76
- outline: (val) => ({
77
- outline: (0, import_scratch.transformBorder)(val)
84
+ backgroundPosition: ({ props }) => ({
85
+ backgroundPosition: props.backgroundPosition
78
86
  }),
79
- outlineOffset: (val, { props }) => (0, import_scratch.transformSizeRatio)("outlineOffset", val, props),
80
- border: (val) => ({
81
- border: (0, import_scratch.transformBorder)(val)
87
+ backgroundRepeat: ({ props }) => ({
88
+ backgroundRepeat: props.backgroundRepeat
82
89
  }),
83
- borderColor: (val, element) => {
84
- const globalTheme = getSystemGlobalTheme(element);
85
- if (!val) return;
86
- return {
87
- borderColor: (0, import_scratch.getMediaColor)(val, globalTheme)
88
- };
89
- },
90
- borderTopColor: (val, element) => {
91
- const globalTheme = getSystemGlobalTheme(element);
92
- if (!val) return;
93
- return { borderTopColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
94
- },
95
- borderBottomColor: (val, element) => {
96
- const globalTheme = getSystemGlobalTheme(element);
97
- if (!val) return;
98
- return { borderBottomColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
90
+ textStroke: ({ props }) => ({
91
+ WebkitTextStroke: (0, import_scratch.transformTextStroke)(props.textStroke)
92
+ }),
93
+ outline: ({ props }) => (0, import_utils.isDefined)(props.outline) && {
94
+ outline: (0, import_scratch.transformBorder)(props.outline)
99
95
  },
100
- borderLeftColor: (val, element) => {
101
- const globalTheme = getSystemGlobalTheme(element);
102
- if (!val) return;
103
- return { borderLeftColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
96
+ outlineOffset: ({ props }) => (0, import_scratch.transformSizeRatio)("outlineOffset", props),
97
+ border: ({ props }) => (0, import_utils.isDefined)(props.border) && {
98
+ border: (0, import_scratch.transformBorder)(props.border)
104
99
  },
105
- borderRightColor: (val, element) => {
100
+ borderColor: (element) => {
101
+ const { props } = element;
106
102
  const globalTheme = getSystemGlobalTheme(element);
107
- if (!val) return;
108
- return { borderRightColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
103
+ if (!props.borderColor) return;
104
+ return {
105
+ borderColor: (0, import_scratch.getMediaColor)(props.borderColor, globalTheme)
106
+ };
109
107
  },
110
- borderLeft: (val) => ({
111
- borderLeft: (0, import_scratch.transformBorder)(val)
108
+ borderLeft: ({ props }) => ({
109
+ borderLeft: (0, import_scratch.transformBorder)(props.borderLeft)
112
110
  }),
113
- borderTop: (val) => ({
114
- borderTop: (0, import_scratch.transformBorder)(val)
111
+ borderTop: ({ props }) => ({
112
+ borderTop: (0, import_scratch.transformBorder)(props.borderTop)
115
113
  }),
116
- borderRight: (val) => ({
117
- borderRight: (0, import_scratch.transformBorder)(val)
114
+ borderRight: ({ props }) => ({
115
+ borderRight: (0, import_scratch.transformBorder)(props.borderRight)
118
116
  }),
119
- borderBottom: (val) => ({
120
- borderBottom: (0, import_scratch.transformBorder)(val)
117
+ borderBottom: ({ props }) => ({
118
+ borderBottom: (0, import_scratch.transformBorder)(props.borderBottom)
121
119
  }),
122
- shadow: (val, element) => {
120
+ shadow: (element) => {
121
+ const { props } = element;
123
122
  const globalTheme = getSystemGlobalTheme(element);
124
- if (!val) return;
123
+ if (!props.backgroundImage) return;
125
124
  return {
126
- boxShadow: (0, import_scratch.transformShadow)(val, globalTheme)
125
+ boxShadow: (0, import_scratch.transformShadow)(props.shadow, globalTheme)
127
126
  };
128
127
  },
129
- boxShadow: (val, element) => {
130
- if (!(0, import_utils.isString)(val)) return;
131
- const [value, hasImportant] = val.split("!importan");
128
+ boxShadow: (element, state, context) => {
129
+ const { props } = element;
130
+ if (!(0, import_utils.isString)(props.boxShadow)) return;
131
+ const [val, hasImportant] = props.boxShadow.split("!importan");
132
132
  const globalTheme = getSystemGlobalTheme(element);
133
133
  const important = hasImportant ? " !important" : "";
134
134
  return {
135
- boxShadow: (0, import_scratch.transformBoxShadow)(value.trim(), globalTheme) + important
135
+ boxShadow: (0, import_scratch.transformBoxShadow)(val.trim(), globalTheme) + important
136
136
  };
137
137
  },
138
- textShadow: (val, { context }) => ({
139
- textShadow: (0, import_scratch.transformBoxShadow)(val, context.designSystem.globalTheme)
138
+ textShadow: ({ props, context }) => ({
139
+ textShadow: (0, import_scratch.transformBoxShadow)(
140
+ props.textShadow,
141
+ context.designSystem.globalTheme
142
+ )
140
143
  }),
141
- columnRule: (val) => ({
142
- columnRule: (0, import_scratch.transformBorder)(val)
144
+ columnRule: ({ props }) => ({
145
+ columnRule: (0, import_scratch.transformBorder)(props.columnRule)
143
146
  })
144
147
  };
@@ -23,20 +23,20 @@ __export(timing_exports, {
23
23
  module.exports = __toCommonJS(timing_exports);
24
24
  var import_scratch = require("@symbo.ls/scratch");
25
25
  const TIMING_PROPS = {
26
- transition: (val) => ({
27
- transition: (0, import_scratch.splitTransition)(val)
26
+ transition: ({ props }) => ({
27
+ transition: (0, import_scratch.splitTransition)(props.transition)
28
28
  }),
29
- transitionDuration: (val) => ({
30
- transitionDuration: (0, import_scratch.transformDuration)(val)
29
+ transitionDuration: ({ props }) => ({
30
+ transitionDuration: (0, import_scratch.transformDuration)(props.transitionDuration)
31
31
  }),
32
- transitionDelay: (val) => ({
33
- transitionDelay: (0, import_scratch.transformDuration)(val)
32
+ transitionDelay: ({ props }) => ({
33
+ transitionDelay: (0, import_scratch.transformDuration)(props.transitionDelay)
34
34
  }),
35
- transitionTimingFunction: (val) => ({
36
- transitionTimingFunction: (0, import_scratch.getTimingFunction)(val)
35
+ transitionTimingFunction: ({ props }) => ({
36
+ transitionTimingFunction: (0, import_scratch.getTimingFunction)(props.transitionTimingFunction)
37
37
  }),
38
- transitionProperty: (val) => ({
39
- transitionProperty: val,
40
- willChange: val
38
+ transitionProperty: ({ props }) => ({
39
+ transitionProperty: props.transitionProperty,
40
+ willChange: props.transitionProperty
41
41
  })
42
42
  };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
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
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var registry_exports = {};
30
+ __export(registry_exports, {
31
+ CSS_PREPROCS_DEFAULTS: () => CSS_PREPROCS_DEFAULTS,
32
+ CSS_PROPS_REGISTRY: () => CSS_PROPS_REGISTRY
33
+ });
34
+ module.exports = __toCommonJS(registry_exports);
35
+ var import_utils = require("@domql/utils");
36
+ var preprocs = __toESM(require("./props"), 1);
37
+ var import_atoms = require("@symbo.ls/atoms");
38
+ const CSS_PROPS_REGISTRY = (0, import_utils.mergeArray)([import_atoms.Text]).class;
39
+ const CSS_PREPROCS_DEFAULTS = (0, import_utils.mergeArray)(Object.values(preprocs));
package/dist/cjs/set.js CHANGED
@@ -21,7 +21,7 @@ __export(set_exports, {
21
21
  setClassname: () => setClassname
22
22
  });
23
23
  module.exports = __toCommonJS(set_exports);
24
- var import_transform = require("./_transform");
24
+ var import_transform = require("./transform");
25
25
  var import_emotion = require("./emotion");
26
26
  const setClassname = (props, emotionCss) => {
27
27
  const transform = (0, import_transform.transformClassname)(props);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var transform_exports = {};
20
+ __export(transform_exports, {
21
+ extractCSSfromProps: () => extractCSSfromProps,
22
+ transformClassname: () => transformClassname
23
+ });
24
+ module.exports = __toCommonJS(transform_exports);
25
+ var import_utils = require("@domql/utils");
26
+ var import_atoms = require("@symbo.ls/atoms");
27
+ var import_registry = require("./registry");
28
+ var import_defaults = require("./defaults");
29
+ const transformClassname = (element, restProps = {}) => {
30
+ const classCss = {};
31
+ const { props, class: elementClass } = element;
32
+ if (!(0, import_utils.isObject)(props)) return;
33
+ for (const key in props) {
34
+ const setter = import_atoms.keySetters[key.slice(0, 1)];
35
+ const hasCSS = elementClass[key];
36
+ if (setter) setter(key, props[key], classCss, element, true);
37
+ else if ((0, import_utils.isFunction)(hasCSS)) {
38
+ const stack = hasCSS(element, element.state, element.context);
39
+ const exec = (0, import_utils.isArray)(stack) ? stack.reduce((a, c) => {
40
+ return (0, import_utils.merge)(a, c);
41
+ }, {}) : stack;
42
+ (0, import_utils.deepMerge)(classCss, exec);
43
+ } else if (key === "style") {
44
+ (0, import_utils.deepMerge)(classCss, props[key]);
45
+ } else restProps[key] = props[key];
46
+ }
47
+ return classCss;
48
+ };
49
+ const extractCSSfromProps = (element) => {
50
+ const { props: defProps } = element;
51
+ const css = {};
52
+ const props = {};
53
+ for (const key in defProps) {
54
+ const val = defProps[key];
55
+ const mediaProp = import_atoms.keySetters[key.slice(0, 1)];
56
+ if (mediaProp) {
57
+ mediaProp(key, defProps[key], css, element, true);
58
+ continue;
59
+ }
60
+ const preprop = import_registry.CSS_PREPROCS_DEFAULTS[key];
61
+ if (preprop) {
62
+ const stack = preprop(element, element.state, element.context);
63
+ const exec = (0, import_utils.isArray)(stack) ? stack.reduce((a, c) => {
64
+ return (0, import_utils.merge)(a, c);
65
+ }, {}) : stack;
66
+ (0, import_utils.deepMerge)(css, exec);
67
+ continue;
68
+ }
69
+ if (key === "style") {
70
+ (0, import_utils.deepMerge)(css, defProps[key]);
71
+ continue;
72
+ }
73
+ if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.includes(key)) {
74
+ css[key] = val;
75
+ continue;
76
+ }
77
+ props[key] = val;
78
+ }
79
+ return { css, props };
80
+ };
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './src/index.js'
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.1",
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) => ({