@tamagui/web 1.101.0 → 1.101.2

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.
Files changed (143) hide show
  1. package/dist/cjs/createComponent.js +23 -15
  2. package/dist/cjs/createComponent.js.map +1 -1
  3. package/dist/cjs/createComponent.native.js +13 -10
  4. package/dist/cjs/createComponent.native.js.map +2 -2
  5. package/dist/cjs/createTokens.js.map +1 -1
  6. package/dist/cjs/createTokens.native.js.map +1 -1
  7. package/dist/cjs/helpers/createMediaStyle.js +2 -6
  8. package/dist/cjs/helpers/createMediaStyle.js.map +1 -1
  9. package/dist/cjs/helpers/createMediaStyle.native.js +51 -7
  10. package/dist/cjs/helpers/createMediaStyle.native.js.map +2 -2
  11. package/dist/cjs/helpers/expandStyles.js.map +1 -1
  12. package/dist/cjs/helpers/expandStyles.native.js.map +1 -1
  13. package/dist/cjs/helpers/getSplitStyles.js +77 -60
  14. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  15. package/dist/cjs/helpers/getSplitStyles.native.js +55 -42
  16. package/dist/cjs/helpers/getSplitStyles.native.js.map +2 -2
  17. package/dist/cjs/helpers/getStylesAtomic.js +7 -6
  18. package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
  19. package/dist/cjs/helpers/insertStyleRule.js +17 -14
  20. package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
  21. package/dist/cjs/helpers/insertStyleRule.native.js +4 -3
  22. package/dist/cjs/helpers/insertStyleRule.native.js.map +2 -2
  23. package/dist/cjs/helpers/propMapper.js +1 -1
  24. package/dist/cjs/helpers/propMapper.js.map +1 -1
  25. package/dist/cjs/helpers/propMapper.native.js +1 -1
  26. package/dist/cjs/helpers/propMapper.native.js.map +2 -2
  27. package/dist/cjs/hooks/useDidHydrateOnce.js +4 -10
  28. package/dist/cjs/hooks/useDidHydrateOnce.js.map +1 -1
  29. package/dist/cjs/hooks/useDidHydrateOnce.native.js +11 -1
  30. package/dist/cjs/hooks/useDidHydrateOnce.native.js.map +2 -2
  31. package/dist/cjs/hooks/useMedia.js +39 -27
  32. package/dist/cjs/hooks/useMedia.js.map +2 -2
  33. package/dist/cjs/hooks/useMedia.native.js +38 -44
  34. package/dist/cjs/hooks/useMedia.native.js.map +2 -2
  35. package/dist/cjs/views/TamaguiProvider.js.map +1 -1
  36. package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
  37. package/dist/esm/createComponent.js +29 -16
  38. package/dist/esm/createComponent.js.map +1 -1
  39. package/dist/esm/createComponent.mjs +18 -16
  40. package/dist/esm/createComponent.native.js +14 -11
  41. package/dist/esm/createComponent.native.js.map +2 -2
  42. package/dist/esm/createTokens.js.map +1 -1
  43. package/dist/esm/createTokens.native.js.map +1 -1
  44. package/dist/esm/helpers/createMediaStyle.js +2 -6
  45. package/dist/esm/helpers/createMediaStyle.js.map +1 -1
  46. package/dist/esm/helpers/createMediaStyle.mjs +2 -10
  47. package/dist/esm/helpers/createMediaStyle.native.js +49 -6
  48. package/dist/esm/helpers/createMediaStyle.native.js.map +2 -2
  49. package/dist/esm/helpers/expandStyles.js.map +1 -1
  50. package/dist/esm/helpers/expandStyles.native.js.map +1 -1
  51. package/dist/esm/helpers/getSplitStyles.js +81 -60
  52. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  53. package/dist/esm/helpers/getSplitStyles.mjs +83 -64
  54. package/dist/esm/helpers/getSplitStyles.native.js +56 -43
  55. package/dist/esm/helpers/getSplitStyles.native.js.map +2 -2
  56. package/dist/esm/helpers/getStylesAtomic.js +7 -6
  57. package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
  58. package/dist/esm/helpers/getStylesAtomic.mjs +3 -7
  59. package/dist/esm/helpers/insertStyleRule.js +17 -13
  60. package/dist/esm/helpers/insertStyleRule.js.map +1 -1
  61. package/dist/esm/helpers/insertStyleRule.mjs +6 -5
  62. package/dist/esm/helpers/insertStyleRule.native.js +4 -2
  63. package/dist/esm/helpers/insertStyleRule.native.js.map +2 -2
  64. package/dist/esm/helpers/propMapper.js +1 -1
  65. package/dist/esm/helpers/propMapper.js.map +1 -1
  66. package/dist/esm/helpers/propMapper.mjs +1 -2
  67. package/dist/esm/helpers/propMapper.native.js +1 -1
  68. package/dist/esm/helpers/propMapper.native.js.map +2 -2
  69. package/dist/esm/hooks/useDidHydrateOnce.js +5 -11
  70. package/dist/esm/hooks/useDidHydrateOnce.js.map +1 -1
  71. package/dist/esm/hooks/useDidHydrateOnce.mjs +7 -11
  72. package/dist/esm/hooks/useDidHydrateOnce.native.js +11 -2
  73. package/dist/esm/hooks/useDidHydrateOnce.native.js.map +2 -2
  74. package/dist/esm/hooks/useMedia.js +39 -28
  75. package/dist/esm/hooks/useMedia.js.map +2 -2
  76. package/dist/esm/hooks/useMedia.mjs +34 -33
  77. package/dist/esm/hooks/useMedia.native.js +38 -45
  78. package/dist/esm/hooks/useMedia.native.js.map +2 -2
  79. package/dist/esm/views/TamaguiProvider.js.map +1 -1
  80. package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
  81. package/package.json +12 -12
  82. package/src/createComponent.tsx +38 -21
  83. package/src/createTokens.ts +1 -21
  84. package/src/helpers/createMediaStyle.ts +2 -6
  85. package/src/helpers/expandStyles.ts +2 -1
  86. package/src/helpers/getSplitStyles.tsx +116 -88
  87. package/src/helpers/getStylesAtomic.ts +7 -5
  88. package/src/helpers/insertStyleRule.tsx +6 -3
  89. package/src/helpers/propMapper.ts +1 -2
  90. package/src/hooks/useDidHydrateOnce.tsx +30 -25
  91. package/src/hooks/useMedia.tsx +74 -54
  92. package/src/types.tsx +12 -2
  93. package/src/views/TamaguiProvider.tsx +0 -1
  94. package/types/_withStableStyle.d.ts +0 -1
  95. package/types/_withStableStyle.d.ts.map +1 -1
  96. package/types/config.d.ts +1 -1
  97. package/types/constants/accessibilityDirectMap.d.ts.map +1 -1
  98. package/types/constants/webToNativeProps.native.d.ts.map +1 -1
  99. package/types/createComponent.d.ts.map +1 -1
  100. package/types/createFont.d.ts.map +1 -1
  101. package/types/createTheme.d.ts.map +1 -1
  102. package/types/createTokens.d.ts +1 -1
  103. package/types/createTokens.d.ts.map +1 -1
  104. package/types/createVariable.d.ts +1 -1
  105. package/types/createVariable.d.ts.map +1 -1
  106. package/types/createVariables.d.ts +1 -1
  107. package/types/createVariables.d.ts.map +1 -1
  108. package/types/helpers/ThemeManagerContext.d.ts +0 -1
  109. package/types/helpers/ThemeManagerContext.d.ts.map +1 -1
  110. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  111. package/types/helpers/createShallowSetState.d.ts.map +1 -1
  112. package/types/helpers/expandStyles.d.ts.map +1 -1
  113. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  114. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  115. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  116. package/types/helpers/isTamaguiElement.d.ts +1 -2
  117. package/types/helpers/isTamaguiElement.d.ts.map +1 -1
  118. package/types/helpers/propMapper.d.ts.map +1 -1
  119. package/types/helpers/setElementProps.d.ts.map +1 -1
  120. package/types/helpers/themeable.d.ts.map +1 -1
  121. package/types/hooks/useConfiguration.d.ts +50 -52
  122. package/types/hooks/useConfiguration.d.ts.map +1 -1
  123. package/types/hooks/useDidHydrateOnce.d.ts +1 -1
  124. package/types/hooks/useDidHydrateOnce.d.ts.map +1 -1
  125. package/types/hooks/useMedia.d.ts +6 -7
  126. package/types/hooks/useMedia.d.ts.map +1 -1
  127. package/types/hooks/useTheme.d.ts.map +1 -1
  128. package/types/styled.d.ts.map +1 -1
  129. package/types/types.d.ts +3 -2
  130. package/types/types.d.ts.map +1 -1
  131. package/types/views/Configuration.d.ts +0 -1
  132. package/types/views/Configuration.d.ts.map +1 -1
  133. package/types/views/TamaguiProvider.d.ts.map +1 -1
  134. package/dist/esm/constants/accessibilityDirectMap.native.mjs +0 -6
  135. package/dist/esm/constants/webToNativeProps.native.mjs +0 -77
  136. package/dist/esm/helpers/getStylesAtomic.native.mjs +0 -7
  137. package/dist/esm/helpers/getThemeCSSRules.native.mjs +0 -4
  138. package/dist/esm/helpers/matchMedia.native.mjs +0 -14
  139. package/dist/esm/helpers/normalizeStylePropKeys.native.mjs +0 -13
  140. package/dist/esm/helpers/setElementProps.native.mjs +0 -6
  141. package/dist/esm/helpers/webPropsToSkip.native.mjs +0 -55
  142. package/dist/esm/views/FontLanguage.native.mjs +0 -15
  143. package/dist/esm/views/ThemeDebug.native.mjs +0 -9
@@ -1,6 +1,11 @@
1
1
  import { composeRefs } from '@tamagui/compose-refs'
2
2
  import { isClient, isServer, isWeb } from '@tamagui/constants'
3
- import { composeEventHandlers, validStyles } from '@tamagui/helpers'
3
+ import {
4
+ StyleObjectIdentifier,
5
+ StyleObjectRules,
6
+ composeEventHandlers,
7
+ validStyles,
8
+ } from '@tamagui/helpers'
4
9
  import React, {
5
10
  Children,
6
11
  Fragment,
@@ -10,7 +15,6 @@ import React, {
10
15
  useContext,
11
16
  useEffect,
12
17
  useId,
13
- useLayoutEffect,
14
18
  useMemo,
15
19
  useRef,
16
20
  useState,
@@ -36,6 +40,7 @@ import { log } from './helpers/log'
36
40
  import { mergeProps } from './helpers/mergeProps'
37
41
  import { setElementProps } from './helpers/setElementProps'
38
42
  import { themeable } from './helpers/themeable'
43
+ import { useDidHydrateOnce } from './hooks/useDidHydrateOnce'
39
44
  import { mediaKeyMatch, setMediaShouldUpdate, useMedia } from './hooks/useMedia'
40
45
  import { useThemeWithState } from './hooks/useTheme'
41
46
  import type { TamaguiComponentEvents } from './interfaces/TamaguiComponentEvents'
@@ -69,7 +74,6 @@ import type {
69
74
  import { Slot } from './views/Slot'
70
75
  import { getThemedChildren } from './views/Theme'
71
76
  import { ThemeDebug } from './views/ThemeDebug'
72
- import { useDidHydrateOnce } from './hooks/useDidHydrateOnce'
73
77
 
74
78
  /**
75
79
  * All things that need one-time setup after createTamagui is called
@@ -156,7 +160,12 @@ export const useComponentState = (
156
160
  ) => {
157
161
  const useAnimations = animationDriver?.useAnimations as UseAnimationHook | undefined
158
162
 
159
- const stateRef = useRef<TamaguiComponentStateRef>({})
163
+ const stateRef = useRef<TamaguiComponentStateRef>(
164
+ undefined as any as TamaguiComponentStateRef
165
+ )
166
+ if (!stateRef.current) {
167
+ stateRef.current = {}
168
+ }
160
169
 
161
170
  // after we get states mount we need to turn off isAnimated for server side
162
171
  const hasAnimationProp = Boolean(
@@ -197,19 +206,21 @@ export const useComponentState = (
197
206
 
198
207
  const hasEnterState = hasEnterStyle || isEntering
199
208
 
200
- const didHydrateOnce = useDidHydrateOnce()
201
-
202
- const initialState =
203
- hasEnterState || (!didHydrateOnce && hasRNAnimation)
204
- ? // on the very first render we switch all spring animation drivers to css rendering
205
- // this is because we need to use css variables, which they don't support to do proper SSR
206
- // without flickers of the wrong colors.
207
- // but once we do that initial hydration and we are in client side rendering mode,
208
- // we can avoid the extra re-render on mount
209
- isWeb && !didHydrateOnce
210
- ? defaultComponentState
211
- : defaultComponentStateShouldEnter
212
- : defaultComponentStateMounted
209
+ // this can be conditional because its only ever needed with animations
210
+ const didHydrateOnce = willBeAnimated ? useDidHydrateOnce() : true
211
+ const shouldEnter = hasEnterState || (!didHydrateOnce && hasRNAnimation)
212
+ const shouldEnterFromUnhydrated = isWeb && !didHydrateOnce
213
+
214
+ const initialState = shouldEnter
215
+ ? // on the very first render we switch all spring animation drivers to css rendering
216
+ // this is because we need to use css variables, which they don't support to do proper SSR
217
+ // without flickers of the wrong colors.
218
+ // but once we do that initial hydration and we are in client side rendering mode,
219
+ // we can avoid the extra re-render on mount
220
+ shouldEnterFromUnhydrated
221
+ ? defaultComponentState
222
+ : defaultComponentStateShouldEnter
223
+ : defaultComponentStateMounted
213
224
 
214
225
  // will be nice to deprecate half of these:
215
226
  const disabled = isDisabled(props)
@@ -706,7 +717,7 @@ export function createComponent<
706
717
  if (process.env.NODE_ENV === 'development' && time) time`theme`
707
718
 
708
719
  // HOOK 14 (-1 if no animation, -1 if disableSSR, -1 if no context, -1 if production)
709
- const mediaState = useMedia(stateRef, componentContext)
720
+ const mediaState = useMedia(stateRef, componentContext, debugProp)
710
721
 
711
722
  setDidGetVariableValue(false)
712
723
 
@@ -725,6 +736,7 @@ export function createComponent<
725
736
  resolveValues,
726
737
  isExiting,
727
738
  isAnimated,
739
+ willBeAnimated,
728
740
  } as const
729
741
 
730
742
  // HOOK 15 (-1 if no animation, -1 if disableSSR, -1 if no context, -1 if production)
@@ -758,7 +770,11 @@ export function createComponent<
758
770
  didGetVariableValue() ||
759
771
  isMediaArray ||
760
772
  (noClassNames && splitStyles.hasMedia === true)
761
- const mediaListeningKeys = isMediaArray ? (splitStyles.hasMedia as any) : null
773
+
774
+ const mediaListeningKeys = isMediaArray ? (splitStyles.hasMedia as string[]) : null
775
+ if (process.env.NODE_ENV === 'development' && debugProp) {
776
+ console.info(`useMedia() createComponent`, shouldListenForMedia, mediaListeningKeys)
777
+ }
762
778
 
763
779
  setMediaShouldUpdate(stateRef, {
764
780
  enabled: shouldListenForMedia,
@@ -1296,7 +1312,8 @@ export function createComponent<
1296
1312
  <>
1297
1313
  {content}
1298
1314
  {/* lets see if we can put a single style tag per rule for optimal de-duping */}
1299
- {splitStyles.rulesToInsert.map(({ rules, identifier }) => {
1315
+ {splitStyles.rulesToInsert.map((styleObject) => {
1316
+ const identifier = styleObject[StyleObjectIdentifier]
1300
1317
  return (
1301
1318
  <style
1302
1319
  key={identifier}
@@ -1305,7 +1322,7 @@ export function createComponent<
1305
1322
  // @ts-ignore
1306
1323
  precedence="default"
1307
1324
  >
1308
- {rules.join('\n')}
1325
+ {styleObject[StyleObjectRules].join('\n')}
1309
1326
  </style>
1310
1327
  )
1311
1328
  })}
@@ -2,20 +2,14 @@ import type { Variable } from './createVariable'
2
2
  import { createVariables } from './createVariables'
3
3
  import type { CreateTokens } from './types'
4
4
 
5
- // tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }
6
5
  export function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {
7
6
  return createVariables(tokens) as any
8
7
  }
9
8
 
10
9
  type NormalizeTokens<A, Type = A[keyof A]> = {
11
- // removes $ prefix allowing for defining either as $1: or 1:,
12
- // which is important because Chrome re-orders numerical-seeming keys :/
13
- [Key in keyof A extends `$${infer X}` ? X : keyof A]: Variable<Type>
10
+ [Key in keyof A extends number ? `${keyof A}` : keyof A]: Variable<Type>
14
11
  }
15
12
 
16
- // verbose but gives us nice types...
17
- // removes $ prefix allowing for defining either as $1: or 1:,
18
- // which is important because Chrome re-orders numerical-seeming keys :/
19
13
  type MakeTokens<T extends CreateTokens> = T extends {
20
14
  color?: infer E
21
15
  space?: infer F
@@ -36,17 +30,3 @@ type MakeTokens<T extends CreateTokens> = T extends {
36
30
  'color' | 'space' | 'size' | 'radius' | 'zIndex'
37
31
  >
38
32
  : never
39
-
40
- // // test
41
- // // TODO move to tests
42
- // const tokens = createTokens({
43
- // size: { 0: 1 },
44
- // space: { 0: 1 },
45
- // radius: { 0: 1 },
46
- // zIndex: { 0: 1 },
47
- // color: { 0: 'hi' },
48
- // arbitrary: { abc: '123' },
49
- // })
50
-
51
- // tokens.arbitrary.abc
52
- // tokens.size['0']
@@ -22,7 +22,7 @@ export const createMediaStyle = (
22
22
  negate?: boolean,
23
23
  priority?: number
24
24
  ): MediaStyleObject => {
25
- const { property, identifier, rules } = styleObject
25
+ const [property, _value, identifier, _pseudo, rules] = styleObject
26
26
  const conf = getConfig()
27
27
  const enableMediaPropOrder = conf.settings.mediaPropOrder
28
28
  const isTheme = type === 'theme'
@@ -129,9 +129,5 @@ export const createMediaStyle = (
129
129
  }
130
130
  }
131
131
 
132
- return {
133
- property,
134
- rules: [styleRule],
135
- identifier: nextIdentifier,
136
- }
132
+ return [property, undefined, nextIdentifier, undefined, [styleRule]]
137
133
  }
@@ -12,6 +12,7 @@ export function fixStyles(style: Record<string, any>) {
12
12
  }
13
13
  }
14
14
 
15
+ // TODO deprecate for web-style shadows
15
16
  if (
16
17
  style.shadowRadius != null ||
17
18
  style.shadowColor ||
@@ -21,7 +22,7 @@ export function fixStyles(style: Record<string, any>) {
21
22
  Object.assign(style, normalizeShadow(style))
22
23
  }
23
24
 
24
- // TODO could be native-only
25
+ // could be optimized better
25
26
  // ensure border style set by default to solid
26
27
  for (const key in borderDefaults) {
27
28
  if (key in style) {
@@ -7,6 +7,10 @@ import {
7
7
  useIsomorphicLayoutEffect,
8
8
  } from '@tamagui/constants'
9
9
  import {
10
+ StyleObjectIdentifier,
11
+ StyleObjectProperty,
12
+ StyleObjectPseudo,
13
+ StyleObjectRules,
10
14
  stylePropsText,
11
15
  stylePropsTransform,
12
16
  tokenCategories,
@@ -68,9 +72,6 @@ import { pseudoDescriptors, pseudoPriorities } from './pseudoDescriptors'
68
72
  import { skipProps } from './skipProps'
69
73
  import { transformsToString } from './transformsToString'
70
74
 
71
- // bugfix for some reason it gets reset
72
- const IS_STATIC = process.env.IS_STATIC === 'is_static'
73
-
74
75
  export type SplitStyles = ReturnType<typeof getSplitStyles>
75
76
 
76
77
  export type SplitStyleResult = ReturnType<typeof getSplitStyles>
@@ -185,8 +186,17 @@ export const getSplitStyles: StyleSplitter = (
185
186
  /**
186
187
  * Not the biggest fan of creating an object but it is a nice API
187
188
  */
189
+ let curPropsState
188
190
  const styleState: GetStyleState = {
189
- curProps: {},
191
+ // this should go away, right now we're doing really crazy cumulative props,
192
+ // as variants are resolved basically we go back and merge the results onto
193
+ // the curProps, so that each following variant function recieves the current
194
+ // "styles" with variants expanded. powerful, but i think too fancy
195
+ // there's some part of the ui kit that depends on it we'd have to find and fix
196
+ get curProps() {
197
+ curPropsState ||= {}
198
+ return curPropsState
199
+ },
190
200
  classNames,
191
201
  conf,
192
202
  props,
@@ -221,24 +231,32 @@ export const getSplitStyles: StyleSplitter = (
221
231
  console.groupEnd()
222
232
  }
223
233
 
234
+ const { asChild } = props
235
+ const { accept } = staticConfig
236
+ const { noSkip, disableExpandShorthands, noExpand } = styleProps
237
+ const { webContainerType } = conf.settings
238
+ const parentVariants = parentStaticConfig?.variants
239
+
224
240
  for (const keyOg in props) {
225
241
  let keyInit = keyOg
226
- let valInit = props[keyOg]
242
+ let valInit = props[keyInit]
227
243
 
228
- if (
229
- staticConfig.accept &&
230
- (staticConfig.accept[keyInit] === 'style' ||
231
- staticConfig.accept[keyInit] === 'textStyle') &&
232
- typeof valInit === 'object'
233
- ) {
234
- const styleObject = getSubStyle(
235
- styleState,
236
- keyInit,
237
- valInit,
238
- styleProps.noClassNames
239
- )
240
- viewProps[keyInit] = styleObject
241
- continue
244
+ // for custom accept sub-styles
245
+ if (accept) {
246
+ const accepted = accept[keyInit]
247
+ if (
248
+ (accepted === 'style' || accepted === 'textStyle') &&
249
+ valInit &&
250
+ typeof valInit === 'object'
251
+ ) {
252
+ viewProps[keyInit] = getSubStyle(
253
+ styleState,
254
+ keyInit,
255
+ valInit,
256
+ styleProps.noClassNames
257
+ )
258
+ continue
259
+ }
242
260
  }
243
261
 
244
262
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
@@ -248,7 +266,7 @@ export const getSplitStyles: StyleSplitter = (
248
266
  }
249
267
 
250
268
  // normalize shorthands up front
251
- if (!styleProps.disableExpandShorthands) {
269
+ if (!disableExpandShorthands) {
252
270
  if (keyInit in shorthands) {
253
271
  keyInit = shorthands[keyInit]
254
272
  }
@@ -259,25 +277,27 @@ export const getSplitStyles: StyleSplitter = (
259
277
 
260
278
  if (process.env.TAMAGUI_TARGET === 'web') {
261
279
  // skip the webViewFlexCompatStyles when asChild on web
262
- if (props.asChild && webViewFlexCompatStyles[keyInit] === valInit) {
280
+ if (asChild && webViewFlexCompatStyles[keyInit] === valInit) {
263
281
  continue
264
282
  }
265
283
  }
266
284
 
267
285
  // keyInit === 'style' is handled in skipProps
268
- if (keyInit in skipProps && !styleProps.noSkip && !isHOC) {
286
+ if (keyInit in skipProps && !noSkip && !isHOC) {
269
287
  if (keyInit === 'group') {
270
288
  if (process.env.TAMAGUI_TARGET === 'web') {
271
289
  // add container style
272
290
  const identifier = `t_group_${valInit}`
273
- const containerType = conf.settings.webContainerType || 'inline-size'
274
- const containerCSS = {
291
+ const containerType = webContainerType || 'inline-size'
292
+ const containerCSS = [
293
+ 'continer',
294
+ undefined,
275
295
  identifier,
276
- property: 'container',
277
- rules: [
296
+ undefined,
297
+ [
278
298
  `.${identifier} { container-name: ${valInit}; container-type: ${containerType}; }`,
279
299
  ],
280
- }
300
+ ] satisfies StyleObject
281
301
  addStyleToInsertRules(rulesToInsert, containerCSS)
282
302
  }
283
303
  }
@@ -287,6 +307,7 @@ export const getSplitStyles: StyleSplitter = (
287
307
  const valInitType = typeof valInit
288
308
  const isValidStyleKeyInit = isValidStyleKey(keyInit, staticConfig)
289
309
 
310
+ // this is all for partially optimized (not flattened)... maybe worth removing?
290
311
  if (process.env.TAMAGUI_TARGET === 'web') {
291
312
  if (isValidStyleKeyInit && valInitType === 'string') {
292
313
  if (valInit[0] === '_') {
@@ -315,12 +336,12 @@ export const getSplitStyles: StyleSplitter = (
315
336
  }
316
337
  }
317
338
 
318
- if (valInit !== props[keyInit]) {
319
- // we collect updated props as we go, for functional variants later
320
- // functional variants receive a prop object that represents the current
321
- // props at that point in the loop
322
- styleState.curProps[keyInit] = valInit
323
- }
339
+ // if (valInit !== props[keyInit]) {
340
+ // // we collect updated props as we go, for functional variants later
341
+ // // functional variants receive a prop object that represents the current
342
+ // // props at that point in the loop
343
+ // styleState.curProps[keyInit] = valInit
344
+ // }
324
345
 
325
346
  if (process.env.TAMAGUI_TARGET === 'native') {
326
347
  if (!isValidStyleKeyInit) {
@@ -339,6 +360,7 @@ export const getSplitStyles: StyleSplitter = (
339
360
  }
340
361
  }
341
362
 
363
+ // TODO deprecate dataSet be sure we map on native from data-
342
364
  if (keyInit === 'dataSet') {
343
365
  for (const keyInit in valInit) {
344
366
  viewProps[`data-${hyphenate(keyInit)}`] = valInit[keyInit]
@@ -347,7 +369,7 @@ export const getSplitStyles: StyleSplitter = (
347
369
  }
348
370
 
349
371
  if (process.env.TAMAGUI_TARGET === 'web') {
350
- if (!styleProps.noExpand) {
372
+ if (!noExpand) {
351
373
  /**
352
374
  * Copying in the accessibility/prop handling from react-native-web here
353
375
  * Keeps it in a single loop, avoids dup de-structuring to avoid bundle size
@@ -486,25 +508,19 @@ export const getSplitStyles: StyleSplitter = (
486
508
  }
487
509
 
488
510
  const isStyleProp =
489
- isValidStyleKeyInit ||
490
- isMediaOrPseudo ||
491
- (isVariant && !styleProps.noExpand) ||
492
- isShorthand
511
+ isValidStyleKeyInit || isMediaOrPseudo || (isVariant && !noExpand) || isShorthand
493
512
 
494
- if (
495
- isStyleProp &&
496
- (props.asChild === 'except-style' || props.asChild === 'except-style-web')
497
- ) {
513
+ if (isStyleProp && (asChild === 'except-style' || asChild === 'except-style-web')) {
498
514
  continue
499
515
  }
500
516
 
501
517
  const shouldPassProp =
502
518
  !isStyleProp ||
503
519
  // is in parent variants
504
- (isHOC && parentStaticConfig?.variants && keyInit in parentStaticConfig.variants) ||
520
+ (isHOC && parentVariants && keyInit in parentVariants) ||
505
521
  inlineProps?.has(keyInit)
506
522
 
507
- const parentVariant = parentStaticConfig?.variants?.[keyInit]
523
+ const parentVariant = parentVariants?.[keyInit]
508
524
  const isHOCShouldPassThrough = Boolean(
509
525
  isHOC &&
510
526
  (isShorthand ||
@@ -571,7 +587,7 @@ export const getSplitStyles: StyleSplitter = (
571
587
  }
572
588
 
573
589
  // after shouldPassThrough
574
- if (!styleProps.noSkip) {
590
+ if (!noSkip) {
575
591
  if (keyInit in skipProps) {
576
592
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
577
593
  console.groupEnd()
@@ -649,7 +665,10 @@ export const getSplitStyles: StyleSplitter = (
649
665
  isMediaOrPseudo = Boolean(isMedia || isPseudo)
650
666
  isVariant = variants && key in variants
651
667
 
652
- if (inlineProps?.has(key) || (IS_STATIC && inlineWhenUnflattened?.has(key))) {
668
+ if (
669
+ inlineProps?.has(key) ||
670
+ (process.env.IS_STATIC === 'is_static' && inlineWhenUnflattened?.has(key))
671
+ ) {
653
672
  viewProps[key] = props[key] ?? val
654
673
  }
655
674
 
@@ -690,10 +709,10 @@ export const getSplitStyles: StyleSplitter = (
690
709
  continue
691
710
  }
692
711
 
693
- if (!shouldDoClasses || IS_STATIC) {
712
+ if (!shouldDoClasses || process.env.IS_STATIC === 'is_static') {
694
713
  pseudos ||= {}
695
714
  pseudos[key] ||= {}
696
- if (IS_STATIC) {
715
+ if (process.env.IS_STATIC === 'is_static') {
697
716
  Object.assign(pseudos[key], pseudoStyleObject)
698
717
  continue
699
718
  }
@@ -712,7 +731,7 @@ export const getSplitStyles: StyleSplitter = (
712
731
  }
713
732
 
714
733
  for (const psuedoStyle of pseudoStyles) {
715
- const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`
734
+ const fullKey = `${psuedoStyle[StyleObjectProperty]}${PROP_SPLIT}${descriptor.name}`
716
735
  if (fullKey in usedKeys) continue
717
736
 
718
737
  addStyleToInsertRules(rulesToInsert, psuedoStyle)
@@ -720,7 +739,7 @@ export const getSplitStyles: StyleSplitter = (
720
739
  transforms,
721
740
  classNames,
722
741
  fullKey,
723
- psuedoStyle.identifier,
742
+ psuedoStyle[StyleObjectIdentifier],
724
743
  isMediaOrPseudo,
725
744
  true
726
745
  )
@@ -803,6 +822,21 @@ export const getSplitStyles: StyleSplitter = (
803
822
  if (isMedia) {
804
823
  if (!val) continue
805
824
 
825
+ // for some reason 'space' in val upsetting next ssr during prod build
826
+ // technically i guess this also will not apply if 0 space which makes sense?
827
+ const hasSpace = val['space']
828
+ const mediaKeyShort = key.slice(1)
829
+
830
+ hasMedia ||= true
831
+
832
+ if (hasSpace || !shouldDoClasses || styleProps.willBeAnimated) {
833
+ if (!Array.isArray(hasMedia)) {
834
+ hasMedia = []
835
+ }
836
+ hasMedia.push(mediaKeyShort)
837
+ }
838
+
839
+ // can bail early
806
840
  if (isMedia === 'platform') {
807
841
  const platform = key.slice(10)
808
842
  if (
@@ -815,10 +849,6 @@ export const getSplitStyles: StyleSplitter = (
815
849
  }
816
850
  }
817
851
 
818
- hasMedia ||= true
819
-
820
- const mediaKeyShort = key.slice(1)
821
-
822
852
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
823
853
  log(` 📺 ${key}`, {
824
854
  key,
@@ -827,19 +857,10 @@ export const getSplitStyles: StyleSplitter = (
827
857
  shouldDoClasses,
828
858
  acceptsClassName,
829
859
  componentState,
860
+ mediaState,
830
861
  })
831
862
  }
832
863
 
833
- // for some reason 'space' in val upsetting next ssr during prod build
834
- // technically i guess this also will not apply if 0 space which makes sense?
835
- const hasSpace = val['space']
836
- if (hasSpace || !shouldDoClasses) {
837
- if (!Array.isArray(hasMedia)) {
838
- hasMedia = []
839
- }
840
- hasMedia.push(mediaKeyShort)
841
- }
842
-
843
864
  if (shouldDoClasses) {
844
865
  const mediaStyle = getSubStyle(styleState, key, val, false)
845
866
 
@@ -881,25 +902,39 @@ export const getSplitStyles: StyleSplitter = (
881
902
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
882
903
  log(`📺 media style:`, out)
883
904
  }
884
- const fullKey = `${style.property}${PROP_SPLIT}${mediaKeyShort}${
885
- style.pseudo || ''
905
+ const fullKey = `${style[StyleObjectProperty]}${PROP_SPLIT}${mediaKeyShort}${
906
+ style[StyleObjectPseudo] || ''
886
907
  }`
887
908
  if (fullKey in usedKeys) continue
888
909
  addStyleToInsertRules(rulesToInsert, out as any)
889
- mergeClassName(transforms, classNames, fullKey, out.identifier, true, true)
910
+ mergeClassName(
911
+ transforms,
912
+ classNames,
913
+ fullKey,
914
+ out[StyleObjectIdentifier],
915
+ true,
916
+ true
917
+ )
890
918
  }
891
919
  } else {
892
- const mediaStyle = getSubStyle(styleState, key, val, true)
893
920
  const isThemeMedia = isMedia === 'theme'
894
921
  const isGroupMedia = isMedia === 'group'
895
922
  const isPlatformMedia = isMedia === 'platform'
896
923
 
897
924
  if (!isThemeMedia && !isPlatformMedia && !isGroupMedia) {
898
925
  if (!mediaState[mediaKeyShort]) {
926
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
927
+ log(` 📺 ❌ DISABLED ${mediaKeyShort}`)
928
+ }
899
929
  continue
900
930
  }
931
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
932
+ log(` 📺 ✅ ENABLED ${mediaKeyShort}`)
933
+ }
901
934
  }
902
935
 
936
+ const mediaStyle = getSubStyle(styleState, key, val, true)
937
+
903
938
  let importanceBump = 0
904
939
 
905
940
  if (isThemeMedia) {
@@ -1023,8 +1058,7 @@ export const getSplitStyles: StyleSplitter = (
1023
1058
  fixStyles(styleState.style)
1024
1059
 
1025
1060
  // shouldn't this be better? but breaks some tests weirdly, need to check
1026
- // if (isWeb && !staticConfig.isReactNative) {
1027
- if (isWeb && !staticConfig.isReactNative) {
1061
+ if (isWeb && !isReactNative) {
1028
1062
  styleToCSS(styleState.style)
1029
1063
  }
1030
1064
  }
@@ -1095,7 +1129,7 @@ export const getSplitStyles: StyleSplitter = (
1095
1129
  const atomic = getStylesAtomic(styleState.style)
1096
1130
 
1097
1131
  for (const atomicStyle of atomic) {
1098
- const key = atomicStyle.property
1132
+ const [key, value, identifier] = atomicStyle
1099
1133
  const isAnimatedAndAnimateOnly =
1100
1134
  styleProps.isAnimated &&
1101
1135
  styleProps.noClassNames &&
@@ -1113,18 +1147,11 @@ export const getSplitStyles: StyleSplitter = (
1113
1147
  retainedStyles[key] = styleState.style[key]
1114
1148
  } else if (nonAnimatedAnimateOnly) {
1115
1149
  retainedStyles ||= {}
1116
- retainedStyles[key] = atomicStyle.value
1150
+ retainedStyles[key] = value
1117
1151
  shouldRetain = true
1118
1152
  } else {
1119
1153
  addStyleToInsertRules(rulesToInsert, atomicStyle)
1120
- mergeClassName(
1121
- transforms,
1122
- classNames,
1123
- key,
1124
- atomicStyle.identifier,
1125
- false,
1126
- true
1127
- )
1154
+ mergeClassName(transforms, classNames, key, identifier, false, true)
1128
1155
  }
1129
1156
  }
1130
1157
 
@@ -1135,7 +1162,7 @@ export const getSplitStyles: StyleSplitter = (
1135
1162
  console.groupEnd()
1136
1163
  }
1137
1164
 
1138
- if (shouldRetain || !IS_STATIC) {
1165
+ if (shouldRetain || !(process.env.IS_STATIC === 'is_static')) {
1139
1166
  styleState.style = retainedStyles || {}
1140
1167
  }
1141
1168
  }
@@ -1152,11 +1179,13 @@ export const getSplitStyles: StyleSplitter = (
1152
1179
  const identifier = `_transform${hash}`
1153
1180
  if (isClient && !insertedTransforms[identifier]) {
1154
1181
  const rule = `.${identifier} { transform: ${val}; }`
1155
- addStyleToInsertRules(rulesToInsert, {
1182
+ addStyleToInsertRules(rulesToInsert, [
1183
+ namespace,
1184
+ val,
1156
1185
  identifier,
1157
- rules: [rule],
1158
- property: namespace,
1159
- } as StyleObject)
1186
+ undefined,
1187
+ [rule],
1188
+ ] satisfies StyleObject)
1160
1189
  }
1161
1190
  classNames[namespace] = identifier
1162
1191
  }
@@ -1268,7 +1297,6 @@ export const getSplitStyles: StyleSplitter = (
1268
1297
  mediaGroups,
1269
1298
  }
1270
1299
 
1271
- const asChild = props.asChild
1272
1300
  const asChildExceptStyleLike =
1273
1301
  asChild === 'except-style' || asChild === 'except-style-web'
1274
1302
 
@@ -1480,11 +1508,11 @@ export const useSplitStyles: StyleSplitter = (a, b, c, d, e, f, g, h, i, j) => {
1480
1508
 
1481
1509
  function addStyleToInsertRules(rulesToInsert: RulesToInsert, styleObject: StyleObject) {
1482
1510
  if (process.env.TAMAGUI_TARGET === 'web') {
1483
- if (!shouldInsertStyleRules(styleObject.identifier)) {
1511
+ if (!shouldInsertStyleRules(styleObject[StyleObjectIdentifier])) {
1484
1512
  return
1485
1513
  }
1486
1514
  if (!process.env.TAMAGUI_REACT_19) {
1487
- updateRules(styleObject.identifier, styleObject.rules)
1515
+ updateRules(styleObject[StyleObjectIdentifier], styleObject[StyleObjectRules])
1488
1516
  }
1489
1517
  rulesToInsert.push(styleObject)
1490
1518
  }
@@ -53,6 +53,7 @@ export const getStyleAtomic = (
53
53
 
54
54
  let conf: TamaguiInternalConfig
55
55
 
56
+ // this could be cached for performance?
56
57
  const getStyleObject = (
57
58
  style: ViewStyleWithPseudos,
58
59
  key: string,
@@ -71,13 +72,14 @@ const getStyleObject = (
71
72
  const shortProp = conf.inverseShorthands[key] || key
72
73
  const identifier = `_${shortProp}-${pseudoPrefix}${hash}`
73
74
  const rules = createAtomicRules(identifier, key, value, pseudo)
74
- return {
75
- property: key,
76
- pseudo: pseudo?.name as any,
75
+ return [
76
+ // array for performance
77
+ key,
78
+ value,
77
79
  identifier,
80
+ pseudo?.name as any,
78
81
  rules,
79
- value,
80
- }
82
+ ]
81
83
  }
82
84
 
83
85
  export function styleToCSS(style: Record<string, any>) {