@tamagui/web 1.48.11 → 1.49.1

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 (66) hide show
  1. package/dist/cjs/Tamagui.js.map +1 -1
  2. package/dist/cjs/createComponent.js +92 -8
  3. package/dist/cjs/createComponent.js.map +1 -1
  4. package/dist/cjs/helpers/ThemeManager.js +3 -2
  5. package/dist/cjs/helpers/ThemeManager.js.map +1 -1
  6. package/dist/cjs/helpers/getSplitStyles.js +55 -10
  7. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  8. package/dist/cjs/helpers/getStylesAtomic.js +33 -34
  9. package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
  10. package/dist/cjs/helpers/normalizeValueWithProperty.js +2 -0
  11. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +1 -1
  12. package/dist/cjs/helpers/propMapper.js +5 -1
  13. package/dist/cjs/helpers/propMapper.js.map +1 -1
  14. package/dist/cjs/helpers/pseudoDescriptors.js +10 -4
  15. package/dist/cjs/helpers/pseudoDescriptors.js.map +1 -1
  16. package/dist/cjs/hooks/useTheme.js +12 -5
  17. package/dist/cjs/hooks/useTheme.js.map +1 -1
  18. package/dist/cjs/views/Theme.js +3 -6
  19. package/dist/cjs/views/Theme.js.map +2 -2
  20. package/dist/esm/Tamagui.js +1 -5
  21. package/dist/esm/Tamagui.js.map +1 -1
  22. package/dist/esm/createComponent.js +92 -8
  23. package/dist/esm/createComponent.js.map +1 -1
  24. package/dist/esm/helpers/ThemeManager.js +3 -2
  25. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  26. package/dist/esm/helpers/getSplitStyles.js +55 -10
  27. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  28. package/dist/esm/helpers/getStylesAtomic.js +37 -35
  29. package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
  30. package/dist/esm/helpers/normalizeValueWithProperty.js +2 -0
  31. package/dist/esm/helpers/normalizeValueWithProperty.js.map +1 -1
  32. package/dist/esm/helpers/propMapper.js +5 -1
  33. package/dist/esm/helpers/propMapper.js.map +1 -1
  34. package/dist/esm/helpers/pseudoDescriptors.js +8 -3
  35. package/dist/esm/helpers/pseudoDescriptors.js.map +1 -1
  36. package/dist/esm/hooks/useTheme.js +12 -5
  37. package/dist/esm/hooks/useTheme.js.map +1 -1
  38. package/dist/esm/views/Theme.js +10 -7
  39. package/dist/esm/views/Theme.js.map +2 -2
  40. package/package.json +10 -9
  41. package/src/Tamagui.ts +1 -5
  42. package/src/createComponent.tsx +85 -42
  43. package/src/helpers/ThemeManager.tsx +4 -3
  44. package/src/helpers/getSplitStyles.tsx +63 -13
  45. package/src/helpers/getStylesAtomic.ts +45 -48
  46. package/src/helpers/normalizeValueWithProperty.ts +2 -0
  47. package/src/helpers/propMapper.ts +11 -2
  48. package/src/helpers/pseudoDescriptors.ts +9 -4
  49. package/src/hooks/useTheme.tsx +13 -6
  50. package/src/types.tsx +3 -5
  51. package/src/views/Theme.tsx +16 -6
  52. package/types/Tamagui.d.ts.map +1 -1
  53. package/types/createComponent.d.ts.map +1 -1
  54. package/types/helpers/ThemeManager.d.ts +1 -0
  55. package/types/helpers/ThemeManager.d.ts.map +1 -1
  56. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  57. package/types/helpers/getStylesAtomic.d.ts +3 -3
  58. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  59. package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
  60. package/types/helpers/propMapper.d.ts.map +1 -1
  61. package/types/helpers/pseudoDescriptors.d.ts +15 -0
  62. package/types/helpers/pseudoDescriptors.d.ts.map +1 -1
  63. package/types/hooks/useTheme.d.ts.map +1 -1
  64. package/types/types.d.ts +3 -3
  65. package/types/types.d.ts.map +1 -1
  66. package/types/views/Theme.d.ts.map +1 -1
@@ -48,8 +48,6 @@ import { Slot } from './views/Slot'
48
48
  import { useThemedChildren } from './views/Theme'
49
49
  import { ThemeDebug } from './views/ThemeDebug'
50
50
 
51
- // const timer = require('@tamagui/timer').timer()
52
-
53
51
  // this appears to fix expo / babel not picking this up sometimes? really odd
54
52
  process.env.TAMAGUI_TARGET
55
53
 
@@ -71,10 +69,6 @@ const defaultComponentStateShouldEnter: TamaguiComponentState = {
71
69
  unmounted: 'should-enter',
72
70
  }
73
71
 
74
- const HYDRATION_CUTOFF = process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
75
- ? +process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF
76
- : 5
77
-
78
72
  /**
79
73
  * All things that need one-time setup after createTamagui is called
80
74
  */
@@ -149,10 +143,6 @@ export function createComponent<
149
143
  }
150
144
 
151
145
  const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {
152
- // const shouldTime = staticConfig.defaultProps?.padding === 5
153
- // let time: any
154
- // if (shouldTime) time = timer.start()
155
-
156
146
  if (process.env.TAMAGUI_TARGET === 'native') {
157
147
  // todo this could be moved to a cleaner location
158
148
  if (!hasSetupBaseViews) {
@@ -223,6 +213,16 @@ export function createComponent<
223
213
  const debugProp = props['debug'] as DebugProp
224
214
  const componentName = props.componentName || staticConfig.componentName
225
215
 
216
+ let time: any
217
+ if (
218
+ !process.env.TAMAGUI_IS_CORE_NODE &&
219
+ process.env.NODE_ENV === 'development' &&
220
+ debugProp === 'profile'
221
+ ) {
222
+ const timer = require('@tamagui/timer').timer()
223
+ time = timer.start()
224
+ }
225
+
226
226
  const isHydrated = useDidFinishSSR()
227
227
 
228
228
  // conditional but if ever true stays true
@@ -236,7 +236,7 @@ export function createComponent<
236
236
  )
237
237
  stateRef.current ||= {}
238
238
 
239
- // if (shouldTime) time`stateref`
239
+ if (process.env.NODE_ENV === 'development' && time) time`stateref`
240
240
 
241
241
  const hostRef = useRef<TamaguiElement>(null)
242
242
 
@@ -267,7 +267,7 @@ export function createComponent<
267
267
  const hasEnterStyle = !!props.enterStyle
268
268
  const needsMount = Boolean((isWeb ? isClient : true) && willBeAnimated)
269
269
 
270
- // if (shouldTime) time`pre-use-state`
270
+ if (process.env.NODE_ENV === 'development' && time) time`pre-use-state`
271
271
 
272
272
  const initialState = willBeAnimated
273
273
  ? supportsCSSVars
@@ -285,7 +285,7 @@ export function createComponent<
285
285
  // TODO performance optimization could avoid useCallback and just have this be setStateShallow(setState, state) at call-sites
286
286
  const setStateShallow = useShallowSetState(setState, debugProp, componentName)
287
287
 
288
- // if (shouldTime) time`use-state`
288
+ if (process.env.NODE_ENV === 'development' && time) time`use-state`
289
289
 
290
290
  let isAnimated = willBeAnimated
291
291
 
@@ -311,7 +311,7 @@ export function createComponent<
311
311
  const languageContext = useContext(FontLanguageContext)
312
312
  const isDisabled = props.disabled ?? props.accessibilityState?.disabled
313
313
 
314
- // if (shouldTime) time`use-context`
314
+ if (process.env.NODE_ENV === 'development' && time) time`use-context`
315
315
 
316
316
  const isTaggable = !Component || typeof Component === 'string'
317
317
  // default to tag, fallback to component (when both strings)
@@ -353,7 +353,7 @@ export function createComponent<
353
353
  const disableThemeProp = props['data-disable-theme']
354
354
  const disableTheme = (disableThemeProp && !willBeAnimated) || isHOC
355
355
 
356
- // if (shouldTime) time`theme-props`
356
+ if (process.env.NODE_ENV === 'development' && time) time`theme-props`
357
357
 
358
358
  const themeStateProps = {
359
359
  name: props.theme,
@@ -374,9 +374,11 @@ export function createComponent<
374
374
  if (process.env.NODE_ENV === 'development') {
375
375
  const id = useId()
376
376
 
377
- if (debugProp) {
377
+ if (debugProp && debugProp !== 'profile') {
378
378
  // prettier-ignore
379
- const name = `${componentName || Component?.displayName || Component?.name || '[Unnamed Component]'}`
379
+ const name = `${
380
+ componentName || Component?.displayName || Component?.name || "[Unnamed Component]"
381
+ }`;
380
382
  const type = isAnimatedReactNative ? '(animated)' : isReactNative ? '(rnw)' : ''
381
383
  const dataIs = propsIn['data-is'] || ''
382
384
  const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type} id ${id}`
@@ -394,20 +396,35 @@ export function createComponent<
394
396
  )
395
397
  // prettier-ignore
396
398
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
397
- console.log({ propsIn, props, state, staticConfig, elementType, themeStateProps, styledContext: { contextProps: styledContextProps, overriddenContextProps }, presence, isAnimated, isHOC, hasAnimationProp, useAnimations, propsInOrder: Object.keys(propsIn), propsOrder: Object.keys(props) })
399
+ console.log({
400
+ propsIn,
401
+ props,
402
+ state,
403
+ staticConfig,
404
+ elementType,
405
+ themeStateProps,
406
+ styledContext: { contextProps: styledContextProps, overriddenContextProps },
407
+ presence,
408
+ isAnimated,
409
+ isHOC,
410
+ hasAnimationProp,
411
+ useAnimations,
412
+ propsInOrder: Object.keys(propsIn),
413
+ propsOrder: Object.keys(props),
414
+ });
398
415
  console.groupEnd()
399
416
  }
400
417
  }
401
418
  }
402
419
 
403
- // if (shouldTime) time`pre-theme-media`
420
+ if (process.env.NODE_ENV === 'development' && time) time`pre-theme-media`
404
421
 
405
422
  const [themeState, theme] = useThemeWithState(themeStateProps)
406
423
 
407
424
  elementType = Component || elementType
408
425
  const isStringElement = typeof elementType === 'string'
409
426
 
410
- // if (shouldTime) time`theme`
427
+ if (process.env.NODE_ENV === 'development' && time) time`theme`
411
428
 
412
429
  const mediaState = useMedia(
413
430
  // @ts-ignore, we just pass a stable object so we can get it later with
@@ -415,7 +432,7 @@ export function createComponent<
415
432
  stateRef
416
433
  )
417
434
 
418
- // if (shouldTime) time`media`
435
+ if (process.env.NODE_ENV === 'development' && time) time`media`
419
436
 
420
437
  setDidGetVariableValue(false)
421
438
 
@@ -452,13 +469,13 @@ export function createComponent<
452
469
  debugProp
453
470
  )
454
471
 
455
- // if (shouldTime) time`split-styles`
472
+ if (process.env.NODE_ENV === 'development' && time) time`split-styles`
456
473
 
457
474
  stateRef.current.isListeningToTheme = splitStyles.dynamicThemeAccess
458
475
 
459
476
  // only listen for changes if we are using raw theme values or media space, or dynamic media (native)
460
477
  // array = space media breakpoints
461
- const isMediaArray = Array.isArray(splitStyles.hasMedia)
478
+ const isMediaArray = splitStyles.hasMedia && Array.isArray(splitStyles.hasMedia)
462
479
  const shouldListenForMedia =
463
480
  didGetVariableValue() ||
464
481
  isMediaArray ||
@@ -480,11 +497,11 @@ export function createComponent<
480
497
  )
481
498
  }
482
499
 
483
- if (debugProp) {
500
+ if (debugProp && debugProp !== 'profile') {
484
501
  console.groupCollapsed('>>>')
485
502
  // prettier-ignore
486
503
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
487
- console.log('props in', propsIn, 'mapped to', props, 'in order', Object.keys(props))
504
+ console.log("props in", propsIn, "mapped to", props, "in order", Object.keys(props));
488
505
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
489
506
  console.log('splitStyles', splitStyles)
490
507
  // rome-ignore lint/nursery/noConsoleLog: ok
@@ -535,6 +552,8 @@ export function createComponent<
535
552
  if (isAnimated && animations) {
536
553
  animationStyles = animations.style
537
554
  }
555
+
556
+ if (process.env.NODE_ENV === 'development' && time) time`animations`
538
557
  }
539
558
 
540
559
  const {
@@ -565,7 +584,7 @@ export function createComponent<
565
584
  ...nonTamaguiProps
566
585
  } = viewPropsIn
567
586
 
568
- // if (shouldTime) time`destructure`
587
+ if (process.env.NODE_ENV === 'development' && time) time`destructure`
569
588
 
570
589
  const disabled = props.accessibilityState?.disabled || props.accessibilityDisabled
571
590
 
@@ -604,7 +623,7 @@ export function createComponent<
604
623
  }
605
624
  }
606
625
 
607
- // if (shouldTime) time`events-hooks`
626
+ if (process.env.NODE_ENV === 'development' && time) time`events-hooks`
608
627
 
609
628
  const unPress = useCallback(() => {
610
629
  setStateShallow({
@@ -707,7 +726,7 @@ export function createComponent<
707
726
  (isWeb && noClassNames && 'hoverStyle' in props)
708
727
  )
709
728
 
710
- // if (shouldTime) time`events-setup`
729
+ if (process.env.NODE_ENV === 'development' && time) time`events-setup`
711
730
 
712
731
  const events: TamaguiComponentEvents | null =
713
732
  shouldAttach && !isDisabled && !asChild
@@ -789,7 +808,7 @@ export function createComponent<
789
808
  })
790
809
  }
791
810
 
792
- // if (shouldTime) time`events`
811
+ if (process.env.NODE_ENV === 'development' && time) time`events`
793
812
 
794
813
  if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {
795
814
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
@@ -806,7 +825,7 @@ export function createComponent<
806
825
 
807
826
  const direction = props.spaceDirection || 'both'
808
827
 
809
- // if (shouldTime) time`hooks`
828
+ if (process.env.NODE_ENV === 'development' && time) time`hooks`
810
829
 
811
830
  // since we re-render without changing children often for animations or on mount
812
831
  // we memo children here. tested this on the site homepage which has hundreds of components
@@ -878,7 +897,7 @@ export function createComponent<
878
897
  }
879
898
 
880
899
  if (process.env.NODE_ENV === 'development') {
881
- if (debugProp) {
900
+ if (debugProp && debugProp !== 'profile') {
882
901
  const element = typeof elementType === 'string' ? elementType : 'Component'
883
902
  console.groupCollapsed(`render <${element} /> with props`)
884
903
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
@@ -894,22 +913,45 @@ export function createComponent<
894
913
  if (typeof window !== 'undefined') {
895
914
  // prettier-ignore
896
915
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
897
- console.log({ state, styleProps, themeState, isAnimated, isAnimatedReactNativeWeb, defaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, willBeAnimated, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, pseudos, content, shouldAvoidClasses, animation: props.animation, style: splitStylesStyle, staticConfig, tamaguiConfig, shouldForcePseudo, elementType, initialState, classNames })
916
+ console.log({
917
+ state,
918
+ styleProps,
919
+ themeState,
920
+ isAnimated,
921
+ isAnimatedReactNativeWeb,
922
+ defaultProps,
923
+ viewProps,
924
+ splitStyles,
925
+ animationStyles,
926
+ handlesPressEvents,
927
+ willBeAnimated,
928
+ isStringElement,
929
+ classNamesIn: props.className?.split(" "),
930
+ classNamesOut: viewProps.className?.split(" "),
931
+ events,
932
+ shouldAttach,
933
+ pseudos,
934
+ content,
935
+ shouldAvoidClasses,
936
+ animation: props.animation,
937
+ style: splitStylesStyle,
938
+ staticConfig,
939
+ tamaguiConfig,
940
+ shouldForcePseudo,
941
+ elementType,
942
+ initialState,
943
+ classNames,
944
+ });
898
945
  }
899
946
  console.groupEnd()
900
947
  console.groupEnd()
901
948
  }
902
949
  }
903
950
 
904
- // if (shouldTime) {
905
- // time`rest`
906
- // setTimeout(() => {
907
- // if (!hasLogged) {
908
- // timer.print()
909
- // }
910
- // hasLogged = true
911
- // }, 1000)
912
- // }
951
+ if (process.env.NODE_ENV === 'development' && time) {
952
+ time`rest`
953
+ time.print()
954
+ }
913
955
 
914
956
  return content
915
957
  })
@@ -948,7 +990,8 @@ export function createComponent<
948
990
  const isForwardedRefAlready = Component.render?.length === 2
949
991
  const ComponentForwardedRef = isForwardedRefAlready
950
992
  ? (Component as any)
951
- : forwardRef(Component as any)
993
+ : // memo because theme changes otherwise would always re-render
994
+ memo(forwardRef(Component as any))
952
995
 
953
996
  const extendedConfig = extendStyledConfig()
954
997
  const out = themeable(ComponentForwardedRef, extendedConfig) as any
@@ -1,6 +1,5 @@
1
- import { getThemes, getTokens } from '../config'
1
+ import { getThemes } from '../config'
2
2
  import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'
3
- import { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'
4
3
  import { ThemeParsed, ThemeProps } from '../types'
5
4
 
6
5
  type ThemeListener = (
@@ -23,6 +22,7 @@ export type ThemeManagerState = {
23
22
  className?: string
24
23
  parentName?: string
25
24
  componentName?: string
25
+ inverse?: boolean
26
26
  }
27
27
 
28
28
  const emptyState: ThemeManagerState = { name: '' }
@@ -56,7 +56,7 @@ export class ThemeManager {
56
56
  `No parent manager given, this is likely due to duplicated Tamagui dependencies. Check your lockfile for mis-matched versions.`
57
57
  )
58
58
  }
59
- throw `❌`
59
+ throw `❌ 0`
60
60
  }
61
61
 
62
62
  // no change no props
@@ -311,6 +311,7 @@ function getState(
311
311
  className: getNextThemeClassName(found),
312
312
  parentName,
313
313
  componentName,
314
+ inverse: props.inverse,
314
315
  }
315
316
  break
316
317
  }
@@ -181,11 +181,24 @@ export const getSplitStyles: StyleSplitter = (
181
181
  debug,
182
182
  }
183
183
 
184
- if (process.env.NODE_ENV === 'development' && debug && isClient) {
184
+ if (
185
+ process.env.NODE_ENV === 'development' &&
186
+ debug &&
187
+ debug !== 'profile' &&
188
+ isClient
189
+ ) {
185
190
  console.groupCollapsed('getSplitStyles (collapsed)')
186
191
  // prettier-ignore
187
192
  // rome-ignore lint/nursery/noConsoleLog: ok
188
- console.log({ props, staticConfig, shouldDoClasses, styleProps, componentState, styleState, theme: { ...theme } })
193
+ console.log({
194
+ props,
195
+ staticConfig,
196
+ shouldDoClasses,
197
+ styleProps,
198
+ componentState,
199
+ styleState,
200
+ theme: { ...theme },
201
+ });
189
202
  console.groupEnd()
190
203
  }
191
204
 
@@ -526,7 +539,14 @@ export const getSplitStyles: StyleSplitter = (
526
539
  if (isClient) {
527
540
  // prettier-ignore
528
541
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
529
- console.log({ variants, variant: variants?.[keyInit], isVariant, isHOCShouldPassThrough, curProps: { ...styleState.curProps }, parentStaticConfig })
542
+ console.log({
543
+ variants,
544
+ variant: variants?.[keyInit],
545
+ isVariant,
546
+ isHOCShouldPassThrough,
547
+ curProps: { ...styleState.curProps },
548
+ parentStaticConfig,
549
+ });
530
550
  }
531
551
  console.groupEnd()
532
552
  }
@@ -598,7 +618,18 @@ export const getSplitStyles: StyleSplitter = (
598
618
  if (!isServer && isDevTools) {
599
619
  // prettier-ignore
600
620
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
601
- console.log({ expanded, styleProps, componentState, isVariant, variant: variants?.[keyInit], shouldPassProp, isHOCShouldPassThrough, theme, usedKeys: { ...usedKeys }, curProps: { ...styleState.curProps } })
621
+ console.log({
622
+ expanded,
623
+ styleProps,
624
+ componentState,
625
+ isVariant,
626
+ variant: variants?.[keyInit],
627
+ shouldPassProp,
628
+ isHOCShouldPassThrough,
629
+ theme,
630
+ usedKeys: { ...usedKeys },
631
+ curProps: { ...styleState.curProps },
632
+ });
602
633
  // rome-ignore lint/nursery/noConsoleLog: ok
603
634
  console.log('expanded', expanded, '\nusedKeys', { ...usedKeys }, '\ncurrent', {
604
635
  ...style,
@@ -687,10 +718,10 @@ export const getSplitStyles: StyleSplitter = (
687
718
 
688
719
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
689
720
  // prettier-ignore
690
- console.groupCollapsed('pseudo (classes)', key)
721
+ console.groupCollapsed("pseudo (classes)", key);
691
722
  // prettier-ignore
692
723
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
693
- console.log({ pseudoStyleObject, pseudoStyles })
724
+ console.log({ pseudoStyleObject, pseudoStyles });
694
725
  console.groupEnd()
695
726
  }
696
727
 
@@ -727,10 +758,16 @@ export const getSplitStyles: StyleSplitter = (
727
758
 
728
759
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
729
760
  // prettier-ignore
730
- console.groupCollapsed('pseudo', key, { isDisabled })
761
+ console.groupCollapsed("pseudo", key, { isDisabled });
731
762
  // prettier-ignore
732
763
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
733
- console.log(pseudoStyleObject, { isDisabled, descriptorKey, descriptor, pseudoState, state: { ...componentState } })
764
+ console.log(pseudoStyleObject, {
765
+ isDisabled,
766
+ descriptorKey,
767
+ descriptor,
768
+ pseudoState,
769
+ state: { ...componentState },
770
+ });
734
771
  console.groupEnd()
735
772
  }
736
773
 
@@ -759,7 +796,12 @@ export const getSplitStyles: StyleSplitter = (
759
796
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
760
797
  // prettier-ignore
761
798
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
762
- console.log(' subKey', pkey, shouldMerge, { importance, curImportance, pkey, val })
799
+ console.log(" subKey", pkey, shouldMerge, {
800
+ importance,
801
+ curImportance,
802
+ pkey,
803
+ val,
804
+ });
763
805
  }
764
806
  }
765
807
  }
@@ -806,7 +848,7 @@ export const getSplitStyles: StyleSplitter = (
806
848
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
807
849
  // prettier-ignore
808
850
  // rome-ignore lint/nursery/noConsoleLog: ok
809
- console.log(` 📺 ${key}`, { key, mediaStyle, props, shouldDoClasses })
851
+ console.log(` 📺 ${key}`, { key, val, mediaStyle, props, shouldDoClasses });
810
852
  }
811
853
 
812
854
  // for some reason 'space' in val upsetting next ssr during prod build
@@ -842,7 +884,7 @@ export const getSplitStyles: StyleSplitter = (
842
884
  }
843
885
  }
844
886
 
845
- const mediaStyles = getStylesAtomic(mediaStyle)
887
+ const mediaStyles = getStylesAtomic(mediaStyle, debug)
846
888
  const priority = mediaStylesSeen
847
889
  mediaStylesSeen += 1
848
890
 
@@ -1123,7 +1165,7 @@ export const getSplitStyles: StyleSplitter = (
1123
1165
  styleState.fontFamily = overrideFace
1124
1166
  }
1125
1167
  }
1126
- if (process.env.NODE_ENV === 'development' && debug) {
1168
+ if (process.env.NODE_ENV === 'development' && debug && debug !== 'profile') {
1127
1169
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
1128
1170
  console.log(`Found fontFamily native: ${style.fontFamily}`, faceInfo)
1129
1171
  }
@@ -1138,7 +1180,15 @@ export const getSplitStyles: StyleSplitter = (
1138
1180
  if (isDevTools) {
1139
1181
  console.groupCollapsed(' 🔹 ===>')
1140
1182
  // prettier-ignore
1141
- const logs = { ...result, componentState, transforms, viewProps, viewPropsOrder: Object.keys(viewProps), rulesToInsert, parentSplitStyles }
1183
+ const logs = {
1184
+ ...result,
1185
+ componentState,
1186
+ transforms,
1187
+ viewProps,
1188
+ viewPropsOrder: Object.keys(viewProps),
1189
+ rulesToInsert,
1190
+ parentSplitStyles,
1191
+ };
1142
1192
  for (const key in logs) {
1143
1193
  // rome-ignore lint/nursery/noConsoleLog: ok
1144
1194
  console.log(key, logs[key])
@@ -6,77 +6,55 @@
6
6
  import { StyleObject, simpleHash } from '@tamagui/helpers'
7
7
 
8
8
  import { getConfig } from '../config'
9
- import type { TamaguiInternalConfig, ViewStyleWithPseudos } from '../types'
9
+ import type { DebugProp, TamaguiInternalConfig, ViewStyleWithPseudos } from '../types'
10
10
  import { defaultOffset } from './defaultOffset'
11
11
  import { normalizeValueWithProperty } from './normalizeValueWithProperty'
12
- import { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors'
12
+ import {
13
+ PseudoDescriptor,
14
+ pseudoDescriptors,
15
+ pseudoDescriptorsBase,
16
+ } from './pseudoDescriptors'
13
17
 
14
18
  // refactor this file away next...
15
19
 
16
- // matching order of the below *0
17
- const pseudosOrdered = [
18
- pseudoDescriptors.hoverStyle,
19
- pseudoDescriptors.pressStyle,
20
- pseudoDescriptors.focusStyle,
21
- ]
22
-
23
- export function getStylesAtomic(stylesIn: ViewStyleWithPseudos) {
24
- // performance optimization
25
- if (!(stylesIn.hoverStyle || stylesIn.pressStyle || stylesIn.focusStyle)) {
26
- return generateAtomicStyles(stylesIn)
27
- }
28
-
29
- // only for pseudos
30
- const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn
20
+ export function getStylesAtomic(stylesIn: ViewStyleWithPseudos, debug?: DebugProp) {
31
21
  let res: StyleObject[] = []
32
- // *1 order matched to *0
33
- for (const [index, style] of [hoverStyle, pressStyle, focusStyle, base].entries()) {
34
- if (!style) continue
35
- const pseudo = pseudosOrdered[index]
36
- res = [...res, ...generateAtomicStyles(style, pseudo)]
22
+ for (const pseudoName in pseudoDescriptorsBase) {
23
+ const pseudoStyle = stylesIn[pseudoName]
24
+ if (pseudoStyle) {
25
+ res = [
26
+ ...res,
27
+ ...generateAtomicStyles(pseudoStyle, pseudoDescriptorsBase[pseudoName]),
28
+ ]
29
+ }
30
+ }
31
+ res = [...res, ...generateAtomicStyles(stylesIn)]
32
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
33
+ // rome-ignore lint/nursery/noConsoleLog: <explanation>
34
+ console.log(` 🪮 getStylesAtomic`, { stylesIn, res })
37
35
  }
38
36
  return res
39
37
  }
40
38
 
41
39
  let conf: TamaguiInternalConfig
42
40
 
41
+ // mutates...
42
+
43
43
  export const generateAtomicStyles = (
44
- styleIn: ViewStyleWithPseudos,
44
+ style: ViewStyleWithPseudos,
45
45
  pseudo?: PseudoDescriptor
46
46
  ): StyleObject[] => {
47
- if (!styleIn) return []
47
+ if (!style) return []
48
48
 
49
49
  conf = conf || getConfig()
50
50
 
51
- // were converting to css styles
52
- const style = { ...styleIn } as Record<string, string | null | undefined>
53
-
54
- // transform
55
- if ('transform' in style && Array.isArray(style.transform)) {
56
- style.transform = style.transform
57
- .map(
58
- // { scale: 2 } => 'scale(2)'
59
- // { translateX: 20 } => 'translateX(20px)'
60
- // { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
61
- (transform) => {
62
- const type = Object.keys(transform)[0]
63
- const value = transform[type]
64
- if (type === 'matrix' || type === 'matrix3d') {
65
- return `${type}(${value.join(',')})`
66
- }
67
- return `${type}(${normalizeValueWithProperty(value, type)})`
68
- }
69
- )
70
- .join(' ')
71
- }
72
-
73
51
  styleToCSS(style)
74
52
 
75
53
  const out: StyleObject[] = []
76
54
  for (const key in style) {
77
55
  const value = normalizeValueWithProperty(style[key], key)
78
- if (value == null || value == undefined) continue
79
-
56
+ if (key in pseudoDescriptors) continue
57
+ if (value == null) continue
80
58
  const hash = simpleHash(`${value}`)
81
59
  const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''
82
60
  const shortProp = conf.inverseShorthands[key] || key
@@ -96,6 +74,25 @@ export const generateAtomicStyles = (
96
74
  }
97
75
 
98
76
  export function styleToCSS(style: Record<string, any>) {
77
+ // transform
78
+ if ('transform' in style && Array.isArray(style.transform)) {
79
+ style.transform = style.transform
80
+ .map(
81
+ // { scale: 2 } => 'scale(2)'
82
+ // { translateX: 20 } => 'translateX(20px)'
83
+ // { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'
84
+ (transform) => {
85
+ const type = Object.keys(transform)[0]
86
+ const value = transform[type]
87
+ if (type === 'matrix' || type === 'matrix3d') {
88
+ return `${type}(${value.join(',')})`
89
+ }
90
+ return `${type}(${normalizeValueWithProperty(value, type)})`
91
+ }
92
+ )
93
+ .join(' ')
94
+ }
95
+
99
96
  // box-shadow
100
97
  const { shadowOffset, shadowRadius, shadowColor } = style
101
98
  if (style.shadowRadius) {
@@ -16,6 +16,8 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
16
16
  return value
17
17
  }
18
18
  let res = value
19
+ // shadowOffset etc
20
+ if (value && typeof value === 'object') return value
19
21
  if (typeof value === 'number') {
20
22
  res = `${value}px`
21
23
  } else if (property) {
@@ -42,9 +42,18 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
42
42
  const { variants } = staticConfig
43
43
 
44
44
  // prettier-ignore
45
- if (process.env.NODE_ENV === 'development' && fontFamily && fontFamily[0] === '$' && !(fontFamily in conf.fontsParsed)) {
45
+ if (
46
+ process.env.NODE_ENV === "development" &&
47
+ fontFamily &&
48
+ fontFamily[0] === "$" &&
49
+ !(fontFamily in conf.fontsParsed)
50
+ ) {
46
51
  // prettier-ignore
47
- console.warn(`Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys(conf.fontsParsed).join(', ')}`)
52
+ console.warn(
53
+ `Warning: no fontFamily "${fontFamily}" found in config: ${Object.keys(conf.fontsParsed).join(
54
+ ", ",
55
+ )}`,
56
+ );
48
57
  }
49
58
 
50
59
  if (variants && key in variants && value != null) {
@@ -1,9 +1,7 @@
1
1
  // *0 order matches to *1
2
2
 
3
- export const pseudoDescriptors: Record<
4
- 'hoverStyle' | 'pressStyle' | 'focusStyle' | 'enterStyle' | 'exitStyle',
5
- PseudoDescriptor
6
- > = {
3
+ export const pseudoDescriptorsBase = {
4
+ // order of keys here important! in priority order
7
5
  hoverStyle: {
8
6
  name: 'hover',
9
7
  priority: 1,
@@ -17,6 +15,13 @@ export const pseudoDescriptors: Record<
17
15
  name: 'focus',
18
16
  priority: 3,
19
17
  },
18
+ } as const
19
+
20
+ export const pseudoDescriptors: Record<
21
+ 'hoverStyle' | 'pressStyle' | 'focusStyle' | 'enterStyle' | 'exitStyle',
22
+ PseudoDescriptor
23
+ > = {
24
+ ...pseudoDescriptorsBase,
20
25
  enterStyle: {
21
26
  name: 'enter',
22
27
  stateKey: 'unmounted',