@tamagui/core 1.0.1-beta.59 → 1.0.1-beta.62
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/Pressability.js +28 -0
- package/dist/cjs/Pressability.js.map +7 -0
- package/dist/cjs/Pressability.native.js +28 -0
- package/dist/cjs/Pressability.native.js.map +7 -0
- package/dist/cjs/createComponent.js +53 -15
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +34 -15
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createTamaguiProvider.js +3 -3
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +79 -121
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +29 -15
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +8 -22
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +38 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +2 -8
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +40 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/pseudos.js +41 -0
- package/dist/cjs/helpers/pseudos.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +2 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +1 -1
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +2 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +2 -1
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/Pressability.js +5 -0
- package/dist/esm/Pressability.js.map +7 -0
- package/dist/esm/Pressability.native.js +5 -0
- package/dist/esm/Pressability.native.js.map +7 -0
- package/dist/esm/createComponent.js +57 -20
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -1
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +34 -15
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +5 -3
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +65 -119
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +29 -15
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +7 -20
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +16 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +2 -8
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +18 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/pseudos.js +18 -0
- package/dist/esm/helpers/pseudos.js.map +7 -0
- package/dist/esm/helpers/themeable.js +2 -1
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +2 -2
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +2 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/views/Slot.js +2 -1
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/jsx/Pressability.js +4 -0
- package/dist/jsx/Pressability.native.js +4 -0
- package/dist/jsx/createComponent.js +57 -16
- package/dist/jsx/helpers/createMediaStyle.js +1 -1
- package/dist/jsx/helpers/createPropMapper.js +34 -15
- package/dist/jsx/helpers/createTamaguiProvider.js +2 -2
- package/dist/jsx/helpers/extendStaticConfig.js +5 -3
- package/dist/jsx/helpers/generateAtomicStyles.js +65 -119
- package/dist/jsx/helpers/getSplitStyles.js +29 -15
- package/dist/jsx/helpers/getStylesAtomic.js +7 -20
- package/dist/jsx/helpers/insertStyleRule.js +2 -1
- package/dist/jsx/helpers/isTamaguiComponent.js +15 -0
- package/dist/jsx/helpers/isTamaguiElement.js +2 -8
- package/dist/jsx/helpers/mergeProps.js +17 -0
- package/dist/jsx/helpers/pseudos.js +17 -0
- package/dist/jsx/helpers/themeable.js +2 -1
- package/dist/jsx/hooks/useTheme.js +2 -2
- package/dist/jsx/index.js +5 -0
- package/dist/jsx/static.js +2 -0
- package/dist/jsx/views/Slot.js +2 -1
- package/package.json +5 -6
- package/types/Pressability.d.ts +2 -0
- package/types/Pressability.d.ts.map +1 -0
- package/types/Pressability.native.d.ts +2 -0
- package/types/Pressability.native.d.ts.map +1 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +5 -6
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +2 -2
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -14
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +2 -0
- package/types/helpers/mergeProps.d.ts.map +1 -0
- package/types/helpers/pseudos.d.ts +15 -0
- package/types/helpers/pseudos.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -1
- package/types/static.d.ts +2 -0
- package/types/static.d.ts.map +1 -1
- package/types/types.d.ts +4 -3
- package/types/types.d.ts.map +1 -1
- package/types/views/Slot.d.ts.map +1 -1
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { stylePropsView } from "@tamagui/helpers";
|
|
4
4
|
import { createPropMapper } from "./createPropMapper";
|
|
5
|
+
import { mergeProps } from "./mergeProps";
|
|
5
6
|
function extendStaticConfig(config, parent) {
|
|
6
7
|
var _a;
|
|
7
8
|
if (!parent || !("staticConfig" in parent)) {
|
|
@@ -35,12 +36,13 @@ function extendStaticConfig(config, parent) {
|
|
|
35
36
|
...parent.staticConfig.validStyles,
|
|
36
37
|
...config.validStyles
|
|
37
38
|
} : parent.staticConfig.validStyles || stylePropsView,
|
|
38
|
-
defaultProps: {
|
|
39
|
+
defaultProps: mergeProps({
|
|
39
40
|
...parent.staticConfig.defaultProps,
|
|
40
|
-
...parent.staticConfig.defaultVariants
|
|
41
|
+
...parent.staticConfig.defaultVariants
|
|
42
|
+
}, {
|
|
41
43
|
...config.defaultProps,
|
|
42
44
|
...config.defaultVariants
|
|
43
|
-
}
|
|
45
|
+
})
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
__name(extendStaticConfig, "extendStaticConfig");
|
|
@@ -4,53 +4,44 @@ import { simpleHash } from "@tamagui/helpers";
|
|
|
4
4
|
import hyphenateStyleName from "hyphenate-style-name";
|
|
5
5
|
import normalizeCSSColor from "normalize-css-color";
|
|
6
6
|
import { isWeb } from "../constants/platform";
|
|
7
|
-
import {
|
|
7
|
+
import { pseudos } from "./pseudos";
|
|
8
|
+
const reducedStyleKeys = {
|
|
9
|
+
shadowColor: true,
|
|
10
|
+
shadowOffset: true,
|
|
11
|
+
shadowOpacity: true,
|
|
12
|
+
shadowRadius: true,
|
|
13
|
+
textShadowColor: true,
|
|
14
|
+
textShadowOffset: true,
|
|
15
|
+
textShadowRadius: true
|
|
16
|
+
};
|
|
8
17
|
function expandStyles(style) {
|
|
9
18
|
const res = {};
|
|
19
|
+
boxShadowReducer(res, style);
|
|
20
|
+
textShadowReducer(res, style);
|
|
10
21
|
for (const key in style) {
|
|
11
|
-
|
|
22
|
+
if (reducedStyleKeys[key])
|
|
23
|
+
continue;
|
|
24
|
+
if (key in pseudos) {
|
|
25
|
+
res[key] = expandStyles(style[key]);
|
|
26
|
+
} else {
|
|
27
|
+
updateReactDOMStyle(res, key, style[key]);
|
|
28
|
+
}
|
|
12
29
|
}
|
|
13
30
|
return res;
|
|
14
31
|
}
|
|
15
32
|
__name(expandStyles, "expandStyles");
|
|
16
|
-
function
|
|
17
|
-
|
|
33
|
+
function updateReactDOMStyle(style, key, value) {
|
|
34
|
+
value = normalizeValueWithProperty(value, key);
|
|
35
|
+
const out = expandStyle(key, value);
|
|
36
|
+
if (out) {
|
|
37
|
+
Object.assign(style, Object.fromEntries(out));
|
|
38
|
+
} else {
|
|
39
|
+
style[key] = value;
|
|
40
|
+
}
|
|
18
41
|
}
|
|
19
|
-
__name(
|
|
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
|
-
};
|
|
42
|
+
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
39
43
|
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
40
44
|
const res = expandStyles(style);
|
|
41
|
-
if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
|
|
42
|
-
boxShadowReducer(res, style);
|
|
43
|
-
delete res["shadowColor"];
|
|
44
|
-
delete res["shadowOffset"];
|
|
45
|
-
delete res["shadowOpacity"];
|
|
46
|
-
delete res["shadowRadius"];
|
|
47
|
-
}
|
|
48
|
-
if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
|
|
49
|
-
textShadowReducer(res, style);
|
|
50
|
-
delete res["textShadowColor"];
|
|
51
|
-
delete res["textShadowOffset"];
|
|
52
|
-
delete res["textShadowRadius"];
|
|
53
|
-
}
|
|
54
45
|
const out = {};
|
|
55
46
|
for (const key in res) {
|
|
56
47
|
const value = res[key];
|
|
@@ -61,11 +52,11 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
|
61
52
|
const { identifier } = cachedResult;
|
|
62
53
|
out[identifier] = cachedResult;
|
|
63
54
|
} else {
|
|
64
|
-
const identifier =
|
|
65
|
-
const rules = createAtomicRules(identifier, key,
|
|
55
|
+
const identifier = simpleHash(key + valueString);
|
|
56
|
+
const rules = createAtomicRules(identifier, key, valueString);
|
|
66
57
|
const cachedResult2 = cache.set(key, valueString, {
|
|
67
58
|
property: key,
|
|
68
|
-
value:
|
|
59
|
+
value: valueString,
|
|
69
60
|
identifier,
|
|
70
61
|
rules
|
|
71
62
|
});
|
|
@@ -75,16 +66,6 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
|
75
66
|
}
|
|
76
67
|
return out;
|
|
77
68
|
}, "generateAtomicStyles");
|
|
78
|
-
function updateReactDOMStyle(style, key, value) {
|
|
79
|
-
value = normalizeValueWithProperty(value, key);
|
|
80
|
-
const out = expandStyle(key, value);
|
|
81
|
-
if (out) {
|
|
82
|
-
Object.assign(style, Object.fromEntries(out));
|
|
83
|
-
} else {
|
|
84
|
-
style[key] = value;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
88
69
|
function expandStyle(key, value) {
|
|
89
70
|
if (key === "flex") {
|
|
90
71
|
if (value <= -1) {
|
|
@@ -153,15 +134,9 @@ function createAtomicRules(identifier, property, value) {
|
|
|
153
134
|
const rules = [];
|
|
154
135
|
const selector = `.${identifier}`;
|
|
155
136
|
switch (property) {
|
|
156
|
-
case "animationKeyframes": {
|
|
157
|
-
const { animationNames, rules: keyframesRules } = processKeyframesValue(value);
|
|
158
|
-
const block = createDeclarationBlock({ animationName: animationNames.join(",") });
|
|
159
|
-
rules.push(`${selector}${block}`, ...keyframesRules);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
137
|
case "placeholderTextColor": {
|
|
163
138
|
const block = createDeclarationBlock({ color: value, opacity: 1 });
|
|
164
|
-
rules.push(`${selector}
|
|
139
|
+
rules.push(`${selector}::placeholder${block}`);
|
|
165
140
|
break;
|
|
166
141
|
}
|
|
167
142
|
case "pointerEvents": {
|
|
@@ -200,58 +175,16 @@ function createAtomicRules(identifier, property, value) {
|
|
|
200
175
|
return rules;
|
|
201
176
|
}
|
|
202
177
|
__name(createAtomicRules, "createAtomicRules");
|
|
203
|
-
function processKeyframesValue(keyframesValue) {
|
|
204
|
-
if (typeof keyframesValue === "number") {
|
|
205
|
-
throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`);
|
|
206
|
-
}
|
|
207
|
-
const animationNames = [];
|
|
208
|
-
const rules = [];
|
|
209
|
-
const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue];
|
|
210
|
-
for (const keyframes of value) {
|
|
211
|
-
if (typeof keyframes === "string") {
|
|
212
|
-
animationNames.push(keyframes);
|
|
213
|
-
} else {
|
|
214
|
-
const { identifier, rules: keyframesRules } = createKeyframes(keyframes);
|
|
215
|
-
animationNames.push(identifier);
|
|
216
|
-
rules.push(...keyframesRules);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return { animationNames, rules };
|
|
220
|
-
}
|
|
221
|
-
__name(processKeyframesValue, "processKeyframesValue");
|
|
222
|
-
function createKeyframes(keyframes) {
|
|
223
|
-
const prefixes2 = ["-webkit-", ""];
|
|
224
|
-
const identifier = createIdentifier("r", "animation", keyframes);
|
|
225
|
-
const steps = "{" + Object.keys(keyframes).map((stepName) => {
|
|
226
|
-
const rule = keyframes[stepName];
|
|
227
|
-
const block = createDeclarationBlock(rule);
|
|
228
|
-
return `${stepName}${block}`;
|
|
229
|
-
}).join("") + "}";
|
|
230
|
-
const rules = prefixes2.map((prefix) => {
|
|
231
|
-
return `@${prefix}keyframes ${identifier}${steps}`;
|
|
232
|
-
});
|
|
233
|
-
return { identifier, rules };
|
|
234
|
-
}
|
|
235
|
-
__name(createKeyframes, "createKeyframes");
|
|
236
178
|
function createDeclarationBlock(style) {
|
|
237
|
-
const domStyle =
|
|
179
|
+
const domStyle = expandStyles(style);
|
|
238
180
|
const declarationsString = Object.keys(domStyle).map((property) => {
|
|
239
181
|
const value = domStyle[property];
|
|
240
182
|
const prop = hyphenateStyleName(property);
|
|
241
|
-
|
|
242
|
-
return value.map((v) => `${prop}:${v}`).join(";");
|
|
243
|
-
} else {
|
|
244
|
-
return `${prop}:${value}`;
|
|
245
|
-
}
|
|
183
|
+
return `${prop}:${value}`;
|
|
246
184
|
}).sort().join(";");
|
|
247
185
|
return `{${declarationsString};}`;
|
|
248
186
|
}
|
|
249
187
|
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
250
|
-
function createIdentifier(prefix, name, value) {
|
|
251
|
-
const hashedString = simpleHash(name + stringifyValueWithProperty(value, name));
|
|
252
|
-
return `${prefix}-${hashedString}`;
|
|
253
|
-
}
|
|
254
|
-
__name(createIdentifier, "createIdentifier");
|
|
255
188
|
const cache = {
|
|
256
189
|
get(property, value) {
|
|
257
190
|
if (cache[property] != null && cache[property].hasOwnProperty(value) && cache[property][value] != null) {
|
|
@@ -266,8 +199,7 @@ const cache = {
|
|
|
266
199
|
}
|
|
267
200
|
};
|
|
268
201
|
function stringifyValueWithProperty(value, property) {
|
|
269
|
-
|
|
270
|
-
return typeof normalizedValue !== "string" ? JSON.stringify(normalizedValue || "") : normalizedValue;
|
|
202
|
+
return normalizeValueWithProperty(value, property);
|
|
271
203
|
}
|
|
272
204
|
__name(stringifyValueWithProperty, "stringifyValueWithProperty");
|
|
273
205
|
const mapTransform = /* @__PURE__ */ __name((transform) => {
|
|
@@ -294,7 +226,8 @@ const colorProps = {
|
|
|
294
226
|
};
|
|
295
227
|
function normalizeValueWithProperty(value, property) {
|
|
296
228
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
297
|
-
|
|
229
|
+
const shouldCoerceToPx = typeof value === "number" && (property === void 0 || property === null || !unitlessNumbers[property]);
|
|
230
|
+
if (shouldCoerceToPx) {
|
|
298
231
|
return `${value}px`;
|
|
299
232
|
}
|
|
300
233
|
}
|
|
@@ -322,6 +255,7 @@ const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
|
322
255
|
const alpha = (a * opacity).toFixed(2);
|
|
323
256
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
324
257
|
}
|
|
258
|
+
return `${color}`;
|
|
325
259
|
}, "normalizeColor");
|
|
326
260
|
const isWebColor = /* @__PURE__ */ __name((color) => color === "currentcolor" || color === "currentColor" || color === "inherit" || color.indexOf("var(") === 0, "isWebColor");
|
|
327
261
|
const processColor = /* @__PURE__ */ __name((color) => {
|
|
@@ -381,25 +315,17 @@ const unitlessNumbers = {
|
|
|
381
315
|
scaleZ: true,
|
|
382
316
|
shadowOpacity: true
|
|
383
317
|
};
|
|
384
|
-
const prefixes = ["ms", "Moz", "O", "Webkit"];
|
|
385
|
-
const prefixKey = /* @__PURE__ */ __name((prefix, key) => {
|
|
386
|
-
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
387
|
-
}, "prefixKey");
|
|
388
|
-
Object.keys(unitlessNumbers).forEach((prop) => {
|
|
389
|
-
prefixes.forEach((prefix) => {
|
|
390
|
-
unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop];
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
318
|
const resolveShadowValue = /* @__PURE__ */ __name((style) => {
|
|
394
319
|
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
|
320
|
+
if (shadowRadius === void 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
395
323
|
const { height, width } = shadowOffset || defaultOffset;
|
|
396
324
|
const offsetX = normalizeValueWithProperty(width);
|
|
397
325
|
const offsetY = normalizeValueWithProperty(height);
|
|
398
326
|
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
399
|
-
const color = normalizeColor(shadowColor || "black", shadowOpacity);
|
|
400
|
-
|
|
401
|
-
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
402
|
-
}
|
|
327
|
+
const color = normalizeColor(String(shadowColor || "black"), shadowOpacity);
|
|
328
|
+
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
403
329
|
}, "resolveShadowValue");
|
|
404
330
|
function boxShadowReducer(resolvedStyle, style) {
|
|
405
331
|
const { boxShadow } = style;
|
|
@@ -423,9 +349,29 @@ function textShadowReducer(resolvedStyle, style) {
|
|
|
423
349
|
}
|
|
424
350
|
}
|
|
425
351
|
__name(textShadowReducer, "textShadowReducer");
|
|
352
|
+
const STYLE_SHORT_FORM_EXPANSIONS = {
|
|
353
|
+
borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
|
|
354
|
+
borderRadius: [
|
|
355
|
+
"borderTopLeftRadius",
|
|
356
|
+
"borderTopRightRadius",
|
|
357
|
+
"borderBottomRightRadius",
|
|
358
|
+
"borderBottomLeftRadius"
|
|
359
|
+
],
|
|
360
|
+
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
361
|
+
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
362
|
+
margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
|
|
363
|
+
marginHorizontal: ["marginRight", "marginLeft"],
|
|
364
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
365
|
+
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
366
|
+
padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
|
|
367
|
+
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
368
|
+
paddingVertical: ["paddingTop", "paddingBottom"],
|
|
369
|
+
...isWeb && {
|
|
370
|
+
overflow: ["overflowX", "overflowY"]
|
|
371
|
+
}
|
|
372
|
+
};
|
|
426
373
|
export {
|
|
427
374
|
expandStyle,
|
|
428
375
|
expandStyles,
|
|
429
|
-
generateAtomicStyles
|
|
430
|
-
inline
|
|
376
|
+
generateAtomicStyles
|
|
431
377
|
};
|
|
@@ -30,13 +30,12 @@ const skipProps = {
|
|
|
30
30
|
selectable: true,
|
|
31
31
|
cursor: true,
|
|
32
32
|
contain: true,
|
|
33
|
-
pointerEvents: true,
|
|
34
33
|
boxSizing: true,
|
|
35
34
|
boxShadow: true
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
let conf;
|
|
39
|
-
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
|
|
38
|
+
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames, debug) => {
|
|
40
39
|
var _a;
|
|
41
40
|
conf = conf || getConfig();
|
|
42
41
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
|
|
@@ -46,7 +45,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
46
45
|
const usedKeys = /* @__PURE__ */ new Set();
|
|
47
46
|
let style = {};
|
|
48
47
|
let classNames = {};
|
|
49
|
-
let transforms =
|
|
48
|
+
let transforms = null;
|
|
50
49
|
const rulesToInsert = [];
|
|
51
50
|
function addStyle(prop, rule) {
|
|
52
51
|
rulesToInsert.push([prop, rule]);
|
|
@@ -63,17 +62,22 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
63
62
|
if (!transform) {
|
|
64
63
|
updateInserted();
|
|
65
64
|
transform = insertedTransforms[val];
|
|
65
|
+
if (process.env.NODE_ENV === "development") {
|
|
66
|
+
if (!transform) {
|
|
67
|
+
console.warn("no transform, error", { insertedTransforms, val });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
if (!transform) {
|
|
68
72
|
if (isWeb && val[0] !== "_") {
|
|
69
73
|
transform = val;
|
|
70
|
-
} else {
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
if (process.env.NODE_ENV === "development" &&
|
|
76
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
74
77
|
console.log(" \xBB getSplitStyles mergeClassName transform", { key, val, namespace, transform, insertedTransforms });
|
|
75
78
|
}
|
|
76
79
|
}
|
|
80
|
+
transforms = transforms || {};
|
|
77
81
|
transforms[namespace] = transforms[namespace] || ["", ""];
|
|
78
82
|
const identifier = val.replace("_transform", "");
|
|
79
83
|
transforms[namespace][0] += identifier;
|
|
@@ -86,6 +90,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
86
90
|
}
|
|
87
91
|
__name(mergeClassName, "mergeClassName");
|
|
88
92
|
const propKeys = Object.keys(props);
|
|
93
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
94
|
+
console.log("propKeys", propKeys);
|
|
95
|
+
}
|
|
89
96
|
for (let i = propKeys.length - 1; i >= 0; i--) {
|
|
90
97
|
const keyInit = propKeys[i];
|
|
91
98
|
if (usedKeys.has(keyInit))
|
|
@@ -161,9 +168,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
161
168
|
viewProps[keyInit] = valInit;
|
|
162
169
|
continue;
|
|
163
170
|
}
|
|
164
|
-
const expanded = isMedia || isPseudo ? [[keyInit, valInit]] : staticConfig.propMapper(keyInit, valInit, theme, props, state);
|
|
171
|
+
const expanded = isMedia || isPseudo ? [[keyInit, valInit]] : staticConfig.propMapper(keyInit, valInit, theme, props, state, void 0, debug);
|
|
165
172
|
let isMediaOrPseudo = isMedia || isPseudo;
|
|
166
|
-
if (process.env.NODE_ENV === "development" &&
|
|
173
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
167
174
|
console.log(" \xBB getSplitStyles", keyInit, expanded);
|
|
168
175
|
}
|
|
169
176
|
if (!expanded) {
|
|
@@ -185,6 +192,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
185
192
|
continue;
|
|
186
193
|
}
|
|
187
194
|
if (staticConfig.deoptProps && staticConfig.deoptProps.has(key) || staticConfig.inlineProps && staticConfig.inlineProps.has(key)) {
|
|
195
|
+
usedKeys.add(key);
|
|
188
196
|
viewProps[key] = val;
|
|
189
197
|
}
|
|
190
198
|
if (isPseudo) {
|
|
@@ -201,7 +209,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
201
209
|
const fullKey = `${style2.property}-${key}`;
|
|
202
210
|
if (!usedKeys.has(fullKey)) {
|
|
203
211
|
usedKeys.add(fullKey);
|
|
204
|
-
addStyle(style2.identifier, style2.rules
|
|
212
|
+
addStyle(style2.identifier, style2.rules.join(";"));
|
|
205
213
|
mergeClassName(fullKey, style2.identifier, isMediaOrPseudo);
|
|
206
214
|
}
|
|
207
215
|
}
|
|
@@ -212,12 +220,14 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
212
220
|
const mediaKey = key;
|
|
213
221
|
const mediaKeyShort = mediaKey.slice(1);
|
|
214
222
|
if (!mediaQueryConfig[mediaKeyShort]) {
|
|
215
|
-
|
|
223
|
+
if (!usedKeys.has(key)) {
|
|
224
|
+
viewProps[key] = val;
|
|
225
|
+
}
|
|
216
226
|
continue;
|
|
217
227
|
}
|
|
218
228
|
const mediaStyle = getSubStyle(val, staticConfig, theme, props, state);
|
|
219
229
|
const shouldDoClasses = isWeb && !state.noClassNames;
|
|
220
|
-
if (process.env.NODE_ENV === "development" &&
|
|
230
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
221
231
|
console.log(" \xBB getSplitStyles mediaStyle", { mediaKey, mediaStyle, props, shouldDoClasses });
|
|
222
232
|
}
|
|
223
233
|
if (shouldDoClasses) {
|
|
@@ -233,7 +243,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
233
243
|
}
|
|
234
244
|
} else {
|
|
235
245
|
if (mediaState[mediaKey]) {
|
|
236
|
-
if (process.env.NODE_ENV === "development" &&
|
|
246
|
+
if (process.env.NODE_ENV === "development" && debug) {
|
|
237
247
|
console.log("apply media style", mediaKey, mediaState);
|
|
238
248
|
}
|
|
239
249
|
Object.assign(shouldDoClasses ? medias : style, mediaStyle);
|
|
@@ -252,8 +262,8 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
252
262
|
classNames[key] = val;
|
|
253
263
|
} else {
|
|
254
264
|
if (key in stylePropsTransform) {
|
|
255
|
-
if (process.env.NODE_ENV === "development" &&
|
|
256
|
-
console.log("mergeTransform", key, val);
|
|
265
|
+
if (process.env.NODE_ENV === "development" && debug) {
|
|
266
|
+
console.log(" > mergeTransform", key, val);
|
|
257
267
|
}
|
|
258
268
|
mergeTransform(style, key, val, true);
|
|
259
269
|
} else {
|
|
@@ -281,7 +291,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
281
291
|
for (const atomicStyle of atomic) {
|
|
282
292
|
const key = atomicStyle.property;
|
|
283
293
|
if (!state.dynamicStylesInline) {
|
|
284
|
-
addStyle(atomicStyle.identifier, atomicStyle.rules
|
|
294
|
+
addStyle(atomicStyle.identifier, atomicStyle.rules.join(";"));
|
|
285
295
|
mergeClassName(key, atomicStyle.identifier);
|
|
286
296
|
} else {
|
|
287
297
|
style[key] = atomicStyle.value;
|
|
@@ -290,6 +300,10 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
290
300
|
}
|
|
291
301
|
if (transforms) {
|
|
292
302
|
for (const namespace in transforms) {
|
|
303
|
+
if (!transforms[namespace]) {
|
|
304
|
+
console.warn("Error no transform");
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
293
307
|
const [hash, val] = transforms[namespace];
|
|
294
308
|
const identifier = `_transform${hash}`;
|
|
295
309
|
if (isClient) {
|
|
@@ -301,7 +315,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
301
315
|
classNames[namespace] = identifier;
|
|
302
316
|
}
|
|
303
317
|
}
|
|
304
|
-
if (process.env.NODE_ENV === "development" &&
|
|
318
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
305
319
|
if (typeof document !== "undefined") {
|
|
306
320
|
console.log(" \xBB getSplitStyles out", { style, pseudos, medias, classNames, viewProps, state });
|
|
307
321
|
}
|
|
@@ -5,20 +5,7 @@ import { reversedShorthands } from "../createTamagui";
|
|
|
5
5
|
import { isVariable } from "../createVariable";
|
|
6
6
|
import { generateAtomicStyles } from "./generateAtomicStyles";
|
|
7
7
|
import { invertMapTransformKeys, mergeTransform } from "./mergeTransform";
|
|
8
|
-
|
|
9
|
-
hoverStyle: {
|
|
10
|
-
name: "hover",
|
|
11
|
-
priority: 1
|
|
12
|
-
},
|
|
13
|
-
pressStyle: {
|
|
14
|
-
name: "active",
|
|
15
|
-
priority: 2
|
|
16
|
-
},
|
|
17
|
-
focusStyle: {
|
|
18
|
-
name: "focus",
|
|
19
|
-
priority: 3
|
|
20
|
-
}
|
|
21
|
-
};
|
|
8
|
+
import { pseudos } from "./pseudos";
|
|
22
9
|
const pseudosOrdered = Object.values(pseudos);
|
|
23
10
|
const psuedoCNInverse = {
|
|
24
11
|
hover: "hoverStyle",
|
|
@@ -61,7 +48,7 @@ function getAtomicStyle(style, pseudo, options) {
|
|
|
61
48
|
let atomicStyles = {};
|
|
62
49
|
if (options.splitTransforms && style.transform) {
|
|
63
50
|
let { transform, ...rest } = style;
|
|
64
|
-
|
|
51
|
+
style = rest;
|
|
65
52
|
for (const t of transform) {
|
|
66
53
|
const tKey = Object.keys(t)[0];
|
|
67
54
|
const transformProperty = invertMapTransformKeys[tKey] || tKey;
|
|
@@ -72,12 +59,13 @@ function getAtomicStyle(style, pseudo, options) {
|
|
|
72
59
|
transformProperty
|
|
73
60
|
};
|
|
74
61
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
62
|
+
}
|
|
63
|
+
if (style) {
|
|
64
|
+
Object.assign(atomicStyles, generateAtomicStyles(style));
|
|
77
65
|
}
|
|
78
66
|
return Object.keys(atomicStyles).map((key) => {
|
|
79
67
|
const val = atomicStyles[key];
|
|
80
|
-
const
|
|
68
|
+
const hash = val.identifier;
|
|
81
69
|
const psuedoPrefix = pseudo ? `0${pseudo.name}-` : "";
|
|
82
70
|
if (!val.property) {
|
|
83
71
|
throw new Error(`no prop`);
|
|
@@ -99,7 +87,7 @@ function getAtomicStyle(style, pseudo, options) {
|
|
|
99
87
|
const result = {
|
|
100
88
|
property: val.transformProperty || val.property,
|
|
101
89
|
pseudo: pseudo == null ? void 0 : pseudo.name,
|
|
102
|
-
value: val.value
|
|
90
|
+
value: val.value,
|
|
103
91
|
identifier,
|
|
104
92
|
className,
|
|
105
93
|
rules
|
|
@@ -118,6 +106,5 @@ const borderDefaults = {
|
|
|
118
106
|
};
|
|
119
107
|
export {
|
|
120
108
|
getStylesAtomic,
|
|
121
|
-
pseudos,
|
|
122
109
|
psuedoCNInverse
|
|
123
110
|
};
|
|
@@ -71,7 +71,8 @@ function updateInsertedCache(identifier, rule) {
|
|
|
71
71
|
if (insertedSelectors[identifier])
|
|
72
72
|
return;
|
|
73
73
|
insertedSelectors[identifier] = rule;
|
|
74
|
-
|
|
74
|
+
const isTransform = identifier.startsWith("_transform");
|
|
75
|
+
if (isTransform) {
|
|
75
76
|
addTransform(identifier, rule);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function isTamaguiComponent(comp, name) {
|
|
4
|
+
const config = comp && comp["staticConfig"];
|
|
5
|
+
if (!config || !config.parsed)
|
|
6
|
+
return false;
|
|
7
|
+
if (name) {
|
|
8
|
+
return name === config.componentName;
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
__name(isTamaguiComponent, "isTamaguiComponent");
|
|
13
|
+
export {
|
|
14
|
+
isTamaguiComponent
|
|
15
|
+
};
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
|
+
import { isTamaguiComponent } from "./isTamaguiComponent";
|
|
4
5
|
const isTamaguiElement = /* @__PURE__ */ __name((child, name) => {
|
|
5
|
-
|
|
6
|
-
const isTamagui = isValidElement(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
|
|
7
|
-
if (!isTamagui)
|
|
8
|
-
return false;
|
|
9
|
-
if (name) {
|
|
10
|
-
return name === child.type["staticConfig"].componentName;
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
6
|
+
return isValidElement(child) && isTamaguiComponent(child.type, name);
|
|
13
7
|
}, "isTamaguiElement");
|
|
14
8
|
export {
|
|
15
9
|
isTamaguiElement
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const mergeProps = /* @__PURE__ */ __name((a, b) => {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const key in a) {
|
|
6
|
+
if (!(key in b)) {
|
|
7
|
+
out[key] = a[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
for (const key in b) {
|
|
11
|
+
out[key] = b[key];
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}, "mergeProps");
|
|
15
|
+
export {
|
|
16
|
+
mergeProps
|
|
17
|
+
};
|
|
@@ -4,7 +4,8 @@ import React, { forwardRef } from "react";
|
|
|
4
4
|
import { Theme } from "../views/Theme";
|
|
5
5
|
import { ThemeInverse } from "../views/ThemeInverse";
|
|
6
6
|
function themeable(component, opts) {
|
|
7
|
-
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(
|
|
7
|
+
const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme(props, ref) {
|
|
8
|
+
const { themeInverse, theme, ...rest } = props;
|
|
8
9
|
const element = React.createElement(component, { ...rest, ref });
|
|
9
10
|
if (themeInverse) {
|
|
10
11
|
return <ThemeInverse>{element}</ThemeInverse>;
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
4
|
import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { getConfig } from "../conf";
|
|
6
|
-
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
6
|
+
import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
7
7
|
import { areEqualSets } from "../helpers/areEqualSets";
|
|
8
8
|
import { ThemeContext } from "../ThemeContext";
|
|
9
9
|
import { ThemeManager, ThemeManagerContext, emptyManager } from "../ThemeManager";
|
|
@@ -128,7 +128,7 @@ const useChangeThemeEffect = /* @__PURE__ */ __name((name, componentName, props,
|
|
|
128
128
|
return null;
|
|
129
129
|
return new ThemeManager(next.name, next.theme, parentManager, reset);
|
|
130
130
|
});
|
|
131
|
-
if (typeof document !== "undefined") {
|
|
131
|
+
if (!isWeb || typeof document !== "undefined") {
|
|
132
132
|
useLayoutEffect(() => {
|
|
133
133
|
if (!themeManager)
|
|
134
134
|
return;
|
package/dist/jsx/index.js
CHANGED
|
@@ -23,9 +23,13 @@ export * from "./helpers/getExpandedShorthands";
|
|
|
23
23
|
export * from "./helpers/getSize";
|
|
24
24
|
export * from "./helpers/getSplitStyles";
|
|
25
25
|
export * from "./helpers/getStylesAtomic";
|
|
26
|
+
export * from "./helpers/pseudos";
|
|
27
|
+
export * from "./helpers/mergeProps";
|
|
28
|
+
import { expandStyles } from "./helpers/generateAtomicStyles";
|
|
26
29
|
export * from "./helpers/getTextSize";
|
|
27
30
|
export * from "./helpers/isObj";
|
|
28
31
|
export * from "./helpers/isTamaguiElement";
|
|
32
|
+
export * from "./helpers/isTamaguiComponent";
|
|
29
33
|
export * from "./helpers/matchMedia";
|
|
30
34
|
export * from "./helpers/themeable";
|
|
31
35
|
export * from "./helpers/withStaticProperties";
|
|
@@ -51,6 +55,7 @@ export * from "@tamagui/helpers";
|
|
|
51
55
|
export {
|
|
52
56
|
RNWTextProps,
|
|
53
57
|
RNWViewProps,
|
|
58
|
+
expandStyles,
|
|
54
59
|
getConfig,
|
|
55
60
|
getHasConfigured,
|
|
56
61
|
getThemes,
|
package/dist/jsx/static.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./hooks/useMedia";
|
|
|
9
9
|
export * from "./hooks/useTheme";
|
|
10
10
|
export * from "./helpers/isObj";
|
|
11
11
|
export * from "./helpers/getStylesAtomic";
|
|
12
|
+
export * from "./helpers/generateAtomicStyles";
|
|
13
|
+
export * from "./helpers/pseudos";
|
|
12
14
|
export * from "./helpers/proxyThemeVariables";
|
|
13
15
|
export * from "./helpers/getSplitStyles";
|
|
14
16
|
export * from "@tamagui/helpers";
|