@tamagui/core 1.0.0-alpha.0
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/.ultra.cache.json +1 -0
- package/_/constants/constants.js +14 -0
- package/_/constants/constants.js.map +7 -0
- package/_/constants/platform.js +20 -0
- package/_/constants/platform.js.map +7 -0
- package/_/constants/pseudos.js +18 -0
- package/_/constants/pseudos.js.map +7 -0
- package/_/constants/rnw.js +22 -0
- package/_/constants/rnw.js.map +7 -0
- package/_/createComponent.js +427 -0
- package/_/createComponent.js.map +7 -0
- package/_/createShorthands.js +10 -0
- package/_/createShorthands.js.map +7 -0
- package/_/createTamagui.js +122 -0
- package/_/createTamagui.js.map +7 -0
- package/_/createTheme.js +20 -0
- package/_/createTheme.js.map +7 -0
- package/_/createTokens.js +29 -0
- package/_/createTokens.js.map +7 -0
- package/_/createVariable.js +22 -0
- package/_/createVariable.js.map +7 -0
- package/_/helpers/addStylesUsingClassname.js +32 -0
- package/_/helpers/addStylesUsingClassname.js.map +7 -0
- package/_/helpers/createMediaStyle.js +34 -0
- package/_/helpers/createMediaStyle.js.map +7 -0
- package/_/helpers/createTamaguiProvider.js +42 -0
- package/_/helpers/createTamaguiProvider.js.map +7 -0
- package/_/helpers/extendStaticConfig.js +176 -0
- package/_/helpers/extendStaticConfig.js.map +7 -0
- package/_/helpers/fixNativeShadow.js +8 -0
- package/_/helpers/fixNativeShadow.js.map +7 -0
- package/_/helpers/fixNativeShadow.native.js +30 -0
- package/_/helpers/fixNativeShadow.native.js.map +7 -0
- package/_/helpers/getSplitStyles.js +160 -0
- package/_/helpers/getSplitStyles.js.map +7 -0
- package/_/helpers/getStylesAtomic.js +84 -0
- package/_/helpers/getStylesAtomic.js.map +7 -0
- package/_/helpers/getStylesAtomic.native.js +10 -0
- package/_/helpers/getStylesAtomic.native.js.map +7 -0
- package/_/helpers/insertStyleRule.js +24 -0
- package/_/helpers/insertStyleRule.js.map +7 -0
- package/_/helpers/matchMedia.js +15 -0
- package/_/helpers/matchMedia.js.map +7 -0
- package/_/helpers/matchMedia.native.js +8 -0
- package/_/helpers/matchMedia.native.js.map +7 -0
- package/_/helpers/themeable.js +26 -0
- package/_/helpers/themeable.js.map +7 -0
- package/_/hooks/useConstant.js +15 -0
- package/_/hooks/useConstant.js.map +7 -0
- package/_/hooks/useFeatures.js +75 -0
- package/_/hooks/useFeatures.js.map +7 -0
- package/_/hooks/useForceUpdate.js +28 -0
- package/_/hooks/useForceUpdate.js.map +7 -0
- package/_/hooks/useMedia.js +173 -0
- package/_/hooks/useMedia.js.map +7 -0
- package/_/hooks/usePressable.js +14 -0
- package/_/hooks/usePressable.js.map +7 -0
- package/_/hooks/useTheme.js +94 -0
- package/_/hooks/useTheme.js.map +7 -0
- package/_/index.js +30 -0
- package/_/index.js.map +7 -0
- package/_/static/postProcessStyles.js +18 -0
- package/_/static/postProcessStyles.js.map +7 -0
- package/_/static.js +12 -0
- package/_/static.js.map +7 -0
- package/_/styled.js +21 -0
- package/_/styled.js.map +7 -0
- package/_/types.js +1 -0
- package/_/types.js.map +7 -0
- package/_/views/Animated.js +79 -0
- package/_/views/Animated.js.map +7 -0
- package/_/views/Stack.js +12 -0
- package/_/views/Stack.js.map +7 -0
- package/_/views/Text.js +60 -0
- package/_/views/Text.js.map +7 -0
- package/_/views/TextAncestorContext.js +19 -0
- package/_/views/TextAncestorContext.js.map +7 -0
- package/_/views/Theme.js +57 -0
- package/_/views/Theme.js.map +7 -0
- package/_/views/ThemeContext.js +6 -0
- package/_/views/ThemeContext.js.map +7 -0
- package/_/views/ThemeInverse.js +27 -0
- package/_/views/ThemeInverse.js.map +7 -0
- package/_/views/ThemeManagerContext.js +56 -0
- package/_/views/ThemeManagerContext.js.map +7 -0
- package/_/views/ThemeProvider.js +45 -0
- package/_/views/ThemeProvider.js.map +7 -0
- package/dist/constants/constants.js +14 -0
- package/dist/constants/constants.js.map +7 -0
- package/dist/constants/platform.js +19 -0
- package/dist/constants/platform.js.map +7 -0
- package/dist/constants/pseudos.js +18 -0
- package/dist/constants/pseudos.js.map +7 -0
- package/dist/constants/rnw.js +22 -0
- package/dist/constants/rnw.js.map +7 -0
- package/dist/constants/styleConstants.js +46 -0
- package/dist/constants/styleConstants.js.map +7 -0
- package/dist/createComponent.js +445 -0
- package/dist/createComponent.js.map +7 -0
- package/dist/createFont.js +24 -0
- package/dist/createFont.js.map +7 -0
- package/dist/createShorthands.js +10 -0
- package/dist/createShorthands.js.map +7 -0
- package/dist/createTamagui.js +159 -0
- package/dist/createTamagui.js.map +7 -0
- package/dist/createTheme.js +20 -0
- package/dist/createTheme.js.map +7 -0
- package/dist/createTokens.js +29 -0
- package/dist/createTokens.js.map +7 -0
- package/dist/createVariable.js +22 -0
- package/dist/createVariable.js.map +7 -0
- package/dist/helpers/addStylesUsingClassname.js +57 -0
- package/dist/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/helpers/createMediaStyle.js +34 -0
- package/dist/helpers/createMediaStyle.js.map +7 -0
- package/dist/helpers/createPropMapper.js +153 -0
- package/dist/helpers/createPropMapper.js.map +7 -0
- package/dist/helpers/createTamaguiProvider.js +25 -0
- package/dist/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/helpers/extendStaticConfig.js +59 -0
- package/dist/helpers/extendStaticConfig.js.map +7 -0
- package/dist/helpers/fixNativeShadow.js +8 -0
- package/dist/helpers/fixNativeShadow.js.map +7 -0
- package/dist/helpers/fixNativeShadow.native.js +30 -0
- package/dist/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/helpers/getSplitStyles.js +160 -0
- package/dist/helpers/getSplitStyles.js.map +7 -0
- package/dist/helpers/getStylesAtomic.js +83 -0
- package/dist/helpers/getStylesAtomic.js.map +7 -0
- package/dist/helpers/getStylesAtomic.native.js +10 -0
- package/dist/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/helpers/insertStyleRule.js +24 -0
- package/dist/helpers/insertStyleRule.js.map +7 -0
- package/dist/helpers/isObj.js +7 -0
- package/dist/helpers/isObj.js.map +7 -0
- package/dist/helpers/matchMedia.js +15 -0
- package/dist/helpers/matchMedia.js.map +7 -0
- package/dist/helpers/matchMedia.native.js +8 -0
- package/dist/helpers/matchMedia.native.js.map +7 -0
- package/dist/helpers/pseudos.js +1 -0
- package/dist/helpers/pseudos.js.map +7 -0
- package/dist/helpers/themeable.js +26 -0
- package/dist/helpers/themeable.js.map +7 -0
- package/dist/hooks/useConstant.js +15 -0
- package/dist/hooks/useConstant.js.map +7 -0
- package/dist/hooks/useFeatures.js +75 -0
- package/dist/hooks/useFeatures.js.map +7 -0
- package/dist/hooks/useForceUpdate.js +28 -0
- package/dist/hooks/useForceUpdate.js.map +7 -0
- package/dist/hooks/useMedia.js +171 -0
- package/dist/hooks/useMedia.js.map +7 -0
- package/dist/hooks/usePressable.js +13 -0
- package/dist/hooks/usePressable.js.map +7 -0
- package/dist/hooks/useTheme.js +93 -0
- package/dist/hooks/useTheme.js.map +7 -0
- package/dist/index.cjs +2125 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +7 -0
- package/dist/packages/core/src/constants/constants.d.ts +8 -0
- package/dist/packages/core/src/constants/constants.d.ts.map +1 -0
- package/dist/packages/core/src/constants/platform.d.ts +9 -0
- package/dist/packages/core/src/constants/platform.d.ts.map +1 -0
- package/dist/packages/core/src/constants/pseudos.d.ts +15 -0
- package/dist/packages/core/src/constants/pseudos.d.ts.map +1 -0
- package/dist/packages/core/src/constants/rnw.d.ts +2 -0
- package/dist/packages/core/src/constants/rnw.d.ts.map +1 -0
- package/dist/packages/core/src/createComponent.d.ts +16 -0
- package/dist/packages/core/src/createComponent.d.ts.map +1 -0
- package/dist/packages/core/src/createShorthands.d.ts +2 -0
- package/dist/packages/core/src/createShorthands.d.ts.map +1 -0
- package/dist/packages/core/src/createTamagui.d.ts +37 -0
- package/dist/packages/core/src/createTamagui.d.ts.map +1 -0
- package/dist/packages/core/src/createTheme.d.ts +5 -0
- package/dist/packages/core/src/createTheme.d.ts.map +1 -0
- package/dist/packages/core/src/createTokens.d.ts +45 -0
- package/dist/packages/core/src/createTokens.d.ts.map +1 -0
- package/dist/packages/core/src/createVariable.d.ts +14 -0
- package/dist/packages/core/src/createVariable.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts +2 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts +8 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts +5 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts +5 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts +15 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts +3 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts +2 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts +2 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts +3 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/themeable.d.ts +10 -0
- package/dist/packages/core/src/helpers/themeable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts +2 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts +5 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts +2 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts +16 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts +3 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts +18 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts.map +1 -0
- package/dist/packages/core/src/index.d.ts +27 -0
- package/dist/packages/core/src/index.d.ts.map +1 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts +7 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts.map +1 -0
- package/dist/packages/core/src/static.d.ts +12 -0
- package/dist/packages/core/src/static.d.ts.map +1 -0
- package/dist/packages/core/src/styled.d.ts +16 -0
- package/dist/packages/core/src/styled.d.ts.map +1 -0
- package/dist/packages/core/src/types.d.ts +305 -0
- package/dist/packages/core/src/types.d.ts.map +1 -0
- package/dist/packages/core/src/views/Animated.d.ts +15 -0
- package/dist/packages/core/src/views/Animated.d.ts.map +1 -0
- package/dist/packages/core/src/views/Stack.d.ts +3 -0
- package/dist/packages/core/src/views/Stack.d.ts.map +1 -0
- package/dist/packages/core/src/views/Text.d.ts +3 -0
- package/dist/packages/core/src/views/Text.d.ts.map +1 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts +3 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/Theme.d.ts +8 -0
- package/dist/packages/core/src/views/Theme.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts +18 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts +15 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts.map +1 -0
- package/dist/packages/helpers/src/AllRules.d.ts +3 -0
- package/dist/packages/helpers/src/AllRules.d.ts.map +1 -0
- package/dist/packages/helpers/src/concatClassName.d.ts +2 -0
- package/dist/packages/helpers/src/concatClassName.d.ts.map +1 -0
- package/dist/packages/helpers/src/index.d.ts +5 -0
- package/dist/packages/helpers/src/index.d.ts.map +1 -0
- package/dist/packages/helpers/src/types.d.ts +8 -0
- package/dist/packages/helpers/src/types.d.ts.map +1 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts +475 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts.map +1 -0
- package/dist/static/postProcessStyles.js +18 -0
- package/dist/static/postProcessStyles.js.map +7 -0
- package/dist/static.js +15 -0
- package/dist/static.js.map +7 -0
- package/dist/styled.js +21 -0
- package/dist/styled.js.map +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/dist/views/Animated.js +79 -0
- package/dist/views/Animated.js.map +7 -0
- package/dist/views/SafeAreaProvider.js +30 -0
- package/dist/views/SafeAreaProvider.js.map +7 -0
- package/dist/views/Stack.js +12 -0
- package/dist/views/Stack.js.map +7 -0
- package/dist/views/Text.js +60 -0
- package/dist/views/Text.js.map +7 -0
- package/dist/views/TextAncestorContext.js +18 -0
- package/dist/views/TextAncestorContext.js.map +7 -0
- package/dist/views/Theme.js +56 -0
- package/dist/views/Theme.js.map +7 -0
- package/dist/views/ThemeContext.js +6 -0
- package/dist/views/ThemeContext.js.map +7 -0
- package/dist/views/ThemeInverse.js +27 -0
- package/dist/views/ThemeInverse.js.map +7 -0
- package/dist/views/ThemeManagerContext.js +55 -0
- package/dist/views/ThemeManagerContext.js.map +7 -0
- package/dist/views/ThemeProvider.js +45 -0
- package/dist/views/ThemeProvider.js.map +7 -0
- package/package.json +33 -0
- package/src/constants/constants.ts +12 -0
- package/src/constants/platform.ts +15 -0
- package/src/constants/pseudos.ts +14 -0
- package/src/constants/rnw.tsx +20 -0
- package/src/createComponent.tsx +596 -0
- package/src/createFont.ts +26 -0
- package/src/createShorthands.ts +5 -0
- package/src/createTamagui.ts +207 -0
- package/src/createTheme.ts +19 -0
- package/src/createTokens.ts +83 -0
- package/src/createVariable.ts +22 -0
- package/src/helpers/addStylesUsingClassname.tsx +60 -0
- package/src/helpers/createMediaStyle.ts +46 -0
- package/src/helpers/createPropMapper.ts +184 -0
- package/src/helpers/createTamaguiProvider.tsx +22 -0
- package/src/helpers/extendStaticConfig.ts +68 -0
- package/src/helpers/fixNativeShadow.native.tsx +27 -0
- package/src/helpers/fixNativeShadow.tsx +2 -0
- package/src/helpers/getSplitStyles.tsx +210 -0
- package/src/helpers/getStylesAtomic.native.ts +3 -0
- package/src/helpers/getStylesAtomic.ts +103 -0
- package/src/helpers/insertStyleRule.tsx +18 -0
- package/src/helpers/isObj.ts +1 -0
- package/src/helpers/matchMedia.native.ts +3 -0
- package/src/helpers/matchMedia.ts +9 -0
- package/src/helpers/themeable.tsx +42 -0
- package/src/hooks/useConstant.tsx +10 -0
- package/src/hooks/useFeatures.tsx +78 -0
- package/src/hooks/useForceUpdate.tsx +26 -0
- package/src/hooks/useMedia.tsx +194 -0
- package/src/hooks/usePressable.tsx +9 -0
- package/src/hooks/useTheme.tsx +107 -0
- package/src/index.ts +33 -0
- package/src/static/postProcessStyles.tsx +20 -0
- package/src/static.ts +22 -0
- package/src/styled.ts +82 -0
- package/src/types.tsx +561 -0
- package/src/views/Animated.tsx +121 -0
- package/src/views/SafeAreaProvider.tsx +33 -0
- package/src/views/Stack.tsx +21 -0
- package/src/views/Text.tsx +66 -0
- package/src/views/TextAncestorContext.tsx +12 -0
- package/src/views/Theme.tsx +73 -0
- package/src/views/ThemeContext.tsx +5 -0
- package/src/views/ThemeInverse.tsx +23 -0
- package/src/views/ThemeManagerContext.tsx +50 -0
- package/src/views/ThemeProvider.tsx +52 -0
- package/tsconfig.json +8 -0
- package/types.d.ts +558 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2125 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
|
+
var __objRest = (source, exclude) => {
|
|
27
|
+
var target = {};
|
|
28
|
+
for (var prop in source)
|
|
29
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
if (source != null && __getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
var __export = (target, all) => {
|
|
39
|
+
__markAsModule(target);
|
|
40
|
+
for (var name in all)
|
|
41
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
42
|
+
};
|
|
43
|
+
var __reExport = (target, module2, desc) => {
|
|
44
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
45
|
+
for (let key of __getOwnPropNames(module2))
|
|
46
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
47
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
48
|
+
}
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
var __toModule = (module2) => {
|
|
52
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/index.ts
|
|
56
|
+
__export(exports, {
|
|
57
|
+
AnimatedStack: () => AnimatedStack,
|
|
58
|
+
GET_DEFAULT_THEME: () => GET_DEFAULT_THEME,
|
|
59
|
+
SafeAreaProvider: () => SafeAreaProvider,
|
|
60
|
+
Spacer: () => Spacer,
|
|
61
|
+
Stack: () => Stack,
|
|
62
|
+
Text: () => Text2,
|
|
63
|
+
TextAncestorContext: () => TextAncestorContext,
|
|
64
|
+
TextAncestorProvider: () => TextAncestorProvider,
|
|
65
|
+
Theme: () => Theme,
|
|
66
|
+
ThemeInverse: () => ThemeInverse,
|
|
67
|
+
ThemeProvider: () => ThemeProvider,
|
|
68
|
+
Variable: () => Variable,
|
|
69
|
+
addMediaQueryListener: () => addMediaQueryListener,
|
|
70
|
+
configureMedia: () => configureMedia,
|
|
71
|
+
createComponent: () => createComponent,
|
|
72
|
+
createFont: () => createFont,
|
|
73
|
+
createShorthands: () => createShorthands,
|
|
74
|
+
createTamagui: () => createTamagui,
|
|
75
|
+
createTheme: () => createTheme,
|
|
76
|
+
createTokens: () => createTokens,
|
|
77
|
+
createVariable: () => createVariable,
|
|
78
|
+
getHasConfigured: () => getHasConfigured,
|
|
79
|
+
getMedia: () => getMedia,
|
|
80
|
+
getStylesAtomic: () => getStylesAtomic,
|
|
81
|
+
getTamaguiConfig: () => getTamaguiConfig,
|
|
82
|
+
getThemeParentClassName: () => getThemeParentClassName,
|
|
83
|
+
isChrome: () => isChrome,
|
|
84
|
+
isObj: () => isObj,
|
|
85
|
+
isSSR: () => isSSR,
|
|
86
|
+
isTouchDevice: () => isTouchDevice,
|
|
87
|
+
isVariable: () => isVariable,
|
|
88
|
+
isWeb: () => isWeb,
|
|
89
|
+
isWebIOS: () => isWebIOS,
|
|
90
|
+
matchMedia: () => matchMedia,
|
|
91
|
+
mediaObjectToString: () => mediaObjectToString,
|
|
92
|
+
mediaQueryConfig: () => mediaQueryConfig,
|
|
93
|
+
mediaState: () => mediaState,
|
|
94
|
+
mouseUps: () => mouseUps,
|
|
95
|
+
onConfiguredOnce: () => onConfiguredOnce,
|
|
96
|
+
pseudos: () => pseudos,
|
|
97
|
+
removeMediaQueryListener: () => removeMediaQueryListener,
|
|
98
|
+
rnw: () => rnw,
|
|
99
|
+
setThemeInversions: () => setThemeInversions,
|
|
100
|
+
spacedChildren: () => spacedChildren,
|
|
101
|
+
stackDefaultStyles: () => stackDefaultStyles,
|
|
102
|
+
styled: () => styled,
|
|
103
|
+
supportsTouchWeb: () => supportsTouchWeb,
|
|
104
|
+
themeable: () => themeable,
|
|
105
|
+
useConstant: () => useConstant,
|
|
106
|
+
useDefaultThemeName: () => useDefaultThemeName,
|
|
107
|
+
useForceUpdate: () => useForceUpdate,
|
|
108
|
+
useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect,
|
|
109
|
+
useMedia: () => useMedia,
|
|
110
|
+
useTheme: () => useTheme,
|
|
111
|
+
useThemeName: () => useThemeName
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// src/createComponent.tsx
|
|
115
|
+
var import_helpers4 = __toModule(require("@tamagui/helpers"));
|
|
116
|
+
var import_react12 = __toModule(require("react"));
|
|
117
|
+
var import_react_native3 = __toModule(require("react-native"));
|
|
118
|
+
|
|
119
|
+
// src/constants/platform.ts
|
|
120
|
+
var import_react = __toModule(require("react"));
|
|
121
|
+
var import_react_native = __toModule(require("react-native"));
|
|
122
|
+
var _a;
|
|
123
|
+
var isWeb = process.env.TAMAGUI_TARGET !== "web" ? false : ((_a = import_react_native.Platform) == null ? void 0 : _a.OS) === "web";
|
|
124
|
+
var isSSR = isWeb && typeof window === "undefined";
|
|
125
|
+
var useIsomorphicLayoutEffect = isSSR ? import_react.useEffect : import_react.useLayoutEffect;
|
|
126
|
+
var isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
127
|
+
var supportsTouchWeb = typeof window !== "undefined" && "ontouchstart" in window;
|
|
128
|
+
var isTouchDevice = !isWeb || supportsTouchWeb;
|
|
129
|
+
var isWebIOS = isWeb && typeof navigator !== "undefined" && (/iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window["MSStream"];
|
|
130
|
+
|
|
131
|
+
// src/constants/constants.ts
|
|
132
|
+
var stackDefaultStyles = __spreadValues({
|
|
133
|
+
alignItems: "stretch",
|
|
134
|
+
flexShrink: 0
|
|
135
|
+
}, isWeb && {
|
|
136
|
+
display: "flex",
|
|
137
|
+
flexBasis: "auto",
|
|
138
|
+
boxSizing: "border-box"
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// src/constants/rnw.tsx
|
|
142
|
+
var interopRequire = /* @__PURE__ */ __name((src) => "default" in src ? src.default : src, "interopRequire");
|
|
143
|
+
var rnw = {};
|
|
144
|
+
if (process.env.IS_STATIC === "is_static") {
|
|
145
|
+
const createCompileableStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle");
|
|
146
|
+
const createReactDOMStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle");
|
|
147
|
+
const i18Style = require("react-native-web/dist/cjs/exports/StyleSheet/i18nStyle");
|
|
148
|
+
const atomic = require("react-native-web/dist/cjs/exports/StyleSheet/compile").atomic;
|
|
149
|
+
Object.assign(rnw, {
|
|
150
|
+
createCompileableStyle,
|
|
151
|
+
createReactDOMStyle,
|
|
152
|
+
i18Style,
|
|
153
|
+
atomic
|
|
154
|
+
});
|
|
155
|
+
} else if (process.env.TAMAGUI_TARGET === "web") {
|
|
156
|
+
Object.assign(rnw, interopRequire(require("react-native-web").TamaguiExports));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/createTamagui.ts
|
|
160
|
+
var import_helpers = __toModule(require("@tamagui/helpers"));
|
|
161
|
+
|
|
162
|
+
// src/createVariable.ts
|
|
163
|
+
var Variable = class {
|
|
164
|
+
constructor({ val, name }) {
|
|
165
|
+
this.val = val;
|
|
166
|
+
this.name = name;
|
|
167
|
+
this.variable = isWeb ? `var(--${name})` : this.val;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
__name(Variable, "Variable");
|
|
171
|
+
var createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
|
|
172
|
+
function isVariable(v) {
|
|
173
|
+
return v instanceof Variable;
|
|
174
|
+
}
|
|
175
|
+
__name(isVariable, "isVariable");
|
|
176
|
+
|
|
177
|
+
// src/helpers/createTamaguiProvider.tsx
|
|
178
|
+
var React4 = __toModule(require("react"));
|
|
179
|
+
|
|
180
|
+
// src/views/TextAncestorContext.tsx
|
|
181
|
+
var import_react2 = __toModule(require("react"));
|
|
182
|
+
var _a2;
|
|
183
|
+
var TextAncestorContext = (_a2 = rnw) == null ? void 0 : _a2.TextAncestorContext;
|
|
184
|
+
var TextAncestorProvider = /* @__PURE__ */ __name((props) => {
|
|
185
|
+
if (TextAncestorContext) {
|
|
186
|
+
return /* @__PURE__ */ import_react2.default.createElement(TextAncestorContext.Provider, {
|
|
187
|
+
value: false
|
|
188
|
+
}, props.children);
|
|
189
|
+
}
|
|
190
|
+
return props.children;
|
|
191
|
+
}, "TextAncestorProvider");
|
|
192
|
+
|
|
193
|
+
// src/views/ThemeProvider.tsx
|
|
194
|
+
var import_react7 = __toModule(require("react"));
|
|
195
|
+
|
|
196
|
+
// src/views/Theme.tsx
|
|
197
|
+
var import_react6 = __toModule(require("react"));
|
|
198
|
+
|
|
199
|
+
// src/hooks/useConstant.tsx
|
|
200
|
+
var import_react3 = __toModule(require("react"));
|
|
201
|
+
function useConstant(fn) {
|
|
202
|
+
const ref = (0, import_react3.useRef)();
|
|
203
|
+
if (!ref.current) {
|
|
204
|
+
ref.current = { v: fn() };
|
|
205
|
+
}
|
|
206
|
+
return ref.current.v;
|
|
207
|
+
}
|
|
208
|
+
__name(useConstant, "useConstant");
|
|
209
|
+
|
|
210
|
+
// src/views/ThemeContext.tsx
|
|
211
|
+
var import_react4 = __toModule(require("react"));
|
|
212
|
+
var ThemeContext = (0, import_react4.createContext)(null);
|
|
213
|
+
|
|
214
|
+
// src/views/ThemeManagerContext.tsx
|
|
215
|
+
var import_react5 = __toModule(require("react"));
|
|
216
|
+
var ThemeManager = class {
|
|
217
|
+
constructor() {
|
|
218
|
+
this.name = "light";
|
|
219
|
+
this.keys = new Map();
|
|
220
|
+
this.listeners = new Map();
|
|
221
|
+
this.callbacks = new Set();
|
|
222
|
+
this.theme = null;
|
|
223
|
+
}
|
|
224
|
+
setActiveTheme(name, theme) {
|
|
225
|
+
if (name === this.name)
|
|
226
|
+
return;
|
|
227
|
+
this.name = name;
|
|
228
|
+
this.theme = theme;
|
|
229
|
+
this.update();
|
|
230
|
+
}
|
|
231
|
+
track(uuid, keys) {
|
|
232
|
+
if (!this.name)
|
|
233
|
+
return;
|
|
234
|
+
this.keys.set(uuid, keys);
|
|
235
|
+
}
|
|
236
|
+
update() {
|
|
237
|
+
var _a4;
|
|
238
|
+
if (!this.name) {
|
|
239
|
+
this.keys.clear();
|
|
240
|
+
}
|
|
241
|
+
for (const [uuid, keys] of this.keys.entries()) {
|
|
242
|
+
if (keys.size) {
|
|
243
|
+
(_a4 = this.listeners.get(uuid)) == null ? void 0 : _a4();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
this.callbacks.forEach((cb) => cb(this.name));
|
|
247
|
+
}
|
|
248
|
+
onChangeTheme(cb) {
|
|
249
|
+
this.callbacks.add(cb);
|
|
250
|
+
return () => {
|
|
251
|
+
this.callbacks.delete(cb);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
onUpdate(uuid, cb) {
|
|
255
|
+
this.listeners.set(uuid, cb);
|
|
256
|
+
return () => {
|
|
257
|
+
this.listeners.delete(uuid);
|
|
258
|
+
this.keys.delete(uuid);
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
__name(ThemeManager, "ThemeManager");
|
|
263
|
+
var ThemeManagerContext = (0, import_react5.createContext)(new ThemeManager());
|
|
264
|
+
|
|
265
|
+
// src/views/Theme.tsx
|
|
266
|
+
var Theme = /* @__PURE__ */ __name((props) => {
|
|
267
|
+
var _a4, _b2;
|
|
268
|
+
const parent = (0, import_react6.useContext)(ThemeManagerContext);
|
|
269
|
+
const themes = (0, import_react6.useContext)(ThemeContext);
|
|
270
|
+
const [parentName, setParentName] = (0, import_react6.useState)(parent.name || "light");
|
|
271
|
+
if (!themes) {
|
|
272
|
+
console.warn("no themes???", props);
|
|
273
|
+
return props.children;
|
|
274
|
+
}
|
|
275
|
+
const name = props.name;
|
|
276
|
+
const theme = themes[name] || themes[`${name}-${parentName}`];
|
|
277
|
+
const themeManager = useConstant(() => {
|
|
278
|
+
const manager = new ThemeManager();
|
|
279
|
+
if (name) {
|
|
280
|
+
manager.setActiveTheme(name, themes[name]);
|
|
281
|
+
}
|
|
282
|
+
return manager;
|
|
283
|
+
});
|
|
284
|
+
useIsomorphicLayoutEffect(() => {
|
|
285
|
+
themeManager.setActiveTheme(name, theme);
|
|
286
|
+
return parent.onChangeTheme((next) => {
|
|
287
|
+
if (next) {
|
|
288
|
+
themeManager.setActiveTheme(next, themes[next]);
|
|
289
|
+
setParentName(next);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}, [themes, name]);
|
|
293
|
+
if (!name) {
|
|
294
|
+
return props.children;
|
|
295
|
+
}
|
|
296
|
+
const contents = themeManager ? /* @__PURE__ */ import_react6.default.createElement(ThemeManagerContext.Provider, {
|
|
297
|
+
value: themeManager
|
|
298
|
+
}, props.children) : props.children;
|
|
299
|
+
if (isWeb) {
|
|
300
|
+
if (props.disableThemeClass) {
|
|
301
|
+
return contents;
|
|
302
|
+
}
|
|
303
|
+
const color = (_b2 = (_a4 = themes[name]) == null ? void 0 : _a4["color"]) == null ? void 0 : _b2["variable"];
|
|
304
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
305
|
+
className: getThemeParentClassName(name),
|
|
306
|
+
style: { display: "contents", color }
|
|
307
|
+
}, contents);
|
|
308
|
+
}
|
|
309
|
+
return contents;
|
|
310
|
+
}, "Theme");
|
|
311
|
+
|
|
312
|
+
// src/views/ThemeProvider.tsx
|
|
313
|
+
var GET_DEFAULT_THEME = "___TGUI";
|
|
314
|
+
var ThemeProvider = /* @__PURE__ */ __name((props) => {
|
|
315
|
+
if (!getHasConfigured()) {
|
|
316
|
+
throw new Error(`Missing configureThemes() call, add to your root file`);
|
|
317
|
+
}
|
|
318
|
+
useIsomorphicLayoutEffect(() => {
|
|
319
|
+
if (props.disableRootThemeClass) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (typeof document !== "undefined") {
|
|
323
|
+
const cns = getThemeParentClassName(`${props.defaultTheme}`).split(" ");
|
|
324
|
+
cns.forEach((cn) => document.body.classList.add(cn));
|
|
325
|
+
return () => {
|
|
326
|
+
cns.forEach((cn) => document.body.classList.remove(cn));
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}, []);
|
|
330
|
+
const themeContext = (0, import_react7.useMemo)(() => {
|
|
331
|
+
return new Proxy(props.themes, {
|
|
332
|
+
get(target, key) {
|
|
333
|
+
if (key === GET_DEFAULT_THEME)
|
|
334
|
+
return props.defaultTheme;
|
|
335
|
+
return Reflect.get(target, key);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}, [props.themes]);
|
|
339
|
+
return /* @__PURE__ */ import_react7.default.createElement(ThemeContext.Provider, {
|
|
340
|
+
value: themeContext
|
|
341
|
+
}, /* @__PURE__ */ import_react7.default.createElement(Theme, {
|
|
342
|
+
name: props.defaultTheme,
|
|
343
|
+
disableThemeClass: props.disableRootThemeClass
|
|
344
|
+
}, props.children));
|
|
345
|
+
}, "ThemeProvider");
|
|
346
|
+
|
|
347
|
+
// src/helpers/createTamaguiProvider.tsx
|
|
348
|
+
function createTamaguiProvider(themeProps) {
|
|
349
|
+
return /* @__PURE__ */ __name(function TamaguiProvider(_a4) {
|
|
350
|
+
var _b2 = _a4, {
|
|
351
|
+
initialWindowMetrics,
|
|
352
|
+
fallback,
|
|
353
|
+
children
|
|
354
|
+
} = _b2, themePropsProvider = __objRest(_b2, [
|
|
355
|
+
"initialWindowMetrics",
|
|
356
|
+
"fallback",
|
|
357
|
+
"children"
|
|
358
|
+
]);
|
|
359
|
+
return /* @__PURE__ */ React4.createElement(TextAncestorProvider, null, /* @__PURE__ */ React4.createElement(ThemeProvider, __spreadValues(__spreadValues({}, themeProps), themePropsProvider), /* @__PURE__ */ React4.createElement(React4.Suspense, {
|
|
360
|
+
fallback: fallback || null
|
|
361
|
+
}, children)));
|
|
362
|
+
}, "TamaguiProvider");
|
|
363
|
+
}
|
|
364
|
+
__name(createTamaguiProvider, "createTamaguiProvider");
|
|
365
|
+
|
|
366
|
+
// src/hooks/useMedia.tsx
|
|
367
|
+
var import_react9 = __toModule(require("react"));
|
|
368
|
+
|
|
369
|
+
// src/helpers/matchMedia.ts
|
|
370
|
+
var matchMedia = typeof window !== "undefined" && window.matchMedia || /* @__PURE__ */ __name(function matchMediaFallback(query) {
|
|
371
|
+
return {
|
|
372
|
+
addListener() {
|
|
373
|
+
},
|
|
374
|
+
removeListener() {
|
|
375
|
+
},
|
|
376
|
+
matches: false
|
|
377
|
+
};
|
|
378
|
+
}, "matchMediaFallback");
|
|
379
|
+
|
|
380
|
+
// src/hooks/useForceUpdate.tsx
|
|
381
|
+
var import_react8 = __toModule(require("react"));
|
|
382
|
+
function useForceUpdate() {
|
|
383
|
+
const setState = (0, import_react8.useState)(0)[1];
|
|
384
|
+
const internal = (0, import_react8.useRef)();
|
|
385
|
+
if (!internal.current) {
|
|
386
|
+
internal.current = {
|
|
387
|
+
isMounted: true,
|
|
388
|
+
update: () => {
|
|
389
|
+
if (internal.current.isMounted) {
|
|
390
|
+
setState(Math.random());
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
(0, import_react8.useEffect)(() => {
|
|
396
|
+
return () => {
|
|
397
|
+
internal.current.isMounted = false;
|
|
398
|
+
};
|
|
399
|
+
}, []);
|
|
400
|
+
return internal.current.update;
|
|
401
|
+
}
|
|
402
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
403
|
+
|
|
404
|
+
// src/hooks/useMedia.tsx
|
|
405
|
+
var mediaState = {};
|
|
406
|
+
var mediaQueryListeners = {};
|
|
407
|
+
var addMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
408
|
+
mediaQueryListeners[key] = mediaQueryListeners[key] || new Set();
|
|
409
|
+
mediaQueryListeners[key].add(cb);
|
|
410
|
+
}, "addMediaQueryListener");
|
|
411
|
+
var removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
412
|
+
mediaQueryListeners[key].delete(cb);
|
|
413
|
+
}, "removeMediaQueryListener");
|
|
414
|
+
var conf = null;
|
|
415
|
+
var mediaQueryConfig = new Proxy({}, {
|
|
416
|
+
get(target, key) {
|
|
417
|
+
if (!conf) {
|
|
418
|
+
throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`);
|
|
419
|
+
}
|
|
420
|
+
return Reflect.get(conf, key);
|
|
421
|
+
},
|
|
422
|
+
ownKeys() {
|
|
423
|
+
if (!conf) {
|
|
424
|
+
throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`);
|
|
425
|
+
}
|
|
426
|
+
return Object.keys(conf);
|
|
427
|
+
},
|
|
428
|
+
getOwnPropertyDescriptor() {
|
|
429
|
+
return {
|
|
430
|
+
enumerable: true,
|
|
431
|
+
configurable: true
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
var getMedia = /* @__PURE__ */ __name(() => {
|
|
436
|
+
if (!conf) {
|
|
437
|
+
throw new Error(`not configured yet`);
|
|
438
|
+
}
|
|
439
|
+
return mediaState;
|
|
440
|
+
}, "getMedia");
|
|
441
|
+
var configureMedia = /* @__PURE__ */ __name(({
|
|
442
|
+
queries,
|
|
443
|
+
defaultActive = ["sm", "xs"]
|
|
444
|
+
} = {}) => {
|
|
445
|
+
if (conf) {
|
|
446
|
+
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
447
|
+
}
|
|
448
|
+
if (queries) {
|
|
449
|
+
conf = queries;
|
|
450
|
+
}
|
|
451
|
+
for (const key in queries) {
|
|
452
|
+
const str = mediaObjectToString(queries[key]);
|
|
453
|
+
try {
|
|
454
|
+
const getMatch = /* @__PURE__ */ __name(() => matchMedia(str), "getMatch");
|
|
455
|
+
const match = getMatch();
|
|
456
|
+
if (!match || typeof match.addListener !== "function") {
|
|
457
|
+
throw new Error("\u26A0\uFE0F No match (seeing this in RN sometimes)");
|
|
458
|
+
}
|
|
459
|
+
mediaState[key] = !!match.matches;
|
|
460
|
+
match.addListener(() => {
|
|
461
|
+
const next = !!getMatch().matches;
|
|
462
|
+
if (next === mediaState[key])
|
|
463
|
+
return;
|
|
464
|
+
mediaState[key] = next;
|
|
465
|
+
const listeners = mediaQueryListeners[key];
|
|
466
|
+
if (listeners == null ? void 0 : listeners.size) {
|
|
467
|
+
for (const cb of [...listeners]) {
|
|
468
|
+
cb();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
} catch (err) {
|
|
473
|
+
console.error("Error running media query", str, err.message, err.stack);
|
|
474
|
+
const isDefaultActive = (defaultActive == null ? void 0 : defaultActive.includes(key)) ?? true;
|
|
475
|
+
mediaState[key] = isDefaultActive;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}, "configureMedia");
|
|
479
|
+
var useMedia = /* @__PURE__ */ __name(() => {
|
|
480
|
+
const forceUpdate = useForceUpdate();
|
|
481
|
+
const state = (0, import_react9.useRef)();
|
|
482
|
+
if (!state.current) {
|
|
483
|
+
state.current = {
|
|
484
|
+
selections: {},
|
|
485
|
+
nextSelections: {},
|
|
486
|
+
isUnmounted: false,
|
|
487
|
+
isRendering: true
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
state.current.isRendering = true;
|
|
491
|
+
useIsomorphicLayoutEffect(() => {
|
|
492
|
+
const st = state.current;
|
|
493
|
+
st.isRendering = false;
|
|
494
|
+
for (const key in st.selections) {
|
|
495
|
+
if (!(key in st.nextSelections)) {
|
|
496
|
+
removeMediaQueryListener(key, forceUpdate);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
for (const key in st.nextSelections) {
|
|
500
|
+
if (!(key in st.selections)) {
|
|
501
|
+
addMediaQueryListener(key, forceUpdate);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
useIsomorphicLayoutEffect(() => {
|
|
506
|
+
return () => {
|
|
507
|
+
const st = state.current;
|
|
508
|
+
st.isUnmounted = true;
|
|
509
|
+
const allKeys = __spreadValues(__spreadValues({}, st.selections), st.nextSelections);
|
|
510
|
+
for (const key in allKeys) {
|
|
511
|
+
removeMediaQueryListener(key, forceUpdate);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
}, []);
|
|
515
|
+
return useConstant(() => {
|
|
516
|
+
const st = state.current;
|
|
517
|
+
return new Proxy(mediaState, {
|
|
518
|
+
get(target, key) {
|
|
519
|
+
if (!(key in mediaState)) {
|
|
520
|
+
return Reflect.get(target, key);
|
|
521
|
+
}
|
|
522
|
+
if (!st.isUnmounted) {
|
|
523
|
+
if (st.isRendering) {
|
|
524
|
+
st.nextSelections[key] = true;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (key in mediaState) {
|
|
528
|
+
return mediaState[key];
|
|
529
|
+
}
|
|
530
|
+
return Reflect.get(mediaState, key);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}, "useMedia");
|
|
535
|
+
function camelToHyphen(str) {
|
|
536
|
+
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase();
|
|
537
|
+
}
|
|
538
|
+
__name(camelToHyphen, "camelToHyphen");
|
|
539
|
+
function mediaObjectToString(query) {
|
|
540
|
+
if (typeof query === "string") {
|
|
541
|
+
return query;
|
|
542
|
+
}
|
|
543
|
+
return Object.entries(query).map(([feature, value]) => {
|
|
544
|
+
feature = camelToHyphen(feature);
|
|
545
|
+
if (typeof value === "string") {
|
|
546
|
+
return `(${feature}: ${value})`;
|
|
547
|
+
}
|
|
548
|
+
if (typeof value === "number" && /[height|width]$/.test(feature)) {
|
|
549
|
+
value = `${value}px`;
|
|
550
|
+
}
|
|
551
|
+
return `(${feature}: ${value})`;
|
|
552
|
+
}).join(" and ");
|
|
553
|
+
}
|
|
554
|
+
__name(mediaObjectToString, "mediaObjectToString");
|
|
555
|
+
|
|
556
|
+
// src/createTamagui.ts
|
|
557
|
+
var conf2;
|
|
558
|
+
var getHasConfigured = /* @__PURE__ */ __name(() => !!conf2, "getHasConfigured");
|
|
559
|
+
var getTamaguiConfig = /* @__PURE__ */ __name(() => conf2, "getTamaguiConfig");
|
|
560
|
+
var configListeners = new Set();
|
|
561
|
+
var onConfiguredOnce = /* @__PURE__ */ __name((cb) => {
|
|
562
|
+
if (conf2) {
|
|
563
|
+
cb(conf2);
|
|
564
|
+
} else {
|
|
565
|
+
configListeners.add(cb);
|
|
566
|
+
}
|
|
567
|
+
}, "onConfiguredOnce");
|
|
568
|
+
var PREFIX = `theme--`;
|
|
569
|
+
function createTamagui(config) {
|
|
570
|
+
if (conf2) {
|
|
571
|
+
console.warn("Called createTamagui twice! Should never do so");
|
|
572
|
+
}
|
|
573
|
+
configureMedia({
|
|
574
|
+
queries: config.media,
|
|
575
|
+
defaultActive: config.mediaQueryDefaultActive
|
|
576
|
+
});
|
|
577
|
+
const themeConfig = (() => {
|
|
578
|
+
let cssRules = [];
|
|
579
|
+
let tokenRule = `:root {`;
|
|
580
|
+
const varsByValue = new Map();
|
|
581
|
+
const addVar = /* @__PURE__ */ __name((v) => {
|
|
582
|
+
varsByValue[v.val] = v;
|
|
583
|
+
const rule = `--${v.name}:${typeof v.val === "number" ? `${v.val}px` : v.val};`;
|
|
584
|
+
tokenRule += rule;
|
|
585
|
+
}, "addVar");
|
|
586
|
+
for (const key in config.tokens) {
|
|
587
|
+
for (const skey in config.tokens[key]) {
|
|
588
|
+
const val = config.tokens[key][skey];
|
|
589
|
+
if (key === "font") {
|
|
590
|
+
for (const fkey in val) {
|
|
591
|
+
if (fkey === "family") {
|
|
592
|
+
addVar(val[fkey]);
|
|
593
|
+
} else {
|
|
594
|
+
for (const fskey in val[fkey]) {
|
|
595
|
+
addVar(val[fkey][fskey]);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
addVar(val);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
cssRules.push(`${tokenRule}
|
|
605
|
+
}`);
|
|
606
|
+
for (const themeName in config.themes) {
|
|
607
|
+
config.themes[themeName] = __spreadValues({}, config.themes[themeName]);
|
|
608
|
+
const theme = config.themes[themeName];
|
|
609
|
+
let vars = "";
|
|
610
|
+
for (const themeKey in theme) {
|
|
611
|
+
const val = theme[themeKey];
|
|
612
|
+
const getVariableCSS = /* @__PURE__ */ __name((inv) => {
|
|
613
|
+
const v = varsByValue[inv] ?? inv;
|
|
614
|
+
return isVariable(v) ? `--${themeKey}:var(--${v.name});` : `--${themeKey}:${v};`;
|
|
615
|
+
}, "getVariableCSS");
|
|
616
|
+
vars += getVariableCSS(val);
|
|
617
|
+
if (!isVariable(val)) {
|
|
618
|
+
theme[themeKey] = createVariable({
|
|
619
|
+
name: themeKey,
|
|
620
|
+
val
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const [themeClassName, parentName] = themeName.includes("-") ? themeName.split("-") : [themeName, ""];
|
|
625
|
+
const oppositeName = parentName === "dark" ? "light" : "dark";
|
|
626
|
+
const cssParentSel = parentName ? `.${PREFIX}${parentName}` : "";
|
|
627
|
+
const cssChildSel = `.${PREFIX}${themeClassName}`;
|
|
628
|
+
const cssSel = `${cssParentSel} ${cssChildSel}`;
|
|
629
|
+
const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {
|
|
630
|
+
${vars}
|
|
631
|
+
}`;
|
|
632
|
+
cssRules.push(cssRule);
|
|
633
|
+
}
|
|
634
|
+
Object.freeze(cssRules);
|
|
635
|
+
return {
|
|
636
|
+
cssRules,
|
|
637
|
+
css: cssRules.join("\n")
|
|
638
|
+
};
|
|
639
|
+
})();
|
|
640
|
+
const tokensParsed = parseTokens(config.tokens);
|
|
641
|
+
const themeParsed = {};
|
|
642
|
+
const firstKey = Object.keys(config.themes)[0];
|
|
643
|
+
for (const key in config.themes[firstKey]) {
|
|
644
|
+
const val = config.themes[firstKey][key].val;
|
|
645
|
+
themeParsed[`$${key}`] = new Variable({ val, name: key });
|
|
646
|
+
}
|
|
647
|
+
const next = __spreadProps(__spreadValues({
|
|
648
|
+
shorthands: {}
|
|
649
|
+
}, config), {
|
|
650
|
+
Provider: createTamaguiProvider(__spreadValues({
|
|
651
|
+
defaultTheme: "light"
|
|
652
|
+
}, config)),
|
|
653
|
+
themeConfig,
|
|
654
|
+
themeParsed,
|
|
655
|
+
tokensParsed,
|
|
656
|
+
getCSS() {
|
|
657
|
+
return `${themeConfig.css}
|
|
658
|
+
${[...(0, import_helpers.getStyleRules)()].join("\n")}`;
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
conf2 = next;
|
|
662
|
+
if (configListeners.size) {
|
|
663
|
+
configListeners.forEach((cb) => cb(next));
|
|
664
|
+
configListeners.clear();
|
|
665
|
+
}
|
|
666
|
+
return next;
|
|
667
|
+
}
|
|
668
|
+
__name(createTamagui, "createTamagui");
|
|
669
|
+
function getThemeParentClassName(themeName) {
|
|
670
|
+
return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ""}`;
|
|
671
|
+
}
|
|
672
|
+
__name(getThemeParentClassName, "getThemeParentClassName");
|
|
673
|
+
var parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
674
|
+
const res = {};
|
|
675
|
+
for (const key in tokens) {
|
|
676
|
+
res[key] = {};
|
|
677
|
+
if (key === "font") {
|
|
678
|
+
for (const family in tokens.font) {
|
|
679
|
+
const obj = {};
|
|
680
|
+
res.font[`$${family}`] = obj;
|
|
681
|
+
for (const attrKey in tokens.font[family]) {
|
|
682
|
+
const attr = tokens.font[family][attrKey];
|
|
683
|
+
if (attrKey === "family") {
|
|
684
|
+
obj[attrKey] = attr;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
688
|
+
acc[`$${cur}`] = attr[cur];
|
|
689
|
+
return acc;
|
|
690
|
+
}, {});
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
for (const skey in tokens[key]) {
|
|
696
|
+
res[key][`$${skey}`] = tokens[key][skey];
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return res;
|
|
700
|
+
}, "parseTokens");
|
|
701
|
+
|
|
702
|
+
// src/helpers/addStylesUsingClassname.tsx
|
|
703
|
+
var import_react10 = __toModule(require("react"));
|
|
704
|
+
|
|
705
|
+
// src/helpers/getStylesAtomic.ts
|
|
706
|
+
var import_helpers2 = __toModule(require("@tamagui/helpers"));
|
|
707
|
+
|
|
708
|
+
// src/constants/pseudos.ts
|
|
709
|
+
var pseudos = {
|
|
710
|
+
focusStyle: {
|
|
711
|
+
name: "focus",
|
|
712
|
+
priority: 3
|
|
713
|
+
},
|
|
714
|
+
pressStyle: {
|
|
715
|
+
name: "active",
|
|
716
|
+
priority: 2
|
|
717
|
+
},
|
|
718
|
+
hoverStyle: {
|
|
719
|
+
name: "hover",
|
|
720
|
+
priority: 1
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// src/helpers/getStylesAtomic.ts
|
|
725
|
+
var generateStyle = /* @__PURE__ */ __name((style) => {
|
|
726
|
+
const { atomic, createCompileableStyle, createReactDOMStyle, i18Style } = rnw;
|
|
727
|
+
return __spreadValues({}, atomic(createCompileableStyle(createReactDOMStyle(i18Style(style)))));
|
|
728
|
+
}, "generateStyle");
|
|
729
|
+
var borderDefaults = {
|
|
730
|
+
borderWidth: "borderStyle",
|
|
731
|
+
borderBottomWidth: "borderBottomStyle",
|
|
732
|
+
borderTopWidth: "borderTopStyle",
|
|
733
|
+
borderLeftWidth: "borderLeftStyle",
|
|
734
|
+
borderRightWidth: "borderRightStyle"
|
|
735
|
+
};
|
|
736
|
+
function getStylesAtomic(style, avoidCollection = false) {
|
|
737
|
+
const styles = {
|
|
738
|
+
base: {}
|
|
739
|
+
};
|
|
740
|
+
for (const key in style) {
|
|
741
|
+
if (!!pseudos[key]) {
|
|
742
|
+
styles[key] = style[key];
|
|
743
|
+
} else {
|
|
744
|
+
styles.base[key] = style[key];
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return Object.keys(styles).map((key) => {
|
|
748
|
+
return getAtomicStyle(styles[key], pseudos[key], avoidCollection);
|
|
749
|
+
}).flat();
|
|
750
|
+
}
|
|
751
|
+
__name(getStylesAtomic, "getStylesAtomic");
|
|
752
|
+
var importantRegex = /\!important*/g;
|
|
753
|
+
function getAtomicStyle(style, pseudo, avoidCollection) {
|
|
754
|
+
if (style == null || typeof style !== "object") {
|
|
755
|
+
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
|
|
756
|
+
}
|
|
757
|
+
for (const key in borderDefaults) {
|
|
758
|
+
if (key in style) {
|
|
759
|
+
style[borderDefaults[key]] = style[borderDefaults[key]] ?? "solid";
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
const all = generateStyle(style);
|
|
763
|
+
return Object.keys(all).map((key) => {
|
|
764
|
+
const val = all[key];
|
|
765
|
+
const hash = val.identifier.slice(`${val.identifier}`.lastIndexOf("-") + 1);
|
|
766
|
+
const psuedoPrefix = pseudo ? `-${pseudo.name}-` : "";
|
|
767
|
+
const identifier = `_${val.property}-${psuedoPrefix}${hash}`;
|
|
768
|
+
const className = `.${identifier}`;
|
|
769
|
+
const rules = val.rules.map((rule) => {
|
|
770
|
+
if (pseudo) {
|
|
771
|
+
const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
|
|
772
|
+
let res = rule.replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`).replace("{", `:${pseudo.name}{`);
|
|
773
|
+
if (pseudo.name === "hover") {
|
|
774
|
+
res = `@media not all and (hover: none) { ${res} }`;
|
|
775
|
+
}
|
|
776
|
+
return res;
|
|
777
|
+
}
|
|
778
|
+
return rule.replace(`.${val.identifier}`, className).replace(importantRegex, "");
|
|
779
|
+
});
|
|
780
|
+
if (!avoidCollection) {
|
|
781
|
+
if (rules.length > 1) {
|
|
782
|
+
console.warn("have never seen more than one, verifying");
|
|
783
|
+
}
|
|
784
|
+
import_helpers2.AllRules.add(rules[0]);
|
|
785
|
+
}
|
|
786
|
+
const result = {
|
|
787
|
+
property: val.property,
|
|
788
|
+
value: val.value,
|
|
789
|
+
identifier,
|
|
790
|
+
className,
|
|
791
|
+
rules
|
|
792
|
+
};
|
|
793
|
+
return result;
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
__name(getAtomicStyle, "getAtomicStyle");
|
|
797
|
+
|
|
798
|
+
// src/helpers/insertStyleRule.tsx
|
|
799
|
+
function insertStyleRule(rule) {
|
|
800
|
+
if (typeof window === "undefined") {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
if (process.env.NODE_ENV === "development") {
|
|
804
|
+
if (!isWeb) {
|
|
805
|
+
console.warn("non web platform, dont use this");
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const sheet2 = window.document.styleSheets[0];
|
|
810
|
+
if (!sheet2) {
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
sheet2.insertRule(rule, sheet2.cssRules.length);
|
|
814
|
+
}
|
|
815
|
+
__name(insertStyleRule, "insertStyleRule");
|
|
816
|
+
|
|
817
|
+
// src/helpers/addStylesUsingClassname.tsx
|
|
818
|
+
var added = new Set();
|
|
819
|
+
function useStylesAsClassname(styles) {
|
|
820
|
+
if (!import_react10.useInsertionEffect) {
|
|
821
|
+
return addStylesUsingClassname(styles);
|
|
822
|
+
} else {
|
|
823
|
+
const insertions = [];
|
|
824
|
+
const className = addStylesUsingClassname(styles, (_, rules) => {
|
|
825
|
+
for (const rule of rules) {
|
|
826
|
+
insertions.push(rule);
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
(0, import_react10.useInsertionEffect)(() => {
|
|
830
|
+
for (const ruleset of insertions) {
|
|
831
|
+
insertStyleRule(ruleset);
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
return className;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
__name(useStylesAsClassname, "useStylesAsClassname");
|
|
838
|
+
function addStylesUsingClassname(styles, onAdd) {
|
|
839
|
+
let className = "";
|
|
840
|
+
for (const style of styles) {
|
|
841
|
+
if (!style)
|
|
842
|
+
continue;
|
|
843
|
+
if (Array.isArray(style)) {
|
|
844
|
+
className += " " + addStylesUsingClassname(style);
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
for (const { identifier, rules } of getStylesAtomic(style)) {
|
|
848
|
+
className += ` ${identifier}`;
|
|
849
|
+
if (added.has(identifier)) {
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
added.add(identifier);
|
|
853
|
+
if (onAdd) {
|
|
854
|
+
onAdd(identifier, rules);
|
|
855
|
+
} else {
|
|
856
|
+
for (const rule of rules) {
|
|
857
|
+
insertStyleRule(rule);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return className;
|
|
863
|
+
}
|
|
864
|
+
__name(addStylesUsingClassname, "addStylesUsingClassname");
|
|
865
|
+
|
|
866
|
+
// src/helpers/isObj.ts
|
|
867
|
+
var isObj = /* @__PURE__ */ __name((x) => x && !Array.isArray(x) && typeof x === "object", "isObj");
|
|
868
|
+
|
|
869
|
+
// src/helpers/createPropMapper.ts
|
|
870
|
+
var createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
871
|
+
const variants = c.variants;
|
|
872
|
+
let variantsParsed;
|
|
873
|
+
const defaultProps = c.defaultProps || {};
|
|
874
|
+
return (key, value, theme, props) => {
|
|
875
|
+
const conf3 = getTamaguiConfig();
|
|
876
|
+
if (!conf3) {
|
|
877
|
+
console.trace("no conf! err");
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (variants && !variantsParsed) {
|
|
881
|
+
variantsParsed = parseVariants(variants, conf3);
|
|
882
|
+
}
|
|
883
|
+
let fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
884
|
+
const variant = variantsParsed == null ? void 0 : variantsParsed[key];
|
|
885
|
+
if (variant && typeof value !== "undefined") {
|
|
886
|
+
const val = value === true ? variant["$true"] || variant["true"] : variant[value] ?? variant["..."] ?? value;
|
|
887
|
+
const res = typeof val === "function" ? val(value, { tokens: conf3.tokensParsed, theme, props }) : isObj(val) ? __spreadValues({}, val) : val;
|
|
888
|
+
if (isObj(res)) {
|
|
889
|
+
resolveTokens(res, conf3, fontFamily);
|
|
890
|
+
}
|
|
891
|
+
return res;
|
|
892
|
+
}
|
|
893
|
+
let shouldReturn = false;
|
|
894
|
+
if (conf3.shorthands[key]) {
|
|
895
|
+
shouldReturn = true;
|
|
896
|
+
key = conf3.shorthands[key];
|
|
897
|
+
}
|
|
898
|
+
if (value && value[0] === "$") {
|
|
899
|
+
shouldReturn = true;
|
|
900
|
+
value = getToken(key, value, conf3, fontFamily);
|
|
901
|
+
}
|
|
902
|
+
if (value instanceof Variable) {
|
|
903
|
+
shouldReturn = true;
|
|
904
|
+
value = value.variable;
|
|
905
|
+
}
|
|
906
|
+
if (shouldReturn) {
|
|
907
|
+
return {
|
|
908
|
+
[key]: value
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
}, "createPropMapper");
|
|
913
|
+
var resolveTokens = /* @__PURE__ */ __name((res, conf3, fontFamily) => {
|
|
914
|
+
for (const rKey in res) {
|
|
915
|
+
const fKey = conf3.shorthands[rKey] || rKey;
|
|
916
|
+
const val = res[rKey];
|
|
917
|
+
if (val instanceof Variable) {
|
|
918
|
+
res[fKey] = val.variable;
|
|
919
|
+
} else if (typeof val === "string") {
|
|
920
|
+
const fVal = val[0] === "$" ? getToken(fKey, val, conf3, fontFamily) : val;
|
|
921
|
+
res[fKey] = fVal;
|
|
922
|
+
} else {
|
|
923
|
+
if (isObj(val)) {
|
|
924
|
+
resolveTokens(val, conf3, fontFamily);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}, "resolveTokens");
|
|
929
|
+
var getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, themeParsed }, fontFamily = "$body") => {
|
|
930
|
+
var _a4, _b2, _c, _d, _e;
|
|
931
|
+
if (themeParsed[value]) {
|
|
932
|
+
return themeParsed[value].variable;
|
|
933
|
+
}
|
|
934
|
+
let valOrVar;
|
|
935
|
+
if (key === "fontFamily") {
|
|
936
|
+
valOrVar = ((_a4 = tokensParsed.font[value]) == null ? void 0 : _a4.family) || value;
|
|
937
|
+
}
|
|
938
|
+
if (key === "fontSize") {
|
|
939
|
+
valOrVar = ((_b2 = tokensParsed.font[fontFamily]) == null ? void 0 : _b2.size[value]) || value;
|
|
940
|
+
}
|
|
941
|
+
if (key === "lineHeight") {
|
|
942
|
+
valOrVar = ((_c = tokensParsed.font[fontFamily]) == null ? void 0 : _c.lineHeight[value]) || value;
|
|
943
|
+
}
|
|
944
|
+
if (key === "letterSpacing") {
|
|
945
|
+
valOrVar = ((_d = tokensParsed.font[fontFamily]) == null ? void 0 : _d.letterSpacing[value]) || value;
|
|
946
|
+
}
|
|
947
|
+
if (key === "fontWeight") {
|
|
948
|
+
valOrVar = ((_e = tokensParsed.font[fontFamily]) == null ? void 0 : _e.weight[value]) || value;
|
|
949
|
+
}
|
|
950
|
+
if (typeof valOrVar !== "undefined") {
|
|
951
|
+
if (valOrVar instanceof Variable) {
|
|
952
|
+
return valOrVar.variable;
|
|
953
|
+
} else {
|
|
954
|
+
return valOrVar;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
for (const cat in tokenCategories) {
|
|
958
|
+
if (tokenCategories[cat][key]) {
|
|
959
|
+
const res = tokensParsed[cat][value];
|
|
960
|
+
if (res) {
|
|
961
|
+
return res.variable;
|
|
962
|
+
} else {
|
|
963
|
+
const themeVar = themeParsed[value];
|
|
964
|
+
if (themeVar) {
|
|
965
|
+
return themeVar.variable;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const spaceVar = tokensParsed.space[value];
|
|
971
|
+
if (spaceVar) {
|
|
972
|
+
return spaceVar.variable;
|
|
973
|
+
}
|
|
974
|
+
return value;
|
|
975
|
+
}, "getToken");
|
|
976
|
+
var tokenCategories = {
|
|
977
|
+
size: {
|
|
978
|
+
width: true,
|
|
979
|
+
height: true,
|
|
980
|
+
minWidth: true,
|
|
981
|
+
minHeight: true,
|
|
982
|
+
maxWidth: true,
|
|
983
|
+
maxHeight: true
|
|
984
|
+
},
|
|
985
|
+
color: {
|
|
986
|
+
color: true,
|
|
987
|
+
backgroundColor: true,
|
|
988
|
+
borderColor: true,
|
|
989
|
+
borderBottomColor: true,
|
|
990
|
+
borderTopColor: true,
|
|
991
|
+
borderLeftColor: true,
|
|
992
|
+
borderRightColor: true
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
function parseVariants(variants, conf3) {
|
|
996
|
+
return Object.keys(variants).reduce((acc, key) => {
|
|
997
|
+
acc[key] = Object.keys(variants[key]).reduce((vacc, vkey) => {
|
|
998
|
+
const variantVal = variants[key][vkey];
|
|
999
|
+
if (vkey.startsWith("...")) {
|
|
1000
|
+
vacc["..."] = variantVal;
|
|
1001
|
+
const tokenKey = vkey.slice(3);
|
|
1002
|
+
const tokens = conf3.tokens[tokenKey];
|
|
1003
|
+
for (const tkey in tokens) {
|
|
1004
|
+
vacc[`$${tkey}`] = variantVal;
|
|
1005
|
+
}
|
|
1006
|
+
} else {
|
|
1007
|
+
vacc[vkey] = variantVal;
|
|
1008
|
+
}
|
|
1009
|
+
return vacc;
|
|
1010
|
+
}, {});
|
|
1011
|
+
return acc;
|
|
1012
|
+
}, {});
|
|
1013
|
+
}
|
|
1014
|
+
__name(parseVariants, "parseVariants");
|
|
1015
|
+
|
|
1016
|
+
// src/helpers/extendStaticConfig.ts
|
|
1017
|
+
function extendStaticConfig(Component, config = {}) {
|
|
1018
|
+
const parent = Component || {};
|
|
1019
|
+
if (!parent.staticConfig) {
|
|
1020
|
+
parent.staticConfig = {
|
|
1021
|
+
Component
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
const variants = __spreadValues({}, parent.staticConfig.variants);
|
|
1025
|
+
if (config.variants) {
|
|
1026
|
+
for (const key in config.variants) {
|
|
1027
|
+
if (variants[key]) {
|
|
1028
|
+
variants[key] = __spreadValues(__spreadValues({}, variants[key]), config.variants[key]);
|
|
1029
|
+
} else {
|
|
1030
|
+
variants[key] = config.variants[key];
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return parseStaticConfig(__spreadProps(__spreadValues({}, parent.staticConfig), {
|
|
1035
|
+
isZStack: config.isZStack || parent.staticConfig.isZStack,
|
|
1036
|
+
variants,
|
|
1037
|
+
isText: config.isText || parent.staticConfig.isText || false,
|
|
1038
|
+
neverFlatten: config.neverFlatten ?? parent.staticConfig.neverFlatten,
|
|
1039
|
+
ensureOverriddenProp: config.ensureOverriddenProp ?? parent.staticConfig.ensureOverriddenProp,
|
|
1040
|
+
validStyles: config.validStyles ? __spreadValues(__spreadValues({}, parent.staticConfig.validStyles), config.validStyles) : parent.staticConfig.validStyles,
|
|
1041
|
+
validPropsExtra: __spreadValues(__spreadValues({}, parent.staticConfig.validPropsExtra), config.validPropsExtra),
|
|
1042
|
+
defaultProps: __spreadValues(__spreadValues({}, parent.staticConfig.defaultProps), config.defaultProps)
|
|
1043
|
+
}));
|
|
1044
|
+
}
|
|
1045
|
+
__name(extendStaticConfig, "extendStaticConfig");
|
|
1046
|
+
var parseStaticConfig = /* @__PURE__ */ __name((config) => {
|
|
1047
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
1048
|
+
parsed: true,
|
|
1049
|
+
propMapper: createPropMapper(config)
|
|
1050
|
+
});
|
|
1051
|
+
}, "parseStaticConfig");
|
|
1052
|
+
|
|
1053
|
+
// src/helpers/getSplitStyles.tsx
|
|
1054
|
+
var import_helpers3 = __toModule(require("@tamagui/helpers"));
|
|
1055
|
+
|
|
1056
|
+
// src/helpers/createMediaStyle.ts
|
|
1057
|
+
var MEDIA_SEP = "_";
|
|
1058
|
+
var createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey, mediaQueries, negate, importance = 0) => {
|
|
1059
|
+
const mediaKeys = Object.keys(mediaQueries);
|
|
1060
|
+
const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
|
|
1061
|
+
acc[cur] = new Array(importance + 1).fill(":root").join("");
|
|
1062
|
+
return acc;
|
|
1063
|
+
}, {});
|
|
1064
|
+
const negKey = negate ? "0" : "";
|
|
1065
|
+
const ogPrefix = identifier.slice(0, identifier.indexOf("-") + 1);
|
|
1066
|
+
const nextIdentifier = `${identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`)}`;
|
|
1067
|
+
const screenStr = negate ? "not all" : "screen";
|
|
1068
|
+
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
1069
|
+
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
1070
|
+
const precendencePrefix = mediaKeyPrecendence[mediaKey];
|
|
1071
|
+
const styleInner = rules[0].replace(identifier, nextIdentifier);
|
|
1072
|
+
let styleRule = "";
|
|
1073
|
+
if (styleInner.includes("@media")) {
|
|
1074
|
+
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
1075
|
+
} else {
|
|
1076
|
+
styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`;
|
|
1077
|
+
}
|
|
1078
|
+
return {
|
|
1079
|
+
styleRule,
|
|
1080
|
+
identifier: nextIdentifier
|
|
1081
|
+
};
|
|
1082
|
+
}, "createMediaStyle");
|
|
1083
|
+
|
|
1084
|
+
// src/helpers/fixNativeShadow.tsx
|
|
1085
|
+
var fixNativeShadow = /* @__PURE__ */ __name((a) => {
|
|
1086
|
+
}, "fixNativeShadow");
|
|
1087
|
+
|
|
1088
|
+
// src/helpers/getSplitStyles.tsx
|
|
1089
|
+
var getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, isSplittingDefaultProps) => {
|
|
1090
|
+
const validStyleProps = staticConfig.isText ? import_helpers3.stylePropsText : import_helpers3.validStyles;
|
|
1091
|
+
const viewProps = {};
|
|
1092
|
+
const style = [];
|
|
1093
|
+
const blacklistProps = isSplittingDefaultProps ? blacklistDefaultProps : blacklistFinalProps;
|
|
1094
|
+
let pseudos2 = null;
|
|
1095
|
+
let cur = null;
|
|
1096
|
+
let classNames = null;
|
|
1097
|
+
for (const keyInit in props) {
|
|
1098
|
+
const valInit = props[keyInit];
|
|
1099
|
+
if (keyInit[0] === "$") {
|
|
1100
|
+
const mediaKey = keyInit.slice(1);
|
|
1101
|
+
if (!mediaQueryConfig[mediaKey]) {
|
|
1102
|
+
viewProps[keyInit] = valInit;
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
const mediaProps = __spreadValues(__spreadValues({}, props), valInit);
|
|
1106
|
+
const mediaStyle = getSubStyle(valInit, staticConfig, theme, props);
|
|
1107
|
+
const mediaStyles = getStylesAtomic(mediaStyle);
|
|
1108
|
+
if (process.env.NODE_ENV === "development") {
|
|
1109
|
+
if (props["debug"]) {
|
|
1110
|
+
console.log("mediaStyles", keyInit, { mediaProps, mediaStyle, mediaStyles });
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
for (const style2 of mediaStyles) {
|
|
1114
|
+
if (isWeb) {
|
|
1115
|
+
const out2 = createMediaStyle(style2, mediaKey, mediaQueryConfig);
|
|
1116
|
+
classNames = classNames || [];
|
|
1117
|
+
classNames.push(out2.identifier);
|
|
1118
|
+
import_helpers3.AllRules.add(out2.styleRule);
|
|
1119
|
+
insertStyleRule(out2.styleRule);
|
|
1120
|
+
if (process.env.NODE_ENV === "development" && props["debug"]) {
|
|
1121
|
+
console.log("mediaProp", style2.identifier, out2, mediaProps, mediaStyle, mediaStyles);
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
console.log("TODO native media style logic");
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
if (import_helpers3.validStylesPseudo[keyInit]) {
|
|
1130
|
+
if (!valInit)
|
|
1131
|
+
continue;
|
|
1132
|
+
pseudos2 = pseudos2 || {};
|
|
1133
|
+
pseudos2[keyInit] = getSubStyle(valInit, staticConfig, theme, props);
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
const out = staticConfig.propMapper(keyInit, valInit, theme, props);
|
|
1137
|
+
const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out);
|
|
1138
|
+
for (const [key, val] of expanded) {
|
|
1139
|
+
const keyFirstChar = key[0];
|
|
1140
|
+
if (key === "style" || keyFirstChar === "_" && key.startsWith("_style")) {
|
|
1141
|
+
if (cur) {
|
|
1142
|
+
fixNativeShadow(cur);
|
|
1143
|
+
style.push(cur);
|
|
1144
|
+
cur = null;
|
|
1145
|
+
}
|
|
1146
|
+
fixNativeShadow(val);
|
|
1147
|
+
style.push(val);
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (key === "flex") {
|
|
1151
|
+
cur = cur || {};
|
|
1152
|
+
Object.assign(cur, {
|
|
1153
|
+
flexGrow: val,
|
|
1154
|
+
flexShrink: 1
|
|
1155
|
+
});
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
if (!isWeb && key === "pointerEvents") {
|
|
1159
|
+
viewProps[key] = val;
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
if (validStyleProps[key]) {
|
|
1163
|
+
if (key in import_helpers3.stylePropsTransform) {
|
|
1164
|
+
cur = cur || {};
|
|
1165
|
+
mergeTransform(cur, key, val);
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
cur = cur || {};
|
|
1169
|
+
cur[key] = val;
|
|
1170
|
+
continue;
|
|
1171
|
+
}
|
|
1172
|
+
if (!blacklistProps[key]) {
|
|
1173
|
+
viewProps[key] = val;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
if (cur) {
|
|
1178
|
+
fixNativeShadow(cur);
|
|
1179
|
+
style.push(cur);
|
|
1180
|
+
}
|
|
1181
|
+
if (process.env.NODE_ENV === "development") {
|
|
1182
|
+
if (props["debug"]) {
|
|
1183
|
+
console.log(" \u{1F95A} splitProps:", { props, viewProps, style });
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return {
|
|
1187
|
+
viewProps,
|
|
1188
|
+
style,
|
|
1189
|
+
pseudos: pseudos2,
|
|
1190
|
+
classNames
|
|
1191
|
+
};
|
|
1192
|
+
}, "getSplitStyles");
|
|
1193
|
+
var getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props) => {
|
|
1194
|
+
const styleOut = {};
|
|
1195
|
+
for (const key in styleIn) {
|
|
1196
|
+
const val = styleIn[key];
|
|
1197
|
+
const out = staticConfig.propMapper(key, val, theme, props);
|
|
1198
|
+
const expanded = out === true || !out ? [[key, val]] : Object.entries(out);
|
|
1199
|
+
for (const [skey, sval] of expanded) {
|
|
1200
|
+
if (skey in import_helpers3.stylePropsTransform) {
|
|
1201
|
+
mergeTransform(styleOut, skey, sval);
|
|
1202
|
+
} else {
|
|
1203
|
+
styleOut[skey] = sval;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
fixNativeShadow(styleOut);
|
|
1208
|
+
return styleOut;
|
|
1209
|
+
}, "getSubStyle");
|
|
1210
|
+
var blacklistDefaultProps = __spreadValues(__spreadValues({}, import_helpers3.validStyles), import_helpers3.stylePropsText);
|
|
1211
|
+
var blacklistFinalProps = __spreadProps(__spreadValues({}, blacklistDefaultProps), {
|
|
1212
|
+
tag: true,
|
|
1213
|
+
debug: true,
|
|
1214
|
+
space: true,
|
|
1215
|
+
hitSlop: true
|
|
1216
|
+
});
|
|
1217
|
+
var mapTransformKeys = {
|
|
1218
|
+
x: "translateX",
|
|
1219
|
+
y: "translateY"
|
|
1220
|
+
};
|
|
1221
|
+
var mergeTransform = /* @__PURE__ */ __name((obj, key, val) => {
|
|
1222
|
+
const transform = obj.transform ? Array.isArray(obj.transform) ? obj.transform : [obj.transform] : [];
|
|
1223
|
+
transform.push({ [mapTransformKeys[key] || key]: val });
|
|
1224
|
+
obj.transform = transform;
|
|
1225
|
+
}, "mergeTransform");
|
|
1226
|
+
|
|
1227
|
+
// src/hooks/useFeatures.tsx
|
|
1228
|
+
var import_react11 = __toModule(require("react"));
|
|
1229
|
+
var createDefinition = /* @__PURE__ */ __name(({ Component, propNames }) => ({
|
|
1230
|
+
isEnabled: (props) => propNames.some((name) => !!props[name]),
|
|
1231
|
+
Component
|
|
1232
|
+
}), "createDefinition");
|
|
1233
|
+
var mediaQueryPropNames = [
|
|
1234
|
+
"$xs",
|
|
1235
|
+
"$sm",
|
|
1236
|
+
"$md",
|
|
1237
|
+
"$lg",
|
|
1238
|
+
"$xl",
|
|
1239
|
+
"$xxl",
|
|
1240
|
+
"$pointerCoarse",
|
|
1241
|
+
"$hoverNone",
|
|
1242
|
+
"$tall",
|
|
1243
|
+
"$short",
|
|
1244
|
+
"$gtSm",
|
|
1245
|
+
"$notXs",
|
|
1246
|
+
"$gtMd",
|
|
1247
|
+
"$gtLg"
|
|
1248
|
+
];
|
|
1249
|
+
var featureDefinitions = {
|
|
1250
|
+
measureLayout: createDefinition({
|
|
1251
|
+
Component: (props) => {
|
|
1252
|
+
console.log("measure", props);
|
|
1253
|
+
return null;
|
|
1254
|
+
},
|
|
1255
|
+
propNames: ["onLayout"]
|
|
1256
|
+
}),
|
|
1257
|
+
mediaQuery: createDefinition({
|
|
1258
|
+
Component: (props) => {
|
|
1259
|
+
if (isWeb) {
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
const keys = mediaQueryPropNames.flatMap((x) => x in props ? x.slice(1) : []);
|
|
1263
|
+
useIsomorphicLayoutEffect(() => {
|
|
1264
|
+
for (const key of keys) {
|
|
1265
|
+
addMediaQueryListener(key, props._utils.forceUpdate);
|
|
1266
|
+
}
|
|
1267
|
+
return () => {
|
|
1268
|
+
for (const key of keys) {
|
|
1269
|
+
removeMediaQueryListener(key, props._utils.forceUpdate);
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
}, [keys.join(",")]);
|
|
1273
|
+
return null;
|
|
1274
|
+
},
|
|
1275
|
+
propNames: mediaQueryPropNames
|
|
1276
|
+
})
|
|
1277
|
+
};
|
|
1278
|
+
var featureNames = Object.keys(featureDefinitions);
|
|
1279
|
+
var numFeatures = featureNames.length;
|
|
1280
|
+
var useFeatures = /* @__PURE__ */ __name((props, utils) => {
|
|
1281
|
+
const features = [];
|
|
1282
|
+
for (let i = 0; i < numFeatures; i++) {
|
|
1283
|
+
const name = featureNames[i];
|
|
1284
|
+
const { isEnabled, Component } = featureDefinitions[name];
|
|
1285
|
+
if (isEnabled(props) && Component) {
|
|
1286
|
+
features.push(/* @__PURE__ */ import_react11.default.createElement(Component, __spreadProps(__spreadValues({
|
|
1287
|
+
key: name
|
|
1288
|
+
}, props), {
|
|
1289
|
+
_utils: utils
|
|
1290
|
+
})));
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return features;
|
|
1294
|
+
}, "useFeatures");
|
|
1295
|
+
|
|
1296
|
+
// src/hooks/usePressable.tsx
|
|
1297
|
+
var import_react_native2 = __toModule(require("react-native"));
|
|
1298
|
+
var _a3, _b;
|
|
1299
|
+
var getPressable = (_b = (_a3 = import_react_native2.Pressable) == null ? void 0 : _a3["type"]) == null ? void 0 : _b["render"];
|
|
1300
|
+
var usePressable = /* @__PURE__ */ __name((props) => {
|
|
1301
|
+
const out = getPressable(props);
|
|
1302
|
+
const _a4 = out.props, { children, style } = _a4, pressableProps = __objRest(_a4, ["children", "style"]);
|
|
1303
|
+
return [pressableProps, style];
|
|
1304
|
+
}, "usePressable");
|
|
1305
|
+
|
|
1306
|
+
// src/createComponent.tsx
|
|
1307
|
+
var mouseUps = new Set();
|
|
1308
|
+
if (typeof document !== "undefined") {
|
|
1309
|
+
document.addEventListener("mouseup", () => {
|
|
1310
|
+
mouseUps.forEach((x) => x());
|
|
1311
|
+
mouseUps.clear();
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
function createComponent(configIn) {
|
|
1315
|
+
let staticConfig;
|
|
1316
|
+
if ("parsed" in configIn) {
|
|
1317
|
+
staticConfig = configIn;
|
|
1318
|
+
} else {
|
|
1319
|
+
staticConfig = parseStaticConfig(configIn);
|
|
1320
|
+
}
|
|
1321
|
+
const { Component, validStyles: validStyles3, isText, isZStack } = staticConfig;
|
|
1322
|
+
const validStyleProps = validStyles3 ?? import_helpers4.stylePropsView;
|
|
1323
|
+
let defaultProps = null;
|
|
1324
|
+
let tamaguiConfig;
|
|
1325
|
+
let defaultsStyle;
|
|
1326
|
+
let defaultsClassName = "";
|
|
1327
|
+
let initialTheme;
|
|
1328
|
+
const component = (0, import_react12.forwardRef)((props, forwardedRef) => {
|
|
1329
|
+
var _a4;
|
|
1330
|
+
const {
|
|
1331
|
+
tag,
|
|
1332
|
+
hitSlop,
|
|
1333
|
+
children,
|
|
1334
|
+
pointerEvents,
|
|
1335
|
+
onPress,
|
|
1336
|
+
onPressIn,
|
|
1337
|
+
onPressOut,
|
|
1338
|
+
onHoverIn,
|
|
1339
|
+
onHoverOut,
|
|
1340
|
+
space,
|
|
1341
|
+
disabled,
|
|
1342
|
+
onMouseEnter,
|
|
1343
|
+
onMouseLeave,
|
|
1344
|
+
hrefAttrs,
|
|
1345
|
+
onMoveShouldSetResponder,
|
|
1346
|
+
onMoveShouldSetResponderCapture,
|
|
1347
|
+
onResponderEnd,
|
|
1348
|
+
onResponderGrant,
|
|
1349
|
+
onResponderMove,
|
|
1350
|
+
onResponderReject,
|
|
1351
|
+
onResponderRelease,
|
|
1352
|
+
onResponderStart,
|
|
1353
|
+
onResponderTerminate,
|
|
1354
|
+
onResponderTerminationRequest,
|
|
1355
|
+
onScrollShouldSetResponder,
|
|
1356
|
+
onScrollShouldSetResponderCapture,
|
|
1357
|
+
onSelectionChangeShouldSetResponder,
|
|
1358
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
1359
|
+
onStartShouldSetResponder,
|
|
1360
|
+
onStartShouldSetResponderCapture,
|
|
1361
|
+
onMouseDown,
|
|
1362
|
+
onClick,
|
|
1363
|
+
onLayout
|
|
1364
|
+
} = props;
|
|
1365
|
+
const forceUpdate = useForceUpdate();
|
|
1366
|
+
const features = useFeatures(props, { forceUpdate });
|
|
1367
|
+
const manager = (0, import_react12.useContext)(ThemeManagerContext);
|
|
1368
|
+
const [state, set_] = (0, import_react12.useState)(() => ({
|
|
1369
|
+
hover: false,
|
|
1370
|
+
press: false,
|
|
1371
|
+
pressIn: false,
|
|
1372
|
+
theme: manager.name
|
|
1373
|
+
}));
|
|
1374
|
+
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
1375
|
+
for (const key in next) {
|
|
1376
|
+
if (prev[key] !== next[key]) {
|
|
1377
|
+
return __spreadValues(__spreadValues({}, prev), next);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return prev;
|
|
1381
|
+
}), "set");
|
|
1382
|
+
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
1383
|
+
import_react12.Children.toArray(props.children).forEach((item) => {
|
|
1384
|
+
if (typeof item === "string") {
|
|
1385
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
const hasTextAncestor = isWeb ? (0, import_react12.useContext)(TextAncestorContext) : false;
|
|
1390
|
+
const hostRef = (0, import_react12.useRef)(null);
|
|
1391
|
+
if (isWeb) {
|
|
1392
|
+
rnw.useResponderEvents(hostRef, {
|
|
1393
|
+
onMoveShouldSetResponder,
|
|
1394
|
+
onMoveShouldSetResponderCapture,
|
|
1395
|
+
onResponderEnd,
|
|
1396
|
+
onResponderGrant,
|
|
1397
|
+
onResponderMove,
|
|
1398
|
+
onResponderReject,
|
|
1399
|
+
onResponderRelease,
|
|
1400
|
+
onResponderStart,
|
|
1401
|
+
onResponderTerminate,
|
|
1402
|
+
onResponderTerminationRequest,
|
|
1403
|
+
onScrollShouldSetResponder,
|
|
1404
|
+
onScrollShouldSetResponderCapture,
|
|
1405
|
+
onSelectionChangeShouldSetResponder,
|
|
1406
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
1407
|
+
onStartShouldSetResponder,
|
|
1408
|
+
onStartShouldSetResponderCapture
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
const isTracking = (0, import_react12.useRef)(false);
|
|
1412
|
+
const { viewProps, pseudos: pseudos2, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
|
|
1413
|
+
const internal = (0, import_react12.useRef)();
|
|
1414
|
+
if (!internal.current) {
|
|
1415
|
+
internal.current = {
|
|
1416
|
+
isMounted: true
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
(0, import_react12.useEffect)(() => {
|
|
1420
|
+
internal.current.isMounted = true;
|
|
1421
|
+
const dispose = manager == null ? void 0 : manager.onChangeTheme((name) => {
|
|
1422
|
+
if (isTracking.current) {
|
|
1423
|
+
set({ theme: name });
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
return () => {
|
|
1427
|
+
dispose();
|
|
1428
|
+
mouseUps.delete(unPress);
|
|
1429
|
+
isTracking.current = false;
|
|
1430
|
+
internal.current.isMounted = false;
|
|
1431
|
+
};
|
|
1432
|
+
}, [manager]);
|
|
1433
|
+
const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
|
|
1434
|
+
const ReactView = !isWeb ? import_react_native3.View : element || (hasTextAncestor ? "span" : "div");
|
|
1435
|
+
const ReactText = !isWeb ? import_react_native3.Text : element || "span";
|
|
1436
|
+
const ViewComponent = isText ? ReactText : ReactView;
|
|
1437
|
+
const isHovering = !isTouchDevice && !disabled && pseudos2 && state.hover;
|
|
1438
|
+
const isPressing = !disabled && pseudos2 && state.press;
|
|
1439
|
+
const styles = [
|
|
1440
|
+
style,
|
|
1441
|
+
isHovering ? pseudos2.hoverStyle || null : null,
|
|
1442
|
+
isPressing ? pseudos2.pressStyle || null : null
|
|
1443
|
+
];
|
|
1444
|
+
if (isWeb) {
|
|
1445
|
+
const stylesClassNames = useStylesAsClassname(styles);
|
|
1446
|
+
const classList = isText ? [
|
|
1447
|
+
defaultsClassName,
|
|
1448
|
+
classNames,
|
|
1449
|
+
stylesClassNames,
|
|
1450
|
+
props.className
|
|
1451
|
+
] : [defaultsClassName, props.className, classNames, stylesClassNames];
|
|
1452
|
+
const className = (0, import_helpers4.concatClassName)(...classList);
|
|
1453
|
+
if (process.env.NODE_ENV === "development") {
|
|
1454
|
+
if (props["debug"]) {
|
|
1455
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
viewProps.className = className;
|
|
1459
|
+
} else {
|
|
1460
|
+
viewProps.style = styles;
|
|
1461
|
+
}
|
|
1462
|
+
if (pointerEvents) {
|
|
1463
|
+
viewProps.pointerEvents = pointerEvents;
|
|
1464
|
+
}
|
|
1465
|
+
if (isWeb) {
|
|
1466
|
+
const platformMethodsRef = rnw.usePlatformMethods(viewProps);
|
|
1467
|
+
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
|
|
1468
|
+
viewProps.ref = setRef;
|
|
1469
|
+
if (props.href != null && hrefAttrs != null) {
|
|
1470
|
+
const { download, rel, target } = hrefAttrs;
|
|
1471
|
+
if (download != null) {
|
|
1472
|
+
viewProps.download = download;
|
|
1473
|
+
}
|
|
1474
|
+
if (rel != null) {
|
|
1475
|
+
viewProps.rel = rel;
|
|
1476
|
+
}
|
|
1477
|
+
if (typeof target === "string") {
|
|
1478
|
+
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
} else {
|
|
1482
|
+
if (forwardedRef) {
|
|
1483
|
+
viewProps.ref = forwardedRef;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
const attachPress = !!(pseudos2 && pseudos2.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
1487
|
+
const attachHover = isWeb && !isTouchDevice && !!(pseudos2 && pseudos2.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
1488
|
+
const shouldAttach = internal.current.hasEverHadEvents || attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onClick" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
|
|
1489
|
+
if (shouldAttach) {
|
|
1490
|
+
internal.current.hasEverHadEvents = true;
|
|
1491
|
+
}
|
|
1492
|
+
const unPress = (0, import_react12.useCallback)(() => {
|
|
1493
|
+
if (!internal.current.isMounted)
|
|
1494
|
+
return;
|
|
1495
|
+
set({
|
|
1496
|
+
press: false,
|
|
1497
|
+
pressIn: false
|
|
1498
|
+
});
|
|
1499
|
+
}, []);
|
|
1500
|
+
const events = shouldAttach ? __spreadProps(__spreadValues(__spreadValues({}, !isWeb && {
|
|
1501
|
+
onPressOut: (e) => {
|
|
1502
|
+
unPress();
|
|
1503
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
1504
|
+
}
|
|
1505
|
+
}), isWeb && !isTouchDevice && {
|
|
1506
|
+
onMouseEnter: attachHover || attachPress ? (e) => {
|
|
1507
|
+
let next = {};
|
|
1508
|
+
if (attachHover) {
|
|
1509
|
+
next.hover = true;
|
|
1510
|
+
}
|
|
1511
|
+
if (state.pressIn) {
|
|
1512
|
+
next.press = true;
|
|
1513
|
+
}
|
|
1514
|
+
if (Object.keys(next).length) {
|
|
1515
|
+
set(next);
|
|
1516
|
+
}
|
|
1517
|
+
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
1518
|
+
onMouseEnter == null ? void 0 : onMouseEnter(e);
|
|
1519
|
+
} : void 0,
|
|
1520
|
+
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
1521
|
+
let next = {};
|
|
1522
|
+
mouseUps.add(unPress);
|
|
1523
|
+
if (attachHover) {
|
|
1524
|
+
next.hover = false;
|
|
1525
|
+
}
|
|
1526
|
+
if (state.pressIn) {
|
|
1527
|
+
next.press = false;
|
|
1528
|
+
next.pressIn = false;
|
|
1529
|
+
}
|
|
1530
|
+
if (Object.keys(next).length) {
|
|
1531
|
+
set(next);
|
|
1532
|
+
}
|
|
1533
|
+
onHoverOut == null ? void 0 : onHoverOut(e);
|
|
1534
|
+
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
1535
|
+
} : void 0
|
|
1536
|
+
}), {
|
|
1537
|
+
onMouseDown: attachPress ? (e) => {
|
|
1538
|
+
set({
|
|
1539
|
+
press: true,
|
|
1540
|
+
pressIn: true
|
|
1541
|
+
});
|
|
1542
|
+
onPressIn == null ? void 0 : onPressIn(e);
|
|
1543
|
+
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
1544
|
+
} : onPressIn,
|
|
1545
|
+
onClick: attachPress ? (e) => {
|
|
1546
|
+
onPress == null ? void 0 : onPress(e);
|
|
1547
|
+
onClick == null ? void 0 : onClick(e);
|
|
1548
|
+
unPress();
|
|
1549
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
1550
|
+
} : onPressOut
|
|
1551
|
+
}) : null;
|
|
1552
|
+
if (events) {
|
|
1553
|
+
if (typeof ViewComponent !== "string") {
|
|
1554
|
+
const [pressProps] = usePressable({
|
|
1555
|
+
disabled,
|
|
1556
|
+
hitSlop,
|
|
1557
|
+
onPressIn: events.onMouseDown,
|
|
1558
|
+
onPressOut: events.onPressOut,
|
|
1559
|
+
onPress: events.onClick
|
|
1560
|
+
});
|
|
1561
|
+
Object.assign(viewProps, pressProps);
|
|
1562
|
+
} else {
|
|
1563
|
+
Object.assign(viewProps, events);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
const childEls = spacedChildren({
|
|
1567
|
+
children,
|
|
1568
|
+
space,
|
|
1569
|
+
flexDirection: props.flexDirection || (defaultProps == null ? void 0 : defaultProps.flexDirection),
|
|
1570
|
+
isZStack
|
|
1571
|
+
});
|
|
1572
|
+
let content;
|
|
1573
|
+
if (isWeb && rnw) {
|
|
1574
|
+
const domProps = rnw.createDOMProps(viewProps);
|
|
1575
|
+
const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
|
|
1576
|
+
Object.assign(viewProps, domProps);
|
|
1577
|
+
viewProps.className = className;
|
|
1578
|
+
content = (0, import_react12.createElement)(ViewComponent, viewProps, childEls);
|
|
1579
|
+
} else {
|
|
1580
|
+
content = (0, import_react12.createElement)(ViewComponent, viewProps, childEls);
|
|
1581
|
+
}
|
|
1582
|
+
const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor;
|
|
1583
|
+
if (shouldWrapTextAncestor) {
|
|
1584
|
+
content = (0, import_react12.createElement)(TextAncestorContext.Provider, { value: true }, content);
|
|
1585
|
+
}
|
|
1586
|
+
if (process.env.NODE_ENV === "development") {
|
|
1587
|
+
if (props["debug"]) {
|
|
1588
|
+
viewProps["debug"] = true;
|
|
1589
|
+
console.log("\u{1F95A} props in:", props);
|
|
1590
|
+
console.log("\u{1F95A} props out:", viewProps);
|
|
1591
|
+
console.log((_a4 = props.onClick) == null ? void 0 : _a4.toString());
|
|
1592
|
+
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos: pseudos2, content, childEls });
|
|
1593
|
+
if (isWeb) {
|
|
1594
|
+
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, features, content);
|
|
1599
|
+
});
|
|
1600
|
+
onConfiguredOnce((conf3) => {
|
|
1601
|
+
var _a4;
|
|
1602
|
+
tamaguiConfig = conf3;
|
|
1603
|
+
initialTheme = conf3.themes[conf3.defaultTheme || Object.keys(conf3.themes)[0]];
|
|
1604
|
+
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
1605
|
+
if (isWeb) {
|
|
1606
|
+
if (next.classNames) {
|
|
1607
|
+
defaultsClassName += next.classNames + " ";
|
|
1608
|
+
}
|
|
1609
|
+
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
|
|
1610
|
+
} else {
|
|
1611
|
+
if (!hasWarnedOnce) {
|
|
1612
|
+
hasWarnedOnce = true;
|
|
1613
|
+
console.log("\u26A0\uFE0F we need to account for default styles for media queries");
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
component.defaultProps = __spreadValues(__spreadValues({}, next.viewProps), component.defaultProps);
|
|
1617
|
+
if (process.env.NODE_ENV === "development") {
|
|
1618
|
+
if ((_a4 = staticConfig.defaultProps) == null ? void 0 : _a4.debug) {
|
|
1619
|
+
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
component["staticConfig"] = __spreadValues({
|
|
1624
|
+
validStyles: validStyleProps
|
|
1625
|
+
}, staticConfig);
|
|
1626
|
+
const res = component;
|
|
1627
|
+
res["extractable"] = (Component2) => {
|
|
1628
|
+
Component2["staticConfig"] = extendStaticConfig(res, {
|
|
1629
|
+
neverFlatten: true,
|
|
1630
|
+
defaultProps: Component2.defaultProps
|
|
1631
|
+
});
|
|
1632
|
+
return Component2;
|
|
1633
|
+
};
|
|
1634
|
+
return res;
|
|
1635
|
+
}
|
|
1636
|
+
__name(createComponent, "createComponent");
|
|
1637
|
+
var hasWarnedOnce = false;
|
|
1638
|
+
var Spacer = createComponent({
|
|
1639
|
+
defaultProps: __spreadProps(__spreadValues({}, stackDefaultStyles), {
|
|
1640
|
+
size: true
|
|
1641
|
+
}),
|
|
1642
|
+
variants: {
|
|
1643
|
+
size: {
|
|
1644
|
+
"...size": (size, { tokens }) => {
|
|
1645
|
+
size = size == true ? "$true" : size;
|
|
1646
|
+
return {
|
|
1647
|
+
width: tokens.size[size] ?? size,
|
|
1648
|
+
height: tokens.size[size] ?? size
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1652
|
+
direction: {
|
|
1653
|
+
horizontal: {
|
|
1654
|
+
height: 0
|
|
1655
|
+
},
|
|
1656
|
+
vertical: {
|
|
1657
|
+
width: 0
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
function spacedChildren({
|
|
1663
|
+
isZStack,
|
|
1664
|
+
children,
|
|
1665
|
+
space,
|
|
1666
|
+
flexDirection
|
|
1667
|
+
}) {
|
|
1668
|
+
var _a4;
|
|
1669
|
+
if (!space && !isZStack) {
|
|
1670
|
+
return children;
|
|
1671
|
+
}
|
|
1672
|
+
const childrenList = import_react12.Children.toArray(children);
|
|
1673
|
+
const len = childrenList.length;
|
|
1674
|
+
if (len === 1) {
|
|
1675
|
+
return children;
|
|
1676
|
+
}
|
|
1677
|
+
const next = [];
|
|
1678
|
+
for (const [index, child] of childrenList.entries()) {
|
|
1679
|
+
if (child === null || child === void 0) {
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
const key = `${(child == null ? void 0 : child["key"]) ?? index}`;
|
|
1683
|
+
next.push(/* @__PURE__ */ import_react12.default.createElement(import_react12.Fragment, {
|
|
1684
|
+
key
|
|
1685
|
+
}, isZStack ? /* @__PURE__ */ import_react12.default.createElement(Absolute, null, child) : child));
|
|
1686
|
+
if ((_a4 = child == null ? void 0 : child["type"]) == null ? void 0 : _a4["isVisuallyHidden"]) {
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
if (index !== len - 1) {
|
|
1690
|
+
if (space) {
|
|
1691
|
+
next.push(/* @__PURE__ */ import_react12.default.createElement(Spacer, {
|
|
1692
|
+
key: `${key}_spacer`,
|
|
1693
|
+
direction: flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical",
|
|
1694
|
+
size: space
|
|
1695
|
+
}));
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return next;
|
|
1700
|
+
}
|
|
1701
|
+
__name(spacedChildren, "spacedChildren");
|
|
1702
|
+
var Absolute = /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ import_react12.default.createElement(import_react_native3.View, {
|
|
1703
|
+
style: sheet.fullscreen
|
|
1704
|
+
}, children), "Absolute");
|
|
1705
|
+
var sheet = import_react_native3.StyleSheet.create({
|
|
1706
|
+
fullscreen: {
|
|
1707
|
+
position: "absolute",
|
|
1708
|
+
top: 0,
|
|
1709
|
+
left: 0,
|
|
1710
|
+
right: 0,
|
|
1711
|
+
bottom: 0
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
// src/createShorthands.ts
|
|
1716
|
+
function createShorthands(shorthands) {
|
|
1717
|
+
return Object.freeze(shorthands);
|
|
1718
|
+
}
|
|
1719
|
+
__name(createShorthands, "createShorthands");
|
|
1720
|
+
|
|
1721
|
+
// src/createTheme.ts
|
|
1722
|
+
var createTheme = /* @__PURE__ */ __name((theme) => {
|
|
1723
|
+
const res = {};
|
|
1724
|
+
for (const key in theme) {
|
|
1725
|
+
const val = theme[key];
|
|
1726
|
+
if (!(val instanceof Variable)) {
|
|
1727
|
+
res[key] = createVariable({
|
|
1728
|
+
name: key,
|
|
1729
|
+
val
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return res;
|
|
1734
|
+
}, "createTheme");
|
|
1735
|
+
|
|
1736
|
+
// src/createFont.ts
|
|
1737
|
+
var createFont = /* @__PURE__ */ __name((font) => {
|
|
1738
|
+
const sizeKeys = Object.keys(font.size);
|
|
1739
|
+
for (const key in font) {
|
|
1740
|
+
if (key === "size" || key === "family")
|
|
1741
|
+
continue;
|
|
1742
|
+
const section = font[key];
|
|
1743
|
+
const keys = Object.keys(section);
|
|
1744
|
+
let fillVal = section[keys[0]];
|
|
1745
|
+
for (const sKey of sizeKeys) {
|
|
1746
|
+
if (!(sKey in section)) {
|
|
1747
|
+
section[sKey] = fillVal;
|
|
1748
|
+
} else {
|
|
1749
|
+
fillVal = section[sKey];
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return Object.freeze(font);
|
|
1754
|
+
}, "createFont");
|
|
1755
|
+
|
|
1756
|
+
// src/createTokens.ts
|
|
1757
|
+
function createTokens(tokens) {
|
|
1758
|
+
return setupTokens(tokens);
|
|
1759
|
+
}
|
|
1760
|
+
__name(createTokens, "createTokens");
|
|
1761
|
+
function setupTokens(tokens) {
|
|
1762
|
+
return mapTokensToVariables(tokens);
|
|
1763
|
+
}
|
|
1764
|
+
__name(setupTokens, "setupTokens");
|
|
1765
|
+
var mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
|
|
1766
|
+
const res = {};
|
|
1767
|
+
for (const key in tokens) {
|
|
1768
|
+
const val = tokens[key];
|
|
1769
|
+
const name = parentPath ? `${parentPath}-${key}` : key;
|
|
1770
|
+
if (val && typeof val === "object") {
|
|
1771
|
+
res[key] = mapTokensToVariables(tokens[key], name);
|
|
1772
|
+
} else {
|
|
1773
|
+
res[key] = createVariable({ val, name });
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return res;
|
|
1777
|
+
}, "mapTokensToVariables");
|
|
1778
|
+
|
|
1779
|
+
// src/styled.ts
|
|
1780
|
+
function styled(Component, options, staticExtractionOptions) {
|
|
1781
|
+
const staticConfigProps = (() => {
|
|
1782
|
+
if (options) {
|
|
1783
|
+
const _a4 = options, { variants } = _a4, defaultProps = __objRest(_a4, ["variants"]);
|
|
1784
|
+
return __spreadProps(__spreadValues({}, staticExtractionOptions), { variants, defaultProps });
|
|
1785
|
+
}
|
|
1786
|
+
return {};
|
|
1787
|
+
})();
|
|
1788
|
+
const config = extendStaticConfig(Component, staticConfigProps);
|
|
1789
|
+
const component = createComponent(config);
|
|
1790
|
+
return component;
|
|
1791
|
+
}
|
|
1792
|
+
__name(styled, "styled");
|
|
1793
|
+
|
|
1794
|
+
// src/helpers/themeable.tsx
|
|
1795
|
+
var import_react15 = __toModule(require("react"));
|
|
1796
|
+
|
|
1797
|
+
// src/views/ThemeInverse.tsx
|
|
1798
|
+
var import_react14 = __toModule(require("react"));
|
|
1799
|
+
|
|
1800
|
+
// src/hooks/useTheme.tsx
|
|
1801
|
+
var import_react13 = __toModule(require("react"));
|
|
1802
|
+
var areEqualSets = /* @__PURE__ */ __name((a, b) => {
|
|
1803
|
+
if (a.size !== b.size)
|
|
1804
|
+
return false;
|
|
1805
|
+
for (const val in a) {
|
|
1806
|
+
if (!b.has(val)) {
|
|
1807
|
+
return false;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return true;
|
|
1811
|
+
}, "areEqualSets");
|
|
1812
|
+
var useThemeName = /* @__PURE__ */ __name(() => {
|
|
1813
|
+
const parent = (0, import_react13.useContext)(ThemeManagerContext);
|
|
1814
|
+
const [name, setName] = (0, import_react13.useState)(parent.name);
|
|
1815
|
+
(0, import_react13.useEffect)(() => {
|
|
1816
|
+
return parent.onChangeTheme((next) => {
|
|
1817
|
+
setName((prev) => {
|
|
1818
|
+
if (prev === next)
|
|
1819
|
+
return prev;
|
|
1820
|
+
return next;
|
|
1821
|
+
});
|
|
1822
|
+
});
|
|
1823
|
+
}, [parent]);
|
|
1824
|
+
return name || "light";
|
|
1825
|
+
}, "useThemeName");
|
|
1826
|
+
var useDefaultThemeName = /* @__PURE__ */ __name(() => {
|
|
1827
|
+
return (0, import_react13.useContext)(ThemeContext)[GET_DEFAULT_THEME];
|
|
1828
|
+
}, "useDefaultThemeName");
|
|
1829
|
+
var useTheme = /* @__PURE__ */ __name(() => {
|
|
1830
|
+
const forceUpdate = useForceUpdate();
|
|
1831
|
+
const manager = (0, import_react13.useContext)(ThemeManagerContext);
|
|
1832
|
+
const themes = (0, import_react13.useContext)(ThemeContext);
|
|
1833
|
+
const state = (0, import_react13.useRef)();
|
|
1834
|
+
if (!state.current) {
|
|
1835
|
+
state.current = {
|
|
1836
|
+
uuid: {},
|
|
1837
|
+
keys: new Set(),
|
|
1838
|
+
isRendering: true
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
state.current.isRendering = true;
|
|
1842
|
+
useIsomorphicLayoutEffect(() => {
|
|
1843
|
+
const st = state.current;
|
|
1844
|
+
st.isRendering = false;
|
|
1845
|
+
const cur = manager.keys.get(st.uuid);
|
|
1846
|
+
if (!cur || !areEqualSets(st.keys, cur)) {
|
|
1847
|
+
manager.track(st.uuid, st.keys);
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
(0, import_react13.useEffect)(() => {
|
|
1851
|
+
return manager.onUpdate(state.current.uuid, forceUpdate);
|
|
1852
|
+
}, []);
|
|
1853
|
+
const theme = (manager.name ? themes[manager.name] : themes.light) ?? themes.light;
|
|
1854
|
+
return (0, import_react13.useMemo)(() => {
|
|
1855
|
+
return new Proxy(theme, {
|
|
1856
|
+
get(_, key) {
|
|
1857
|
+
const name = manager.name;
|
|
1858
|
+
if (!name) {
|
|
1859
|
+
return Reflect.get(_, key);
|
|
1860
|
+
}
|
|
1861
|
+
let activeTheme = themes[name];
|
|
1862
|
+
if (!activeTheme) {
|
|
1863
|
+
console.error("No theme by name", name, "only:", themes, "keeping current theme");
|
|
1864
|
+
activeTheme = theme;
|
|
1865
|
+
}
|
|
1866
|
+
const val = activeTheme[key];
|
|
1867
|
+
if (process.env.NODE_ENV === "development") {
|
|
1868
|
+
if (typeof val === "undefined") {
|
|
1869
|
+
throw new Error(`No theme value "${String(key)}" in: ${Object.keys(activeTheme)}`);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (state.current.isRendering) {
|
|
1873
|
+
state.current.keys.add(key);
|
|
1874
|
+
}
|
|
1875
|
+
return new Variable({ val: val.val, name: key });
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
}, []);
|
|
1879
|
+
}, "useTheme");
|
|
1880
|
+
|
|
1881
|
+
// src/views/ThemeInverse.tsx
|
|
1882
|
+
var inversions = {
|
|
1883
|
+
light: "dark",
|
|
1884
|
+
dark: "light"
|
|
1885
|
+
};
|
|
1886
|
+
function setThemeInversions(next) {
|
|
1887
|
+
inversions = next;
|
|
1888
|
+
}
|
|
1889
|
+
__name(setThemeInversions, "setThemeInversions");
|
|
1890
|
+
var ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
1891
|
+
const themeName = useThemeName();
|
|
1892
|
+
const defaultTheme = useDefaultThemeName();
|
|
1893
|
+
const name = inversions[themeName] || inversions[defaultTheme] || null;
|
|
1894
|
+
console.log("todo fixme invert", { themeName, defaultTheme, next: name });
|
|
1895
|
+
return /* @__PURE__ */ import_react14.default.createElement(Theme, {
|
|
1896
|
+
name
|
|
1897
|
+
}, props.children);
|
|
1898
|
+
}, "ThemeInverse");
|
|
1899
|
+
|
|
1900
|
+
// src/helpers/themeable.tsx
|
|
1901
|
+
var themeable = /* @__PURE__ */ __name(function graphql(component) {
|
|
1902
|
+
const withThemeComponent = (0, import_react15.forwardRef)(/* @__PURE__ */ __name(function WithTheme(_a4, ref) {
|
|
1903
|
+
var _b2 = _a4, { themeInverse } = _b2, rest = __objRest(_b2, ["themeInverse"]);
|
|
1904
|
+
const el = import_react15.default.createElement(component, __spreadProps(__spreadValues({}, rest), { ref }));
|
|
1905
|
+
if (themeInverse) {
|
|
1906
|
+
return /* @__PURE__ */ import_react15.default.createElement(ThemeInverse, null, el);
|
|
1907
|
+
}
|
|
1908
|
+
if (rest.theme) {
|
|
1909
|
+
return /* @__PURE__ */ import_react15.default.createElement(Theme, {
|
|
1910
|
+
name: rest.theme || null
|
|
1911
|
+
}, el);
|
|
1912
|
+
}
|
|
1913
|
+
return el;
|
|
1914
|
+
}, "WithTheme"));
|
|
1915
|
+
const withTheme = withThemeComponent;
|
|
1916
|
+
withTheme.displayName = `Themed(${(component == null ? void 0 : component.displayName) || (component == null ? void 0 : component.name) || "Anonymous"})`;
|
|
1917
|
+
return withTheme;
|
|
1918
|
+
}, "graphql");
|
|
1919
|
+
|
|
1920
|
+
// src/views/Animated.tsx
|
|
1921
|
+
var import_react16 = __toModule(require("react"));
|
|
1922
|
+
var import_react_native4 = __toModule(require("react-native"));
|
|
1923
|
+
|
|
1924
|
+
// src/views/Stack.tsx
|
|
1925
|
+
var Stack = createComponent({
|
|
1926
|
+
defaultProps: __spreadProps(__spreadValues({}, stackDefaultStyles), {
|
|
1927
|
+
flexDirection: "column"
|
|
1928
|
+
})
|
|
1929
|
+
});
|
|
1930
|
+
|
|
1931
|
+
// src/views/Animated.tsx
|
|
1932
|
+
var defaultAnimation = {
|
|
1933
|
+
from: {
|
|
1934
|
+
opacity: 0,
|
|
1935
|
+
translateY: 12
|
|
1936
|
+
},
|
|
1937
|
+
to: {
|
|
1938
|
+
opacity: 1,
|
|
1939
|
+
translateY: 0
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
var styleKeys = {
|
|
1943
|
+
opacity: true,
|
|
1944
|
+
backgroundColor: true,
|
|
1945
|
+
borderColor: true
|
|
1946
|
+
};
|
|
1947
|
+
var AnimatedStack = /* @__PURE__ */ __name((_a4) => {
|
|
1948
|
+
var _b2 = _a4, {
|
|
1949
|
+
animateState = "in",
|
|
1950
|
+
animation = defaultAnimation,
|
|
1951
|
+
velocity = 6,
|
|
1952
|
+
children,
|
|
1953
|
+
animated
|
|
1954
|
+
} = _b2, props = __objRest(_b2, [
|
|
1955
|
+
"animateState",
|
|
1956
|
+
"animation",
|
|
1957
|
+
"velocity",
|
|
1958
|
+
"children",
|
|
1959
|
+
"animated"
|
|
1960
|
+
]);
|
|
1961
|
+
const driver = useConstant(() => {
|
|
1962
|
+
return new import_react_native4.Animated.Value(0);
|
|
1963
|
+
});
|
|
1964
|
+
const animatedProps = (0, import_react16.useMemo)(() => {
|
|
1965
|
+
if (!animated) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
const styleProps = {};
|
|
1969
|
+
const transform = [];
|
|
1970
|
+
for (const key in animation.from) {
|
|
1971
|
+
const fromVal = animation.from[key];
|
|
1972
|
+
const toVal = animation.to[key];
|
|
1973
|
+
const interpolatedVal = driver.interpolate({
|
|
1974
|
+
inputRange: [0, 1],
|
|
1975
|
+
outputRange: [fromVal, toVal]
|
|
1976
|
+
});
|
|
1977
|
+
if (styleKeys[key]) {
|
|
1978
|
+
styleProps[key] = interpolatedVal;
|
|
1979
|
+
} else {
|
|
1980
|
+
transform.push({
|
|
1981
|
+
[key]: interpolatedVal
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return __spreadValues({ transform }, styleProps);
|
|
1986
|
+
}, [animated, animateState]);
|
|
1987
|
+
useIsomorphicLayoutEffect(() => {
|
|
1988
|
+
if (!animated) {
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1991
|
+
import_react_native4.Animated.spring(driver, {
|
|
1992
|
+
useNativeDriver: true,
|
|
1993
|
+
velocity,
|
|
1994
|
+
toValue: animateState === "in" ? 1 : 0
|
|
1995
|
+
}).start();
|
|
1996
|
+
}, [animated, animateState]);
|
|
1997
|
+
const childrenMemo = (0, import_react16.useMemo)(() => children, [children]);
|
|
1998
|
+
return /* @__PURE__ */ import_react16.default.createElement(Stack, __spreadValues(__spreadValues({
|
|
1999
|
+
animated
|
|
2000
|
+
}, props), animatedProps), childrenMemo);
|
|
2001
|
+
}, "AnimatedStack");
|
|
2002
|
+
|
|
2003
|
+
// src/static.ts
|
|
2004
|
+
var static_exports = {};
|
|
2005
|
+
__export(static_exports, {
|
|
2006
|
+
Spacer: () => Spacer,
|
|
2007
|
+
addMediaQueryListener: () => addMediaQueryListener,
|
|
2008
|
+
configureMedia: () => configureMedia,
|
|
2009
|
+
createComponent: () => createComponent,
|
|
2010
|
+
createFont: () => createFont,
|
|
2011
|
+
createTamagui: () => createTamagui,
|
|
2012
|
+
createTokens: () => createTokens,
|
|
2013
|
+
getHasConfigured: () => getHasConfigured,
|
|
2014
|
+
getMedia: () => getMedia,
|
|
2015
|
+
getSplitStyles: () => getSplitStyles,
|
|
2016
|
+
getStylesAtomic: () => getStylesAtomic,
|
|
2017
|
+
getTamaguiConfig: () => getTamaguiConfig,
|
|
2018
|
+
getThemeParentClassName: () => getThemeParentClassName,
|
|
2019
|
+
isObj: () => isObj,
|
|
2020
|
+
mapTokensToVariables: () => mapTokensToVariables,
|
|
2021
|
+
mediaObjectToString: () => mediaObjectToString,
|
|
2022
|
+
mediaQueryConfig: () => mediaQueryConfig,
|
|
2023
|
+
mediaState: () => mediaState,
|
|
2024
|
+
mouseUps: () => mouseUps,
|
|
2025
|
+
onConfiguredOnce: () => onConfiguredOnce,
|
|
2026
|
+
postProcessStyles: () => postProcessStyles,
|
|
2027
|
+
pseudos: () => pseudos,
|
|
2028
|
+
removeMediaQueryListener: () => removeMediaQueryListener,
|
|
2029
|
+
spacedChildren: () => spacedChildren,
|
|
2030
|
+
stackDefaultStyles: () => stackDefaultStyles,
|
|
2031
|
+
styled: () => styled,
|
|
2032
|
+
useDefaultThemeName: () => useDefaultThemeName,
|
|
2033
|
+
useMedia: () => useMedia,
|
|
2034
|
+
useTheme: () => useTheme,
|
|
2035
|
+
useThemeName: () => useThemeName
|
|
2036
|
+
});
|
|
2037
|
+
__reExport(static_exports, __toModule(require("@tamagui/helpers")));
|
|
2038
|
+
|
|
2039
|
+
// src/static/postProcessStyles.tsx
|
|
2040
|
+
var postProcessStyles = /* @__PURE__ */ __name((inStyles, staticConfig, theme) => {
|
|
2041
|
+
const { style, viewProps, pseudos: pseudos2, classNames } = getSplitStyles(inStyles, staticConfig, theme);
|
|
2042
|
+
const next = {};
|
|
2043
|
+
for (const s of style) {
|
|
2044
|
+
if (!s)
|
|
2045
|
+
continue;
|
|
2046
|
+
Object.assign(next, s);
|
|
2047
|
+
}
|
|
2048
|
+
Object.assign(next, pseudos2);
|
|
2049
|
+
return { style: next, viewProps, classNames };
|
|
2050
|
+
}, "postProcessStyles");
|
|
2051
|
+
|
|
2052
|
+
// src/views/Text.tsx
|
|
2053
|
+
var ellipseStyle = {
|
|
2054
|
+
maxWidth: "100%",
|
|
2055
|
+
overflow: "hidden",
|
|
2056
|
+
textOverflow: "ellipsis",
|
|
2057
|
+
whiteSpace: "nowrap"
|
|
2058
|
+
};
|
|
2059
|
+
var Text2 = createComponent({
|
|
2060
|
+
isText: true,
|
|
2061
|
+
defaultProps: {
|
|
2062
|
+
display: isWeb ? "inline" : "inline-flex",
|
|
2063
|
+
boxSizing: "border-box",
|
|
2064
|
+
fontFamily: "System",
|
|
2065
|
+
wordWrap: "break-word"
|
|
2066
|
+
},
|
|
2067
|
+
variants: {
|
|
2068
|
+
numberOfLines: {
|
|
2069
|
+
1: ellipseStyle,
|
|
2070
|
+
"[number]": (lines) => lines > 1 ? { WebkitLineClamp: 1 } : null
|
|
2071
|
+
},
|
|
2072
|
+
selectable: {
|
|
2073
|
+
true: {
|
|
2074
|
+
userSelect: "text"
|
|
2075
|
+
},
|
|
2076
|
+
false: {
|
|
2077
|
+
userSelect: "none"
|
|
2078
|
+
}
|
|
2079
|
+
},
|
|
2080
|
+
pressable: {
|
|
2081
|
+
true: {
|
|
2082
|
+
cursor: "pointer"
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
ellipse: {
|
|
2086
|
+
true: isWeb ? ellipseStyle : {
|
|
2087
|
+
numberOfLines: 1,
|
|
2088
|
+
lineBreakMode: "clip"
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
},
|
|
2092
|
+
deoptProps: new Set(isWeb ? [] : ["ellipse"]),
|
|
2093
|
+
validStyles: __spreadValues(__spreadValues(__spreadValues({}, static_exports.validStyles), static_exports.stylePropsTextOnly), isWeb && {
|
|
2094
|
+
userSelect: true,
|
|
2095
|
+
textOverflow: true,
|
|
2096
|
+
whiteSpace: true,
|
|
2097
|
+
wordWrap: true,
|
|
2098
|
+
selectable: true,
|
|
2099
|
+
cursor: true
|
|
2100
|
+
})
|
|
2101
|
+
});
|
|
2102
|
+
|
|
2103
|
+
// src/views/SafeAreaProvider.tsx
|
|
2104
|
+
var import_react17 = __toModule(require("react"));
|
|
2105
|
+
var import_react_native5 = __toModule(require("react-native"));
|
|
2106
|
+
var import_react_native_safe_area_context = __toModule(require("react-native-safe-area-context"));
|
|
2107
|
+
var defaultMetrics = null;
|
|
2108
|
+
var SafeAreaProvider = /* @__PURE__ */ __name(({
|
|
2109
|
+
initialWindowMetrics,
|
|
2110
|
+
children
|
|
2111
|
+
}) => {
|
|
2112
|
+
if (!initialWindowMetrics && !defaultMetrics) {
|
|
2113
|
+
defaultMetrics = import_react_native5.Platform.select({
|
|
2114
|
+
web: {
|
|
2115
|
+
frame: { x: 0, y: 0, width: 0, height: 0 },
|
|
2116
|
+
insets: { top: 0, left: 0, right: 0, bottom: 0 }
|
|
2117
|
+
},
|
|
2118
|
+
default: import_react_native_safe_area_context.initialWindowMetrics
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return /* @__PURE__ */ import_react17.default.createElement(import_react_native_safe_area_context.SafeAreaProvider, {
|
|
2122
|
+
initialMetrics: initialWindowMetrics ?? defaultMetrics
|
|
2123
|
+
}, children);
|
|
2124
|
+
}, "SafeAreaProvider");
|
|
2125
|
+
//# sourceMappingURL=index.cjs.map
|