@tamagui/core 1.0.1-beta.220 → 1.0.1-beta.221
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/addTheme.js +7 -10
- package/dist/cjs/addTheme.js.map +3 -3
- package/dist/cjs/config.js +8 -4
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/{hooks/useUnmountEffect.js → contexts/ButtonNestingContext.js} +7 -9
- package/dist/cjs/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/cjs/createComponent.js +63 -67
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createTamagui.js +13 -12
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createTokens.test.js +27 -0
- package/dist/cjs/createTokens.test.js.map +7 -0
- package/dist/cjs/createVariable.js +4 -9
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariable.test.js +7 -0
- package/dist/cjs/createVariable.test.js.map +7 -0
- package/dist/cjs/createVariables.js +6 -7
- package/dist/cjs/createVariables.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +161 -147
- package/dist/cjs/helpers/ThemeManager.js.map +3 -3
- package/dist/cjs/helpers/ThemeManager.test.js +421 -34
- package/dist/cjs/helpers/ThemeManager.test.js.map +2 -2
- package/dist/cjs/helpers/{getTokens.js → ThemeManagerContext.js} +8 -8
- package/dist/cjs/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +4 -4
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +2 -4
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/{assignNativePropsToWeb.native.js → getBoundingClientRect.js} +15 -8
- package/dist/cjs/helpers/getBoundingClientRect.js.map +7 -0
- package/dist/cjs/{hooks/useConstant.js → helpers/getRect.js} +14 -17
- package/dist/cjs/helpers/getRect.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +82 -85
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getThemeCSSRules.js +6 -2
- package/dist/cjs/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +1 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js +11 -8
- package/dist/cjs/helpers/mergeTransform.js.map +2 -2
- package/dist/cjs/helpers/pseudoDescriptors.js +1 -0
- package/dist/cjs/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +9 -9
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +4 -12
- package/dist/cjs/hooks/useElementLayout.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +2 -1
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +114 -156
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/hooks/{useIsMounted.js → useThemeName.js} +23 -14
- package/dist/cjs/hooks/useThemeName.js.map +7 -0
- package/dist/cjs/index.js +2 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/setupReactNative.js +20 -7
- package/dist/cjs/setupReactNative.js.map +2 -2
- package/dist/cjs/styled.js +2 -19
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/updateTheme.js +9 -9
- package/dist/cjs/updateTheme.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +3 -3
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Theme.js +39 -28
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeProvider.js +8 -33
- package/dist/cjs/views/ThemeProvider.js.map +3 -3
- package/dist/esm/addTheme.js +7 -10
- package/dist/esm/addTheme.js.map +3 -3
- package/dist/esm/config.js +8 -3
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/contexts/ButtonNestingContext.js +6 -0
- package/dist/esm/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/esm/createComponent.js +65 -70
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createTamagui.js +13 -12
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createTokens.test.js +26 -0
- package/dist/esm/createTokens.test.js.map +7 -0
- package/dist/esm/createVariable.js +4 -9
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariable.test.js +6 -0
- package/dist/esm/createVariable.test.js.map +7 -0
- package/dist/esm/createVariables.js +6 -7
- package/dist/esm/createVariables.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +140 -144
- package/dist/esm/helpers/ThemeManager.js.map +3 -3
- package/dist/esm/helpers/ThemeManager.test.js +421 -34
- package/dist/esm/helpers/ThemeManager.test.js.map +2 -2
- package/dist/esm/helpers/ThemeManagerContext.js +6 -0
- package/dist/esm/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +4 -4
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +2 -4
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +13 -0
- package/dist/esm/helpers/getBoundingClientRect.js.map +7 -0
- package/dist/esm/helpers/getRect.js +12 -0
- package/dist/esm/helpers/getRect.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +90 -87
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getThemeCSSRules.js +6 -2
- package/dist/esm/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +1 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js +8 -6
- package/dist/esm/helpers/mergeTransform.js.map +2 -2
- package/dist/esm/helpers/pseudoDescriptors.js +1 -0
- package/dist/esm/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/esm/helpers/themeable.js +9 -9
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +2 -9
- package/dist/esm/hooks/useElementLayout.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +3 -2
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +114 -159
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/hooks/useThemeName.js +25 -0
- package/dist/esm/hooks/useThemeName.js.map +7 -0
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/setupReactNative.js +18 -6
- package/dist/esm/setupReactNative.js.map +2 -2
- package/dist/esm/styled.js +3 -20
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/updateTheme.js +9 -9
- package/dist/esm/updateTheme.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +4 -4
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Theme.js +40 -29
- package/dist/esm/views/Theme.js.map +3 -3
- package/dist/esm/views/ThemeProvider.js +8 -27
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/package.json +12 -12
- package/src/__snapshots__/createTokens.test.ts.snap +877 -0
- package/src/addTheme.ts +9 -12
- package/src/config.ts +10 -2
- package/src/contexts/ButtonNestingContext.tsx +3 -0
- package/src/createComponent.tsx +117 -108
- package/src/createTamagui.ts +16 -14
- package/src/createTokens.test.ts +29 -0
- package/src/createTokens.ts +1 -1
- package/src/createVariable.test.ts +7 -0
- package/src/createVariable.ts +4 -10
- package/src/createVariables.ts +7 -7
- package/src/helpers/ThemeManager.test.tsx +480 -0
- package/src/helpers/ThemeManager.tsx +171 -166
- package/src/helpers/ThemeManagerContext.tsx +5 -0
- package/src/helpers/createPropMapper.ts +4 -4
- package/src/helpers/extendStaticConfig.ts +4 -4
- package/src/helpers/getBoundingClientRect.tsx +7 -0
- package/src/helpers/getRect.tsx +8 -0
- package/src/helpers/getSplitStyles.tsx +98 -93
- package/src/helpers/getThemeCSSRules.ts +9 -2
- package/src/helpers/insertStyleRule.tsx +2 -2
- package/src/helpers/mergeTransform.ts +13 -6
- package/src/helpers/pseudoDescriptors.ts +1 -0
- package/src/helpers/themeable.tsx +17 -9
- package/src/hooks/useElementLayout.tsx +3 -8
- package/src/hooks/useMedia.tsx +3 -3
- package/src/hooks/useTheme.tsx +138 -211
- package/src/hooks/useThemeName.tsx +25 -0
- package/src/index.ts +3 -4
- package/src/setupReactNative.ts +16 -5
- package/src/styled.tsx +4 -23
- package/src/types.tsx +42 -17
- package/src/updateTheme.ts +12 -9
- package/src/views/TamaguiProvider.tsx +5 -5
- package/src/views/Theme.tsx +48 -39
- package/src/views/ThemeProvider.tsx +11 -33
- package/types/Tamagui.d.ts +1 -1
- package/types/addTheme.d.ts +23 -2
- package/types/config.d.ts +0 -1
- package/types/contexts/ButtonNestingContext.d.ts +3 -0
- package/types/createTokens.test.d.ts +2 -0
- package/types/createVariable.d.ts +2 -2
- package/types/createVariable.test.d.ts +2 -0
- package/types/helpers/ThemeManager.d.ts +20 -30
- package/types/helpers/ThemeManager.test.d.ts +2 -0
- package/types/helpers/ThemeManagerContext.d.ts +4 -0
- package/types/helpers/getBoundingClientRect.d.ts +2 -0
- package/types/helpers/getRect.d.ts +9 -0
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/helpers/mergeTransform.d.ts +5 -3
- package/types/helpers/themeable.d.ts +3 -0
- package/types/hooks/useElementLayout.d.ts +0 -8
- package/types/hooks/useTheme.d.ts +10 -20
- package/types/hooks/useThemeName.d.ts +5 -0
- package/types/index.d.ts +3 -4
- package/types/setupReactNative.d.ts +4 -2
- package/types/types.d.ts +35 -10
- package/types/updateTheme.d.ts +23 -2
- package/types/views/Theme.d.ts +3 -4
- package/dist/cjs/constants/platform.js +0 -74
- package/dist/cjs/constants/platform.js.map +0 -7
- package/dist/cjs/constants/platform.native.js +0 -62
- package/dist/cjs/constants/platform.native.js.map +0 -7
- package/dist/cjs/helpers/assignNativePropsToWeb.js +0 -188
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +0 -7
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +0 -7
- package/dist/cjs/helpers/calc.js +0 -71
- package/dist/cjs/helpers/calc.js.map +0 -7
- package/dist/cjs/helpers/getFont.js +0 -66
- package/dist/cjs/helpers/getFont.js.map +0 -7
- package/dist/cjs/helpers/getStackSize.js +0 -46
- package/dist/cjs/helpers/getStackSize.js.map +0 -7
- package/dist/cjs/helpers/getTokens.js.map +0 -7
- package/dist/cjs/helpers/startTransition.js +0 -36
- package/dist/cjs/helpers/startTransition.js.map +0 -7
- package/dist/cjs/helpers/validate.js +0 -2
- package/dist/cjs/helpers/validate.js.map +0 -7
- package/dist/cjs/hooks/useConstant.js.map +0 -7
- package/dist/cjs/hooks/useIsMounted.js.map +0 -7
- package/dist/cjs/hooks/usePressable.js +0 -36
- package/dist/cjs/hooks/usePressable.js.map +0 -7
- package/dist/cjs/hooks/useUnmountEffect.js.map +0 -7
- package/dist/cjs/injectStyles.js +0 -40
- package/dist/cjs/injectStyles.js.map +0 -7
- package/dist/cjs/react-native.js +0 -22
- package/dist/cjs/react-native.js.map +0 -7
- package/dist/esm/constants/platform.js +0 -39
- package/dist/esm/constants/platform.js.map +0 -7
- package/dist/esm/constants/platform.native.js +0 -28
- package/dist/esm/constants/platform.native.js.map +0 -7
- package/dist/esm/helpers/assignNativePropsToWeb.js +0 -164
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +0 -7
- package/dist/esm/helpers/assignNativePropsToWeb.native.js +0 -6
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +0 -7
- package/dist/esm/helpers/calc.js +0 -47
- package/dist/esm/helpers/calc.js.map +0 -7
- package/dist/esm/helpers/getFont.js +0 -42
- package/dist/esm/helpers/getFont.js.map +0 -7
- package/dist/esm/helpers/getStackSize.js +0 -22
- package/dist/esm/helpers/getStackSize.js.map +0 -7
- package/dist/esm/helpers/getTokens.js +0 -6
- package/dist/esm/helpers/getTokens.js.map +0 -7
- package/dist/esm/helpers/startTransition.js +0 -6
- package/dist/esm/helpers/startTransition.js.map +0 -7
- package/dist/esm/helpers/validate.js +0 -1
- package/dist/esm/helpers/validate.js.map +0 -7
- package/dist/esm/hooks/useConstant.js +0 -15
- package/dist/esm/hooks/useConstant.js.map +0 -7
- package/dist/esm/hooks/useIsMounted.js +0 -16
- package/dist/esm/hooks/useIsMounted.js.map +0 -7
- package/dist/esm/hooks/usePressable.js +0 -12
- package/dist/esm/hooks/usePressable.js.map +0 -7
- package/dist/esm/hooks/useUnmountEffect.js +0 -8
- package/dist/esm/hooks/useUnmountEffect.js.map +0 -7
- package/dist/esm/injectStyles.js +0 -16
- package/dist/esm/injectStyles.js.map +0 -7
- package/dist/esm/react-native.js +0 -3
- package/dist/esm/react-native.js.map +0 -7
- package/src/contexts/ButtonInsideButtonContext.tsx +0 -3
- package/src/contexts/ThemeContext.tsx +0 -5
- package/src/helpers/areEqualSets.tsx +0 -9
- package/src/views/ThemeInverse.tsx +0 -43
- package/src/views/ThemeReset.tsx +0 -43
- package/types/constants/platform.d.ts +0 -13
- package/types/constants/platform.native.d.ts +0 -13
- package/types/contexts/ButtonInsideButtonContext.d.ts +0 -3
- package/types/contexts/ThemeContext.d.ts +0 -7
- package/types/helpers/areEqualSets.d.ts +0 -2
- package/types/helpers/assignNativePropsToWeb.d.ts +0 -2
- package/types/helpers/assignNativePropsToWeb.native.d.ts +0 -2
- package/types/helpers/calc.d.ts +0 -1
- package/types/helpers/getFont.d.ts +0 -3
- package/types/helpers/getStackSize.d.ts +0 -8
- package/types/helpers/getTokens.d.ts +0 -2
- package/types/helpers/startTransition.d.ts +0 -3
- package/types/helpers/validate.d.ts +0 -1
- package/types/hooks/useConstant.d.ts +0 -2
- package/types/hooks/useIsMounted.d.ts +0 -3
- package/types/hooks/useMedia.test.d.ts +0 -1
- package/types/hooks/usePressable.d.ts +0 -3
- package/types/hooks/usePressablePressResponder.d.ts +0 -84
- package/types/hooks/useUnmountEffect.d.ts +0 -2
- package/types/injectStyles.d.ts +0 -7
- package/types/react-native.d.ts +0 -8
- package/types/views/AbsoluteFill.d.ts +0 -5
- package/types/views/AbsoluteFill.native.d.ts +0 -3
- package/types/views/ThemeInverse.d.ts +0 -9
- package/types/views/ThemeReset.d.ts +0 -4
package/dist/esm/styled.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { createComponent } from "./createComponent";
|
|
2
|
-
import {
|
|
3
|
-
let RNComponentConfigs = null;
|
|
2
|
+
import { ReactNativeStaticConfigs } from "./setupReactNative";
|
|
4
3
|
function styled(Component, options, staticExtractionOptions) {
|
|
5
|
-
const RN = getReactNative();
|
|
6
|
-
if (RN && typeof RN === "object" && !RNComponentConfigs) {
|
|
7
|
-
RNComponentConfigs = /* @__PURE__ */ new WeakMap();
|
|
8
|
-
for (const key in RN) {
|
|
9
|
-
const val = RN[key];
|
|
10
|
-
if (!val)
|
|
11
|
-
continue;
|
|
12
|
-
if (key[0].toLowerCase() === key[0])
|
|
13
|
-
continue;
|
|
14
|
-
RNComponentConfigs.set(val, {
|
|
15
|
-
isReactNative: true,
|
|
16
|
-
isText: key === "Text" || key === "TextInput",
|
|
17
|
-
inlineProps: key === "Image" ? /* @__PURE__ */ new Set(["src", "width", "height"]) : void 0
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
4
|
const staticConfigProps = (() => {
|
|
22
5
|
const parentStaticConfig = "staticConfig" in Component ? Component.staticConfig : null;
|
|
23
6
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -42,11 +25,11 @@ function styled(Component, options, staticExtractionOptions) {
|
|
|
42
25
|
Object.assign(defaultProps, defaultVariants);
|
|
43
26
|
}
|
|
44
27
|
const isReactNative = Boolean(
|
|
45
|
-
|
|
28
|
+
ReactNativeStaticConfigs.has(Component) || ReactNativeStaticConfigs.has(parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || (parentStaticConfig == null ? void 0 : parentStaticConfig.isReactNative) || (staticExtractionOptions == null ? void 0 : staticExtractionOptions.isReactNative)
|
|
46
29
|
);
|
|
47
30
|
const isTamagui = !isReactNative && !!parentStaticConfig;
|
|
48
31
|
const Comp = isReactNative ? (parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || Component : Component;
|
|
49
|
-
const nativeConf = isReactNative &&
|
|
32
|
+
const nativeConf = isReactNative && ReactNativeStaticConfigs.get(Comp) || null;
|
|
50
33
|
const isText = Boolean((staticExtractionOptions == null ? void 0 : staticExtractionOptions.isText) || (parentStaticConfig == null ? void 0 : parentStaticConfig.isText));
|
|
51
34
|
const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative);
|
|
52
35
|
const conf = {
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createComponent } from './createComponent'\nimport { ReactNativeStaticConfigs } from './setupReactNative'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\n// can't infer from styled(<YStack />) which would be nice\n// * excessively deep type instantiation\n\ntype GetBaseProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetBaseProps<A['type']> :\n A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetVariantProps<A['type']>\n // :\n A extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // allows passing styled(<H1 bc=\"red\" />)\n // but to get types right would be tricky\n // if (isValidElement(Component) && isTamaguiComponent(Component.type)) {\n // const props = Component.props\n // if (props && typeof props === 'object') {\n // Component = Component.type as any\n // options = options ? ({ ...props, ...options } as any) : props\n // }\n // }\n\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (process.env.NODE_ENV === 'development') {\n if (parentStaticConfig?.isHOC) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`,\n `Given options:`,\n options,\n new Error().stack\n )\n }\n }\n\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative ||\n staticExtractionOptions?.isReactNative\n )\n const isTamagui = !isReactNative && !!parentStaticConfig\n\n const Comp = isReactNative ? parentStaticConfig?.Component || Component : (Component as any)\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(staticExtractionOptions?.isText || parentStaticConfig?.isText)\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component as StyledComponent\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAmClC,SAAS,OAId,WAEA,S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package/dist/esm/updateTheme.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { addTheme } from "./addTheme";
|
|
2
2
|
import { activeThemeManagers } from "./hooks/useTheme";
|
|
3
|
-
function updateTheme({
|
|
3
|
+
function updateTheme({
|
|
4
|
+
name,
|
|
5
|
+
theme
|
|
6
|
+
}) {
|
|
4
7
|
const next = addTheme({ name, theme, insertCSS: true, update: true });
|
|
5
8
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
6
9
|
activeThemeManagers.forEach((manager) => {
|
|
7
|
-
if (manager.name === name) {
|
|
8
|
-
manager.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
true
|
|
14
|
-
);
|
|
10
|
+
if (manager.state.name === name) {
|
|
11
|
+
manager.updateState({
|
|
12
|
+
name,
|
|
13
|
+
forceTheme: next.theme
|
|
14
|
+
});
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/updateTheme.ts"],
|
|
4
|
-
"sourcesContent": ["import { addTheme } from './addTheme'\nimport { activeThemeManagers } from './hooks/useTheme'\nimport { ThemeDefinition } from './types'\n\nexport function updateTheme({
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAG7B,SAAS,YAAY,
|
|
4
|
+
"sourcesContent": ["import { addTheme } from './addTheme'\nimport { activeThemeManagers } from './hooks/useTheme'\nimport { ThemeDefinition } from './types'\n\nexport function updateTheme({\n name,\n theme,\n}: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n}) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.state.name === name) {\n manager.updateState({\n name,\n forceTheme: next.theme,\n })\n }\n })\n }\n\n return next\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAG7B,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,SAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wBAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,MAAM,SAAS,MAAM;AAC/B,gBAAQ,YAAY;AAAA,UAClB;AAAA,UACA,YAAY,KAAK;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isClient, isRSC, isServer } from "@tamagui/constants";
|
|
2
|
+
import { isClient, isRSC, isServer, isWeb } from "@tamagui/constants";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ButtonNestingContext } from "../contexts/ButtonNestingContext";
|
|
5
5
|
import { TextAncestorContext } from "../contexts/TextAncestorContext";
|
|
6
6
|
import { useMediaListeners } from "../hooks/useMedia";
|
|
7
7
|
import { ThemeProvider } from "./ThemeProvider";
|
|
@@ -18,7 +18,7 @@ function TamaguiProvider({
|
|
|
18
18
|
children
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
if (!isServer) {
|
|
21
|
+
if (!isWeb || !isServer) {
|
|
22
22
|
useMediaListeners(config);
|
|
23
23
|
}
|
|
24
24
|
if (isClient) {
|
|
@@ -33,7 +33,7 @@ function TamaguiProvider({
|
|
|
33
33
|
};
|
|
34
34
|
}, [config, disableInjectCSS]);
|
|
35
35
|
}
|
|
36
|
-
return /* @__PURE__ */ jsx(
|
|
36
|
+
return /* @__PURE__ */ jsx(ButtonNestingContext.Provider, {
|
|
37
37
|
value: false,
|
|
38
38
|
children: /* @__PURE__ */ jsx(TextAncestorContext.Provider, {
|
|
39
39
|
value: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/TamaguiProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isClient, isRSC, isServer } from '@tamagui/constants'\nimport * as React from 'react'\n\nimport {
|
|
5
|
-
"mappings": "AAiBM;AAjBN,SAAS,UAAU,OAAO,
|
|
4
|
+
"sourcesContent": ["import { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport * as React from 'react'\n\nimport { ButtonNestingContext } from '../contexts/ButtonNestingContext'\nimport { TextAncestorContext } from '../contexts/TextAncestorContext'\nimport { useMediaListeners } from '../hooks/useMedia'\nimport type { TamaguiProviderProps } from '../types'\nimport { ThemeProvider } from './ThemeProvider'\n\nexport function TamaguiProvider({\n children,\n disableInjectCSS,\n config,\n ...themePropsProvider\n}: TamaguiProviderProps) {\n if (isRSC) {\n return (\n <span\n style={{ display: 'contents' }}\n className={`t_${Object.keys(config.themes)[0] || 'light'}`}\n >\n {children}\n </span>\n )\n }\n\n if (!isWeb || !isServer) {\n useMediaListeners(config)\n }\n\n if (isClient) {\n // inject CSS if asked to (not SSR compliant)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(() => {\n if (disableInjectCSS) return\n const style = document.createElement('style')\n style.appendChild(document.createTextNode(config.getCSS()))\n document.head.appendChild(style)\n return () => {\n document.head.removeChild(style)\n }\n }, [config, disableInjectCSS])\n }\n\n return (\n <ButtonNestingContext.Provider value={false}>\n <TextAncestorContext.Provider value={false}>\n <ThemeProvider\n themeClassNameOnRoot={config.themeClassNameOnRoot}\n disableRootThemeClass={config.disableRootThemeClass}\n {...themePropsProvider}\n defaultTheme={themePropsProvider.defaultTheme ?? Object.keys(config.themes)[0]}\n >\n {children}\n </ThemeProvider>\n </TextAncestorContext.Provider>\n </ButtonNestingContext.Provider>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sx-runtime";
|
|
2
2
|
import { isWeb } from "@tamagui/constants";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
4
|
import { variableToString } from "../createVariable";
|
|
5
|
-
import { ThemeManagerContext } from "../helpers/
|
|
5
|
+
import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
|
|
6
6
|
import { useChangeThemeEffect } from "../hooks/useTheme";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
props
|
|
7
|
+
function Theme(props) {
|
|
8
|
+
if (props.disable) {
|
|
9
|
+
return props.children;
|
|
10
|
+
}
|
|
11
|
+
const isRoot = !!props["_isRoot"];
|
|
12
|
+
const { name, theme, themeManager, themes, isNewTheme, className } = useChangeThemeEffect(
|
|
13
|
+
props,
|
|
14
|
+
isRoot
|
|
14
15
|
);
|
|
16
|
+
const disableThemeClass = props.disableThemeClass;
|
|
15
17
|
const missingTheme = !themes || !name || !theme;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
const disablePassingTheme = missingTheme || !isNewTheme;
|
|
19
|
+
let contents = useMemo(() => {
|
|
20
|
+
const next = props["data-themeable"] ? React.cloneElement(props.children, { ["data-themeable"]: true }) : props.children;
|
|
21
|
+
return disablePassingTheme ? next : wrapThemeManagerContext(next, themeManager);
|
|
22
|
+
}, [disablePassingTheme, props.children, themeManager]);
|
|
23
|
+
if (process.env.NODE_ENV === "development" && missingTheme) {
|
|
24
|
+
name && !theme && console.warn(`No theme found by name ${name}`);
|
|
24
25
|
return props.children;
|
|
25
26
|
}
|
|
27
|
+
if (disableThemeClass || disablePassingTheme) {
|
|
28
|
+
return contents;
|
|
29
|
+
}
|
|
26
30
|
if (isWeb) {
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
const cn = [props.className, className, "_dsp_contents"].filter(Boolean).join(" ");
|
|
32
|
+
contents = /* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: cn,
|
|
29
34
|
style: {
|
|
30
|
-
|
|
31
|
-
color: variableToString((_a = themes[name]) == null ? void 0 : _a.color)
|
|
35
|
+
color: variableToString(theme == null ? void 0 : theme.color)
|
|
32
36
|
},
|
|
33
37
|
children: contents
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
return contents;
|
|
37
|
-
}
|
|
38
|
-
function wrapThemeManagerContext(children, themeManager,
|
|
39
|
-
|
|
41
|
+
}
|
|
42
|
+
function wrapThemeManagerContext(children, themeManager, shouldReset) {
|
|
43
|
+
if (!themeManager) {
|
|
44
|
+
return children;
|
|
45
|
+
}
|
|
46
|
+
let next = children;
|
|
47
|
+
if (shouldReset && themeManager) {
|
|
48
|
+
next = /* @__PURE__ */ jsx(Theme, {
|
|
49
|
+
name: themeManager.state.parentName,
|
|
50
|
+
children: next
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsx(ThemeManagerContext.Provider, {
|
|
40
54
|
value: themeManager,
|
|
41
|
-
children:
|
|
42
|
-
|
|
43
|
-
children
|
|
44
|
-
}) : children
|
|
45
|
-
}) : children;
|
|
55
|
+
children: next
|
|
56
|
+
});
|
|
46
57
|
}
|
|
47
58
|
export {
|
|
48
59
|
Theme,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport React, {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport React, { useMemo } from 'react'\n\nimport { variableToString } from '../createVariable'\nimport { ThemeManager } from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../types'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error its a permanent prop meant for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const { name, theme, themeManager, themes, isNewTheme, className } = useChangeThemeEffect(\n props,\n isRoot\n )\n\n const disableThemeClass = props.disableThemeClass\n const missingTheme = !themes || !name || !theme\n const disablePassingTheme = missingTheme || !isNewTheme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n let contents = useMemo(() => {\n const next = props['data-themeable']\n ? React.cloneElement(props.children, { ['data-themeable']: true })\n : props.children\n\n return disablePassingTheme ? next : wrapThemeManagerContext(next, themeManager)\n }, [disablePassingTheme, props.children, themeManager])\n\n if (process.env.NODE_ENV === 'development' && missingTheme) {\n // eslint-disable-next-line no-console\n name && !theme && console.warn(`No theme found by name ${name}`)\n return props.children\n }\n\n if (disableThemeClass || disablePassingTheme) {\n return contents\n }\n\n if (isWeb) {\n const cn = [props.className, className, '_dsp_contents'].filter(Boolean).join(' ')\n contents = (\n <span\n className={cn}\n style={{\n // in order to provide currentColor, set color by default\n color: variableToString(theme?.color),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n}\n\nexport function wrapThemeManagerContext(\n children: any,\n themeManager?: ThemeManager | null,\n shouldReset?: boolean\n) {\n // be sure to memoize themeManager to avoid reparenting\n if (!themeManager) {\n return children\n }\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n // TODO likely not necessary if we do reset logic now in useTheme?\n // reset to parent theme\n if (shouldReset && themeManager) {\n next = <Theme name={themeManager.state.parentName}>{next}</Theme>\n }\n return <ThemeManagerContext.Provider value={themeManager}>{next}</ThemeManagerContext.Provider>\n}\n"],
|
|
5
|
+
"mappings": "AAgDM;AAhDN,SAAS,aAAa;AACtB,OAAO,SAAS,eAAe;AAE/B,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAG9B,S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ApB;AAAA,IAA6B,OAAO;AAAA,IAAe;AAAA,GAAK;AAClE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { isClient } from "@tamagui/constants";
|
|
3
|
-
import
|
|
4
|
-
import { getConfig, getHasConfigured } from "../config";
|
|
3
|
+
import { useLayoutEffect } from "react";
|
|
5
4
|
import { THEME_CLASSNAME_PREFIX } from "../constants/constants";
|
|
6
|
-
import { ThemeContext } from "../contexts/ThemeContext";
|
|
7
5
|
import { Theme } from "./Theme";
|
|
8
|
-
React["createElement"];
|
|
9
6
|
const ThemeProvider = (props) => {
|
|
10
|
-
if (process.env.NODE_ENV === "development") {
|
|
11
|
-
if (!getHasConfigured()) {
|
|
12
|
-
throw new Error(`Missing configureThemes() call, add to your root file`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
7
|
if (isClient) {
|
|
16
8
|
useLayoutEffect(() => {
|
|
17
|
-
if (props.disableRootThemeClass)
|
|
9
|
+
if (props.disableRootThemeClass)
|
|
18
10
|
return;
|
|
19
|
-
}
|
|
20
11
|
const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`;
|
|
21
12
|
const target = props.themeClassNameOnRoot ? document.documentElement : document.body;
|
|
22
13
|
target.classList.add(cn);
|
|
@@ -25,22 +16,12 @@ const ThemeProvider = (props) => {
|
|
|
25
16
|
};
|
|
26
17
|
}, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot]);
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
}, [props.defaultTheme]);
|
|
36
|
-
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
37
|
-
value: themeContext,
|
|
38
|
-
children: /* @__PURE__ */ jsx(Theme, {
|
|
39
|
-
className: props.className,
|
|
40
|
-
name: props.defaultTheme,
|
|
41
|
-
disableThemeClass: props.disableRootThemeClass,
|
|
42
|
-
children: props.children
|
|
43
|
-
})
|
|
19
|
+
return /* @__PURE__ */ jsx(Theme, {
|
|
20
|
+
className: props.className,
|
|
21
|
+
name: props.defaultTheme,
|
|
22
|
+
disableThemeClass: props.disableRootThemeClass,
|
|
23
|
+
_isRoot: true,
|
|
24
|
+
children: props.children
|
|
44
25
|
});
|
|
45
26
|
};
|
|
46
27
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isClient } from '@tamagui/constants'\nimport
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { isClient } from '@tamagui/constants'\nimport { useLayoutEffect } from 'react'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { Theme } from './Theme'\n\nexport type ThemeProviderProps = {\n className?: string\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n // ensure theme is attached to root body node as well to work with modals by default\n if (isClient) {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) return\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot])\n }\n\n return (\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n // @ts-expect-error\n _isRoot\n >\n {props.children}\n </Theme>\n )\n}\n"],
|
|
5
|
+
"mappings": "AA8BI;AA9BJ,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAEhC,SAAS,8BAA8B;AACvC,SAAS,aAAa;AAWf,MAAM,gBAAgB,CAAC,UAA8B;AAE1D,MAAI,UAAU;AACZ,oBAAgB,MAAM;AACpB,UAAI,MAAM;AAAuB;AACjC,YAAM,KAAK,GAAG,yBAAyB,MAAM;AAC7C,YAAM,SAAS,MAAM,uBAAuB,SAAS,kBAAkB,SAAS;AAChF,aAAO,UAAU,IAAI,EAAE;AACvB,aAAO,MAAM;AACX,eAAO,UAAU,OAAO,EAAE;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,cAAc,MAAM,uBAAuB,MAAM,oBAAoB,CAAC;AAAA,EAClF;AAEA,SACE,oBAAC;AAAA,IACC,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,mBAAmB,MAAM;AAAA,IAEzB,SAAO;AAAA,IAEN,gBAAM;AAAA,GACT;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.221",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/match-media": "^0.3.0",
|
|
31
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/constants": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/react-native-use-pressable": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/react-native-use-responder-events": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/types-react-native": "^1.0.1-beta.
|
|
38
|
-
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.
|
|
39
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
40
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
31
|
+
"@tamagui/compose-refs": "^1.0.1-beta.221",
|
|
32
|
+
"@tamagui/constants": "^1.0.1-beta.221",
|
|
33
|
+
"@tamagui/helpers": "^1.0.1-beta.221",
|
|
34
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.221",
|
|
35
|
+
"@tamagui/react-native-use-pressable": "^1.0.1-beta.221",
|
|
36
|
+
"@tamagui/react-native-use-responder-events": "^1.0.1-beta.221",
|
|
37
|
+
"@tamagui/types-react-native": "^1.0.1-beta.221",
|
|
38
|
+
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.221",
|
|
39
|
+
"@tamagui/use-event": "^1.0.1-beta.221",
|
|
40
|
+
"@tamagui/use-force-update": "^1.0.1-beta.221"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=18",
|
|
44
44
|
"react-dom": ">=18"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
47
|
+
"@tamagui/build": "^1.0.1-beta.221",
|
|
48
48
|
"@types/node": "^16.11.9",
|
|
49
49
|
"@types/react": "^18.0.15",
|
|
50
50
|
"@types/react-native": "^0.69.2",
|