@tamagui/core 1.0.1-beta.149 → 1.0.1-beta.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Tamagui.js +4 -1
- package/dist/cjs/Tamagui.js.map +1 -1
- package/dist/cjs/addTheme.js.map +1 -1
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/platform.native.js.map +1 -1
- package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/cjs/contexts/FontLanguageContext.js.map +1 -1
- package/dist/cjs/contexts/TextAncestorContext.js +6 -7
- package/dist/cjs/contexts/TextAncestorContext.js.map +2 -2
- package/dist/cjs/contexts/ThemeContext.js.map +1 -1
- package/dist/cjs/createComponent.js +315 -123
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createFont.js +2 -1
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createShorthands.js.map +1 -1
- package/dist/cjs/createTamagui.js +5 -3
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTokens.js.map +1 -1
- package/dist/cjs/createVariable.js +3 -1
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +1 -1
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +1 -1
- package/dist/cjs/helpers/calc.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +10 -4
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +89 -9
- package/dist/cjs/helpers/createPropMapper.js.map +1 -1
- package/dist/cjs/helpers/createShallowUpdate.js +12 -9
- package/dist/cjs/helpers/createShallowUpdate.js.map +1 -1
- package/dist/cjs/helpers/cssHash.js.map +1 -1
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js.map +1 -1
- package/dist/cjs/helpers/extendStaticConfig.js +10 -7
- package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
- package/dist/cjs/helpers/getAnimationDriver.js.map +1 -1
- package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/cjs/helpers/getFont.js.map +1 -1
- package/dist/cjs/helpers/getSize.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +99 -53
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStackSize.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +8 -2
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js +7 -3
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +1 -1
- package/dist/cjs/helpers/getVariantExtras.js +9 -7
- package/dist/cjs/helpers/getVariantExtras.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiElement.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.native.js +4 -1
- package/dist/cjs/helpers/matchMedia.native.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js.map +1 -1
- package/dist/cjs/helpers/mergeTransform.js.map +2 -2
- package/dist/cjs/helpers/normalizeColor.js +4 -1
- package/dist/cjs/helpers/normalizeColor.js.map +2 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/startTransition.js +4 -1
- package/dist/cjs/helpers/startTransition.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +12 -5
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/themes.js.map +1 -1
- package/dist/cjs/hooks/useConstant.js.map +1 -1
- package/dist/cjs/hooks/useFeatures.js +0 -120
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js.map +1 -1
- package/dist/cjs/hooks/useIsSSR.js.map +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/cjs/hooks/useMedia.js +10 -7
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/usePressable.js.map +1 -1
- package/dist/cjs/hooks/useSafeRef.js.map +1 -1
- package/dist/cjs/hooks/useServerHooks.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +6 -1
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
- package/dist/cjs/injectStyles.js.map +1 -1
- package/dist/cjs/insertFont.js +3 -1
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/cjs/styled.js +3 -1
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/updateTheme.js +7 -4
- package/dist/cjs/updateTheme.js.map +1 -1
- package/dist/cjs/views/FontLanguage.js +5 -7
- package/dist/cjs/views/FontLanguage.js.map +1 -1
- package/dist/cjs/views/FontLanguage.native.js +6 -7
- package/dist/cjs/views/FontLanguage.native.js.map +1 -1
- package/dist/cjs/views/Slot.js +16 -8
- package/dist/cjs/views/Slot.js.map +1 -1
- package/dist/cjs/views/Stack.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +21 -12
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/Text.js.map +1 -1
- package/dist/cjs/views/Theme.js +25 -11
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +6 -7
- package/dist/cjs/views/ThemeInverse.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.js +14 -8
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +9 -4
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/Tamagui.js.map +1 -1
- package/dist/esm/addTheme.js.map +1 -1
- package/dist/esm/constants/constants.js.map +1 -1
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/platform.native.js.map +1 -1
- package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/esm/contexts/FontLanguageContext.js.map +1 -1
- package/dist/esm/contexts/TextAncestorContext.js +6 -4
- package/dist/esm/contexts/TextAncestorContext.js.map +1 -1
- package/dist/esm/contexts/ThemeContext.js.map +1 -1
- package/dist/esm/createComponent.js +319 -125
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createFont.js +2 -1
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createShorthands.js.map +1 -1
- package/dist/esm/createTamagui.js +5 -3
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js.map +1 -1
- package/dist/esm/createVariable.js +3 -1
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/helpers/RNComponents.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +1 -1
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +1 -1
- package/dist/esm/helpers/calc.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +10 -4
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +89 -9
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/createShallowUpdate.js +12 -9
- package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
- package/dist/esm/helpers/cssHash.js.map +1 -1
- package/dist/esm/helpers/expandStyle.js.map +2 -2
- package/dist/esm/helpers/expandStyles.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +10 -7
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/getAnimationDriver.js.map +1 -1
- package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/esm/helpers/getFont.js.map +1 -1
- package/dist/esm/helpers/getSize.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +99 -53
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStackSize.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +4 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.js +7 -3
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +1 -1
- package/dist/esm/helpers/getVariantExtras.js +9 -7
- package/dist/esm/helpers/getVariantExtras.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/esm/helpers/isTamaguiElement.js.map +1 -1
- package/dist/esm/helpers/matchMedia.js.map +1 -1
- package/dist/esm/helpers/matchMedia.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js.map +1 -1
- package/dist/esm/helpers/mergeTransform.js.map +2 -2
- package/dist/esm/helpers/normalizeColor.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/startTransition.js.map +1 -1
- package/dist/esm/helpers/themeable.js +8 -4
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/themes.js.map +1 -1
- package/dist/esm/hooks/useConstant.js.map +1 -1
- package/dist/esm/hooks/useFeatures.js +0 -120
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useId.js.map +1 -1
- package/dist/esm/hooks/useIsMounted.js.map +1 -1
- package/dist/esm/hooks/useIsSSR.js.map +1 -1
- package/dist/esm/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +10 -7
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useSafeRef.js.map +1 -1
- package/dist/esm/hooks/useServerHooks.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +6 -1
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injectStyles.js.map +1 -1
- package/dist/esm/insertFont.js +3 -1
- package/dist/esm/insertFont.js.map +2 -2
- package/dist/esm/static.js.map +1 -1
- package/dist/esm/styled.js +3 -1
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/updateTheme.js +7 -4
- package/dist/esm/updateTheme.js.map +1 -1
- package/dist/esm/views/FontLanguage.js +5 -4
- package/dist/esm/views/FontLanguage.js.map +1 -1
- package/dist/esm/views/FontLanguage.native.js +6 -4
- package/dist/esm/views/FontLanguage.native.js.map +1 -1
- package/dist/esm/views/Slot.js +12 -7
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.js +17 -11
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/Text.js.map +1 -1
- package/dist/esm/views/Theme.js +21 -10
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +6 -4
- package/dist/esm/views/ThemeInverse.js.map +1 -1
- package/dist/esm/views/ThemeProvider.js +10 -7
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +5 -3
- package/dist/esm/views/ThemeReset.js.map +1 -1
- package/package.json +10 -10
- package/src/constants/platform.ts +1 -0
- package/src/createComponent.tsx +246 -57
- package/src/createFont.ts +4 -1
- package/src/createVariable.ts +2 -1
- package/src/helpers/createMediaStyle.ts +2 -2
- package/src/helpers/getSplitStyles.tsx +73 -65
- package/src/helpers/mergeTransform.ts +2 -0
- package/src/insertFont.ts +2 -1
- package/src/types.tsx +7 -5
- package/types/createVariable.d.ts +1 -1
- package/types/helpers/getSplitStyles.d.ts +1 -0
- package/types/hooks/useFeatures.d.ts +0 -1
- package/types/types.d.ts +11 -3
- package/src/helpers/cssHash.ts +0 -28
- package/src/hooks/useFeatures.tsx +0 -289
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeReset.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManagerContext } from '../helpers/ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const themeManager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (name !== themeManager.parentName) {\n setName(themeManager.parentName)\n }\n }, [themeManager?.parentName])\n\n useLayoutEffect(() => {\n if (!themeManager) return\n return themeManager.onChangeTheme(() => {\n setName(themeManager.parentName)\n })\n }, [])\n }\n\n if (!themeManager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAsCI;AAtCJ,OAAO,SAAS,YAAY,iBAAiB,gBAAgB;AAE7D,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,aAAa;AAGtB,MAAM;AAGC,MAAM,aAAa,CAAC,UAA8B;AACvD,QAAM,eAAe,WAAW,mBAAmB;AACnD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAwB,IAAI;AAKpD,MAAI,CAAC,SAAS,OAAO,aAAa,aAAa;AAC7C,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,SAAS,aAAa,YAAY;AACpC,gBAAQ,aAAa,UAAU;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,6CAAc,UAAU,CAAC;AAE7B,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,aAAO,aAAa,cAAc,MAAM;AACtC,gBAAQ,aAAa,UAAU;AAAA,MACjC,CAAC;AAAA,IACH,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,MAAI,CAAC,gBAAgB,CAAC,MAAM,UAAU;AACpC,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE,oBAAC;AAAA,IAAM,WAAU;AAAA,IAAkB,OAAK;AAAA,IAAC;AAAA,IACtC,gBAAM;AAAA,GACT;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.152",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@expo/match-media": "^0.3.0",
|
|
30
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
31
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/rnw": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/rnw-lite": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/use-debounce": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
30
|
+
"@tamagui/compose-refs": "^1.0.1-beta.152",
|
|
31
|
+
"@tamagui/helpers": "^1.0.1-beta.152",
|
|
32
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.152",
|
|
33
|
+
"@tamagui/rnw": "^1.0.1-beta.152",
|
|
34
|
+
"@tamagui/rnw-lite": "^1.0.1-beta.152",
|
|
35
|
+
"@tamagui/use-debounce": "^1.0.1-beta.152",
|
|
36
|
+
"@tamagui/use-event": "^1.0.1-beta.152",
|
|
37
|
+
"@tamagui/use-force-update": "^1.0.1-beta.152",
|
|
38
38
|
"expo-screen-orientation": "^4.3.0",
|
|
39
39
|
"hyphenate-style-name": "^1.0.4"
|
|
40
40
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-dom": "*"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
46
|
+
"@tamagui/build": "^1.0.1-beta.152",
|
|
47
47
|
"@types/react": "^18.0.15",
|
|
48
48
|
"csstype": "^3.0.10",
|
|
49
49
|
"esbuild": "^0.14.49",
|
|
@@ -8,6 +8,7 @@ export const isWindowDefined = typeof window !== 'undefined'
|
|
|
8
8
|
export const isSSR = isWeb && !isWindowDefined
|
|
9
9
|
export const isClient = isWeb && isWindowDefined
|
|
10
10
|
|
|
11
|
+
// may want to move to VITE_RSC_BUILD
|
|
11
12
|
export const isRSC = process.env.ENABLE_RSC
|
|
12
13
|
? // note this is statically analyzed so no funny business, just access it without optional chaining
|
|
13
14
|
// @ts-ignore
|
package/src/createComponent.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import React, {
|
|
|
20
20
|
memo,
|
|
21
21
|
useCallback,
|
|
22
22
|
useContext,
|
|
23
|
+
useEffect,
|
|
23
24
|
} from 'react'
|
|
24
25
|
import { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
25
26
|
|
|
@@ -32,12 +33,16 @@ import { assignNativePropsToWeb } from './helpers/assignNativePropsToWeb'
|
|
|
32
33
|
import { getReturnVariablesAs } from './helpers/createPropMapper'
|
|
33
34
|
import { createShallowUpdate } from './helpers/createShallowUpdate'
|
|
34
35
|
import { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'
|
|
35
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
SplitStyleResult,
|
|
38
|
+
getSubStyle,
|
|
39
|
+
insertSplitStyles,
|
|
40
|
+
useSplitStyles,
|
|
41
|
+
} from './helpers/getSplitStyles'
|
|
36
42
|
import { getAllSelectors } from './helpers/insertStyleRule'
|
|
37
43
|
import { mergeProps } from './helpers/mergeProps'
|
|
38
44
|
import { proxyThemeVariables } from './helpers/proxyThemeVariables'
|
|
39
|
-
import {
|
|
40
|
-
import { mediaState } from './hooks/useMedia'
|
|
45
|
+
import { addMediaQueryListener, mediaState, removeMediaQueryListener } from './hooks/useMedia'
|
|
41
46
|
import { usePressable } from './hooks/usePressable'
|
|
42
47
|
import { useServerRef, useServerState } from './hooks/useServerHooks'
|
|
43
48
|
import { getThemeManager, useTheme } from './hooks/useTheme'
|
|
@@ -54,6 +59,7 @@ import {
|
|
|
54
59
|
TamaguiElement,
|
|
55
60
|
TamaguiInternalConfig,
|
|
56
61
|
UseAnimationHook,
|
|
62
|
+
UseAnimationProps,
|
|
57
63
|
} from './types'
|
|
58
64
|
import { usePressability } from './vendor/Pressability'
|
|
59
65
|
import { Slot, mergeEvent } from './views/Slot'
|
|
@@ -92,6 +98,7 @@ function mergeShorthands({ defaultProps }: StaticConfigParsed, { shorthands }: T
|
|
|
92
98
|
|
|
93
99
|
let initialTheme: any
|
|
94
100
|
let config: TamaguiInternalConfig
|
|
101
|
+
let mediaPropNames: string[] = []
|
|
95
102
|
|
|
96
103
|
export function createComponent<
|
|
97
104
|
ComponentPropTypes extends Object = {},
|
|
@@ -199,25 +206,114 @@ export function createComponent<
|
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
|
|
202
|
-
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles
|
|
209
|
+
const { viewProps: viewPropsIn, pseudos, medias, style, classNames, mediaKeys } = splitStyles
|
|
210
|
+
|
|
211
|
+
// media queries
|
|
212
|
+
useIsomorphicLayoutEffect(() => {
|
|
213
|
+
for (const key of mediaKeys) {
|
|
214
|
+
addMediaQueryListener(key, forceUpdate)
|
|
215
|
+
}
|
|
216
|
+
return () => {
|
|
217
|
+
for (const key of mediaKeys) {
|
|
218
|
+
removeMediaQueryListener(key, forceUpdate)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, [mediaKeys.join(',')])
|
|
222
|
+
|
|
223
|
+
// animations
|
|
203
224
|
const useAnimations = tamaguiConfig?.animations?.useAnimations as UseAnimationHook | undefined
|
|
204
225
|
const isAnimated = !!(useAnimations && props.animation)
|
|
205
226
|
const hasEnterStyle = !!props.enterStyle
|
|
206
|
-
|
|
207
227
|
const animationFeatureStylesIn = props.animation ? { ...defaultNativeStyle, ...style } : null
|
|
228
|
+
const propsWithAnimation = props as UseAnimationProps
|
|
229
|
+
|
|
230
|
+
// lets make changing the key mandatory for adding/removing animations
|
|
231
|
+
// reason is animations are heavy no way around it, and must be run inline here (🙅 loading as a sub-component)
|
|
232
|
+
// because they need to sync update on first render. it's pretty rare too going to/from no animation => animation
|
|
233
|
+
// so requiring key change on animation change is least-bad option.
|
|
234
|
+
// plus, React use() may let us get away with conditional hooks soon :)
|
|
235
|
+
if (!isRSC && isAnimated) {
|
|
236
|
+
const animationState = useAnimations(propsWithAnimation, {
|
|
237
|
+
state,
|
|
238
|
+
pseudos,
|
|
239
|
+
onDidAnimate: props.onDidAnimate,
|
|
240
|
+
hostRef,
|
|
241
|
+
staticConfig,
|
|
242
|
+
getStyle({ isExiting, isEntering, exitVariant, enterVariant } = {}) {
|
|
243
|
+
// we have to merge such that transforms keys all exist
|
|
244
|
+
const style = animationFeatureStylesIn
|
|
245
|
+
|
|
246
|
+
const enterStyle = isEntering
|
|
247
|
+
? enterVariant && staticConfig.variants?.[enterVariant]['true']
|
|
248
|
+
? getSubStyle(
|
|
249
|
+
'',
|
|
250
|
+
staticConfig.variants?.[enterVariant]['true'],
|
|
251
|
+
staticConfig,
|
|
252
|
+
theme,
|
|
253
|
+
props,
|
|
254
|
+
state,
|
|
255
|
+
tamaguiConfig
|
|
256
|
+
) || pseudos.enterStyle
|
|
257
|
+
: null || pseudos.enterStyle
|
|
258
|
+
: null
|
|
259
|
+
|
|
260
|
+
const exitStyle = isExiting
|
|
261
|
+
? exitVariant && staticConfig.variants?.[exitVariant]['true']
|
|
262
|
+
? getSubStyle(
|
|
263
|
+
'',
|
|
264
|
+
staticConfig.variants?.[exitVariant]['true'],
|
|
265
|
+
staticConfig,
|
|
266
|
+
theme,
|
|
267
|
+
props,
|
|
268
|
+
state,
|
|
269
|
+
tamaguiConfig
|
|
270
|
+
) || pseudos.exitStyle
|
|
271
|
+
: null || pseudos.exitStyle
|
|
272
|
+
: null
|
|
273
|
+
|
|
274
|
+
// if you have hoverStyle={{ scale: 1.1 }} and don't have scale set on the base style
|
|
275
|
+
// no animation will run! this is really confusing. this will look at all variants,
|
|
276
|
+
// and fill in base styles if they don't exist. eg:
|
|
277
|
+
// input:
|
|
278
|
+
// base: {}
|
|
279
|
+
// hoverStyle: { scale: 2 }
|
|
280
|
+
// enterStyle: { x: 100 }
|
|
281
|
+
// output:
|
|
282
|
+
// base: { x: 0, scale: 1 }
|
|
283
|
+
ensureBaseHasDefaults(
|
|
284
|
+
style,
|
|
285
|
+
// enterStyle,
|
|
286
|
+
pseudos.hoverStyle,
|
|
287
|
+
pseudos.focusStyle,
|
|
288
|
+
pseudos.pressStyle,
|
|
289
|
+
pseudos.pressStyle
|
|
290
|
+
)
|
|
208
291
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
292
|
+
enterStyle && isEntering && merge(style, enterStyle)
|
|
293
|
+
state.hover && pseudos.hoverStyle && merge(style, pseudos.hoverStyle)
|
|
294
|
+
state.focus && pseudos.focusStyle && merge(style, pseudos.focusStyle)
|
|
295
|
+
state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle)
|
|
296
|
+
exitStyle && isExiting && merge(style, exitStyle)
|
|
297
|
+
|
|
298
|
+
if (process.env.NODE_ENV === 'development') {
|
|
299
|
+
if (props['debug']) {
|
|
300
|
+
// eslint-disable-next-line no-console
|
|
301
|
+
console.log('animation style', style)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return style
|
|
306
|
+
},
|
|
307
|
+
//, delay
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
// must be properly memoized
|
|
311
|
+
if (animationState !== state.animation) {
|
|
312
|
+
setStateShallow({
|
|
313
|
+
animation: animationState,
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
}
|
|
221
317
|
|
|
222
318
|
const {
|
|
223
319
|
tag,
|
|
@@ -434,7 +530,27 @@ export function createComponent<
|
|
|
434
530
|
|
|
435
531
|
// from react-native-web
|
|
436
532
|
const platformMethodsRef = usePlatformMethods(viewProps)
|
|
437
|
-
|
|
533
|
+
|
|
534
|
+
const shouldSetMounted = Boolean(
|
|
535
|
+
isClient && (hasEnterStyle || props.animation) && !state.mounted
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
const setRef = useMergeRefs(
|
|
539
|
+
hostRef,
|
|
540
|
+
platformMethodsRef,
|
|
541
|
+
forwardedRef as any,
|
|
542
|
+
shouldSetMounted
|
|
543
|
+
? () => {
|
|
544
|
+
// for some reason without some small delay it doesn't animate css
|
|
545
|
+
setTimeout(() => {
|
|
546
|
+
setStateShallow({
|
|
547
|
+
mounted: true,
|
|
548
|
+
})
|
|
549
|
+
}, 10)
|
|
550
|
+
}
|
|
551
|
+
: undefined
|
|
552
|
+
)
|
|
553
|
+
|
|
438
554
|
viewProps.ref = setRef
|
|
439
555
|
}
|
|
440
556
|
|
|
@@ -503,31 +619,14 @@ export function createComponent<
|
|
|
503
619
|
})
|
|
504
620
|
}
|
|
505
621
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
622
|
+
if (!isRSC) {
|
|
623
|
+
useEffect(() => {
|
|
624
|
+
return () => {
|
|
625
|
+
mouseUps.delete(unPress)
|
|
626
|
+
}
|
|
627
|
+
}, [])
|
|
512
628
|
}
|
|
513
629
|
|
|
514
|
-
useIsomorphicLayoutEffect(() => {
|
|
515
|
-
// we need to use state to properly have mounted go from false => true
|
|
516
|
-
if (isClient && (hasEnterStyle || props.animation) && !state.mounted) {
|
|
517
|
-
// for SSR we never set mounted, ensuring enterStyle={{}} is set by default
|
|
518
|
-
setStateShallow({
|
|
519
|
-
mounted: true,
|
|
520
|
-
})
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
internal.current!.isMounted = true
|
|
524
|
-
return () => {
|
|
525
|
-
mouseUps.delete(unPress)
|
|
526
|
-
internal.current!.isMounted = false
|
|
527
|
-
internal.current!.unmountEffects?.forEach((cb) => cb())
|
|
528
|
-
}
|
|
529
|
-
}, [hasEnterStyle, props.animation])
|
|
530
|
-
|
|
531
630
|
let styles: any[]
|
|
532
631
|
|
|
533
632
|
const animationStyles = state.animation ? state.animation.style : null
|
|
@@ -546,11 +645,13 @@ export function createComponent<
|
|
|
546
645
|
]
|
|
547
646
|
if (!animationStyles && initialSplitStyles) {
|
|
548
647
|
const initPseudos = initialSplitStyles.pseudos
|
|
549
|
-
const force = shouldForcePseudo
|
|
550
648
|
!state.mounted && addPseudoToStyles(styles, initPseudos, pseudos, 'enterStyle')
|
|
551
|
-
state.hover &&
|
|
552
|
-
|
|
553
|
-
state.
|
|
649
|
+
state.hover &&
|
|
650
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'hoverStyle', shouldForcePseudo)
|
|
651
|
+
state.focus &&
|
|
652
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'focusStyle', shouldForcePseudo)
|
|
653
|
+
state.press &&
|
|
654
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'pressStyle', shouldForcePseudo)
|
|
554
655
|
}
|
|
555
656
|
// ugly but for now...
|
|
556
657
|
if (shouldForcePseudo) {
|
|
@@ -606,7 +707,34 @@ export function createComponent<
|
|
|
606
707
|
}
|
|
607
708
|
|
|
608
709
|
viewProps.style = style
|
|
609
|
-
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
713
|
+
// swap out the right family based on weight/style
|
|
714
|
+
if (splitStyles.fontFamily) {
|
|
715
|
+
const faceInfo = config.fontsParsed[splitStyles.fontFamily]?.face
|
|
716
|
+
if (faceInfo) {
|
|
717
|
+
const [weight, style] = (() => {
|
|
718
|
+
let weight: string | undefined
|
|
719
|
+
let style: string | undefined
|
|
720
|
+
for (let i = styles.length; i >= 0; i--) {
|
|
721
|
+
weight ??= styles[i]?.fontWeight
|
|
722
|
+
style ??= styles[i]?.fontStyle
|
|
723
|
+
}
|
|
724
|
+
return [weight || '400', style || 'normal'] as const
|
|
725
|
+
})()
|
|
726
|
+
const overrideFace = faceInfo[weight]?.[style]?.val
|
|
727
|
+
if (overrideFace) {
|
|
728
|
+
for (const style of styles) {
|
|
729
|
+
if (style?.fontFamily) {
|
|
730
|
+
style.fontFamily = overrideFace
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// assign styles
|
|
610
738
|
viewProps.style = styles
|
|
611
739
|
}
|
|
612
740
|
|
|
@@ -648,7 +776,6 @@ export function createComponent<
|
|
|
648
776
|
'onMouseLeave' in props)))
|
|
649
777
|
|
|
650
778
|
const unPress = useCallback(() => {
|
|
651
|
-
if (!internal.current!.isMounted) return
|
|
652
779
|
setStateShallow({
|
|
653
780
|
press: false,
|
|
654
781
|
pressIn: false,
|
|
@@ -739,8 +866,9 @@ export function createComponent<
|
|
|
739
866
|
: null
|
|
740
867
|
|
|
741
868
|
let space = spaceProp
|
|
869
|
+
|
|
742
870
|
// find space by media query
|
|
743
|
-
if (
|
|
871
|
+
if (mediaKeys.length) {
|
|
744
872
|
for (const key in mediaState) {
|
|
745
873
|
if (!mediaState[key]) continue
|
|
746
874
|
if (props[key] && props[key].space !== undefined) {
|
|
@@ -854,7 +982,9 @@ export function createComponent<
|
|
|
854
982
|
// only necessary when animating because some AnimatedView which wraps RNW View doesn't forward dataSet className
|
|
855
983
|
const isAnimatedRNWView = isAnimated && typeof elementType !== 'string' // assuming for now as reanimated is only driver
|
|
856
984
|
const shouldWrapWithComponentTheme =
|
|
857
|
-
|
|
985
|
+
!!theme.className &&
|
|
986
|
+
isAnimatedRNWView &&
|
|
987
|
+
getReturnVariablesAs(props, splitStyleState) === 'non-color-value'
|
|
858
988
|
const shouldWrapWithHover = Boolean(events || isRSC) && attachHover
|
|
859
989
|
|
|
860
990
|
if (shouldWrapWithHover || shouldWrapWithComponentTheme) {
|
|
@@ -901,14 +1031,7 @@ export function createComponent<
|
|
|
901
1031
|
}
|
|
902
1032
|
}
|
|
903
1033
|
|
|
904
|
-
return
|
|
905
|
-
<>
|
|
906
|
-
{features.elements}
|
|
907
|
-
{content}
|
|
908
|
-
</>
|
|
909
|
-
) : (
|
|
910
|
-
content
|
|
911
|
-
)
|
|
1034
|
+
return content
|
|
912
1035
|
})
|
|
913
1036
|
|
|
914
1037
|
if (staticConfig.componentName) {
|
|
@@ -1335,3 +1458,69 @@ function mergeConfigDefaultProps(
|
|
|
1335
1458
|
}
|
|
1336
1459
|
return props
|
|
1337
1460
|
}
|
|
1461
|
+
|
|
1462
|
+
const defaults = {
|
|
1463
|
+
left: 0,
|
|
1464
|
+
right: 0,
|
|
1465
|
+
top: 0,
|
|
1466
|
+
bottom: 0,
|
|
1467
|
+
opacity: 1,
|
|
1468
|
+
translateX: 0,
|
|
1469
|
+
translateY: 0,
|
|
1470
|
+
skew: 0,
|
|
1471
|
+
skewX: 0,
|
|
1472
|
+
skewY: 0,
|
|
1473
|
+
scale: 1,
|
|
1474
|
+
rotate: '0deg',
|
|
1475
|
+
rotateY: '0deg',
|
|
1476
|
+
rotateX: '0deg',
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
function ensureBaseHasDefaults(base: ViewStyle, ...pseudos: (ViewStyle | null | undefined)[]) {
|
|
1480
|
+
for (const pseudo of pseudos) {
|
|
1481
|
+
if (!pseudo) continue
|
|
1482
|
+
for (const key in pseudo) {
|
|
1483
|
+
const val = pseudo[key]
|
|
1484
|
+
// can we just use merge() here?
|
|
1485
|
+
if (key === 'transform') {
|
|
1486
|
+
if (typeof val === 'string') {
|
|
1487
|
+
continue
|
|
1488
|
+
}
|
|
1489
|
+
for (const t of val) {
|
|
1490
|
+
const tkey = Object.keys(t)[0]
|
|
1491
|
+
const defaultVal = defaults[tkey]
|
|
1492
|
+
const tDefaultVal = { [tkey]: defaultVal } as any
|
|
1493
|
+
if (!base.transform) {
|
|
1494
|
+
base.transform = [tDefaultVal]
|
|
1495
|
+
} else {
|
|
1496
|
+
if (!base.transform.find((x) => x[tkey])) {
|
|
1497
|
+
base.transform.push(tDefaultVal)
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
} else {
|
|
1502
|
+
if (!(key in base)) {
|
|
1503
|
+
base[key] = defaults[key]
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
function merge(base: ViewStyle, next: ViewStyle) {
|
|
1511
|
+
if (!next.transform || !base.transform) {
|
|
1512
|
+
Object.assign(base, next)
|
|
1513
|
+
return
|
|
1514
|
+
}
|
|
1515
|
+
const { transform, ...rest } = next
|
|
1516
|
+
Object.assign(base, rest)
|
|
1517
|
+
for (const t of transform) {
|
|
1518
|
+
const key = Object.keys(t)[0]
|
|
1519
|
+
const existing = base.transform.find((x) => key in x)
|
|
1520
|
+
if (existing) {
|
|
1521
|
+
existing[key] = t[key]
|
|
1522
|
+
} else {
|
|
1523
|
+
base.transform.push(t)
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
package/src/createFont.ts
CHANGED
|
@@ -4,8 +4,11 @@ export const createFont = <A extends GenericFont>(font: A): A => {
|
|
|
4
4
|
// fills in any missing values based on size keys being standard
|
|
5
5
|
const sizeKeys = Object.keys(font.size)
|
|
6
6
|
|
|
7
|
+
// fill in intermediate values
|
|
7
8
|
for (const key in font) {
|
|
8
|
-
if (key === 'size' || key === 'family')
|
|
9
|
+
if (key === 'size' || key === 'family' || key === 'face') {
|
|
10
|
+
continue
|
|
11
|
+
}
|
|
9
12
|
const section = font[key] as Object
|
|
10
13
|
const keys = Object.keys(section)
|
|
11
14
|
|
package/src/createVariable.ts
CHANGED
|
@@ -36,9 +36,10 @@ export const createVariable = <A extends string | number = any>(props: VariableI
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// on the client maybe we can change the prototype of variable object toString to keep backwards compat
|
|
39
|
-
export function variableToString(vrble?: any) {
|
|
39
|
+
export function variableToString(vrble?: any, getValue = false) {
|
|
40
40
|
if (!vrble) return ''
|
|
41
41
|
if (isVariable(vrble)) {
|
|
42
|
+
if (getValue) return `${vrble.val}`
|
|
42
43
|
return `${isWeb ? vrble.variable : vrble.val}`
|
|
43
44
|
}
|
|
44
45
|
return `${vrble}`
|
|
@@ -27,9 +27,9 @@ export const createMediaStyle = (
|
|
|
27
27
|
ogPrefix,
|
|
28
28
|
`${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`
|
|
29
29
|
)}`
|
|
30
|
-
const screenStr = negate ? 'not all' : '
|
|
30
|
+
const screenStr = negate ? 'not all and' : ''
|
|
31
31
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey])
|
|
32
|
-
const mediaQuery = `${screenStr}
|
|
32
|
+
const mediaQuery = `${screenStr} ${mediaSelector}`
|
|
33
33
|
const styleInner = rules.map((rule) => rule.replace(identifier, nextIdentifier)).join(';')
|
|
34
34
|
// combines media queries if they already exist
|
|
35
35
|
let styleRule = ''
|