@tamagui/web 1.130.1 → 1.130.3

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 (51) hide show
  1. package/dist/cjs/createComponent.cjs +3 -3
  2. package/dist/cjs/createComponent.js +4 -5
  3. package/dist/cjs/createComponent.js.map +1 -1
  4. package/dist/cjs/createComponent.native.js +3 -4
  5. package/dist/cjs/createComponent.native.js.map +1 -1
  6. package/dist/cjs/hooks/useTheme.cjs +2 -2
  7. package/dist/cjs/hooks/useTheme.js +2 -2
  8. package/dist/cjs/hooks/useTheme.js.map +1 -1
  9. package/dist/cjs/hooks/useTheme.native.js +3 -3
  10. package/dist/cjs/hooks/useTheme.native.js.map +2 -2
  11. package/dist/cjs/hooks/useThemeState.cjs +3 -1
  12. package/dist/cjs/hooks/useThemeState.js +1 -1
  13. package/dist/cjs/hooks/useThemeState.js.map +1 -1
  14. package/dist/cjs/hooks/useThemeState.native.js +3 -1
  15. package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
  16. package/dist/cjs/views/Theme.cjs +3 -3
  17. package/dist/cjs/views/Theme.js +2 -2
  18. package/dist/cjs/views/Theme.js.map +1 -1
  19. package/dist/cjs/views/Theme.native.js +2 -2
  20. package/dist/cjs/views/Theme.native.js.map +1 -1
  21. package/dist/esm/createComponent.js +4 -5
  22. package/dist/esm/createComponent.js.map +1 -1
  23. package/dist/esm/createComponent.mjs +3 -3
  24. package/dist/esm/createComponent.mjs.map +1 -1
  25. package/dist/esm/createComponent.native.js +3 -3
  26. package/dist/esm/createComponent.native.js.map +1 -1
  27. package/dist/esm/hooks/useTheme.js +2 -2
  28. package/dist/esm/hooks/useTheme.js.map +1 -1
  29. package/dist/esm/hooks/useTheme.mjs +2 -2
  30. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  31. package/dist/esm/hooks/useTheme.native.js +3 -3
  32. package/dist/esm/hooks/useTheme.native.js.map +1 -1
  33. package/dist/esm/hooks/useThemeState.js +1 -1
  34. package/dist/esm/hooks/useThemeState.js.map +1 -1
  35. package/dist/esm/hooks/useThemeState.mjs +3 -1
  36. package/dist/esm/hooks/useThemeState.mjs.map +1 -1
  37. package/dist/esm/hooks/useThemeState.native.js +3 -1
  38. package/dist/esm/hooks/useThemeState.native.js.map +1 -1
  39. package/dist/esm/views/Theme.js +2 -2
  40. package/dist/esm/views/Theme.js.map +1 -1
  41. package/dist/esm/views/Theme.mjs +3 -3
  42. package/dist/esm/views/Theme.mjs.map +1 -1
  43. package/dist/esm/views/Theme.native.js +3 -3
  44. package/dist/esm/views/Theme.native.js.map +1 -1
  45. package/package.json +12 -12
  46. package/src/createComponent.tsx +77 -80
  47. package/src/hooks/useTheme.tsx +2 -2
  48. package/src/hooks/useThemeState.ts +1 -1
  49. package/src/views/Theme.tsx +4 -2
  50. package/types/createComponent.d.ts.map +1 -1
  51. package/types/views/Theme.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.130.1",
3
+ "version": "1.130.3",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,16 +27,16 @@
27
27
  "reset.css"
28
28
  ],
29
29
  "dependencies": {
30
- "@tamagui/compose-refs": "1.130.1",
31
- "@tamagui/constants": "1.130.1",
32
- "@tamagui/helpers": "1.130.1",
33
- "@tamagui/is-equal-shallow": "1.130.1",
34
- "@tamagui/normalize-css-color": "1.130.1",
35
- "@tamagui/timer": "1.130.1",
36
- "@tamagui/types": "1.130.1",
37
- "@tamagui/use-did-finish-ssr": "1.130.1",
38
- "@tamagui/use-event": "1.130.1",
39
- "@tamagui/use-force-update": "1.130.1"
30
+ "@tamagui/compose-refs": "1.130.3",
31
+ "@tamagui/constants": "1.130.3",
32
+ "@tamagui/helpers": "1.130.3",
33
+ "@tamagui/is-equal-shallow": "1.130.3",
34
+ "@tamagui/normalize-css-color": "1.130.3",
35
+ "@tamagui/timer": "1.130.3",
36
+ "@tamagui/types": "1.130.3",
37
+ "@tamagui/use-did-finish-ssr": "1.130.3",
38
+ "@tamagui/use-event": "1.130.3",
39
+ "@tamagui/use-force-update": "1.130.3"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "*",
@@ -44,7 +44,7 @@
44
44
  "react-native": "*"
45
45
  },
46
46
  "devDependencies": {
47
- "@tamagui/build": "1.130.1",
47
+ "@tamagui/build": "1.130.3",
48
48
  "@testing-library/react": "^16.1.0",
49
49
  "csstype": "^3.0.10",
50
50
  "react": "*",
@@ -652,96 +652,93 @@ export function createComponent<
652
652
 
653
653
  // avoids re-rendering if animation driver supports it
654
654
  // TODO believe we need to set some sort of "pendingState" in case it re-renders
655
- if (splitStyles) {
656
- if ((!hasAnimationProp || groupName) && animationDriver?.avoidReRenders) {
657
- const useStyleListener = stateRef.current.useStyleListener
658
- const ogSetStateShallow = setStateShallow
659
-
660
- stateRef.current.setStateShallow = (nextOrGetNext) => {
661
- const prev = NextState.get(stateRef) || state
662
- const next =
663
- typeof nextOrGetNext === 'function' ? nextOrGetNext(prev) : nextOrGetNext
664
-
665
- if (next === prev || isEqualShallow(prev, next)) {
666
- return
667
- }
655
+ if (
656
+ splitStyles &&
657
+ (hasAnimationProp || groupName) &&
658
+ animationDriver?.avoidReRenders
659
+ ) {
660
+ const useStyleListener = stateRef.current.useStyleListener
661
+ const ogSetStateShallow = setStateShallow
668
662
 
669
- // one thing we have to handle here and where it gets a bit more complex is group styles
670
- const canAvoidReRender = Object.keys(next).every((key) =>
671
- avoidReRenderKeys.has(key)
672
- )
663
+ stateRef.current.setStateShallow = (nextOrGetNext) => {
664
+ const prev = NextState.get(stateRef) || state
665
+ const next =
666
+ typeof nextOrGetNext === 'function' ? nextOrGetNext(prev) : nextOrGetNext
673
667
 
674
- if (canAvoidReRender) {
675
- const updatedState = {
676
- ...prev,
677
- ...next,
678
- }
679
- NextState.set(stateRef, updatedState)
680
-
681
- if (
682
- process.env.NODE_ENV === 'development' &&
683
- debugProp &&
684
- debugProp !== 'profile'
685
- ) {
686
- console.groupCollapsed(`[⚡️] avoid setState`, next, { updatedState, props })
687
- console.info(stateRef.current.host)
688
- console.groupEnd()
689
- }
668
+ if (next === prev || isEqualShallow(prev, next)) {
669
+ return
670
+ }
690
671
 
691
- const {
692
- group,
693
- hasDynGroupChildren,
694
- unmounted,
695
- animation,
696
- ...childrenGroupState
697
- } = updatedState
698
-
699
- // update before getting styles
700
- if (groupContext) {
701
- notifyGroupSubscribers(
702
- groupContext,
703
- stateRef.current.group || null,
704
- childrenGroupState
705
- )
706
- }
672
+ // one thing we have to handle here and where it gets a bit more complex is group styles
673
+ const canAvoidReRender = Object.keys(next).every((key) =>
674
+ avoidReRenderKeys.has(key)
675
+ )
707
676
 
708
- // we just emit and return for group without animation ^
709
- if (!hasAnimationProp || !useStyleListener) {
710
- return
711
- }
677
+ if (canAvoidReRender) {
678
+ const updatedState = {
679
+ ...prev,
680
+ ...next,
681
+ }
682
+ NextState.set(stateRef, updatedState)
683
+
684
+ if (
685
+ process.env.NODE_ENV === 'development' &&
686
+ debugProp &&
687
+ debugProp !== 'profile'
688
+ ) {
689
+ console.groupCollapsed(`[⚡️] avoid setState`, next, { updatedState, props })
690
+ console.info(stateRef.current.host)
691
+ console.groupEnd()
692
+ }
712
693
 
713
- const nextStyles = getSplitStyles(
714
- props,
715
- staticConfig,
716
- theme,
717
- themeName,
718
- updatedState,
719
- styleProps,
720
- null,
721
- componentContext,
722
- allGroupContexts,
723
- elementType,
724
- startedUnhydrated,
725
- debugProp
694
+ const {
695
+ group,
696
+ hasDynGroupChildren,
697
+ unmounted,
698
+ animation,
699
+ ...childrenGroupState
700
+ } = updatedState
701
+
702
+ // update before getting styles
703
+ if (groupContext) {
704
+ notifyGroupSubscribers(
705
+ groupContext,
706
+ stateRef.current.group || null,
707
+ childrenGroupState
726
708
  )
709
+ }
727
710
 
728
- useStyleListener((nextStyles?.style || {}) as any)
729
- } else {
730
- if (
731
- process.env.NODE_ENV === 'development' &&
732
- debugProp &&
733
- debugProp !== 'profile'
734
- ) {
735
- console.info(`[🐌] re-render`, { canAvoidReRender, next })
736
- }
737
- ogSetStateShallow(next)
711
+ const nextStyles = getSplitStyles(
712
+ props,
713
+ staticConfig,
714
+ theme,
715
+ themeName,
716
+ updatedState,
717
+ styleProps,
718
+ null,
719
+ componentContext,
720
+ allGroupContexts,
721
+ elementType,
722
+ startedUnhydrated,
723
+ debugProp
724
+ )
725
+
726
+ useStyleListener?.((nextStyles?.style || {}) as any)
727
+ } else {
728
+ if (
729
+ process.env.NODE_ENV === 'development' &&
730
+ debugProp &&
731
+ debugProp !== 'profile'
732
+ ) {
733
+ console.info(`[🐌] re-render`, { canAvoidReRender, next })
738
734
  }
735
+ ogSetStateShallow(next)
739
736
  }
737
+ }
740
738
 
741
- // needs to capture latest props (it's called from memoized `events`)
742
- setStateShallow = (state) => {
743
- stateRef.current.setStateShallow?.(state)
744
- }
739
+ // needs to capture latest props (it's called from memoized `events`)
740
+ setStateShallow = (state) => {
741
+ stateRef.current.setStateShallow?.(state)
745
742
  }
746
743
  }
747
744
 
@@ -23,7 +23,7 @@ export const useThemeWithState = (
23
23
  const themeState = useThemeState(props, isRoot, keys)
24
24
 
25
25
  if (process.env.NODE_ENV === 'development') {
26
- if (!themeState?.theme) {
26
+ if (!props.passThrough && !themeState?.theme) {
27
27
  if (process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== '1') {
28
28
  console.error(
29
29
  `[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify(
@@ -34,7 +34,7 @@ export const useThemeWithState = (
34
34
  }
35
35
  }
36
36
 
37
- const themeProxied = getThemeProxied(props, themeState, keys)
37
+ const themeProxied = props.passThrough ? {} : getThemeProxied(props, themeState, keys)
38
38
 
39
39
  return [themeProxied, themeState]
40
40
  }
@@ -205,7 +205,7 @@ const getNextState = (
205
205
  const parentState = states.get(parentId)
206
206
 
207
207
  if (props.passThrough) {
208
- return [false, lastState ?? parentState!]
208
+ return [false, lastState || parentState || ({ name: '' } as any)]
209
209
  }
210
210
 
211
211
  if (!themes) {
@@ -141,7 +141,7 @@ export function getThemedChildren(
141
141
  }
142
142
 
143
143
  if (process.env.NODE_ENV === 'development') {
144
- if (props.debug) {
144
+ if (!passThrough && props.debug) {
145
145
  console.warn(` getThemedChildren`, {
146
146
  requiresExtraWrapper,
147
147
  forceClassName,
@@ -157,7 +157,9 @@ export function getThemedChildren(
157
157
  }
158
158
 
159
159
  if (isWeb) {
160
- const { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot)
160
+ const { className = '', style } = passThrough
161
+ ? {}
162
+ : getThemeClassNameAndStyle(themeState, props, isRoot)
161
163
 
162
164
  children = (
163
165
  <span
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAoBtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAG/E,OAAO,KAAK,EAGV,SAAS,EAMT,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAElB,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EAOf,MAAM,SAAS,CAAA;AAahB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AA8G9D,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,wEAo1C3B;AAoBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAA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../src/views/Theme.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,KAAqE,MAAM,OAAO,CAAA;AAIzF,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAK1C,eAAO,MAAM,KAAK;kBACoB,OAAO;iCA4C3C,CAAA;AAIF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,UAAU,EACjB,MAAM,qBAAQ,EACd,QAAQ,EAAE,gBAAgB,CAAC;IAAE,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC,EACnE,WAAW,UAAQ,OA0HpB"}