@tamagui/web 1.105.1 → 1.105.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 (180) hide show
  1. package/dist/cjs/config.js +7 -1
  2. package/dist/cjs/config.js.map +1 -1
  3. package/dist/cjs/config.native.js +11 -1
  4. package/dist/cjs/config.native.js.map +2 -2
  5. package/dist/cjs/createComponent.js +16 -11
  6. package/dist/cjs/createComponent.js.map +1 -1
  7. package/dist/cjs/createComponent.native.js +16 -14
  8. package/dist/cjs/createComponent.native.js.map +2 -2
  9. package/dist/cjs/createTamagui.js +3 -3
  10. package/dist/cjs/createTamagui.js.map +1 -1
  11. package/dist/cjs/createTamagui.native.js +4 -3
  12. package/dist/cjs/createTamagui.native.js.map +2 -2
  13. package/dist/cjs/helpers/createMediaStyle.js +1 -1
  14. package/dist/cjs/helpers/createMediaStyle.js.map +1 -1
  15. package/dist/cjs/helpers/createMediaStyle.native.js +1 -1
  16. package/dist/cjs/helpers/createMediaStyle.native.js.map +2 -2
  17. package/dist/cjs/helpers/createShallowSetState.js +1 -1
  18. package/dist/cjs/helpers/createShallowSetState.native.js +1 -1
  19. package/dist/cjs/helpers/createShallowSetState.native.js.map +1 -1
  20. package/dist/cjs/helpers/getSplitStyles.js +35 -18
  21. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  22. package/dist/cjs/helpers/getSplitStyles.native.js +25 -17
  23. package/dist/cjs/helpers/getSplitStyles.native.js.map +2 -2
  24. package/dist/cjs/helpers/getThemeCSSRules.js +7 -6
  25. package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
  26. package/dist/cjs/helpers/log.js +9 -2
  27. package/dist/cjs/helpers/log.js.map +1 -1
  28. package/dist/cjs/helpers/log.native.js +10 -4
  29. package/dist/cjs/helpers/log.native.js.map +2 -2
  30. package/dist/cjs/helpers/propMapper.js +4 -3
  31. package/dist/cjs/helpers/propMapper.js.map +1 -1
  32. package/dist/cjs/helpers/propMapper.native.js +4 -3
  33. package/dist/cjs/helpers/propMapper.native.js.map +2 -2
  34. package/dist/cjs/hooks/useDisableSSR.js +1 -1
  35. package/dist/cjs/hooks/useDisableSSR.js.map +1 -1
  36. package/dist/cjs/hooks/useDisableSSR.native.js +1 -1
  37. package/dist/cjs/hooks/useDisableSSR.native.js.map +2 -2
  38. package/dist/cjs/hooks/useMedia.js +22 -3
  39. package/dist/cjs/hooks/useMedia.js.map +1 -1
  40. package/dist/cjs/hooks/useMedia.native.js +43 -6
  41. package/dist/cjs/hooks/useMedia.native.js.map +2 -2
  42. package/dist/cjs/hooks/useTheme.js +12 -5
  43. package/dist/cjs/hooks/useTheme.js.map +1 -1
  44. package/dist/cjs/hooks/useTheme.native.js +19 -8
  45. package/dist/cjs/hooks/useTheme.native.js.map +2 -2
  46. package/dist/cjs/views/TamaguiProvider.js +3 -3
  47. package/dist/cjs/views/TamaguiProvider.js.map +1 -1
  48. package/dist/cjs/views/TamaguiProvider.native.js +3 -3
  49. package/dist/cjs/views/TamaguiProvider.native.js.map +2 -2
  50. package/dist/cjs/views/ThemeProvider.js +2 -2
  51. package/dist/cjs/views/ThemeProvider.js.map +1 -1
  52. package/dist/cjs/views/ThemeProvider.native.js +2 -2
  53. package/dist/cjs/views/ThemeProvider.native.js.map +2 -2
  54. package/dist/cjs/views/html.js +1 -0
  55. package/dist/cjs/views/html.js.map +6 -0
  56. package/dist/cjs/views/html.native.js +2 -0
  57. package/dist/cjs/views/html.native.js.map +6 -0
  58. package/dist/esm/config.js +7 -1
  59. package/dist/esm/config.js.map +1 -1
  60. package/dist/esm/config.mjs +8 -2
  61. package/dist/esm/config.mjs.map +1 -1
  62. package/dist/esm/config.native.js +10 -1
  63. package/dist/esm/config.native.js.map +2 -2
  64. package/dist/esm/createComponent.js +20 -11
  65. package/dist/esm/createComponent.js.map +1 -1
  66. package/dist/esm/createComponent.mjs +16 -10
  67. package/dist/esm/createComponent.mjs.map +1 -1
  68. package/dist/esm/createComponent.native.js +16 -14
  69. package/dist/esm/createComponent.native.js.map +2 -2
  70. package/dist/esm/createTamagui.js +3 -3
  71. package/dist/esm/createTamagui.js.map +1 -1
  72. package/dist/esm/createTamagui.mjs +3 -3
  73. package/dist/esm/createTamagui.mjs.map +1 -1
  74. package/dist/esm/createTamagui.native.js +4 -3
  75. package/dist/esm/createTamagui.native.js.map +2 -2
  76. package/dist/esm/helpers/createMediaStyle.js +2 -2
  77. package/dist/esm/helpers/createMediaStyle.js.map +1 -1
  78. package/dist/esm/helpers/createMediaStyle.mjs +2 -2
  79. package/dist/esm/helpers/createMediaStyle.mjs.map +1 -1
  80. package/dist/esm/helpers/createMediaStyle.native.js +2 -2
  81. package/dist/esm/helpers/createMediaStyle.native.js.map +2 -2
  82. package/dist/esm/helpers/createShallowSetState.js +1 -1
  83. package/dist/esm/helpers/createShallowSetState.mjs +1 -1
  84. package/dist/esm/helpers/createShallowSetState.mjs.map +1 -1
  85. package/dist/esm/helpers/createShallowSetState.native.js +1 -1
  86. package/dist/esm/helpers/createShallowSetState.native.js.map +1 -1
  87. package/dist/esm/helpers/getSplitStyles.js +35 -18
  88. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  89. package/dist/esm/helpers/getSplitStyles.mjs +29 -19
  90. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  91. package/dist/esm/helpers/getSplitStyles.native.js +25 -17
  92. package/dist/esm/helpers/getSplitStyles.native.js.map +2 -2
  93. package/dist/esm/helpers/getThemeCSSRules.js +7 -5
  94. package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
  95. package/dist/esm/helpers/getThemeCSSRules.mjs +7 -5
  96. package/dist/esm/helpers/getThemeCSSRules.mjs.map +1 -1
  97. package/dist/esm/helpers/log.js +9 -2
  98. package/dist/esm/helpers/log.js.map +1 -1
  99. package/dist/esm/helpers/log.mjs +9 -1
  100. package/dist/esm/helpers/log.mjs.map +1 -1
  101. package/dist/esm/helpers/log.native.js +10 -4
  102. package/dist/esm/helpers/log.native.js.map +2 -2
  103. package/dist/esm/helpers/propMapper.js +4 -3
  104. package/dist/esm/helpers/propMapper.js.map +1 -1
  105. package/dist/esm/helpers/propMapper.mjs +8 -8
  106. package/dist/esm/helpers/propMapper.mjs.map +1 -1
  107. package/dist/esm/helpers/propMapper.native.js +4 -3
  108. package/dist/esm/helpers/propMapper.native.js.map +2 -2
  109. package/dist/esm/hooks/useDisableSSR.js +2 -2
  110. package/dist/esm/hooks/useDisableSSR.js.map +1 -1
  111. package/dist/esm/hooks/useDisableSSR.mjs +2 -2
  112. package/dist/esm/hooks/useDisableSSR.mjs.map +1 -1
  113. package/dist/esm/hooks/useDisableSSR.native.js +2 -2
  114. package/dist/esm/hooks/useDisableSSR.native.js.map +2 -2
  115. package/dist/esm/hooks/useMedia.js +23 -4
  116. package/dist/esm/hooks/useMedia.js.map +1 -1
  117. package/dist/esm/hooks/useMedia.mjs +21 -8
  118. package/dist/esm/hooks/useMedia.mjs.map +1 -1
  119. package/dist/esm/hooks/useMedia.native.js +42 -7
  120. package/dist/esm/hooks/useMedia.native.js.map +2 -2
  121. package/dist/esm/hooks/useTheme.js +13 -6
  122. package/dist/esm/hooks/useTheme.js.map +1 -1
  123. package/dist/esm/hooks/useTheme.mjs +12 -5
  124. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  125. package/dist/esm/hooks/useTheme.native.js +20 -9
  126. package/dist/esm/hooks/useTheme.native.js.map +2 -2
  127. package/dist/esm/views/TamaguiProvider.js +3 -2
  128. package/dist/esm/views/TamaguiProvider.js.map +1 -1
  129. package/dist/esm/views/TamaguiProvider.mjs +3 -2
  130. package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
  131. package/dist/esm/views/TamaguiProvider.native.js +3 -2
  132. package/dist/esm/views/TamaguiProvider.native.js.map +2 -2
  133. package/dist/esm/views/ThemeProvider.js +2 -1
  134. package/dist/esm/views/ThemeProvider.js.map +1 -1
  135. package/dist/esm/views/ThemeProvider.mjs +2 -1
  136. package/dist/esm/views/ThemeProvider.mjs.map +1 -1
  137. package/dist/esm/views/ThemeProvider.native.js +2 -1
  138. package/dist/esm/views/ThemeProvider.native.js.map +2 -2
  139. package/dist/esm/views/html.js +1 -0
  140. package/dist/esm/views/html.js.map +6 -0
  141. package/dist/esm/views/html.mjs +2 -0
  142. package/dist/esm/views/html.mjs.map +1 -0
  143. package/dist/esm/views/html.native.js +1 -0
  144. package/dist/esm/views/html.native.js.map +6 -0
  145. package/package.json +11 -11
  146. package/src/config.ts +14 -0
  147. package/src/createComponent.tsx +25 -19
  148. package/src/createTamagui.ts +5 -3
  149. package/src/helpers/createMediaStyle.ts +2 -2
  150. package/src/helpers/createShallowSetState.tsx +1 -1
  151. package/src/helpers/getSplitStyles.tsx +45 -15
  152. package/src/helpers/getThemeCSSRules.ts +7 -5
  153. package/src/helpers/log.ts +12 -5
  154. package/src/helpers/propMapper.ts +4 -3
  155. package/src/hooks/useDisableSSR.tsx +2 -2
  156. package/src/hooks/useMedia.tsx +30 -4
  157. package/src/hooks/useTheme.tsx +21 -4
  158. package/src/types.tsx +92 -15
  159. package/src/views/TamaguiProvider.tsx +7 -2
  160. package/src/views/ThemeProvider.tsx +6 -1
  161. package/types/config.d.ts +2 -1
  162. package/types/config.d.ts.map +1 -1
  163. package/types/createComponent.d.ts.map +1 -1
  164. package/types/createTamagui.d.ts.map +1 -1
  165. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  166. package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
  167. package/types/helpers/log.d.ts.map +1 -1
  168. package/types/helpers/propMapper.d.ts.map +1 -1
  169. package/types/hooks/useConfiguration.d.ts +2 -41
  170. package/types/hooks/useConfiguration.d.ts.map +1 -1
  171. package/types/hooks/useMedia.d.ts +3 -1
  172. package/types/hooks/useMedia.d.ts.map +1 -1
  173. package/types/hooks/useTheme.d.ts.map +1 -1
  174. package/types/types.d.ts +82 -12
  175. package/types/types.d.ts.map +1 -1
  176. package/types/views/TamaguiProvider.d.ts.map +1 -1
  177. package/types/views/ThemeProvider.d.ts +1 -0
  178. package/types/views/ThemeProvider.d.ts.map +1 -1
  179. package/types/views/html.d.ts +1 -0
  180. package/types/views/html.d.ts.map +1 -0
@@ -72,6 +72,8 @@ import { pseudoDescriptors, pseudoPriorities } from './pseudoDescriptors'
72
72
  import { skipProps } from './skipProps'
73
73
  import { transformsToString } from './transformsToString'
74
74
 
75
+ const consoleGroupCollapsed = isWeb ? console.groupCollapsed : console.info
76
+
75
77
  export type SplitStyles = ReturnType<typeof getSplitStyles>
76
78
 
77
79
  export type SplitStyleResult = ReturnType<typeof getSplitStyles>
@@ -218,7 +220,7 @@ export const getSplitStyles: StyleSplitter = (
218
220
  debug !== 'profile' &&
219
221
  isClient
220
222
  ) {
221
- console.groupCollapsed('getSplitStyles (collapsed)')
223
+ consoleGroupCollapsed('getSplitStyles (collapsed)')
222
224
  log({
223
225
  props,
224
226
  staticConfig,
@@ -536,7 +538,7 @@ export const getSplitStyles: StyleSplitter = (
536
538
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
537
539
  console.groupEnd() // react native was not nesting right
538
540
  console.groupEnd() // react native was not nesting right
539
- console.groupCollapsed(
541
+ consoleGroupCollapsed(
540
542
  ` 🔑 ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ''} ${
541
543
  shouldPassThrough ? '(pass)' : ''
542
544
  }`
@@ -620,7 +622,7 @@ export const getSplitStyles: StyleSplitter = (
620
622
  }
621
623
 
622
624
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
623
- console.groupCollapsed(' 💠 expanded', keyInit, valInit)
625
+ consoleGroupCollapsed(' 💠 expanded', keyInit, valInit)
624
626
  try {
625
627
  if (!isServer && isDevTools) {
626
628
  log({
@@ -631,7 +633,6 @@ export const getSplitStyles: StyleSplitter = (
631
633
  variant: variants?.[keyInit],
632
634
  shouldPassProp,
633
635
  isHOCShouldPassThrough,
634
- theme,
635
636
  usedKeys: { ...usedKeys },
636
637
  curProps: { ...styleState.curProps },
637
638
  })
@@ -682,7 +683,7 @@ export const getSplitStyles: StyleSplitter = (
682
683
  if (shouldPassThrough) {
683
684
  passDownProp(viewProps, key, val, isMediaOrPseudo)
684
685
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
685
- console.groupCollapsed(` - passing down prop ${key}`)
686
+ consoleGroupCollapsed(` - passing down prop ${key}`)
686
687
  log({ val, after: { ...viewProps[key] } })
687
688
  console.groupEnd()
688
689
  }
@@ -725,7 +726,7 @@ export const getSplitStyles: StyleSplitter = (
725
726
 
726
727
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
727
728
  // prettier-ignore
728
- console.groupCollapsed('pseudo (classes)', key)
729
+ consoleGroupCollapsed('pseudo (classes)', key)
729
730
 
730
731
  log({ pseudoStyleObject, pseudoStyles })
731
732
  console.groupEnd()
@@ -764,7 +765,7 @@ export const getSplitStyles: StyleSplitter = (
764
765
  }
765
766
 
766
767
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
767
- console.groupCollapsed('pseudo', key, { isDisabled })
768
+ consoleGroupCollapsed('pseudo', key, { isDisabled })
768
769
  log({ pseudoStyleObject, isDisabled, descriptor, componentState })
769
770
  console.groupEnd()
770
771
  }
@@ -953,7 +954,7 @@ export const getSplitStyles: StyleSplitter = (
953
954
  const groupContext = context?.groups.state[groupName]
954
955
  if (!groupContext) {
955
956
  if (process.env.NODE_ENV === 'development' && debug) {
956
- console.warn(`No parent with group prop, skipping styles: ${groupName}`)
957
+ log(`No parent with group prop, skipping styles: ${groupName}`)
957
958
  }
958
959
  continue
959
960
  }
@@ -971,6 +972,9 @@ export const getSplitStyles: StyleSplitter = (
971
972
  if (!mediaState && groupContext.layout) {
972
973
  isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)
973
974
  }
975
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
976
+ log(` 🏘️ GROUP media ${groupMediaKey} active? ${isActive}`)
977
+ }
974
978
  if (!isActive) continue
975
979
  importanceBump = 2
976
980
  }
@@ -984,8 +988,13 @@ export const getSplitStyles: StyleSplitter = (
984
988
  context.groups.state[groupName]
985
989
  ).pseudo
986
990
  const isActive = componentGroupPseudoState?.[groupPseudoKey]
987
- if (!isActive) continue
988
991
  const priority = pseudoPriorities[groupPseudoKey]
992
+ if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
993
+ log(
994
+ ` 🏘️ GROUP pseudo ${groupMediaKey} active? ${isActive}, priority ${priority}`
995
+ )
996
+ }
997
+ if (!isActive) continue
989
998
  importanceBump = priority
990
999
  }
991
1000
  }
@@ -1003,7 +1012,8 @@ export const getSplitStyles: StyleSplitter = (
1003
1012
  mediaStyle[subKey],
1004
1013
  usedKeys,
1005
1014
  mediaState[mediaKeyShort],
1006
- importanceBump
1015
+ importanceBump,
1016
+ debug
1007
1017
  )
1008
1018
  if (key === 'fontFamily') {
1009
1019
  styleState.fontFamily = mediaStyle.fontFamily as string
@@ -1158,7 +1168,7 @@ export const getSplitStyles: StyleSplitter = (
1158
1168
 
1159
1169
  if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {
1160
1170
  console.groupEnd() // ensure group ended from loop above
1161
- console.groupCollapsed(`🔹 getSplitStyles final style object`)
1171
+ consoleGroupCollapsed(`🔹 getSplitStyles final style object`)
1162
1172
  console.info(styleState.style)
1163
1173
  console.groupEnd()
1164
1174
  }
@@ -1172,7 +1182,7 @@ export const getSplitStyles: StyleSplitter = (
1172
1182
  for (const namespace in transforms) {
1173
1183
  if (!transforms[namespace]) {
1174
1184
  if (process.env.NODE_ENV === 'development') {
1175
- console.warn('Error no transform', transforms, namespace)
1185
+ log('Error no transform', transforms, namespace)
1176
1186
  }
1177
1187
  continue
1178
1188
  }
@@ -1365,7 +1375,7 @@ export const getSplitStyles: StyleSplitter = (
1365
1375
 
1366
1376
  if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
1367
1377
  if (isDevTools) {
1368
- console.groupCollapsed('🔹 getSplitStyles ===>')
1378
+ consoleGroupCollapsed('🔹 getSplitStyles ===>')
1369
1379
  try {
1370
1380
  // prettier-ignore
1371
1381
  const logs = {
@@ -1596,7 +1606,8 @@ function mergeMediaByImportance(
1596
1606
  value: any,
1597
1607
  importancesUsed: Record<string, number>,
1598
1608
  isSizeMedia: boolean,
1599
- importanceBump?: number
1609
+ importanceBump?: number,
1610
+ debugProp?: DebugProp
1600
1611
  ) {
1601
1612
  let importance = getMediaImportanceIfMoreImportant(
1602
1613
  mediaKey,
@@ -1607,11 +1618,30 @@ function mergeMediaByImportance(
1607
1618
  if (importanceBump) {
1608
1619
  importance = (importance || 0) + importanceBump
1609
1620
  }
1621
+ if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {
1622
+ log(
1623
+ `mergeMediaByImportance ${key} importance existing ${importancesUsed[key]} next ${importance}`
1624
+ )
1625
+ }
1610
1626
  if (importance === null) {
1611
1627
  return false
1612
1628
  }
1613
1629
  importancesUsed[key] = importance
1614
- mergeStyle(styleState, key, value)
1630
+
1631
+ if (key in pseudoDescriptors) {
1632
+ const descriptor = pseudoDescriptors[key]
1633
+ const descriptorKey = descriptor.stateKey || descriptor.name
1634
+ const isDisabled = styleState.componentState[descriptorKey] === false
1635
+ if (isDisabled) {
1636
+ return false
1637
+ }
1638
+ for (const subKey in value) {
1639
+ mergeStyle(styleState, subKey, value[subKey])
1640
+ }
1641
+ } else {
1642
+ mergeStyle(styleState, key, value)
1643
+ }
1644
+
1615
1645
  return true
1616
1646
  }
1617
1647
 
@@ -5,6 +5,7 @@ import type { Variable } from '../createVariable'
5
5
  import { variableToString } from '../createVariable'
6
6
  import type { CreateTamaguiProps, ThemeParsed } from '../types'
7
7
  import { tokensValueToVariable } from './registerCSSVariable'
8
+ import { getSetting } from '../config'
8
9
 
9
10
  export function getThemeCSSRules(props: {
10
11
  config: CreateTamaguiProps
@@ -59,7 +60,7 @@ export function getThemeCSSRules(props: {
59
60
  // since we dont specify dark/light in classnames we have to do an awkward specificity war
60
61
  // use config.maxDarkLightNesting to determine how deep you can nest until it breaks
61
62
  if (hasDarkLight) {
62
- const maxDepth = config.maxDarkLightNesting ?? 3
63
+ const maxDepth = getSetting('maxDarkLightNesting') ?? 3
63
64
 
64
65
  for (const subName of names) {
65
66
  const isDark = isDarkBase || subName.startsWith('dark_')
@@ -115,7 +116,7 @@ export function getThemeCSSRules(props: {
115
116
  // this isBaseTheme logic could probably be done more efficiently above
116
117
  const selectorsString = selectors
117
118
  .map((x) => {
118
- const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? '' : ' '
119
+ const rootSep = isBaseTheme(x) && getSetting('themeClassNameOnRoot') ? '' : ' '
119
120
  return `:root${rootSep}${x}`
120
121
  })
121
122
  .join(', ')
@@ -123,7 +124,7 @@ export function getThemeCSSRules(props: {
123
124
  const css = `${selectorsString} {${vars}}`
124
125
  cssRuleSets.push(css)
125
126
 
126
- if (config.shouldAddPrefersColorThemes) {
127
+ if (getSetting('shouldAddPrefersColorThemes')) {
127
128
  const bgString = theme.background
128
129
  ? `background:${variableToString(theme.background)};`
129
130
  : ''
@@ -154,8 +155,9 @@ export function getThemeCSSRules(props: {
154
155
  cssRuleSets.push(prefersMediaSelectors)
155
156
  }
156
157
 
157
- if (config.selectionStyles) {
158
- const rules = config.selectionStyles(theme as any)
158
+ const selectionStyles = getSetting('selectionStyles')
159
+ if (selectionStyles) {
160
+ const rules = selectionStyles(theme as any)
159
161
  if (rules) {
160
162
  const selectionSelectors = baseSelectors.map((s) => `${s} ::selection`).join(', ')
161
163
  const styles = Object.entries(rules)
@@ -1,9 +1,16 @@
1
+ import { _dmt } from '../hooks/useMedia'
2
+
1
3
  export function log(...args: any[]) {
2
4
  if (process.env.NODE_ENV === 'production') return
3
- if (process.env.TAMAGUI_TARGET === 'web') {
4
- return console.info(...args)
5
+ _dmt(true)
6
+ try {
7
+ if (process.env.TAMAGUI_TARGET === 'web') {
8
+ return console.info(...args)
9
+ }
10
+ // react native doesn't log in the cli unless it's log
11
+ // biome-ignore lint/suspicious/noConsoleLog: <explanation>
12
+ return console.log(...args)
13
+ } finally {
14
+ _dmt(false)
5
15
  }
6
- // react native doesn't log in the cli unless it's log
7
- // biome-ignore lint/suspicious/noConsoleLog: <explanation>
8
- return console.log(...args)
9
16
  }
@@ -28,8 +28,10 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
28
28
  if (key === 'elevationAndroid') return
29
29
  }
30
30
 
31
+ const { conf, styleProps, fontFamily, staticConfig } = styleStateIn
32
+
31
33
  if (value === 'unset') {
32
- const unsetVal = styleStateIn.conf.unset?.[key]
34
+ const unsetVal = conf.unset?.[key]
33
35
  if (unsetVal != null) {
34
36
  value = unsetVal
35
37
  } else {
@@ -41,7 +43,7 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
41
43
  // we use this for the sub-props like pseudos so we need to overwrite the "props" in styleState
42
44
  // fallbackProps is awkward thanks to static
43
45
  // also we need to override the props here because subStyles pass in a sub-style props object
44
- const subProps = styleStateIn.styleProps.fallbackProps || subPropsIn
46
+ const subProps = styleProps.fallbackProps || subPropsIn
45
47
  const styleState = subProps
46
48
  ? new Proxy(styleStateIn, {
47
49
  get(_, k) {
@@ -50,7 +52,6 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
50
52
  })
51
53
  : styleStateIn
52
54
 
53
- const { conf, styleProps, fontFamily, staticConfig } = styleState
54
55
  const { variants } = staticConfig
55
56
 
56
57
  if (
@@ -1,6 +1,6 @@
1
- import { getConfig } from '../config'
1
+ import { getSetting } from '../config'
2
2
  import type { ComponentContextI } from '../types'
3
3
 
4
4
  export function getDisableSSR(componentContext?: ComponentContextI) {
5
- return componentContext?.disableSSR ?? getConfig().disableSSR
5
+ return componentContext?.disableSSR ?? getSetting('disableSSR')
6
6
  }
@@ -1,13 +1,14 @@
1
1
  import { isServer, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
2
2
  import { useRef, useState, useSyncExternalStore } from 'react'
3
3
 
4
- import { getConfig } from '../config'
4
+ import { getConfig, getSetting } from '../config'
5
5
  import { matchMedia } from '../helpers/matchMedia'
6
6
  import { pseudoDescriptors } from '../helpers/pseudoDescriptors'
7
7
  import type {
8
8
  ComponentContextI,
9
9
  DebugProp,
10
10
  IsMediaType,
11
+ LayoutEvent,
11
12
  MediaQueries,
12
13
  MediaQueryObject,
13
14
  MediaQueryState,
@@ -83,7 +84,8 @@ const dispose = new Set<Function>()
83
84
  let mediaVersion = 0
84
85
 
85
86
  export const configureMedia = (config: TamaguiInternalConfig) => {
86
- const { media, mediaQueryDefaultActive } = config
87
+ const { media } = config
88
+ const mediaQueryDefaultActive = getSetting('mediaQueryDefaultActive')
87
89
  if (!media) return
88
90
  mediaVersion++
89
91
  for (const key in media) {
@@ -265,6 +267,7 @@ export function useMedia(
265
267
 
266
268
  return new Proxy(state, {
267
269
  get(_, key) {
270
+ if (disableMediaTouch) return
268
271
  if (typeof key === 'string') {
269
272
  componentState.keys ||= {}
270
273
  componentState.keys[key] = true
@@ -277,15 +280,38 @@ export function useMedia(
277
280
  })
278
281
  }
279
282
 
283
+ let disableMediaTouch = false
284
+
285
+ export function _dmt(val: boolean) {
286
+ disableMediaTouch = val
287
+ }
288
+
289
+ export function getMediaState(
290
+ mediaGroups: Set<string>,
291
+ layout: LayoutEvent['nativeEvent']['layout']
292
+ ) {
293
+ disableMediaTouch = true
294
+ let res: Record<string, boolean>
295
+ try {
296
+ res = Object.fromEntries(
297
+ [...mediaGroups].map((mediaKey) => {
298
+ return [mediaKey, mediaKeyMatch(mediaKey, layout as any)]
299
+ })
300
+ )
301
+ } finally {
302
+ disableMediaTouch = false
303
+ }
304
+ return res
305
+ }
306
+
280
307
  export const getMediaImportanceIfMoreImportant = (
281
308
  mediaKey: string,
282
309
  key: string,
283
310
  importancesUsed: Record<string, number>,
284
311
  isSizeMedia: boolean
285
312
  ) => {
286
- const conf = getConfig()
287
313
  const importance =
288
- isSizeMedia && !conf.settings.mediaPropOrder
314
+ isSizeMedia && !getSetting('mediaPropOrder')
289
315
  ? getMediaKeyImportance(mediaKey)
290
316
  : defaultMediaImportance
291
317
  return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null
@@ -1,7 +1,7 @@
1
1
  import { isClient, isIos, isServer, isWeb } from '@tamagui/constants'
2
2
  import { useContext, useEffect, useMemo, useRef, useState } from 'react'
3
3
 
4
- import { getConfig } from '../config'
4
+ import { getConfig, getSetting } from '../config'
5
5
  import type { Variable } from '../createVariable'
6
6
  import { getVariable } from '../createVariable'
7
7
  import type { ThemeManagerState } from '../helpers/ThemeManager'
@@ -130,7 +130,7 @@ export const useThemeWithState = (
130
130
  if (process.env.NODE_ENV === 'development') {
131
131
  if (!state?.theme) {
132
132
  if (process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== '1') {
133
- console.warn(
133
+ console.error(
134
134
  `[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify(
135
135
  props
136
136
  )}).\n\nIf this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`
@@ -217,7 +217,7 @@ export function getThemeProxied(
217
217
  platform !== 'web' &&
218
218
  isIos &&
219
219
  !deopt &&
220
- config.settings.fastSchemeChange &&
220
+ getSetting('fastSchemeChange') &&
221
221
  !someParentIsInversed(themeManager)
222
222
  ) {
223
223
  if (scheme) {
@@ -300,6 +300,19 @@ const registerThemeManager = (t: ThemeManager) => {
300
300
  }
301
301
  }
302
302
 
303
+ const ogLog = console.error
304
+ const preventWarnSetState =
305
+ process.env.NODE_ENV === 'production'
306
+ ? ogLog
307
+ : // temporary fix for logs, they are harmless in that i've tried to rewrite this
308
+ // a few times using the "right" ways, but they are always slower. maybe skill issue
309
+ (a?: any, ...args: any[]) => {
310
+ if (typeof a === 'string' && a.includes('Cannot update a component')) {
311
+ return
312
+ }
313
+ return ogLog(a, ...args)
314
+ }
315
+
303
316
  export const useChangeThemeEffect = (
304
317
  props: UseThemeWithStateProps,
305
318
  isRoot = false,
@@ -379,7 +392,9 @@ export const useChangeThemeEffect = (
379
392
  // for updateTheme/replaceTheme
380
393
  const selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => {
381
394
  if (forced) {
395
+ console.error = preventWarnSetState
382
396
  setThemeState((prev) => createState(prev, true))
397
+ console.error = ogLog
383
398
  }
384
399
  })
385
400
 
@@ -409,7 +424,9 @@ export const useChangeThemeEffect = (
409
424
  }
410
425
 
411
426
  if (shouldTryUpdate) {
427
+ console.error = preventWarnSetState
412
428
  setThemeState((prev) => createState(prev, force))
429
+ console.error = ogLog
413
430
  }
414
431
  },
415
432
  themeManager.id
@@ -525,7 +542,7 @@ export const useChangeThemeEffect = (
525
542
  registerThemeManager(themeManager)
526
543
  }
527
544
 
528
- const isWebSSR = isWeb ? !getConfig().disableSSR : false
545
+ const isWebSSR = isWeb ? !getSetting('disableSSR') : false
529
546
  const mounted = isWebSSR ? isRoot || prev?.mounted : true
530
547
 
531
548
  if (!state) {
package/src/types.tsx CHANGED
@@ -264,8 +264,7 @@ export type CreateTamaguiConfig<
264
264
  E extends GenericAnimations = GenericAnimations,
265
265
  F extends GenericFonts = GenericFonts,
266
266
  G extends OnlyAllowShorthandsSetting = OnlyAllowShorthandsSetting,
267
- H extends DefaultFontSetting = DefaultFontSetting,
268
- I extends GenericTamaguiSettings = GenericTamaguiSettings,
267
+ H extends GenericTamaguiSettings = GenericTamaguiSettings,
269
268
  > = {
270
269
  fonts: RemoveLanguagePostfixes<F>
271
270
  fontLanguages: GetLanguagePostfixes<F> extends never
@@ -282,8 +281,7 @@ export type CreateTamaguiConfig<
282
281
  media: D
283
282
  animations: AnimationDriver<E>
284
283
  onlyAllowShorthands: G
285
- defaultFont: H
286
- settings: I
284
+ settings: H
287
285
  }
288
286
 
289
287
  type GetLanguagePostfix<Set> = Set extends string
@@ -310,7 +308,7 @@ type GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>
310
308
  // body_en: any
311
309
  // }>['fonts']
312
310
 
313
- type ConfProps<A, B, C, D, E, F, G, H, I> = {
311
+ type ConfProps<A, B, C, D, E, F, G, I> = {
314
312
  tokens?: A
315
313
  themes?: B
316
314
  shorthands?: C
@@ -318,7 +316,6 @@ type ConfProps<A, B, C, D, E, F, G, H, I> = {
318
316
  animations?: E extends AnimationConfig ? AnimationDriver<E> : undefined
319
317
  fonts?: F
320
318
  onlyAllowShorthands?: G
321
- defaultFont?: H
322
319
  settings?: I
323
320
  }
324
321
 
@@ -348,8 +345,7 @@ export type InferTamaguiConfig<Conf> = Conf extends ConfProps<
348
345
  infer E,
349
346
  infer F,
350
347
  infer G,
351
- infer H,
352
- infer I
348
+ infer H
353
349
  >
354
350
  ? TamaguiInternalConfig<
355
351
  A extends GenericTokens ? A : EmptyTokens,
@@ -359,8 +355,7 @@ export type InferTamaguiConfig<Conf> = Conf extends ConfProps<
359
355
  E extends GenericAnimations ? E : EmptyAnimations,
360
356
  F extends GenericFonts ? F : EmptyFonts,
361
357
  G extends OnlyAllowShorthandsSetting ? G : OnlyAllowShorthandsSetting,
362
- H extends DefaultFontSetting ? H : DefaultFontSetting,
363
- I extends GenericTamaguiSettings ? I : EmptyTamaguiSettings
358
+ H extends GenericTamaguiSettings ? H : EmptyTamaguiSettings
364
359
  >
365
360
  : unknown
366
361
 
@@ -490,7 +485,7 @@ type AllowedStyleValuesSetting =
490
485
 
491
486
  type AutocompleteSpecificTokensSetting = boolean | 'except-special'
492
487
 
493
- type GenericTamaguiSettings = {
488
+ export interface GenericTamaguiSettings {
494
489
  /**
495
490
  * When true, flexBasis will be set to 0 when flex is positive. This will be
496
491
  * the default in v2 of Tamagui alongside an alternative mode for web compat.
@@ -597,6 +592,81 @@ type GenericTamaguiSettings = {
597
592
  | 'revert'
598
593
  | 'revert-layer'
599
594
  | 'unset'
595
+
596
+ /**
597
+ * Only allow shorthands when enabled. Recommended to be true to avoid having
598
+ * two ways to style the same property.
599
+ */
600
+ onlyAllowShorthands?: OnlyAllowShorthandsSetting
601
+
602
+ /**
603
+ * Define a default font, for better types and default font on Text
604
+ */
605
+ defaultFont?: string
606
+
607
+ /**
608
+ * Web-only: define CSS text-selection styles
609
+ */
610
+ selectionStyles?: (theme: Record<string, string>) => null | {
611
+ backgroundColor?: any
612
+ color?: any
613
+ }
614
+
615
+ /**
616
+ * If building a non-server rendered app, set this to true.
617
+ *
618
+ * For SSR compatibility on the web, Tamagui will render once with the settings
619
+ * from `mediaQueryDefaultActive` set for all media queries. Then, it will render
620
+ * again after the initial render using the proper media query values. This is so that
621
+ * hydration will match perfectly with the server.
622
+ *
623
+ * Setting disableSSR will avoid this second render by setting the media query state
624
+ * to the actual browser dimensions on initial load. This is only useful for client-only
625
+ * apps.
626
+ *
627
+ */
628
+ disableSSR?: boolean
629
+
630
+ /**
631
+ * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.
632
+ * For custom use cases like integration with next-theme.
633
+ */
634
+ disableRootThemeClass?: boolean
635
+
636
+ /**
637
+ * For the first render, determines which media queries are true, this only
638
+ * affects things on native or on web if you disableSSR, as otherwise Tamagui
639
+ * relies on CSS to avoid the need for re-rendering on first render.
640
+ */
641
+ mediaQueryDefaultActive?: Record<string, boolean>
642
+
643
+ /**
644
+ * What's between each CSS style rule, set to "\n" to be easier to read
645
+ * @default "\n" when NODE_ENV=development, "" otherwise
646
+ */
647
+ cssStyleSeparator?: string
648
+
649
+ /**
650
+ * (Advanced) on the web, tamagui treats `dark` and `light` themes as special
651
+ * and generates extra CSS to avoid having to re-render the entire page. this
652
+ * CSS relies on specificity hacks that multiply by your sub-themes. this sets
653
+ * the maxiumum number of nested dark/light themes you can do defaults to 3
654
+ * for a balance, but can be higher if you nest them deeply.
655
+ */
656
+ maxDarkLightNesting?: number
657
+
658
+ /**
659
+ * Adds @media(prefers-color-scheme) media queries for dark/light, must be set
660
+ * true if you are supporting system preference for light and dark mode themes
661
+ */
662
+ shouldAddPrefersColorThemes?: boolean
663
+
664
+ /**
665
+ * If you want to style your <body> tag to use themes, you must place the
666
+ * theme className onto the body element. This will do so. Otherwise, Tamagui
667
+ * will place the className onto the element rendered by the TamaguiProvider
668
+ */
669
+ themeClassNameOnRoot?: boolean
600
670
  }
601
671
 
602
672
  export type TamaguiSettings = TamaguiConfig['settings']
@@ -626,6 +696,7 @@ export type CreateTamaguiProps = {
626
696
  /**
627
697
  * Define a default font, for better types and default font on Text
628
698
  */
699
+ /** @deprecated moved into settings sub-object */
629
700
  defaultFont?: string
630
701
 
631
702
  /**
@@ -649,12 +720,14 @@ export type CreateTamaguiProps = {
649
720
  * apps.
650
721
  *
651
722
  */
723
+ /** @deprecated moved into settings sub-object */
652
724
  disableSSR?: boolean
653
725
 
654
726
  /**
655
727
  * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.
656
728
  * For custom use cases like integration with next-theme.
657
729
  */
730
+ /** @deprecated moved into settings sub-object */
658
731
  disableRootThemeClass?: boolean
659
732
 
660
733
  defaultProps?: Record<string, any> & {
@@ -665,10 +738,12 @@ export type CreateTamaguiProps = {
665
738
 
666
739
  // for the first render, determines which media queries are true
667
740
  // useful for SSR
741
+ /** @deprecated moved into settings sub-object */
668
742
  mediaQueryDefaultActive?: Record<string, boolean>
669
743
 
670
744
  // what's between each CSS style rule, set to "\n" to be easier to read
671
745
  // defaults: "\n" when NODE_ENV=development, "" otherwise
746
+ /** @deprecated moved into settings sub-object */
672
747
  cssStyleSeparator?: string
673
748
 
674
749
  // (Advanced)
@@ -677,17 +752,21 @@ export type CreateTamaguiProps = {
677
752
  // this CSS relies on specificity hacks that multiply by your sub-themes.
678
753
  // this sets the maxiumum number of nested dark/light themes you can do
679
754
  // defaults to 3 for a balance, but can be higher if you nest them deeply.
755
+ /** @deprecated moved into settings sub-object */
680
756
  maxDarkLightNesting?: number
681
757
 
682
758
  // adds @media(prefers-color-scheme) media queries for dark/light
759
+ /** @deprecated moved into settings sub-object */
683
760
  shouldAddPrefersColorThemes?: boolean
684
761
 
685
762
  // only if you put the theme classname on the html element we have to generate diff
763
+ /** @deprecated moved into settings sub-object */
686
764
  themeClassNameOnRoot?: boolean
687
765
 
688
766
  /**
689
767
  * Only allow shorthands when enabled
690
768
  */
769
+ /** @deprecated moved into settings sub-object */
691
770
  onlyAllowShorthands?: OnlyAllowShorthandsSetting
692
771
  }
693
772
 
@@ -706,10 +785,9 @@ export type TamaguiInternalConfig<
706
785
  E extends GenericAnimations = GenericAnimations,
707
786
  F extends GenericFonts = GenericFonts,
708
787
  G extends OnlyAllowShorthandsSetting = OnlyAllowShorthandsSetting,
709
- H extends DefaultFontSetting = DefaultFontSetting,
710
788
  I extends GenericTamaguiSettings = GenericTamaguiSettings,
711
789
  > = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &
712
- Omit<CreateTamaguiConfig<A, B, C, D, E, F, G, H, I>, 'tokens'> & {
790
+ Omit<CreateTamaguiConfig<A, B, C, D, E, F, G, I>, 'tokens'> & {
713
791
  // TODO need to make it this but this breaks types, revisit
714
792
  // animations: E //AnimationDriver<E>
715
793
  // with $ prefixes for fast lookups (one time cost at startup vs every render)
@@ -722,7 +800,6 @@ export type TamaguiInternalConfig<
722
800
  parsed: boolean
723
801
  inverseShorthands: Record<string, string>
724
802
  reactNative?: any
725
- defaultFont?: H
726
803
  fontSizeTokens: Set<string>
727
804
  specificTokens: Record<string, Variable>
728
805
  settings: Omit<GenericTamaguiSettings, keyof I> & I
@@ -1045,7 +1122,7 @@ export type Token =
1045
1122
  export type ColorStyleProp = ThemeValueFallbackColor | ColorTokens
1046
1123
 
1047
1124
  // fonts
1048
- type DefaultFont = TamaguiConfig['defaultFont']
1125
+ type DefaultFont = TamaguiSettings['defaultFont']
1049
1126
 
1050
1127
  export type Fonts = DefaultFont extends string
1051
1128
  ? TamaguiConfig['fonts'][DefaultFont]