@tamagui/web 1.123.17 → 1.124.0

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 (246) hide show
  1. package/dist/cjs/Tamagui.cjs +1 -6
  2. package/dist/cjs/Tamagui.js +1 -5
  3. package/dist/cjs/Tamagui.js.map +1 -1
  4. package/dist/cjs/Tamagui.native.js +2 -8
  5. package/dist/cjs/Tamagui.native.js.map +2 -2
  6. package/dist/cjs/createComponent.cjs +9 -13
  7. package/dist/cjs/createComponent.js +10 -8
  8. package/dist/cjs/createComponent.js.map +1 -1
  9. package/dist/cjs/createComponent.native.js +17 -19
  10. package/dist/cjs/createComponent.native.js.map +2 -2
  11. package/dist/cjs/helpers/createShallowSetState.cjs +7 -4
  12. package/dist/cjs/helpers/createShallowSetState.js +12 -6
  13. package/dist/cjs/helpers/createShallowSetState.js.map +1 -1
  14. package/dist/cjs/helpers/createShallowSetState.native.js +10 -4
  15. package/dist/cjs/helpers/createShallowSetState.native.js.map +2 -2
  16. package/dist/cjs/hooks/{shouldDeoptDueToParentScheme.cjs → doesRootSchemeMatchSystem.cjs} +5 -5
  17. package/dist/cjs/hooks/{shouldDeoptDueToParentScheme.js → doesRootSchemeMatchSystem.js} +6 -6
  18. package/dist/cjs/hooks/doesRootSchemeMatchSystem.js.map +6 -0
  19. package/dist/cjs/hooks/doesRootSchemeMatchSystem.native.js +30 -0
  20. package/dist/cjs/hooks/doesRootSchemeMatchSystem.native.js.map +6 -0
  21. package/dist/cjs/hooks/getThemeProxied.cjs +58 -0
  22. package/dist/cjs/hooks/getThemeProxied.js +53 -0
  23. package/dist/cjs/hooks/getThemeProxied.js.map +6 -0
  24. package/dist/cjs/hooks/getThemeProxied.native.js +76 -0
  25. package/dist/cjs/hooks/getThemeProxied.native.js.map +6 -0
  26. package/dist/cjs/hooks/useComponentState.cjs +16 -16
  27. package/dist/cjs/hooks/useComponentState.js +22 -15
  28. package/dist/cjs/hooks/useComponentState.js.map +1 -1
  29. package/dist/cjs/hooks/useComponentState.native.js +15 -15
  30. package/dist/cjs/hooks/useComponentState.native.js.map +2 -2
  31. package/dist/cjs/hooks/useProps.cjs +2 -2
  32. package/dist/cjs/hooks/useProps.js +2 -2
  33. package/dist/cjs/hooks/useProps.js.map +1 -1
  34. package/dist/cjs/hooks/useProps.native.js +2 -2
  35. package/dist/cjs/hooks/useProps.native.js.map +2 -2
  36. package/dist/cjs/hooks/useTheme.cjs +10 -208
  37. package/dist/cjs/hooks/useTheme.js +7 -207
  38. package/dist/cjs/hooks/useTheme.js.map +2 -2
  39. package/dist/cjs/hooks/useTheme.native.js +8 -252
  40. package/dist/cjs/hooks/useTheme.native.js.map +2 -2
  41. package/dist/cjs/hooks/useThemeName.cjs +15 -27
  42. package/dist/cjs/hooks/useThemeName.js +6 -20
  43. package/dist/cjs/hooks/useThemeName.js.map +2 -2
  44. package/dist/cjs/hooks/useThemeName.native.js +16 -22
  45. package/dist/cjs/hooks/useThemeName.native.js.map +2 -2
  46. package/dist/cjs/hooks/useThemeState.cjs +187 -0
  47. package/dist/cjs/hooks/useThemeState.js +159 -0
  48. package/dist/cjs/hooks/useThemeState.js.map +6 -0
  49. package/dist/cjs/hooks/useThemeState.native.js +206 -0
  50. package/dist/cjs/hooks/useThemeState.native.js.map +6 -0
  51. package/dist/cjs/index.cjs +2 -0
  52. package/dist/cjs/index.js +2 -0
  53. package/dist/cjs/index.js.map +1 -1
  54. package/dist/cjs/index.native.js +3 -0
  55. package/dist/cjs/index.native.js.map +1 -1
  56. package/dist/cjs/views/TamaguiProvider.js.map +1 -1
  57. package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
  58. package/dist/cjs/views/Theme.cjs +81 -85
  59. package/dist/cjs/views/Theme.js +44 -51
  60. package/dist/cjs/views/Theme.js.map +2 -2
  61. package/dist/cjs/views/Theme.native.js +58 -58
  62. package/dist/cjs/views/Theme.native.js.map +2 -2
  63. package/dist/cjs/views/ThemeDebug.cjs +21 -43
  64. package/dist/cjs/views/ThemeDebug.js +18 -38
  65. package/dist/cjs/views/ThemeDebug.js.map +2 -2
  66. package/dist/cjs/views/ThemeProvider.cjs +1 -1
  67. package/dist/cjs/views/ThemeProvider.js +1 -1
  68. package/dist/cjs/views/ThemeProvider.js.map +1 -1
  69. package/dist/cjs/views/ThemeProvider.native.js +1 -1
  70. package/dist/cjs/views/ThemeProvider.native.js.map +2 -2
  71. package/dist/esm/Tamagui.js +0 -5
  72. package/dist/esm/Tamagui.js.map +1 -1
  73. package/dist/esm/Tamagui.mjs +0 -5
  74. package/dist/esm/Tamagui.mjs.map +1 -1
  75. package/dist/esm/Tamagui.native.js +1 -8
  76. package/dist/esm/Tamagui.native.js.map +2 -2
  77. package/dist/esm/createComponent.js +9 -8
  78. package/dist/esm/createComponent.js.map +1 -1
  79. package/dist/esm/createComponent.mjs +9 -13
  80. package/dist/esm/createComponent.mjs.map +1 -1
  81. package/dist/esm/createComponent.native.js +16 -19
  82. package/dist/esm/createComponent.native.js.map +2 -2
  83. package/dist/esm/helpers/createShallowSetState.js +13 -7
  84. package/dist/esm/helpers/createShallowSetState.js.map +1 -1
  85. package/dist/esm/helpers/createShallowSetState.mjs +8 -5
  86. package/dist/esm/helpers/createShallowSetState.mjs.map +1 -1
  87. package/dist/esm/helpers/createShallowSetState.native.js +11 -5
  88. package/dist/esm/helpers/createShallowSetState.native.js.map +2 -2
  89. package/dist/esm/hooks/doesRootSchemeMatchSystem.js +7 -0
  90. package/dist/esm/hooks/doesRootSchemeMatchSystem.js.map +6 -0
  91. package/dist/esm/hooks/doesRootSchemeMatchSystem.mjs +5 -0
  92. package/dist/esm/hooks/doesRootSchemeMatchSystem.mjs.map +1 -0
  93. package/dist/esm/hooks/doesRootSchemeMatchSystem.native.js +10 -0
  94. package/dist/esm/hooks/doesRootSchemeMatchSystem.native.js.map +6 -0
  95. package/dist/esm/hooks/getThemeProxied.js +40 -0
  96. package/dist/esm/hooks/getThemeProxied.js.map +6 -0
  97. package/dist/esm/hooks/getThemeProxied.mjs +35 -0
  98. package/dist/esm/hooks/getThemeProxied.mjs.map +1 -0
  99. package/dist/esm/hooks/getThemeProxied.native.js +59 -0
  100. package/dist/esm/hooks/getThemeProxied.native.js.map +6 -0
  101. package/dist/esm/hooks/useComponentState.js +22 -15
  102. package/dist/esm/hooks/useComponentState.js.map +1 -1
  103. package/dist/esm/hooks/useComponentState.mjs +16 -16
  104. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  105. package/dist/esm/hooks/useComponentState.native.js +15 -15
  106. package/dist/esm/hooks/useComponentState.native.js.map +2 -2
  107. package/dist/esm/hooks/useProps.js +2 -2
  108. package/dist/esm/hooks/useProps.js.map +1 -1
  109. package/dist/esm/hooks/useProps.mjs +2 -2
  110. package/dist/esm/hooks/useProps.mjs.map +1 -1
  111. package/dist/esm/hooks/useProps.native.js +2 -2
  112. package/dist/esm/hooks/useProps.native.js.map +2 -2
  113. package/dist/esm/hooks/useTheme.js +9 -220
  114. package/dist/esm/hooks/useTheme.js.map +2 -2
  115. package/dist/esm/hooks/useTheme.mjs +10 -205
  116. package/dist/esm/hooks/useTheme.mjs.map +1 -1
  117. package/dist/esm/hooks/useTheme.native.js +11 -257
  118. package/dist/esm/hooks/useTheme.native.js.map +2 -2
  119. package/dist/esm/hooks/useThemeName.js +4 -12
  120. package/dist/esm/hooks/useThemeName.js.map +2 -2
  121. package/dist/esm/hooks/useThemeName.mjs +11 -12
  122. package/dist/esm/hooks/useThemeName.mjs.map +1 -1
  123. package/dist/esm/hooks/useThemeName.native.js +15 -14
  124. package/dist/esm/hooks/useThemeName.native.js.map +2 -2
  125. package/dist/esm/hooks/useThemeState.js +151 -0
  126. package/dist/esm/hooks/useThemeState.js.map +6 -0
  127. package/dist/esm/hooks/useThemeState.mjs +159 -0
  128. package/dist/esm/hooks/useThemeState.mjs.map +1 -0
  129. package/dist/esm/hooks/useThemeState.native.js +182 -0
  130. package/dist/esm/hooks/useThemeState.native.js.map +6 -0
  131. package/dist/esm/index.js +2 -0
  132. package/dist/esm/index.js.map +1 -1
  133. package/dist/esm/index.mjs +2 -1
  134. package/dist/esm/index.mjs.map +1 -1
  135. package/dist/esm/index.native.js +2 -0
  136. package/dist/esm/index.native.js.map +2 -2
  137. package/dist/esm/views/TamaguiProvider.js.map +1 -1
  138. package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
  139. package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
  140. package/dist/esm/views/Theme.js +57 -54
  141. package/dist/esm/views/Theme.js.map +2 -2
  142. package/dist/esm/views/Theme.mjs +81 -85
  143. package/dist/esm/views/Theme.mjs.map +1 -1
  144. package/dist/esm/views/Theme.native.js +61 -61
  145. package/dist/esm/views/Theme.native.js.map +2 -2
  146. package/dist/esm/views/ThemeDebug.js +16 -29
  147. package/dist/esm/views/ThemeDebug.js.map +1 -1
  148. package/dist/esm/views/ThemeDebug.mjs +16 -27
  149. package/dist/esm/views/ThemeDebug.mjs.map +1 -1
  150. package/dist/esm/views/ThemeProvider.js +2 -2
  151. package/dist/esm/views/ThemeProvider.js.map +1 -1
  152. package/dist/esm/views/ThemeProvider.mjs +2 -2
  153. package/dist/esm/views/ThemeProvider.mjs.map +1 -1
  154. package/dist/esm/views/ThemeProvider.native.js +2 -2
  155. package/dist/esm/views/ThemeProvider.native.js.map +2 -2
  156. package/package.json +11 -11
  157. package/src/Tamagui.ts +0 -6
  158. package/src/createComponent.tsx +19 -28
  159. package/src/helpers/createShallowSetState.tsx +17 -8
  160. package/src/hooks/doesRootSchemeMatchSystem.native.ts +7 -0
  161. package/src/hooks/doesRootSchemeMatchSystem.ts +4 -0
  162. package/src/hooks/getThemeProxied.ts +165 -0
  163. package/src/hooks/useComponentState.ts +26 -21
  164. package/src/hooks/useProps.tsx +2 -2
  165. package/src/hooks/useTheme.tsx +22 -633
  166. package/src/hooks/useThemeName.tsx +6 -18
  167. package/src/hooks/useThemeState.ts +341 -0
  168. package/src/index.ts +1 -0
  169. package/src/types.tsx +2 -2
  170. package/src/views/TamaguiProvider.tsx +1 -1
  171. package/src/views/Theme.tsx +129 -132
  172. package/src/views/ThemeDebug.native.tsx +2 -2
  173. package/src/views/ThemeDebug.tsx +17 -39
  174. package/src/views/ThemeProvider.tsx +2 -2
  175. package/types/Tamagui.d.ts +0 -2
  176. package/types/Tamagui.d.ts.map +1 -1
  177. package/types/createComponent.d.ts.map +1 -1
  178. package/types/helpers/createShallowSetState.d.ts +1 -1
  179. package/types/helpers/createShallowSetState.d.ts.map +1 -1
  180. package/types/hooks/doesRootSchemeMatchSystem.d.ts +2 -0
  181. package/types/hooks/doesRootSchemeMatchSystem.d.ts.map +1 -0
  182. package/types/hooks/doesRootSchemeMatchSystem.native.d.ts +2 -0
  183. package/types/hooks/doesRootSchemeMatchSystem.native.d.ts.map +1 -0
  184. package/types/hooks/getThemeProxied.d.ts +25 -0
  185. package/types/hooks/getThemeProxied.d.ts.map +1 -0
  186. package/types/hooks/useComponentState.d.ts.map +1 -1
  187. package/types/hooks/useConfiguration.d.ts.map +1 -1
  188. package/types/hooks/useTheme.d.ts +9 -36
  189. package/types/hooks/useTheme.d.ts.map +1 -1
  190. package/types/hooks/useThemeName.d.ts +1 -3
  191. package/types/hooks/useThemeName.d.ts.map +1 -1
  192. package/types/hooks/useThemeState.d.ts +22 -0
  193. package/types/hooks/useThemeState.d.ts.map +1 -0
  194. package/types/index.d.ts +1 -0
  195. package/types/index.d.ts.map +1 -1
  196. package/types/types.d.ts +2 -2
  197. package/types/types.d.ts.map +1 -1
  198. package/types/views/Theme.d.ts +3 -3
  199. package/types/views/Theme.d.ts.map +1 -1
  200. package/types/views/ThemeDebug.d.ts +2 -2
  201. package/types/views/ThemeDebug.d.ts.map +1 -1
  202. package/types/views/ThemeDebug.native.d.ts +2 -2
  203. package/types/views/ThemeDebug.native.d.ts.map +1 -1
  204. package/dist/cjs/helpers/ThemeManager.cjs +0 -202
  205. package/dist/cjs/helpers/ThemeManager.js +0 -183
  206. package/dist/cjs/helpers/ThemeManager.js.map +0 -6
  207. package/dist/cjs/helpers/ThemeManager.native.js +0 -282
  208. package/dist/cjs/helpers/ThemeManager.native.js.map +0 -6
  209. package/dist/cjs/helpers/ThemeManagerContext.cjs +0 -38
  210. package/dist/cjs/helpers/ThemeManagerContext.js +0 -30
  211. package/dist/cjs/helpers/ThemeManagerContext.js.map +0 -6
  212. package/dist/cjs/helpers/ThemeManagerContext.native.js +0 -34
  213. package/dist/cjs/helpers/ThemeManagerContext.native.js.map +0 -6
  214. package/dist/cjs/hooks/shouldDeoptDueToParentScheme.js.map +0 -6
  215. package/dist/cjs/hooks/shouldDeoptDueToParentScheme.native.js +0 -50
  216. package/dist/cjs/hooks/shouldDeoptDueToParentScheme.native.js.map +0 -6
  217. package/dist/esm/helpers/ThemeManager.js +0 -169
  218. package/dist/esm/helpers/ThemeManager.js.map +0 -6
  219. package/dist/esm/helpers/ThemeManager.mjs +0 -177
  220. package/dist/esm/helpers/ThemeManager.mjs.map +0 -1
  221. package/dist/esm/helpers/ThemeManager.native.js +0 -261
  222. package/dist/esm/helpers/ThemeManager.native.js.map +0 -6
  223. package/dist/esm/helpers/ThemeManagerContext.js +0 -6
  224. package/dist/esm/helpers/ThemeManagerContext.js.map +0 -6
  225. package/dist/esm/helpers/ThemeManagerContext.mjs +0 -4
  226. package/dist/esm/helpers/ThemeManagerContext.mjs.map +0 -1
  227. package/dist/esm/helpers/ThemeManagerContext.native.js +0 -6
  228. package/dist/esm/helpers/ThemeManagerContext.native.js.map +0 -6
  229. package/dist/esm/hooks/shouldDeoptDueToParentScheme.js +0 -7
  230. package/dist/esm/hooks/shouldDeoptDueToParentScheme.js.map +0 -6
  231. package/dist/esm/hooks/shouldDeoptDueToParentScheme.mjs +0 -5
  232. package/dist/esm/hooks/shouldDeoptDueToParentScheme.mjs.map +0 -1
  233. package/dist/esm/hooks/shouldDeoptDueToParentScheme.native.js +0 -29
  234. package/dist/esm/hooks/shouldDeoptDueToParentScheme.native.js.map +0 -6
  235. package/src/helpers/ThemeManager.tsx +0 -405
  236. package/src/helpers/ThemeManagerContext.tsx +0 -4
  237. package/src/hooks/shouldDeoptDueToParentScheme.native.tsx +0 -37
  238. package/src/hooks/shouldDeoptDueToParentScheme.tsx +0 -6
  239. package/types/helpers/ThemeManager.d.ts +0 -45
  240. package/types/helpers/ThemeManager.d.ts.map +0 -1
  241. package/types/helpers/ThemeManagerContext.d.ts +0 -4
  242. package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
  243. package/types/hooks/shouldDeoptDueToParentScheme.d.ts +0 -3
  244. package/types/hooks/shouldDeoptDueToParentScheme.d.ts.map +0 -1
  245. package/types/hooks/shouldDeoptDueToParentScheme.native.d.ts +0 -3
  246. package/types/hooks/shouldDeoptDueToParentScheme.native.d.ts.map +0 -1
@@ -1,29 +1,43 @@
1
1
  import { isWeb } from '@tamagui/constants'
2
2
  import type { MutableRefObject } from 'react'
3
- import React, { Children, cloneElement, forwardRef, isValidElement, useRef } from 'react'
3
+ import React, {
4
+ Children,
5
+ cloneElement,
6
+ forwardRef,
7
+ isValidElement,
8
+ useEffect,
9
+ useRef,
10
+ } from 'react'
11
+ import { getSetting } from '../config'
4
12
  import { variableToString } from '../createVariable'
5
- import { log } from '../helpers/log'
6
- import { ThemeManagerContext } from '../helpers/ThemeManagerContext'
7
- import type { ChangedThemeResponse } from '../hooks/useTheme'
8
- import { useChangeThemeEffect } from '../hooks/useTheme'
13
+ import { useThemeWithState } from '../hooks/useTheme'
14
+ import {
15
+ getThemeState,
16
+ hasThemeUpdatingProps,
17
+ ThemeStateContext,
18
+ type ThemeState,
19
+ } from '../hooks/useThemeState'
9
20
  import type { ThemeProps } from '../types'
10
21
  import { ThemeDebug } from './ThemeDebug'
11
22
 
12
- export const Theme = forwardRef(function Theme({ children, ...props }: ThemeProps, ref) {
23
+ const empty = { className: '', style: {} }
24
+
25
+ export const Theme = forwardRef(function Theme(props: ThemeProps, ref) {
13
26
  // @ts-expect-error only for internal views
14
27
  if (props.disable) {
15
- return children
28
+ return props.children
16
29
  }
17
30
 
18
31
  const isRoot = !!props['_isRoot']
19
- const themeState = useChangeThemeEffect(props, isRoot)
32
+ const [_, themeState] = useThemeWithState(props, isRoot)
33
+
20
34
  const disableDirectChildTheme = props['disable-child-theme']
21
35
 
22
36
  let finalChildren = disableDirectChildTheme
23
- ? Children.map(children, (child) =>
37
+ ? Children.map(props.children, (child) =>
24
38
  cloneElement(child, { ['data-disable-theme']: true })
25
39
  )
26
- : children
40
+ : props.children
27
41
 
28
42
  if (ref) {
29
43
  try {
@@ -34,16 +48,6 @@ export const Theme = forwardRef(function Theme({ children, ...props }: ThemeProp
34
48
  }
35
49
  }
36
50
 
37
- if (process.env.NODE_ENV === 'development') {
38
- if (props.debug === 'visualize') {
39
- finalChildren = (
40
- <ThemeDebug themeState={themeState} themeProps={props}>
41
- {finalChildren}
42
- </ThemeDebug>
43
- )
44
- }
45
- }
46
-
47
51
  const stateRef = useRef({
48
52
  hasEverThemed: false,
49
53
  })
@@ -54,149 +58,136 @@ export const Theme = forwardRef(function Theme({ children, ...props }: ThemeProp
54
58
  Theme['avoidForwardRef'] = true
55
59
 
56
60
  export function getThemedChildren(
57
- themeState: ChangedThemeResponse,
61
+ themeState: ThemeState,
58
62
  children: any,
59
63
  props: ThemeProps,
60
64
  isRoot = false,
61
- stateRef: MutableRefObject<{ hasEverThemed?: boolean }>
65
+ stateRef: MutableRefObject<{ hasEverThemed?: boolean | 'wrapped' }>
62
66
  ) {
63
- const { themeManager, isNewTheme } = themeState
64
-
65
- // its always there.. should fix type
66
- if (!themeManager) {
67
- return children
68
- // throw new Error(
69
- // process.env.NODE_ENV === 'development'
70
- // ? `❌ No theme found, either incorrect name, potential duplicate tamagui deps, or TamaguiProvider not providing themes.`
71
- // : `❌ 005`
72
- // )
73
- }
74
-
75
67
  const { shallow, forceClassName } = props
76
68
 
77
69
  // always be true if ever themed so we avoid re-parenting
70
+ const state = stateRef.current
71
+ let hasEverThemed = state.hasEverThemed
72
+
78
73
  let shouldRenderChildrenWithTheme =
79
- isNewTheme ||
80
- isRoot ||
81
- 'inverse' in props ||
82
- 'name' in props ||
83
- 'reset' in props ||
84
- 'forceClassName' in props ||
85
- stateRef.current.hasEverThemed
86
-
87
- if (shouldRenderChildrenWithTheme) {
88
- stateRef.current.hasEverThemed = true
89
- }
74
+ hasEverThemed || themeState.isNew || isRoot || hasThemeUpdatingProps(props)
90
75
 
91
76
  if (!shouldRenderChildrenWithTheme) {
92
77
  return children
93
78
  }
94
79
 
95
- if (process.env.NODE_ENV === 'development') {
96
- if (shouldRenderChildrenWithTheme && props.debug === 'verbose') {
97
- log(
98
- `adding theme: isRoot ${isRoot}, inverse ${'inverse' in props}, isNewTheme ${isNewTheme}, hasEver ${stateRef.current.hasEverThemed}`,
99
- props
100
- )
101
- }
102
- }
103
-
104
- let next = children
105
-
106
- // each children of these children wont get the theme
107
- if (shallow) {
108
- next = Children.toArray(children).map((child) => {
109
- return isValidElement(child)
110
- ? cloneElement(
111
- child,
112
- undefined,
113
- <Theme name={themeManager.state.parentName}>
114
- {(child as any).props.children}
115
- </Theme>
116
- )
117
- : child
118
- })
119
- }
80
+ // from here on out we have to be careful not to re-parent
120
81
 
121
- const elementsWithContext = (
122
- <ThemeManagerContext.Provider value={themeManager}>
123
- {next}
124
- </ThemeManagerContext.Provider>
82
+ children = (
83
+ <ThemeStateContext.Provider value={themeState.id}>
84
+ {children}
85
+ </ThemeStateContext.Provider>
125
86
  )
126
87
 
127
- if (forceClassName === false) {
128
- return elementsWithContext
88
+ const { isInverse, name } = themeState
89
+ const requiresExtraWrapper = isInverse || forceClassName
90
+
91
+ // it only ever progresses from false => true => 'wrapped'
92
+ if (!state.hasEverThemed) {
93
+ state.hasEverThemed = true
94
+ }
95
+ if (
96
+ requiresExtraWrapper ||
97
+ // if the theme is exactly dark or light, its likely to change between dark/light
98
+ // and that would require wrapping which would re-parent, so to avoid re-parenting do this
99
+ themeState.name === 'dark' ||
100
+ themeState.name === 'light'
101
+ ) {
102
+ state.hasEverThemed = 'wrapped'
129
103
  }
130
104
 
131
- if (isWeb) {
132
- return wrapThemeElements({
133
- children: elementsWithContext,
134
- themeState,
135
- forceClassName,
136
- isRoot,
137
- })
105
+ // each children of these children wont get the theme
106
+ if (shallow) {
107
+ if (!themeState.parentId) {
108
+ // they are doing shallow but didnt change actually change a theme theme?
109
+ } else {
110
+ const parentState = getThemeState(
111
+ themeState.isNew ? themeState.id : themeState.parentId
112
+ )
113
+ if (!parentState) throw new Error(`‼️010`)
114
+ children = Children.toArray(children).map((child) => {
115
+ return isValidElement(child)
116
+ ? cloneElement(
117
+ child,
118
+ undefined,
119
+ <Theme name={parentState.name}>{(child as any).props.children}</Theme>
120
+ )
121
+ : child
122
+ })
123
+ }
138
124
  }
139
125
 
140
- return elementsWithContext
141
- }
126
+ if (process.env.NODE_ENV === 'development') {
127
+ if (props.debug) {
128
+ console.warn(` getThemedChildren`, {
129
+ requiresExtraWrapper,
130
+ forceClassName,
131
+ themeState,
132
+ state,
133
+ ...getThemeClassNameAndStyle(themeState, props, isRoot),
134
+ })
135
+ children = (
136
+ <ThemeDebug themeState={themeState} themeProps={props}>
137
+ {children}
138
+ </ThemeDebug>
139
+ )
140
+ }
141
+ }
142
142
 
143
- function wrapThemeElements({
144
- children,
145
- themeState,
146
- forceClassName,
147
- isRoot,
148
- }: {
149
- children?: React.ReactNode
150
- themeState: ChangedThemeResponse
151
- forceClassName?: boolean
152
- isRoot?: boolean
153
- }) {
154
- if (isRoot && forceClassName === false) {
143
+ if (forceClassName === false) {
155
144
  return children
156
145
  }
157
146
 
158
- const inverse = themeState.inversed
159
- const requiresExtraWrapper = typeof inverse === 'boolean' || forceClassName
160
-
161
- const { className, style } = getThemeClassNameAndStyle(themeState, isRoot)
162
-
163
- let themedChildren = (
164
- <span className={`${className} _dsp_contents is_Theme`} style={style}>
165
- {children}
166
- </span>
167
- )
147
+ if (isWeb) {
148
+ const { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot)
168
149
 
169
- // to prevent tree structure changes always render this if inverse is true or false
170
- if (requiresExtraWrapper) {
171
- const name = themeState.state?.name || ''
172
- const inverseClassName = name.startsWith('light')
173
- ? 't_light is_inversed'
174
- : name.startsWith('dark')
175
- ? 't_dark is_inversed'
176
- : ''
177
-
178
- themedChildren = (
179
- <span className={`${inverse ? inverseClassName : ''} _dsp_contents`}>
180
- {themedChildren}
150
+ children = (
151
+ <span className={`${className} _dsp_contents is_Theme`} style={style}>
152
+ {children}
181
153
  </span>
182
154
  )
155
+
156
+ // to prevent tree structure changes always render this if inverse is true or false
157
+ if (state.hasEverThemed === 'wrapped') {
158
+ // but still calculate if we need the classnames
159
+ const className = requiresExtraWrapper
160
+ ? `${
161
+ isInverse
162
+ ? name.startsWith('light')
163
+ ? 't_light is_inversed'
164
+ : name.startsWith('dark')
165
+ ? 't_dark is_inversed'
166
+ : ''
167
+ : ''
168
+ } _dsp_contents`
169
+ : `_dsp_contents`
170
+ children = <span className={className}>{children}</span>
171
+ }
172
+
173
+ return children
183
174
  }
184
175
 
185
- return themedChildren
176
+ return children
186
177
  }
187
178
 
188
- const emptyObj = {}
189
-
190
- function getThemeClassNameAndStyle(themeState: ChangedThemeResponse, isRoot = false) {
191
- if (!themeState.isNewTheme) {
192
- return { className: '', style: emptyObj }
179
+ function getThemeClassNameAndStyle(
180
+ themeState: ThemeState,
181
+ props: ThemeProps,
182
+ isRoot = false
183
+ ) {
184
+ if (!themeState.isNew && !props.forceClassName) {
185
+ return empty
193
186
  }
194
187
 
195
188
  // in order to provide currentColor, set color by default
196
189
  const themeColor =
197
- themeState.state?.theme && themeState.isNewTheme
198
- ? variableToString(themeState.state.theme.color)
199
- : ''
190
+ themeState?.theme && themeState.isNew ? variableToString(themeState.theme.color) : ''
200
191
 
201
192
  const style = themeColor
202
193
  ? {
@@ -204,9 +195,15 @@ function getThemeClassNameAndStyle(themeState: ChangedThemeResponse, isRoot = fa
204
195
  }
205
196
  : undefined
206
197
 
207
- let className = themeState.state?.className || ''
208
- if (isRoot) {
209
- className = className.replace('t_sub_theme', '')
210
- }
198
+ const maxInverses = getSetting('maxDarkLightNesting') || 3
199
+ const themeClassName =
200
+ themeState.inverses >= maxInverses
201
+ ? themeState.name
202
+ : themeState.name.replace(schemePrefix, '')
203
+
204
+ const className = `${isRoot ? '' : 't_sub_theme'} t_${themeClassName}`
205
+
211
206
  return { style, className }
212
207
  }
208
+
209
+ const schemePrefix = /^(dark|light)_/
@@ -1,4 +1,4 @@
1
- import type { ChangedThemeResponse } from '../hooks/useTheme'
1
+ import type { ThemeState } from '../hooks/useThemeState'
2
2
  import type { ThemeProps } from '../types'
3
3
 
4
4
  export function ThemeDebug({
@@ -6,7 +6,7 @@ export function ThemeDebug({
6
6
  themeProps,
7
7
  children,
8
8
  }: {
9
- themeState: ChangedThemeResponse
9
+ themeState: ThemeState
10
10
  themeProps: ThemeProps
11
11
  children: any
12
12
  }) {
@@ -1,9 +1,7 @@
1
- import React from 'react'
2
1
  import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
3
- import { useForceUpdate } from '@tamagui/use-force-update'
2
+ import { useEffect } from 'react'
4
3
  import { createPortal } from 'react-dom'
5
-
6
- import type { ChangedThemeResponse } from '../hooks/useTheme'
4
+ import type { ThemeState } from '../hooks/useThemeState'
7
5
  import type { ThemeProps } from '../types'
8
6
 
9
7
  let node
@@ -12,12 +10,9 @@ export function ThemeDebug({
12
10
  themeState,
13
11
  themeProps,
14
12
  children,
15
- }: { themeState: ChangedThemeResponse; themeProps: ThemeProps; children: any }) {
13
+ }: { themeState: ThemeState; themeProps: ThemeProps; children: any }) {
16
14
  if (process.env.NODE_ENV === 'development') {
17
15
  const isHydrated = useDidFinishSSR()
18
- const [onChangeCount, setOnChangeCount] = React.useState(0)
19
- const rerender = useForceUpdate()
20
- const id = React.useId()
21
16
 
22
17
  if (process.env.NODE_ENV === 'development' && typeof document !== 'undefined') {
23
18
  if (!node) {
@@ -33,24 +28,11 @@ export function ThemeDebug({
33
28
  node.style.border = '1px solid #888'
34
29
  node.style.flexDirection = 'row'
35
30
  node.style.background = 'var(--background)'
36
- document.body.appendChild(node)
37
31
  }
38
32
  }
39
33
 
40
- React.useEffect(() => {
41
- themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {
42
- setOnChangeCount((p) => ++p)
43
- console.warn(
44
- `theme changed for ${themeState.themeManager?.id} from parent ${themeState.themeManager?.parentManager?.id} to new name`,
45
- name
46
- )
47
- })
48
- }, [themeState.themeManager])
49
-
50
- React.useEffect(() => {
51
- // to refresh _listeningIds every so often
52
- const tm = setInterval(rerender, 1000)
53
- return () => clearTimeout(tm as any)
34
+ useEffect(() => {
35
+ document.body.appendChild(node)
54
36
  }, [])
55
37
 
56
38
  if (themeProps['disable-child-theme'] || !isHydrated) {
@@ -68,23 +50,19 @@ export function ThemeDebug({
68
50
  padding: 5,
69
51
  }}
70
52
  >
71
- &lt;Theme {id} /&gt;&nbsp;
53
+ &lt;Theme {themeState.id} /&gt;&nbsp;
72
54
  {JSON.stringify(
73
55
  {
74
- propsName: themeProps.name,
75
- name: themeState?.state?.name,
76
- className: themeState?.state?.className,
77
- inverse: themeProps.inverse,
78
- forceClassName: themeProps.forceClassName,
79
- parent: themeState.themeManager?.state.parentName,
80
- id: themeState.themeManager?.id,
81
- parentId: themeState.themeManager?.parentManager?.id,
82
- isNew: themeState.isNewTheme,
83
- onChangeCount,
84
- listening: [...(themeState.themeManager?.['_listeningIds'] || [])].join(
85
- ','
86
- ),
87
- _numChangeEventsSent: themeState.themeManager?.['_numChangeEventsSent'],
56
+ name: themeState.name,
57
+ parentId: themeState.parentId,
58
+ inverses: themeState.inverses,
59
+ isNew: themeState.isNew,
60
+ themeProps: {
61
+ name: themeProps.name,
62
+ componentName: themeProps.componentName,
63
+ reset: themeProps.reset,
64
+ inverse: themeProps.inverse,
65
+ },
88
66
  },
89
67
  null,
90
68
  2
@@ -93,7 +71,7 @@ export function ThemeDebug({
93
71
  node
94
72
  )}
95
73
 
96
- <div style={{ color: 'red' }}>{id}</div>
74
+ <div style={{ color: 'red' }}>{themeState.id}</div>
97
75
 
98
76
  {children}
99
77
  </>
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useId } from 'react'
2
2
  import { isClient } from '@tamagui/constants'
3
3
 
4
4
  import { THEME_CLASSNAME_PREFIX } from '../constants/constants'
@@ -42,7 +42,7 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
42
42
  // if root class disabled, force class here
43
43
  forceClassName={!disableRootThemeClass && !themeClassNameOnRoot}
44
44
  // @ts-expect-error
45
- _isRoot
45
+ _isRoot={useId}
46
46
  >
47
47
  {props.children}
48
48
  </Theme>
@@ -1,8 +1,6 @@
1
1
  import * as Helpers from '@tamagui/helpers';
2
2
  export declare const Tamagui: {
3
3
  Helpers: typeof Helpers;
4
- getThemeManager: (id: number) => import("./helpers/ThemeManager").ThemeManager | undefined;
5
- readonly activeThemeManagers: Set<import("./helpers/ThemeManager").ThemeManager>;
6
4
  readonly mediaState: {
7
5
  [x: string]: boolean;
8
6
  [x: number]: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Tamagui.d.ts","sourceRoot":"","sources":["../src/Tamagui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAU3C,eAAO,MAAM,OAAO;;;;;;;;;;;;;aAoChB,CAAA;AAIJ,eAAO,MAAM,sBAAsB,eAAgB,MAAM,QAExD,CAAA;AAED,eAAO,MAAM,kBAAkB,eAAgB,MAAM,SAAS,GAAG,SAEhE,CAAA"}
1
+ {"version":3,"file":"Tamagui.d.ts","sourceRoot":"","sources":["../src/Tamagui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAS3C,eAAO,MAAM,OAAO;;;;;;;;;;;aA+BhB,CAAA;AAIJ,eAAO,MAAM,sBAAsB,eAAgB,MAAM,QAExD,CAAA;AAED,eAAO,MAAM,kBAAkB,eAAgB,MAAM,SAAS,GAAG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S,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { DebugProp } from '../types';
3
- export declare function createShallowSetState<State extends Object>(setter: React.Dispatch<React.SetStateAction<State>>, isDisabled?: boolean, transition?: boolean, debug?: DebugProp): (next?: Partial<State>) => void;
3
+ export declare function createShallowSetState<State extends Object>(setter: React.Dispatch<React.SetStateAction<State>>, isDisabled?: boolean, transition?: boolean, debug?: DebugProp, callback?: (nextState: any) => void): (next?: Partial<State>) => void;
4
4
  export declare function mergeIfNotShallowEqual(prev: any, next: any, isDisabled?: boolean, debug?: DebugProp): any;
5
5
  export declare function isEqualShallow(prev: any, next: any): boolean;
6
6
  //# sourceMappingURL=createShallowSetState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createShallowSetState.d.ts","sourceRoot":"","sources":["../../src/helpers/createShallowSetState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKzC,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EACxD,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EACnD,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,OAAO,EACpB,KAAK,CAAC,EAAE,SAAS,WAEF,OAAO,CAAC,KAAK,CAAC,UAM9B;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,GAAG,EACT,UAAU,CAAC,EAAE,OAAO,EACpB,KAAK,CAAC,EAAE,SAAS,OAgBlB;AAED,wBAAgB,cAAc,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,WAOxC"}
1
+ {"version":3,"file":"createShallowSetState.d.ts","sourceRoot":"","sources":["../../src/helpers/createShallowSetState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKzC,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EACxD,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EACnD,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,OAAO,EACpB,KAAK,CAAC,EAAE,SAAS,EACjB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,WAIzB,OAAO,CAAC,KAAK,CAAC,UAYzB;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,GAAG,EACT,UAAU,CAAC,EAAE,OAAO,EACpB,KAAK,CAAC,EAAE,SAAS,OAgBlB;AAED,wBAAgB,cAAc,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,WAOxC"}
@@ -0,0 +1,2 @@
1
+ export declare function doesRootSchemeMatchSystem(): boolean;
2
+ //# sourceMappingURL=doesRootSchemeMatchSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doesRootSchemeMatchSystem.d.ts","sourceRoot":"","sources":["../../src/hooks/doesRootSchemeMatchSystem.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,YAGxC"}
@@ -0,0 +1,2 @@
1
+ export declare function doesRootSchemeMatchSystem(): boolean;
2
+ //# sourceMappingURL=doesRootSchemeMatchSystem.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doesRootSchemeMatchSystem.native.d.ts","sourceRoot":"","sources":["../../src/hooks/doesRootSchemeMatchSystem.native.ts"],"names":[],"mappings":"AAGA,wBAAgB,yBAAyB,YAGxC"}
@@ -0,0 +1,25 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import type { Variable } from '../createVariable';
3
+ import type { ThemeParsed, Tokens, UseThemeWithStateProps, VariableVal, VariableValGeneric } from '../types';
4
+ import type { ThemeState } from './useThemeState';
5
+ export type ThemeProxied = {
6
+ [Key in keyof ThemeParsed | keyof Tokens['color']]: ThemeGettable<Key extends keyof ThemeParsed ? ThemeParsed[Key] : Variable<any>>;
7
+ } & {
8
+ [Key in string & {}]?: ThemeGettable<Variable<any>>;
9
+ };
10
+ type ThemeGettable<Val> = Val & {
11
+ /**
12
+ * Tries to return an optimized value that avoids the need for re-rendering:
13
+ * On web a CSS variable, on iOS a dynamic color, on Android it doesn't
14
+ * optimize and returns the underyling value.
15
+ *
16
+ * See: https://reactnative.dev/docs/dynamiccolorios
17
+ *
18
+ * @param platform when "web" it will only return the dynamic value for web, avoiding the iOS dynamic value.
19
+ * For things like SVG, gradients, or other external components that don't support it, use this option.
20
+ */
21
+ get: (platform?: 'web') => string | (Val extends Variable<infer X> ? X extends VariableValGeneric ? any : Exclude<X, Variable> : Val extends VariableVal ? string | number : unknown);
22
+ };
23
+ export declare function getThemeProxied(_props: UseThemeWithStateProps, state: ThemeState | null, _keys: MutableRefObject<Set<string> | null>): ThemeProxied;
24
+ export {};
25
+ //# sourceMappingURL=getThemeProxied.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getThemeProxied.d.ts","sourceRoot":"","sources":["../../src/hooks/getThemeProxied.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,MAAM,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B,CAAA"}
1
+ {"version":3,"file":"useComponentState.d.ts","sourceRoot":"","sources":["../../src/hooks/useComponentState.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EAEjB,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,SAAS,EAEV,MAAM,UAAU,CAAA;AAEjB,eAAO,MAAM,iBAAiB,UACrB,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BACtB,iBAAiB,gBAChC,YAAY,UAClB,qBAAqB;;;;;;;;;;;;;;;;;;;CAkO9B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useConfiguration.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfiguration.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;;;;;;+BAU0oE,CAAC;;;;;uBAAurjB,CAAC;aAAe,CAAC;;;;aAAo+B,CAAC;YAAqB,CAAC;cAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADj4pB,CAAA"}
1
+ {"version":3,"file":"useConfiguration.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfiguration.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;;;;;;+BAU0oE,CAAC;;;;;uBAAirjB,CAAC;aAAe,CAAC;;;;aAAo+B,CAAC;YAAqB,CAAC;cAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD33pB,CAAA"}
@@ -1,37 +1,10 @@
1
- import { type MutableRefObject } from 'react';
2
- import type { Variable } from '../createVariable';
3
- import type { ThemeManagerState } from '../helpers/ThemeManager';
4
- import { ThemeManager } from '../helpers/ThemeManager';
5
- import type { ThemeParsed, ThemeProps, Tokens, UseThemeWithStateProps, VariableVal, VariableValGeneric } from '../types';
6
- export type ChangedThemeResponse = {
7
- state?: ThemeManagerState;
8
- prevState?: ThemeManagerState;
9
- themeManager?: ThemeManager | null;
10
- isNewTheme: boolean;
11
- inversed?: null | boolean;
12
- mounted?: boolean;
13
- };
14
- export type ThemeGettable<Val> = Val & {
15
- /**
16
- * Tries to return an optimized value that avoids the need for re-rendering:
17
- * On web a CSS variable, on iOS a dynamic color, on Android it doesn't
18
- * optimize and returns the underyling value.
19
- *
20
- * See: https://reactnative.dev/docs/dynamiccolorios
21
- *
22
- * @param platform when "web" it will only return the dynamic value for web, avoiding the iOS dynamic value.
23
- * For things like SVG, gradients, or other external components that don't support it, use this option.
24
- */
25
- get: (platform?: 'web') => string | (Val extends Variable<infer X> ? X extends VariableValGeneric ? any : Exclude<X, Variable> : Val extends VariableVal ? string | number : unknown);
26
- };
27
- export type UseThemeResult = {
28
- [Key in keyof ThemeParsed | keyof Tokens['color']]: ThemeGettable<Key extends keyof ThemeParsed ? ThemeParsed[Key] : Variable<any>>;
29
- } & {
30
- [Key in string & {}]?: ThemeGettable<Variable<any>>;
31
- };
32
- export declare const useTheme: (props?: ThemeProps) => UseThemeResult;
33
- export declare const useThemeWithState: (props: UseThemeWithStateProps) => [ChangedThemeResponse, ThemeParsed];
34
- export declare const activeThemeManagers: Set<ThemeManager>;
35
- export declare const getThemeManager: (id: number) => ThemeManager | undefined;
36
- export declare const useChangeThemeEffect: (props: UseThemeWithStateProps, isRoot?: boolean, keys?: MutableRefObject<string[] | null>) => ChangedThemeResponse;
1
+ import type { ThemeParsed, ThemeProps, UseThemeWithStateProps } from '../types';
2
+ import { type ThemeProxied } from './getThemeProxied';
3
+ import type { ThemeState } from './useThemeState';
4
+ export declare const useTheme: (props?: ThemeProps) => ThemeProxied;
5
+ export type ThemeWithState = [ThemeParsed, ThemeState];
6
+ /**
7
+ * Adds a proxy around themeState that tracks update keys
8
+ */
9
+ export declare const useThemeWithState: (props: UseThemeWithStateProps, isRoot?: boolean) => ThemeWithState;
37
10
  //# sourceMappingURL=useTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,YAAY,EAA4B,MAAM,yBAAyB,CAAA;AAGhF,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAClC,UAAU,EAAE,OAAO,CAAA;IAGnB,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAID,MAAM,MAAM,aAAa,CAAC,GAAG,IAAI,GAAG,GAAG;IACrC;;;;;;;;;OASG;IACH,GAAG,EAAE,CACH,QAAQ,CAAC,EAAE,KAAK,KAEd,MAAM,GACN,CAAC,GAAG,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAC1B,CAAC,SAAS,kBAAkB,GAC1B,GAAG,GACH,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,GACtB,GAAG,SAAS,WAAW,GACrB,MAAM,GAAG,MAAM,GACf,OAAO,CAAC,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;KAC1B,GAAG,IAAI,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,aAAa,CAC/D,GAAG,SAAS,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CACjE;CACF,GAAG;KAED,GAAG,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CACpD,CAAA;AAED,eAAO,MAAM,QAAQ,WAAW,UAAU,KAG1B,cACf,CAAA;AAED,eAAO,MAAM,iBAAiB,UACrB,sBAAsB,KAC5B,CAAC,oBAAoB,EAAE,WAAW,CAoCpC,CAAA;AAmJD,eAAO,MAAM,mBAAmB,mBAA0B,CAAA;AAO1D,eAAO,MAAM,eAAe,OAAQ,MAAM,6BAEzC,CAAA;AAiDD,eAAO,MAAM,oBAAoB,UACxB,sBAAsB,2BAEtB,gBAAgB,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,KACvC,oBAqUF,CAAA"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGjD,eAAO,MAAM,QAAQ,WAAW,UAAU,KAG1B,YACf,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UACrB,sBAAsB,uBAE5B,cAmBF,CAAA"}
@@ -1,5 +1,3 @@
1
1
  import type { ThemeName } from '../types';
2
- export declare function useThemeName(opts?: {
3
- parent?: true;
4
- }): ThemeName;
2
+ export declare function useThemeName(): ThemeName;
5
3
  //# sourceMappingURL=useThemeName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useThemeName.d.ts","sourceRoot":"","sources":["../../src/hooks/useThemeName.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAgBhE"}
1
+ {"version":3,"file":"useThemeName.d.ts","sourceRoot":"","sources":["../../src/hooks/useThemeName.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAOzC,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
@@ -0,0 +1,22 @@
1
+ import { type MutableRefObject } from 'react';
2
+ import type { ThemeParsed, ThemeProps, UseThemeWithStateProps } from '../types';
3
+ type ID = string;
4
+ export type ThemeState = {
5
+ id: ID;
6
+ name: string;
7
+ theme: ThemeParsed;
8
+ inverses: number;
9
+ parentName?: string;
10
+ isInverse?: boolean;
11
+ isNew?: boolean;
12
+ parentId?: ID;
13
+ scheme?: 'light' | 'dark';
14
+ };
15
+ export declare const ThemeStateContext: import("react").Context<string>;
16
+ export declare const forceUpdateThemes: () => void;
17
+ export declare const getThemeState: (id: ID) => ThemeState | undefined;
18
+ export declare const getRootThemeState: () => ThemeState | null;
19
+ export declare const useThemeState: (props: UseThemeWithStateProps, isRoot: boolean | undefined, keys: MutableRefObject<Set<string> | null>) => ThemeState;
20
+ export declare const hasThemeUpdatingProps: (props: ThemeProps) => boolean;
21
+ export {};
22
+ //# sourceMappingURL=useThemeState.d.ts.map