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.
- package/README.md +6 -22
- package/dist/cjs/{props/defaults.js → defaults.js} +2 -2
- package/dist/cjs/index.js +19 -2
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/props/animation.js +16 -80
- package/dist/cjs/props/block.js +71 -89
- package/dist/cjs/props/font.js +8 -7
- package/dist/cjs/props/index.js +0 -32
- package/dist/cjs/props/misc.js +9 -8
- package/dist/cjs/props/position.js +17 -14
- package/dist/cjs/props/theme.js +73 -70
- package/dist/cjs/props/timing.js +11 -11
- package/dist/cjs/registry.js +39 -0
- package/dist/cjs/set.js +1 -1
- package/dist/cjs/transform.js +80 -0
- 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/props/flex.js +0 -45
- package/dist/cjs/props/grid.js +0 -39
- package/dist/cjs/transform/executors.js +0 -124
- package/dist/cjs/transform/index.js +0 -19
- package/dist/cjs/transform/transformers.js +0 -107
- package/dist/esm/_transform.js +0 -10
- package/dist/esm/emotion.js +0 -9
- package/dist/esm/index.js +0 -4
- package/dist/esm/props/animation.js +0 -101
- package/dist/esm/props/block.js +0 -171
- package/dist/esm/props/defaults.js +0 -321
- package/dist/esm/props/flex.js +0 -25
- package/dist/esm/props/font.js +0 -16
- package/dist/esm/props/grid.js +0 -19
- package/dist/esm/props/index.js +0 -35
- package/dist/esm/props/misc.js +0 -15
- package/dist/esm/props/position.js +0 -31
- package/dist/esm/props/theme.js +0 -134
- package/dist/esm/props/timing.js +0 -26
- package/dist/esm/set.js +0 -9
- package/dist/esm/transform/executors.js +0 -104
- package/dist/esm/transform/index.js +0 -2
- package/dist/esm/transform/transformers.js +0 -87
- package/dist/iife/index.js +0 -1084
- package/src/_transform.js +0 -10
- package/src/emotion.js +0 -9
package/dist/cjs/props/theme.js
CHANGED
|
@@ -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
|
|
29
|
-
return
|
|
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: (
|
|
32
|
+
theme: (element) => {
|
|
33
33
|
const { props } = element;
|
|
34
|
-
|
|
35
|
-
if (props.
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
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: (
|
|
46
|
+
color: (element) => {
|
|
47
|
+
const { props } = element;
|
|
41
48
|
const globalTheme = getSystemGlobalTheme(element);
|
|
42
|
-
if (!
|
|
49
|
+
if (!props.color) return;
|
|
43
50
|
return {
|
|
44
|
-
color: (0, import_scratch.getMediaColor)(
|
|
51
|
+
color: (0, import_scratch.getMediaColor)(props.color, globalTheme)
|
|
45
52
|
};
|
|
46
53
|
},
|
|
47
|
-
background: (
|
|
54
|
+
background: (element) => {
|
|
55
|
+
const { props } = element;
|
|
48
56
|
const globalTheme = getSystemGlobalTheme(element);
|
|
49
|
-
if (!
|
|
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)(
|
|
59
|
+
background: (0, import_scratch.getMediaColor)(props.background, globalTheme)
|
|
55
60
|
};
|
|
56
61
|
},
|
|
57
|
-
backgroundColor: (
|
|
62
|
+
backgroundColor: (element) => {
|
|
63
|
+
const { props } = element;
|
|
58
64
|
const globalTheme = getSystemGlobalTheme(element);
|
|
59
|
-
if (!
|
|
65
|
+
if (!props.backgroundColor) return;
|
|
60
66
|
return {
|
|
61
|
-
backgroundColor: (0, import_scratch.getMediaColor)(
|
|
67
|
+
backgroundColor: (0, import_scratch.getMediaColor)(props.backgroundColor, globalTheme)
|
|
62
68
|
};
|
|
63
69
|
},
|
|
64
|
-
backgroundImage: (
|
|
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
|
-
|
|
74
|
-
|
|
81
|
+
backgroundSize: ({ props }) => ({
|
|
82
|
+
backgroundSize: props.backgroundSize
|
|
75
83
|
}),
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
backgroundPosition: ({ props }) => ({
|
|
85
|
+
backgroundPosition: props.backgroundPosition
|
|
78
86
|
}),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
border: (0, import_scratch.transformBorder)(val)
|
|
87
|
+
backgroundRepeat: ({ props }) => ({
|
|
88
|
+
backgroundRepeat: props.backgroundRepeat
|
|
82
89
|
}),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
100
|
+
borderColor: (element) => {
|
|
101
|
+
const { props } = element;
|
|
106
102
|
const globalTheme = getSystemGlobalTheme(element);
|
|
107
|
-
if (!
|
|
108
|
-
return {
|
|
103
|
+
if (!props.borderColor) return;
|
|
104
|
+
return {
|
|
105
|
+
borderColor: (0, import_scratch.getMediaColor)(props.borderColor, globalTheme)
|
|
106
|
+
};
|
|
109
107
|
},
|
|
110
|
-
borderLeft: (
|
|
111
|
-
borderLeft: (0, import_scratch.transformBorder)(
|
|
108
|
+
borderLeft: ({ props }) => ({
|
|
109
|
+
borderLeft: (0, import_scratch.transformBorder)(props.borderLeft)
|
|
112
110
|
}),
|
|
113
|
-
borderTop: (
|
|
114
|
-
borderTop: (0, import_scratch.transformBorder)(
|
|
111
|
+
borderTop: ({ props }) => ({
|
|
112
|
+
borderTop: (0, import_scratch.transformBorder)(props.borderTop)
|
|
115
113
|
}),
|
|
116
|
-
borderRight: (
|
|
117
|
-
borderRight: (0, import_scratch.transformBorder)(
|
|
114
|
+
borderRight: ({ props }) => ({
|
|
115
|
+
borderRight: (0, import_scratch.transformBorder)(props.borderRight)
|
|
118
116
|
}),
|
|
119
|
-
borderBottom: (
|
|
120
|
-
borderBottom: (0, import_scratch.transformBorder)(
|
|
117
|
+
borderBottom: ({ props }) => ({
|
|
118
|
+
borderBottom: (0, import_scratch.transformBorder)(props.borderBottom)
|
|
121
119
|
}),
|
|
122
|
-
shadow: (
|
|
120
|
+
shadow: (element) => {
|
|
121
|
+
const { props } = element;
|
|
123
122
|
const globalTheme = getSystemGlobalTheme(element);
|
|
124
|
-
if (!
|
|
123
|
+
if (!props.backgroundImage) return;
|
|
125
124
|
return {
|
|
126
|
-
boxShadow: (0, import_scratch.transformShadow)(
|
|
125
|
+
boxShadow: (0, import_scratch.transformShadow)(props.shadow, globalTheme)
|
|
127
126
|
};
|
|
128
127
|
},
|
|
129
|
-
boxShadow: (
|
|
130
|
-
|
|
131
|
-
|
|
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)(
|
|
135
|
+
boxShadow: (0, import_scratch.transformBoxShadow)(val.trim(), globalTheme) + important
|
|
136
136
|
};
|
|
137
137
|
},
|
|
138
|
-
textShadow: (
|
|
139
|
-
textShadow: (0, import_scratch.transformBoxShadow)(
|
|
138
|
+
textShadow: ({ props, context }) => ({
|
|
139
|
+
textShadow: (0, import_scratch.transformBoxShadow)(
|
|
140
|
+
props.textShadow,
|
|
141
|
+
context.designSystem.globalTheme
|
|
142
|
+
)
|
|
140
143
|
}),
|
|
141
|
-
columnRule: (
|
|
142
|
-
columnRule: (0, import_scratch.transformBorder)(
|
|
144
|
+
columnRule: ({ props }) => ({
|
|
145
|
+
columnRule: (0, import_scratch.transformBorder)(props.columnRule)
|
|
143
146
|
})
|
|
144
147
|
};
|
package/dist/cjs/props/timing.js
CHANGED
|
@@ -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: (
|
|
27
|
-
transition: (0, import_scratch.splitTransition)(
|
|
26
|
+
transition: ({ props }) => ({
|
|
27
|
+
transition: (0, import_scratch.splitTransition)(props.transition)
|
|
28
28
|
}),
|
|
29
|
-
transitionDuration: (
|
|
30
|
-
transitionDuration: (0, import_scratch.transformDuration)(
|
|
29
|
+
transitionDuration: ({ props }) => ({
|
|
30
|
+
transitionDuration: (0, import_scratch.transformDuration)(props.transitionDuration)
|
|
31
31
|
}),
|
|
32
|
-
transitionDelay: (
|
|
33
|
-
transitionDelay: (0, import_scratch.transformDuration)(
|
|
32
|
+
transitionDelay: ({ props }) => ({
|
|
33
|
+
transitionDelay: (0, import_scratch.transformDuration)(props.transitionDelay)
|
|
34
34
|
}),
|
|
35
|
-
transitionTimingFunction: (
|
|
36
|
-
transitionTimingFunction: (0, import_scratch.getTimingFunction)(
|
|
35
|
+
transitionTimingFunction: ({ props }) => ({
|
|
36
|
+
transitionTimingFunction: (0, import_scratch.getTimingFunction)(props.transitionTimingFunction)
|
|
37
37
|
}),
|
|
38
|
-
transitionProperty: (
|
|
39
|
-
transitionProperty:
|
|
40
|
-
willChange:
|
|
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("./
|
|
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.
|
|
5
|
+
"version": "3.14.1",
|
|
6
6
|
"repository": "https://github.com/symbo-ls/smbls",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"module": "./
|
|
8
|
+
"module": "./index.js",
|
|
9
9
|
"unpkg": "./dist/iife/index.js",
|
|
10
10
|
"jsdelivr": "./dist/iife/index.js",
|
|
11
|
-
"main": "./
|
|
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": "
|
|
27
|
-
"build:cjs": "
|
|
28
|
-
"build:iife": "
|
|
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
|
-
"@
|
|
39
|
-
"@symbo.ls/
|
|
40
|
-
"@symbo.ls/scratch": "^3.
|
|
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": "./
|
|
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 './
|
|
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'
|
package/src/props/animation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isObject, isString } from '@
|
|
4
|
-
import {
|
|
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 {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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.
|
|
70
|
-
animationDelay: parsed.durations[1] || getTimingByKey(el.
|
|
71
|
-
animationTimingFunction: parsed.timingFunction || getTimingFunction(el.
|
|
72
|
-
animationFillMode: parsed.fillMode || el.
|
|
73
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : (el.
|
|
74
|
-
animationPlayState: parsed.playState || el.
|
|
75
|
-
animationDirection: parsed.direction || el.
|
|
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.
|
|
82
|
-
animationDelay: getTimingByKey(el.
|
|
83
|
-
animationTimingFunction: getTimingFunction(el.
|
|
84
|
-
animationFillMode: el.
|
|
85
|
-
animationIterationCount: el.
|
|
86
|
-
animationPlayState: el.
|
|
87
|
-
animationDirection: el.
|
|
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) => ({
|