@tamagui/core 1.0.0-alpha.11 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/constants/constants.js +14 -0
- package/dist/esm/constants/constants.js.map +7 -0
- package/dist/esm/constants/platform.js +19 -0
- package/dist/esm/constants/platform.js.map +7 -0
- package/dist/esm/constants/pseudos.js +18 -0
- package/dist/esm/constants/pseudos.js.map +7 -0
- package/dist/esm/constants/rnw.js +22 -0
- package/dist/esm/constants/rnw.js.map +7 -0
- package/dist/esm/createComponent.js +464 -0
- package/dist/esm/createComponent.js.map +7 -0
- package/dist/esm/createFont.js +28 -0
- package/dist/esm/createFont.js.map +7 -0
- package/dist/esm/createShorthands.js +10 -0
- package/dist/esm/createShorthands.js.map +7 -0
- package/dist/esm/createTamagui.js +168 -0
- package/dist/esm/createTamagui.js.map +7 -0
- package/dist/esm/createTheme.js +20 -0
- package/dist/esm/createTheme.js.map +7 -0
- package/dist/esm/createTokens.js +33 -0
- package/dist/esm/createTokens.js.map +7 -0
- package/dist/esm/createVariable.js +25 -0
- package/dist/esm/createVariable.js.map +7 -0
- package/dist/esm/helpers/addStylesUsingClassname.js +57 -0
- package/dist/esm/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +34 -0
- package/dist/esm/helpers/createMediaStyle.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +160 -0
- package/dist/esm/helpers/createPropMapper.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +25 -0
- package/dist/esm/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +59 -0
- package/dist/esm/helpers/extendStaticConfig.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.js +8 -0
- package/dist/esm/helpers/fixNativeShadow.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.native.js +30 -0
- package/dist/esm/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +150 -0
- package/dist/esm/helpers/getSplitStyles.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +83 -0
- package/dist/esm/helpers/getStylesAtomic.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.native.js +10 -0
- package/dist/esm/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +24 -0
- package/dist/esm/helpers/insertStyleRule.js.map +7 -0
- package/dist/esm/helpers/isObj.js +7 -0
- package/dist/esm/helpers/isObj.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +10 -0
- package/dist/esm/helpers/isTamaguiElement.js.map +7 -0
- package/dist/esm/helpers/matchMedia.js +18 -0
- package/dist/esm/helpers/matchMedia.js.map +7 -0
- package/dist/esm/helpers/matchMedia.native.js +9 -0
- package/dist/esm/helpers/matchMedia.native.js.map +7 -0
- package/dist/esm/helpers/themeable.js +26 -0
- package/dist/esm/helpers/themeable.js.map +7 -0
- package/dist/esm/helpers/validate.js +60 -0
- package/dist/esm/helpers/validate.js.map +7 -0
- package/dist/esm/hooks/useConstant.js +15 -0
- package/dist/esm/hooks/useConstant.js.map +7 -0
- package/dist/esm/hooks/useFeatures.js +63 -0
- package/dist/esm/hooks/useFeatures.js.map +7 -0
- package/dist/esm/hooks/useMedia.js +173 -0
- package/dist/esm/hooks/useMedia.js.map +7 -0
- package/dist/esm/hooks/usePressable.js +13 -0
- package/dist/esm/hooks/usePressable.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +89 -0
- package/dist/esm/hooks/useTheme.js.map +7 -0
- package/dist/esm/index.js +32 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/static/postProcessStyles.js +18 -0
- package/dist/esm/static/postProcessStyles.js.map +7 -0
- package/dist/esm/static.js +15 -0
- package/dist/esm/static.js.map +7 -0
- package/dist/esm/styled.js +21 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/views/Animated.js +79 -0
- package/dist/esm/views/Animated.js.map +7 -0
- package/dist/esm/views/Stack.js +12 -0
- package/dist/esm/views/Stack.js.map +7 -0
- package/dist/esm/views/Text.js +60 -0
- package/dist/esm/views/Text.js.map +7 -0
- package/dist/esm/views/TextAncestorContext.js +18 -0
- package/dist/esm/views/TextAncestorContext.js.map +7 -0
- package/dist/esm/views/Theme.js +68 -0
- package/dist/esm/views/Theme.js.map +7 -0
- package/dist/esm/views/ThemeContext.js +6 -0
- package/dist/esm/views/ThemeContext.js.map +7 -0
- package/dist/esm/views/ThemeInverse.js +26 -0
- package/dist/esm/views/ThemeInverse.js.map +7 -0
- package/dist/esm/views/ThemeManagerContext.js +61 -0
- package/dist/esm/views/ThemeManagerContext.js.map +7 -0
- package/dist/esm/views/ThemeProvider.js +45 -0
- package/dist/esm/views/ThemeProvider.js.map +7 -0
- package/dist/jsx/constants/constants.js +13 -0
- package/dist/jsx/constants/platform.js +18 -0
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/constants/rnw.js +21 -0
- package/dist/jsx/createComponent.js +458 -0
- package/dist/jsx/createFont.js +27 -0
- package/dist/jsx/createShorthands.js +9 -0
- package/dist/jsx/createTamagui.js +167 -0
- package/dist/jsx/createTheme.js +19 -0
- package/dist/jsx/createTokens.js +32 -0
- package/dist/jsx/createVariable.js +24 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +56 -0
- package/dist/jsx/helpers/createMediaStyle.js +33 -0
- package/dist/jsx/helpers/createPropMapper.js +159 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +19 -0
- package/dist/jsx/helpers/extendStaticConfig.js +58 -0
- package/dist/jsx/helpers/fixNativeShadow.js +7 -0
- package/dist/jsx/helpers/fixNativeShadow.native.js +29 -0
- package/dist/jsx/helpers/getSplitStyles.js +149 -0
- package/dist/jsx/helpers/getStylesAtomic.js +82 -0
- package/dist/jsx/helpers/getStylesAtomic.native.js +9 -0
- package/dist/jsx/helpers/insertStyleRule.js +23 -0
- package/dist/jsx/helpers/isObj.js +6 -0
- package/dist/jsx/helpers/isTamaguiElement.js +9 -0
- package/dist/jsx/helpers/matchMedia.js +17 -0
- package/dist/jsx/helpers/matchMedia.native.js +8 -0
- package/dist/jsx/helpers/themeable.js +23 -0
- package/dist/jsx/helpers/validate.js +59 -0
- package/dist/jsx/hooks/useConstant.js +14 -0
- package/dist/jsx/hooks/useFeatures.js +57 -0
- package/dist/jsx/hooks/useMedia.js +172 -0
- package/dist/jsx/hooks/usePressable.js +12 -0
- package/dist/jsx/hooks/useTheme.js +88 -0
- package/dist/jsx/index.js +31 -0
- package/dist/jsx/static/postProcessStyles.js +17 -0
- package/dist/jsx/static.js +14 -0
- package/dist/jsx/styled.js +20 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Animated.js +74 -0
- package/dist/jsx/views/Stack.js +11 -0
- package/dist/jsx/views/Text.js +59 -0
- package/dist/jsx/views/TextAncestorContext.js +14 -0
- package/dist/jsx/views/Theme.js +62 -0
- package/dist/jsx/views/ThemeContext.js +5 -0
- package/dist/jsx/views/ThemeInverse.js +22 -0
- package/dist/jsx/views/ThemeManagerContext.js +60 -0
- package/dist/jsx/views/ThemeProvider.js +39 -0
- package/package.json +10 -11
- package/src/createComponent.tsx +1 -1
- package/src/types.tsx +6 -6
- package/src/views/Text.tsx +2 -1
- package/types/constants/constants.d.ts +8 -0
- package/types/constants/constants.d.ts.map +1 -0
- package/types/constants/platform.d.ts +9 -0
- package/types/constants/platform.d.ts.map +1 -0
- package/types/constants/pseudos.d.ts +15 -0
- package/types/constants/pseudos.d.ts.map +1 -0
- package/types/constants/rnw.d.ts +2 -0
- package/types/constants/rnw.d.ts.map +1 -0
- package/types/createComponent.d.ts +17 -0
- package/types/createComponent.d.ts.map +1 -0
- package/types/createFont.d.ts +3 -0
- package/types/createFont.d.ts.map +1 -0
- package/types/createShorthands.d.ts +2 -0
- package/types/createShorthands.d.ts.map +1 -0
- package/types/createTamagui.d.ts +38 -0
- package/types/createTamagui.d.ts.map +1 -0
- package/types/createTheme.d.ts +5 -0
- package/types/createTheme.d.ts.map +1 -0
- package/types/createTokens.d.ts +55 -0
- package/types/createTokens.d.ts.map +1 -0
- package/types/createVariable.d.ts +15 -0
- package/types/createVariable.d.ts.map +1 -0
- package/types/helpers/addStylesUsingClassname.d.ts +3 -0
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts +8 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts +3 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts +5 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/types/helpers/extendStaticConfig.d.ts +5 -0
- package/types/helpers/extendStaticConfig.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.d.ts +2 -0
- package/types/helpers/fixNativeShadow.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.native.d.ts +2 -0
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +15 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.d.ts +3 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.native.d.ts +2 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts +2 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -0
- package/types/helpers/isObj.d.ts +2 -0
- package/types/helpers/isObj.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts +3 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -0
- package/types/helpers/matchMedia.d.ts +2 -0
- package/types/helpers/matchMedia.d.ts.map +1 -0
- package/types/helpers/matchMedia.native.d.ts +3 -0
- package/types/helpers/matchMedia.native.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts +10 -0
- package/types/helpers/themeable.d.ts.map +1 -0
- package/types/helpers/validate.d.ts +4 -0
- package/types/helpers/validate.d.ts.map +1 -0
- package/types/hooks/useConstant.d.ts +2 -0
- package/types/hooks/useConstant.d.ts.map +1 -0
- package/types/hooks/useFeatures.d.ts +5 -0
- package/types/hooks/useFeatures.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts +16 -0
- package/types/hooks/useMedia.d.ts.map +1 -0
- package/types/hooks/usePressable.d.ts +3 -0
- package/types/hooks/usePressable.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +20 -0
- package/types/hooks/useTheme.d.ts.map +1 -0
- package/types/index.d.ts +29 -0
- package/types/index.d.ts.map +1 -0
- package/types/static/postProcessStyles.d.ts +7 -0
- package/types/static/postProcessStyles.d.ts.map +1 -0
- package/types/static.d.ts +15 -0
- package/types/static.d.ts.map +1 -0
- package/types/styled.d.ts +21 -0
- package/types/styled.d.ts.map +1 -0
- package/types/types.d.ts +306 -0
- package/types/types.d.ts.map +1 -0
- package/types/views/Animated.d.ts +15 -0
- package/types/views/Animated.d.ts.map +1 -0
- package/types/views/Stack.d.ts +3 -0
- package/types/views/Stack.d.ts.map +1 -0
- package/types/views/Text.d.ts +3 -0
- package/types/views/Text.d.ts.map +1 -0
- package/types/views/TextAncestorContext.d.ts +3 -0
- package/types/views/TextAncestorContext.d.ts.map +1 -0
- package/types/views/Theme.d.ts +8 -0
- package/types/views/Theme.d.ts.map +1 -0
- package/types/views/ThemeContext.d.ts +18 -0
- package/types/views/ThemeContext.d.ts.map +1 -0
- package/types/views/ThemeInverse.d.ts +10 -0
- package/types/views/ThemeInverse.d.ts.map +1 -0
- package/types/views/ThemeManagerContext.d.ts +22 -0
- package/types/views/ThemeManagerContext.d.ts.map +1 -0
- package/types/views/ThemeProvider.d.ts +10 -0
- package/types/views/ThemeProvider.d.ts.map +1 -0
- package/types.d.ts +0 -559
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/views/ThemeProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { getHasConfigured, getThemeParentClassName } from '../createTamagui'\nimport { Theme } from './Theme'\nimport { ThemeContext } from './ThemeContext'\n\nexport type ThemeProviderProps = {\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n children?: any\n}\n\nexport const GET_DEFAULT_THEME = '___TGUI'\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n useIsomorphicLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n if (typeof document !== 'undefined') {\n const cns = getThemeParentClassName(`${props.defaultTheme}`).split(' ')\n cns.forEach((cn) => document.body.classList.add(cn))\n return () => {\n cns.forEach((cn) => document.body.classList.remove(cn))\n }\n }\n }, [])\n\n const themeContext = useMemo(() => {\n return new Proxy(props.themes, {\n get(target, key) {\n if (key === GET_DEFAULT_THEME) return props.defaultTheme\n return Reflect.get(target, key)\n },\n })\n }, [props.themes])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme name={props.defaultTheme} disableThemeClass={props.disableRootThemeClass}>\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AACA;AASO,MAAM,oBAAoB;AAE1B,MAAM,gBAAgB,wBAAC,UAA8B;AAC1D,MAAI,CAAC,oBAAoB;AACvB,UAAM,IAAI,MAAM;AAAA;AAIlB,4BAA0B,MAAM;AAC9B,QAAI,MAAM,uBAAuB;AAC/B;AAAA;AAEF,QAAI,OAAO,aAAa,aAAa;AACnC,YAAM,MAAM,wBAAwB,GAAG,MAAM,gBAAgB,MAAM;AACnE,UAAI,QAAQ,CAAC,OAAO,SAAS,KAAK,UAAU,IAAI;AAChD,aAAO,MAAM;AACX,YAAI,QAAQ,CAAC,OAAO,SAAS,KAAK,UAAU,OAAO;AAAA;AAAA;AAAA,KAGtD;AAEH,QAAM,eAAe,QAAQ,MAAM;AACjC,WAAO,IAAI,MAAM,MAAM,QAAQ;AAAA,MAC7B,IAAI,QAAQ,KAAK;AACf,YAAI,QAAQ;AAAmB,iBAAO,MAAM;AAC5C,eAAO,QAAQ,IAAI,QAAQ;AAAA;AAAA;AAAA,KAG9B,CAAC,MAAM;AAEV,SACE,oCAAC,aAAa,UAAd;AAAA,IAAuB,OAAO;AAAA,KAC5B,oCAAC,OAAD;AAAA,IAAO,MAAM,MAAM;AAAA,IAAc,mBAAmB,MAAM;AAAA,KACvD,MAAM;AAAA,GA/Bc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
import { Platform } from "react-native";
|
|
3
|
+
const isWeb = process.env.TAMAGUI_TARGET === "web" ? true : Platform?.OS === "web";
|
|
4
|
+
const isSSR = isWeb && typeof window === "undefined";
|
|
5
|
+
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
6
|
+
const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
7
|
+
const supportsTouchWeb = typeof window !== "undefined" && "ontouchstart" in window;
|
|
8
|
+
const isTouchDevice = !isWeb || supportsTouchWeb;
|
|
9
|
+
const isWebIOS = isWeb && typeof navigator !== "undefined" && (/iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window["MSStream"];
|
|
10
|
+
export {
|
|
11
|
+
isChrome,
|
|
12
|
+
isSSR,
|
|
13
|
+
isTouchDevice,
|
|
14
|
+
isWeb,
|
|
15
|
+
isWebIOS,
|
|
16
|
+
supportsTouchWeb,
|
|
17
|
+
useIsomorphicLayoutEffect
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const interopRequire = /* @__PURE__ */ __name((src) => "default" in src ? src.default : src, "interopRequire");
|
|
4
|
+
const rnw = {};
|
|
5
|
+
if (process.env.IS_STATIC === "is_static") {
|
|
6
|
+
const createCompileableStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle");
|
|
7
|
+
const createReactDOMStyle = require("react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle");
|
|
8
|
+
const i18Style = require("react-native-web/dist/cjs/exports/StyleSheet/i18nStyle");
|
|
9
|
+
const atomic = require("react-native-web/dist/cjs/exports/StyleSheet/compile").atomic;
|
|
10
|
+
Object.assign(rnw, {
|
|
11
|
+
createCompileableStyle,
|
|
12
|
+
createReactDOMStyle,
|
|
13
|
+
i18Style,
|
|
14
|
+
atomic
|
|
15
|
+
});
|
|
16
|
+
} else if (process.env.TAMAGUI_TARGET === "web") {
|
|
17
|
+
Object.assign(rnw, interopRequire(require("react-native-web").TamaguiExports));
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
rnw
|
|
21
|
+
};
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { concatClassName, stylePropsView } from "@tamagui/helpers";
|
|
4
|
+
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
|
+
import {
|
|
6
|
+
Children,
|
|
7
|
+
Fragment,
|
|
8
|
+
createElement,
|
|
9
|
+
forwardRef,
|
|
10
|
+
useCallback,
|
|
11
|
+
useContext,
|
|
12
|
+
useEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState
|
|
15
|
+
} from "react";
|
|
16
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
17
|
+
import { stackDefaultStyles } from "./constants/constants";
|
|
18
|
+
import { isTouchDevice, isWeb } from "./constants/platform";
|
|
19
|
+
import { rnw } from "./constants/rnw";
|
|
20
|
+
import { onConfiguredOnce } from "./createTamagui";
|
|
21
|
+
import { addStylesUsingClassname, useStylesAsClassname } from "./helpers/addStylesUsingClassname";
|
|
22
|
+
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
23
|
+
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
24
|
+
import { useFeatures } from "./hooks/useFeatures";
|
|
25
|
+
import { usePressable } from "./hooks/usePressable";
|
|
26
|
+
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
27
|
+
import { ThemeManagerContext } from "./views/ThemeManagerContext";
|
|
28
|
+
const mouseUps = new Set();
|
|
29
|
+
if (typeof document !== "undefined") {
|
|
30
|
+
document.addEventListener("mouseup", () => {
|
|
31
|
+
mouseUps.forEach((x) => x());
|
|
32
|
+
mouseUps.clear();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function createComponent(configIn) {
|
|
36
|
+
let staticConfig;
|
|
37
|
+
if ("parsed" in configIn) {
|
|
38
|
+
staticConfig = configIn;
|
|
39
|
+
} else {
|
|
40
|
+
staticConfig = parseStaticConfig(configIn);
|
|
41
|
+
}
|
|
42
|
+
const { Component, validStyles, isText, isZStack } = staticConfig;
|
|
43
|
+
const validStyleProps = validStyles ?? stylePropsView;
|
|
44
|
+
let defaultProps = null;
|
|
45
|
+
let tamaguiConfig;
|
|
46
|
+
let defaultsStyle;
|
|
47
|
+
let defaultsClassName = "";
|
|
48
|
+
let initialTheme;
|
|
49
|
+
const component = forwardRef((props, forwardedRef) => {
|
|
50
|
+
const forceUpdate = useForceUpdate();
|
|
51
|
+
const features = useFeatures(props, { forceUpdate });
|
|
52
|
+
const manager = useContext(ThemeManagerContext);
|
|
53
|
+
const [state, set_] = useState(() => ({
|
|
54
|
+
hover: false,
|
|
55
|
+
press: false,
|
|
56
|
+
pressIn: false,
|
|
57
|
+
theme: manager.name
|
|
58
|
+
}));
|
|
59
|
+
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
60
|
+
for (const key in next) {
|
|
61
|
+
if (prev[key] !== next[key]) {
|
|
62
|
+
return { ...prev, ...next };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return prev;
|
|
66
|
+
}), "set");
|
|
67
|
+
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
68
|
+
Children.toArray(props.children).forEach((item) => {
|
|
69
|
+
if (typeof item === "string") {
|
|
70
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
75
|
+
const hostRef = useRef(null);
|
|
76
|
+
const theme = manager.theme || initialTheme;
|
|
77
|
+
const {
|
|
78
|
+
viewProps: viewPropsIn,
|
|
79
|
+
pseudos,
|
|
80
|
+
style,
|
|
81
|
+
classNames
|
|
82
|
+
} = getSplitStyles(props, staticConfig, theme);
|
|
83
|
+
const {
|
|
84
|
+
tag,
|
|
85
|
+
hitSlop,
|
|
86
|
+
children,
|
|
87
|
+
pointerEvents,
|
|
88
|
+
onPress,
|
|
89
|
+
onPressIn,
|
|
90
|
+
onPressOut,
|
|
91
|
+
onHoverIn,
|
|
92
|
+
onHoverOut,
|
|
93
|
+
space,
|
|
94
|
+
disabled,
|
|
95
|
+
onMouseEnter,
|
|
96
|
+
onMouseLeave,
|
|
97
|
+
hrefAttrs,
|
|
98
|
+
onMoveShouldSetResponder,
|
|
99
|
+
onMoveShouldSetResponderCapture,
|
|
100
|
+
onResponderEnd,
|
|
101
|
+
onResponderGrant,
|
|
102
|
+
onResponderMove,
|
|
103
|
+
onResponderReject,
|
|
104
|
+
onResponderRelease,
|
|
105
|
+
onResponderStart,
|
|
106
|
+
onResponderTerminate,
|
|
107
|
+
onResponderTerminationRequest,
|
|
108
|
+
onScrollShouldSetResponder,
|
|
109
|
+
onScrollShouldSetResponderCapture,
|
|
110
|
+
onSelectionChangeShouldSetResponder,
|
|
111
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
112
|
+
onStartShouldSetResponder,
|
|
113
|
+
onStartShouldSetResponderCapture,
|
|
114
|
+
onMouseDown,
|
|
115
|
+
onClick,
|
|
116
|
+
accessible,
|
|
117
|
+
accessibilityRole,
|
|
118
|
+
onLayout,
|
|
119
|
+
...viewProps
|
|
120
|
+
} = viewPropsIn;
|
|
121
|
+
if (!isWeb) {
|
|
122
|
+
if (accessible)
|
|
123
|
+
viewProps.accessible = accessible;
|
|
124
|
+
if (accessibilityRole)
|
|
125
|
+
viewProps.accessibilityRole = accessibilityRole;
|
|
126
|
+
}
|
|
127
|
+
if (isWeb) {
|
|
128
|
+
rnw.useResponderEvents(hostRef, {
|
|
129
|
+
onMoveShouldSetResponder,
|
|
130
|
+
onMoveShouldSetResponderCapture,
|
|
131
|
+
onResponderEnd,
|
|
132
|
+
onResponderGrant,
|
|
133
|
+
onResponderMove,
|
|
134
|
+
onResponderReject,
|
|
135
|
+
onResponderRelease,
|
|
136
|
+
onResponderStart,
|
|
137
|
+
onResponderTerminate,
|
|
138
|
+
onResponderTerminationRequest,
|
|
139
|
+
onScrollShouldSetResponder,
|
|
140
|
+
onScrollShouldSetResponderCapture,
|
|
141
|
+
onSelectionChangeShouldSetResponder,
|
|
142
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
143
|
+
onStartShouldSetResponder,
|
|
144
|
+
onStartShouldSetResponderCapture
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const isTracking = useRef(false);
|
|
148
|
+
const internal = useRef();
|
|
149
|
+
if (!internal.current) {
|
|
150
|
+
internal.current = {
|
|
151
|
+
isMounted: true
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
internal.current.isMounted = true;
|
|
156
|
+
const dispose = manager?.onChangeTheme((name) => {
|
|
157
|
+
if (isTracking.current) {
|
|
158
|
+
set({ theme: name });
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
dispose();
|
|
163
|
+
mouseUps.delete(unPress);
|
|
164
|
+
isTracking.current = false;
|
|
165
|
+
internal.current.isMounted = false;
|
|
166
|
+
};
|
|
167
|
+
}, [manager]);
|
|
168
|
+
const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
|
|
169
|
+
const ReactView = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
|
|
170
|
+
const ReactText = !isWeb ? Text : element || "span";
|
|
171
|
+
const ViewComponent = isText ? ReactText : ReactView;
|
|
172
|
+
const isHovering = !isTouchDevice && !disabled && pseudos && state.hover;
|
|
173
|
+
const isPressing = !disabled && pseudos && state.press;
|
|
174
|
+
const styles = [
|
|
175
|
+
style,
|
|
176
|
+
isHovering ? pseudos.hoverStyle || null : null,
|
|
177
|
+
isPressing ? pseudos.pressStyle || null : null
|
|
178
|
+
];
|
|
179
|
+
if (isWeb) {
|
|
180
|
+
const stylesClassNames = useStylesAsClassname(styles);
|
|
181
|
+
const classList = isText ? [
|
|
182
|
+
defaultsClassName,
|
|
183
|
+
classNames,
|
|
184
|
+
stylesClassNames,
|
|
185
|
+
props.className
|
|
186
|
+
] : [defaultsClassName, props.className, classNames, stylesClassNames];
|
|
187
|
+
const className = concatClassName(...classList);
|
|
188
|
+
if (process.env.NODE_ENV === "development") {
|
|
189
|
+
if (props["debug"]) {
|
|
190
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
viewProps.className = className;
|
|
194
|
+
} else {
|
|
195
|
+
viewProps.style = styles;
|
|
196
|
+
}
|
|
197
|
+
if (pointerEvents) {
|
|
198
|
+
viewProps.pointerEvents = pointerEvents;
|
|
199
|
+
}
|
|
200
|
+
if (isWeb) {
|
|
201
|
+
const platformMethodsRef = rnw.usePlatformMethods(viewProps);
|
|
202
|
+
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
|
|
203
|
+
viewProps.ref = setRef;
|
|
204
|
+
if (props.href != null && hrefAttrs != null) {
|
|
205
|
+
const { download, rel, target } = hrefAttrs;
|
|
206
|
+
if (download != null) {
|
|
207
|
+
viewProps.download = download;
|
|
208
|
+
}
|
|
209
|
+
if (rel != null) {
|
|
210
|
+
viewProps.rel = rel;
|
|
211
|
+
}
|
|
212
|
+
if (typeof target === "string") {
|
|
213
|
+
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (forwardedRef) {
|
|
218
|
+
viewProps.ref = forwardedRef;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
222
|
+
const attachHover = isWeb && !isTouchDevice && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
223
|
+
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);
|
|
224
|
+
if (shouldAttach) {
|
|
225
|
+
internal.current.hasEverHadEvents = true;
|
|
226
|
+
}
|
|
227
|
+
const unPress = useCallback(() => {
|
|
228
|
+
if (!internal.current.isMounted)
|
|
229
|
+
return;
|
|
230
|
+
set({
|
|
231
|
+
press: false,
|
|
232
|
+
pressIn: false
|
|
233
|
+
});
|
|
234
|
+
}, []);
|
|
235
|
+
const events = shouldAttach ? {
|
|
236
|
+
...!isWeb && {
|
|
237
|
+
onPressOut: (e) => {
|
|
238
|
+
unPress();
|
|
239
|
+
onPressOut?.(e);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
...isWeb && !isTouchDevice && {
|
|
243
|
+
onMouseEnter: attachHover || attachPress ? (e) => {
|
|
244
|
+
let next = {};
|
|
245
|
+
if (attachHover) {
|
|
246
|
+
next.hover = true;
|
|
247
|
+
}
|
|
248
|
+
if (state.pressIn) {
|
|
249
|
+
next.press = true;
|
|
250
|
+
}
|
|
251
|
+
if (Object.keys(next).length) {
|
|
252
|
+
set(next);
|
|
253
|
+
}
|
|
254
|
+
onHoverIn?.(e);
|
|
255
|
+
onMouseEnter?.(e);
|
|
256
|
+
} : void 0,
|
|
257
|
+
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
258
|
+
let next = {};
|
|
259
|
+
mouseUps.add(unPress);
|
|
260
|
+
if (attachHover) {
|
|
261
|
+
next.hover = false;
|
|
262
|
+
}
|
|
263
|
+
if (state.pressIn) {
|
|
264
|
+
next.press = false;
|
|
265
|
+
next.pressIn = false;
|
|
266
|
+
}
|
|
267
|
+
if (Object.keys(next).length) {
|
|
268
|
+
set(next);
|
|
269
|
+
}
|
|
270
|
+
onHoverOut?.(e);
|
|
271
|
+
onMouseLeave?.(e);
|
|
272
|
+
} : void 0
|
|
273
|
+
},
|
|
274
|
+
onMouseDown: attachPress ? (e) => {
|
|
275
|
+
set({
|
|
276
|
+
press: true,
|
|
277
|
+
pressIn: true
|
|
278
|
+
});
|
|
279
|
+
onPressIn?.(e);
|
|
280
|
+
onMouseDown?.(e);
|
|
281
|
+
} : onPressIn,
|
|
282
|
+
onClick: attachPress ? (e) => {
|
|
283
|
+
onPress?.(e);
|
|
284
|
+
onClick?.(e);
|
|
285
|
+
unPress();
|
|
286
|
+
onPressOut?.(e);
|
|
287
|
+
} : onPressOut
|
|
288
|
+
} : null;
|
|
289
|
+
if (events) {
|
|
290
|
+
if (typeof ViewComponent !== "string") {
|
|
291
|
+
const [pressProps] = usePressable({
|
|
292
|
+
disabled,
|
|
293
|
+
hitSlop,
|
|
294
|
+
onPressIn: events.onMouseDown,
|
|
295
|
+
onPressOut: events.onPressOut,
|
|
296
|
+
onPress: events.onClick
|
|
297
|
+
});
|
|
298
|
+
Object.assign(viewProps, pressProps);
|
|
299
|
+
} else {
|
|
300
|
+
Object.assign(viewProps, events);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const childEls = spacedChildren({
|
|
304
|
+
children,
|
|
305
|
+
space,
|
|
306
|
+
flexDirection: props.flexDirection || defaultProps?.flexDirection,
|
|
307
|
+
isZStack
|
|
308
|
+
});
|
|
309
|
+
let content;
|
|
310
|
+
if (isWeb && rnw) {
|
|
311
|
+
const domProps = rnw.createDOMProps(viewProps);
|
|
312
|
+
const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
|
|
313
|
+
Object.assign(viewProps, domProps);
|
|
314
|
+
viewProps.className = className;
|
|
315
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
316
|
+
} else {
|
|
317
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
318
|
+
}
|
|
319
|
+
const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor;
|
|
320
|
+
if (shouldWrapTextAncestor) {
|
|
321
|
+
content = createElement(TextAncestorContext.Provider, { value: true }, content);
|
|
322
|
+
}
|
|
323
|
+
if (process.env.NODE_ENV === "development") {
|
|
324
|
+
if (props["debug"]) {
|
|
325
|
+
viewProps["debug"] = true;
|
|
326
|
+
console.log("\u{1F95A} props in:", props);
|
|
327
|
+
console.log("\u{1F95A} props out:", viewProps);
|
|
328
|
+
console.log(props.onClick?.toString());
|
|
329
|
+
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls });
|
|
330
|
+
if (isWeb) {
|
|
331
|
+
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return <>
|
|
336
|
+
{features}
|
|
337
|
+
{content}
|
|
338
|
+
</>;
|
|
339
|
+
});
|
|
340
|
+
onConfiguredOnce((conf) => {
|
|
341
|
+
tamaguiConfig = conf;
|
|
342
|
+
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
343
|
+
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
344
|
+
if (isWeb) {
|
|
345
|
+
if (next.classNames) {
|
|
346
|
+
defaultsClassName += next.classNames + " ";
|
|
347
|
+
}
|
|
348
|
+
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
|
|
349
|
+
} else {
|
|
350
|
+
if (!hasWarnedOnce) {
|
|
351
|
+
hasWarnedOnce = true;
|
|
352
|
+
console.log("\u26A0\uFE0F TODO account for default styles for media queries");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
component.defaultProps = {
|
|
356
|
+
...next.viewProps,
|
|
357
|
+
...component.defaultProps
|
|
358
|
+
};
|
|
359
|
+
if (process.env.NODE_ENV === "development") {
|
|
360
|
+
if (staticConfig.defaultProps?.debug) {
|
|
361
|
+
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
component["staticConfig"] = {
|
|
366
|
+
validStyles: validStyleProps,
|
|
367
|
+
...staticConfig
|
|
368
|
+
};
|
|
369
|
+
const res = component;
|
|
370
|
+
res["extractable"] = (Component2, conf) => {
|
|
371
|
+
Component2["staticConfig"] = extendStaticConfig(res, {
|
|
372
|
+
...conf,
|
|
373
|
+
neverFlatten: true,
|
|
374
|
+
defaultProps: {
|
|
375
|
+
...Component2.defaultProps,
|
|
376
|
+
...conf?.defaultProps
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
return Component2;
|
|
380
|
+
};
|
|
381
|
+
return res;
|
|
382
|
+
}
|
|
383
|
+
__name(createComponent, "createComponent");
|
|
384
|
+
let hasWarnedOnce = false;
|
|
385
|
+
const Spacer = createComponent({
|
|
386
|
+
defaultProps: {
|
|
387
|
+
...stackDefaultStyles,
|
|
388
|
+
size: true
|
|
389
|
+
},
|
|
390
|
+
variants: {
|
|
391
|
+
size: {
|
|
392
|
+
"...size": (size, { tokens }) => {
|
|
393
|
+
size = size == true ? "$true" : size;
|
|
394
|
+
return {
|
|
395
|
+
width: tokens.size[size] ?? size,
|
|
396
|
+
height: tokens.size[size] ?? size
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
direction: {
|
|
401
|
+
horizontal: {
|
|
402
|
+
height: 0
|
|
403
|
+
},
|
|
404
|
+
vertical: {
|
|
405
|
+
width: 0
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
function spacedChildren({
|
|
411
|
+
isZStack,
|
|
412
|
+
children,
|
|
413
|
+
space,
|
|
414
|
+
flexDirection
|
|
415
|
+
}) {
|
|
416
|
+
if (!space && !isZStack) {
|
|
417
|
+
return children;
|
|
418
|
+
}
|
|
419
|
+
const childrenList = Children.toArray(children);
|
|
420
|
+
const len = childrenList.length;
|
|
421
|
+
if (len === 1) {
|
|
422
|
+
return children;
|
|
423
|
+
}
|
|
424
|
+
const next = [];
|
|
425
|
+
for (const [index, child] of childrenList.entries()) {
|
|
426
|
+
if (child === null || child === void 0) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const key = `${child?.["key"] ?? index}`;
|
|
430
|
+
next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>);
|
|
431
|
+
if (child?.["type"]?.["isVisuallyHidden"]) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (index !== len - 1) {
|
|
435
|
+
if (space) {
|
|
436
|
+
next.push(<Spacer key={`${key}_spacer`} direction={flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical"} size={space} />);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return next;
|
|
441
|
+
}
|
|
442
|
+
__name(spacedChildren, "spacedChildren");
|
|
443
|
+
const Absolute = /* @__PURE__ */ __name(({ children }) => <View style={sheet.fullscreen}>{children}</View>, "Absolute");
|
|
444
|
+
const sheet = StyleSheet.create({
|
|
445
|
+
fullscreen: {
|
|
446
|
+
position: "absolute",
|
|
447
|
+
top: 0,
|
|
448
|
+
left: 0,
|
|
449
|
+
right: 0,
|
|
450
|
+
bottom: 0
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
export {
|
|
454
|
+
Spacer,
|
|
455
|
+
createComponent,
|
|
456
|
+
mouseUps,
|
|
457
|
+
spacedChildren
|
|
458
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { validateFont } from "./helpers/validate";
|
|
4
|
+
const createFont = /* @__PURE__ */ __name((font) => {
|
|
5
|
+
if (process.env.NODE_ENV === "development") {
|
|
6
|
+
validateFont(font);
|
|
7
|
+
}
|
|
8
|
+
const sizeKeys = Object.keys(font.size);
|
|
9
|
+
for (const key in font) {
|
|
10
|
+
if (key === "size" || key === "family")
|
|
11
|
+
continue;
|
|
12
|
+
const section = font[key];
|
|
13
|
+
const keys = Object.keys(section);
|
|
14
|
+
let fillVal = section[keys[0]];
|
|
15
|
+
for (const sKey of sizeKeys) {
|
|
16
|
+
if (!(sKey in section)) {
|
|
17
|
+
section[sKey] = fillVal;
|
|
18
|
+
} else {
|
|
19
|
+
fillVal = section[sKey];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return Object.freeze(font);
|
|
24
|
+
}, "createFont");
|
|
25
|
+
export {
|
|
26
|
+
createFont
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function createShorthands(shorthands) {
|
|
4
|
+
return Object.freeze(shorthands);
|
|
5
|
+
}
|
|
6
|
+
__name(createShorthands, "createShorthands");
|
|
7
|
+
export {
|
|
8
|
+
createShorthands
|
|
9
|
+
};
|