@tamagui/core 1.0.1-beta.193 → 1.0.1-beta.195
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 -2
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/config.js +1 -2
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/constants/constants.js +13 -8
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/contexts/TextAncestorContext.js +3 -16
- package/dist/cjs/contexts/TextAncestorContext.js.map +3 -3
- package/dist/cjs/createComponent.js +204 -294
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +15 -16
- package/dist/cjs/createTamagui.js.map +3 -3
- package/dist/cjs/createVariable.js +1 -2
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +7 -14
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/{createShallowUpdate.js → cache.js} +20 -21
- package/dist/cjs/helpers/cache.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +14 -8
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +0 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +212 -93
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStylesAtomic.js +16 -36
- package/dist/cjs/helpers/getStylesAtomic.js.map +3 -3
- package/dist/cjs/helpers/insertStyleRule.js +14 -6
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.js +32 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/cjs/helpers/useShallowSetState.js.map +2 -2
- package/dist/cjs/hooks/getThemeUnwrapped.js +1 -3
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +92 -0
- package/dist/cjs/hooks/useElementLayout.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +2 -10
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +77 -84
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useMedia.test.js +2 -0
- package/dist/cjs/{helpers/validate.js.map → hooks/useMedia.test.js.map} +0 -0
- package/dist/cjs/hooks/usePressablePressResponder.js +370 -0
- package/dist/cjs/hooks/usePressablePressResponder.js.map +7 -0
- package/dist/cjs/hooks/useSafeRef.js +13 -15
- package/dist/cjs/hooks/useSafeRef.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +3 -4
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +1 -17
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +0 -20
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +4 -22
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/{hooks/useIsSSR.js → views/AbsoluteFill.js} +18 -23
- package/dist/cjs/views/AbsoluteFill.js.map +7 -0
- package/dist/cjs/views/AbsoluteFill.native.js +45 -0
- package/dist/cjs/views/AbsoluteFill.native.js.map +7 -0
- package/dist/cjs/views/FontLanguage.native.js.map +2 -2
- package/dist/cjs/views/Stack.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +3 -2
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Text.js.map +1 -1
- package/dist/cjs/views/ThemeReset.js +10 -10
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/Tamagui.js +4 -2
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/config.js +1 -2
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/constants/constants.js +11 -7
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/contexts/TextAncestorContext.js +2 -13
- package/dist/esm/contexts/TextAncestorContext.js.map +2 -2
- package/dist/esm/createComponent.js +203 -296
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +15 -16
- package/dist/esm/createTamagui.js.map +3 -3
- package/dist/esm/createVariable.js +1 -2
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +7 -14
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/cache.js +18 -0
- package/dist/esm/helpers/cache.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +14 -8
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +0 -1
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +221 -94
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStylesAtomic.js +13 -26
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +14 -6
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/matchMedia.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js +30 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/esm/helpers/useShallowSetState.js.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.js +1 -3
- package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +66 -0
- package/dist/esm/hooks/useElementLayout.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +3 -11
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +74 -83
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useMedia.test.js +1 -0
- package/dist/esm/{helpers/validate.js.map → hooks/useMedia.test.js.map} +0 -0
- package/dist/esm/hooks/usePressablePressResponder.js +346 -0
- package/dist/esm/hooks/usePressablePressResponder.js.map +7 -0
- package/dist/esm/hooks/useSafeRef.js +13 -15
- package/dist/esm/hooks/useSafeRef.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +3 -4
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +1 -14
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +0 -14
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +4 -22
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/AbsoluteFill.js +17 -0
- package/dist/esm/views/AbsoluteFill.js.map +7 -0
- package/dist/esm/views/AbsoluteFill.native.js +21 -0
- package/dist/esm/views/AbsoluteFill.native.js.map +7 -0
- package/dist/esm/views/FontLanguage.native.js.map +2 -2
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.js +5 -4
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Text.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +10 -10
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +14 -14
- package/src/Tamagui.ts +7 -3
- package/src/config.ts +2 -3
- package/src/constants/constants.ts +10 -6
- package/src/contexts/TextAncestorContext.tsx +1 -8
- package/src/createComponent.tsx +256 -421
- package/src/createTamagui.ts +16 -19
- package/src/createVariable.ts +1 -3
- package/src/helpers/ThemeManager.tsx +7 -15
- package/src/helpers/cache.ts +18 -0
- package/src/helpers/createMediaStyle.ts +16 -9
- package/src/helpers/extendStaticConfig.ts +0 -1
- package/src/helpers/getSplitStyles.tsx +257 -151
- package/src/helpers/getStylesAtomic.ts +14 -34
- package/src/helpers/insertStyleRule.tsx +16 -8
- package/src/helpers/matchMedia.ts +1 -0
- package/src/helpers/mergeTransform.ts +1 -1
- package/src/helpers/normalizeValueWithProperty.ts +30 -0
- package/src/helpers/useShallowSetState.tsx +0 -1
- package/src/hooks/getThemeUnwrapped.tsx +1 -2
- package/src/hooks/useElementLayout.tsx +90 -0
- package/src/hooks/useIsTouchDevice.tsx +3 -17
- package/src/hooks/useMedia.tsx +80 -87
- package/src/hooks/useSafeRef.ts +17 -18
- package/src/hooks/useTheme.tsx +4 -4
- package/src/index.ts +1 -11
- package/src/static.ts +0 -10
- package/src/styled.tsx +15 -33
- package/src/types.tsx +58 -55
- package/src/views/FontLanguage.native.tsx +1 -0
- package/src/views/Stack.tsx +1 -1
- package/src/views/TamaguiProvider.tsx +5 -5
- package/src/views/Text.tsx +1 -1
- package/src/views/ThemeReset.tsx +11 -11
- package/types/Tamagui.d.ts +6 -4
- package/types/constants/constants.d.ts +14 -3
- package/types/contexts/TextAncestorContext.d.ts +1 -3
- package/types/createComponent.d.ts +0 -15
- package/types/helpers/ThemeManager.d.ts +2 -3
- package/types/helpers/cache.d.ts +12 -0
- package/types/helpers/calc.d.ts +0 -16
- package/types/helpers/createMediaStyle.d.ts +1 -1
- package/types/helpers/getSplitStyles.d.ts +6 -10
- package/types/helpers/getStylesAtomic.d.ts +1 -5
- package/types/helpers/insertStyleRule.d.ts +2 -2
- package/types/helpers/mergeTransform.d.ts +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts +1 -0
- package/types/hooks/useElementLayout.d.ts +27 -0
- package/types/hooks/useMedia.d.ts +3 -1
- package/types/hooks/useMedia.test.d.ts +1 -0
- package/types/hooks/usePressablePressResponder.d.ts +84 -0
- package/types/index.d.ts +1 -11
- package/types/static.d.ts +0 -1
- package/types/types.d.ts +42 -44
- package/types/views/AbsoluteFill.d.ts +5 -0
- package/types/views/AbsoluteFill.native.d.ts +3 -0
- package/types/views/Stack.d.ts +1 -1
- package/types/views/Text.d.ts +1 -1
- package/dist/cjs/constants/platform.js +0 -74
- package/dist/cjs/constants/platform.js.map +0 -7
- package/dist/cjs/constants/platform.native.js +0 -62
- package/dist/cjs/constants/platform.native.js.map +0 -7
- package/dist/cjs/helpers/createShallowUpdate.js.map +0 -7
- package/dist/cjs/helpers/validate.js +0 -2
- package/dist/cjs/hooks/useDidFinishSSR.js +0 -60
- package/dist/cjs/hooks/useDidFinishSSR.js.map +0 -7
- package/dist/cjs/hooks/useIsSSR.js.map +0 -7
- package/dist/esm/constants/platform.js +0 -39
- package/dist/esm/constants/platform.js.map +0 -7
- package/dist/esm/constants/platform.native.js +0 -28
- package/dist/esm/constants/platform.native.js.map +0 -7
- package/dist/esm/helpers/createShallowUpdate.js +0 -20
- package/dist/esm/helpers/createShallowUpdate.js.map +0 -7
- package/dist/esm/helpers/validate.js +0 -1
- package/dist/esm/hooks/useDidFinishSSR.js +0 -35
- package/dist/esm/hooks/useDidFinishSSR.js.map +0 -7
- package/dist/esm/hooks/useIsSSR.js +0 -22
- package/dist/esm/hooks/useIsSSR.js.map +0 -7
- package/src/helpers/assignNativePropsToWeb.tsx +0 -178
- package/src/helpers/calc.ts +0 -68
- package/src/helpers/getFont.tsx +0 -43
- package/src/helpers/getStackSize.ts +0 -22
- package/src/helpers/startTransition.ts +0 -4
- package/src/hooks/useConstant.tsx +0 -19
- package/src/hooks/useIsMounted.ts +0 -16
- package/src/hooks/usePressable.tsx +0 -9
- package/src/hooks/useUnmountEffect.ts +0 -5
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { isClient, isRSC, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
2
|
import { stylePropsText, stylePropsTransform, validPseudoKeys, validStyles } from '@tamagui/helpers'
|
|
3
|
+
import type { ViewStyle } from '@tamagui/types-react-native'
|
|
3
4
|
import { useInsertionEffect } from 'react'
|
|
4
|
-
import type { ViewStyle } from 'react-native'
|
|
5
5
|
|
|
6
6
|
import { getConfig } from '../config'
|
|
7
7
|
import { isDevTools } from '../constants/isDevTools'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
mediaState as globalMediaState,
|
|
10
|
+
mediaQueryConfig,
|
|
11
|
+
mergeMediaByImportance,
|
|
12
|
+
} from '../hooks/useMedia'
|
|
9
13
|
import type {
|
|
10
14
|
DebugProp,
|
|
11
15
|
MediaQueryKey,
|
|
@@ -32,9 +36,11 @@ import {
|
|
|
32
36
|
updateInserted,
|
|
33
37
|
updateRules,
|
|
34
38
|
} from './insertStyleRule'
|
|
35
|
-
import { mergeProps } from './mergeProps'
|
|
36
39
|
import { mergeTransform } from './mergeTransform'
|
|
37
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
normalizeValueWithProperty,
|
|
42
|
+
reverseMapClassNameToValue,
|
|
43
|
+
} from './normalizeValueWithProperty.js'
|
|
38
44
|
import { pseudoDescriptors } from './pseudoDescriptors'
|
|
39
45
|
|
|
40
46
|
export type SplitStyles = ReturnType<typeof getSplitStyles>
|
|
@@ -46,12 +52,13 @@ const skipProps = {
|
|
|
46
52
|
animateOnly: true,
|
|
47
53
|
debug: true,
|
|
48
54
|
componentName: true,
|
|
55
|
+
role: true,
|
|
56
|
+
tag: true,
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
// native only skips
|
|
52
60
|
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
53
61
|
Object.assign(skipProps, {
|
|
54
|
-
tag: true,
|
|
55
62
|
whiteSpace: true,
|
|
56
63
|
wordWrap: true,
|
|
57
64
|
textOverflow: true,
|
|
@@ -65,37 +72,93 @@ if (process.env.TAMAGUI_TARGET === 'native') {
|
|
|
65
72
|
})
|
|
66
73
|
}
|
|
67
74
|
|
|
75
|
+
// web only maps accessibility to aria props
|
|
76
|
+
const accessibilityDirectMap: Record<string, string> = {}
|
|
77
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
78
|
+
// bundle size shave
|
|
79
|
+
const items = {
|
|
80
|
+
Hidden: true,
|
|
81
|
+
ActiveDescendant: true,
|
|
82
|
+
Atomic: true,
|
|
83
|
+
AutoComplete: true,
|
|
84
|
+
Busy: true,
|
|
85
|
+
Checked: true,
|
|
86
|
+
ColumnCount: 'colcount',
|
|
87
|
+
ColumnIndex: 'colindex',
|
|
88
|
+
ColumnSpan: 'colspan',
|
|
89
|
+
Current: true,
|
|
90
|
+
Details: true,
|
|
91
|
+
ErrorMessage: true,
|
|
92
|
+
Expanded: true,
|
|
93
|
+
HasPopup: true,
|
|
94
|
+
Invalid: true,
|
|
95
|
+
Label: true,
|
|
96
|
+
Level: true,
|
|
97
|
+
Modal: true,
|
|
98
|
+
Multiline: true,
|
|
99
|
+
MultiSelectable: true,
|
|
100
|
+
Orientation: true,
|
|
101
|
+
Owns: true,
|
|
102
|
+
Placeholder: true,
|
|
103
|
+
PosInSet: true,
|
|
104
|
+
Pressed: true,
|
|
105
|
+
RoleDescription: true,
|
|
106
|
+
RowCount: true,
|
|
107
|
+
RowIndex: true,
|
|
108
|
+
RowSpan: true,
|
|
109
|
+
Selected: true,
|
|
110
|
+
SetSize: true,
|
|
111
|
+
Sort: true,
|
|
112
|
+
ValueMax: true,
|
|
113
|
+
ValueMin: true,
|
|
114
|
+
ValueNow: true,
|
|
115
|
+
ValueText: true,
|
|
116
|
+
}
|
|
117
|
+
for (const key in items) {
|
|
118
|
+
let val = items[key]
|
|
119
|
+
if (val === true) {
|
|
120
|
+
val = key.toLowerCase()
|
|
121
|
+
}
|
|
122
|
+
accessibilityDirectMap[`accessibility${key}`] = `aria-${val}`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
68
126
|
type TransformNamespaceKey = 'transform' | PseudoPropKeys | MediaQueryKey
|
|
69
127
|
|
|
70
128
|
let conf: TamaguiInternalConfig
|
|
71
129
|
|
|
72
|
-
type
|
|
73
|
-
props: { [key: string]: any },
|
|
74
|
-
staticConfig: StaticConfigParsed,
|
|
75
|
-
theme: ThemeParsed,
|
|
76
|
-
state: SplitStyleState,
|
|
77
|
-
defaultClassNames?: any,
|
|
78
|
-
languageContext?: LanguageContextType,
|
|
79
|
-
debug?: DebugProp
|
|
80
|
-
) => {
|
|
130
|
+
type SplitStylesAndProps = {
|
|
81
131
|
pseudos: PseudoStyles
|
|
82
132
|
medias: Record<MediaQueryKey, ViewStyle>
|
|
83
133
|
style: ViewStyle
|
|
84
134
|
classNames: ClassNamesObject
|
|
85
135
|
rulesToInsert: RulesToInsert
|
|
86
|
-
viewProps: StackProps
|
|
136
|
+
viewProps: StackProps & Record<string, any>
|
|
87
137
|
fontFamily: string | undefined
|
|
88
138
|
mediaKeys: string[]
|
|
89
139
|
}
|
|
90
140
|
|
|
141
|
+
type StyleSplitter = (
|
|
142
|
+
props: { [key: string]: any },
|
|
143
|
+
staticConfig: StaticConfigParsed,
|
|
144
|
+
theme: ThemeParsed,
|
|
145
|
+
state: SplitStyleState,
|
|
146
|
+
parentSplitStyles?: SplitStylesAndProps | null,
|
|
147
|
+
languageContext?: LanguageContextType,
|
|
148
|
+
// web-only
|
|
149
|
+
elementType?: string,
|
|
150
|
+
debug?: DebugProp
|
|
151
|
+
) => SplitStylesAndProps
|
|
152
|
+
|
|
91
153
|
export const PROP_SPLIT = '-'
|
|
92
154
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
155
|
+
const accessibilityRoleToWebRole = {
|
|
156
|
+
adjustable: 'slider',
|
|
157
|
+
header: 'heading',
|
|
158
|
+
image: 'img',
|
|
159
|
+
link: 'link',
|
|
160
|
+
none: 'presentation',
|
|
161
|
+
summary: 'region',
|
|
99
162
|
}
|
|
100
163
|
|
|
101
164
|
// loop props backwards
|
|
@@ -105,37 +168,36 @@ export const pseudoCNInverse = {
|
|
|
105
168
|
// const styles = {}
|
|
106
169
|
// const classNames = {}
|
|
107
170
|
|
|
171
|
+
const isMediaKey = (key: string) => Boolean(key[0] === '$' && mediaQueryConfig[key.slice(1)])
|
|
172
|
+
|
|
108
173
|
export const getSplitStyles: StyleSplitter = (
|
|
109
174
|
props,
|
|
110
175
|
staticConfig,
|
|
111
176
|
theme,
|
|
112
177
|
state,
|
|
113
|
-
|
|
178
|
+
parentSplitStyles,
|
|
114
179
|
languageContext,
|
|
180
|
+
elementType,
|
|
115
181
|
debug
|
|
116
182
|
) => {
|
|
117
183
|
conf = conf || getConfig()
|
|
118
184
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles
|
|
119
185
|
const mediaKeys: string[] = []
|
|
120
|
-
const viewProps:
|
|
186
|
+
const viewProps: SplitStylesAndProps['viewProps'] = {}
|
|
121
187
|
const pseudos: PseudoStyles = {}
|
|
122
188
|
const medias: Record<MediaQueryKey, ViewStyle> = {}
|
|
123
189
|
const mediaState = state.mediaState || globalMediaState
|
|
124
|
-
const usedKeys
|
|
190
|
+
const usedKeys: Record<string, number> = {}
|
|
125
191
|
const propKeys = Object.keys(props)
|
|
192
|
+
|
|
126
193
|
const shouldDoClasses =
|
|
127
194
|
staticConfig.acceptsClassName &&
|
|
128
195
|
(isWeb || process.env.IS_STATIC === 'is_static') &&
|
|
129
|
-
!state.noClassNames
|
|
130
|
-
|
|
196
|
+
!state.noClassNames
|
|
197
|
+
|
|
131
198
|
const len = propKeys.length
|
|
132
199
|
const rulesToInsert: RulesToInsert = []
|
|
133
200
|
const style: ViewStyle = {}
|
|
134
|
-
// TODO make this CSS, not compile-friendly
|
|
135
|
-
if (state.hasTextAncestor) {
|
|
136
|
-
// parity with react-native-web
|
|
137
|
-
style.display = 'inline-flex' as any
|
|
138
|
-
}
|
|
139
201
|
const classNames: ClassNamesObject = {}
|
|
140
202
|
// we need to gather these specific to each media query / pseudo
|
|
141
203
|
// value is [hash, val], so ["-jnjad-asdnjk", "scaleX(1) rotate(10deg)"]
|
|
@@ -154,30 +216,119 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
154
216
|
keyInit = expandedKey
|
|
155
217
|
}
|
|
156
218
|
|
|
157
|
-
if (usedKeys
|
|
219
|
+
if (usedKeys[keyInit]) continue
|
|
158
220
|
if (skipProps[keyInit]) continue
|
|
159
221
|
if (!isWeb && keyInit.startsWith('data-')) continue
|
|
160
222
|
|
|
161
223
|
if (keyInit === 'style' || keyInit.startsWith('_style')) {
|
|
162
224
|
if (!valInit) continue
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
usedKeys.add(key)
|
|
174
|
-
style[key] = valInit
|
|
225
|
+
const styles = Array.isArray(valInit) ? valInit : [valInit]
|
|
226
|
+
const styleLen = styles.length
|
|
227
|
+
for (let j = styleLen; j >= 0; j--) {
|
|
228
|
+
const cur = styles[j]
|
|
229
|
+
if (!cur) continue
|
|
230
|
+
for (const key in cur) {
|
|
231
|
+
if (usedKeys[key]) continue
|
|
232
|
+
usedKeys[key] = 1
|
|
233
|
+
style[key] = cur[key]
|
|
175
234
|
}
|
|
176
235
|
}
|
|
177
236
|
continue
|
|
178
237
|
}
|
|
179
238
|
|
|
180
239
|
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
240
|
+
/**
|
|
241
|
+
* Copying in the accessibility/prop handling from react-native-web here
|
|
242
|
+
* Keeps it in a single loop, avoids dup de-structuring to avoid bundle size
|
|
243
|
+
*/
|
|
244
|
+
if (keyInit === 'disabled' && valInit === true) {
|
|
245
|
+
usedKeys[keyInit] = 1
|
|
246
|
+
viewProps['aria-disabled'] = true
|
|
247
|
+
// Enhance with native semantics
|
|
248
|
+
if (
|
|
249
|
+
elementType === 'button' ||
|
|
250
|
+
elementType === 'form' ||
|
|
251
|
+
elementType === 'input' ||
|
|
252
|
+
elementType === 'select' ||
|
|
253
|
+
elementType === 'textarea'
|
|
254
|
+
) {
|
|
255
|
+
viewProps.disabled = true
|
|
256
|
+
}
|
|
257
|
+
continue
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (accessibilityDirectMap[keyInit]) {
|
|
261
|
+
viewProps[accessibilityDirectMap[keyInit]] = valInit
|
|
262
|
+
usedKeys[keyInit] = 1
|
|
263
|
+
continue
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let didUseKeyInit = true
|
|
267
|
+
switch (keyInit) {
|
|
268
|
+
case 'nativeID': {
|
|
269
|
+
viewProps.id = valInit
|
|
270
|
+
break
|
|
271
|
+
}
|
|
272
|
+
case 'accessibilityRole': {
|
|
273
|
+
if (valInit === 'none') {
|
|
274
|
+
viewProps.role = 'presentation'
|
|
275
|
+
} else {
|
|
276
|
+
viewProps.role = accessibilityRoleToWebRole[valInit] || valInit
|
|
277
|
+
}
|
|
278
|
+
break
|
|
279
|
+
}
|
|
280
|
+
case 'accessibilityControls': {
|
|
281
|
+
viewProps['aria-controls'] = processIDRefList(valInit)
|
|
282
|
+
break
|
|
283
|
+
}
|
|
284
|
+
case 'accessibilityDescribedBy': {
|
|
285
|
+
viewProps['aria-describedby'] = processIDRefList(valInit)
|
|
286
|
+
break
|
|
287
|
+
}
|
|
288
|
+
case 'accessibilityFlowTo': {
|
|
289
|
+
viewProps['aria-flowto'] = processIDRefList(valInit)
|
|
290
|
+
break
|
|
291
|
+
}
|
|
292
|
+
case 'accessibilityLabelledBy': {
|
|
293
|
+
viewProps['aria-labelledby'] = processIDRefList(valInit)
|
|
294
|
+
break
|
|
295
|
+
}
|
|
296
|
+
case 'accessibilityKeyShortcuts': {
|
|
297
|
+
if (Array.isArray(valInit)) {
|
|
298
|
+
viewProps['aria-keyshortcuts'] = valInit.join(' ')
|
|
299
|
+
}
|
|
300
|
+
break
|
|
301
|
+
}
|
|
302
|
+
case 'accessibilityLiveRegion': {
|
|
303
|
+
viewProps['aria-live'] = valInit === 'none' ? 'off' : valInit
|
|
304
|
+
break
|
|
305
|
+
}
|
|
306
|
+
case 'accessibilityReadOnly': {
|
|
307
|
+
viewProps['aria-readonly'] = valInit
|
|
308
|
+
// Enhance with native semantics
|
|
309
|
+
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
|
|
310
|
+
viewProps.readOnly = true
|
|
311
|
+
}
|
|
312
|
+
break
|
|
313
|
+
}
|
|
314
|
+
case 'accessibilityRequired': {
|
|
315
|
+
viewProps['aria-required'] = valInit
|
|
316
|
+
// Enhance with native semantics
|
|
317
|
+
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
|
|
318
|
+
viewProps.required = true
|
|
319
|
+
}
|
|
320
|
+
break
|
|
321
|
+
}
|
|
322
|
+
default: {
|
|
323
|
+
didUseKeyInit = false
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (didUseKeyInit) {
|
|
328
|
+
usedKeys[keyInit] = 1
|
|
329
|
+
continue
|
|
330
|
+
}
|
|
331
|
+
|
|
181
332
|
if (keyInit === 'className') {
|
|
182
333
|
let nonTamaguis = ''
|
|
183
334
|
if (!valInit) continue
|
|
@@ -199,14 +350,14 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
199
350
|
const pseudoShortKey = mediaOrPseudo.slice(1)
|
|
200
351
|
fullKey += `${PROP_SPLIT}${pseudoShortKey}`
|
|
201
352
|
}
|
|
202
|
-
usedKeys
|
|
353
|
+
usedKeys[fullKey] = 1
|
|
203
354
|
mergeClassName(transforms, classNames, fullKey, cn, isMediaOrPseudo)
|
|
204
355
|
} else {
|
|
205
356
|
nonTamaguis += ' ' + cn
|
|
206
357
|
}
|
|
207
358
|
}
|
|
208
359
|
if (nonTamaguis) {
|
|
209
|
-
usedKeys
|
|
360
|
+
usedKeys[keyInit] = 1
|
|
210
361
|
mergeClassName(transforms, classNames, keyInit, nonTamaguis)
|
|
211
362
|
}
|
|
212
363
|
continue
|
|
@@ -221,7 +372,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
221
372
|
keyInit.includes(PROP_SPLIT) &&
|
|
222
373
|
validStyles[keyInit.split(PROP_SPLIT)[0]]
|
|
223
374
|
if (isValidClassName || isMediaOrPseudo) {
|
|
224
|
-
usedKeys
|
|
375
|
+
usedKeys[keyInit] = 1
|
|
225
376
|
mergeClassName(transforms, classNames, keyInit, valInit, isMediaOrPseudo)
|
|
226
377
|
continue
|
|
227
378
|
}
|
|
@@ -246,9 +397,8 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
246
397
|
* for if there's a pseudo/media returned from it.
|
|
247
398
|
*/
|
|
248
399
|
|
|
249
|
-
let isMedia = keyInit
|
|
400
|
+
let isMedia = isMediaKey(keyInit)
|
|
250
401
|
let isPseudo = validPseudoKeys[keyInit]
|
|
251
|
-
let isMediaOrPseudo = isMedia || isPseudo
|
|
252
402
|
|
|
253
403
|
if (
|
|
254
404
|
!isMedia &&
|
|
@@ -257,7 +407,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
257
407
|
!validStyleProps[keyInit] &&
|
|
258
408
|
!conf.shorthands[keyInit]
|
|
259
409
|
) {
|
|
260
|
-
usedKeys
|
|
410
|
+
usedKeys[keyInit] = 1
|
|
261
411
|
viewProps[keyInit] = valInit
|
|
262
412
|
continue
|
|
263
413
|
}
|
|
@@ -286,35 +436,35 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
286
436
|
}
|
|
287
437
|
|
|
288
438
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
439
|
+
if (isClient) {
|
|
440
|
+
// eslint-disable-next-line no-console
|
|
441
|
+
console.log('expanded', expanded)
|
|
442
|
+
// eslint-disable-next-line no-console
|
|
443
|
+
console.log('usedKeys', usedKeys)
|
|
444
|
+
}
|
|
293
445
|
// eslint-disable-next-line no-console
|
|
294
446
|
console.groupEnd()
|
|
295
447
|
}
|
|
296
448
|
|
|
297
|
-
if (!expanded)
|
|
298
|
-
continue
|
|
299
|
-
}
|
|
449
|
+
if (!expanded) continue
|
|
300
450
|
|
|
301
451
|
for (const [key, val] of expanded) {
|
|
302
452
|
if (val === undefined) continue
|
|
303
453
|
|
|
304
|
-
isMedia = key
|
|
454
|
+
isMedia = isMediaKey(key)
|
|
305
455
|
isPseudo = validPseudoKeys[key]
|
|
306
|
-
isMediaOrPseudo = isMedia || isPseudo
|
|
456
|
+
const isMediaOrPseudo = isMedia || isPseudo
|
|
307
457
|
|
|
308
|
-
if (!isMediaOrPseudo) {
|
|
309
|
-
|
|
458
|
+
if (!isMediaOrPseudo && usedKeys[key]) {
|
|
459
|
+
continue
|
|
310
460
|
}
|
|
311
461
|
|
|
312
462
|
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
463
|
+
staticConfig.deoptProps?.has(key) ||
|
|
464
|
+
staticConfig.inlineProps?.has(key) ||
|
|
465
|
+
staticConfig.inlineWhenUnflattened?.has(key)
|
|
316
466
|
) {
|
|
317
|
-
usedKeys
|
|
467
|
+
usedKeys[key] = 1
|
|
318
468
|
viewProps[key] = props[key] ?? val
|
|
319
469
|
}
|
|
320
470
|
|
|
@@ -325,7 +475,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
325
475
|
// once mounted we can ignore enterStyle
|
|
326
476
|
continue
|
|
327
477
|
}
|
|
328
|
-
pseudos[key]
|
|
478
|
+
pseudos[key] ??= {}
|
|
329
479
|
const pseudoStyleObject = getSubStyle(
|
|
330
480
|
key,
|
|
331
481
|
val,
|
|
@@ -343,17 +493,23 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
343
493
|
...pseudos[key],
|
|
344
494
|
}
|
|
345
495
|
|
|
346
|
-
if (
|
|
496
|
+
if (key === 'enterStyle' || key === 'exitStyle') {
|
|
497
|
+
continue
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (shouldDoClasses) {
|
|
347
501
|
const pseudoStyles = getAtomicStyle(pseudoStyleObject, pseudoDescriptors[key])
|
|
348
502
|
for (const style of pseudoStyles) {
|
|
349
503
|
const postfix = pseudoDescriptors[key]?.name || key // exitStyle/enterStyle dont have pseudoDescriptors
|
|
350
504
|
const fullKey = `${style.property}${PROP_SPLIT}${postfix}`
|
|
351
|
-
if (!usedKeys
|
|
352
|
-
usedKeys
|
|
505
|
+
if (!usedKeys[fullKey]) {
|
|
506
|
+
usedKeys[fullKey] = 1
|
|
353
507
|
addStyleToInsertRules(rulesToInsert, style)
|
|
354
508
|
mergeClassName(transforms, classNames, fullKey, style.identifier, isMediaOrPseudo)
|
|
355
509
|
}
|
|
356
510
|
}
|
|
511
|
+
} else {
|
|
512
|
+
// need same treatment as media (individual merge + importance) + can avoid calling getSubStyle entirely when state = off
|
|
357
513
|
}
|
|
358
514
|
continue
|
|
359
515
|
}
|
|
@@ -362,29 +518,11 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
362
518
|
if (isMedia) {
|
|
363
519
|
const mediaKey = key
|
|
364
520
|
const mediaKeyShort = mediaKey.slice(1)
|
|
365
|
-
|
|
366
521
|
mediaKeys.push(mediaKeyShort)
|
|
367
522
|
|
|
368
|
-
if (!mediaQueryConfig[mediaKeyShort]) {
|
|
369
|
-
if (process.env.NODE_ENV === 'development' && debug) {
|
|
370
|
-
// eslint-disable-next-line no-console
|
|
371
|
-
console.warn(
|
|
372
|
-
`Warning: using a $ prefixed prop that doesn't match to a media query, may be an error`,
|
|
373
|
-
key
|
|
374
|
-
)
|
|
375
|
-
}
|
|
376
|
-
if (!usedKeys.has(key)) {
|
|
377
|
-
// this isn't a media key, pass through
|
|
378
|
-
viewProps[key] = val
|
|
379
|
-
}
|
|
380
|
-
continue
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// dont check if media is active, we just apply *all* media styles
|
|
384
|
-
// we combine the media props on top regular props, could proxy this
|
|
385
|
-
// TODO test proxy here instead of merge
|
|
386
523
|
// THIS USED TO PROXY BACK TO REGULAR PROPS BUT THAT IS THE WRONG BEHAVIOR
|
|
387
524
|
// we avoid passing in default props for media queries because that would confuse things like SizableText.size:
|
|
525
|
+
|
|
388
526
|
const mediaStyle = getSubStyle(
|
|
389
527
|
key,
|
|
390
528
|
val,
|
|
@@ -407,29 +545,17 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
407
545
|
for (const style of mediaStyles) {
|
|
408
546
|
const out = createMediaStyle(style, mediaKeyShort, mediaQueryConfig)
|
|
409
547
|
const fullKey = `${style.property}${PROP_SPLIT}${mediaKeyShort}`
|
|
410
|
-
if (!usedKeys
|
|
411
|
-
usedKeys
|
|
548
|
+
if (!usedKeys[fullKey]) {
|
|
549
|
+
usedKeys[fullKey] = 1
|
|
412
550
|
addStyleToInsertRules(rulesToInsert, out)
|
|
413
551
|
mergeClassName(transforms, classNames, fullKey, out.identifier, true)
|
|
414
552
|
}
|
|
415
553
|
}
|
|
416
|
-
} else {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
if (shouldDoClasses) {
|
|
423
|
-
Object.assign(medias, mediaStyle)
|
|
424
|
-
} else {
|
|
425
|
-
for (const key in mediaStyle) {
|
|
426
|
-
// TODO we should likely account for importance here to match CSS, right??
|
|
427
|
-
usedKeys.add(key)
|
|
428
|
-
style[key] = mediaStyle[key]
|
|
429
|
-
if (key === 'fontFamily') {
|
|
430
|
-
fontFamily = mediaStyle[key]
|
|
431
|
-
}
|
|
432
|
-
}
|
|
554
|
+
} else if (mediaState[mediaKeyShort]) {
|
|
555
|
+
for (const key in mediaStyle) {
|
|
556
|
+
const didMerge = mergeMediaByImportance(style, key, mediaStyle[key], usedKeys)
|
|
557
|
+
if (didMerge && key === 'fontFamily') {
|
|
558
|
+
fontFamily = mediaStyle[key]
|
|
433
559
|
}
|
|
434
560
|
}
|
|
435
561
|
}
|
|
@@ -437,7 +563,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
437
563
|
}
|
|
438
564
|
|
|
439
565
|
if (!isWeb && key === 'pointerEvents') {
|
|
440
|
-
usedKeys
|
|
566
|
+
usedKeys[key] = 1
|
|
441
567
|
viewProps[key] = val
|
|
442
568
|
continue
|
|
443
569
|
}
|
|
@@ -447,7 +573,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
447
573
|
}
|
|
448
574
|
|
|
449
575
|
if (validStyleProps[key]) {
|
|
450
|
-
usedKeys
|
|
576
|
+
usedKeys[key] = 1
|
|
451
577
|
if (val && val[0] === '_') {
|
|
452
578
|
classNames[key] = val
|
|
453
579
|
} else if (key in stylePropsTransform) {
|
|
@@ -462,7 +588,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
462
588
|
if (!staticConfig.variants || !(key in staticConfig.variants)) {
|
|
463
589
|
if (!skipProps[key]) {
|
|
464
590
|
viewProps[key] = val
|
|
465
|
-
usedKeys
|
|
591
|
+
usedKeys[key] = 1
|
|
466
592
|
}
|
|
467
593
|
}
|
|
468
594
|
}
|
|
@@ -474,10 +600,23 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
474
600
|
}
|
|
475
601
|
|
|
476
602
|
// add in defaults if not set:
|
|
477
|
-
if (
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
603
|
+
if (parentSplitStyles) {
|
|
604
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
605
|
+
for (const key in parentSplitStyles.classNames) {
|
|
606
|
+
if (key in classNames) continue
|
|
607
|
+
if (key in style) continue
|
|
608
|
+
const val = parentSplitStyles.classNames[key]
|
|
609
|
+
if (!shouldDoClasses) {
|
|
610
|
+
style[key] = reverseMapClassNameToValue(key, val)
|
|
611
|
+
} else {
|
|
612
|
+
classNames[key] = val
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (!shouldDoClasses) {
|
|
617
|
+
for (const key in parentSplitStyles.style) {
|
|
618
|
+
if (key in style) continue
|
|
619
|
+
style[key] = parentSplitStyles.style[key]
|
|
481
620
|
}
|
|
482
621
|
}
|
|
483
622
|
}
|
|
@@ -491,44 +630,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
491
630
|
mergeClassName(transforms, classNames, key, atomicStyle.identifier)
|
|
492
631
|
}
|
|
493
632
|
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// else {
|
|
497
|
-
// if (classNames && state.resolveVariablesAs === 'value') {
|
|
498
|
-
// getting real values for colors for animations (reverse mapped from CSS)
|
|
499
|
-
// this isn't beautiful, but will do relatively fine performance for now
|
|
500
|
-
// has a bug still - try adding <Switch theme="bouncy" /> should animate bg color on active
|
|
501
|
-
// const selectors = getAllSelectors()
|
|
502
|
-
// for (const key in classNames) {
|
|
503
|
-
// if (key.endsWith('Color')) {
|
|
504
|
-
// const selector = classNames[key]
|
|
505
|
-
// let value = selectorValuesCache[selector]
|
|
506
|
-
// if (!value) {
|
|
507
|
-
// const css = selectors[selector]
|
|
508
|
-
// value = css.replace(/.*:/, '').replace(/;.*/, '')
|
|
509
|
-
// if (value) {
|
|
510
|
-
// const themeUnwrapped = getThemeUnwrapped(theme)
|
|
511
|
-
// const map = themeToVariableToValueMap.get(themeUnwrapped)
|
|
512
|
-
// if (map && value.startsWith('var(')) {
|
|
513
|
-
// value = map[value]
|
|
514
|
-
// }
|
|
515
|
-
// if (value) {
|
|
516
|
-
// selectorValuesCache[selector] = value
|
|
517
|
-
// }
|
|
518
|
-
// } else {
|
|
519
|
-
// // err
|
|
520
|
-
// continue
|
|
521
|
-
// }
|
|
522
|
-
// }
|
|
523
|
-
// if (value) {
|
|
524
|
-
// style[key] = value
|
|
525
|
-
// }
|
|
526
|
-
// }
|
|
527
|
-
// }
|
|
528
|
-
// }
|
|
529
|
-
// }
|
|
530
633
|
|
|
531
|
-
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
532
634
|
if (transforms) {
|
|
533
635
|
for (const namespace in transforms) {
|
|
534
636
|
if (!transforms[namespace]) {
|
|
@@ -736,3 +838,7 @@ function addStyleToInsertRules(rulesToInsert: RulesToInsert, styleObject: Partia
|
|
|
736
838
|
rulesToInsert.push(styleObject)
|
|
737
839
|
}
|
|
738
840
|
}
|
|
841
|
+
|
|
842
|
+
function processIDRefList(idRefList: string | Array<string>): string {
|
|
843
|
+
return Array.isArray(idRefList) ? idRefList.join(' ') : idRefList
|
|
844
|
+
}
|