@tamagui/core 1.0.0-alpha.38 → 1.0.0-alpha.41
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/conf.js +52 -0
- package/dist/cjs/conf.js.map +7 -0
- package/dist/cjs/constants/constants.js +55 -0
- package/dist/cjs/constants/constants.js.map +7 -0
- package/dist/cjs/constants/platform.js +44 -0
- package/dist/cjs/constants/platform.js.map +7 -0
- package/dist/cjs/constants/pseudos.js +42 -0
- package/dist/cjs/constants/pseudos.js.map +7 -0
- package/dist/cjs/constants/rnw.js +45 -0
- package/dist/cjs/constants/rnw.js.map +7 -0
- package/dist/cjs/createComponent.js +539 -0
- package/dist/cjs/createComponent.js.map +7 -0
- package/dist/cjs/createFont.js +51 -0
- package/dist/cjs/createFont.js.map +7 -0
- package/dist/cjs/createShorthands.js +33 -0
- package/dist/cjs/createShorthands.js.map +7 -0
- package/dist/cjs/createTamagui.js +205 -0
- package/dist/cjs/createTamagui.js.map +7 -0
- package/dist/cjs/createTheme.js +30 -0
- package/dist/cjs/createTheme.js.map +7 -0
- package/dist/cjs/createTokens.js +56 -0
- package/dist/cjs/createTokens.js.map +7 -0
- package/dist/cjs/createVariable.js +48 -0
- package/dist/cjs/createVariable.js.map +7 -0
- package/dist/cjs/getThemeParentClassName.js +34 -0
- package/dist/cjs/getThemeParentClassName.js.map +7 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js +80 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +57 -0
- package/dist/cjs/helpers/createMediaStyle.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +198 -0
- package/dist/cjs/helpers/createPropMapper.js.map +7 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +80 -0
- package/dist/cjs/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/cjs/helpers/extendStaticConfig.js +83 -0
- package/dist/cjs/helpers/extendStaticConfig.js.map +7 -0
- package/dist/cjs/helpers/fixNativeShadow.js +31 -0
- package/dist/cjs/helpers/fixNativeShadow.js.map +7 -0
- package/dist/cjs/helpers/fixNativeShadow.native.js +57 -0
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +181 -0
- package/dist/cjs/helpers/getSplitStyles.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.js +118 -0
- package/dist/cjs/helpers/getStylesAtomic.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.native.js +33 -0
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/cjs/helpers/getThemeParentClassName.js +34 -0
- package/dist/cjs/helpers/getThemeParentClassName.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +47 -0
- package/dist/cjs/helpers/insertStyleRule.js.map +7 -0
- package/dist/cjs/helpers/isObj.js +30 -0
- package/dist/cjs/helpers/isObj.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +34 -0
- package/dist/cjs/helpers/isTamaguiElement.js.map +7 -0
- package/dist/cjs/helpers/matchMedia.js +41 -0
- package/dist/cjs/helpers/matchMedia.js.map +7 -0
- package/dist/cjs/helpers/matchMedia.native.js +37 -0
- package/dist/cjs/helpers/matchMedia.native.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +84 -0
- package/dist/cjs/helpers/themeable.js.map +7 -0
- package/dist/cjs/helpers/validate.js +88 -0
- package/dist/cjs/helpers/validate.js.map +7 -0
- package/dist/cjs/hooks/useConstant.js +38 -0
- package/dist/cjs/hooks/useConstant.js.map +7 -0
- package/dist/cjs/hooks/useFeatures.js +106 -0
- package/dist/cjs/hooks/useFeatures.js.map +7 -0
- package/dist/cjs/hooks/useMedia.js +208 -0
- package/dist/cjs/hooks/useMedia.js.map +7 -0
- package/dist/cjs/hooks/usePressable.js +51 -0
- package/dist/cjs/hooks/usePressable.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +119 -0
- package/dist/cjs/hooks/useTheme.js.map +7 -0
- package/dist/cjs/index.js +64 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/static/postProcessStyles.js +41 -0
- package/dist/cjs/static/postProcessStyles.js.map +7 -0
- package/dist/cjs/static.js +35 -0
- package/dist/cjs/static.js.map +7 -0
- package/dist/cjs/styled.js +73 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/cjs/types.js +21 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/views/Animated.js +135 -0
- package/dist/cjs/views/Animated.js.map +7 -0
- package/dist/cjs/views/Stack.js +52 -0
- package/dist/cjs/views/Stack.js.map +7 -0
- package/dist/cjs/views/Text.js +94 -0
- package/dist/cjs/views/Text.js.map +7 -0
- package/dist/cjs/views/TextAncestorContext.js +46 -0
- package/dist/cjs/views/TextAncestorContext.js.map +7 -0
- package/dist/cjs/views/Theme.js +97 -0
- package/dist/cjs/views/Theme.js.map +7 -0
- package/dist/cjs/views/ThemeContext.js +30 -0
- package/dist/cjs/views/ThemeContext.js.map +7 -0
- package/dist/cjs/views/ThemeInverse.js +54 -0
- package/dist/cjs/views/ThemeInverse.js.map +7 -0
- package/dist/cjs/views/ThemeManagerContext.js +85 -0
- package/dist/cjs/views/ThemeManagerContext.js.map +7 -0
- package/dist/cjs/views/ThemeProvider.js +73 -0
- package/dist/cjs/views/ThemeProvider.js.map +7 -0
- package/dist/esm/conf.js +29 -0
- package/dist/esm/conf.js.map +7 -0
- package/dist/esm/constants/constants.js +18 -0
- package/dist/esm/constants/constants.js.map +7 -0
- package/dist/{constants → esm/constants}/platform.js +3 -2
- package/dist/esm/constants/platform.js.map +7 -0
- package/dist/esm/constants/pseudos.js +18 -0
- package/dist/esm/constants/pseudos.js.map +7 -0
- package/dist/esm/constants/rnw.js +22 -0
- package/dist/esm/constants/rnw.js.map +7 -0
- package/dist/esm/createComponent.js +469 -0
- package/dist/esm/createComponent.js.map +7 -0
- package/dist/esm/createFont.js +28 -0
- package/dist/esm/createFont.js.map +7 -0
- package/dist/{createShorthands.js → esm/createShorthands.js} +0 -0
- package/dist/esm/createShorthands.js.map +7 -0
- package/dist/esm/createTamagui.js +166 -0
- package/dist/esm/createTamagui.js.map +7 -0
- package/dist/esm/createTheme.js +7 -0
- package/dist/esm/createTheme.js.map +7 -0
- package/dist/{createTokens.js → esm/createTokens.js} +4 -0
- package/dist/esm/createTokens.js.map +7 -0
- package/dist/{createVariable.js → esm/createVariable.js} +6 -2
- package/dist/esm/createVariable.js.map +7 -0
- package/dist/esm/getThemeParentClassName.js +11 -0
- package/dist/esm/getThemeParentClassName.js.map +7 -0
- package/dist/esm/helpers/addStylesUsingClassname.js +57 -0
- package/dist/esm/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/{helpers → esm/helpers}/createMediaStyle.js +0 -0
- package/dist/{helpers → esm/helpers}/createMediaStyle.js.map +1 -1
- package/dist/esm/helpers/createPropMapper.js +162 -0
- package/dist/esm/helpers/createPropMapper.js.map +7 -0
- package/dist/{helpers → esm/helpers}/createTamaguiProvider.js +2 -20
- package/dist/esm/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +60 -0
- package/dist/esm/helpers/extendStaticConfig.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.js +8 -0
- package/dist/esm/helpers/fixNativeShadow.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.native.js +34 -0
- package/dist/esm/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/{helpers → esm/helpers}/getSplitStyles.js +43 -40
- package/dist/esm/helpers/getSplitStyles.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +84 -0
- package/dist/esm/helpers/getStylesAtomic.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.native.js +10 -0
- package/dist/esm/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/esm/helpers/getThemeParentClassName.js +11 -0
- package/dist/esm/helpers/getThemeParentClassName.js.map +7 -0
- package/dist/{helpers → esm/helpers}/insertStyleRule.js +7 -0
- package/dist/esm/helpers/insertStyleRule.js.map +7 -0
- package/dist/esm/helpers/isObj.js +7 -0
- package/dist/esm/helpers/isObj.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +11 -0
- package/dist/esm/helpers/isTamaguiElement.js.map +7 -0
- package/dist/{helpers → esm/helpers}/matchMedia.js +3 -0
- package/dist/esm/helpers/matchMedia.js.map +7 -0
- package/dist/{helpers → esm/helpers}/matchMedia.native.js +1 -0
- package/dist/{helpers → esm/helpers}/matchMedia.native.js.map +3 -3
- package/dist/{helpers → esm/helpers}/themeable.js +1 -1
- package/dist/{helpers → esm/helpers}/themeable.js.map +3 -3
- package/dist/esm/helpers/validate.js +60 -0
- package/dist/esm/helpers/validate.js.map +7 -0
- package/dist/{hooks → esm/hooks}/useConstant.js +0 -0
- package/dist/{hooks → esm/hooks}/useConstant.js.map +1 -1
- package/dist/{hooks → esm/hooks}/useFeatures.js +39 -51
- package/dist/esm/hooks/useFeatures.js.map +7 -0
- package/dist/{hooks → esm/hooks}/useMedia.js +21 -19
- package/dist/esm/hooks/useMedia.js.map +7 -0
- package/dist/{hooks → esm/hooks}/usePressable.js +2 -1
- package/dist/{hooks → esm/hooks}/usePressable.js.map +2 -2
- package/dist/{hooks → esm/hooks}/useTheme.js +30 -27
- package/dist/esm/hooks/useTheme.js.map +7 -0
- package/dist/{index.js → esm/index.js} +22 -5
- package/dist/esm/index.js.map +7 -0
- package/dist/{static → esm/static}/postProcessStyles.js +3 -3
- package/dist/esm/static/postProcessStyles.js.map +7 -0
- package/dist/{static.js → esm/static.js} +6 -1
- package/dist/esm/static.js.map +7 -0
- package/dist/esm/styled.js +21 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/{types.js → esm/types.js} +0 -0
- package/dist/{types.js.map → esm/types.js.map} +0 -0
- package/dist/{views → esm/views}/Animated.js +0 -0
- package/dist/{views → esm/views}/Animated.js.map +3 -3
- package/dist/{views → esm/views}/Stack.js +1 -1
- package/dist/esm/views/Stack.js.map +7 -0
- package/dist/esm/views/Text.js +60 -0
- package/dist/esm/views/Text.js.map +7 -0
- package/dist/esm/views/TextAncestorContext.js +18 -0
- package/dist/esm/views/TextAncestorContext.js.map +7 -0
- package/dist/{views → esm/views}/Theme.js +30 -24
- package/dist/esm/views/Theme.js.map +7 -0
- package/dist/{views → esm/views}/ThemeContext.js +0 -0
- package/dist/{views → esm/views}/ThemeContext.js.map +1 -1
- package/dist/{views → esm/views}/ThemeInverse.js +0 -1
- package/dist/{views → esm/views}/ThemeInverse.js.map +3 -3
- package/dist/{views → esm/views}/ThemeManagerContext.js +15 -8
- package/dist/esm/views/ThemeManagerContext.js.map +7 -0
- package/dist/{views → esm/views}/ThemeProvider.js +13 -13
- package/dist/esm/views/ThemeProvider.js.map +7 -0
- package/dist/jsx/conf.js +28 -0
- package/dist/jsx/constants/constants.js +17 -0
- package/dist/jsx/constants/platform.js +19 -0
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/constants/rnw.js +21 -0
- package/dist/jsx/createComponent.js +463 -0
- package/dist/jsx/createFont.js +27 -0
- package/dist/jsx/createShorthands.js +9 -0
- package/dist/jsx/createTamagui.js +165 -0
- package/dist/jsx/createTheme.js +6 -0
- package/dist/jsx/createTokens.js +32 -0
- package/dist/jsx/createVariable.js +24 -0
- package/dist/jsx/getThemeParentClassName.js +10 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +56 -0
- package/dist/jsx/helpers/createMediaStyle.js +33 -0
- package/dist/jsx/helpers/createPropMapper.js +161 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +19 -0
- package/dist/jsx/helpers/extendStaticConfig.js +59 -0
- package/dist/jsx/helpers/fixNativeShadow.js +7 -0
- package/dist/jsx/helpers/fixNativeShadow.native.js +33 -0
- package/dist/jsx/helpers/getSplitStyles.js +149 -0
- package/dist/jsx/helpers/getStylesAtomic.js +83 -0
- package/dist/jsx/helpers/getStylesAtomic.native.js +9 -0
- package/dist/jsx/helpers/getThemeParentClassName.js +10 -0
- package/dist/jsx/helpers/insertStyleRule.js +23 -0
- package/dist/jsx/helpers/isObj.js +6 -0
- package/dist/jsx/helpers/isTamaguiElement.js +10 -0
- package/dist/jsx/helpers/matchMedia.js +17 -0
- package/dist/jsx/helpers/matchMedia.native.js +8 -0
- package/dist/jsx/helpers/themeable.js +23 -0
- package/dist/jsx/helpers/validate.js +59 -0
- package/dist/jsx/hooks/useConstant.js +14 -0
- package/dist/jsx/hooks/useFeatures.js +57 -0
- package/dist/jsx/hooks/useMedia.js +174 -0
- package/dist/jsx/hooks/usePressable.js +13 -0
- package/dist/jsx/hooks/useTheme.js +96 -0
- package/dist/jsx/index.js +46 -0
- package/dist/jsx/static/postProcessStyles.js +17 -0
- package/dist/jsx/static.js +14 -0
- package/dist/jsx/styled.js +20 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Animated.js +74 -0
- package/dist/jsx/views/Stack.js +11 -0
- package/dist/jsx/views/Text.js +59 -0
- package/dist/jsx/views/TextAncestorContext.js +15 -0
- package/dist/jsx/views/Theme.js +63 -0
- package/dist/jsx/views/ThemeContext.js +5 -0
- package/dist/jsx/views/ThemeInverse.js +22 -0
- package/dist/jsx/views/ThemeManagerContext.js +61 -0
- package/dist/jsx/views/ThemeProvider.js +39 -0
- package/package.json +6 -6
- package/types/conf.d.ts +45 -0
- package/types/conf.d.ts.map +1 -0
- package/types/constants/constants.d.ts +2 -0
- package/types/constants/constants.d.ts.map +1 -0
- package/types/constants/platform.d.ts.map +1 -0
- package/types/constants/pseudos.d.ts.map +1 -0
- package/types/constants/rnw.d.ts.map +1 -0
- package/types/createComponent.d.ts.map +1 -0
- package/types/createFont.d.ts.map +1 -0
- package/types/createShorthands.d.ts.map +1 -0
- package/types/createTamagui.d.ts +2 -43
- package/types/createTamagui.d.ts.map +1 -0
- package/types/createTheme.d.ts.map +1 -0
- package/types/createTokens.d.ts.map +1 -0
- package/types/createVariable.d.ts.map +1 -0
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/types/helpers/extendStaticConfig.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/types/helpers/getThemeParentClassName.d.ts +2 -0
- package/types/helpers/getThemeParentClassName.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -0
- package/types/helpers/isObj.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -0
- package/types/helpers/matchMedia.d.ts.map +1 -0
- package/types/helpers/matchMedia.native.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts.map +1 -0
- package/types/helpers/validate.d.ts.map +1 -0
- package/types/hooks/useConstant.d.ts.map +1 -0
- package/types/hooks/useFeatures.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts.map +1 -0
- package/types/hooks/usePressable.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/static/postProcessStyles.d.ts.map +1 -0
- package/types/static.d.ts.map +1 -0
- package/types/styled.d.ts +1 -1
- package/types/styled.d.ts.map +1 -0
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -0
- package/types/views/Animated.d.ts.map +1 -0
- package/types/views/Stack.d.ts.map +1 -0
- package/types/views/Text.d.ts.map +1 -0
- package/types/views/TextAncestorContext.d.ts.map +1 -0
- package/types/views/Theme.d.ts.map +1 -0
- package/types/views/ThemeContext.d.ts.map +1 -0
- package/types/views/ThemeInverse.d.ts.map +1 -0
- package/types/views/ThemeManagerContext.d.ts.map +1 -0
- package/types/views/ThemeProvider.d.ts +0 -1
- package/types/views/ThemeProvider.d.ts.map +1 -0
- package/dist/constants/constants.js +0 -32
- package/dist/constants/constants.js.map +0 -7
- package/dist/constants/platform.js.map +0 -7
- package/dist/constants/rnw.js +0 -10
- package/dist/constants/rnw.js.map +0 -7
- package/dist/constants/styleConstants.js +0 -59
- package/dist/constants/styleConstants.js.map +0 -7
- package/dist/createComponent.js +0 -395
- package/dist/createComponent.js.map +0 -7
- package/dist/createShorthands.js.map +0 -7
- package/dist/createTamagui.js +0 -107
- package/dist/createTamagui.js.map +0 -7
- package/dist/createTokens.js.map +0 -7
- package/dist/createVariable.js.map +0 -7
- package/dist/helpers/addStylesUsingClassname.js +0 -28
- package/dist/helpers/addStylesUsingClassname.js.map +0 -7
- package/dist/helpers/createTamaguiProvider.js.map +0 -7
- package/dist/helpers/extendStaticConfig.js +0 -158
- package/dist/helpers/extendStaticConfig.js.map +0 -7
- package/dist/helpers/fixNativeShadow.js +0 -38
- package/dist/helpers/fixNativeShadow.js.map +0 -7
- package/dist/helpers/getSplitStyles.js.map +0 -7
- package/dist/helpers/insertStyleRule.js.map +0 -7
- package/dist/helpers/matchMedia.js.map +0 -7
- package/dist/helpers/setIfChanged.js +0 -17
- package/dist/helpers/setIfChanged.js.map +0 -7
- package/dist/hooks/useFeatures.js.map +0 -7
- package/dist/hooks/useForceUpdate.js +0 -28
- package/dist/hooks/useForceUpdate.js.map +0 -7
- package/dist/hooks/useMedia.js.map +0 -7
- package/dist/hooks/useTheme.js.map +0 -7
- package/dist/index.cjs +0 -1837
- package/dist/index.cjs.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/static/postProcessStyles.js.map +0 -7
- package/dist/static.js.map +0 -7
- package/dist/styled.js +0 -28
- package/dist/styled.js.map +0 -7
- package/dist/testtypes.js +0 -1
- package/dist/testtypes.js.map +0 -7
- package/dist/views/Stack.js.map +0 -7
- package/dist/views/Text.js +0 -36
- package/dist/views/Text.js.map +0 -7
- package/dist/views/TextAncestorContext.js +0 -18
- package/dist/views/TextAncestorContext.js.map +0 -7
- package/dist/views/Theme.js.map +0 -7
- package/dist/views/ThemeManagerContext.js.map +0 -7
- package/dist/views/ThemeProvider.js.map +0 -7
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import ow from "@tamagui/ow";
|
|
4
|
+
const validateConfig = /* @__PURE__ */ __name((conf) => {
|
|
5
|
+
if (!conf) {
|
|
6
|
+
console.warn("no conf?");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
ow(conf, validConfig);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.log("Given config:\n", JSON.stringify(conf, null, 2));
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
}, "validateConfig");
|
|
16
|
+
const validConfig = ow.object.exactShape({
|
|
17
|
+
defaultTheme: ow.optional.string,
|
|
18
|
+
disableRootThemeClass: ow.optional.boolean,
|
|
19
|
+
shorthands: ow.optional.object.valuesOfType(ow.string),
|
|
20
|
+
themes: ow.object.valuesOfType(ow.object),
|
|
21
|
+
tokens: ow.object.valuesOfType(ow.object),
|
|
22
|
+
media: ow.object.valuesOfType(ow.object)
|
|
23
|
+
});
|
|
24
|
+
const validFont = ow.object.exactShape({
|
|
25
|
+
family: ow.string,
|
|
26
|
+
size: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
27
|
+
lineHeight: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
28
|
+
weight: ow.object.nonEmpty.valuesOfType(ow.string),
|
|
29
|
+
letterSpacing: ow.object.nonEmpty.valuesOfType(ow.number)
|
|
30
|
+
});
|
|
31
|
+
const validTokens = ow.object.exactShape({
|
|
32
|
+
font: ow.object.valuesOfType(validFont),
|
|
33
|
+
size: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
34
|
+
space: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
35
|
+
zIndex: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
36
|
+
radius: ow.object.nonEmpty.valuesOfType(ow.number),
|
|
37
|
+
color: ow.object.nonEmpty.valuesOfType(ow.string)
|
|
38
|
+
});
|
|
39
|
+
const validateTokens = /* @__PURE__ */ __name((tokens) => {
|
|
40
|
+
try {
|
|
41
|
+
ow(tokens, validTokens);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.log("Given tokens:\n", JSON.stringify(tokens, null, 2));
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}, "validateTokens");
|
|
47
|
+
const validateFont = /* @__PURE__ */ __name((font) => {
|
|
48
|
+
try {
|
|
49
|
+
ow(font, validFont);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log("Given font:\n", JSON.stringify(font, null, 2));
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}, "validateFont");
|
|
55
|
+
export {
|
|
56
|
+
validateConfig,
|
|
57
|
+
validateFont,
|
|
58
|
+
validateTokens
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/validate.ts"],
|
|
4
|
+
"sourcesContent": ["// published a patched version that works on native\nimport ow from '@tamagui/ow'\n\nexport const validateConfig = (conf: any) => {\n if (!conf) {\n console.warn('no conf?')\n return\n }\n try {\n ow(conf, validConfig)\n } catch (err: any) {\n console.log('Given config:\\n', JSON.stringify(conf, null, 2))\n throw err\n }\n}\n\nconst validConfig = ow.object.exactShape({\n defaultTheme: ow.optional.string,\n disableRootThemeClass: ow.optional.boolean,\n shorthands: ow.optional.object.valuesOfType(ow.string),\n themes: ow.object.valuesOfType(ow.object),\n tokens: ow.object.valuesOfType(ow.object),\n media: ow.object.valuesOfType(ow.object),\n})\n\nconst validFont = ow.object.exactShape({\n family: ow.string,\n size: ow.object.nonEmpty.valuesOfType(ow.number),\n lineHeight: ow.object.nonEmpty.valuesOfType(ow.number),\n weight: ow.object.nonEmpty.valuesOfType(ow.string),\n letterSpacing: ow.object.nonEmpty.valuesOfType(ow.number),\n})\n\nconst validTokens = ow.object.exactShape({\n font: ow.object.valuesOfType(validFont),\n size: ow.object.nonEmpty.valuesOfType(ow.number),\n space: ow.object.nonEmpty.valuesOfType(ow.number),\n zIndex: ow.object.nonEmpty.valuesOfType(ow.number),\n radius: ow.object.nonEmpty.valuesOfType(ow.number),\n color: ow.object.nonEmpty.valuesOfType(ow.string),\n})\n\nexport const validateTokens = (tokens: any) => {\n try {\n ow(tokens, validTokens)\n } catch (err: any) {\n console.log('Given tokens:\\n', JSON.stringify(tokens, null, 2))\n throw err\n }\n}\n\nexport const validateFont = (font: any) => {\n try {\n ow(font, validFont)\n } catch (err: any) {\n console.log('Given font:\\n', JSON.stringify(font, null, 2))\n throw err\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AACA;AAEO,MAAM,iBAAiB,wBAAC,SAAc;AAC3C,MAAI,CAAC,MAAM;AACT,YAAQ,KAAK;AACb;AAAA;AAEF,MAAI;AACF,OAAG,MAAM;AAAA,WACF,KAAP;AACA,YAAQ,IAAI,mBAAmB,KAAK,UAAU,MAAM,MAAM;AAC1D,UAAM;AAAA;AAAA,GAToB;AAa9B,MAAM,cAAc,GAAG,OAAO,WAAW;AAAA,EACvC,cAAc,GAAG,SAAS;AAAA,EAC1B,uBAAuB,GAAG,SAAS;AAAA,EACnC,YAAY,GAAG,SAAS,OAAO,aAAa,GAAG;AAAA,EAC/C,QAAQ,GAAG,OAAO,aAAa,GAAG;AAAA,EAClC,QAAQ,GAAG,OAAO,aAAa,GAAG;AAAA,EAClC,OAAO,GAAG,OAAO,aAAa,GAAG;AAAA;AAGnC,MAAM,YAAY,GAAG,OAAO,WAAW;AAAA,EACrC,QAAQ,GAAG;AAAA,EACX,MAAM,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EACzC,YAAY,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EAC/C,QAAQ,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EAC3C,eAAe,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA;AAGpD,MAAM,cAAc,GAAG,OAAO,WAAW;AAAA,EACvC,MAAM,GAAG,OAAO,aAAa;AAAA,EAC7B,MAAM,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EACzC,OAAO,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EAC1C,QAAQ,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EAC3C,QAAQ,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA,EAC3C,OAAO,GAAG,OAAO,SAAS,aAAa,GAAG;AAAA;AAGrC,MAAM,iBAAiB,wBAAC,WAAgB;AAC7C,MAAI;AACF,OAAG,QAAQ;AAAA,WACJ,KAAP;AACA,YAAQ,IAAI,mBAAmB,KAAK,UAAU,QAAQ,MAAM;AAC5D,UAAM;AAAA;AAAA,GALoB;AASvB,MAAM,eAAe,wBAAC,SAAc;AACzC,MAAI;AACF,OAAG,MAAM;AAAA,WACF,KAAP;AACA,YAAQ,IAAI,iBAAiB,KAAK,UAAU,MAAM,MAAM;AACxD,UAAM;AAAA;AAAA,GALkB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/hooks/useConstant.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useRef } from 'react'\n\ntype ResultBox<T> = { v: T }\nexport function useConstant<T>(fn: () => T): T {\n const ref = useRef<ResultBox<T>>()\n if (!ref.current) {\n ref.current = { v: fn() }\n }\n return ref.current.v\n}\n"],
|
|
5
5
|
"mappings": ";;AAAA;AAGO,qBAAwB,IAAgB;AAC7C,QAAM,MAAM;AACZ,MAAI,CAAC,IAAI,SAAS;AAChB,QAAI,UAAU,EAAE,GAAG;AAAA;AAErB,SAAO,IAAI,QAAQ;AAAA;AALL;",
|
|
6
6
|
"names": []
|
|
@@ -2,62 +2,21 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
|
-
import { addMediaQueryListener, removeMediaQueryListener } from "./useMedia";
|
|
6
|
-
const createDefinition = /* @__PURE__ */ __name(({
|
|
5
|
+
import { addMediaQueryListener, mediaState, removeMediaQueryListener } from "./useMedia";
|
|
6
|
+
const createDefinition = /* @__PURE__ */ __name(({
|
|
7
|
+
Component,
|
|
8
|
+
propNames
|
|
9
|
+
}) => ({
|
|
7
10
|
isEnabled: (props) => propNames.some((name) => !!props[name]),
|
|
8
11
|
Component
|
|
9
12
|
}), "createDefinition");
|
|
10
|
-
|
|
11
|
-
"$xs",
|
|
12
|
-
"$sm",
|
|
13
|
-
"$md",
|
|
14
|
-
"$lg",
|
|
15
|
-
"$xl",
|
|
16
|
-
"$xxl",
|
|
17
|
-
"$pointerCoarse",
|
|
18
|
-
"$hoverNone",
|
|
19
|
-
"$tall",
|
|
20
|
-
"$short",
|
|
21
|
-
"$gtSm",
|
|
22
|
-
"$notXs",
|
|
23
|
-
"$gtMd",
|
|
24
|
-
"$gtLg"
|
|
25
|
-
];
|
|
26
|
-
const featureDefinitions = {
|
|
27
|
-
measureLayout: createDefinition({
|
|
28
|
-
Component: (props) => {
|
|
29
|
-
console.log("measure", props);
|
|
30
|
-
return null;
|
|
31
|
-
},
|
|
32
|
-
propNames: ["onLayout"]
|
|
33
|
-
}),
|
|
34
|
-
mediaQuery: createDefinition({
|
|
35
|
-
Component: (props) => {
|
|
36
|
-
if (isWeb) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const keys = mediaQueryPropNames.flatMap((x) => x in props ? x.slice(1) : []);
|
|
40
|
-
useIsomorphicLayoutEffect(() => {
|
|
41
|
-
for (const key of keys) {
|
|
42
|
-
addMediaQueryListener(key, props._utils.forceUpdate);
|
|
43
|
-
}
|
|
44
|
-
return () => {
|
|
45
|
-
for (const key of keys) {
|
|
46
|
-
removeMediaQueryListener(key, props._utils.forceUpdate);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}, [keys.join(",")]);
|
|
50
|
-
return null;
|
|
51
|
-
},
|
|
52
|
-
propNames: mediaQueryPropNames
|
|
53
|
-
})
|
|
54
|
-
};
|
|
55
|
-
const featureNames = Object.keys(featureDefinitions);
|
|
56
|
-
const numFeatures = featureNames.length;
|
|
13
|
+
let featureDefinitions = null;
|
|
57
14
|
const useFeatures = /* @__PURE__ */ __name((props, utils) => {
|
|
15
|
+
if (!featureDefinitions) {
|
|
16
|
+
featureDefinitions = loadFeatures();
|
|
17
|
+
}
|
|
58
18
|
const features = [];
|
|
59
|
-
for (
|
|
60
|
-
const name = featureNames[i];
|
|
19
|
+
for (const name in featureDefinitions) {
|
|
61
20
|
const { isEnabled, Component } = featureDefinitions[name];
|
|
62
21
|
if (isEnabled(props) && Component) {
|
|
63
22
|
features.push(/* @__PURE__ */ React.createElement(Component, {
|
|
@@ -69,6 +28,35 @@ const useFeatures = /* @__PURE__ */ __name((props, utils) => {
|
|
|
69
28
|
}
|
|
70
29
|
return features;
|
|
71
30
|
}, "useFeatures");
|
|
31
|
+
function loadFeatures() {
|
|
32
|
+
return {
|
|
33
|
+
...!isWeb && {
|
|
34
|
+
mediaQuery: loadMediaQueryFeature()
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
__name(loadFeatures, "loadFeatures");
|
|
39
|
+
function loadMediaQueryFeature() {
|
|
40
|
+
const mediaPropNames = Object.keys(mediaState);
|
|
41
|
+
return createDefinition({
|
|
42
|
+
Component: (props) => {
|
|
43
|
+
const keys = mediaPropNames.flatMap((x) => x in props ? x.slice(1) : []);
|
|
44
|
+
useIsomorphicLayoutEffect(() => {
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
addMediaQueryListener(key, props._utils.forceUpdate);
|
|
47
|
+
}
|
|
48
|
+
return () => {
|
|
49
|
+
for (const key of keys) {
|
|
50
|
+
removeMediaQueryListener(key, props._utils.forceUpdate);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, [keys.join(",")]);
|
|
54
|
+
return null;
|
|
55
|
+
},
|
|
56
|
+
propNames: mediaPropNames
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
__name(loadMediaQueryFeature, "loadMediaQueryFeature");
|
|
72
60
|
export {
|
|
73
61
|
useFeatures
|
|
74
62
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useFeatures.tsx"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { addMediaQueryListener, mediaState, removeMediaQueryListener } from './useMedia'\n\ntype FeatureDefinition = {\n isEnabled: (props: any) => boolean\n Component: any\n}\n\nconst createDefinition = ({\n Component,\n propNames,\n}: {\n Component: any\n propNames: string[]\n}): FeatureDefinition => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nlet featureDefinitions: Record<string, FeatureDefinition> | null = null\n\nexport const useFeatures = (props: any, utils?: { forceUpdate?: Function }) => {\n if (!featureDefinitions) {\n featureDefinitions = loadFeatures()\n }\n const features: JSX.Element[] = []\n for (const name in featureDefinitions) {\n const { isEnabled, Component } = featureDefinitions[name]\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n\nfunction loadFeatures(): Record<string, FeatureDefinition> {\n return {\n // TODO\n // measureLayout: createDefinition({\n // Component: (props) => {\n // console.log('measure', props)\n // return null\n // },\n // propNames: ['onLayout'],\n // }),\n\n // will update the parent whenever media query changes\n // no need on web, media queries are inserted and run in css\n ...(!isWeb && {\n mediaQuery: loadMediaQueryFeature(),\n }),\n }\n}\n\nfunction loadMediaQueryFeature() {\n const mediaPropNames = Object.keys(mediaState)\n\n return createDefinition({\n Component: (props: any) => {\n const keys = mediaPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\n\n useIsomorphicLayoutEffect(() => {\n for (const key of keys) {\n addMediaQueryListener(key, props._utils.forceUpdate)\n }\n return () => {\n for (const key of keys) {\n removeMediaQueryListener(key, props._utils.forceUpdate)\n }\n }\n }, [keys.join(',')])\n\n return null\n },\n propNames: mediaPropNames,\n })\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AAOA,MAAM,mBAAmB,wBAAC;AAAA,EACxB;AAAA,EACA;AAAA,MAIwB;AAAA,EACxB,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM;AAAA,EAC5D;AAAA,IARuB;AAWzB,IAAI,qBAA+D;AAE5D,MAAM,cAAc,wBAAC,OAAY,UAAuC;AAC7E,MAAI,CAAC,oBAAoB;AACvB,yBAAqB;AAAA;AAEvB,QAAM,WAA0B;AAChC,aAAW,QAAQ,oBAAoB;AACrC,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,UAAU,WAAW;AACjC,eAAS,KAAK,oCAAC,WAAD;AAAA,QAAW,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA;AAAA;AAAA;AAG3D,SAAO;AAAA,GAXkB;AAc3B,wBAA2D;AACzD,SAAO;AAAA,OAYD,CAAC,SAAS;AAAA,MACZ,YAAY;AAAA;AAAA;AAAA;AAdT;AAmBT,iCAAiC;AAC/B,QAAM,iBAAiB,OAAO,KAAK;AAEnC,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,UAAe;AACzB,YAAM,OAAO,eAAe,QAAQ,CAAC,MAAO,KAAK,QAAQ,EAAE,MAAM,KAAK;AAEtE,gCAA0B,MAAM;AAC9B,mBAAW,OAAO,MAAM;AACtB,gCAAsB,KAAK,MAAM,OAAO;AAAA;AAE1C,eAAO,MAAM;AACX,qBAAW,OAAO,MAAM;AACtB,qCAAyB,KAAK,MAAM,OAAO;AAAA;AAAA;AAAA,SAG9C,CAAC,KAAK,KAAK;AAEd,aAAO;AAAA;AAAA,IAET,WAAW;AAAA;AAAA;AApBN;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
3
4
|
import { useRef } from "react";
|
|
4
5
|
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
6
|
import { matchMedia } from "../helpers/matchMedia";
|
|
6
7
|
import { useConstant } from "./useConstant";
|
|
7
|
-
import { useForceUpdate } from "./useForceUpdate";
|
|
8
8
|
const mediaState = {};
|
|
9
9
|
const mediaQueryListeners = {};
|
|
10
10
|
const addMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
11
|
-
mediaQueryListeners[key] = mediaQueryListeners[key] || new Set();
|
|
11
|
+
mediaQueryListeners[key] = mediaQueryListeners[key] || /* @__PURE__ */ new Set();
|
|
12
12
|
mediaQueryListeners[key].add(cb);
|
|
13
13
|
}, "addMediaQueryListener");
|
|
14
14
|
const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
15
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
16
17
|
}, "removeMediaQueryListener");
|
|
17
|
-
let
|
|
18
|
-
let mediaQueryConfigObject = null;
|
|
18
|
+
let conf = null;
|
|
19
19
|
const mediaQueryConfig = new Proxy({}, {
|
|
20
20
|
get(target, key) {
|
|
21
|
-
if (!
|
|
22
|
-
|
|
21
|
+
if (!conf) {
|
|
22
|
+
console.warn("Tamagui warning: accessing media query before init");
|
|
23
|
+
return null;
|
|
23
24
|
}
|
|
24
|
-
return Reflect.get(
|
|
25
|
+
return Reflect.get(conf, key);
|
|
25
26
|
},
|
|
26
27
|
ownKeys() {
|
|
27
|
-
if (!
|
|
28
|
-
|
|
28
|
+
if (!conf) {
|
|
29
|
+
console.warn("Tamagui warning: accessing media query before init");
|
|
30
|
+
return [];
|
|
29
31
|
}
|
|
30
|
-
return Object.keys(
|
|
32
|
+
return Object.keys(conf);
|
|
31
33
|
},
|
|
32
34
|
getOwnPropertyDescriptor() {
|
|
33
35
|
return {
|
|
@@ -37,7 +39,7 @@ const mediaQueryConfig = new Proxy({}, {
|
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
const getMedia = /* @__PURE__ */ __name(() => {
|
|
40
|
-
if (!
|
|
42
|
+
if (!conf) {
|
|
41
43
|
throw new Error(`not configured yet`);
|
|
42
44
|
}
|
|
43
45
|
return mediaState;
|
|
@@ -46,13 +48,13 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
46
48
|
queries,
|
|
47
49
|
defaultActive = ["sm", "xs"]
|
|
48
50
|
} = {}) => {
|
|
49
|
-
|
|
51
|
+
var _a;
|
|
52
|
+
if (conf) {
|
|
50
53
|
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
51
|
-
return;
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (queries) {
|
|
56
|
+
conf = queries;
|
|
57
|
+
}
|
|
56
58
|
for (const key in queries) {
|
|
57
59
|
const str = mediaObjectToString(queries[key]);
|
|
58
60
|
try {
|
|
@@ -68,7 +70,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
68
70
|
return;
|
|
69
71
|
mediaState[key] = next;
|
|
70
72
|
const listeners = mediaQueryListeners[key];
|
|
71
|
-
if (listeners
|
|
73
|
+
if (listeners == null ? void 0 : listeners.size) {
|
|
72
74
|
for (const cb of [...listeners]) {
|
|
73
75
|
cb();
|
|
74
76
|
}
|
|
@@ -76,7 +78,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
76
78
|
});
|
|
77
79
|
} catch (err) {
|
|
78
80
|
console.error("Error running media query", str, err.message, err.stack);
|
|
79
|
-
const isDefaultActive = defaultActive
|
|
81
|
+
const isDefaultActive = (_a = defaultActive == null ? void 0 : defaultActive.includes(key)) != null ? _a : true;
|
|
80
82
|
mediaState[key] = isDefaultActive;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport const addMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport const removeMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nlet conf: MediaQueries | null = null\n\nexport const mediaQueryConfig = new Proxy<MediaQueries>({} as any, {\n get(target, key) {\n if (!conf) {\n console.warn('Tamagui warning: accessing media query before init')\n return null\n }\n return Reflect.get(conf, key)\n },\n ownKeys() {\n if (!conf) {\n console.warn('Tamagui warning: accessing media query before init')\n return []\n }\n return Object.keys(conf)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n})\n\nexport const getMedia = () => {\n if (!conf) {\n throw new Error(`not configured yet`)\n }\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (conf) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n }\n\n if (queries) {\n conf = queries\n }\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[key] = !!match.matches\n match.addListener(() => {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n })\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[key] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport const useMedia = () => {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(mediaState, {\n get(target, key: string) {\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n })\n })\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a, _b;
|
|
3
4
|
import { Pressable } from "react-native";
|
|
4
|
-
const getPressable = Pressable
|
|
5
|
+
const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
|
|
5
6
|
const usePressable = /* @__PURE__ */ __name((props) => {
|
|
6
7
|
const out = getPressable(props);
|
|
7
8
|
const { children, style, ...pressableProps } = out.props;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/hooks/usePressable.tsx"],
|
|
4
4
|
"sourcesContent": ["import { Pressable, PressableProps } from 'react-native'\n\nconst getPressable = Pressable?.['type']?.['render']\n\nexport const usePressable = (props: PressableProps) => {\n const out = getPressable(props)\n const { children, style, ...pressableProps } = out.props\n return [pressableProps, style] as const\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAEA,MAAM,eAAe,
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAEA,MAAM,eAAe,6CAAY,YAAZ,mBAAsB;AAEpC,MAAM,eAAe,wBAAC,UAA0B;AACrD,QAAM,MAAM,aAAa;AACzB,QAAM,EAAE,UAAU,UAAU,mBAAmB,IAAI;AACnD,SAAO,CAAC,gBAAgB;AAAA,GAHE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import {
|
|
3
|
+
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
4
|
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { GET_DEFAULT_THEME } from "../constants/constants";
|
|
5
6
|
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
7
|
+
import { Variable } from "../createVariable";
|
|
6
8
|
import { ThemeContext } from "../views/ThemeContext";
|
|
7
9
|
import { ThemeManagerContext } from "../views/ThemeManagerContext";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const areEqualSets = /* @__PURE__ */ __name((a, b) => {
|
|
11
|
+
if (a.size !== b.size)
|
|
12
|
+
return false;
|
|
13
|
+
for (const val in a) {
|
|
14
|
+
if (!b.has(val)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}, "areEqualSets");
|
|
20
|
+
const useThemeName = /* @__PURE__ */ __name((opts) => {
|
|
11
21
|
const parent = useContext(ThemeManagerContext);
|
|
12
22
|
const [name, setName] = useState(parent.name);
|
|
13
|
-
|
|
14
|
-
return parent.onChangeTheme((next) => {
|
|
15
|
-
setName((
|
|
16
|
-
if (prev === next)
|
|
17
|
-
return prev;
|
|
18
|
-
return next;
|
|
19
|
-
});
|
|
23
|
+
useIsomorphicLayoutEffect(() => {
|
|
24
|
+
return parent.onChangeTheme((next, manager) => {
|
|
25
|
+
setName((opts == null ? void 0 : opts.parent) ? manager.parentName : next);
|
|
20
26
|
});
|
|
21
27
|
}, [parent]);
|
|
22
28
|
return name || "light";
|
|
@@ -25,6 +31,7 @@ const useDefaultThemeName = /* @__PURE__ */ __name(() => {
|
|
|
25
31
|
return useContext(ThemeContext)[GET_DEFAULT_THEME];
|
|
26
32
|
}, "useDefaultThemeName");
|
|
27
33
|
const useTheme = /* @__PURE__ */ __name(() => {
|
|
34
|
+
var _a;
|
|
28
35
|
const forceUpdate = useForceUpdate();
|
|
29
36
|
const manager = useContext(ThemeManagerContext);
|
|
30
37
|
const themes = useContext(ThemeContext);
|
|
@@ -32,7 +39,7 @@ const useTheme = /* @__PURE__ */ __name(() => {
|
|
|
32
39
|
if (!state.current) {
|
|
33
40
|
state.current = {
|
|
34
41
|
uuid: {},
|
|
35
|
-
keys: new Set(),
|
|
42
|
+
keys: /* @__PURE__ */ new Set(),
|
|
36
43
|
isRendering: true
|
|
37
44
|
};
|
|
38
45
|
}
|
|
@@ -40,14 +47,15 @@ const useTheme = /* @__PURE__ */ __name(() => {
|
|
|
40
47
|
useIsomorphicLayoutEffect(() => {
|
|
41
48
|
const st = state.current;
|
|
42
49
|
st.isRendering = false;
|
|
43
|
-
|
|
50
|
+
const cur = manager.keys.get(st.uuid);
|
|
51
|
+
if (!cur || !areEqualSets(st.keys, cur)) {
|
|
44
52
|
manager.track(st.uuid, st.keys);
|
|
45
53
|
}
|
|
46
54
|
});
|
|
47
55
|
useEffect(() => {
|
|
48
56
|
return manager.onUpdate(state.current.uuid, forceUpdate);
|
|
49
57
|
}, []);
|
|
50
|
-
const theme = (manager.name ? themes[manager.name] : themes.light)
|
|
58
|
+
const theme = (_a = manager.name ? themes[manager.name] : themes.light) != null ? _a : themes.light;
|
|
51
59
|
return useMemo(() => {
|
|
52
60
|
return new Proxy(theme, {
|
|
53
61
|
get(_, key) {
|
|
@@ -63,20 +71,15 @@ const useTheme = /* @__PURE__ */ __name(() => {
|
|
|
63
71
|
const val = activeTheme[key];
|
|
64
72
|
if (process.env.NODE_ENV === "development") {
|
|
65
73
|
if (typeof val === "undefined") {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.error(err.message, err.stack);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
74
|
+
console.warn(`No theme value "${String(key)}" in`, activeTheme, themes);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (!(val instanceof Variable)) {
|
|
78
|
+
console.warn("Non variable!", val);
|
|
79
|
+
}
|
|
80
|
+
if (val.name !== key) {
|
|
81
|
+
console.warn("Non-matching name for variable to key", key, val.name);
|
|
78
82
|
}
|
|
79
|
-
return Reflect.get(_, key);
|
|
80
83
|
}
|
|
81
84
|
if (state.current.isRendering) {
|
|
82
85
|
state.current.keys.add(key);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { GET_DEFAULT_THEME } from '../constants/constants'\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { Variable } from '../createVariable'\nimport { ThemeName, ThemeObject } from '../types'\nimport { ThemeContext } from '../views/ThemeContext'\nimport { ThemeManagerContext } from '../views/ThemeManagerContext'\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nconst areEqualSets = (a: Set<string>, b: Set<string>) => {\n if (a.size !== b.size) return false\n for (const val in a) {\n if (!b.has(val)) {\n return false\n }\n }\n return true\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent.name)\n\n useIsomorphicLayoutEffect(() => {\n return parent.onChangeTheme((next, manager) => {\n setName(opts?.parent ? manager.parentName : next)\n })\n }, [parent])\n\n return name || 'light'\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)[GET_DEFAULT_THEME] as any as ThemeName\n}\n\nexport const useTheme = (): ThemeObject => {\n const forceUpdate = useForceUpdate()\n const manager = useContext(ThemeManagerContext)\n const themes = useContext(ThemeContext)\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = manager.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n manager.track(st.uuid, st.keys)\n }\n })\n\n useEffect(() => {\n return manager.onUpdate(state.current.uuid, forceUpdate)\n }, [])\n\n const theme = (manager.name ? themes[manager.name] : themes.light) ?? themes.light\n\n return useMemo(\n () => {\n return new Proxy(theme, {\n get(_, key: string) {\n const name = manager.name\n if (!name) {\n return Reflect.get(_, key)\n }\n let activeTheme = themes[name]\n if (!activeTheme) {\n console.error('No theme by name', name, 'only:', themes, 'keeping current theme')\n activeTheme = theme\n }\n const val = activeTheme[key]\n if (process.env.NODE_ENV === 'development') {\n if (typeof val === 'undefined') {\n console.warn(`No theme value \"${String(key)}\" in`, activeTheme, themes)\n return null\n }\n if (!(val instanceof Variable)) {\n console.warn('Non variable!', val)\n }\n if (val.name !== key) {\n console.warn('Non-matching name for variable to key', key, val.name)\n }\n }\n if (state.current.isRendering) {\n state.current.keys.add(key)\n }\n return val\n },\n })\n },\n [\n /* if concurrent mode wanted put manager.name here */\n ]\n )\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAQA,MAAM,eAAe,wBAAC,GAAgB,MAAmB;AACvD,MAAI,EAAE,SAAS,EAAE;AAAM,WAAO;AAC9B,aAAW,OAAO,GAAG;AACnB,QAAI,CAAC,EAAE,IAAI,MAAM;AACf,aAAO;AAAA;AAAA;AAGX,SAAO;AAAA,GAPY;AAUd,MAAM,eAAe,wBAAC,SAA6B;AACxD,QAAM,SAAS,WAAW;AAC1B,QAAM,CAAC,MAAM,WAAW,SAAS,OAAO;AAExC,4BAA0B,MAAM;AAC9B,WAAO,OAAO,cAAc,CAAC,MAAM,YAAY;AAC7C,cAAQ,8BAAM,UAAS,QAAQ,aAAa;AAAA;AAAA,KAE7C,CAAC;AAEJ,SAAO,QAAQ;AAAA,GAVW;AAarB,MAAM,sBAAsB,6BAAM;AACvC,SAAO,WAAW,cAAc;AAAA,GADC;AAI5B,MAAM,WAAW,6BAAmB;AA3C3C;AA4CE,QAAM,cAAc;AACpB,QAAM,UAAU,WAAW;AAC3B,QAAM,SAAS,WAAW;AAC1B,QAAM,QAAQ;AACd,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM;AAAA,MACN,MAAM,oBAAI;AAAA,MACV,aAAa;AAAA;AAAA;AAGjB,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,QAAQ,KAAK,IAAI,GAAG;AAChC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,MAAM;AACvC,cAAQ,MAAM,GAAG,MAAM,GAAG;AAAA;AAAA;AAI9B,YAAU,MAAM;AACd,WAAO,QAAQ,SAAS,MAAM,QAAQ,MAAM;AAAA,KAC3C;AAEH,QAAM,QAAS,cAAQ,OAAO,OAAO,QAAQ,QAAQ,OAAO,UAA7C,YAAuD,OAAO;AAE7E,SAAO,QACL,MAAM;AACJ,WAAO,IAAI,MAAM,OAAO;AAAA,MACtB,IAAI,GAAG,KAAa;AAClB,cAAM,OAAO,QAAQ;AACrB,YAAI,CAAC,MAAM;AACT,iBAAO,QAAQ,IAAI,GAAG;AAAA;AAExB,YAAI,cAAc,OAAO;AACzB,YAAI,CAAC,aAAa;AAChB,kBAAQ,MAAM,oBAAoB,MAAM,SAAS,QAAQ;AACzD,wBAAc;AAAA;AAEhB,cAAM,MAAM,YAAY;AACxB,YAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAI,OAAO,QAAQ,aAAa;AAC9B,oBAAQ,KAAK,mBAAmB,OAAO,YAAY,aAAa;AAChE,mBAAO;AAAA;AAET,cAAI,CAAE,gBAAe,WAAW;AAC9B,oBAAQ,KAAK,iBAAiB;AAAA;AAEhC,cAAI,IAAI,SAAS,KAAK;AACpB,oBAAQ,KAAK,yCAAyC,KAAK,IAAI;AAAA;AAAA;AAGnE,YAAI,MAAM,QAAQ,aAAa;AAC7B,gBAAM,QAAQ,KAAK,IAAI;AAAA;AAEzB,eAAO;AAAA;AAAA;AAAA,KAIb;AAAA,GA/DoB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
export * from "./createComponent";
|
|
2
2
|
export * from "./createShorthands";
|
|
3
|
+
export * from "./createTheme";
|
|
3
4
|
export * from "./createTamagui";
|
|
5
|
+
export * from "./createFont";
|
|
4
6
|
import { createTokens } from "./createTokens";
|
|
5
7
|
export * from "./createVariable";
|
|
6
8
|
export * from "./styled";
|
|
7
9
|
export * from "./types";
|
|
10
|
+
import {
|
|
11
|
+
getHasConfigured,
|
|
12
|
+
getTamagui,
|
|
13
|
+
getThemes,
|
|
14
|
+
getTokens,
|
|
15
|
+
onConfiguredOnce,
|
|
16
|
+
ConfigListener
|
|
17
|
+
} from "./conf";
|
|
18
|
+
export * from "./constants/pseudos";
|
|
8
19
|
export * from "./constants/constants";
|
|
9
20
|
export * from "./constants/platform";
|
|
10
21
|
export * from "./constants/rnw";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./helpers/
|
|
22
|
+
export * from "./helpers/getThemeParentClassName";
|
|
23
|
+
export * from "./helpers/isObj";
|
|
24
|
+
export * from "./helpers/getStylesAtomic";
|
|
13
25
|
export * from "./helpers/matchMedia";
|
|
14
|
-
export * from "./helpers/setIfChanged";
|
|
15
26
|
export * from "./helpers/themeable";
|
|
27
|
+
export * from "./helpers/isTamaguiElement";
|
|
16
28
|
export * from "./hooks/useConstant";
|
|
17
|
-
export * from "./hooks/useForceUpdate";
|
|
18
29
|
export * from "./hooks/useMedia";
|
|
19
30
|
export * from "./hooks/useTheme";
|
|
20
31
|
export * from "./views/Animated";
|
|
@@ -25,6 +36,12 @@ export * from "./views/ThemeInverse";
|
|
|
25
36
|
export * from "./views/ThemeProvider";
|
|
26
37
|
export * from "./views/TextAncestorContext";
|
|
27
38
|
export {
|
|
28
|
-
|
|
39
|
+
ConfigListener,
|
|
40
|
+
createTokens,
|
|
41
|
+
getHasConfigured,
|
|
42
|
+
getTamagui,
|
|
43
|
+
getThemes,
|
|
44
|
+
getTokens,
|
|
45
|
+
onConfiguredOnce
|
|
29
46
|
};
|
|
30
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport { createTokens } from './createTokens'\nexport * from './createVariable'\nexport * from './styled'\nexport * from './types'\nexport {\n getHasConfigured,\n getTamagui,\n getThemes,\n getTokens,\n onConfiguredOnce,\n ConfigListener,\n} from './conf'\n\nexport * from './constants/pseudos'\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport * from './constants/rnw'\n\nexport * from './helpers/getThemeParentClassName'\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/matchMedia'\nexport * from './helpers/themeable'\nexport * from './helpers/isTamaguiElement'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './views/Animated'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/TextAncestorContext'\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { getSplitStyles } from "../helpers/getSplitStyles";
|
|
4
|
-
const postProcessStyles = /* @__PURE__ */ __name((inStyles, staticConfig,
|
|
5
|
-
const { style, viewProps,
|
|
4
|
+
const postProcessStyles = /* @__PURE__ */ __name((inStyles, staticConfig, theme) => {
|
|
5
|
+
const { style, viewProps, pseudos, classNames } = getSplitStyles(inStyles, staticConfig, theme);
|
|
6
6
|
const next = {};
|
|
7
7
|
for (const s of style) {
|
|
8
8
|
if (!s)
|
|
9
9
|
continue;
|
|
10
10
|
Object.assign(next, s);
|
|
11
11
|
}
|
|
12
|
-
Object.assign(next,
|
|
12
|
+
Object.assign(next, pseudos);
|
|
13
13
|
return { style: next, viewProps, classNames };
|
|
14
14
|
}, "postProcessStyles");
|
|
15
15
|
export {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/static/postProcessStyles.tsx"],
|
|
4
|
+
"sourcesContent": ["import { getSplitStyles } from '../helpers/getSplitStyles'\nimport { StaticConfigParsed, TamaguiInternalConfig, ThemeObject } from '../types'\n\n// used only by static extractor\n\nexport const postProcessStyles = (\n inStyles: any,\n staticConfig: StaticConfigParsed,\n theme: ThemeObject\n) => {\n const { style, viewProps, pseudos, classNames } = getSplitStyles(inStyles, staticConfig, theme)\n // flattening\n const next = {}\n for (const s of style) {\n if (!s) continue\n Object.assign(next, s)\n }\n Object.assign(next, pseudos)\n return { style: next, viewProps, classNames }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAKO,MAAM,oBAAoB,wBAC/B,UACA,cACA,UACG;AACH,QAAM,EAAE,OAAO,WAAW,SAAS,eAAe,eAAe,UAAU,cAAc;AAEzF,QAAM,OAAO;AACb,aAAW,KAAK,OAAO;AACrB,QAAI,CAAC;AAAG;AACR,WAAO,OAAO,MAAM;AAAA;AAEtB,SAAO,OAAO,MAAM;AACpB,SAAO,EAAE,OAAO,MAAM,WAAW;AAAA,GAbF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./styled";
|
|
2
2
|
export * from "./createComponent";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./createFont";
|
|
4
|
+
export * from "./createTokens";
|
|
5
|
+
export * from "./createTamagui";
|
|
4
6
|
export * from "./constants/constants";
|
|
5
7
|
export * from "./hooks/useMedia";
|
|
6
8
|
export * from "./hooks/useTheme";
|
|
9
|
+
export * from "./helpers/isObj";
|
|
10
|
+
export * from "./helpers/getStylesAtomic";
|
|
7
11
|
export * from "./helpers/getSplitStyles";
|
|
8
12
|
export * from "@tamagui/helpers";
|
|
13
|
+
export * from "./constants/pseudos";
|
|
9
14
|
export * from "./static/postProcessStyles";
|
|
10
15
|
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/static.ts"],
|
|
4
|
+
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\n\nexport * from './styled'\nexport * from './createComponent'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createTamagui'\nexport * from './constants/constants'\n\nexport * from './hooks/useMedia'\nexport * from './hooks/useTheme'\n\nexport * from './helpers/isObj'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/getSplitStyles'\nexport * from '@tamagui/helpers'\n\nexport * from './constants/pseudos'\n\n// -- below exports are only bundled compile-time --\n\nexport * from './static/postProcessStyles'\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAIA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createComponent } from "./createComponent";
|
|
4
|
+
import { extendStaticConfig } from "./helpers/extendStaticConfig";
|
|
5
|
+
function styled(Component, options, staticExtractionOptions) {
|
|
6
|
+
const staticConfigProps = (() => {
|
|
7
|
+
if (options) {
|
|
8
|
+
const { variants, ...defaultProps } = options;
|
|
9
|
+
return { ...staticExtractionOptions, variants, defaultProps };
|
|
10
|
+
}
|
|
11
|
+
return {};
|
|
12
|
+
})();
|
|
13
|
+
const config = extendStaticConfig(Component, staticConfigProps);
|
|
14
|
+
const component = createComponent(config);
|
|
15
|
+
return component;
|
|
16
|
+
}
|
|
17
|
+
__name(styled, "styled");
|
|
18
|
+
export {
|
|
19
|
+
styled
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/styled.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { MediaProps, StaticComponent, StaticConfig, TamaguiConfig, Themes, Tokens } from './types'\n\nexport function styled<\n ParentComponent extends StaticComponent | React.Component<any>,\n Variants extends GetVariants<ParentComponent>\n>(\n Component: ParentComponent,\n options?: GetProps<ParentComponent> & {\n variants?: Variants\n },\n staticExtractionOptions?: StaticConfig\n) {\n const staticConfigProps: StaticConfig = (() => {\n if (options) {\n const { variants, ...defaultProps } = options\n return { ...staticExtractionOptions, variants, defaultProps }\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\n type VariantProps = GetVariantProps<Variants>\n return component as StaticComponent<\n // if not options/variants passed just styled(Text):\n keyof VariantProps extends never\n ? GetProps<ParentComponent>\n : // if options passed: styled(Text, { ... })\n Omit<GetProps<ParentComponent>, keyof VariantProps> &\n VariantProps &\n MediaProps<VariantProps>,\n void\n >\n}\n\n// type ParentVariants = A extends StaticComponent<any, infer Variants> ? Variants : {}\n\nexport type GetProps<A> = A extends StaticComponent<infer Props>\n ? Props\n : A extends React.Component<infer Props>\n ? Props\n : {}\n\nexport type GetVariants<ParentComponent extends StaticComponent | React.Component<any>> = void | {\n [key: string]: {\n [key: string]:\n | Partial<GetProps<ParentComponent>>\n | ((\n val: any,\n config: {\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: GetProps<ParentComponent>\n }\n ) => Partial<GetProps<ParentComponent>>)\n }\n}\n\nexport type GetVariantProps<Variants> = Variants extends void\n ? {}\n : {\n // ensure variants actually defined\n [Key in keyof Variants]?: keyof Variants[Key] extends `...${infer VariantSpread}`\n ? VariantSpread extends keyof Tokens\n ? keyof Tokens[VariantSpread] extends string | number\n ? `$${keyof Tokens[VariantSpread]}` | null\n : unknown\n : unknown\n : keyof Variants[Key] extends 'true'\n ? boolean | null\n : keyof Exclude<Variants[Key], undefined>\n }\n\n// type X = { ok: 1 }\n// type Y = { okk: 2; ok: 3 }\n// type Z = X & Y\n// type Z2 = Z\n\n// TODO get name\n// const displayName = `styled(Component)`\n// Object.defineProperty(component, 'name', {\n// value: displayName,\n// writable: false,\n// })\n"],
|
|
5
|
+
"mappings": ";;AAEA;AACA;AAGO,gBAIL,WACA,SAGA,yBACA;AACA,QAAM,oBAAmC,OAAM;AAC7C,QAAI,SAAS;AACX,YAAM,EAAE,aAAa,iBAAiB;AACtC,aAAO,KAAK,yBAAyB,UAAU;AAAA;AAEjD,WAAO;AAAA;AAET,QAAM,SAAS,mBAAmB,WAAW;AAC7C,QAAM,YAAY,gBAAgB;AAElC,SAAO;AAAA;AApBO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|