@tamagui/web 1.20.5 → 1.20.7

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 (63) hide show
  1. package/dist/cjs/createComponent.js +51 -39
  2. package/dist/cjs/createComponent.js.map +1 -1
  3. package/dist/cjs/helpers/createPropMapper.js +7 -14
  4. package/dist/cjs/helpers/createPropMapper.js.map +1 -1
  5. package/dist/cjs/helpers/createProxy.js.map +1 -1
  6. package/dist/cjs/helpers/extendStaticConfig.js +8 -10
  7. package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
  8. package/dist/cjs/helpers/getSplitStyles.js +36 -17
  9. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  10. package/dist/cjs/helpers/useShallowSetState.js +8 -20
  11. package/dist/cjs/helpers/useShallowSetState.js.map +1 -1
  12. package/dist/cjs/hooks/useTheme.js.map +1 -1
  13. package/dist/cjs/styled.js +5 -2
  14. package/dist/cjs/styled.js.map +1 -1
  15. package/dist/esm/createComponent.js +58 -41
  16. package/dist/esm/createComponent.js.map +1 -1
  17. package/dist/esm/createComponent.mjs +58 -41
  18. package/dist/esm/createComponent.mjs.map +1 -1
  19. package/dist/esm/helpers/createPropMapper.js +6 -12
  20. package/dist/esm/helpers/createPropMapper.js.map +1 -1
  21. package/dist/esm/helpers/createPropMapper.mjs +6 -12
  22. package/dist/esm/helpers/createPropMapper.mjs.map +1 -1
  23. package/dist/esm/helpers/createProxy.js.map +1 -1
  24. package/dist/esm/helpers/createProxy.mjs.map +1 -1
  25. package/dist/esm/helpers/extendStaticConfig.js +8 -10
  26. package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
  27. package/dist/esm/helpers/extendStaticConfig.mjs +8 -10
  28. package/dist/esm/helpers/extendStaticConfig.mjs.map +1 -1
  29. package/dist/esm/helpers/getSplitStyles.js +36 -17
  30. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  31. package/dist/esm/helpers/getSplitStyles.mjs +36 -17
  32. package/dist/esm/helpers/getSplitStyles.mjs.map +2 -2
  33. package/dist/esm/helpers/useShallowSetState.js +9 -21
  34. package/dist/esm/helpers/useShallowSetState.js.map +1 -1
  35. package/dist/esm/helpers/useShallowSetState.mjs +9 -21
  36. package/dist/esm/helpers/useShallowSetState.mjs.map +1 -1
  37. package/dist/esm/hooks/useTheme.js.map +1 -1
  38. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  39. package/dist/esm/styled.js +5 -2
  40. package/dist/esm/styled.js.map +1 -1
  41. package/dist/esm/styled.mjs +5 -2
  42. package/dist/esm/styled.mjs.map +1 -1
  43. package/package.json +9 -9
  44. package/src/createComponent.tsx +85 -47
  45. package/src/helpers/createPropMapper.ts +4 -12
  46. package/src/helpers/createProxy.ts +0 -1
  47. package/src/helpers/extendStaticConfig.ts +9 -10
  48. package/src/helpers/getSplitStyles.tsx +47 -27
  49. package/src/helpers/useShallowSetState.tsx +9 -23
  50. package/src/hooks/useTheme.tsx +0 -2
  51. package/src/styled.tsx +6 -2
  52. package/src/types.tsx +6 -3
  53. package/types/createComponent.d.ts.map +1 -1
  54. package/types/helpers/createPropMapper.d.ts +1 -2
  55. package/types/helpers/createPropMapper.d.ts.map +1 -1
  56. package/types/helpers/createProxy.d.ts.map +1 -1
  57. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  58. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  59. package/types/helpers/useShallowSetState.d.ts.map +1 -1
  60. package/types/hooks/useTheme.d.ts.map +1 -1
  61. package/types/styled.d.ts.map +1 -1
  62. package/types/types.d.ts +2 -2
  63. package/types/types.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.20.5",
3
+ "version": "1.20.7",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,19 +27,19 @@
27
27
  "reset.css"
28
28
  ],
29
29
  "dependencies": {
30
- "@tamagui/compose-refs": "1.20.5",
31
- "@tamagui/constants": "1.20.5",
32
- "@tamagui/helpers": "1.20.5",
33
- "@tamagui/normalize-css-color": "1.20.5",
34
- "@tamagui/use-did-finish-ssr": "1.20.5",
35
- "@tamagui/use-event": "1.20.5",
36
- "@tamagui/use-force-update": "1.20.5"
30
+ "@tamagui/compose-refs": "1.20.7",
31
+ "@tamagui/constants": "1.20.7",
32
+ "@tamagui/helpers": "1.20.7",
33
+ "@tamagui/normalize-css-color": "1.20.7",
34
+ "@tamagui/use-did-finish-ssr": "1.20.7",
35
+ "@tamagui/use-event": "1.20.7",
36
+ "@tamagui/use-force-update": "1.20.7"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "1.20.5",
42
+ "@tamagui/build": "1.20.7",
43
43
  "@testing-library/react": "^13.4.0",
44
44
  "csstype": "^3.0.10",
45
45
  "react": "^18.2.0",
@@ -1,5 +1,11 @@
1
1
  import { useComposedRefs } from '@tamagui/compose-refs'
2
- import { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'
2
+ import {
3
+ isClient,
4
+ isRSC,
5
+ isServer,
6
+ isWeb,
7
+ useIsomorphicLayoutEffect,
8
+ } from '@tamagui/constants'
3
9
  import { stylePropsView, validPseudoKeys, validStyles } from '@tamagui/helpers'
4
10
  import React, {
5
11
  Children,
@@ -12,7 +18,6 @@ import React, {
12
18
  useEffect,
13
19
  useId,
14
20
  useRef,
15
- useState,
16
21
  } from 'react'
17
22
 
18
23
  import { onConfiguredOnce } from './config.js'
@@ -49,8 +54,6 @@ import {
49
54
  UseAnimationProps,
50
55
  } from './types'
51
56
  import { Slot } from './views/Slot.js'
52
- import { Stack } from './views/Stack.js'
53
- import { Text } from './views/Text.js'
54
57
  import { useThemedChildren } from './views/Theme.js'
55
58
  import { ThemeDebug } from './views/ThemeDebug'
56
59
 
@@ -120,6 +123,8 @@ let BaseText: any
120
123
  let BaseView: any
121
124
  let hasSetupBaseViews = false
122
125
 
126
+ const numRenderedOfType: Record<string, number> = {}
127
+
123
128
  export function createComponent<
124
129
  ComponentPropTypes extends Object = {},
125
130
  Ref = TamaguiElement,
@@ -195,7 +200,10 @@ export function createComponent<
195
200
  */
196
201
  const animationsConfig = useAnimationDriver()
197
202
  const useAnimations = animationsConfig?.useAnimations as UseAnimationHook | undefined
198
- const isAnimated = (() => {
203
+
204
+ // after we get states mount we need to turn off isAnimated for server side
205
+ const willBeAnimated = (() => {
206
+ if (isServer) return false
199
207
  const next = !!(
200
208
  !staticConfig.isHOC &&
201
209
  useAnimations &&
@@ -206,6 +214,47 @@ export function createComponent<
206
214
  }
207
215
  return next || stateRef.current.hasAnimated
208
216
  })()
217
+
218
+ const usePresence = animationsConfig?.usePresence
219
+ const presence = !isRSC && willBeAnimated && usePresence ? usePresence() : null
220
+
221
+ const hasEnterStyle = !!props.enterStyle
222
+ const needsMount = Boolean((isWeb ? isClient : true) && willBeAnimated)
223
+
224
+ const states = useServerState<TamaguiComponentState>(
225
+ needsMount ? defaultComponentState! : defaultComponentStateMounted!
226
+ )
227
+ const state = propsIn.forceStyle
228
+ ? { ...states[0], [propsIn.forceStyle]: true }
229
+ : states[0]
230
+ const setState = states[1]
231
+ const setStateShallow = useShallowSetState(setState, debugProp, componentName)
232
+
233
+ // cheat code
234
+ let hasHydrated = false
235
+ numRenderedOfType[componentName] ??= 0
236
+ if (willBeAnimated) {
237
+ if (
238
+ ++numRenderedOfType[componentName] >
239
+ (process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
240
+ ? +process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
241
+ : 5)
242
+ ) {
243
+ hasHydrated = true
244
+ }
245
+ }
246
+
247
+ let isAnimated = willBeAnimated
248
+
249
+ // presence avoids ssr stuff
250
+ if (presence && hasHydrated) {
251
+ // no
252
+ } else {
253
+ if (isAnimated && (isServer || state.unmounted === true)) {
254
+ isAnimated = false
255
+ }
256
+ }
257
+
209
258
  const componentClassName = props.asChild
210
259
  ? ''
211
260
  : props.componentName
@@ -234,22 +283,6 @@ export function createComponent<
234
283
  : (isAnimated ? AnimatedView : null) || BaseViewComponent
235
284
 
236
285
  const avoidClassesWhileAnimating = animationsConfig?.isReactNative
237
- const hasEnterStyle = !!props.enterStyle
238
- const needsMount = Boolean(
239
- (isWeb ? isClient : true) && (hasEnterStyle || props.animation)
240
- )
241
- const states = useServerState<TamaguiComponentState>(
242
- needsMount ? defaultComponentState! : defaultComponentStateMounted!
243
- )
244
-
245
- const state = propsIn.forceStyle
246
- ? { ...states[0], [propsIn.forceStyle]: true }
247
- : states[0]
248
- const setState = states[1]
249
- const setStateShallow = useShallowSetState(setState, debugProp, componentName)
250
-
251
- const usePresence = animationsConfig?.usePresence
252
- const presence = !isRSC && isAnimated && usePresence ? usePresence() : null
253
286
 
254
287
  // set enter/exit variants onto our new props object
255
288
  if (isAnimated && presence) {
@@ -269,14 +302,14 @@ export function createComponent<
269
302
 
270
303
  const shouldAvoidClasses =
271
304
  !isWeb ||
272
- !!(props.animation && avoidClassesWhileAnimating) ||
305
+ !!(isAnimated && avoidClassesWhileAnimating) ||
273
306
  !staticConfig.acceptsClassName
274
307
  const shouldForcePseudo = !!propsIn.forceStyle
275
308
  const noClassNames = shouldAvoidClasses || shouldForcePseudo
276
309
 
277
310
  // internal use only
278
311
  const disableTheme =
279
- (props['data-disable-theme'] && !isAnimated) || staticConfig.isHOC
312
+ (props['data-disable-theme'] && !willBeAnimated) || staticConfig.isHOC
280
313
 
281
314
  const themeStateProps = {
282
315
  name: props.theme,
@@ -315,7 +348,10 @@ export function createComponent<
315
348
  const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type} id ${id}`
316
349
  const parentsLog = (conf: StaticConfig) =>
317
350
  conf.parentNames ? ` (${conf.parentNames?.join(' > ')})` : ''
318
- console.group(`%c ${banner}${parentsLog(staticConfig)}`, 'background: yellow;')
351
+ console.group(
352
+ `%c ${banner}${parentsLog(staticConfig)} (unmounted: ${state.unmounted})`,
353
+ 'background: yellow;'
354
+ )
319
355
  if (!isServer) {
320
356
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
321
357
  console.log({
@@ -326,6 +362,7 @@ export function createComponent<
326
362
  themeStateProps,
327
363
  themeState,
328
364
  })
365
+ console.warn(themeState.name)
329
366
  }
330
367
  }
331
368
  }
@@ -338,9 +375,8 @@ export function createComponent<
338
375
  ...state,
339
376
  mediaState,
340
377
  noClassNames,
341
- dynamicStylesInline: noClassNames,
342
378
  hasTextAncestor,
343
- resolveVariablesAs: 'auto',
379
+ resolveVariablesAs: isAnimated ? 'value' : 'auto',
344
380
  isExiting,
345
381
  },
346
382
  null,
@@ -408,19 +444,22 @@ export function createComponent<
408
444
  // once you set animation prop don't remove it, you can set to undefined/false
409
445
  // reason is animations are heavy - no way around it, and must be run inline here (🙅 loading as a sub-component)
410
446
  let animationStyles: any
411
- if (!isRSC && isAnimated && useAnimations && !staticConfig.isHOC) {
447
+ if (!isRSC && willBeAnimated && useAnimations && !staticConfig.isHOC) {
412
448
  const animations = useAnimations({
413
449
  props: propsWithAnimation,
414
450
  style: splitStylesStyle,
415
451
  presence,
416
452
  state,
453
+ theme: themeState.theme,
417
454
  pseudos: pseudos || null,
418
455
  onDidAnimate: props.onDidAnimate,
419
456
  hostRef,
420
457
  staticConfig,
421
458
  })
422
- if (animations) {
423
- animationStyles = animations.style
459
+ if (isAnimated) {
460
+ if (animations) {
461
+ animationStyles = animations.style
462
+ }
424
463
  }
425
464
  }
426
465
 
@@ -462,7 +501,12 @@ export function createComponent<
462
501
  }
463
502
 
464
503
  // if react-native-web view just pass all props down
465
- if (process.env.TAMAGUI_TARGET === 'web' && !isReactNative && !asChild) {
504
+ if (
505
+ process.env.TAMAGUI_TARGET === 'web' &&
506
+ !isReactNative &&
507
+ !willBeAnimated &&
508
+ !asChild
509
+ ) {
466
510
  viewProps = hooks.usePropsTransform?.(elementType, nonTamaguiProps, hostRef)
467
511
  } else {
468
512
  viewProps = nonTamaguiProps
@@ -490,26 +534,20 @@ export function createComponent<
490
534
  })
491
535
  }, [setStateShallow])
492
536
 
493
- if (isWeb) {
494
- useEffect(() => {
537
+ const shouldSetMounted = needsMount && state.unmounted
538
+
539
+ // combinined two effects into one for performance so be careful with logic
540
+ // because no need for mouseUp removal effect if its not even mounted yet
541
+ useIsomorphicLayoutEffect(() => {
542
+ if (!shouldSetMounted) {
495
543
  return () => {
496
544
  mouseUps.delete(unPress)
497
545
  }
498
- }, [])
499
- }
500
-
501
- const shouldSetMounted = needsMount && state.unmounted
502
- useEffect(() => {
503
- if (!shouldSetMounted) return
504
- if (state.unmounted === true && needsMount) {
505
- setStateShallow({
506
- unmounted: false,
507
- })
508
- return
509
546
  }
510
547
 
548
+ const unmounted = state.unmounted === true && hasEnterStyle ? 'should-enter' : false
511
549
  setStateShallow({
512
- unmounted: false,
550
+ unmounted,
513
551
  })
514
552
  }, [shouldSetMounted, state.unmounted])
515
553
 
@@ -782,7 +820,7 @@ export function createComponent<
782
820
  }
783
821
  }
784
822
 
785
- if (process.env.NODE_ENV === 'development' && process.env.DEBUG !== 'tamagui') {
823
+ if (process.env.NODE_ENV === 'development') {
786
824
  if (debugProp) {
787
825
  const element = typeof elementType === 'string' ? elementType : 'Component'
788
826
  console.groupCollapsed(`render <${element} /> with props`, viewProps)
@@ -792,13 +830,13 @@ export function createComponent<
792
830
  }
793
831
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
794
832
  console.log('children', content)
795
- console.groupEnd()
796
833
  if (typeof window !== 'undefined') {
797
834
  // prettier-ignore
798
835
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
799
836
  console.log({ state, themeState, isAnimated, isAnimatedReactNativeWeb, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, staticConfig, tamaguiConfig, shouldForcePseudo })
800
837
  }
801
838
  console.groupEnd()
839
+ console.groupEnd()
802
840
  }
803
841
  }
804
842
 
@@ -868,7 +906,7 @@ export function createComponent<
868
906
  })
869
907
 
870
908
  // split - keep variables on props to be processed using theme values at runtime (native)
871
- if (!isWeb) {
909
+ if (process.env.TAMAGUI_TARGET === 'native') {
872
910
  for (const key in staticConfig.defaultProps) {
873
911
  const val = staticConfig.defaultProps[key]
874
912
  if (validPseudoKeys[key]) continue
@@ -26,10 +26,6 @@ export type ResolveVariableTypes =
26
26
  | 'both'
27
27
  | 'non-color-value'
28
28
 
29
- export const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {
30
- return !!props.animation || state.resolveVariablesAs === 'value' ? 'value' : 'auto'
31
- }
32
-
33
29
  export const createPropMapper = (staticConfig: StaticConfigParsed) => {
34
30
  const variants = staticConfig.variants || {}
35
31
 
@@ -57,7 +53,7 @@ export const createPropMapper = (staticConfig: StaticConfigParsed) => {
57
53
  }
58
54
 
59
55
  const props = state.fallbackProps || propsIn
60
- const returnVariablesAs = getReturnVariablesAs(props, state)
56
+ const returnVariablesAs = state.resolveVariablesAs === 'value' ? 'value' : 'auto'
61
57
 
62
58
  // handled here because we need to resolve this off tokens, its the only one-off like this
63
59
  const fontFamily =
@@ -177,13 +173,9 @@ const resolveVariants: StyleResolver = (
177
173
  if (!variantValue) {
178
174
  // variant at key exists, but no matching variant value, return nothing
179
175
  if (process.env.NODE_ENV === 'development') {
180
- if (staticConfig.validStyles?.[key]) {
181
- return null
182
- }
183
- if (typeof value === 'boolean') {
184
- // don't warn on missing boolean values, common to only one of true/false
185
- return null
186
- }
176
+ if (staticConfig.validStyles?.[key]) return
177
+ // don't warn on missing boolean values, common to only one of true/false
178
+ if (typeof value === 'boolean') return
187
179
  const name = staticConfig.componentName || '[UnnamedComponent]'
188
180
  console.warn(
189
181
  `No variant found: ${name} has variant "${key}", but no matching value "${value}"`
@@ -1,7 +1,6 @@
1
1
  export function createProxy<A extends object>(target: A, handler: ProxyHandler<A>) {
2
2
  if (process.env.NODE_ENV === 'development') {
3
3
  if (typeof target !== 'object' || !target) {
4
- // rome-ignore lint/nursery/noConsoleLog: ok
5
4
  console.warn(
6
5
  'Invalid object given for proxy:',
7
6
  target,
@@ -40,6 +40,14 @@ export function extendStaticConfig(
40
40
  const deoptProps = config.deoptProps || new Set<string>()
41
41
  // deoptProps.add('style')
42
42
 
43
+ const defaultProps = mergeProps(
44
+ { ...parentStaticConfig.defaultProps },
45
+ {
46
+ ...config.defaultVariants,
47
+ ...config.defaultProps,
48
+ }
49
+ )[0]
50
+
43
51
  return parseStaticConfig({
44
52
  ...parentStaticConfig,
45
53
  ...config,
@@ -53,16 +61,7 @@ export function extendStaticConfig(
53
61
  ...config.validStyles,
54
62
  }
55
63
  : parentStaticConfig.validStyles || stylePropsView,
56
- defaultProps: mergeProps(
57
- {
58
- ...parentStaticConfig.defaultProps,
59
- ...parentStaticConfig.defaultVariants,
60
- },
61
- {
62
- ...config.defaultProps,
63
- ...config.defaultVariants,
64
- }
65
- )[0],
64
+ defaultProps,
66
65
  })
67
66
  }
68
67
 
@@ -263,7 +263,11 @@ export const getSplitStyles: StyleSplitter = (
263
263
  languageContext,
264
264
  }
265
265
 
266
- if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
266
+ if (process.env.NODE_ENV === 'development' && debug) {
267
+ // pass debug down
268
+ // @ts-ignore
269
+ delete skipProps.debug
270
+
267
271
  console.groupCollapsed('getSplitStyles (looping backwards)')
268
272
  // prettier-ignore
269
273
  // rome-ignore lint/nursery/noConsoleLog: ok
@@ -550,31 +554,40 @@ export const getSplitStyles: StyleSplitter = (
550
554
  const isVariant = variants && keyInit in variants
551
555
 
552
556
  const shouldPassProp = !(
553
- isMedia ||
554
- isPseudo ||
557
+ isMediaOrPseudo ||
555
558
  isVariant ||
556
559
  keyInit in validStyleProps ||
557
560
  keyInit in shorthands
558
561
  )
559
562
 
560
- const parentHasVariant =
561
- staticConfig.parentStaticConfig?.variants &&
562
- keyInit in staticConfig.parentStaticConfig
563
- const isHOCShouldPassThrough = staticConfig.isHOC && isMediaOrPseudo
564
- const shouldPassThrough = shouldPassProp || isHOCShouldPassThrough || parentHasVariant
565
-
566
- if (
567
- process.env.NODE_ENV === 'development' &&
568
- debug === 'verbose' &&
569
- shouldPassThrough
570
- ) {
571
- console.groupCollapsed(` 🔹 pass through ${keyInit}`)
572
- // rome-ignore lint/nursery/noConsoleLog: <explanation>
573
- console.log({ valInit, variants, parentHasVariant, isVariant, shouldPassProp })
574
- console.groupEnd()
575
- }
563
+ const isHOCShouldPassThrough = staticConfig.isHOC && (isMediaOrPseudo || isVariant)
564
+ const shouldPassThrough = shouldPassProp || isHOCShouldPassThrough
576
565
 
577
566
  if (shouldPassThrough) {
567
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
568
+ console.groupCollapsed(` 🔹 pass through ${keyInit}`)
569
+ // rome-ignore lint/nursery/noConsoleLog: <explanation>
570
+ console.log({ valInit, variants, isVariant, shouldPassProp })
571
+ console.groupEnd()
572
+ }
573
+
574
+ if (isPseudo) {
575
+ // this is a lot... but we need to track sub-keys so we don't override them in future things that aren't passed down
576
+ // like our own variants that aren't in parent
577
+ const pseudoStyleObject = getSubStyle(
578
+ styleState,
579
+ keyInit,
580
+ valInit,
581
+ true,
582
+ state.noClassNames
583
+ )
584
+ const descriptor = pseudoDescriptors[keyInit]
585
+ for (const key in pseudoStyleObject) {
586
+ const fullKey = `${key}${PROP_SPLIT}${descriptor.name}`
587
+ usedKeys[fullKey] = 1
588
+ }
589
+ }
590
+
578
591
  passDownProp(keyInit, valInit, isMediaOrPseudo)
579
592
 
580
593
  // if it's a variant here, we have a two layer variant...
@@ -586,12 +599,6 @@ export const getSplitStyles: StyleSplitter = (
586
599
  }
587
600
  }
588
601
 
589
- if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
590
- console.groupCollapsed(' 🔹 styles', keyInit, valInit)
591
- // rome-ignore lint/nursery/noConsoleLog: <explanation>
592
- console.log({ isVariant, shouldPassProp, isHOCShouldPassThrough, parentHasVariant })
593
- }
594
-
595
602
  const expanded = isMediaOrPseudo
596
603
  ? [[keyInit, valInit]]
597
604
  : propMapper(
@@ -610,14 +617,24 @@ export const getSplitStyles: StyleSplitter = (
610
617
  }
611
618
 
612
619
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
620
+ console.groupCollapsed(' 🔹 styles', keyInit, valInit)
621
+ // rome-ignore lint/nursery/noConsoleLog: <explanation>
622
+ console.log({
623
+ expanded,
624
+ state,
625
+ isVariant,
626
+ shouldPassProp,
627
+ isHOCShouldPassThrough,
628
+ })
613
629
  if (!isServer && isDevTools) {
614
630
  // rome-ignore lint/nursery/noConsoleLog: ok
615
- console.log('expanded', expanded, '\nusedKeys', usedKeys, '\ncurrent', {
631
+ console.log('expanded', expanded, '\nusedKeys', { ...usedKeys }, '\ncurrent', {
616
632
  ...style,
617
633
  })
618
634
  }
619
635
  console.groupEnd()
620
636
  }
637
+
621
638
  if (!expanded) return
622
639
 
623
640
  for (const [key, val] of expanded) {
@@ -648,7 +665,10 @@ export const getSplitStyles: StyleSplitter = (
648
665
  const isHOCShouldPassThrough = staticConfig.isHOC && isMediaOrPseudo
649
666
  if (isHOCShouldPassThrough) {
650
667
  passDownProp(key, val, true)
651
- continue
668
+ // if its also a variant here, pass down but also keep it
669
+ if (!isVariant) {
670
+ continue
671
+ }
652
672
  }
653
673
 
654
674
  // pseudo
@@ -1,4 +1,4 @@
1
- import React, { startTransition, useCallback } from 'react'
1
+ import React, { useCallback } from 'react'
2
2
 
3
3
  import { DebugProp, TamaguiComponentState } from '../types.js'
4
4
 
@@ -9,32 +9,18 @@ export function useShallowSetState<State extends TamaguiComponentState>(
9
9
  ) {
10
10
  return useCallback(
11
11
  (next: Partial<State>) => {
12
- const shouldTransition = Object.keys(next).every((k) =>
13
- transitionKeys.has(k as any)
14
- )
15
- const run = shouldTransition ? startTransition : (_) => _()
16
- run(() => {
17
- setter((prev) => {
18
- for (const key in next) {
19
- if (prev[key] !== next[key]) {
20
- if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
21
- // rome-ignore lint/nursery/noConsoleLog: ok
22
- console.log(` ▲ setState ${debugName}`, next)
23
- }
24
- return { ...prev, ...next }
12
+ setter((prev) => {
13
+ for (const key in next) {
14
+ if (prev[key] !== next[key]) {
15
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
16
+ console.warn(` ▲ setState ${debugName}`, next)
25
17
  }
18
+ return { ...prev, ...next }
26
19
  }
27
- return prev
28
- })
20
+ }
21
+ return prev
29
22
  })
30
23
  },
31
24
  [setter]
32
25
  )
33
26
  }
34
-
35
- const transitionKeys = new Set<keyof TamaguiComponentState>([
36
- 'press',
37
- 'pressIn',
38
- 'focus',
39
- 'unmounted',
40
- ])
@@ -4,13 +4,11 @@ import { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react
4
4
 
5
5
  import { getConfig } from '../config.js'
6
6
  import { isDevTools } from '../constants/isDevTools.js'
7
- import { isVariable } from '../createVariable.js'
8
7
  import { createProxy } from '../helpers/createProxy.js'
9
8
  import {
10
9
  ThemeManager,
11
10
  ThemeManagerState,
12
11
  getNonComponentParentManager,
13
- hasNoThemeUpdatingProps,
14
12
  } from '../helpers/ThemeManager.js'
15
13
  import { ThemeManagerContext } from '../helpers/ThemeManagerContext.js'
16
14
  import type { ThemeParsed, ThemeProps } from '../types.js'
package/src/styled.tsx CHANGED
@@ -90,15 +90,19 @@ export function styled<
90
90
 
91
91
  const staticConfigProps = (() => {
92
92
  if (options) {
93
- const {
93
+ let {
94
94
  variants,
95
95
  name,
96
96
  defaultVariants,
97
97
  acceptsClassName: acceptsClassNameProp,
98
98
  ...defaultProps
99
99
  } = options
100
+
100
101
  if (defaultVariants) {
101
- Object.assign(defaultProps, defaultVariants)
102
+ defaultProps = {
103
+ ...defaultVariants,
104
+ ...defaultProps,
105
+ }
102
106
  }
103
107
 
104
108
  const nativeConf =
package/src/types.tsx CHANGED
@@ -1500,7 +1500,7 @@ export type TamaguiComponentState = {
1500
1500
  press: boolean
1501
1501
  pressIn: boolean
1502
1502
  focus: boolean
1503
- unmounted: boolean
1503
+ unmounted: boolean | 'should-enter'
1504
1504
  animation?: null | {
1505
1505
  style?: any
1506
1506
  avoidClasses?: boolean
@@ -1510,7 +1510,6 @@ export type TamaguiComponentState = {
1510
1510
  export type SplitStyleState = TamaguiComponentState & {
1511
1511
  mediaState?: Record<string, boolean>
1512
1512
  noClassNames?: boolean
1513
- dynamicStylesInline?: boolean
1514
1513
  resolveVariablesAs?: ResolveVariableTypes
1515
1514
  fallbackProps?: Record<string, any>
1516
1515
  hasTextAncestor?: boolean
@@ -1602,6 +1601,7 @@ export type UseAnimationHook = (props: {
1602
1601
  hostRef: RefObject<HTMLElement | View>
1603
1602
  staticConfig: StaticConfigParsed
1604
1603
  state: SplitStyleState
1604
+ theme: ThemeParsed
1605
1605
  pseudos: PseudoProps<ViewStyle> | null
1606
1606
  onDidAnimate?: any
1607
1607
  delay?: number
@@ -1676,4 +1676,7 @@ type NarrowRaw<A> =
1676
1676
  export type Narrow<A extends any> = Try<A, [], NarrowRaw<A>>
1677
1677
 
1678
1678
  export type NativePlatform = 'web' | 'mobile' | 'android' | 'ios'
1679
- export type NativeValue<Platform extends NativePlatform = NativePlatform> = boolean | Platform | Platform[]
1679
+ export type NativeValue<Platform extends NativePlatform = NativePlatform> =
1680
+ | boolean
1681
+ | Platform
1682
+ | Platform[]
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAYN,MAAM,OAAO,CAAA;AAkBd,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAEhB,qBAAqB,EAErB,cAAc,EAIf,MAAM,SAAS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gB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,cAAc,EACpB,SAAS,GAAG,KAAK,EAEjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EACpD,eAAe,CAAC,EAAE,iBAAiB,wDA81BpC;AAGD,eAAO,MAAM,QAAQ;YAAW;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;;CAAmB,CAAA;AAMrE,eAAO,MAAM,MAAM,sDA8CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAkGxD"}
@@ -1,6 +1,5 @@
1
- import type { PropMapper, SplitStyleState, StaticConfigParsed, TamaguiInternalConfig } from '../types.js';
1
+ import type { PropMapper, StaticConfigParsed, TamaguiInternalConfig } from '../types.js';
2
2
  export type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value';
3
- export declare const getReturnVariablesAs: (props: any, state: Partial<SplitStyleState>) => "auto" | "value";
4
3
  export declare const createPropMapper: (staticConfig: StaticConfigParsed) => PropMapper;
5
4
  export declare function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig): string | undefined;
6
5
  export declare const getPropMappedFontFamily: (expanded?: any) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"createPropMapper.d.ts","sourceRoot":"","sources":["../../src/helpers/createPropMapper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,aAAa,CAAA;AAQpB,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,OAAO,GACP,UAAU,GACV,MAAM,GACN,iBAAiB,CAAA;AAErB,eAAO,MAAM,oBAAoB,UAAW,GAAG,SAAS,QAAQ,eAAe,CAAC,qBAE/E,CAAA;AAED,eAAO,MAAM,gBAAgB,iBAAkB,kBAAkB,eAsGhE,CAAA;AA8GD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB,sBA2BtF;AAMD,eAAO,MAAM,uBAAuB,cAAe,GAAG,QAErD,CAAA"}
1
+ {"version":3,"file":"createPropMapper.d.ts","sourceRoot":"","sources":["../../src/helpers/createPropMapper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,UAAU,EAEV,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,aAAa,CAAA;AAQpB,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,OAAO,GACP,UAAU,GACV,MAAM,GACN,iBAAiB,CAAA;AAErB,eAAO,MAAM,gBAAgB,iBAAkB,kBAAkB,eAsGhE,CAAA;AA0GD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB,sBA2BtF;AAMD,eAAO,MAAM,uBAAuB,cAAe,GAAG,QAErD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/createProxy.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAehF"}
1
+ {"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/createProxy.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAchF"}
@@ -1 +1 @@
1
- {"version":3,"file":"extendStaticConfig.d.ts","sourceRoot":"","sources":["../../src/helpers/extendStaticConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAItF,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAC7B,MAAM,CAAC,EAAE,iBAAiB,sBA0D3B;AAED,eAAO,MAAM,iBAAiB,WAAY,QAAQ,YAAY,CAAC,KAAG,kBAUjE,CAAA"}
1
+ {"version":3,"file":"extendStaticConfig.d.ts","sourceRoot":"","sources":["../../src/helpers/extendStaticConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAItF,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAC7B,MAAM,CAAC,EAAE,iBAAiB,sBAyD3B;AAED,eAAO,MAAM,iBAAiB,WAAY,QAAQ,YAAY,CAAC,KAAG,kBAUjE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,cAAc,EAMd,eAAe,EACf,kBAAkB,EAElB,qBAAqB,EACrB,cAAc,EACd,WAAW,EAEZ,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gCAAgC,CAAA;AAkBvC,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,cAAc,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,E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