@tamagui/core 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cjs/hooks/usePlatformMethods.js +48 -0
- package/dist/cjs/hooks/usePlatformMethods.js.map +7 -0
- package/dist/cjs/index.js +152 -75
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/{types.js → reactNativeTypes.js} +3 -3
- package/dist/cjs/reactNativeTypes.js.map +7 -0
- package/dist/esm/hooks/usePlatformMethods.js +24 -0
- package/dist/esm/hooks/usePlatformMethods.js.map +7 -0
- package/dist/esm/index.js +157 -71
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/reactNativeTypes.js +1 -0
- package/dist/esm/{types-rnw.js.map → reactNativeTypes.js.map} +0 -0
- package/package.json +5 -11
- package/src/hooks/usePlatformMethods.ts +26 -0
- package/src/index.ts +214 -71
- package/src/reactNativeTypes.ts +104 -0
- package/types/hooks/usePlatformMethods.d.ts +3 -0
- package/types/hooks/usePlatformMethods.d.ts.map +1 -0
- package/types/index.d.ts +6 -54
- package/types/index.d.ts.map +1 -1
- package/types/reactNativeTypes.d.ts +26 -0
- package/types/reactNativeTypes.d.ts.map +1 -0
- package/dist/cjs/Tamagui.js +0 -77
- package/dist/cjs/Tamagui.js.map +0 -7
- package/dist/cjs/addTheme.js +0 -78
- package/dist/cjs/addTheme.js.map +0 -7
- package/dist/cjs/config.js +0 -91
- package/dist/cjs/config.js.map +0 -7
- package/dist/cjs/constants/constants.js +0 -49
- package/dist/cjs/constants/constants.js.map +0 -7
- package/dist/cjs/constants/isDevTools.js +0 -37
- package/dist/cjs/constants/isDevTools.js.map +0 -7
- package/dist/cjs/contexts/ButtonNestingContext.js +0 -30
- package/dist/cjs/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/cjs/contexts/FontLanguageContext.js +0 -30
- package/dist/cjs/contexts/FontLanguageContext.js.map +0 -7
- package/dist/cjs/contexts/TextAncestorContext.js +0 -30
- package/dist/cjs/contexts/TextAncestorContext.js.map +0 -7
- package/dist/cjs/createComponent.js +0 -993
- package/dist/cjs/createComponent.js.map +0 -7
- package/dist/cjs/createFont.js +0 -69
- package/dist/cjs/createFont.js.map +0 -7
- package/dist/cjs/createFont.web.test.js +0 -125
- package/dist/cjs/createFont.web.test.js.map +0 -7
- package/dist/cjs/createShorthands.js +0 -31
- package/dist/cjs/createShorthands.js.map +0 -7
- package/dist/cjs/createTamagui.js +0 -206
- package/dist/cjs/createTamagui.js.map +0 -7
- package/dist/cjs/createTheme.js +0 -31
- package/dist/cjs/createTheme.js.map +0 -7
- package/dist/cjs/createTokens.js +0 -39
- package/dist/cjs/createTokens.js.map +0 -7
- package/dist/cjs/createTokens.web.test.js +0 -28
- package/dist/cjs/createTokens.web.test.js.map +0 -7
- package/dist/cjs/createVariable.js +0 -111
- package/dist/cjs/createVariable.js.map +0 -7
- package/dist/cjs/createVariable.web.test.js +0 -7
- package/dist/cjs/createVariable.web.test.js.map +0 -7
- package/dist/cjs/createVariables.js +0 -60
- package/dist/cjs/createVariables.js.map +0 -7
- package/dist/cjs/helpers/RNComponents.js +0 -40
- package/dist/cjs/helpers/RNComponents.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.js +0 -234
- package/dist/cjs/helpers/ThemeManager.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.test.js +0 -465
- package/dist/cjs/helpers/ThemeManager.test.js.map +0 -7
- package/dist/cjs/helpers/ThemeManagerContext.js +0 -30
- package/dist/cjs/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/cjs/helpers/createMediaStyle.js +0 -67
- package/dist/cjs/helpers/createMediaStyle.js.map +0 -7
- package/dist/cjs/helpers/createPropMapper.js +0 -423
- package/dist/cjs/helpers/createPropMapper.js.map +0 -7
- package/dist/cjs/helpers/createProxy.js +0 -43
- package/dist/cjs/helpers/createProxy.js.map +0 -7
- package/dist/cjs/helpers/expandStyle.js +0 -95
- package/dist/cjs/helpers/expandStyle.js.map +0 -7
- package/dist/cjs/helpers/expandStyles.js +0 -116
- package/dist/cjs/helpers/expandStyles.js.map +0 -7
- package/dist/cjs/helpers/extendStaticConfig.js +0 -91
- package/dist/cjs/helpers/extendStaticConfig.js.map +0 -7
- package/dist/cjs/helpers/fixNativeShadow.js +0 -30
- package/dist/cjs/helpers/fixNativeShadow.js.map +0 -7
- package/dist/cjs/helpers/getAnimationDriver.js +0 -32
- package/dist/cjs/helpers/getAnimationDriver.js.map +0 -7
- package/dist/cjs/helpers/getExpandedShorthands.js +0 -40
- package/dist/cjs/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/cjs/helpers/getFontLanguage.js +0 -29
- package/dist/cjs/helpers/getFontLanguage.js.map +0 -7
- package/dist/cjs/helpers/getSplitStyles.js +0 -848
- package/dist/cjs/helpers/getSplitStyles.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.js +0 -226
- package/dist/cjs/helpers/getStylesAtomic.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.native.js +0 -38
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.js +0 -110
- package/dist/cjs/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.native.js +0 -31
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/cjs/helpers/getVariantExtras.js +0 -92
- package/dist/cjs/helpers/getVariantExtras.js.map +0 -7
- package/dist/cjs/helpers/insertStyleRule.js +0 -218
- package/dist/cjs/helpers/insertStyleRule.js.map +0 -7
- package/dist/cjs/helpers/isObj.js +0 -29
- package/dist/cjs/helpers/isObj.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiComponent.js +0 -32
- package/dist/cjs/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiElement.js +0 -33
- package/dist/cjs/helpers/isTamaguiElement.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.js +0 -42
- package/dist/cjs/helpers/matchMedia.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.native.js +0 -48
- package/dist/cjs/helpers/matchMedia.native.js.map +0 -7
- package/dist/cjs/helpers/mergeProps.js +0 -54
- package/dist/cjs/helpers/mergeProps.js.map +0 -7
- package/dist/cjs/helpers/mergeTransform.js +0 -47
- package/dist/cjs/helpers/mergeTransform.js.map +0 -7
- package/dist/cjs/helpers/normalizeColor.js +0 -71
- package/dist/cjs/helpers/normalizeColor.js.map +0 -7
- package/dist/cjs/helpers/normalizeValueWithProperty.js +0 -138
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/cjs/helpers/proxyThemeVariables.js +0 -40
- package/dist/cjs/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/cjs/helpers/pseudoDescriptors.js +0 -53
- package/dist/cjs/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/cjs/helpers/registerCSSVariable.js +0 -40
- package/dist/cjs/helpers/registerCSSVariable.js.map +0 -7
- package/dist/cjs/helpers/themeable.js +0 -62
- package/dist/cjs/helpers/themeable.js.map +0 -7
- package/dist/cjs/helpers/themes.js +0 -78
- package/dist/cjs/helpers/themes.js.map +0 -7
- package/dist/cjs/helpers/timer.js +0 -35
- package/dist/cjs/helpers/timer.js.map +0 -7
- package/dist/cjs/helpers/useShallowSetState.js +0 -59
- package/dist/cjs/helpers/useShallowSetState.js.map +0 -7
- package/dist/cjs/helpers/warnOnce.js +0 -38
- package/dist/cjs/helpers/warnOnce.js.map +0 -7
- package/dist/cjs/helpers/withStaticProperties.js +0 -32
- package/dist/cjs/helpers/withStaticProperties.js.map +0 -7
- package/dist/cjs/hooks/getThemeUnwrapped.js +0 -34
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/cjs/hooks/useId.js +0 -29
- package/dist/cjs/hooks/useId.js.map +0 -7
- package/dist/cjs/hooks/useIsTouchDevice.js +0 -33
- package/dist/cjs/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/cjs/hooks/useMedia.js +0 -263
- package/dist/cjs/hooks/useMedia.js.map +0 -7
- package/dist/cjs/hooks/useSafeRef.js +0 -59
- package/dist/cjs/hooks/useSafeRef.js.map +0 -7
- package/dist/cjs/hooks/useServerHooks.js +0 -36
- package/dist/cjs/hooks/useServerHooks.js.map +0 -7
- package/dist/cjs/hooks/useStyle.js +0 -61
- package/dist/cjs/hooks/useStyle.js.map +0 -7
- package/dist/cjs/hooks/useTheme.js +0 -230
- package/dist/cjs/hooks/useTheme.js.map +0 -7
- package/dist/cjs/hooks/useThemeName.js +0 -52
- package/dist/cjs/hooks/useThemeName.js.map +0 -7
- package/dist/cjs/insertFont.js +0 -93
- package/dist/cjs/insertFont.js.map +0 -7
- package/dist/cjs/setupReactNative.js +0 -51
- package/dist/cjs/setupReactNative.js.map +0 -7
- package/dist/cjs/static.js +0 -20
- package/dist/cjs/static.js.map +0 -7
- package/dist/cjs/styled.js +0 -95
- package/dist/cjs/styled.js.map +0 -7
- package/dist/cjs/types-rnw.js +0 -17
- package/dist/cjs/types-rnw.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/cjs/updateTheme.js +0 -47
- package/dist/cjs/updateTheme.js.map +0 -7
- package/dist/cjs/views/FontLanguage.js +0 -41
- package/dist/cjs/views/FontLanguage.js.map +0 -7
- package/dist/cjs/views/FontLanguage.native.js +0 -35
- package/dist/cjs/views/FontLanguage.native.js.map +0 -7
- package/dist/cjs/views/FontLanguage.types.js +0 -17
- package/dist/cjs/views/FontLanguage.types.js.map +0 -7
- package/dist/cjs/views/Slot.js +0 -92
- package/dist/cjs/views/Slot.js.map +0 -7
- package/dist/cjs/views/Stack.js +0 -38
- package/dist/cjs/views/Stack.js.map +0 -7
- package/dist/cjs/views/Stack.web.test.js +0 -22
- package/dist/cjs/views/Stack.web.test.js.map +0 -7
- package/dist/cjs/views/TamaguiProvider.js +0 -90
- package/dist/cjs/views/TamaguiProvider.js.map +0 -7
- package/dist/cjs/views/Text.js +0 -94
- package/dist/cjs/views/Text.js.map +0 -7
- package/dist/cjs/views/Theme.js +0 -88
- package/dist/cjs/views/Theme.js.map +0 -7
- package/dist/cjs/views/ThemeProvider.js +0 -70
- package/dist/cjs/views/ThemeProvider.js.map +0 -7
- package/dist/esm/Tamagui.js +0 -41
- package/dist/esm/Tamagui.js.map +0 -7
- package/dist/esm/addTheme.js +0 -54
- package/dist/esm/addTheme.js.map +0 -7
- package/dist/esm/config.js +0 -58
- package/dist/esm/config.js.map +0 -7
- package/dist/esm/constants/constants.js +0 -22
- package/dist/esm/constants/constants.js.map +0 -7
- package/dist/esm/constants/isDevTools.js +0 -13
- package/dist/esm/constants/isDevTools.js.map +0 -7
- package/dist/esm/contexts/ButtonNestingContext.js +0 -6
- package/dist/esm/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/esm/contexts/FontLanguageContext.js +0 -6
- package/dist/esm/contexts/FontLanguageContext.js.map +0 -7
- package/dist/esm/contexts/TextAncestorContext.js +0 -6
- package/dist/esm/contexts/TextAncestorContext.js.map +0 -7
- package/dist/esm/createComponent.js +0 -975
- package/dist/esm/createComponent.js.map +0 -7
- package/dist/esm/createFont.js +0 -45
- package/dist/esm/createFont.js.map +0 -7
- package/dist/esm/createFont.web.test.js +0 -124
- package/dist/esm/createFont.web.test.js.map +0 -7
- package/dist/esm/createShorthands.js +0 -7
- package/dist/esm/createShorthands.js.map +0 -7
- package/dist/esm/createTamagui.js +0 -190
- package/dist/esm/createTamagui.js.map +0 -7
- package/dist/esm/createTheme.js +0 -7
- package/dist/esm/createTheme.js.map +0 -7
- package/dist/esm/createTokens.js +0 -15
- package/dist/esm/createTokens.js.map +0 -7
- package/dist/esm/createTokens.web.test.js +0 -27
- package/dist/esm/createTokens.web.test.js.map +0 -7
- package/dist/esm/createVariable.js +0 -78
- package/dist/esm/createVariable.js.map +0 -7
- package/dist/esm/createVariable.web.test.js +0 -6
- package/dist/esm/createVariable.web.test.js.map +0 -7
- package/dist/esm/createVariables.js +0 -35
- package/dist/esm/createVariables.js.map +0 -7
- package/dist/esm/helpers/RNComponents.js +0 -16
- package/dist/esm/helpers/RNComponents.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.js +0 -209
- package/dist/esm/helpers/ThemeManager.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.test.js +0 -464
- package/dist/esm/helpers/ThemeManager.test.js.map +0 -7
- package/dist/esm/helpers/ThemeManagerContext.js +0 -6
- package/dist/esm/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/esm/helpers/createMediaStyle.js +0 -42
- package/dist/esm/helpers/createMediaStyle.js.map +0 -7
- package/dist/esm/helpers/createPropMapper.js +0 -396
- package/dist/esm/helpers/createPropMapper.js.map +0 -7
- package/dist/esm/helpers/createProxy.js +0 -19
- package/dist/esm/helpers/createProxy.js.map +0 -7
- package/dist/esm/helpers/expandStyle.js +0 -71
- package/dist/esm/helpers/expandStyle.js.map +0 -7
- package/dist/esm/helpers/expandStyles.js +0 -90
- package/dist/esm/helpers/expandStyles.js.map +0 -7
- package/dist/esm/helpers/extendStaticConfig.js +0 -66
- package/dist/esm/helpers/extendStaticConfig.js.map +0 -7
- package/dist/esm/helpers/fixNativeShadow.js +0 -6
- package/dist/esm/helpers/fixNativeShadow.js.map +0 -7
- package/dist/esm/helpers/getAnimationDriver.js +0 -8
- package/dist/esm/helpers/getAnimationDriver.js.map +0 -7
- package/dist/esm/helpers/getExpandedShorthands.js +0 -16
- package/dist/esm/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/esm/helpers/getFontLanguage.js +0 -5
- package/dist/esm/helpers/getFontLanguage.js.map +0 -7
- package/dist/esm/helpers/getSplitStyles.js +0 -847
- package/dist/esm/helpers/getSplitStyles.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.js +0 -200
- package/dist/esm/helpers/getStylesAtomic.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -12
- package/dist/esm/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.js +0 -86
- package/dist/esm/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/esm/helpers/getVariantExtras.js +0 -67
- package/dist/esm/helpers/getVariantExtras.js.map +0 -7
- package/dist/esm/helpers/insertStyleRule.js +0 -186
- package/dist/esm/helpers/insertStyleRule.js.map +0 -7
- package/dist/esm/helpers/isObj.js +0 -5
- package/dist/esm/helpers/isObj.js.map +0 -7
- package/dist/esm/helpers/isTamaguiComponent.js +0 -8
- package/dist/esm/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/esm/helpers/isTamaguiElement.js +0 -9
- package/dist/esm/helpers/isTamaguiElement.js.map +0 -7
- package/dist/esm/helpers/matchMedia.js +0 -17
- package/dist/esm/helpers/matchMedia.js.map +0 -7
- package/dist/esm/helpers/matchMedia.native.js +0 -23
- package/dist/esm/helpers/matchMedia.native.js.map +0 -7
- package/dist/esm/helpers/mergeProps.js +0 -30
- package/dist/esm/helpers/mergeProps.js.map +0 -7
- package/dist/esm/helpers/mergeTransform.js +0 -21
- package/dist/esm/helpers/mergeTransform.js.map +0 -7
- package/dist/esm/helpers/normalizeColor.js +0 -36
- package/dist/esm/helpers/normalizeColor.js.map +0 -7
- package/dist/esm/helpers/normalizeValueWithProperty.js +0 -113
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/esm/helpers/proxyThemeVariables.js +0 -16
- package/dist/esm/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/esm/helpers/pseudoDescriptors.js +0 -29
- package/dist/esm/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/esm/helpers/registerCSSVariable.js +0 -14
- package/dist/esm/helpers/registerCSSVariable.js.map +0 -7
- package/dist/esm/helpers/themeable.js +0 -28
- package/dist/esm/helpers/themeable.js.map +0 -7
- package/dist/esm/helpers/themes.js +0 -53
- package/dist/esm/helpers/themes.js.map +0 -7
- package/dist/esm/helpers/timer.js +0 -11
- package/dist/esm/helpers/timer.js.map +0 -7
- package/dist/esm/helpers/useShallowSetState.js +0 -35
- package/dist/esm/helpers/useShallowSetState.js.map +0 -7
- package/dist/esm/helpers/warnOnce.js +0 -14
- package/dist/esm/helpers/warnOnce.js.map +0 -7
- package/dist/esm/helpers/withStaticProperties.js +0 -8
- package/dist/esm/helpers/withStaticProperties.js.map +0 -7
- package/dist/esm/hooks/getThemeUnwrapped.js +0 -9
- package/dist/esm/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/esm/hooks/useId.js +0 -5
- package/dist/esm/hooks/useId.js.map +0 -7
- package/dist/esm/hooks/useIsTouchDevice.js +0 -9
- package/dist/esm/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/esm/hooks/useMedia.js +0 -225
- package/dist/esm/hooks/useMedia.js.map +0 -7
- package/dist/esm/hooks/useSafeRef.js +0 -35
- package/dist/esm/hooks/useSafeRef.js.map +0 -7
- package/dist/esm/hooks/useServerHooks.js +0 -11
- package/dist/esm/hooks/useServerHooks.js.map +0 -7
- package/dist/esm/hooks/useStyle.js +0 -37
- package/dist/esm/hooks/useStyle.js.map +0 -7
- package/dist/esm/hooks/useTheme.js +0 -205
- package/dist/esm/hooks/useTheme.js.map +0 -7
- package/dist/esm/hooks/useThemeName.js +0 -28
- package/dist/esm/hooks/useThemeName.js.map +0 -7
- package/dist/esm/insertFont.js +0 -67
- package/dist/esm/insertFont.js.map +0 -7
- package/dist/esm/setupReactNative.js +0 -25
- package/dist/esm/setupReactNative.js.map +0 -7
- package/dist/esm/static.js +0 -3
- package/dist/esm/static.js.map +0 -7
- package/dist/esm/styled.js +0 -71
- package/dist/esm/styled.js.map +0 -7
- package/dist/esm/types-rnw.js +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/esm/updateTheme.js +0 -23
- package/dist/esm/updateTheme.js.map +0 -7
- package/dist/esm/views/FontLanguage.js +0 -17
- package/dist/esm/views/FontLanguage.js.map +0 -7
- package/dist/esm/views/FontLanguage.native.js +0 -11
- package/dist/esm/views/FontLanguage.native.js.map +0 -7
- package/dist/esm/views/FontLanguage.types.js +0 -1
- package/dist/esm/views/FontLanguage.types.js.map +0 -7
- package/dist/esm/views/Slot.js +0 -71
- package/dist/esm/views/Slot.js.map +0 -7
- package/dist/esm/views/Stack.js +0 -14
- package/dist/esm/views/Stack.js.map +0 -7
- package/dist/esm/views/Stack.web.test.js +0 -21
- package/dist/esm/views/Stack.web.test.js.map +0 -7
- package/dist/esm/views/TamaguiProvider.js +0 -56
- package/dist/esm/views/TamaguiProvider.js.map +0 -7
- package/dist/esm/views/Text.js +0 -70
- package/dist/esm/views/Text.js.map +0 -7
- package/dist/esm/views/Theme.js +0 -63
- package/dist/esm/views/Theme.js.map +0 -7
- package/dist/esm/views/ThemeProvider.js +0 -45
- package/dist/esm/views/ThemeProvider.js.map +0 -7
- package/src/Tamagui.ts +0 -48
- package/src/__snapshots__/createTokens.test.ts.snap +0 -772
- package/src/__snapshots__/createTokens.web.test.tsx.snap +0 -772
- package/src/addTheme.ts +0 -65
- package/src/config.ts +0 -62
- package/src/constants/constants.ts +0 -17
- package/src/constants/isDevTools.ts +0 -12
- package/src/contexts/ButtonNestingContext.tsx +0 -3
- package/src/contexts/FontLanguageContext.tsx +0 -5
- package/src/contexts/TextAncestorContext.tsx +0 -3
- package/src/createComponent.tsx +0 -1293
- package/src/createFont.ts +0 -50
- package/src/createShorthands.ts +0 -7
- package/src/createTamagui.ts +0 -253
- package/src/createTheme.ts +0 -13
- package/src/createTokens.ts +0 -46
- package/src/createVariable.ts +0 -93
- package/src/createVariables.ts +0 -55
- package/src/helpers/RNComponents.tsx +0 -14
- package/src/helpers/ThemeManager.tsx +0 -285
- package/src/helpers/ThemeManagerContext.tsx +0 -5
- package/src/helpers/createMediaStyle.ts +0 -56
- package/src/helpers/createPropMapper.ts +0 -562
- package/src/helpers/createProxy.ts +0 -16
- package/src/helpers/expandStyle.ts +0 -82
- package/src/helpers/expandStyles.ts +0 -107
- package/src/helpers/extendStaticConfig.ts +0 -78
- package/src/helpers/fixNativeShadow.tsx +0 -2
- package/src/helpers/getAnimationDriver.tsx +0 -5
- package/src/helpers/getExpandedShorthands.ts +0 -17
- package/src/helpers/getFontLanguage.ts +0 -2
- package/src/helpers/getSplitStyles.tsx +0 -1137
- package/src/helpers/getStylesAtomic.native.ts +0 -8
- package/src/helpers/getStylesAtomic.ts +0 -274
- package/src/helpers/getThemeCSSRules.native.ts +0 -3
- package/src/helpers/getThemeCSSRules.ts +0 -120
- package/src/helpers/getVariantExtras.tsx +0 -85
- package/src/helpers/insertStyleRule.tsx +0 -220
- package/src/helpers/isObj.ts +0 -1
- package/src/helpers/isTamaguiComponent.tsx +0 -11
- package/src/helpers/isTamaguiElement.tsx +0 -15
- package/src/helpers/matchMedia.native.ts +0 -23
- package/src/helpers/matchMedia.ts +0 -16
- package/src/helpers/mergeProps.ts +0 -56
- package/src/helpers/mergeTransform.ts +0 -30
- package/src/helpers/normalizeColor.ts +0 -38
- package/src/helpers/normalizeValueWithProperty.ts +0 -129
- package/src/helpers/proxyThemeVariables.tsx +0 -15
- package/src/helpers/pseudoDescriptors.ts +0 -40
- package/src/helpers/registerCSSVariable.ts +0 -13
- package/src/helpers/themeable.tsx +0 -44
- package/src/helpers/themes.ts +0 -67
- package/src/helpers/timer.ts +0 -9
- package/src/helpers/useShallowSetState.tsx +0 -41
- package/src/helpers/warnOnce.tsx +0 -11
- package/src/helpers/withStaticProperties.tsx +0 -7
- package/src/hooks/getThemeUnwrapped.tsx +0 -5
- package/src/hooks/useId.tsx +0 -1
- package/src/hooks/useIsTouchDevice.tsx +0 -6
- package/src/hooks/useMedia.tsx +0 -298
- package/src/hooks/useSafeRef.ts +0 -45
- package/src/hooks/useServerHooks.tsx +0 -12
- package/src/hooks/useStyle.tsx +0 -49
- package/src/hooks/useTheme.tsx +0 -274
- package/src/hooks/useThemeName.tsx +0 -27
- package/src/insertFont.ts +0 -73
- package/src/setupReactNative.ts +0 -22
- package/src/static.ts +0 -5
- package/src/styled.tsx +0 -195
- package/src/types-rnw.tsx +0 -162
- package/src/types.tsx +0 -1405
- package/src/updateTheme.ts +0 -26
- package/src/views/FontLanguage.native.tsx +0 -12
- package/src/views/FontLanguage.tsx +0 -16
- package/src/views/FontLanguage.types.ts +0 -13
- package/src/views/Slot.tsx +0 -102
- package/src/views/Stack.tsx +0 -25
- package/src/views/TamaguiProvider.tsx +0 -65
- package/src/views/Text.tsx +0 -88
- package/src/views/Theme.tsx +0 -83
- package/src/views/ThemeProvider.tsx +0 -55
- package/types/Tamagui.d.ts +0 -30
- package/types/Tamagui.d.ts.map +0 -1
- package/types/addTheme.d.ts +0 -32
- package/types/addTheme.d.ts.map +0 -1
- package/types/config.d.ts +0 -49
- package/types/config.d.ts.map +0 -1
- package/types/constants/constants.d.ts +0 -21
- package/types/constants/constants.d.ts.map +0 -1
- package/types/constants/isDevTools.d.ts +0 -2
- package/types/constants/isDevTools.d.ts.map +0 -1
- package/types/contexts/ButtonNestingContext.d.ts +0 -3
- package/types/contexts/ButtonNestingContext.d.ts.map +0 -1
- package/types/contexts/FontLanguageContext.d.ts +0 -5
- package/types/contexts/FontLanguageContext.d.ts.map +0 -1
- package/types/contexts/TextAncestorContext.d.ts +0 -3
- package/types/contexts/TextAncestorContext.d.ts.map +0 -1
- package/types/createComponent.d.ts +0 -23
- package/types/createComponent.d.ts.map +0 -1
- package/types/createFont.d.ts +0 -3
- package/types/createFont.d.ts.map +0 -1
- package/types/createFont.web.test.d.ts +0 -2
- package/types/createFont.web.test.d.ts.map +0 -1
- package/types/createShorthands.d.ts +0 -3
- package/types/createShorthands.d.ts.map +0 -1
- package/types/createTamagui.d.ts +0 -3
- package/types/createTamagui.d.ts.map +0 -1
- package/types/createTheme.d.ts +0 -7
- package/types/createTheme.d.ts.map +0 -1
- package/types/createTokens.d.ts +0 -28
- package/types/createTokens.d.ts.map +0 -1
- package/types/createTokens.web.test.d.ts +0 -2
- package/types/createTokens.web.test.d.ts.map +0 -1
- package/types/createVariable.d.ts +0 -26
- package/types/createVariable.d.ts.map +0 -1
- package/types/createVariable.web.test.d.ts +0 -2
- package/types/createVariable.web.test.d.ts.map +0 -1
- package/types/createVariables.d.ts +0 -11
- package/types/createVariables.d.ts.map +0 -1
- package/types/helpers/RNComponents.d.ts +0 -2
- package/types/helpers/RNComponents.d.ts.map +0 -1
- package/types/helpers/ThemeManager.d.ts +0 -36
- package/types/helpers/ThemeManager.d.ts.map +0 -1
- package/types/helpers/ThemeManager.test.d.ts +0 -2
- package/types/helpers/ThemeManager.test.d.ts.map +0 -1
- package/types/helpers/ThemeManagerContext.d.ts +0 -4
- package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
- package/types/helpers/createMediaStyle.d.ts +0 -6
- package/types/helpers/createMediaStyle.d.ts.map +0 -1
- package/types/helpers/createPropMapper.d.ts +0 -7
- package/types/helpers/createPropMapper.d.ts.map +0 -1
- package/types/helpers/createProxy.d.ts +0 -2
- package/types/helpers/createProxy.d.ts.map +0 -1
- package/types/helpers/expandStyle.d.ts +0 -6
- package/types/helpers/expandStyle.d.ts.map +0 -1
- package/types/helpers/expandStyles.d.ts +0 -26
- package/types/helpers/expandStyles.d.ts.map +0 -1
- package/types/helpers/extendStaticConfig.d.ts +0 -4
- package/types/helpers/extendStaticConfig.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.d.ts +0 -2
- package/types/helpers/fixNativeShadow.d.ts.map +0 -1
- package/types/helpers/getAnimationDriver.d.ts +0 -6
- package/types/helpers/getAnimationDriver.d.ts.map +0 -1
- package/types/helpers/getExpandedShorthands.d.ts +0 -3
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
- package/types/helpers/getFontLanguage.d.ts +0 -2
- package/types/helpers/getFontLanguage.d.ts.map +0 -1
- package/types/helpers/getSplitStyles.d.ts +0 -43
- package/types/helpers/getSplitStyles.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -18
- package/types/helpers/getStylesAtomic.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.native.d.ts +0 -4
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.d.ts +0 -8
- package/types/helpers/getThemeCSSRules.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.native.d.ts +0 -2
- package/types/helpers/getThemeCSSRules.native.d.ts.map +0 -1
- package/types/helpers/getVariantExtras.d.ts +0 -5
- package/types/helpers/getVariantExtras.d.ts.map +0 -1
- package/types/helpers/insertStyleRule.d.ts +0 -13
- package/types/helpers/insertStyleRule.d.ts.map +0 -1
- package/types/helpers/isObj.d.ts +0 -2
- package/types/helpers/isObj.d.ts.map +0 -1
- package/types/helpers/isTamaguiComponent.d.ts +0 -5
- package/types/helpers/isTamaguiComponent.d.ts.map +0 -1
- package/types/helpers/isTamaguiElement.d.ts +0 -7
- package/types/helpers/isTamaguiElement.d.ts.map +0 -1
- package/types/helpers/matchMedia.d.ts +0 -6
- package/types/helpers/matchMedia.d.ts.map +0 -1
- package/types/helpers/matchMedia.native.d.ts +0 -4
- package/types/helpers/matchMedia.native.d.ts.map +0 -1
- package/types/helpers/mergeProps.d.ts +0 -17
- package/types/helpers/mergeProps.d.ts.map +0 -1
- package/types/helpers/mergeTransform.d.ts +0 -9
- package/types/helpers/mergeTransform.d.ts.map +0 -1
- package/types/helpers/normalizeColor.d.ts +0 -4
- package/types/helpers/normalizeColor.d.ts.map +0 -1
- package/types/helpers/normalizeValueWithProperty.d.ts +0 -7
- package/types/helpers/normalizeValueWithProperty.d.ts.map +0 -1
- package/types/helpers/proxyThemeVariables.d.ts +0 -2
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
- package/types/helpers/pseudoDescriptors.d.ts +0 -10
- package/types/helpers/pseudoDescriptors.d.ts.map +0 -1
- package/types/helpers/registerCSSVariable.d.ts +0 -5
- package/types/helpers/registerCSSVariable.d.ts.map +0 -1
- package/types/helpers/themeable.d.ts +0 -12
- package/types/helpers/themeable.d.ts.map +0 -1
- package/types/helpers/themes.d.ts +0 -4
- package/types/helpers/themes.d.ts.map +0 -1
- package/types/helpers/timer.d.ts +0 -2
- package/types/helpers/timer.d.ts.map +0 -1
- package/types/helpers/useShallowSetState.d.ts +0 -5
- package/types/helpers/useShallowSetState.d.ts.map +0 -1
- package/types/helpers/warnOnce.d.ts +0 -2
- package/types/helpers/warnOnce.d.ts.map +0 -1
- package/types/helpers/withStaticProperties.d.ts +0 -2
- package/types/helpers/withStaticProperties.d.ts.map +0 -1
- package/types/hooks/getThemeUnwrapped.d.ts +0 -3
- package/types/hooks/getThemeUnwrapped.d.ts.map +0 -1
- package/types/hooks/useId.d.ts +0 -2
- package/types/hooks/useId.d.ts.map +0 -1
- package/types/hooks/useIsTouchDevice.d.ts +0 -2
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
- package/types/hooks/useMedia.d.ts +0 -33
- package/types/hooks/useMedia.d.ts.map +0 -1
- package/types/hooks/useSafeRef.d.ts +0 -4
- package/types/hooks/useSafeRef.d.ts.map +0 -1
- package/types/hooks/useServerHooks.d.ts +0 -4
- package/types/hooks/useServerHooks.d.ts.map +0 -1
- package/types/hooks/useStyle.d.ts +0 -8
- package/types/hooks/useStyle.d.ts.map +0 -1
- package/types/hooks/useTheme.d.ts +0 -25
- package/types/hooks/useTheme.d.ts.map +0 -1
- package/types/hooks/useThemeName.d.ts +0 -5
- package/types/hooks/useThemeName.d.ts.map +0 -1
- package/types/insertFont.d.ts +0 -9
- package/types/insertFont.d.ts.map +0 -1
- package/types/setupReactNative.d.ts +0 -5
- package/types/setupReactNative.d.ts.map +0 -1
- package/types/static.d.ts +0 -3
- package/types/static.d.ts.map +0 -1
- package/types/styled.d.ts +0 -20
- package/types/styled.d.ts.map +0 -1
- package/types/types-rnw.d.ts +0 -74
- package/types/types-rnw.d.ts.map +0 -1
- package/types/types.d.ts +0 -673
- package/types/types.d.ts.map +0 -1
- package/types/updateTheme.d.ts +0 -30
- package/types/updateTheme.d.ts.map +0 -1
- package/types/views/FontLanguage.d.ts +0 -4
- package/types/views/FontLanguage.d.ts.map +0 -1
- package/types/views/FontLanguage.native.d.ts +0 -4
- package/types/views/FontLanguage.native.d.ts.map +0 -1
- package/types/views/FontLanguage.types.d.ts +0 -11
- package/types/views/FontLanguage.types.d.ts.map +0 -1
- package/types/views/Slot.d.ts +0 -11
- package/types/views/Slot.d.ts.map +0 -1
- package/types/views/Stack.d.ts +0 -4
- package/types/views/Stack.d.ts.map +0 -1
- package/types/views/Stack.web.test.d.ts +0 -2
- package/types/views/Stack.web.test.d.ts.map +0 -1
- package/types/views/TamaguiProvider.d.ts +0 -4
- package/types/views/TamaguiProvider.d.ts.map +0 -1
- package/types/views/Text.d.ts +0 -4
- package/types/views/Text.d.ts.map +0 -1
- package/types/views/Theme.d.ts +0 -8
- package/types/views/Theme.d.ts.map +0 -1
- package/types/views/ThemeProvider.d.ts +0 -12
- package/types/views/ThemeProvider.d.ts.map +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { isRSC, isWeb } from "@tamagui/constants";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { FontLanguageContext } from "../contexts/FontLanguageContext";
|
|
4
|
-
import { TextAncestorContext } from "../contexts/TextAncestorContext";
|
|
5
|
-
import { useSplitStyles } from "../helpers/getSplitStyles";
|
|
6
|
-
import { useMedia } from "./useMedia";
|
|
7
|
-
import { useTheme } from "./useTheme";
|
|
8
|
-
function useStyle(base, style, options) {
|
|
9
|
-
const isText = base.staticConfig.isText;
|
|
10
|
-
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false);
|
|
11
|
-
const languageContext = isRSC ? null : useContext(FontLanguageContext);
|
|
12
|
-
const theme = useTheme();
|
|
13
|
-
const media = useMedia();
|
|
14
|
-
const out = useSplitStyles(
|
|
15
|
-
style,
|
|
16
|
-
base.staticConfig,
|
|
17
|
-
theme,
|
|
18
|
-
{
|
|
19
|
-
...options,
|
|
20
|
-
mediaState: media,
|
|
21
|
-
hasTextAncestor,
|
|
22
|
-
resolveVariablesAs: "auto"
|
|
23
|
-
},
|
|
24
|
-
null,
|
|
25
|
-
languageContext || void 0,
|
|
26
|
-
isText ? "span" : "div",
|
|
27
|
-
options == null ? void 0 : options.debug
|
|
28
|
-
);
|
|
29
|
-
return {
|
|
30
|
-
style: Object.keys(out.style).length ? out.style : null,
|
|
31
|
-
classNames: out.classNames
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
useStyle
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=useStyle.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useStyle.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\nimport { useContext } from 'react'\n\nimport { FontLanguageContext } from '../contexts/FontLanguageContext'\nimport { TextAncestorContext } from '../contexts/TextAncestorContext'\nimport { useSplitStyles } from '../helpers/getSplitStyles'\nimport {\n DebugProp,\n GetProps,\n SplitStyleState,\n TamaguiComponent,\n TextNonStyleProps,\n} from '../types'\nimport { useMedia } from './useMedia'\nimport { useTheme } from './useTheme'\n\nexport function useStyle<\n Component extends TamaguiComponent,\n StyleProps = Omit<GetProps<Component>, keyof TextNonStyleProps>\n>(\n base: Component,\n style: StyleProps,\n options?: Partial<SplitStyleState> & { debug?: DebugProp }\n) {\n const isText = base.staticConfig.isText\n const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)\n const languageContext = isRSC ? null : useContext(FontLanguageContext)\n const theme = useTheme()\n const media = useMedia()\n const out = useSplitStyles(\n style as any,\n base.staticConfig,\n theme,\n {\n ...(options as any),\n mediaState: media,\n hasTextAncestor,\n resolveVariablesAs: 'auto',\n },\n null,\n languageContext || undefined,\n isText ? 'span' : 'div',\n options?.debug\n )\n return {\n style: Object.keys(out.style).length ? out.style : null,\n classNames: out.classNames,\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,OAAO,aAAa;AAC7B,SAAS,kBAAkB;AAE3B,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAQ/B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAElB,SAAS,SAId,MACA,OACA,SACA;AACA,QAAM,SAAS,KAAK,aAAa;AACjC,QAAM,kBAAkB,CAAC,EAAE,SAAS,SAAS,WAAW,mBAAmB,IAAI;AAC/E,QAAM,kBAAkB,QAAQ,OAAO,WAAW,mBAAmB;AACrE,QAAM,QAAQ,SAAS;AACvB,QAAM,QAAQ,SAAS;AACvB,QAAM,MAAM;AAAA,IACV;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAI;AAAA,MACJ,YAAY;AAAA,MACZ;AAAA,MACA,oBAAoB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB,SAAS,SAAS;AAAA,IAClB,mCAAS;AAAA,EACX;AACA,SAAO;AAAA,IACL,OAAO,OAAO,KAAK,IAAI,KAAK,EAAE,SAAS,IAAI,QAAQ;AAAA,IACnD,YAAY,IAAI;AAAA,EAClB;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { isClient, isRSC, isServer, isWeb } from "@tamagui/constants";
|
|
2
|
-
import { useContext, useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { getConfig } from "../config";
|
|
4
|
-
import { isDevTools } from "../constants/isDevTools";
|
|
5
|
-
import { createProxy } from "../helpers/createProxy";
|
|
6
|
-
import {
|
|
7
|
-
ThemeManager,
|
|
8
|
-
hasNoThemeUpdatingProps
|
|
9
|
-
} from "../helpers/ThemeManager";
|
|
10
|
-
import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
|
|
11
|
-
import { GetThemeUnwrapped } from "./getThemeUnwrapped";
|
|
12
|
-
import { useServerRef } from "./useServerHooks";
|
|
13
|
-
const emptyProps = { name: null };
|
|
14
|
-
function getDefaultThemeProxied() {
|
|
15
|
-
const config = getConfig();
|
|
16
|
-
const name = Object.keys(config.themes)[0];
|
|
17
|
-
return getThemeProxied({
|
|
18
|
-
theme: config.themes[name],
|
|
19
|
-
name
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
const useTheme = (props = emptyProps) => {
|
|
23
|
-
var _a;
|
|
24
|
-
return (isRSC ? null : (_a = useThemeWithState(props)) == null ? void 0 : _a.theme) || getDefaultThemeProxied();
|
|
25
|
-
};
|
|
26
|
-
const useThemeWithState = (props) => {
|
|
27
|
-
var _a;
|
|
28
|
-
const keys = useServerRef([]);
|
|
29
|
-
const changedTheme = useChangeThemeEffect(
|
|
30
|
-
props,
|
|
31
|
-
false,
|
|
32
|
-
isClient ? () => {
|
|
33
|
-
var _a2;
|
|
34
|
-
return ((_a2 = props.shouldUpdate) == null ? void 0 : _a2.call(props)) ?? keys.current.length === 0;
|
|
35
|
-
} : void 0
|
|
36
|
-
);
|
|
37
|
-
const { themeManager, isNewTheme, theme, name, className } = changedTheme;
|
|
38
|
-
if (process.env.NODE_ENV === "development") {
|
|
39
|
-
if (isWeb && isNewTheme && className === ((_a = themeManager == null ? void 0 : themeManager.parentManager) == null ? void 0 : _a.state.className)) {
|
|
40
|
-
console.error("Should always change, duplicating ThemeMananger bug", themeManager);
|
|
41
|
-
}
|
|
42
|
-
if (props.debug === "verbose") {
|
|
43
|
-
console.groupCollapsed(" \u{1F539} useTheme =>", name);
|
|
44
|
-
const logs = { ...props, name, className, ...isDevTools && { theme } };
|
|
45
|
-
for (const key in logs) {
|
|
46
|
-
console.log(" ", key, logs[key]);
|
|
47
|
-
}
|
|
48
|
-
console.groupEnd();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!changedTheme.theme) {
|
|
52
|
-
if (process.env.NODE_ENV === "development") {
|
|
53
|
-
console.warn("No theme found", name, props, themeManager);
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
const proxiedTheme = useMemo(() => {
|
|
58
|
-
return getThemeProxied(changedTheme);
|
|
59
|
-
}, [theme, isNewTheme, name, className, themeManager]);
|
|
60
|
-
return {
|
|
61
|
-
...changedTheme,
|
|
62
|
-
theme: proxiedTheme
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
function getThemeProxied({
|
|
66
|
-
theme,
|
|
67
|
-
themeManager,
|
|
68
|
-
keys
|
|
69
|
-
}) {
|
|
70
|
-
return createProxy(theme, {
|
|
71
|
-
has(_, key) {
|
|
72
|
-
if (typeof key === "string") {
|
|
73
|
-
if (key[0] === "$")
|
|
74
|
-
key = key.slice(1);
|
|
75
|
-
return themeManager == null ? void 0 : themeManager.allKeys.has(key);
|
|
76
|
-
}
|
|
77
|
-
return Reflect.has(theme, key);
|
|
78
|
-
},
|
|
79
|
-
get(_, key) {
|
|
80
|
-
if (key === GetThemeUnwrapped) {
|
|
81
|
-
return theme;
|
|
82
|
-
}
|
|
83
|
-
if (key === "undefined" || key === "__proto__" || key === "$typeof" || typeof key !== "string" || !themeManager) {
|
|
84
|
-
return Reflect.get(_, key);
|
|
85
|
-
}
|
|
86
|
-
const keyString = key;
|
|
87
|
-
if (key[0] === "$") {
|
|
88
|
-
key = key.slice(1);
|
|
89
|
-
}
|
|
90
|
-
const val = themeManager.getValue(key);
|
|
91
|
-
const currentKeys = keys == null ? void 0 : keys.current;
|
|
92
|
-
if (val && currentKeys) {
|
|
93
|
-
return new Proxy(val, {
|
|
94
|
-
// when they touch the actual value we only track it
|
|
95
|
-
// if its a variable (web), its ignored!
|
|
96
|
-
get(_2, subkey) {
|
|
97
|
-
if (subkey === "val" && !currentKeys.includes(keyString)) {
|
|
98
|
-
currentKeys.push(keyString);
|
|
99
|
-
}
|
|
100
|
-
return Reflect.get(val, subkey);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return val;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
const activeThemeManagers = /* @__PURE__ */ new Set();
|
|
109
|
-
const useChangeThemeEffect = (props, root = false, disableUpdate) => {
|
|
110
|
-
if (isRSC) {
|
|
111
|
-
return {
|
|
112
|
-
...createState().state,
|
|
113
|
-
themeManager: null
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const parentManager = useContext(ThemeManagerContext);
|
|
117
|
-
const {
|
|
118
|
-
debug,
|
|
119
|
-
// @ts-expect-error internal use only
|
|
120
|
-
disable
|
|
121
|
-
} = props;
|
|
122
|
-
if (disable) {
|
|
123
|
-
if (!parentManager)
|
|
124
|
-
throw `\u274C`;
|
|
125
|
-
return {
|
|
126
|
-
...parentManager.state,
|
|
127
|
-
isNewTheme: false,
|
|
128
|
-
themeManager: parentManager
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const [themeState, setThemeState] = useState(createState);
|
|
132
|
-
const { isNewTheme, state, themeManager, mounted } = themeState;
|
|
133
|
-
if (!isServer) {
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
if (disable)
|
|
136
|
-
return;
|
|
137
|
-
if (props.inverse && !mounted) {
|
|
138
|
-
setThemeState({ ...themeState, mounted: true });
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
activeThemeManagers.add(themeManager);
|
|
142
|
-
return () => {
|
|
143
|
-
activeThemeManagers.delete(themeManager);
|
|
144
|
-
};
|
|
145
|
-
}, [disable, state, isNewTheme, debug]);
|
|
146
|
-
}
|
|
147
|
-
const isInversingOnMount = Boolean(!themeState.mounted && props.inverse);
|
|
148
|
-
const shouldReturnParentState = hasNoThemeUpdatingProps(props) || isInversingOnMount;
|
|
149
|
-
if (shouldReturnParentState) {
|
|
150
|
-
if (!parentManager)
|
|
151
|
-
throw "impossible";
|
|
152
|
-
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
153
|
-
console.log("useTheme hasNoThemeUpdatingProps", parentManager.state.name, "isInversingOnMount", isInversingOnMount);
|
|
154
|
-
return {
|
|
155
|
-
...parentManager.state,
|
|
156
|
-
className: isInversingOnMount ? "" : parentManager.state.className,
|
|
157
|
-
themeManager: parentManager,
|
|
158
|
-
isNewTheme: false
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
updateState();
|
|
162
|
-
return {
|
|
163
|
-
...state,
|
|
164
|
-
isNewTheme,
|
|
165
|
-
themeManager
|
|
166
|
-
};
|
|
167
|
-
function createState(prev) {
|
|
168
|
-
if (prev && (disableUpdate == null ? void 0 : disableUpdate())) {
|
|
169
|
-
return prev;
|
|
170
|
-
}
|
|
171
|
-
const _ = new ThemeManager(props, root ? "root" : parentManager);
|
|
172
|
-
const isNewTheme2 = _ !== parentManager;
|
|
173
|
-
const mounted2 = !props.inverse ? true : root || (prev == null ? void 0 : prev.mounted);
|
|
174
|
-
return {
|
|
175
|
-
// ThemeManager returns parentManager if no change
|
|
176
|
-
isNewTheme: isNewTheme2,
|
|
177
|
-
state: { ..._.state },
|
|
178
|
-
themeManager: _,
|
|
179
|
-
mounted: mounted2
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function updateState(updatingManager) {
|
|
183
|
-
if (disableUpdate == null ? void 0 : disableUpdate()) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const manager = updatingManager ?? themeManager;
|
|
187
|
-
const next = manager.getState(props, parentManager);
|
|
188
|
-
const shouldChange = manager.getStateShouldChange(next, isNewTheme ? state : null);
|
|
189
|
-
if (shouldChange) {
|
|
190
|
-
setThemeState(createState);
|
|
191
|
-
} else {
|
|
192
|
-
if (!next && (parentManager == null ? void 0 : parentManager.state.name) !== state.name) {
|
|
193
|
-
setThemeState(createState);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
export {
|
|
199
|
-
activeThemeManagers,
|
|
200
|
-
getThemeProxied,
|
|
201
|
-
useChangeThemeEffect,
|
|
202
|
-
useTheme,
|
|
203
|
-
useThemeWithState
|
|
204
|
-
};
|
|
205
|
-
//# sourceMappingURL=useTheme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport {\n ThemeManager,\n ThemeManagerState,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useServerRef } from './useServerHooks'\n\nexport type ChangedThemeResponse = {\n themeManager: ThemeManager | null\n name: string\n isNewTheme?: boolean\n theme?: ThemeParsed | null\n className?: string\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n return (isRSC ? null : useThemeWithState(props)?.theme) || getDefaultThemeProxied()\n}\n\nexport const useThemeWithState = (props: ThemeProps) => {\n const keys = useServerRef([])\n\n const changedTheme = useChangeThemeEffect(\n props,\n false,\n isClient\n ? () => {\n return props.shouldUpdate?.() ?? keys.current.length === 0\n }\n : undefined\n )\n\n const { themeManager, isNewTheme, theme, name, className } = changedTheme\n\n if (process.env.NODE_ENV === 'development') {\n // ensure we aren't creating too many ThemeManagers\n // prettier-ignore\n if (isWeb && isNewTheme && className === themeManager?.parentManager?.state.className) {\n console.error('Should always change, duplicating ThemeMananger bug', themeManager)\n }\n if (props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n }\n\n if (!changedTheme.theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return null\n }\n\n const proxiedTheme = useMemo(() => {\n return getThemeProxied(changedTheme as any)\n }, [theme, isNewTheme, name, className, themeManager])\n\n return {\n ...changedTheme,\n theme: proxiedTheme,\n }\n}\n\nexport function getThemeProxied({\n theme,\n themeManager,\n keys,\n}: Partial<ChangedThemeResponse> & {\n theme: ThemeParsed\n keys?: React.RefObject<string[]>\n}) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (\n key === 'undefined' ||\n key === '__proto__' ||\n key === '$typeof' ||\n typeof key !== 'string' ||\n !themeManager\n ) {\n return Reflect.get(_, key)\n }\n const keyString = key\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n const currentKeys = keys?.current\n if (val && currentKeys) {\n return new Proxy(val as any, {\n // when they touch the actual value we only track it\n // if its a variable (web), its ignored!\n get(_, subkey) {\n if (subkey === 'val' && !currentKeys.includes(keyString)) {\n currentKeys.push(keyString)\n }\n return Reflect.get(val as any, subkey)\n },\n })\n }\n return val\n },\n })\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n ...createState().state,\n themeManager: null,\n }\n }\n const parentManager = useContext(ThemeManagerContext)\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n if (disable) {\n if (!parentManager) throw `\u274C`\n return {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }\n }\n\n type State = {\n isNewTheme: boolean\n state: ThemeManagerState\n themeManager: ThemeManager\n mounted?: boolean\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { isNewTheme, state, themeManager, mounted } = themeState\n\n if (!isServer) {\n useEffect(() => {\n if (disable) return\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n activeThemeManagers.add(themeManager)\n // const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {\n // // console.log('hi', props, state, name, manager)\n // if (state.theme !== manager.state.theme) {\n // console.warn('now update to', manager.state.name)\n // updateState(manager)\n // }\n // })\n return () => {\n activeThemeManagers.delete(themeManager)\n // disposeChangeListener?.()\n }\n }, [disable, state, isNewTheme, debug])\n }\n\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = hasNoThemeUpdatingProps(props) || isInversingOnMount\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('useTheme hasNoThemeUpdatingProps', parentManager.state.name, 'isInversingOnMount', isInversingOnMount)\n return {\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n isNewTheme: false,\n }\n }\n\n // run inline in render\n updateState()\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State) {\n if (prev && disableUpdate?.()) {\n return prev\n }\n // returns previous theme manager if no change\n const _ = new ThemeManager(props, root ? 'root' : parentManager)\n const isNewTheme = _ !== parentManager\n // prettier-ignore\n\n // if (prev?.isNewTheme && _.state.theme !== parentManager?.state.theme) {\n // console.warn('notify')\n // _.notify()\n // }\n\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n return {\n // ThemeManager returns parentManager if no change\n isNewTheme,\n state: { ..._.state },\n themeManager: _,\n mounted,\n }\n }\n\n function updateState(updatingManager?: ThemeManager) {\n if (disableUpdate?.()) {\n return\n }\n const manager = updatingManager ?? themeManager\n const next = manager.getState(props, parentManager)\n const shouldChange = manager.getStateShouldChange(next, isNewTheme ? state : null)\n // console.log(`got it`, next, isNewTheme, shouldChange, { ...updatingManager?.state })\n if (shouldChange) {\n setThemeState(createState)\n } else {\n if (!next && parentManager?.state.name !== state.name) {\n // were changing back to parent state\n setThemeState(createState)\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["_a", "_", "isNewTheme", "mounted"]
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { isRSC, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
-
import { useContext, useState } from "react";
|
|
3
|
-
import { getConfig } from "../config";
|
|
4
|
-
import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
|
|
5
|
-
function useThemeName(opts) {
|
|
6
|
-
if (isRSC) {
|
|
7
|
-
const config = getConfig();
|
|
8
|
-
return config.themes[Object.keys(config.themes)[0]];
|
|
9
|
-
}
|
|
10
|
-
const manager = useContext(ThemeManagerContext);
|
|
11
|
-
const [name, setName] = useState((manager == null ? void 0 : manager.state.name) || "");
|
|
12
|
-
useIsomorphicLayoutEffect(() => {
|
|
13
|
-
if (!manager)
|
|
14
|
-
return;
|
|
15
|
-
setName(manager.state.name);
|
|
16
|
-
return manager.onChangeTheme((next, manager2) => {
|
|
17
|
-
const name2 = (opts == null ? void 0 : opts.parent) ? manager2.state.parentName || next : next;
|
|
18
|
-
if (!name2)
|
|
19
|
-
return;
|
|
20
|
-
setName(name2);
|
|
21
|
-
});
|
|
22
|
-
}, [manager == null ? void 0 : manager.state.name]);
|
|
23
|
-
return name;
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
useThemeName
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=useThemeName.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useThemeName.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isRSC, useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useContext, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeName } from '../types'\n\nexport function useThemeName(opts?: { parent?: true }): ThemeName {\n if (isRSC) {\n const config = getConfig()\n return config.themes[Object.keys(config.themes)[0]] as any\n }\n const manager = useContext(ThemeManagerContext)\n const [name, setName] = useState(manager?.state.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!manager) return\n setName(manager.state.name)\n return manager.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.state.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [manager?.state.name])\n\n return name\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,OAAO,iCAAiC;AACjD,SAAS,YAAY,gBAAgB;AAErC,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAG7B,SAAS,aAAa,MAAqC;AAChE,MAAI,OAAO;AACT,UAAM,SAAS,UAAU;AACzB,WAAO,OAAO,OAAO,OAAO,KAAK,OAAO,MAAM,EAAE,CAAC,CAAC;AAAA,EACpD;AACA,QAAM,UAAU,WAAW,mBAAmB;AAC9C,QAAM,CAAC,MAAM,OAAO,IAAI,UAAS,mCAAS,MAAM,SAAQ,EAAE;AAE1D,4BAA0B,MAAM;AAC9B,QAAI,CAAC;AAAS;AACd,YAAQ,QAAQ,MAAM,IAAI;AAC1B,WAAO,QAAQ,cAAc,CAAC,MAAMA,aAAY;AAC9C,YAAMC,SAAO,6BAAM,UAASD,SAAQ,MAAM,cAAc,OAAO;AAC/D,UAAI,CAACC;AAAM;AACX,cAAQA,KAAI;AAAA,IACd,CAAC;AAAA,EACH,GAAG,CAAC,mCAAS,MAAM,IAAI,CAAC;AAExB,SAAO;AACT;",
|
|
6
|
-
"names": ["manager", "name"]
|
|
7
|
-
}
|
package/dist/esm/insertFont.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { setConfigFont } from "./config";
|
|
2
|
-
import { createFont } from "./createFont";
|
|
3
|
-
import { createVariables } from "./createVariables";
|
|
4
|
-
import { registerCSSVariable, variableToCSS } from "./helpers/registerCSSVariable";
|
|
5
|
-
function insertFont(name, fontIn) {
|
|
6
|
-
const font = createFont(fontIn);
|
|
7
|
-
const tokened = createVariables(font, name);
|
|
8
|
-
const parsed = parseFont(tokened);
|
|
9
|
-
if (process.env.TAMAGUI_TARGET === "web" && typeof document !== "undefined") {
|
|
10
|
-
const fontVars = registerFontVariables(parsed);
|
|
11
|
-
const style = document.createElement("style");
|
|
12
|
-
style.innerText = `:root .font_${name} {${fontVars.join(";")}}`;
|
|
13
|
-
style.setAttribute("data-tamagui-font", name);
|
|
14
|
-
document.head.appendChild(style);
|
|
15
|
-
}
|
|
16
|
-
setConfigFont(name, tokened, parsed);
|
|
17
|
-
return parsed;
|
|
18
|
-
}
|
|
19
|
-
function parseFont(definition) {
|
|
20
|
-
var _a;
|
|
21
|
-
const parsed = {};
|
|
22
|
-
for (const attrKey in definition) {
|
|
23
|
-
const attr = definition[attrKey];
|
|
24
|
-
if (attrKey === "family" || attrKey === "face") {
|
|
25
|
-
parsed[attrKey] = attr;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
parsed[attrKey] = {};
|
|
29
|
-
for (const key in attr) {
|
|
30
|
-
let val = attr[key];
|
|
31
|
-
if (((_a = val.val) == null ? void 0 : _a[0]) === "$") {
|
|
32
|
-
val = val.val;
|
|
33
|
-
}
|
|
34
|
-
parsed[attrKey][`$${key}`] = val;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return parsed;
|
|
38
|
-
}
|
|
39
|
-
function registerFontVariables(parsedFont) {
|
|
40
|
-
const response = [];
|
|
41
|
-
for (const fkey in parsedFont) {
|
|
42
|
-
if (fkey === "face")
|
|
43
|
-
continue;
|
|
44
|
-
if (fkey === "family") {
|
|
45
|
-
const val = parsedFont[fkey];
|
|
46
|
-
registerCSSVariable(val);
|
|
47
|
-
response.push(variableToCSS(val));
|
|
48
|
-
} else {
|
|
49
|
-
for (const fskey in parsedFont[fkey]) {
|
|
50
|
-
const fval = parsedFont[fkey][fskey];
|
|
51
|
-
if (typeof fval === "string") {
|
|
52
|
-
} else {
|
|
53
|
-
const val = parsedFont[fkey][fskey];
|
|
54
|
-
registerCSSVariable(val);
|
|
55
|
-
response.push(variableToCSS(val));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return response;
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
insertFont,
|
|
64
|
-
parseFont,
|
|
65
|
-
registerFontVariables
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=insertFont.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/insertFont.ts"],
|
|
4
|
-
"sourcesContent": ["import { setConfigFont } from './config'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable, variableToCSS } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\n/**\n * Runtime dynamic insert font\n */\nexport function insertFont<A extends GenericFont>(\n name: string,\n fontIn: A\n): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n if (process.env.TAMAGUI_TARGET === 'web' && typeof document !== 'undefined') {\n const fontVars = registerFontVariables(parsed)\n const style = document.createElement('style')\n style.innerText = `:root .font_${name} {${fontVars.join(';')}}`\n style.setAttribute('data-tamagui-font', name)\n document.head.appendChild(style)\n }\n setConfigFont(name, tokened, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family' || attrKey === 'face') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any\n // is a theme reference\n if (val.val?.[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any) {\n const response: string[] = []\n\n for (const fkey in parsedFont) {\n if (fkey === 'face') continue\n if (fkey === 'family') {\n const val = parsedFont[fkey] as Variable\n registerCSSVariable(val)\n response.push(variableToCSS(val))\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference like \"$borderColor\"\n } else {\n const val = parsedFont[fkey][fskey] as Variable\n registerCSSVariable(val)\n response.push(variableToCSS(val))\n }\n }\n }\n }\n return response\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAE3B,SAA6B,uBAAuB;AACpD,SAAS,qBAAqB,qBAAqB;AAM5C,SAAS,WACd,MACA,QACuB;AACvB,QAAM,OAAO,WAAW,MAAM;AAC9B,QAAM,UAAU,gBAAgB,MAAM,IAAI;AAC1C,QAAM,SAAS,UAAU,OAAO;AAChC,MAAI,QAAQ,IAAI,mBAAmB,SAAS,OAAO,aAAa,aAAa;AAC3E,UAAM,WAAW,sBAAsB,MAAM;AAC7C,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,YAAY,eAAe,SAAS,SAAS,KAAK,GAAG;AAC3D,UAAM,aAAa,qBAAqB,IAAI;AAC5C,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AACA,gBAAc,MAAM,SAAS,MAAM;AACnC,SAAO;AACT;AAEO,SAAS,UAAiC,YAAsC;AA5BvF;AA6BE,QAAM,SAAc,CAAC;AACrB,aAAW,WAAW,YAAY;AAChC,UAAM,OAAO,WAAW,OAAO;AAC/B,QAAI,YAAY,YAAY,YAAY,QAAQ;AAC9C,aAAO,OAAO,IAAI;AAClB;AAAA,IACF;AACA,WAAO,OAAO,IAAI,CAAC;AACnB,eAAW,OAAO,MAAM;AACtB,UAAI,MAAM,KAAK,GAAG;AAElB,YAAI,SAAI,QAAJ,mBAAU,QAAO,KAAK;AACxB,cAAM,IAAI;AAAA,MACZ;AACA,aAAO,OAAO,EAAE,IAAI,KAAK,IAAI;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,sBAAsB,YAAiB;AACrD,QAAM,WAAqB,CAAC;AAE5B,aAAW,QAAQ,YAAY;AAC7B,QAAI,SAAS;AAAQ;AACrB,QAAI,SAAS,UAAU;AACrB,YAAM,MAAM,WAAW,IAAI;AAC3B,0BAAoB,GAAG;AACvB,eAAS,KAAK,cAAc,GAAG,CAAC;AAAA,IAClC,OAAO;AACL,iBAAW,SAAS,WAAW,IAAI,GAAG;AACpC,cAAM,OAAO,WAAW,IAAI,EAAE,KAAK;AACnC,YAAI,OAAO,SAAS,UAAU;AAAA,QAE9B,OAAO;AACL,gBAAM,MAAM,WAAW,IAAI,EAAE,KAAK;AAClC,8BAAoB,GAAG;AACvB,mBAAS,KAAK,cAAc,GAAG,CAAC;AAAA,QAClC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const ReactNativeStaticConfigs = /* @__PURE__ */ new WeakMap();
|
|
2
|
-
function getReactNativeConfig(Component) {
|
|
3
|
-
return ReactNativeStaticConfigs.get(Component);
|
|
4
|
-
}
|
|
5
|
-
function setupReactNative(rnExports) {
|
|
6
|
-
for (const key in rnExports) {
|
|
7
|
-
if (key[0].toLowerCase() === key[0])
|
|
8
|
-
continue;
|
|
9
|
-
const val = rnExports[key];
|
|
10
|
-
if (val && typeof val === "object") {
|
|
11
|
-
ReactNativeStaticConfigs.set(val, {
|
|
12
|
-
isReactNative: true,
|
|
13
|
-
isText: key === "Text" || key === "TextInput",
|
|
14
|
-
isInput: key === "TextInput",
|
|
15
|
-
inlineProps: key === "Image" ? /* @__PURE__ */ new Set(["src", "width", "height"]) : void 0
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
ReactNativeStaticConfigs,
|
|
22
|
-
getReactNativeConfig,
|
|
23
|
-
setupReactNative
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=setupReactNative.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/setupReactNative.ts"],
|
|
4
|
-
"sourcesContent": ["import { StaticConfig } from './types'\n\nexport const ReactNativeStaticConfigs = new WeakMap<any, Partial<StaticConfig> | null>()\n\nexport function getReactNativeConfig(Component: any) {\n return ReactNativeStaticConfigs.get(Component)\n}\n\nexport function setupReactNative(rnExports: Record<string, any>) {\n for (const key in rnExports) {\n if (key[0].toLowerCase() === key[0]) continue\n const val = rnExports[key]\n if (val && typeof val === 'object') {\n ReactNativeStaticConfigs.set(val, {\n isReactNative: true,\n isText: key === 'Text' || key === 'TextInput',\n isInput: key === 'TextInput',\n inlineProps: key === 'Image' ? new Set(['src', 'width', 'height']) : undefined,\n })\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAEO,MAAM,2BAA2B,oBAAI,QAA2C;AAEhF,SAAS,qBAAqB,WAAgB;AACnD,SAAO,yBAAyB,IAAI,SAAS;AAC/C;AAEO,SAAS,iBAAiB,WAAgC;AAC/D,aAAW,OAAO,WAAW;AAC3B,QAAI,IAAI,CAAC,EAAE,YAAY,MAAM,IAAI,CAAC;AAAG;AACrC,UAAM,MAAM,UAAU,GAAG;AACzB,QAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,+BAAyB,IAAI,KAAK;AAAA,QAChC,eAAe;AAAA,QACf,QAAQ,QAAQ,UAAU,QAAQ;AAAA,QAClC,SAAS,QAAQ;AAAA,QACjB,aAAa,QAAQ,UAAU,oBAAI,IAAI,CAAC,OAAO,SAAS,QAAQ,CAAC,IAAI;AAAA,MACvE,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/static.js
DELETED
package/dist/esm/static.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/static.ts"],
|
|
4
|
-
"sourcesContent": ["// only stuff that gets extracted or needed by tamagui-static\nexport * from './index'\n\n// for static\nexport * from './helpers/proxyThemeVariables'\n"],
|
|
5
|
-
"mappings": "AACA,cAAc;AAGd,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/styled.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { stylePropsAll } from "@tamagui/helpers";
|
|
2
|
-
import { createComponent } from "./createComponent";
|
|
3
|
-
import { ReactNativeStaticConfigs } from "./setupReactNative";
|
|
4
|
-
function styled(Component, options, staticExtractionOptions) {
|
|
5
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6
|
-
if (!Component) {
|
|
7
|
-
throw new Error(`No component given to styled()`);
|
|
8
|
-
}
|
|
9
|
-
if (options == null ? void 0 : options.variants) {
|
|
10
|
-
for (const key in options.variants) {
|
|
11
|
-
if (key in stylePropsAll) {
|
|
12
|
-
console.error(
|
|
13
|
-
`Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce implementation complexity.`
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const staticConfigProps = (() => {
|
|
20
|
-
const parentStaticConfig = "staticConfig" in Component ? Component.staticConfig : null;
|
|
21
|
-
if (options) {
|
|
22
|
-
const {
|
|
23
|
-
variants,
|
|
24
|
-
name,
|
|
25
|
-
defaultVariants,
|
|
26
|
-
acceptsClassName: acceptsClassNameProp,
|
|
27
|
-
...defaultProps
|
|
28
|
-
} = options;
|
|
29
|
-
if (defaultVariants) {
|
|
30
|
-
Object.assign(defaultProps, defaultVariants);
|
|
31
|
-
}
|
|
32
|
-
const isReactNative = Boolean(
|
|
33
|
-
ReactNativeStaticConfigs.has(Component) || ReactNativeStaticConfigs.has(parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || (parentStaticConfig == null ? void 0 : parentStaticConfig.isReactNative) || (staticExtractionOptions == null ? void 0 : staticExtractionOptions.isReactNative)
|
|
34
|
-
);
|
|
35
|
-
const isTamagui = !isReactNative && !!parentStaticConfig;
|
|
36
|
-
const Comp = isReactNative ? (parentStaticConfig == null ? void 0 : parentStaticConfig.Component) || Component : Component;
|
|
37
|
-
const nativeConf = isReactNative && ReactNativeStaticConfigs.get(Comp) || null;
|
|
38
|
-
const isText = Boolean(
|
|
39
|
-
(staticExtractionOptions == null ? void 0 : staticExtractionOptions.isText) || (parentStaticConfig == null ? void 0 : parentStaticConfig.isText)
|
|
40
|
-
);
|
|
41
|
-
const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative);
|
|
42
|
-
const conf = {
|
|
43
|
-
...staticExtractionOptions,
|
|
44
|
-
...!isTamagui && {
|
|
45
|
-
Component: Comp
|
|
46
|
-
},
|
|
47
|
-
// this type gets messed up by options?: Partial<GetProps<ParentComponent>> above
|
|
48
|
-
// take away the Partial<> and it's fine
|
|
49
|
-
variants,
|
|
50
|
-
defaultProps,
|
|
51
|
-
defaultVariants,
|
|
52
|
-
componentName: name,
|
|
53
|
-
isReactNative,
|
|
54
|
-
isText,
|
|
55
|
-
acceptsClassName,
|
|
56
|
-
...nativeConf
|
|
57
|
-
};
|
|
58
|
-
if (defaultProps.children || !acceptsClassName) {
|
|
59
|
-
conf.neverFlatten = true;
|
|
60
|
-
}
|
|
61
|
-
return conf;
|
|
62
|
-
}
|
|
63
|
-
return {};
|
|
64
|
-
})();
|
|
65
|
-
const component = createComponent(staticConfigProps, Component);
|
|
66
|
-
return component;
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
styled
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=styled.js.map
|
package/dist/esm/styled.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsAll } from '@tamagui/helpers'\n\nimport { 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> =\n GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n }\n\ntype GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer P\n>\n ? P\n : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer V\n>\n ? V\n : {}\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 // validate not using a variant over an existing valid style\n if (process.env.NODE_ENV !== 'production') {\n if (!Component) {\n throw new Error(`No component given to styled()`)\n }\n if (options?.variants) {\n for (const key in options.variants) {\n if (key in stylePropsAll) {\n console.error(\n `Invalid variant key overlaps with style key: ${key}. Tamagui prevents defining variants that use valid style keys to reduce implementation complexity.`\n )\n }\n }\n }\n }\n\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\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\n ? parentStaticConfig?.Component || Component\n : (Component as any)\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(\n staticExtractionOptions?.isText || parentStaticConfig?.isText\n )\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<\n any,\n infer Val\n >\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// sanity check types\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {\n// pointerEvents: 'auto'\n// }\n// }\n// },\n// disabled: {\n// true: {\n// alignContent: 'center',\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,qBAAqB;AAE9B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAuClC,SAAS,OAId,WAEA,SAOA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,QAAI,mCAAS,UAAU;AACrB,iBAAW,OAAO,QAAQ,UAAU;AAClC,YAAI,OAAO,eAAe;AACxB,kBAAQ;AAAA,YACN,gDAAgD;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,gBAAgB;AAAA,QACpB,yBAAyB,IAAI,SAAS,KACpC,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB,mBACpB,mEAAyB;AAAA,MAC7B;AACA,YAAM,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEtC,YAAM,OAAO,iBACT,yDAAoB,cAAa,YAChC;AACL,YAAM,aAAc,iBAAiB,yBAAyB,IAAI,IAAI,KAAM;AAE5E,YAAM,SAAS;AAAA,SACb,mEAAyB,YAAU,yDAAoB;AAAA,MACzD;AACA,YAAM,mBAAmB,yBAAyB,aAAa;AAE/D,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AAqC9D,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/types-rnw.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types-rnw.js.map
|
package/dist/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/dist/esm/types.js.map
DELETED
package/dist/esm/updateTheme.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { addTheme } from "./addTheme";
|
|
2
|
-
import { activeThemeManagers } from "./hooks/useTheme";
|
|
3
|
-
function updateTheme({
|
|
4
|
-
name,
|
|
5
|
-
theme
|
|
6
|
-
}) {
|
|
7
|
-
const next = addTheme({ name, theme, insertCSS: true, update: true });
|
|
8
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
9
|
-
activeThemeManagers.forEach((manager) => {
|
|
10
|
-
if (manager.state.name === name) {
|
|
11
|
-
manager.updateState({
|
|
12
|
-
name,
|
|
13
|
-
forceTheme: next.theme
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return next;
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
updateTheme
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=updateTheme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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({\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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
const FontLanguage = ({ children, ...props }) => {
|
|
3
|
-
return /* @__PURE__ */ jsx(
|
|
4
|
-
"div",
|
|
5
|
-
{
|
|
6
|
-
style: {
|
|
7
|
-
display: "contents"
|
|
8
|
-
},
|
|
9
|
-
className: Object.entries(props).map(([name, language]) => `t_lang-${name}-${language}`).join(" "),
|
|
10
|
-
children
|
|
11
|
-
}
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
FontLanguage
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=FontLanguage.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/views/FontLanguage.tsx"],
|
|
4
|
-
"sourcesContent": ["import { FontLanguageProps } from './FontLanguage.types'\n\nexport const FontLanguage = ({ children, ...props }: FontLanguageProps) => {\n return (\n <div\n style={{\n display: 'contents',\n }}\n className={Object.entries(props)\n .map(([name, language]) => `t_lang-${name}-${language}`)\n .join(' ')}\n >\n {children}\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAII;AAFG,MAAM,eAAe,CAAC,EAAE,UAAU,GAAG,MAAM,MAAyB;AACzE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,MACA,WAAW,OAAO,QAAQ,KAAK,EAC5B,IAAI,CAAC,CAAC,MAAM,QAAQ,MAAM,UAAU,QAAQ,UAAU,EACtD,KAAK,GAAG;AAAA,MAEV;AAAA;AAAA,EACH;AAEJ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { FontLanguageContext } from "../contexts/FontLanguageContext";
|
|
4
|
-
const FontLanguage = ({ children, ...props }) => {
|
|
5
|
-
const value = useMemo(() => props, [JSON.stringify(props)]);
|
|
6
|
-
return /* @__PURE__ */ jsx(FontLanguageContext.Provider, { value, children });
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
FontLanguage
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=FontLanguage.native.js.map
|