@tamagui/core 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ultra.cache.json +1 -0
- package/_/constants/constants.js +14 -0
- package/_/constants/constants.js.map +7 -0
- package/_/constants/platform.js +20 -0
- package/_/constants/platform.js.map +7 -0
- package/_/constants/pseudos.js +18 -0
- package/_/constants/pseudos.js.map +7 -0
- package/_/constants/rnw.js +22 -0
- package/_/constants/rnw.js.map +7 -0
- package/_/createComponent.js +427 -0
- package/_/createComponent.js.map +7 -0
- package/_/createShorthands.js +10 -0
- package/_/createShorthands.js.map +7 -0
- package/_/createTamagui.js +122 -0
- package/_/createTamagui.js.map +7 -0
- package/_/createTheme.js +20 -0
- package/_/createTheme.js.map +7 -0
- package/_/createTokens.js +29 -0
- package/_/createTokens.js.map +7 -0
- package/_/createVariable.js +22 -0
- package/_/createVariable.js.map +7 -0
- package/_/helpers/addStylesUsingClassname.js +32 -0
- package/_/helpers/addStylesUsingClassname.js.map +7 -0
- package/_/helpers/createMediaStyle.js +34 -0
- package/_/helpers/createMediaStyle.js.map +7 -0
- package/_/helpers/createTamaguiProvider.js +42 -0
- package/_/helpers/createTamaguiProvider.js.map +7 -0
- package/_/helpers/extendStaticConfig.js +176 -0
- package/_/helpers/extendStaticConfig.js.map +7 -0
- package/_/helpers/fixNativeShadow.js +8 -0
- package/_/helpers/fixNativeShadow.js.map +7 -0
- package/_/helpers/fixNativeShadow.native.js +30 -0
- package/_/helpers/fixNativeShadow.native.js.map +7 -0
- package/_/helpers/getSplitStyles.js +160 -0
- package/_/helpers/getSplitStyles.js.map +7 -0
- package/_/helpers/getStylesAtomic.js +84 -0
- package/_/helpers/getStylesAtomic.js.map +7 -0
- package/_/helpers/getStylesAtomic.native.js +10 -0
- package/_/helpers/getStylesAtomic.native.js.map +7 -0
- package/_/helpers/insertStyleRule.js +24 -0
- package/_/helpers/insertStyleRule.js.map +7 -0
- package/_/helpers/matchMedia.js +15 -0
- package/_/helpers/matchMedia.js.map +7 -0
- package/_/helpers/matchMedia.native.js +8 -0
- package/_/helpers/matchMedia.native.js.map +7 -0
- package/_/helpers/themeable.js +26 -0
- package/_/helpers/themeable.js.map +7 -0
- package/_/hooks/useConstant.js +15 -0
- package/_/hooks/useConstant.js.map +7 -0
- package/_/hooks/useFeatures.js +75 -0
- package/_/hooks/useFeatures.js.map +7 -0
- package/_/hooks/useForceUpdate.js +28 -0
- package/_/hooks/useForceUpdate.js.map +7 -0
- package/_/hooks/useMedia.js +173 -0
- package/_/hooks/useMedia.js.map +7 -0
- package/_/hooks/usePressable.js +14 -0
- package/_/hooks/usePressable.js.map +7 -0
- package/_/hooks/useTheme.js +94 -0
- package/_/hooks/useTheme.js.map +7 -0
- package/_/index.js +30 -0
- package/_/index.js.map +7 -0
- package/_/static/postProcessStyles.js +18 -0
- package/_/static/postProcessStyles.js.map +7 -0
- package/_/static.js +12 -0
- package/_/static.js.map +7 -0
- package/_/styled.js +21 -0
- package/_/styled.js.map +7 -0
- package/_/types.js +1 -0
- package/_/types.js.map +7 -0
- package/_/views/Animated.js +79 -0
- package/_/views/Animated.js.map +7 -0
- package/_/views/Stack.js +12 -0
- package/_/views/Stack.js.map +7 -0
- package/_/views/Text.js +60 -0
- package/_/views/Text.js.map +7 -0
- package/_/views/TextAncestorContext.js +19 -0
- package/_/views/TextAncestorContext.js.map +7 -0
- package/_/views/Theme.js +57 -0
- package/_/views/Theme.js.map +7 -0
- package/_/views/ThemeContext.js +6 -0
- package/_/views/ThemeContext.js.map +7 -0
- package/_/views/ThemeInverse.js +27 -0
- package/_/views/ThemeInverse.js.map +7 -0
- package/_/views/ThemeManagerContext.js +56 -0
- package/_/views/ThemeManagerContext.js.map +7 -0
- package/_/views/ThemeProvider.js +45 -0
- package/_/views/ThemeProvider.js.map +7 -0
- package/dist/constants/constants.js +14 -0
- package/dist/constants/constants.js.map +7 -0
- package/dist/constants/platform.js +19 -0
- package/dist/constants/platform.js.map +7 -0
- package/dist/constants/pseudos.js +18 -0
- package/dist/constants/pseudos.js.map +7 -0
- package/dist/constants/rnw.js +22 -0
- package/dist/constants/rnw.js.map +7 -0
- package/dist/constants/styleConstants.js +46 -0
- package/dist/constants/styleConstants.js.map +7 -0
- package/dist/createComponent.js +445 -0
- package/dist/createComponent.js.map +7 -0
- package/dist/createFont.js +24 -0
- package/dist/createFont.js.map +7 -0
- package/dist/createShorthands.js +10 -0
- package/dist/createShorthands.js.map +7 -0
- package/dist/createTamagui.js +159 -0
- package/dist/createTamagui.js.map +7 -0
- package/dist/createTheme.js +20 -0
- package/dist/createTheme.js.map +7 -0
- package/dist/createTokens.js +29 -0
- package/dist/createTokens.js.map +7 -0
- package/dist/createVariable.js +22 -0
- package/dist/createVariable.js.map +7 -0
- package/dist/helpers/addStylesUsingClassname.js +57 -0
- package/dist/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/helpers/createMediaStyle.js +34 -0
- package/dist/helpers/createMediaStyle.js.map +7 -0
- package/dist/helpers/createPropMapper.js +153 -0
- package/dist/helpers/createPropMapper.js.map +7 -0
- package/dist/helpers/createTamaguiProvider.js +25 -0
- package/dist/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/helpers/extendStaticConfig.js +59 -0
- package/dist/helpers/extendStaticConfig.js.map +7 -0
- package/dist/helpers/fixNativeShadow.js +8 -0
- package/dist/helpers/fixNativeShadow.js.map +7 -0
- package/dist/helpers/fixNativeShadow.native.js +30 -0
- package/dist/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/helpers/getSplitStyles.js +160 -0
- package/dist/helpers/getSplitStyles.js.map +7 -0
- package/dist/helpers/getStylesAtomic.js +83 -0
- package/dist/helpers/getStylesAtomic.js.map +7 -0
- package/dist/helpers/getStylesAtomic.native.js +10 -0
- package/dist/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/helpers/insertStyleRule.js +24 -0
- package/dist/helpers/insertStyleRule.js.map +7 -0
- package/dist/helpers/isObj.js +7 -0
- package/dist/helpers/isObj.js.map +7 -0
- package/dist/helpers/matchMedia.js +15 -0
- package/dist/helpers/matchMedia.js.map +7 -0
- package/dist/helpers/matchMedia.native.js +8 -0
- package/dist/helpers/matchMedia.native.js.map +7 -0
- package/dist/helpers/pseudos.js +1 -0
- package/dist/helpers/pseudos.js.map +7 -0
- package/dist/helpers/themeable.js +26 -0
- package/dist/helpers/themeable.js.map +7 -0
- package/dist/hooks/useConstant.js +15 -0
- package/dist/hooks/useConstant.js.map +7 -0
- package/dist/hooks/useFeatures.js +75 -0
- package/dist/hooks/useFeatures.js.map +7 -0
- package/dist/hooks/useForceUpdate.js +28 -0
- package/dist/hooks/useForceUpdate.js.map +7 -0
- package/dist/hooks/useMedia.js +171 -0
- package/dist/hooks/useMedia.js.map +7 -0
- package/dist/hooks/usePressable.js +13 -0
- package/dist/hooks/usePressable.js.map +7 -0
- package/dist/hooks/useTheme.js +93 -0
- package/dist/hooks/useTheme.js.map +7 -0
- package/dist/index.cjs +2125 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +7 -0
- package/dist/packages/core/src/constants/constants.d.ts +8 -0
- package/dist/packages/core/src/constants/constants.d.ts.map +1 -0
- package/dist/packages/core/src/constants/platform.d.ts +9 -0
- package/dist/packages/core/src/constants/platform.d.ts.map +1 -0
- package/dist/packages/core/src/constants/pseudos.d.ts +15 -0
- package/dist/packages/core/src/constants/pseudos.d.ts.map +1 -0
- package/dist/packages/core/src/constants/rnw.d.ts +2 -0
- package/dist/packages/core/src/constants/rnw.d.ts.map +1 -0
- package/dist/packages/core/src/createComponent.d.ts +16 -0
- package/dist/packages/core/src/createComponent.d.ts.map +1 -0
- package/dist/packages/core/src/createShorthands.d.ts +2 -0
- package/dist/packages/core/src/createShorthands.d.ts.map +1 -0
- package/dist/packages/core/src/createTamagui.d.ts +37 -0
- package/dist/packages/core/src/createTamagui.d.ts.map +1 -0
- package/dist/packages/core/src/createTheme.d.ts +5 -0
- package/dist/packages/core/src/createTheme.d.ts.map +1 -0
- package/dist/packages/core/src/createTokens.d.ts +45 -0
- package/dist/packages/core/src/createTokens.d.ts.map +1 -0
- package/dist/packages/core/src/createVariable.d.ts +14 -0
- package/dist/packages/core/src/createVariable.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts +2 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts +8 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts +5 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts +5 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts +15 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts +3 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts +2 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts +2 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts +3 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/themeable.d.ts +10 -0
- package/dist/packages/core/src/helpers/themeable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts +2 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts +5 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts +2 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts +16 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts +3 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts +18 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts.map +1 -0
- package/dist/packages/core/src/index.d.ts +27 -0
- package/dist/packages/core/src/index.d.ts.map +1 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts +7 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts.map +1 -0
- package/dist/packages/core/src/static.d.ts +12 -0
- package/dist/packages/core/src/static.d.ts.map +1 -0
- package/dist/packages/core/src/styled.d.ts +16 -0
- package/dist/packages/core/src/styled.d.ts.map +1 -0
- package/dist/packages/core/src/types.d.ts +305 -0
- package/dist/packages/core/src/types.d.ts.map +1 -0
- package/dist/packages/core/src/views/Animated.d.ts +15 -0
- package/dist/packages/core/src/views/Animated.d.ts.map +1 -0
- package/dist/packages/core/src/views/Stack.d.ts +3 -0
- package/dist/packages/core/src/views/Stack.d.ts.map +1 -0
- package/dist/packages/core/src/views/Text.d.ts +3 -0
- package/dist/packages/core/src/views/Text.d.ts.map +1 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts +3 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/Theme.d.ts +8 -0
- package/dist/packages/core/src/views/Theme.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts +18 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts +15 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts.map +1 -0
- package/dist/packages/helpers/src/AllRules.d.ts +3 -0
- package/dist/packages/helpers/src/AllRules.d.ts.map +1 -0
- package/dist/packages/helpers/src/concatClassName.d.ts +2 -0
- package/dist/packages/helpers/src/concatClassName.d.ts.map +1 -0
- package/dist/packages/helpers/src/index.d.ts +5 -0
- package/dist/packages/helpers/src/index.d.ts.map +1 -0
- package/dist/packages/helpers/src/types.d.ts +8 -0
- package/dist/packages/helpers/src/types.d.ts.map +1 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts +475 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts.map +1 -0
- package/dist/static/postProcessStyles.js +18 -0
- package/dist/static/postProcessStyles.js.map +7 -0
- package/dist/static.js +15 -0
- package/dist/static.js.map +7 -0
- package/dist/styled.js +21 -0
- package/dist/styled.js.map +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/dist/views/Animated.js +79 -0
- package/dist/views/Animated.js.map +7 -0
- package/dist/views/SafeAreaProvider.js +30 -0
- package/dist/views/SafeAreaProvider.js.map +7 -0
- package/dist/views/Stack.js +12 -0
- package/dist/views/Stack.js.map +7 -0
- package/dist/views/Text.js +60 -0
- package/dist/views/Text.js.map +7 -0
- package/dist/views/TextAncestorContext.js +18 -0
- package/dist/views/TextAncestorContext.js.map +7 -0
- package/dist/views/Theme.js +56 -0
- package/dist/views/Theme.js.map +7 -0
- package/dist/views/ThemeContext.js +6 -0
- package/dist/views/ThemeContext.js.map +7 -0
- package/dist/views/ThemeInverse.js +27 -0
- package/dist/views/ThemeInverse.js.map +7 -0
- package/dist/views/ThemeManagerContext.js +55 -0
- package/dist/views/ThemeManagerContext.js.map +7 -0
- package/dist/views/ThemeProvider.js +45 -0
- package/dist/views/ThemeProvider.js.map +7 -0
- package/package.json +33 -0
- package/src/constants/constants.ts +12 -0
- package/src/constants/platform.ts +15 -0
- package/src/constants/pseudos.ts +14 -0
- package/src/constants/rnw.tsx +20 -0
- package/src/createComponent.tsx +596 -0
- package/src/createFont.ts +26 -0
- package/src/createShorthands.ts +5 -0
- package/src/createTamagui.ts +207 -0
- package/src/createTheme.ts +19 -0
- package/src/createTokens.ts +83 -0
- package/src/createVariable.ts +22 -0
- package/src/helpers/addStylesUsingClassname.tsx +60 -0
- package/src/helpers/createMediaStyle.ts +46 -0
- package/src/helpers/createPropMapper.ts +184 -0
- package/src/helpers/createTamaguiProvider.tsx +22 -0
- package/src/helpers/extendStaticConfig.ts +68 -0
- package/src/helpers/fixNativeShadow.native.tsx +27 -0
- package/src/helpers/fixNativeShadow.tsx +2 -0
- package/src/helpers/getSplitStyles.tsx +210 -0
- package/src/helpers/getStylesAtomic.native.ts +3 -0
- package/src/helpers/getStylesAtomic.ts +103 -0
- package/src/helpers/insertStyleRule.tsx +18 -0
- package/src/helpers/isObj.ts +1 -0
- package/src/helpers/matchMedia.native.ts +3 -0
- package/src/helpers/matchMedia.ts +9 -0
- package/src/helpers/themeable.tsx +42 -0
- package/src/hooks/useConstant.tsx +10 -0
- package/src/hooks/useFeatures.tsx +78 -0
- package/src/hooks/useForceUpdate.tsx +26 -0
- package/src/hooks/useMedia.tsx +194 -0
- package/src/hooks/usePressable.tsx +9 -0
- package/src/hooks/useTheme.tsx +107 -0
- package/src/index.ts +33 -0
- package/src/static/postProcessStyles.tsx +20 -0
- package/src/static.ts +22 -0
- package/src/styled.ts +82 -0
- package/src/types.tsx +561 -0
- package/src/views/Animated.tsx +121 -0
- package/src/views/SafeAreaProvider.tsx +33 -0
- package/src/views/Stack.tsx +21 -0
- package/src/views/Text.tsx +66 -0
- package/src/views/TextAncestorContext.tsx +12 -0
- package/src/views/Theme.tsx +73 -0
- package/src/views/ThemeContext.tsx +5 -0
- package/src/views/ThemeInverse.tsx +23 -0
- package/src/views/ThemeManagerContext.tsx +50 -0
- package/src/views/ThemeProvider.tsx +52 -0
- package/tsconfig.json +8 -0
- package/types.d.ts +558 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const interopRequire = (src: any) => ('default' in src ? src.default : src)
|
|
2
|
+
|
|
3
|
+
export const rnw: Record<string, any> = {}
|
|
4
|
+
|
|
5
|
+
// in static mode, require them directly since we can't import react-native-web at all (it has flow stuff in it)
|
|
6
|
+
if (process.env.IS_STATIC === 'is_static') {
|
|
7
|
+
const createCompileableStyle = require('react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle')
|
|
8
|
+
const createReactDOMStyle = require('react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle')
|
|
9
|
+
const i18Style = require('react-native-web/dist/cjs/exports/StyleSheet/i18nStyle')
|
|
10
|
+
const atomic = require('react-native-web/dist/cjs/exports/StyleSheet/compile').atomic
|
|
11
|
+
Object.assign(rnw, {
|
|
12
|
+
createCompileableStyle,
|
|
13
|
+
createReactDOMStyle,
|
|
14
|
+
i18Style,
|
|
15
|
+
atomic,
|
|
16
|
+
})
|
|
17
|
+
} else if (process.env.TAMAGUI_TARGET === 'web') {
|
|
18
|
+
// when targeting web (client) import it like so
|
|
19
|
+
Object.assign(rnw, interopRequire(require('react-native-web').TamaguiExports))
|
|
20
|
+
}
|
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import { concatClassName, stylePropsView } from '@tamagui/helpers'
|
|
2
|
+
import React, {
|
|
3
|
+
Children,
|
|
4
|
+
Fragment,
|
|
5
|
+
createElement,
|
|
6
|
+
forwardRef,
|
|
7
|
+
useCallback,
|
|
8
|
+
useContext,
|
|
9
|
+
useEffect,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from 'react'
|
|
13
|
+
import { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
14
|
+
|
|
15
|
+
import { stackDefaultStyles } from './constants/constants'
|
|
16
|
+
import { isTouchDevice, isWeb } from './constants/platform'
|
|
17
|
+
import { rnw } from './constants/rnw'
|
|
18
|
+
import { onConfiguredOnce } from './createTamagui'
|
|
19
|
+
import { addStylesUsingClassname, useStylesAsClassname } from './helpers/addStylesUsingClassname'
|
|
20
|
+
import { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'
|
|
21
|
+
import { getSplitStyles } from './helpers/getSplitStyles'
|
|
22
|
+
import { useFeatures } from './hooks/useFeatures'
|
|
23
|
+
import { useForceUpdate } from './hooks/useForceUpdate'
|
|
24
|
+
import { usePressable } from './hooks/usePressable'
|
|
25
|
+
import {
|
|
26
|
+
SpaceTokens,
|
|
27
|
+
StaticComponent,
|
|
28
|
+
StaticConfig,
|
|
29
|
+
StaticConfigParsed,
|
|
30
|
+
TamaguiInternalConfig,
|
|
31
|
+
} from './types'
|
|
32
|
+
import { TextAncestorContext } from './views/TextAncestorContext'
|
|
33
|
+
import { ThemeManagerContext } from './views/ThemeManagerContext'
|
|
34
|
+
|
|
35
|
+
export const mouseUps = new Set<Function>()
|
|
36
|
+
|
|
37
|
+
if (typeof document !== 'undefined') {
|
|
38
|
+
document.addEventListener('mouseup', () => {
|
|
39
|
+
mouseUps.forEach((x) => x())
|
|
40
|
+
mouseUps.clear()
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type DefaultProps = {}
|
|
45
|
+
|
|
46
|
+
export function createComponent<A extends Object = DefaultProps>(
|
|
47
|
+
configIn: Partial<StaticConfig> | StaticConfigParsed
|
|
48
|
+
) {
|
|
49
|
+
let staticConfig: StaticConfigParsed
|
|
50
|
+
if ('parsed' in configIn) {
|
|
51
|
+
staticConfig = configIn
|
|
52
|
+
} else {
|
|
53
|
+
staticConfig = parseStaticConfig(configIn)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { Component, validStyles, isText, isZStack } = staticConfig
|
|
57
|
+
const validStyleProps = validStyles ?? stylePropsView
|
|
58
|
+
|
|
59
|
+
// split out default styles vs props so we can assign it to component.defaultProps
|
|
60
|
+
let defaultProps = null as any
|
|
61
|
+
let tamaguiConfig: TamaguiInternalConfig
|
|
62
|
+
|
|
63
|
+
// web uses className, native uses style
|
|
64
|
+
let defaultsStyle: any
|
|
65
|
+
let defaultsClassName = ''
|
|
66
|
+
let initialTheme: any
|
|
67
|
+
|
|
68
|
+
// see onConfiguredOnce below which attaches a name then to this component
|
|
69
|
+
|
|
70
|
+
const component = forwardRef<View, A>((props: any, forwardedRef) => {
|
|
71
|
+
const {
|
|
72
|
+
tag,
|
|
73
|
+
hitSlop,
|
|
74
|
+
children,
|
|
75
|
+
pointerEvents,
|
|
76
|
+
onPress,
|
|
77
|
+
onPressIn,
|
|
78
|
+
onPressOut,
|
|
79
|
+
onHoverIn,
|
|
80
|
+
onHoverOut,
|
|
81
|
+
space,
|
|
82
|
+
disabled,
|
|
83
|
+
onMouseEnter,
|
|
84
|
+
onMouseLeave,
|
|
85
|
+
hrefAttrs,
|
|
86
|
+
onMoveShouldSetResponder,
|
|
87
|
+
onMoveShouldSetResponderCapture,
|
|
88
|
+
onResponderEnd,
|
|
89
|
+
onResponderGrant,
|
|
90
|
+
onResponderMove,
|
|
91
|
+
onResponderReject,
|
|
92
|
+
onResponderRelease,
|
|
93
|
+
onResponderStart,
|
|
94
|
+
onResponderTerminate,
|
|
95
|
+
onResponderTerminationRequest,
|
|
96
|
+
onScrollShouldSetResponder,
|
|
97
|
+
onScrollShouldSetResponderCapture,
|
|
98
|
+
onSelectionChangeShouldSetResponder,
|
|
99
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
100
|
+
onStartShouldSetResponder,
|
|
101
|
+
onStartShouldSetResponderCapture,
|
|
102
|
+
onMouseDown,
|
|
103
|
+
onClick,
|
|
104
|
+
// TODO feature load layou hook
|
|
105
|
+
onLayout,
|
|
106
|
+
} = props
|
|
107
|
+
|
|
108
|
+
const forceUpdate = useForceUpdate()
|
|
109
|
+
const features = useFeatures(props, { forceUpdate })
|
|
110
|
+
const manager = useContext(ThemeManagerContext)
|
|
111
|
+
const [state, set_] = useState(() => ({
|
|
112
|
+
hover: false,
|
|
113
|
+
press: false,
|
|
114
|
+
pressIn: false,
|
|
115
|
+
theme: manager.name,
|
|
116
|
+
}))
|
|
117
|
+
const set = (next: Partial<typeof state>) =>
|
|
118
|
+
set_((prev) => {
|
|
119
|
+
for (const key in next) {
|
|
120
|
+
if (prev[key] !== next[key]) {
|
|
121
|
+
return { ...prev, ...next }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return prev
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
// from react-native-web
|
|
128
|
+
if (process.env.NODE_ENV === 'development' && !isText && isWeb) {
|
|
129
|
+
Children.toArray(props.children).forEach((item) => {
|
|
130
|
+
if (typeof item === 'string') {
|
|
131
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false
|
|
137
|
+
const hostRef = useRef(null)
|
|
138
|
+
|
|
139
|
+
if (isWeb) {
|
|
140
|
+
// from react-native-web
|
|
141
|
+
rnw.useResponderEvents(hostRef, {
|
|
142
|
+
onMoveShouldSetResponder,
|
|
143
|
+
onMoveShouldSetResponderCapture,
|
|
144
|
+
onResponderEnd,
|
|
145
|
+
onResponderGrant,
|
|
146
|
+
onResponderMove,
|
|
147
|
+
onResponderReject,
|
|
148
|
+
onResponderRelease,
|
|
149
|
+
onResponderStart,
|
|
150
|
+
onResponderTerminate,
|
|
151
|
+
onResponderTerminationRequest,
|
|
152
|
+
onScrollShouldSetResponder,
|
|
153
|
+
onScrollShouldSetResponderCapture,
|
|
154
|
+
onSelectionChangeShouldSetResponder,
|
|
155
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
156
|
+
onStartShouldSetResponder,
|
|
157
|
+
onStartShouldSetResponderCapture,
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const isTracking = useRef(false)
|
|
162
|
+
|
|
163
|
+
const { viewProps, pseudos, style, classNames } = getSplitStyles(
|
|
164
|
+
props,
|
|
165
|
+
staticConfig,
|
|
166
|
+
(manager.theme as any) || initialTheme
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
// hasEverHadEvents prevents repareting if you remove onPress or similar...
|
|
170
|
+
const internal = useRef<{ isMounted: boolean; hasEverHadEvents?: boolean }>()
|
|
171
|
+
if (!internal.current) {
|
|
172
|
+
internal.current = {
|
|
173
|
+
isMounted: true,
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
internal.current!.isMounted = true
|
|
179
|
+
const dispose = manager?.onChangeTheme((name) => {
|
|
180
|
+
if (isTracking.current) {
|
|
181
|
+
set({ theme: name })
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
return () => {
|
|
185
|
+
dispose()
|
|
186
|
+
mouseUps.delete(unPress)
|
|
187
|
+
isTracking.current = false
|
|
188
|
+
internal.current!.isMounted = false
|
|
189
|
+
}
|
|
190
|
+
}, [manager])
|
|
191
|
+
|
|
192
|
+
// element
|
|
193
|
+
const element = isWeb
|
|
194
|
+
? !Component || typeof Component === 'string'
|
|
195
|
+
? // default to tag, fallback to component (when both strings)
|
|
196
|
+
tag || Component
|
|
197
|
+
: Component
|
|
198
|
+
: Component
|
|
199
|
+
const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')
|
|
200
|
+
const ReactText = !isWeb ? Text : element || 'span'
|
|
201
|
+
const ViewComponent = isText ? ReactText : ReactView
|
|
202
|
+
|
|
203
|
+
// styles
|
|
204
|
+
const isHovering = !isTouchDevice && !disabled && pseudos && state.hover
|
|
205
|
+
const isPressing = !disabled && pseudos && state.press
|
|
206
|
+
|
|
207
|
+
const styles = [
|
|
208
|
+
// parity w react-native-web, only for text in text
|
|
209
|
+
// TODO this should be able to be done w css to replicate after extraction:
|
|
210
|
+
// (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)
|
|
211
|
+
// isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,
|
|
212
|
+
style,
|
|
213
|
+
isHovering ? pseudos.hoverStyle || null : null,
|
|
214
|
+
isPressing ? pseudos.pressStyle || null : null,
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
if (isWeb) {
|
|
218
|
+
const stylesClassNames = useStylesAsClassname(styles)
|
|
219
|
+
const classList = isText
|
|
220
|
+
? [
|
|
221
|
+
defaultsClassName,
|
|
222
|
+
// hasTextAncestor === true && cssText.textHasAncestor,
|
|
223
|
+
// TODO MOVE TO VARIANTS [number] [any]
|
|
224
|
+
// numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,
|
|
225
|
+
classNames,
|
|
226
|
+
stylesClassNames,
|
|
227
|
+
props.className,
|
|
228
|
+
]
|
|
229
|
+
: [defaultsClassName, props.className, classNames, stylesClassNames]
|
|
230
|
+
|
|
231
|
+
const className = concatClassName(...classList)
|
|
232
|
+
if (process.env.NODE_ENV === 'development') {
|
|
233
|
+
if (props['debug']) {
|
|
234
|
+
// prettier-ignore
|
|
235
|
+
console.log('🥚 className', { style, styles, classList, stylesClassNames, className })
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
viewProps.className = className
|
|
239
|
+
} else {
|
|
240
|
+
viewProps.style = styles
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (pointerEvents) {
|
|
244
|
+
viewProps.pointerEvents = pointerEvents
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (isWeb) {
|
|
248
|
+
// from react-native-web
|
|
249
|
+
const platformMethodsRef = rnw.usePlatformMethods(viewProps)
|
|
250
|
+
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef)
|
|
251
|
+
viewProps.ref = setRef
|
|
252
|
+
if (props.href != null && hrefAttrs != null) {
|
|
253
|
+
const { download, rel, target } = hrefAttrs
|
|
254
|
+
if (download != null) {
|
|
255
|
+
viewProps.download = download
|
|
256
|
+
}
|
|
257
|
+
if (rel != null) {
|
|
258
|
+
viewProps.rel = rel
|
|
259
|
+
}
|
|
260
|
+
if (typeof target === 'string') {
|
|
261
|
+
viewProps.target = target.charAt(0) !== '_' ? '_' + target : target
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
if (forwardedRef) {
|
|
266
|
+
viewProps.ref = forwardedRef
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const attachPress = !!(
|
|
271
|
+
(pseudos && pseudos.pressStyle) ||
|
|
272
|
+
onPress ||
|
|
273
|
+
onPressOut ||
|
|
274
|
+
onPressIn ||
|
|
275
|
+
onClick
|
|
276
|
+
)
|
|
277
|
+
const attachHover =
|
|
278
|
+
isWeb &&
|
|
279
|
+
!isTouchDevice &&
|
|
280
|
+
!!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)
|
|
281
|
+
|
|
282
|
+
// check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage
|
|
283
|
+
// while avoiding reparenting...
|
|
284
|
+
// once proper reparenting is supported, we can remove this and use that...
|
|
285
|
+
const shouldAttach =
|
|
286
|
+
internal.current.hasEverHadEvents ||
|
|
287
|
+
attachPress ||
|
|
288
|
+
attachHover ||
|
|
289
|
+
'pressStyle' in props ||
|
|
290
|
+
'onPress' in props ||
|
|
291
|
+
'onPressIn' in props ||
|
|
292
|
+
'onPressOut' in props ||
|
|
293
|
+
(isWeb &&
|
|
294
|
+
('hoverStyle' in props ||
|
|
295
|
+
'onClick' in props ||
|
|
296
|
+
'onHoverIn' in props ||
|
|
297
|
+
'onHoverOut' in props ||
|
|
298
|
+
'onMouseEnter' in props ||
|
|
299
|
+
'onMouseLeave' in props))
|
|
300
|
+
|
|
301
|
+
// never remove events as we wrap in a div (for now, may be able to remove..)
|
|
302
|
+
if (shouldAttach) {
|
|
303
|
+
internal.current.hasEverHadEvents = true
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const unPress = useCallback(() => {
|
|
307
|
+
if (!internal.current!.isMounted) return
|
|
308
|
+
set({
|
|
309
|
+
press: false,
|
|
310
|
+
pressIn: false,
|
|
311
|
+
})
|
|
312
|
+
}, [])
|
|
313
|
+
|
|
314
|
+
const events = shouldAttach
|
|
315
|
+
? {
|
|
316
|
+
...(!isWeb && {
|
|
317
|
+
// non web
|
|
318
|
+
onPressOut: (e) => {
|
|
319
|
+
unPress()
|
|
320
|
+
onPressOut?.(e)
|
|
321
|
+
},
|
|
322
|
+
}),
|
|
323
|
+
...(isWeb &&
|
|
324
|
+
!isTouchDevice && {
|
|
325
|
+
onMouseEnter:
|
|
326
|
+
attachHover || attachPress
|
|
327
|
+
? (e) => {
|
|
328
|
+
let next: Partial<typeof state> = {}
|
|
329
|
+
if (attachHover) {
|
|
330
|
+
next.hover = true
|
|
331
|
+
}
|
|
332
|
+
if (state.pressIn) {
|
|
333
|
+
next.press = true
|
|
334
|
+
}
|
|
335
|
+
if (Object.keys(next).length) {
|
|
336
|
+
set(next)
|
|
337
|
+
}
|
|
338
|
+
onHoverIn?.(e)
|
|
339
|
+
onMouseEnter?.(e)
|
|
340
|
+
}
|
|
341
|
+
: undefined,
|
|
342
|
+
onMouseLeave:
|
|
343
|
+
attachHover || attachPress
|
|
344
|
+
? (e) => {
|
|
345
|
+
let next: Partial<typeof state> = {}
|
|
346
|
+
mouseUps.add(unPress)
|
|
347
|
+
if (attachHover) {
|
|
348
|
+
next.hover = false
|
|
349
|
+
}
|
|
350
|
+
if (state.pressIn) {
|
|
351
|
+
next.press = false
|
|
352
|
+
next.pressIn = false
|
|
353
|
+
}
|
|
354
|
+
if (Object.keys(next).length) {
|
|
355
|
+
set(next)
|
|
356
|
+
}
|
|
357
|
+
onHoverOut?.(e)
|
|
358
|
+
onMouseLeave?.(e)
|
|
359
|
+
}
|
|
360
|
+
: undefined,
|
|
361
|
+
}),
|
|
362
|
+
onMouseDown: attachPress
|
|
363
|
+
? (e) => {
|
|
364
|
+
set({
|
|
365
|
+
press: true,
|
|
366
|
+
pressIn: true,
|
|
367
|
+
})
|
|
368
|
+
onPressIn?.(e)
|
|
369
|
+
onMouseDown?.(e)
|
|
370
|
+
}
|
|
371
|
+
: (onPressIn as any),
|
|
372
|
+
onClick: attachPress
|
|
373
|
+
? (e) => {
|
|
374
|
+
// this caused issue with next.js passing href
|
|
375
|
+
// e.preventDefault()
|
|
376
|
+
onPress?.(e)
|
|
377
|
+
onClick?.(e)
|
|
378
|
+
unPress()
|
|
379
|
+
onPressOut?.(e)
|
|
380
|
+
}
|
|
381
|
+
: (onPressOut as any),
|
|
382
|
+
}
|
|
383
|
+
: null
|
|
384
|
+
|
|
385
|
+
if (events) {
|
|
386
|
+
if (typeof ViewComponent !== 'string') {
|
|
387
|
+
// TODO once we do the above we can then rely entirely on pressStyle returned here isntead of above pressStyle logic
|
|
388
|
+
const [pressProps] = usePressable({
|
|
389
|
+
disabled,
|
|
390
|
+
hitSlop,
|
|
391
|
+
onPressIn: events.onMouseDown,
|
|
392
|
+
onPressOut: events.onPressOut,
|
|
393
|
+
onPress: events.onClick,
|
|
394
|
+
})
|
|
395
|
+
Object.assign(viewProps, pressProps)
|
|
396
|
+
} else {
|
|
397
|
+
Object.assign(viewProps, events)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const childEls = spacedChildren({
|
|
402
|
+
children,
|
|
403
|
+
space,
|
|
404
|
+
flexDirection: props.flexDirection || defaultProps?.flexDirection,
|
|
405
|
+
isZStack: isZStack,
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
let content: any
|
|
409
|
+
|
|
410
|
+
// replicate react-native-web's `createElement`
|
|
411
|
+
if (isWeb && rnw) {
|
|
412
|
+
const domProps = rnw.createDOMProps(viewProps)
|
|
413
|
+
const className =
|
|
414
|
+
domProps.className && domProps.className !== viewProps.className
|
|
415
|
+
? `${domProps.className} ${viewProps.className}`
|
|
416
|
+
: viewProps.className
|
|
417
|
+
Object.assign(viewProps, domProps)
|
|
418
|
+
viewProps.className = className
|
|
419
|
+
content = createElement(ViewComponent, viewProps, childEls)
|
|
420
|
+
} else {
|
|
421
|
+
content = createElement(ViewComponent, viewProps, childEls)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor
|
|
425
|
+
if (shouldWrapTextAncestor) {
|
|
426
|
+
// from react-native-web
|
|
427
|
+
// @ts-ignore
|
|
428
|
+
content = createElement(TextAncestorContext.Provider, { value: true }, content)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (process.env.NODE_ENV === 'development') {
|
|
432
|
+
if (props['debug']) {
|
|
433
|
+
viewProps['debug'] = true
|
|
434
|
+
console.log('🥚 props in:', props)
|
|
435
|
+
console.log('🥚 props out:', viewProps)
|
|
436
|
+
console.log(props.onClick?.toString())
|
|
437
|
+
// prettier-ignore
|
|
438
|
+
console.log('🥚 etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls })
|
|
439
|
+
// only on browser because node expands it huge
|
|
440
|
+
if (isWeb) {
|
|
441
|
+
console.log('🥚 component info', { staticConfig, tamaguiConfig })
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return (
|
|
447
|
+
<>
|
|
448
|
+
{features}
|
|
449
|
+
{content}
|
|
450
|
+
</>
|
|
451
|
+
)
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
// Once configuration is run and all components are registered
|
|
455
|
+
// get default props + className and analyze styles
|
|
456
|
+
onConfiguredOnce((conf) => {
|
|
457
|
+
tamaguiConfig = conf
|
|
458
|
+
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]
|
|
459
|
+
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)
|
|
460
|
+
if (isWeb) {
|
|
461
|
+
if (next.classNames) {
|
|
462
|
+
defaultsClassName += next.classNames + ' '
|
|
463
|
+
}
|
|
464
|
+
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])
|
|
465
|
+
} else {
|
|
466
|
+
if (!hasWarnedOnce) {
|
|
467
|
+
hasWarnedOnce = true
|
|
468
|
+
console.log('⚠️ we need to account for default styles for media queries')
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// @ts-ignore
|
|
472
|
+
component.defaultProps = {
|
|
473
|
+
...next.viewProps,
|
|
474
|
+
...component.defaultProps,
|
|
475
|
+
}
|
|
476
|
+
if (process.env.NODE_ENV === 'development') {
|
|
477
|
+
if (staticConfig.defaultProps?.debug) {
|
|
478
|
+
console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
component['staticConfig'] = {
|
|
484
|
+
validStyles: validStyleProps,
|
|
485
|
+
...staticConfig,
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const res = component as any as StaticComponent<A, void>
|
|
489
|
+
|
|
490
|
+
// add extractable HoC
|
|
491
|
+
res['extractable'] = (Component: any) => {
|
|
492
|
+
Component['staticConfig'] = extendStaticConfig(res, {
|
|
493
|
+
neverFlatten: true,
|
|
494
|
+
defaultProps: Component.defaultProps,
|
|
495
|
+
})
|
|
496
|
+
return Component
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return res
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
let hasWarnedOnce = false
|
|
503
|
+
|
|
504
|
+
// dont used styled() here to avoid circular deps
|
|
505
|
+
// keep inline to avoid circular deps
|
|
506
|
+
|
|
507
|
+
export const Spacer = createComponent<{ size?: number | SpaceTokens; flex?: boolean | number }>({
|
|
508
|
+
defaultProps: {
|
|
509
|
+
...stackDefaultStyles,
|
|
510
|
+
size: true,
|
|
511
|
+
},
|
|
512
|
+
variants: {
|
|
513
|
+
size: {
|
|
514
|
+
'...size': (size, { tokens }) => {
|
|
515
|
+
size = size == true ? '$true' : size
|
|
516
|
+
return {
|
|
517
|
+
width: tokens.size[size] ?? size,
|
|
518
|
+
height: tokens.size[size] ?? size,
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
|
|
523
|
+
direction: {
|
|
524
|
+
horizontal: {
|
|
525
|
+
height: 0,
|
|
526
|
+
},
|
|
527
|
+
vertical: {
|
|
528
|
+
width: 0,
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
})
|
|
533
|
+
|
|
534
|
+
export function spacedChildren({
|
|
535
|
+
isZStack,
|
|
536
|
+
children,
|
|
537
|
+
space,
|
|
538
|
+
flexDirection,
|
|
539
|
+
}: {
|
|
540
|
+
isZStack?: boolean
|
|
541
|
+
children: any
|
|
542
|
+
space?: any
|
|
543
|
+
flexDirection?: ViewStyle['flexDirection']
|
|
544
|
+
}) {
|
|
545
|
+
if (!space && !isZStack) {
|
|
546
|
+
return children
|
|
547
|
+
}
|
|
548
|
+
const childrenList = Children.toArray(children)
|
|
549
|
+
const len = childrenList.length
|
|
550
|
+
if (len === 1) {
|
|
551
|
+
return children
|
|
552
|
+
}
|
|
553
|
+
const next: any[] = []
|
|
554
|
+
for (const [index, child] of childrenList.entries()) {
|
|
555
|
+
if (child === null || child === undefined) {
|
|
556
|
+
continue
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const key = `${child?.['key'] ?? index}`
|
|
560
|
+
|
|
561
|
+
next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>)
|
|
562
|
+
|
|
563
|
+
// allows for custom visually hidden components that dont insert spacing
|
|
564
|
+
if (child?.['type']?.['isVisuallyHidden']) {
|
|
565
|
+
continue
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (index !== len - 1) {
|
|
569
|
+
if (space) {
|
|
570
|
+
next.push(
|
|
571
|
+
<Spacer
|
|
572
|
+
key={`${key}_spacer`}
|
|
573
|
+
// @ts-ignore TODO
|
|
574
|
+
direction={
|
|
575
|
+
flexDirection === 'row' || flexDirection === 'row-reverse' ? 'horizontal' : 'vertical'
|
|
576
|
+
}
|
|
577
|
+
size={space}
|
|
578
|
+
/>
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return next
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// for now not so "tamagui-y"
|
|
587
|
+
const Absolute = ({ children }) => <View style={sheet.fullscreen}>{children}</View>
|
|
588
|
+
const sheet = StyleSheet.create({
|
|
589
|
+
fullscreen: {
|
|
590
|
+
position: 'absolute',
|
|
591
|
+
top: 0,
|
|
592
|
+
left: 0,
|
|
593
|
+
right: 0,
|
|
594
|
+
bottom: 0,
|
|
595
|
+
},
|
|
596
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GenericFont } from './types'
|
|
2
|
+
|
|
3
|
+
export const createFont = <A extends GenericFont>(font: A): A => {
|
|
4
|
+
// fills in any missing values based on size keys being standard
|
|
5
|
+
const sizeKeys = Object.keys(font.size)
|
|
6
|
+
|
|
7
|
+
for (const key in font) {
|
|
8
|
+
if (key === 'size' || key === 'family') continue
|
|
9
|
+
const section = font[key]
|
|
10
|
+
const keys = Object.keys(section)
|
|
11
|
+
|
|
12
|
+
// fill with first filled in value to start
|
|
13
|
+
let fillVal = section[keys[0]]
|
|
14
|
+
|
|
15
|
+
for (const sKey of sizeKeys) {
|
|
16
|
+
if (!(sKey in section)) {
|
|
17
|
+
section[sKey] = fillVal
|
|
18
|
+
} else {
|
|
19
|
+
// if exists, set as the fillVal
|
|
20
|
+
fillVal = section[sKey]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Object.freeze(font)
|
|
26
|
+
}
|