@tamagui/web 2.0.0-1768427228811 → 2.0.0-1768530912818

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 (41) hide show
  1. package/dist/cjs/_withStableStyle.cjs +5 -2
  2. package/dist/cjs/_withStableStyle.js +3 -3
  3. package/dist/cjs/_withStableStyle.js.map +1 -1
  4. package/dist/cjs/_withStableStyle.native.js +10 -2
  5. package/dist/cjs/_withStableStyle.native.js.map +1 -1
  6. package/dist/cjs/helpers/getDynamicVal.cjs +22 -1
  7. package/dist/cjs/helpers/getDynamicVal.js +22 -1
  8. package/dist/cjs/helpers/getDynamicVal.js.map +1 -1
  9. package/dist/cjs/helpers/getDynamicVal.native.js +22 -1
  10. package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
  11. package/dist/cjs/helpers/getSplitStyles.cjs +1 -19
  12. package/dist/cjs/helpers/getSplitStyles.js +2 -25
  13. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  14. package/dist/cjs/helpers/getSplitStyles.native.js +8 -4
  15. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  16. package/dist/esm/_withStableStyle.js +3 -2
  17. package/dist/esm/_withStableStyle.js.map +1 -1
  18. package/dist/esm/_withStableStyle.mjs +5 -2
  19. package/dist/esm/_withStableStyle.mjs.map +1 -1
  20. package/dist/esm/_withStableStyle.native.js +10 -2
  21. package/dist/esm/_withStableStyle.native.js.map +1 -1
  22. package/dist/esm/helpers/getDynamicVal.js +22 -1
  23. package/dist/esm/helpers/getDynamicVal.js.map +1 -1
  24. package/dist/esm/helpers/getDynamicVal.mjs +21 -1
  25. package/dist/esm/helpers/getDynamicVal.mjs.map +1 -1
  26. package/dist/esm/helpers/getDynamicVal.native.js +21 -1
  27. package/dist/esm/helpers/getDynamicVal.native.js.map +1 -1
  28. package/dist/esm/helpers/getSplitStyles.js +4 -32
  29. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  30. package/dist/esm/helpers/getSplitStyles.mjs +4 -22
  31. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  32. package/dist/esm/helpers/getSplitStyles.native.js +9 -5
  33. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  34. package/package.json +12 -12
  35. package/src/_withStableStyle.tsx +14 -1
  36. package/src/helpers/getDynamicVal.ts +35 -0
  37. package/src/helpers/getSplitStyles.tsx +34 -13
  38. package/types/_withStableStyle.d.ts.map +1 -1
  39. package/types/helpers/getDynamicVal.d.ts +4 -0
  40. package/types/helpers/getDynamicVal.d.ts.map +1 -1
  41. package/types/helpers/getSplitStyles.d.ts.map +1 -1
@@ -37,7 +37,6 @@ import type {
37
37
  GetStyleState,
38
38
  PseudoStyles,
39
39
  RulesToInsert,
40
- SpaceTokens,
41
40
  SplitStyleProps,
42
41
  StaticConfig,
43
42
  StyleObject,
@@ -54,6 +53,7 @@ import {
54
53
  extractValueFromDynamic,
55
54
  getDynamicVal,
56
55
  getOppositeScheme,
56
+ isColorStyleKey,
57
57
  } from './getDynamicVal'
58
58
  import { getGroupPropParts } from './getGroupPropParts'
59
59
  import { insertStyleRules, shouldInsertStyleRules, updateRules } from './insertStyleRule'
@@ -204,7 +204,6 @@ export const getSplitStyles: StyleSplitter = (
204
204
  const classNames: ClassNamesObject = {}
205
205
 
206
206
  let pseudos: PseudoStyles | null = null
207
- let space: SpaceTokens | null = props.space
208
207
  let hasMedia: boolean | Set<string> = false
209
208
  let dynamicThemeAccess: boolean | undefined
210
209
  let pseudoGroups: Set<string> | undefined
@@ -896,24 +895,44 @@ export const getSplitStyles: StyleSplitter = (
896
895
  let importanceBump = 0
897
896
 
898
897
  if (isThemeMedia) {
899
- // needed to get updates when theme changes
900
- dynamicThemeAccess = true
901
-
902
- if (isIos && getSetting('fastSchemeChange')) {
898
+ if (
899
+ process.env.TAMAGUI_TARGET === 'native' &&
900
+ isIos &&
901
+ getSetting('fastSchemeChange')
902
+ ) {
903
903
  // iOS will use https://reactnative.dev/docs/dynamiccolorios
904
- // So need to predefine the dynamic color before merging the styles
905
- // For example: <StyledYStack $theme-dark={{borderColor: '$red10'}} $theme-light={{borderColor: '$green10'}}> => {borderColor: {dynamic: {dark: '$red10', light: '$green10'}}}
904
+ // so need to predefine the dynamic color before merging the styles
905
+ // for example: <StyledYStack $theme-dark={{borderColor: '$red10'}} $theme-light={{borderColor: '$green10'}}> => {borderColor: {dynamic: {dark: '$red10', light: '$green10'}}}
906
906
 
907
907
  styleState.style ||= {}
908
908
  const scheme = mediaKeyShort
909
909
  const oppositeScheme = getOppositeScheme(mediaKeyShort)
910
910
  const themeOriginalValues = styleOriginalValues.get(mediaStyle)
911
+ const isCurrentScheme = themeName === scheme || themeName.startsWith(scheme)
911
912
 
912
913
  for (const subKey in mediaStyle) {
913
914
  const val = extractValueFromDynamic(mediaStyle[subKey], scheme)
914
915
  const existing = styleState.style[subKey]
915
916
 
916
- // If there's already a dynamic object from the other theme pseudo prop,
917
+ // Only color properties support DynamicColorIOS - non-color properties
918
+ // like opacity, dimensions, etc. will crash if wrapped with {dynamic: {...}}
919
+ // See: https://github.com/tamagui/tamagui/issues/3096
920
+ // See: https://github.com/tamagui/tamagui/issues/2980
921
+ if (!isColorStyleKey(subKey)) {
922
+ // non-color properties require re-render to update
923
+ dynamicThemeAccess = true
924
+ // only apply if this is the current theme
925
+ if (isCurrentScheme) {
926
+ // update mediastyle so the later merge loop uses correct value
927
+ mediaStyle[subKey] = val
928
+ } else {
929
+ // Remove from mediaStyle so it doesn't get merged with wrong theme's value
930
+ delete mediaStyle[subKey]
931
+ }
932
+ continue
933
+ }
934
+
935
+ // if there's already a dynamic object from the other theme pseudo prop,
917
936
  // merge directly to avoid importance conflicts between $theme-dark and $theme-light
918
937
  if (existing?.dynamic) {
919
938
  existing.dynamic[scheme] = val
@@ -935,10 +954,12 @@ export const getSplitStyles: StyleSplitter = (
935
954
  )
936
955
  }
937
956
  }
938
- } else if (
939
- !(themeName === mediaKeyShort || themeName.startsWith(mediaKeyShort))
940
- ) {
941
- return
957
+ } else {
958
+ // non-ios or no fastschemechange - need re-renders for theme changes
959
+ dynamicThemeAccess = true
960
+ if (!(themeName === mediaKeyShort || themeName.startsWith(mediaKeyShort))) {
961
+ return
962
+ }
942
963
  }
943
964
  } else if (isGroupMedia) {
944
965
  const groupInfo = getGroupPropParts(mediaKeyShort)
@@ -1 +1 @@
1
- {"version":3,"file":"_withStableStyle.d.ts","sourceRoot":"","sources":["../src/_withStableStyle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,4DAA4D;AAE5D,eAAO,MAAM,gBAAgB,GAC3B,WAAW,GAAG,EACd,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,MAAM,qFAMvD,CAAA"}
1
+ {"version":3,"file":"_withStableStyle.d.ts","sourceRoot":"","sources":["../src/_withStableStyle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,4DAA4D;AAE5D,eAAO,MAAM,gBAAgB,GAC3B,WAAW,GAAG,EACd,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,MAAM,qFAkBvD,CAAA"}
@@ -1,4 +1,8 @@
1
1
  export declare function getOppositeScheme(scheme: string): "light" | "dark";
2
+ /**
3
+ * Check if a style key is a color property that supports DynamicColorIOS.
4
+ */
5
+ export declare function isColorStyleKey(key: string): boolean;
2
6
  export declare function getDynamicVal({ scheme, val, oppositeVal, }: {
3
7
  scheme: string;
4
8
  val: string;
@@ -1 +1 @@
1
- {"version":3,"file":"getDynamicVal.d.ts","sourceRoot":"","sources":["../../src/helpers/getDynamicVal.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,oBAE/C;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;;EAQtD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAK/D"}
1
+ {"version":3,"file":"getDynamicVal.d.ts","sourceRoot":"","sources":["../../src/helpers/getDynamicVal.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,oBAE/C;AA8BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;;;EAQtD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAK/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,EAIb,eAAe,EACf,YAAY,EAEZ,qBAAqB,EAErB,SAAS,EACT,WAAW,EAEZ,MAAM,UAAU,CAAA;AAyBjB,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAOhE,eAAO,MAAM,mBAAmB,sCAA6C,CAAA;AAE7E,KAAK,aAAa,GAAG,CACnB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC7B,YAAY,EAAE,YAAY,EAC1B,KAAK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