@tamagui/core 1.0.1-beta.26 → 1.0.1-beta.29
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/dist/cjs/ThemeManager.js +21 -10
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/constants/platform.js +6 -6
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/rnw.js.map +2 -2
- package/dist/cjs/createComponent.js +23 -20
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +10 -2
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -0
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +9 -39
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +453 -0
- package/dist/cjs/helpers/generateAtomicStyles.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +67 -65
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +31 -40
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js +42 -0
- package/dist/cjs/helpers/mergeTransform.js.map +7 -0
- package/dist/cjs/helpers/prefixStyles.js +192 -0
- package/dist/cjs/helpers/prefixStyles.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +8 -7
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +1 -1
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +1 -0
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/ThemeManager.js +21 -10
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/constants/platform.js +4 -4
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/rnw.js.map +2 -2
- package/dist/esm/createComponent.js +24 -20
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +8 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -0
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +9 -40
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +425 -0
- package/dist/esm/helpers/generateAtomicStyles.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +70 -73
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +26 -39
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js +19 -0
- package/dist/esm/helpers/mergeTransform.js.map +7 -0
- package/dist/esm/helpers/prefixStyles.js +166 -0
- package/dist/esm/helpers/prefixStyles.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +8 -7
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +1 -1
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +1 -0
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/dist/jsx/ThemeManager.js +21 -10
- package/dist/jsx/constants/platform.js +4 -4
- package/dist/jsx/createComponent.js +24 -20
- package/dist/jsx/createTamagui.js +8 -1
- package/dist/jsx/helpers/createMediaStyle.js +1 -0
- package/dist/jsx/helpers/createPropMapper.js +9 -40
- package/dist/jsx/helpers/generateAtomicStyles.js +424 -0
- package/dist/jsx/helpers/getSplitStyles.js +70 -73
- package/dist/jsx/helpers/getStylesAtomic.js +26 -39
- package/dist/jsx/helpers/mergeTransform.js +18 -0
- package/dist/jsx/helpers/prefixStyles.js +165 -0
- package/dist/jsx/hooks/useIsTouchDevice.js +2 -2
- package/dist/jsx/hooks/useTheme.js +8 -7
- package/dist/jsx/views/ThemeProvider.js +1 -1
- package/dist/jsx/views/ThemeReset.js +1 -1
- package/package.json +8 -5
- package/reset.css +3 -2
- package/types/Tamagui.d.ts +1 -1
- package/types/Tamagui.d.ts.map +1 -1
- package/types/ThemeManager.d.ts +9 -6
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/constants/platform.d.ts +2 -2
- package/types/constants/platform.d.ts.map +1 -1
- package/types/constants/rnw.d.ts +1 -1
- package/types/constants/rnw.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts +1 -0
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +2 -2
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +22 -0
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +10 -10
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/mergeTransform.d.ts +7 -0
- package/types/helpers/mergeTransform.d.ts.map +1 -0
- package/types/helpers/prefixStyles.d.ts +5 -0
- package/types/helpers/prefixStyles.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +13 -4
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +3 -4
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -9
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
|
@@ -3,6 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import { getConfig } from "../conf";
|
|
4
4
|
import { isWeb } from "../constants/platform";
|
|
5
5
|
import { isVariable } from "../createVariable";
|
|
6
|
+
import { expandStyle, expandStyles } from "./generateAtomicStyles";
|
|
6
7
|
import { getVariantExtras } from "./getVariantExtras";
|
|
7
8
|
import { isObj } from "./isObj";
|
|
8
9
|
function getVariantFunction(variant, key, value) {
|
|
@@ -32,12 +33,14 @@ __name(getVariantFunction, "getVariantFunction");
|
|
|
32
33
|
const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
33
34
|
const variants = staticConfig.variants || {};
|
|
34
35
|
const defaultProps = staticConfig.defaultProps || {};
|
|
35
|
-
|
|
36
|
+
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false) => {
|
|
36
37
|
const conf = getConfig();
|
|
37
38
|
if (!conf) {
|
|
38
39
|
console.trace("no conf! err");
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
42
|
+
const props = state.fallbackProps || propsIn;
|
|
43
|
+
const returnVariablesAs = state.resolveVariablesAs || !!props.animation ? "value" : "auto";
|
|
41
44
|
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
42
45
|
const variant = variants && variants[key];
|
|
43
46
|
if (variant && value !== void 0) {
|
|
@@ -50,16 +53,15 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
50
53
|
if (isObj(variantValue)) {
|
|
51
54
|
variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
|
|
52
55
|
}
|
|
53
|
-
return
|
|
56
|
+
return Object.entries(expandStyles(variantValue));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
let shouldReturn =
|
|
59
|
+
let shouldReturn = value !== void 0 && value !== null;
|
|
57
60
|
if (conf.shorthands[key]) {
|
|
58
61
|
shouldReturn = true;
|
|
59
62
|
key = conf.shorthands[key];
|
|
60
63
|
}
|
|
61
64
|
if (value) {
|
|
62
|
-
shouldReturn = true;
|
|
63
65
|
if (value[0] === "$") {
|
|
64
66
|
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs);
|
|
65
67
|
} else if (isVariable(value)) {
|
|
@@ -67,11 +69,10 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
if (shouldReturn) {
|
|
70
|
-
return
|
|
71
|
-
[key]: value
|
|
72
|
-
});
|
|
72
|
+
return expandStyle(key, value) || [[key, value]];
|
|
73
73
|
}
|
|
74
|
-
};
|
|
74
|
+
}, "mapper");
|
|
75
|
+
return mapper;
|
|
75
76
|
}, "createPropMapper");
|
|
76
77
|
const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, resolveAs) => {
|
|
77
78
|
var _a;
|
|
@@ -194,38 +195,6 @@ const tokenCategories = {
|
|
|
194
195
|
borderRightColor: true
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
|
-
const sidesX = ["Left", "Right"];
|
|
198
|
-
const sidesY = ["Top", "Bottom"];
|
|
199
|
-
const sidesXY = [...sidesX, ...sidesY];
|
|
200
|
-
const expand = {
|
|
201
|
-
padding: sidesXY.map((x) => `padding${x}`),
|
|
202
|
-
paddingHorizontal: sidesX.map((x) => `padding${x}`),
|
|
203
|
-
paddingVertical: sidesY.map((x) => `padding${x}`),
|
|
204
|
-
margin: sidesXY.map((x) => `margin${x}`),
|
|
205
|
-
marginHorizontal: sidesX.map((x) => `margin${x}`),
|
|
206
|
-
marginVertical: sidesY.map((x) => `margin${x}`),
|
|
207
|
-
borderWidth: sidesXY.map((x) => `border${x}Width`)
|
|
208
|
-
};
|
|
209
|
-
function expansions(styleObj) {
|
|
210
|
-
var _a, _b;
|
|
211
|
-
for (const key in expand) {
|
|
212
|
-
if (key in styleObj) {
|
|
213
|
-
for (const expandKey of expand[key]) {
|
|
214
|
-
styleObj[expandKey] = styleObj[key];
|
|
215
|
-
}
|
|
216
|
-
delete styleObj[key];
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if ("flex" in styleObj) {
|
|
220
|
-
if (typeof styleObj.flex === "number") {
|
|
221
|
-
styleObj.flexGrow = (_a = styleObj.flexGrow) != null ? _a : styleObj.flex;
|
|
222
|
-
styleObj.flexShrink = (_b = styleObj.flexShrink) != null ? _b : 1;
|
|
223
|
-
delete styleObj.flex;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return styleObj;
|
|
227
|
-
}
|
|
228
|
-
__name(expansions, "expansions");
|
|
229
198
|
export {
|
|
230
199
|
createPropMapper
|
|
231
200
|
};
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { simpleHash } from "@tamagui/helpers";
|
|
4
|
+
import hyphenateStyleName from "hyphenate-style-name";
|
|
5
|
+
import normalizeCSSColor from "normalize-css-color";
|
|
6
|
+
import { isWeb } from "../constants/platform";
|
|
7
|
+
import { prefixInlineStyles, prefixStyles } from "./prefixStyles";
|
|
8
|
+
function expandStyles(style) {
|
|
9
|
+
const res = {};
|
|
10
|
+
for (const key in style) {
|
|
11
|
+
updateReactDOMStyle(res, key, style[key]);
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
__name(expandStyles, "expandStyles");
|
|
16
|
+
function inline(style) {
|
|
17
|
+
return prefixInlineStyles(expandStyles(style));
|
|
18
|
+
}
|
|
19
|
+
__name(inline, "inline");
|
|
20
|
+
const STYLE_SHORT_FORM_EXPANSIONS = {
|
|
21
|
+
borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
|
|
22
|
+
borderRadius: [
|
|
23
|
+
"borderTopLeftRadius",
|
|
24
|
+
"borderTopRightRadius",
|
|
25
|
+
"borderBottomRightRadius",
|
|
26
|
+
"borderBottomLeftRadius"
|
|
27
|
+
],
|
|
28
|
+
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
29
|
+
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
30
|
+
margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
|
|
31
|
+
marginHorizontal: ["marginRight", "marginLeft"],
|
|
32
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
33
|
+
overflow: ["overflowX", "overflowY"],
|
|
34
|
+
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
35
|
+
padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
|
|
36
|
+
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
37
|
+
paddingVertical: ["paddingTop", "paddingBottom"]
|
|
38
|
+
};
|
|
39
|
+
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
40
|
+
const res = expandStyles(style);
|
|
41
|
+
if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
|
|
42
|
+
boxShadowReducer(res, style);
|
|
43
|
+
}
|
|
44
|
+
if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
|
|
45
|
+
textShadowReducer(res, style);
|
|
46
|
+
}
|
|
47
|
+
const out = {};
|
|
48
|
+
for (const key in res) {
|
|
49
|
+
const value = res[key];
|
|
50
|
+
if (value != null) {
|
|
51
|
+
const valueString = stringifyValueWithProperty(value, key);
|
|
52
|
+
const cachedResult = cache.get(key, valueString);
|
|
53
|
+
if (cachedResult != null) {
|
|
54
|
+
const { identifier } = cachedResult;
|
|
55
|
+
out[identifier] = cachedResult;
|
|
56
|
+
} else {
|
|
57
|
+
const identifier = createIdentifier("r", key, value);
|
|
58
|
+
const rules = createAtomicRules(identifier, key, value);
|
|
59
|
+
const cachedResult2 = cache.set(key, valueString, {
|
|
60
|
+
property: key,
|
|
61
|
+
value: stringifyValueWithProperty(value, key),
|
|
62
|
+
identifier,
|
|
63
|
+
rules
|
|
64
|
+
});
|
|
65
|
+
out[identifier] = cachedResult2;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}, "generateAtomicStyles");
|
|
71
|
+
function updateReactDOMStyle(style, key, value) {
|
|
72
|
+
value = normalizeValueWithProperty(value, key);
|
|
73
|
+
const out = expandStyle(key, value);
|
|
74
|
+
if (out) {
|
|
75
|
+
Object.assign(style, Object.fromEntries(out));
|
|
76
|
+
} else {
|
|
77
|
+
style[key] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
81
|
+
function expandStyle(key, value) {
|
|
82
|
+
if (key === "flex") {
|
|
83
|
+
if (value <= -1) {
|
|
84
|
+
return [
|
|
85
|
+
["flexGrow", 0],
|
|
86
|
+
["flexShrink", 1],
|
|
87
|
+
["flexBasis", "auto"]
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (value >= 0) {
|
|
91
|
+
return [
|
|
92
|
+
["flexGrow", value],
|
|
93
|
+
["flexShrink", 1]
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (isWeb) {
|
|
99
|
+
switch (key) {
|
|
100
|
+
case "elevation":
|
|
101
|
+
case "overlayColor":
|
|
102
|
+
case "resizeMode":
|
|
103
|
+
case "tintColor": {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "aspectRatio": {
|
|
107
|
+
return [key, value.toString()];
|
|
108
|
+
}
|
|
109
|
+
case "backgroundClip": {
|
|
110
|
+
if (value === "text") {
|
|
111
|
+
return [
|
|
112
|
+
["backgroundClip", value],
|
|
113
|
+
["WebkitBackgroundClip", value]
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "textAlignVertical": {
|
|
119
|
+
return [["verticalAlign", value === "center" ? "middle" : value]];
|
|
120
|
+
}
|
|
121
|
+
case "textDecorationLine": {
|
|
122
|
+
return ["textDecorationLine", value];
|
|
123
|
+
}
|
|
124
|
+
case "transform": {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
return [[key, value.map(mapTransform).join(" ")]];
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "writingDirection": {
|
|
131
|
+
return [["direction", value]];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const longKey = STYLE_SHORT_FORM_EXPANSIONS[key];
|
|
136
|
+
if (longKey) {
|
|
137
|
+
return longKey.map((key2) => {
|
|
138
|
+
return [key2, value];
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
if (isWeb && Array.isArray(value)) {
|
|
142
|
+
return [[key, value.join(",")]];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
__name(expandStyle, "expandStyle");
|
|
147
|
+
function createAtomicRules(identifier, property, value) {
|
|
148
|
+
const rules = [];
|
|
149
|
+
const selector = `.${identifier}`;
|
|
150
|
+
switch (property) {
|
|
151
|
+
case "animationKeyframes": {
|
|
152
|
+
const { animationNames, rules: keyframesRules } = processKeyframesValue(value);
|
|
153
|
+
const block = createDeclarationBlock({ animationName: animationNames.join(",") });
|
|
154
|
+
rules.push(`${selector}${block}`, ...keyframesRules);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case "placeholderTextColor": {
|
|
158
|
+
const block = createDeclarationBlock({ color: value, opacity: 1 });
|
|
159
|
+
rules.push(`${selector}::-webkit-input-placeholder${block}`, `${selector}::-moz-placeholder${block}`, `${selector}:-ms-input-placeholder${block}`, `${selector}::placeholder${block}`);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "pointerEvents": {
|
|
163
|
+
let finalValue = value;
|
|
164
|
+
if (value === "auto" || value === "box-only") {
|
|
165
|
+
finalValue = "auto!important";
|
|
166
|
+
if (value === "box-only") {
|
|
167
|
+
const block2 = createDeclarationBlock({ pointerEvents: "none" });
|
|
168
|
+
rules.push(`${selector}>*${block2}`);
|
|
169
|
+
}
|
|
170
|
+
} else if (value === "none" || value === "box-none") {
|
|
171
|
+
finalValue = "none!important";
|
|
172
|
+
if (value === "box-none") {
|
|
173
|
+
const block2 = createDeclarationBlock({ pointerEvents: "auto" });
|
|
174
|
+
rules.push(`${selector}>*${block2}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const block = createDeclarationBlock({ pointerEvents: finalValue });
|
|
178
|
+
rules.push(`${selector}${block}`);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "scrollbarWidth": {
|
|
182
|
+
if (value === "none") {
|
|
183
|
+
rules.push(`${selector}::-webkit-scrollbar{display:none}`);
|
|
184
|
+
}
|
|
185
|
+
const block = createDeclarationBlock({ scrollbarWidth: value });
|
|
186
|
+
rules.push(`${selector}${block}`);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default: {
|
|
190
|
+
const block = createDeclarationBlock({ [property]: value });
|
|
191
|
+
rules.push(`${selector}${block}`);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return rules;
|
|
196
|
+
}
|
|
197
|
+
__name(createAtomicRules, "createAtomicRules");
|
|
198
|
+
function processKeyframesValue(keyframesValue) {
|
|
199
|
+
if (typeof keyframesValue === "number") {
|
|
200
|
+
throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`);
|
|
201
|
+
}
|
|
202
|
+
const animationNames = [];
|
|
203
|
+
const rules = [];
|
|
204
|
+
const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue];
|
|
205
|
+
for (const keyframes of value) {
|
|
206
|
+
if (typeof keyframes === "string") {
|
|
207
|
+
animationNames.push(keyframes);
|
|
208
|
+
} else {
|
|
209
|
+
const { identifier, rules: keyframesRules } = createKeyframes(keyframes);
|
|
210
|
+
animationNames.push(identifier);
|
|
211
|
+
rules.push(...keyframesRules);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { animationNames, rules };
|
|
215
|
+
}
|
|
216
|
+
__name(processKeyframesValue, "processKeyframesValue");
|
|
217
|
+
function createKeyframes(keyframes) {
|
|
218
|
+
const prefixes2 = ["-webkit-", ""];
|
|
219
|
+
const identifier = createIdentifier("r", "animation", keyframes);
|
|
220
|
+
const steps = "{" + Object.keys(keyframes).map((stepName) => {
|
|
221
|
+
const rule = keyframes[stepName];
|
|
222
|
+
const block = createDeclarationBlock(rule);
|
|
223
|
+
return `${stepName}${block}`;
|
|
224
|
+
}).join("") + "}";
|
|
225
|
+
const rules = prefixes2.map((prefix) => {
|
|
226
|
+
return `@${prefix}keyframes ${identifier}${steps}`;
|
|
227
|
+
});
|
|
228
|
+
return { identifier, rules };
|
|
229
|
+
}
|
|
230
|
+
__name(createKeyframes, "createKeyframes");
|
|
231
|
+
function createDeclarationBlock(style) {
|
|
232
|
+
const domStyle = prefixStyles(expandStyles(style));
|
|
233
|
+
const declarationsString = Object.keys(domStyle).map((property) => {
|
|
234
|
+
const value = domStyle[property];
|
|
235
|
+
const prop = hyphenateStyleName(property);
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
return value.map((v) => `${prop}:${v}`).join(";");
|
|
238
|
+
} else {
|
|
239
|
+
return `${prop}:${value}`;
|
|
240
|
+
}
|
|
241
|
+
}).sort().join(";");
|
|
242
|
+
return `{${declarationsString};}`;
|
|
243
|
+
}
|
|
244
|
+
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
245
|
+
function createIdentifier(prefix, name, value) {
|
|
246
|
+
const hashedString = simpleHash(name + stringifyValueWithProperty(value, name));
|
|
247
|
+
return `${prefix}-${hashedString}`;
|
|
248
|
+
}
|
|
249
|
+
__name(createIdentifier, "createIdentifier");
|
|
250
|
+
const cache = {
|
|
251
|
+
get(property, value) {
|
|
252
|
+
if (cache[property] != null && cache[property].hasOwnProperty(value) && cache[property][value] != null) {
|
|
253
|
+
return cache[property][value];
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
set(property, value, object) {
|
|
257
|
+
if (cache[property] == null) {
|
|
258
|
+
cache[property] = {};
|
|
259
|
+
}
|
|
260
|
+
return cache[property][value] = object;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function stringifyValueWithProperty(value, property) {
|
|
264
|
+
const normalizedValue = normalizeValueWithProperty(value, property);
|
|
265
|
+
return typeof normalizedValue !== "string" ? JSON.stringify(normalizedValue || "") : normalizedValue;
|
|
266
|
+
}
|
|
267
|
+
__name(stringifyValueWithProperty, "stringifyValueWithProperty");
|
|
268
|
+
const mapTransform = /* @__PURE__ */ __name((transform) => {
|
|
269
|
+
const type = Object.keys(transform)[0];
|
|
270
|
+
const value = transform[type];
|
|
271
|
+
if (type === "matrix" || type === "matrix3d") {
|
|
272
|
+
return `${type}(${value.join(",")})`;
|
|
273
|
+
} else {
|
|
274
|
+
const normalizedValue = normalizeValueWithProperty(value, type);
|
|
275
|
+
return `${type}(${normalizedValue})`;
|
|
276
|
+
}
|
|
277
|
+
}, "mapTransform");
|
|
278
|
+
const colorProps = {
|
|
279
|
+
backgroundColor: true,
|
|
280
|
+
borderColor: true,
|
|
281
|
+
borderTopColor: true,
|
|
282
|
+
borderRightColor: true,
|
|
283
|
+
borderBottomColor: true,
|
|
284
|
+
borderLeftColor: true,
|
|
285
|
+
color: true,
|
|
286
|
+
shadowColor: true,
|
|
287
|
+
textDecorationColor: true,
|
|
288
|
+
textShadowColor: true
|
|
289
|
+
};
|
|
290
|
+
function normalizeValueWithProperty(value, property) {
|
|
291
|
+
if (isWeb) {
|
|
292
|
+
if ((property == null || !unitlessNumbers[property]) && typeof value === "number") {
|
|
293
|
+
return `${value}px`;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (property && colorProps[property]) {
|
|
297
|
+
return normalizeColor(value);
|
|
298
|
+
}
|
|
299
|
+
return value;
|
|
300
|
+
}
|
|
301
|
+
__name(normalizeValueWithProperty, "normalizeValueWithProperty");
|
|
302
|
+
const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
303
|
+
if (color == null || color == void 0) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (typeof color === "string" && isWebColor(color)) {
|
|
307
|
+
return color;
|
|
308
|
+
}
|
|
309
|
+
const colorInt = processColor(color);
|
|
310
|
+
if (colorInt != null) {
|
|
311
|
+
const r = colorInt >> 16 & 255;
|
|
312
|
+
const g = colorInt >> 8 & 255;
|
|
313
|
+
const b = colorInt & 255;
|
|
314
|
+
const a = (colorInt >> 24 & 255) / 255;
|
|
315
|
+
const alpha = (a * opacity).toFixed(2);
|
|
316
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
317
|
+
}
|
|
318
|
+
}, "normalizeColor");
|
|
319
|
+
const isWebColor = /* @__PURE__ */ __name((color) => color === "currentcolor" || color === "currentColor" || color === "inherit" || color.indexOf("var(") === 0, "isWebColor");
|
|
320
|
+
const processColor = /* @__PURE__ */ __name((color) => {
|
|
321
|
+
if (color === void 0 || color === null) {
|
|
322
|
+
return color;
|
|
323
|
+
}
|
|
324
|
+
let intColor = normalizeCSSColor(color);
|
|
325
|
+
if (intColor === void 0 || intColor === null) {
|
|
326
|
+
return void 0;
|
|
327
|
+
}
|
|
328
|
+
return (+intColor << 24 | +intColor >>> 8) >>> 0;
|
|
329
|
+
}, "processColor");
|
|
330
|
+
const unitlessNumbers = {
|
|
331
|
+
animationIterationCount: true,
|
|
332
|
+
aspectRatio: true,
|
|
333
|
+
borderImageOutset: true,
|
|
334
|
+
borderImageSlice: true,
|
|
335
|
+
borderImageWidth: true,
|
|
336
|
+
boxFlex: true,
|
|
337
|
+
boxFlexGroup: true,
|
|
338
|
+
boxOrdinalGroup: true,
|
|
339
|
+
columnCount: true,
|
|
340
|
+
flex: true,
|
|
341
|
+
flexGrow: true,
|
|
342
|
+
flexOrder: true,
|
|
343
|
+
flexPositive: true,
|
|
344
|
+
flexShrink: true,
|
|
345
|
+
flexNegative: true,
|
|
346
|
+
fontWeight: true,
|
|
347
|
+
gridRow: true,
|
|
348
|
+
gridRowEnd: true,
|
|
349
|
+
gridRowGap: true,
|
|
350
|
+
gridRowStart: true,
|
|
351
|
+
gridColumn: true,
|
|
352
|
+
gridColumnEnd: true,
|
|
353
|
+
gridColumnGap: true,
|
|
354
|
+
gridColumnStart: true,
|
|
355
|
+
lineClamp: true,
|
|
356
|
+
opacity: true,
|
|
357
|
+
order: true,
|
|
358
|
+
orphans: true,
|
|
359
|
+
tabSize: true,
|
|
360
|
+
widows: true,
|
|
361
|
+
zIndex: true,
|
|
362
|
+
zoom: true,
|
|
363
|
+
fillOpacity: true,
|
|
364
|
+
floodOpacity: true,
|
|
365
|
+
stopOpacity: true,
|
|
366
|
+
strokeDasharray: true,
|
|
367
|
+
strokeDashoffset: true,
|
|
368
|
+
strokeMiterlimit: true,
|
|
369
|
+
strokeOpacity: true,
|
|
370
|
+
strokeWidth: true,
|
|
371
|
+
scale: true,
|
|
372
|
+
scaleX: true,
|
|
373
|
+
scaleY: true,
|
|
374
|
+
scaleZ: true,
|
|
375
|
+
shadowOpacity: true
|
|
376
|
+
};
|
|
377
|
+
const prefixes = ["ms", "Moz", "O", "Webkit"];
|
|
378
|
+
const prefixKey = /* @__PURE__ */ __name((prefix, key) => {
|
|
379
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
380
|
+
}, "prefixKey");
|
|
381
|
+
Object.keys(unitlessNumbers).forEach((prop) => {
|
|
382
|
+
prefixes.forEach((prefix) => {
|
|
383
|
+
unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop];
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
const resolveShadowValue = /* @__PURE__ */ __name((style) => {
|
|
387
|
+
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
|
388
|
+
const { height, width } = shadowOffset || defaultOffset;
|
|
389
|
+
const offsetX = normalizeValueWithProperty(width);
|
|
390
|
+
const offsetY = normalizeValueWithProperty(height);
|
|
391
|
+
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
392
|
+
const color = normalizeColor(shadowColor || "black", shadowOpacity);
|
|
393
|
+
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
|
|
394
|
+
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
395
|
+
}
|
|
396
|
+
}, "resolveShadowValue");
|
|
397
|
+
function boxShadowReducer(resolvedStyle, style) {
|
|
398
|
+
const { boxShadow } = style;
|
|
399
|
+
const shadow = resolveShadowValue(style);
|
|
400
|
+
if (shadow != null) {
|
|
401
|
+
resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
__name(boxShadowReducer, "boxShadowReducer");
|
|
405
|
+
const defaultOffset = { height: 0, width: 0 };
|
|
406
|
+
function textShadowReducer(resolvedStyle, style) {
|
|
407
|
+
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
|
|
408
|
+
const { height, width } = textShadowOffset || defaultOffset;
|
|
409
|
+
const radius = textShadowRadius || 0;
|
|
410
|
+
const offsetX = normalizeValueWithProperty(width);
|
|
411
|
+
const offsetY = normalizeValueWithProperty(height);
|
|
412
|
+
const blurRadius = normalizeValueWithProperty(radius);
|
|
413
|
+
const color = normalizeValueWithProperty(textShadowColor, "textShadowColor");
|
|
414
|
+
if (color && (height !== 0 || width !== 0 || radius !== 0) && offsetX != null && offsetY != null && blurRadius != null) {
|
|
415
|
+
resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
__name(textShadowReducer, "textShadowReducer");
|
|
419
|
+
export {
|
|
420
|
+
expandStyle,
|
|
421
|
+
expandStyles,
|
|
422
|
+
generateAtomicStyles,
|
|
423
|
+
inline
|
|
424
|
+
};
|