@tamagui/core 1.0.0-beta.153 → 1.0.0-beta.16
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 +1 -0
- package/dist/cjs/Tamagui.js +13 -1
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/ThemeContext.js +4 -0
- package/dist/cjs/ThemeManager.js +30 -14
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/conf.js +10 -1
- package/dist/cjs/conf.js.map +2 -2
- package/dist/cjs/constants/constants.js +6 -0
- package/dist/cjs/constants/platform.js +15 -0
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/rnw.js +4 -0
- package/dist/cjs/contexts/ButtonInsideButtonContext.js +4 -0
- package/dist/cjs/createComponent.js +191 -113
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js +4 -0
- package/dist/cjs/createShorthands.js +4 -0
- package/dist/cjs/createTamagui.js +48 -27
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +4 -0
- package/dist/cjs/createTokens.js +7 -6
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +18 -2
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/RNComponents.js +4 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js +8 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
- package/dist/cjs/helpers/areEqualSets.js +4 -0
- package/dist/cjs/helpers/createMediaStyle.js +5 -2
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +53 -22
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +4 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +4 -0
- package/dist/cjs/helpers/extendStaticConfig.js +9 -6
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.js +4 -0
- package/dist/cjs/helpers/fixNativeShadow.native.js +10 -9
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/cjs/helpers/getButtonSize.js +45 -0
- package/dist/cjs/helpers/getButtonSize.js.map +7 -0
- package/dist/cjs/helpers/getExpandedShorthands.js +4 -0
- package/dist/cjs/helpers/getSize.js +35 -0
- package/dist/cjs/helpers/getSize.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +137 -55
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +20 -3
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
- package/dist/cjs/helpers/getTextSize.js +56 -0
- package/dist/cjs/helpers/getTextSize.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +42 -27
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isObj.js +4 -0
- package/dist/cjs/helpers/isTamaguiElement.js +4 -0
- package/dist/cjs/helpers/matchMedia.js +4 -0
- package/dist/cjs/helpers/matchMedia.native.js +4 -0
- package/dist/cjs/{constants/pseudos.js → helpers/nativeGestureHandler.js} +11 -19
- package/dist/cjs/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
- package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
- package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +7 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/validate.js +53 -11
- package/dist/cjs/helpers/validate.js.map +2 -2
- package/dist/cjs/helpers/withStaticProperties.js +4 -0
- package/dist/cjs/helpers/wrapThemeManagerContext.js +4 -0
- package/dist/cjs/hooks/useConstant.js +4 -0
- package/dist/cjs/hooks/useFeatures.js +4 -0
- package/dist/cjs/hooks/useId.js +59 -0
- package/dist/cjs/hooks/useId.js.map +7 -0
- package/dist/cjs/hooks/useIsMounted.js +4 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +8 -4
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +14 -0
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/usePressable.js +4 -0
- package/dist/cjs/hooks/usePrevious.js +1 -0
- package/dist/cjs/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
- package/dist/cjs/hooks/useTheme.js +30 -16
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js +4 -0
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/nativeGestureHandler.native.js.map +7 -0
- package/dist/cjs/static.js +3 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +11 -5
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +134 -0
- package/dist/cjs/views/Slot.js.map +7 -0
- package/dist/cjs/views/Stack.js +4 -0
- package/dist/cjs/views/Text.js +13 -14
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/TextAncestorContext.js +6 -0
- package/dist/cjs/views/Theme.js +7 -3
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +10 -1
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +6 -1
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +4 -0
- package/dist/esm/Tamagui.js +8 -2
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/ThemeManager.js +21 -11
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/conf.js +0 -1
- package/dist/esm/conf.js.map +2 -2
- package/dist/esm/constants/platform.js +2 -0
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/createComponent.js +187 -122
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +45 -28
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js +2 -6
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createVariable.js +8 -2
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/addStylesUsingClassname.js +4 -1
- package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +0 -2
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +50 -22
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +9 -6
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/fixNativeShadow.native.js +7 -9
- package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/esm/helpers/getButtonSize.js +24 -0
- package/dist/esm/helpers/getButtonSize.js.map +7 -0
- package/dist/esm/helpers/getSize.js +13 -0
- package/dist/esm/helpers/getSize.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +136 -57
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +15 -3
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getTextSize.js +34 -0
- package/dist/esm/helpers/getTextSize.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +32 -27
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/nativeGestureHandler.js +7 -0
- package/dist/esm/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
- package/dist/esm/helpers/proxyThemeVariables.js +18 -0
- package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/esm/helpers/themeable.js +3 -2
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/validate.js +24 -11
- package/dist/esm/helpers/validate.js.map +2 -2
- package/dist/esm/hooks/useId.js +35 -0
- package/dist/esm/hooks/useId.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +6 -6
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +3 -0
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/usePrevious.js +1 -0
- package/dist/esm/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
- package/dist/esm/hooks/useTheme.js +22 -16
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +13 -6
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/nativeGestureHandler.native.js +2 -0
- package/dist/esm/nativeGestureHandler.native.js.map +7 -0
- package/dist/esm/static.js +3 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +7 -5
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Slot.js +82 -0
- package/dist/esm/views/Slot.js.map +7 -0
- package/dist/esm/views/Text.js +9 -14
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +3 -3
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +6 -2
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +2 -1
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/jsx/Tamagui.js +8 -2
- package/dist/jsx/ThemeManager.js +21 -11
- package/dist/jsx/conf.js +0 -1
- package/dist/jsx/constants/platform.js +2 -0
- package/dist/jsx/createComponent.js +173 -113
- package/dist/jsx/createTamagui.js +45 -28
- package/dist/jsx/createTokens.js +2 -6
- package/dist/jsx/createVariable.js +8 -2
- package/dist/jsx/helpers/addStylesUsingClassname.js +4 -1
- package/dist/jsx/helpers/createMediaStyle.js +0 -2
- package/dist/jsx/helpers/createPropMapper.js +50 -22
- package/dist/jsx/helpers/extendStaticConfig.js +9 -6
- package/dist/jsx/helpers/fixNativeShadow.native.js +7 -9
- package/dist/jsx/helpers/getButtonSize.js +23 -0
- package/dist/jsx/helpers/getSize.js +12 -0
- package/dist/jsx/helpers/getSplitStyles.js +136 -57
- package/dist/jsx/helpers/getStylesAtomic.js +15 -3
- package/dist/jsx/helpers/getTextSize.js +33 -0
- package/dist/jsx/helpers/insertStyleRule.js +32 -27
- package/dist/jsx/helpers/nativeGestureHandler.js +6 -0
- package/dist/jsx/helpers/nativeGestureHandler.native.js +1 -0
- package/dist/jsx/helpers/proxyThemeVariables.js +17 -0
- package/dist/jsx/helpers/themeable.js +3 -3
- package/dist/jsx/helpers/validate.js +24 -11
- package/dist/jsx/hooks/useId.js +34 -0
- package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
- package/dist/jsx/hooks/useMedia.js +3 -0
- package/dist/jsx/{createShallowUpdate.js → hooks/usePrevious.js} +0 -0
- package/dist/jsx/hooks/useTheme.js +22 -16
- package/dist/jsx/index.js +13 -6
- package/dist/jsx/nativeGestureHandler.native.js +1 -0
- package/dist/jsx/static.js +3 -0
- package/dist/jsx/styled.js +7 -5
- package/dist/jsx/views/Slot.js +75 -0
- package/dist/jsx/views/Text.js +9 -14
- package/dist/jsx/views/Theme.js +4 -4
- package/dist/jsx/views/ThemeInverse.js +6 -1
- package/dist/jsx/views/ThemeProvider.js +2 -2
- package/package.json +8 -6
- package/types/Tamagui.d.ts +16 -1
- package/types/Tamagui.d.ts.map +1 -1
- package/types/ThemeManager.d.ts +3 -3
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/conf.d.ts +2 -0
- package/types/conf.d.ts.map +1 -1
- package/types/constants/platform.d.ts +1 -0
- package/types/constants/platform.d.ts.map +1 -1
- package/types/createComponent.d.ts +3 -4
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts +3 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTokens.d.ts +0 -26
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariable.d.ts +1 -0
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
- package/types/helpers/createMediaStyle.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/extendStaticConfig.d.ts +2 -2
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts +2 -1
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
- package/types/helpers/getButtonSize.d.ts +8 -0
- package/types/helpers/getButtonSize.d.ts.map +1 -0
- package/types/helpers/getSize.d.ts +3 -0
- package/types/helpers/getSize.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +14 -6
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getTextSize.d.ts +3 -0
- package/types/helpers/getTextSize.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts +2 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/nativeGestureHandler.d.ts +2 -0
- package/types/helpers/nativeGestureHandler.d.ts.map +1 -0
- package/types/helpers/nativeGestureHandler.native.d.ts +2 -0
- package/types/helpers/nativeGestureHandler.native.d.ts.map +1 -0
- package/types/helpers/proxyThemeVariables.d.ts +2 -0
- package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts +3 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/helpers/validate.d.ts.map +1 -1
- package/types/hooks/useId.d.ts +9 -0
- package/types/hooks/useId.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts +2 -6
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/usePrevious.d.ts +1 -0
- package/types/hooks/usePrevious.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/index.d.ts +11 -6
- package/types/index.d.ts.map +1 -1
- package/types/nativeGestureHandler.native.d.ts +2 -0
- package/types/nativeGestureHandler.native.d.ts.map +1 -0
- package/types/static.d.ts +3 -0
- package/types/static.d.ts.map +1 -1
- package/types/styled.d.ts +12 -3
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +86 -46
- package/types/types.d.ts.map +1 -1
- package/types/views/Slot.d.ts +9 -0
- package/types/views/Slot.d.ts.map +1 -0
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -0
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeInverse.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/constants/pseudos.js.map +0 -7
- package/dist/cjs/createShallowUpdate.js +0 -1
- package/dist/cjs/devtools.js +0 -32
- package/dist/cjs/devtools.js.map +0 -7
- package/dist/cjs/spacedChildren.js +0 -86
- package/dist/cjs/spacedChildren.js.map +0 -7
- package/dist/cjs/tamagui-base.css +0 -8
- package/dist/cjs/tamagui-base.css.map +0 -7
- package/dist/esm/constants/pseudos.js +0 -18
- package/dist/esm/constants/pseudos.js.map +0 -7
- package/dist/esm/createShallowUpdate.js +0 -1
- package/dist/esm/devtools.js +0 -14
- package/dist/esm/devtools.js.map +0 -7
- package/dist/esm/spacedChildren.js +0 -52
- package/dist/esm/spacedChildren.js.map +0 -7
- package/dist/esm/tamagui-base.css +0 -8
- package/dist/esm/tamagui-base.css.map +0 -7
- package/dist/jsx/constants/pseudos.js +0 -17
- package/dist/jsx/devtools.js +0 -13
- package/dist/jsx/spacedChildren.js +0 -44
- package/dist/jsx/tamagui-base.css +0 -7
- package/types/spacedChildren.d.ts +0 -9
- package/types/spacedChildren.d.ts.map +0 -1
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { useInsertionEffect } from "react";
|
|
4
4
|
import { getStylesAtomic } from "./getStylesAtomic";
|
|
5
|
-
import { insertStyleRule } from "./insertStyleRule";
|
|
5
|
+
import { insertStyleRule, updateInsertedCache } from "./insertStyleRule";
|
|
6
6
|
let added = /* @__PURE__ */ new Set();
|
|
7
7
|
function useStylesAsClassname(styles, disable = false, debug = false) {
|
|
8
8
|
if (!useInsertionEffect) {
|
|
@@ -14,6 +14,9 @@ function useStylesAsClassname(styles, disable = false, debug = false) {
|
|
|
14
14
|
insertions.push({ identifier, rule });
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
for (const { identifier, rule } of insertions) {
|
|
18
|
+
updateInsertedCache(identifier, rule);
|
|
19
|
+
}
|
|
17
20
|
useInsertionEffect(() => {
|
|
18
21
|
for (const { identifier, rule } of insertions) {
|
|
19
22
|
insertStyleRule(identifier, rule);
|
|
@@ -13,8 +13,6 @@ const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey
|
|
|
13
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
14
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
15
15
|
const styleInner = rules[0].replace(identifier, nextIdentifier);
|
|
16
|
-
if (styleInner.includes("2:r;"))
|
|
17
|
-
debugger;
|
|
18
16
|
let styleRule = "";
|
|
19
17
|
if (styleInner.includes("@media")) {
|
|
20
18
|
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
@@ -37,13 +37,15 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
37
37
|
console.trace("no conf! err");
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
41
41
|
const variant = variants && variants[key];
|
|
42
42
|
if (variant && value !== void 0) {
|
|
43
43
|
let variantValue = getVariantFunction(variant, key, value);
|
|
44
44
|
if (variantValue) {
|
|
45
45
|
if (typeof variantValue === "function") {
|
|
46
|
-
|
|
46
|
+
const fn = variantValue;
|
|
47
|
+
variantValue = fn(value, {
|
|
48
|
+
fonts: conf.fontsParsed,
|
|
47
49
|
tokens: conf.tokensParsed,
|
|
48
50
|
theme,
|
|
49
51
|
props: avoidDefaultProps ? props : new Proxy(props, {
|
|
@@ -61,7 +63,7 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
61
63
|
if (isObj(variantValue)) {
|
|
62
64
|
variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
|
|
63
65
|
}
|
|
64
|
-
return variantValue;
|
|
66
|
+
return expansions(variantValue);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
let shouldReturn = false;
|
|
@@ -78,9 +80,9 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
if (shouldReturn) {
|
|
81
|
-
return {
|
|
83
|
+
return expansions({
|
|
82
84
|
[key]: value
|
|
83
|
-
};
|
|
85
|
+
});
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
88
|
}, "createPropMapper");
|
|
@@ -110,34 +112,28 @@ const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, re
|
|
|
110
112
|
}
|
|
111
113
|
return res;
|
|
112
114
|
}, "resolveTokens");
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
const fontShorthand = {
|
|
116
|
+
fontSize: "size",
|
|
117
|
+
fontWeight: "weight"
|
|
118
|
+
};
|
|
119
|
+
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs) => {
|
|
120
|
+
var _a, _b, _c;
|
|
115
121
|
let valOrVar;
|
|
116
122
|
let hasSet = false;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
valOrVar = theme[valueName];
|
|
123
|
+
if (value in theme) {
|
|
124
|
+
valOrVar = theme[value];
|
|
120
125
|
hasSet = true;
|
|
121
126
|
} else {
|
|
122
127
|
switch (key) {
|
|
123
128
|
case "fontFamily":
|
|
124
|
-
valOrVar = ((_a =
|
|
129
|
+
valOrVar = ((_a = fontsParsed[value]) == null ? void 0 : _a.family) || value;
|
|
125
130
|
hasSet = true;
|
|
126
131
|
break;
|
|
127
132
|
case "fontSize":
|
|
128
|
-
valOrVar = ((_b = tokensParsed.font[fontFamily]) == null ? void 0 : _b.size[value]) || value;
|
|
129
|
-
hasSet = true;
|
|
130
|
-
break;
|
|
131
133
|
case "lineHeight":
|
|
132
|
-
valOrVar = ((_c = tokensParsed.font[fontFamily]) == null ? void 0 : _c.lineHeight[value]) || value;
|
|
133
|
-
hasSet = true;
|
|
134
|
-
break;
|
|
135
134
|
case "letterSpacing":
|
|
136
|
-
valOrVar = ((_d = tokensParsed.font[fontFamily]) == null ? void 0 : _d.letterSpacing[value]) || value;
|
|
137
|
-
hasSet = true;
|
|
138
|
-
break;
|
|
139
135
|
case "fontWeight":
|
|
140
|
-
valOrVar = ((
|
|
136
|
+
valOrVar = ((_c = (_b = fontsParsed[fontFamily]) == null ? void 0 : _b[fontShorthand[key] || key]) == null ? void 0 : _c[value]) || value;
|
|
141
137
|
hasSet = true;
|
|
142
138
|
break;
|
|
143
139
|
}
|
|
@@ -163,7 +159,7 @@ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed }, theme, fo
|
|
|
163
159
|
}
|
|
164
160
|
if (process.env.NODE_ENV === "development") {
|
|
165
161
|
if (value && value[0] === "$") {
|
|
166
|
-
console.warn(`\u26A0\uFE0F Missing token
|
|
162
|
+
console.warn(`\u26A0\uFE0F Missing token:`, key, value, fontFamily, theme, fontsParsed);
|
|
167
163
|
return null;
|
|
168
164
|
}
|
|
169
165
|
}
|
|
@@ -204,6 +200,38 @@ const tokenCategories = {
|
|
|
204
200
|
borderRightColor: true
|
|
205
201
|
}
|
|
206
202
|
};
|
|
203
|
+
const sidesX = ["Left", "Right"];
|
|
204
|
+
const sidesY = ["Top", "Bottom"];
|
|
205
|
+
const sidesXY = [...sidesX, ...sidesY];
|
|
206
|
+
const expand = {
|
|
207
|
+
padding: sidesXY.map((x) => `padding${x}`),
|
|
208
|
+
paddingHorizontal: sidesX.map((x) => `padding${x}`),
|
|
209
|
+
paddingVertical: sidesY.map((x) => `padding${x}`),
|
|
210
|
+
margin: sidesXY.map((x) => `margin${x}`),
|
|
211
|
+
marginHorizontal: sidesX.map((x) => `margin${x}`),
|
|
212
|
+
marginVertical: sidesY.map((x) => `margin${x}`),
|
|
213
|
+
borderWidth: sidesXY.map((x) => `border${x}Width`)
|
|
214
|
+
};
|
|
215
|
+
function expansions(styleObj) {
|
|
216
|
+
var _a, _b;
|
|
217
|
+
for (const key in expand) {
|
|
218
|
+
if (key in styleObj) {
|
|
219
|
+
for (const expandKey of expand[key]) {
|
|
220
|
+
styleObj[expandKey] = styleObj[key];
|
|
221
|
+
}
|
|
222
|
+
delete styleObj[key];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if ("flex" in styleObj) {
|
|
226
|
+
if (typeof styleObj.flex === "number") {
|
|
227
|
+
styleObj.flexGrow = (_a = styleObj.flexGrow) != null ? _a : styleObj.flex;
|
|
228
|
+
styleObj.flexShrink = (_b = styleObj.flexShrink) != null ? _b : 1;
|
|
229
|
+
delete styleObj.flex;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return styleObj;
|
|
233
|
+
}
|
|
234
|
+
__name(expansions, "expansions");
|
|
207
235
|
export {
|
|
208
236
|
createPropMapper
|
|
209
237
|
};
|
|
@@ -2,12 +2,9 @@ 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
|
-
function extendStaticConfig(
|
|
5
|
+
function extendStaticConfig(config, parent) {
|
|
6
6
|
var _a;
|
|
7
|
-
if (!parent) {
|
|
8
|
-
throw new Error("no parent");
|
|
9
|
-
}
|
|
10
|
-
if (!("staticConfig" in parent)) {
|
|
7
|
+
if (!parent || !("staticConfig" in parent)) {
|
|
11
8
|
return parseStaticConfig(config);
|
|
12
9
|
}
|
|
13
10
|
const variants = {
|
|
@@ -38,9 +35,15 @@ function extendStaticConfig(parent, config = {}) {
|
|
|
38
35
|
...parent.staticConfig.validStyles,
|
|
39
36
|
...config.validStyles
|
|
40
37
|
} : parent.staticConfig.validStyles || stylePropsView,
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
...parent.staticConfig.defaultVariants,
|
|
40
|
+
...config.defaultVariants
|
|
41
|
+
},
|
|
41
42
|
defaultProps: {
|
|
42
43
|
...parent.staticConfig.defaultProps,
|
|
43
|
-
...
|
|
44
|
+
...parent.staticConfig.defaultVariants,
|
|
45
|
+
...config.defaultProps,
|
|
46
|
+
...config.defaultVariants
|
|
44
47
|
}
|
|
45
48
|
});
|
|
46
49
|
}
|
|
@@ -2,7 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
const matchRgbaHsla = /(rgba|hsla)\(\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,})\s*\)$/;
|
|
4
4
|
function fixNativeShadow(props) {
|
|
5
|
-
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (!props.shadowColor || props.shadowColor === "transparent") {
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
9
|
if (!props.shadowOffset) {
|
|
@@ -11,20 +12,17 @@ function fixNativeShadow(props) {
|
|
|
11
12
|
height: 0
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const c = `${props.shadowColor}`;
|
|
15
|
+
const c = String(props.shadowColor);
|
|
18
16
|
if ((c[0] === "r" || c[0] === "h") && c[3] === "a") {
|
|
19
17
|
const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || [];
|
|
20
18
|
if (typeof a !== "string") {
|
|
21
|
-
console.
|
|
22
|
-
|
|
19
|
+
console.trace("invalid", c, type);
|
|
20
|
+
throw new Error(`invalid style`);
|
|
23
21
|
}
|
|
24
22
|
props.shadowColor = `${type.replace("a", "")}(${_1},${_2},${_3})`;
|
|
25
|
-
props.shadowOpacity = +a;
|
|
23
|
+
props.shadowOpacity = (_a = props.shadowOpacity) != null ? _a : +a;
|
|
26
24
|
} else {
|
|
27
|
-
props.shadowOpacity = 1;
|
|
25
|
+
props.shadowOpacity = (_b = props.shadowOpacity) != null ? _b : 1;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
__name(fixNativeShadow, "fixNativeShadow");
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getVariableValue, isVariable } from "@tamagui/core";
|
|
4
|
+
const getButtonSize = /* @__PURE__ */ __name((sizeX = 0.9, sizeY = 0.333) => (val, { tokens, props, fonts }) => {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6
|
+
const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : tokens.size["$4"]) != null ? _b : val) != null ? _c : 14;
|
|
7
|
+
const radius = (_e = (_d = tokens.radius[val]) != null ? _d : tokens.radius["$4"]) != null ? _e : size;
|
|
8
|
+
const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX);
|
|
9
|
+
const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY);
|
|
10
|
+
const font = fonts[props.fontFamily] || fonts["$body"];
|
|
11
|
+
const lineHeights = font.lineHeight;
|
|
12
|
+
const lineHeight = (_f = lineHeights[val]) != null ? _f : lineHeights["$4"];
|
|
13
|
+
const minHeight = Math.round(getVariableValue(lineHeight) + py * 2);
|
|
14
|
+
return {
|
|
15
|
+
minHeight,
|
|
16
|
+
paddingHorizontal: props.circular ? 0 : px,
|
|
17
|
+
paddingVertical: props.circular ? 0 : py,
|
|
18
|
+
borderRadius: props.circular ? 1e5 : (_g = props.borderRadius) != null ? _g : radius
|
|
19
|
+
};
|
|
20
|
+
}, "getButtonSize");
|
|
21
|
+
export {
|
|
22
|
+
getButtonSize
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getTokens } from "../conf";
|
|
4
|
+
const getSize = /* @__PURE__ */ __name((size, sizeUpOrDownBy = 0) => {
|
|
5
|
+
const sizes = getTokens().size;
|
|
6
|
+
const sizeNames = Object.keys(sizes);
|
|
7
|
+
const key = sizeNames[Math.max(0, sizeNames.indexOf(String(size || "$4")) + sizeUpOrDownBy)];
|
|
8
|
+
return sizes[key] || sizes["$4"];
|
|
9
|
+
}, "getSize");
|
|
10
|
+
export {
|
|
11
|
+
getSize
|
|
12
|
+
};
|
|
@@ -7,33 +7,45 @@ import {
|
|
|
7
7
|
validPseudoKeys,
|
|
8
8
|
validStyles
|
|
9
9
|
} from "@tamagui/helpers";
|
|
10
|
-
import {
|
|
10
|
+
import { useInsertionEffect } from "react";
|
|
11
|
+
import { getConfig } from "../conf";
|
|
12
|
+
import { isClient, isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
11
13
|
import { mediaQueryConfig, mediaState } from "../hooks/useMedia";
|
|
12
14
|
import { createMediaStyle } from "./createMediaStyle";
|
|
13
15
|
import { fixNativeShadow } from "./fixNativeShadow";
|
|
14
16
|
import { getStylesAtomic } from "./getStylesAtomic";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
+
import {
|
|
18
|
+
insertStyleRule,
|
|
19
|
+
insertedTransforms,
|
|
20
|
+
updateInserted,
|
|
21
|
+
updateInsertedCache
|
|
22
|
+
} from "./insertStyleRule";
|
|
23
|
+
const skipProps = {
|
|
17
24
|
animation: true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
animateOnly: true,
|
|
26
|
+
debug: true,
|
|
27
|
+
...!isWeb && {
|
|
28
|
+
tag: true,
|
|
29
|
+
whiteSpace: true,
|
|
30
|
+
wordWrap: true,
|
|
31
|
+
textOverflow: true,
|
|
32
|
+
textDecorationDistance: true,
|
|
33
|
+
userSelect: true,
|
|
34
|
+
selectable: true,
|
|
35
|
+
cursor: true,
|
|
36
|
+
contain: true,
|
|
37
|
+
pointerEvents: true,
|
|
38
|
+
boxSizing: true,
|
|
39
|
+
boxShadow: true
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
__name(normalizeStyleObject, "normalizeStyleObject");
|
|
41
|
+
};
|
|
42
|
+
let conf;
|
|
36
43
|
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
|
|
44
|
+
var _a;
|
|
45
|
+
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
46
|
+
console.log(" \xBB getSplitStyles", { props, state, defaultClassNames });
|
|
47
|
+
}
|
|
48
|
+
conf = conf || getConfig();
|
|
37
49
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
|
|
38
50
|
const viewProps = {};
|
|
39
51
|
const style = {};
|
|
@@ -42,28 +54,51 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
42
54
|
};
|
|
43
55
|
const pseudos = {};
|
|
44
56
|
const medias = {};
|
|
57
|
+
const rulesToInsert = [];
|
|
58
|
+
function addStyle(prop, rule) {
|
|
59
|
+
rulesToInsert.push([prop, rule]);
|
|
60
|
+
updateInsertedCache(prop, rule);
|
|
61
|
+
}
|
|
62
|
+
__name(addStyle, "addStyle");
|
|
45
63
|
let cur = null;
|
|
46
64
|
let transforms = {};
|
|
47
65
|
function mergeClassName(key, val) {
|
|
48
|
-
if (!val)
|
|
66
|
+
if (!val) {
|
|
49
67
|
return;
|
|
68
|
+
}
|
|
50
69
|
if (val.startsWith("_transform-")) {
|
|
51
70
|
const isMediaOrPseudo = key !== "transform";
|
|
52
71
|
const isMedia = isMediaOrPseudo && key[11] === "_";
|
|
53
|
-
const isPsuedo = isMediaOrPseudo && key[11] === "0";
|
|
72
|
+
const isPsuedo = isMediaOrPseudo && key[11] === "0" || key.endsWith("Style");
|
|
54
73
|
const namespace = isMedia ? key.split("_")[2] : isPsuedo ? key.split("-")[1] : "transform";
|
|
55
74
|
let transform = insertedTransforms[val];
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
if (isClient) {
|
|
76
|
+
if (!transform) {
|
|
77
|
+
updateInserted();
|
|
78
|
+
transform = insertedTransforms[val];
|
|
79
|
+
}
|
|
80
|
+
if (!transform) {
|
|
81
|
+
if (isWeb && val[0] !== "_") {
|
|
82
|
+
transform = val;
|
|
83
|
+
} else {
|
|
84
|
+
console.trace("?", key, val, cur, props, state);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
88
|
+
console.log(" \xBB getSplitStyles mergeClassName transform", { key, val, namespace, transform, insertedTransforms });
|
|
89
|
+
}
|
|
90
|
+
if (process.env.NODE_ENV === "development") {
|
|
91
|
+
if (!transform) {
|
|
92
|
+
console.trace("NO TRANSFORM?", { key, val, transform });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
63
95
|
}
|
|
64
96
|
transforms[namespace] = transforms[namespace] || ["", ""];
|
|
65
|
-
|
|
66
|
-
transforms[namespace][
|
|
97
|
+
const identifier = val.replace("_transform", "");
|
|
98
|
+
transforms[namespace][0] += identifier;
|
|
99
|
+
if (transform) {
|
|
100
|
+
transforms[namespace][1] += transform;
|
|
101
|
+
}
|
|
67
102
|
} else {
|
|
68
103
|
classNames[key] = val;
|
|
69
104
|
}
|
|
@@ -73,12 +108,15 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
73
108
|
if (!cur)
|
|
74
109
|
return;
|
|
75
110
|
normalizeStyleObject(cur);
|
|
111
|
+
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
112
|
+
console.log(" \xBB getSplitStyles push", cur, state);
|
|
113
|
+
}
|
|
76
114
|
if (isWeb && !state.noClassNames) {
|
|
77
115
|
const atomic = getStylesAtomic(cur);
|
|
78
116
|
for (const atomicStyle of atomic) {
|
|
79
117
|
if (!state.noClassNames) {
|
|
118
|
+
addStyle(atomicStyle.identifier, atomicStyle.rules[0]);
|
|
80
119
|
mergeClassName(atomicStyle.property, atomicStyle.identifier);
|
|
81
|
-
insertStyleRule(atomicStyle.identifier, atomicStyle.rules[0]);
|
|
82
120
|
} else {
|
|
83
121
|
style[atomicStyle.property] = atomicStyle.value;
|
|
84
122
|
}
|
|
@@ -86,6 +124,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
86
124
|
}
|
|
87
125
|
if (!isWeb || state.noClassNames || state.resolveVariablesAs === "value" || state.resolveVariablesAs === "both") {
|
|
88
126
|
for (const key in cur) {
|
|
127
|
+
if (skipProps[key]) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
89
130
|
if (key in stylePropsTransform) {
|
|
90
131
|
mergeTransform(style, key, cur[key]);
|
|
91
132
|
} else {
|
|
@@ -97,27 +138,37 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
97
138
|
}
|
|
98
139
|
__name(push, "push");
|
|
99
140
|
for (const keyInit in props) {
|
|
141
|
+
if (skipProps[keyInit]) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (!isWeb && keyInit.startsWith("data-")) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
100
147
|
const valInit = props[keyInit];
|
|
101
|
-
if (
|
|
102
|
-
|
|
148
|
+
if (keyInit === "style" || keyInit.startsWith("_style")) {
|
|
149
|
+
push();
|
|
150
|
+
cur = valInit;
|
|
151
|
+
push();
|
|
103
152
|
continue;
|
|
104
153
|
}
|
|
105
154
|
if (keyInit === "className" || validStyleProps[keyInit] && valInit && valInit[0] === "_") {
|
|
106
155
|
push();
|
|
107
156
|
mergeClassName(keyInit, valInit);
|
|
108
|
-
if (cur) {
|
|
109
|
-
if (cur[keyInit])
|
|
110
|
-
console.warn("just want to see how used");
|
|
111
|
-
delete cur[keyInit];
|
|
112
|
-
}
|
|
113
157
|
continue;
|
|
114
158
|
}
|
|
159
|
+
if (state.keepVariantsAsProps && staticConfig.defaultVariants && keyInit in staticConfig.defaultVariants) {
|
|
160
|
+
viewProps[keyInit] = valInit;
|
|
161
|
+
}
|
|
115
162
|
let isMedia = keyInit[0] === "$";
|
|
116
163
|
let isPseudo = validPseudoKeys[keyInit];
|
|
164
|
+
if (!isMedia && !isPseudo && !((_a = staticConfig.variants) == null ? void 0 : _a[keyInit]) && !validStyleProps[keyInit] && !conf.shorthands[keyInit]) {
|
|
165
|
+
viewProps[keyInit] = valInit;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
117
168
|
const out = isMedia || isPseudo ? true : staticConfig.propMapper(keyInit, valInit, theme, state.fallbackProps || props, state.resolveVariablesAs);
|
|
118
169
|
const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out);
|
|
119
170
|
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
120
|
-
console.log("
|
|
171
|
+
console.log(" \xBB getSplitStyles", keyInit, expanded);
|
|
121
172
|
}
|
|
122
173
|
for (const [key, val] of expanded) {
|
|
123
174
|
if (val === void 0) {
|
|
@@ -143,26 +194,30 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
143
194
|
if (isWeb && !state.noClassNames) {
|
|
144
195
|
const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] });
|
|
145
196
|
for (const style2 of pseudoStyles) {
|
|
197
|
+
addStyle(style2.identifier, style2.rules[0]);
|
|
146
198
|
mergeClassName(`${style2.property}-${key}`, style2.identifier);
|
|
147
|
-
insertStyleRule(style2.identifier, style2.rules[0]);
|
|
148
199
|
}
|
|
149
200
|
}
|
|
150
201
|
continue;
|
|
151
202
|
}
|
|
152
203
|
if (isMedia) {
|
|
153
204
|
const mediaKey = key;
|
|
154
|
-
|
|
205
|
+
const mediaKeyShort = mediaKey.slice(1);
|
|
206
|
+
if (!mediaQueryConfig[mediaKeyShort]) {
|
|
155
207
|
viewProps[key] = val;
|
|
156
208
|
continue;
|
|
157
209
|
}
|
|
158
|
-
const mediaStyle = getSubStyle(val, staticConfig, theme, props, state
|
|
210
|
+
const mediaStyle = getSubStyle(val, staticConfig, theme, props, state);
|
|
211
|
+
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
212
|
+
console.log(" \xBB getSplitStyles mediaStyle", mediaKey, mediaStyle, props);
|
|
213
|
+
}
|
|
159
214
|
const shouldDoClasses = isWeb && !state.noClassNames;
|
|
160
215
|
if (shouldDoClasses) {
|
|
161
216
|
const mediaStyles = getStylesAtomic(mediaStyle);
|
|
162
217
|
for (const style2 of mediaStyles) {
|
|
163
|
-
const out2 = createMediaStyle(style2,
|
|
218
|
+
const out2 = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
|
|
219
|
+
addStyle(out2.identifier, out2.styleRule);
|
|
164
220
|
mergeClassName(`${out2.identifier}-${mediaKey}`, out2.identifier);
|
|
165
|
-
insertStyleRule(out2.identifier, out2.styleRule);
|
|
166
221
|
}
|
|
167
222
|
} else {
|
|
168
223
|
if (mediaState[mediaKey]) {
|
|
@@ -175,11 +230,6 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
175
230
|
}
|
|
176
231
|
continue;
|
|
177
232
|
}
|
|
178
|
-
if (key === "style" || key.startsWith("_style")) {
|
|
179
|
-
push();
|
|
180
|
-
Object.assign(style, val);
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
233
|
if (!isWeb && key === "pointerEvents") {
|
|
184
234
|
viewProps[key] = val;
|
|
185
235
|
continue;
|
|
@@ -190,7 +240,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
190
240
|
continue;
|
|
191
241
|
}
|
|
192
242
|
if (!staticConfig.variants || !(key in staticConfig.variants)) {
|
|
193
|
-
if (key
|
|
243
|
+
if (!skipProps[key]) {
|
|
194
244
|
push();
|
|
195
245
|
viewProps[key] = val;
|
|
196
246
|
}
|
|
@@ -202,24 +252,44 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
202
252
|
for (const namespace in transforms) {
|
|
203
253
|
const [hash, val] = transforms[namespace];
|
|
204
254
|
const identifier = `_transform${hash}`;
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
255
|
+
if (isClient) {
|
|
256
|
+
if (!insertedTransforms[identifier]) {
|
|
257
|
+
const rule = `.${identifier} { transform: ${val}; }`;
|
|
258
|
+
addStyle(identifier, rule);
|
|
259
|
+
}
|
|
208
260
|
}
|
|
209
261
|
classNames[namespace] = identifier;
|
|
210
262
|
}
|
|
211
263
|
}
|
|
212
264
|
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
213
|
-
console.log("out", { style, pseudos, medias, classNames, viewProps });
|
|
265
|
+
console.log(" \xBB getSplitStyles out", { style, pseudos, medias, classNames, viewProps, state });
|
|
214
266
|
}
|
|
215
267
|
return {
|
|
216
268
|
viewProps,
|
|
217
269
|
style,
|
|
218
270
|
medias,
|
|
219
271
|
pseudos,
|
|
220
|
-
classNames
|
|
272
|
+
classNames,
|
|
273
|
+
rulesToInsert
|
|
221
274
|
};
|
|
222
275
|
}, "getSplitStyles");
|
|
276
|
+
const insertSplitStyles = /* @__PURE__ */ __name((...args) => {
|
|
277
|
+
const res = getSplitStyles(...args);
|
|
278
|
+
for (const [prop, rule] of res.rulesToInsert) {
|
|
279
|
+
insertStyleRule(prop, rule);
|
|
280
|
+
}
|
|
281
|
+
return res;
|
|
282
|
+
}, "insertSplitStyles");
|
|
283
|
+
const effect = useInsertionEffect || useIsomorphicLayoutEffect;
|
|
284
|
+
const useSplitStyles = /* @__PURE__ */ __name((...args) => {
|
|
285
|
+
const res = getSplitStyles(...args);
|
|
286
|
+
effect(() => {
|
|
287
|
+
for (const [prop, rule] of res.rulesToInsert) {
|
|
288
|
+
insertStyleRule(prop, rule);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return res;
|
|
292
|
+
}, "useSplitStyles");
|
|
223
293
|
const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, state, avoidDefaultProps) => {
|
|
224
294
|
const styleOut = {};
|
|
225
295
|
for (const key in styleIn) {
|
|
@@ -237,7 +307,16 @@ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props,
|
|
|
237
307
|
normalizeStyleObject(styleOut);
|
|
238
308
|
return styleOut;
|
|
239
309
|
}, "getSubStyle");
|
|
310
|
+
function normalizeStyleObject(style) {
|
|
311
|
+
if (!isWeb) {
|
|
312
|
+
fixNativeShadow(style);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
__name(normalizeStyleObject, "normalizeStyleObject");
|
|
240
316
|
export {
|
|
241
317
|
getSplitStyles,
|
|
242
|
-
getSubStyle
|
|
318
|
+
getSubStyle,
|
|
319
|
+
insertSplitStyles,
|
|
320
|
+
normalizeStyleObject,
|
|
321
|
+
useSplitStyles
|
|
243
322
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
mergeTransform,
|
|
6
6
|
stylePropsTransform
|
|
7
7
|
} from "@tamagui/helpers";
|
|
8
|
+
import { getConfig } from "../conf";
|
|
8
9
|
import { rnw } from "../constants/rnw";
|
|
9
10
|
import { isVariable } from "../createVariable";
|
|
10
11
|
function getStylesAtomic(stylesIn, options = {}) {
|
|
@@ -33,6 +34,7 @@ __name(getStylesAtomic, "getStylesAtomic");
|
|
|
33
34
|
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
34
35
|
return rnw.atomic(rnw.createCompileableStyle(rnw.createReactDOMStyle(style)));
|
|
35
36
|
}, "generateAtomicStyles");
|
|
37
|
+
let reversedShorthands = null;
|
|
36
38
|
function getAtomicStyle(style, pseudo, options) {
|
|
37
39
|
var _a;
|
|
38
40
|
if (style == null || typeof style !== "object") {
|
|
@@ -56,16 +58,26 @@ function getAtomicStyle(style, pseudo, options) {
|
|
|
56
58
|
...out[key],
|
|
57
59
|
transformProperty
|
|
58
60
|
};
|
|
59
|
-
console.log("got", JSON.stringify({ t, tKey, out, key, atomicStyles }, null, 2));
|
|
60
61
|
}
|
|
61
62
|
} else {
|
|
62
63
|
atomicStyles = generateAtomicStyles(style);
|
|
63
64
|
}
|
|
65
|
+
if (!reversedShorthands) {
|
|
66
|
+
reversedShorthands = {};
|
|
67
|
+
const conf = getConfig();
|
|
68
|
+
if (conf.shorthands) {
|
|
69
|
+
for (const key in conf.shorthands) {
|
|
70
|
+
reversedShorthands[conf.shorthands[key]] = key;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
64
74
|
return Object.keys(atomicStyles).map((key) => {
|
|
65
75
|
const val = atomicStyles[key];
|
|
66
|
-
const [_,
|
|
76
|
+
const [_, a, b] = val.identifier.split("-");
|
|
77
|
+
const hash = b || a;
|
|
67
78
|
const psuedoPrefix = pseudo ? `0${pseudo.name}-` : "";
|
|
68
|
-
const
|
|
79
|
+
const shortProp = reversedShorthands[val.property] || val.property;
|
|
80
|
+
const identifier = `_${shortProp}-${psuedoPrefix}${hash}`;
|
|
69
81
|
const className = `.${identifier}`;
|
|
70
82
|
const rules = val.rules.map((rule) => {
|
|
71
83
|
if (pseudo) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getVariableValue } from "../createVariable";
|
|
4
|
+
const getTextSize = /* @__PURE__ */ __name((val = "$4", { fonts, theme, props }) => {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
const family = getVariableValue(props.fontFamily) || "$body";
|
|
7
|
+
const font = fonts[family] || fonts["$body"];
|
|
8
|
+
if (!font) {
|
|
9
|
+
console.warn("\u26A0\uFE0F no font found", { family, fontTokens: Object.keys(fonts), val });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const fontFamily = font.family;
|
|
13
|
+
const fontSize = props.fontSize || font.size[val];
|
|
14
|
+
const lineHeight = props.lineHeight || font.lineHeight[val];
|
|
15
|
+
const fontWeight = props.fontWeight || font.weight[val];
|
|
16
|
+
const letterSpacing = props.letterSpacing || font.letterSpacing[val];
|
|
17
|
+
const fontStyle = props.fontStyle || ((_a = font.style) == null ? void 0 : _a[val]);
|
|
18
|
+
const textTransform = props.textTransform || ((_b = font.transform) == null ? void 0 : _b[val]);
|
|
19
|
+
const color = props.color || ((_c = font.color) == null ? void 0 : _c[val]) || theme.color;
|
|
20
|
+
return {
|
|
21
|
+
color,
|
|
22
|
+
fontStyle,
|
|
23
|
+
textTransform,
|
|
24
|
+
fontFamily,
|
|
25
|
+
fontWeight,
|
|
26
|
+
letterSpacing,
|
|
27
|
+
fontSize,
|
|
28
|
+
lineHeight
|
|
29
|
+
};
|
|
30
|
+
}, "getTextSize");
|
|
31
|
+
export {
|
|
32
|
+
getTextSize
|
|
33
|
+
};
|