@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.
- package/dist/cjs/Tamagui.cjs +1 -6
- package/dist/cjs/Tamagui.js +1 -5
- package/dist/cjs/Tamagui.js.map +1 -1
- package/dist/cjs/Tamagui.native.js +2 -8
- package/dist/cjs/Tamagui.native.js.map +2 -2
- package/dist/cjs/createComponent.cjs +9 -13
- package/dist/cjs/createComponent.js +10 -8
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +17 -19
- package/dist/cjs/createComponent.native.js.map +2 -2
- package/dist/cjs/helpers/createShallowSetState.cjs +7 -4
- package/dist/cjs/helpers/createShallowSetState.js +12 -6
- package/dist/cjs/helpers/createShallowSetState.js.map +1 -1
- package/dist/cjs/helpers/createShallowSetState.native.js +10 -4
- package/dist/cjs/helpers/createShallowSetState.native.js.map +2 -2
- package/dist/cjs/hooks/{shouldDeoptDueToParentScheme.cjs → doesRootSchemeMatchSystem.cjs} +5 -5
- package/dist/cjs/hooks/{shouldDeoptDueToParentScheme.js → doesRootSchemeMatchSystem.js} +6 -6
- package/dist/cjs/hooks/doesRootSchemeMatchSystem.js.map +6 -0
- package/dist/cjs/hooks/doesRootSchemeMatchSystem.native.js +30 -0
- package/dist/cjs/hooks/doesRootSchemeMatchSystem.native.js.map +6 -0
- package/dist/cjs/hooks/getThemeProxied.cjs +58 -0
- package/dist/cjs/hooks/getThemeProxied.js +53 -0
- package/dist/cjs/hooks/getThemeProxied.js.map +6 -0
- package/dist/cjs/hooks/getThemeProxied.native.js +76 -0
- package/dist/cjs/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/cjs/hooks/useComponentState.cjs +16 -16
- package/dist/cjs/hooks/useComponentState.js +22 -15
- package/dist/cjs/hooks/useComponentState.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.native.js +15 -15
- package/dist/cjs/hooks/useComponentState.native.js.map +2 -2
- package/dist/cjs/hooks/useProps.cjs +2 -2
- package/dist/cjs/hooks/useProps.js +2 -2
- package/dist/cjs/hooks/useProps.js.map +1 -1
- package/dist/cjs/hooks/useProps.native.js +2 -2
- package/dist/cjs/hooks/useProps.native.js.map +2 -2
- package/dist/cjs/hooks/useTheme.cjs +10 -208
- package/dist/cjs/hooks/useTheme.js +7 -207
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useTheme.native.js +8 -252
- package/dist/cjs/hooks/useTheme.native.js.map +2 -2
- package/dist/cjs/hooks/useThemeName.cjs +15 -27
- package/dist/cjs/hooks/useThemeName.js +6 -20
- package/dist/cjs/hooks/useThemeName.js.map +2 -2
- package/dist/cjs/hooks/useThemeName.native.js +16 -22
- package/dist/cjs/hooks/useThemeName.native.js.map +2 -2
- package/dist/cjs/hooks/useThemeState.cjs +187 -0
- package/dist/cjs/hooks/useThemeState.js +159 -0
- package/dist/cjs/hooks/useThemeState.js.map +6 -0
- package/dist/cjs/hooks/useThemeState.native.js +206 -0
- package/dist/cjs/hooks/useThemeState.native.js.map +6 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +3 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Theme.cjs +81 -85
- package/dist/cjs/views/Theme.js +44 -51
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/Theme.native.js +58 -58
- package/dist/cjs/views/Theme.native.js.map +2 -2
- package/dist/cjs/views/ThemeDebug.cjs +21 -43
- package/dist/cjs/views/ThemeDebug.js +18 -38
- package/dist/cjs/views/ThemeDebug.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.cjs +1 -1
- package/dist/cjs/views/ThemeProvider.js +1 -1
- package/dist/cjs/views/ThemeProvider.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.native.js +1 -1
- package/dist/cjs/views/ThemeProvider.native.js.map +2 -2
- package/dist/esm/Tamagui.js +0 -5
- package/dist/esm/Tamagui.js.map +1 -1
- package/dist/esm/Tamagui.mjs +0 -5
- package/dist/esm/Tamagui.mjs.map +1 -1
- package/dist/esm/Tamagui.native.js +1 -8
- package/dist/esm/Tamagui.native.js.map +2 -2
- package/dist/esm/createComponent.js +9 -8
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +9 -13
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +16 -19
- package/dist/esm/createComponent.native.js.map +2 -2
- package/dist/esm/helpers/createShallowSetState.js +13 -7
- package/dist/esm/helpers/createShallowSetState.js.map +1 -1
- package/dist/esm/helpers/createShallowSetState.mjs +8 -5
- package/dist/esm/helpers/createShallowSetState.mjs.map +1 -1
- package/dist/esm/helpers/createShallowSetState.native.js +11 -5
- package/dist/esm/helpers/createShallowSetState.native.js.map +2 -2
- package/dist/esm/hooks/doesRootSchemeMatchSystem.js +7 -0
- package/dist/esm/hooks/doesRootSchemeMatchSystem.js.map +6 -0
- package/dist/esm/hooks/doesRootSchemeMatchSystem.mjs +5 -0
- package/dist/esm/hooks/doesRootSchemeMatchSystem.mjs.map +1 -0
- package/dist/esm/hooks/doesRootSchemeMatchSystem.native.js +10 -0
- package/dist/esm/hooks/doesRootSchemeMatchSystem.native.js.map +6 -0
- package/dist/esm/hooks/getThemeProxied.js +40 -0
- package/dist/esm/hooks/getThemeProxied.js.map +6 -0
- package/dist/esm/hooks/getThemeProxied.mjs +35 -0
- package/dist/esm/hooks/getThemeProxied.mjs.map +1 -0
- package/dist/esm/hooks/getThemeProxied.native.js +59 -0
- package/dist/esm/hooks/getThemeProxied.native.js.map +6 -0
- package/dist/esm/hooks/useComponentState.js +22 -15
- package/dist/esm/hooks/useComponentState.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +16 -16
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +15 -15
- package/dist/esm/hooks/useComponentState.native.js.map +2 -2
- package/dist/esm/hooks/useProps.js +2 -2
- package/dist/esm/hooks/useProps.js.map +1 -1
- package/dist/esm/hooks/useProps.mjs +2 -2
- package/dist/esm/hooks/useProps.mjs.map +1 -1
- package/dist/esm/hooks/useProps.native.js +2 -2
- package/dist/esm/hooks/useProps.native.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +9 -220
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useTheme.mjs +10 -205
- package/dist/esm/hooks/useTheme.mjs.map +1 -1
- package/dist/esm/hooks/useTheme.native.js +11 -257
- package/dist/esm/hooks/useTheme.native.js.map +2 -2
- package/dist/esm/hooks/useThemeName.js +4 -12
- package/dist/esm/hooks/useThemeName.js.map +2 -2
- package/dist/esm/hooks/useThemeName.mjs +11 -12
- package/dist/esm/hooks/useThemeName.mjs.map +1 -1
- package/dist/esm/hooks/useThemeName.native.js +15 -14
- package/dist/esm/hooks/useThemeName.native.js.map +2 -2
- package/dist/esm/hooks/useThemeState.js +151 -0
- package/dist/esm/hooks/useThemeState.js.map +6 -0
- package/dist/esm/hooks/useThemeState.mjs +159 -0
- package/dist/esm/hooks/useThemeState.mjs.map +1 -0
- package/dist/esm/hooks/useThemeState.native.js +182 -0
- package/dist/esm/hooks/useThemeState.native.js.map +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
- package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
- package/dist/esm/views/Theme.js +57 -54
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/Theme.mjs +81 -85
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +61 -61
- package/dist/esm/views/Theme.native.js.map +2 -2
- package/dist/esm/views/ThemeDebug.js +16 -29
- package/dist/esm/views/ThemeDebug.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +16 -27
- package/dist/esm/views/ThemeDebug.mjs.map +1 -1
- package/dist/esm/views/ThemeProvider.js +2 -2
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeProvider.mjs +2 -2
- package/dist/esm/views/ThemeProvider.mjs.map +1 -1
- package/dist/esm/views/ThemeProvider.native.js +2 -2
- package/dist/esm/views/ThemeProvider.native.js.map +2 -2
- package/package.json +11 -11
- package/src/Tamagui.ts +0 -6
- package/src/createComponent.tsx +19 -28
- package/src/helpers/createShallowSetState.tsx +17 -8
- package/src/hooks/doesRootSchemeMatchSystem.native.ts +7 -0
- package/src/hooks/doesRootSchemeMatchSystem.ts +4 -0
- package/src/hooks/getThemeProxied.ts +165 -0
- package/src/hooks/useComponentState.ts +26 -21
- package/src/hooks/useProps.tsx +2 -2
- package/src/hooks/useTheme.tsx +22 -633
- package/src/hooks/useThemeName.tsx +6 -18
- package/src/hooks/useThemeState.ts +341 -0
- package/src/index.ts +1 -0
- package/src/types.tsx +2 -2
- package/src/views/TamaguiProvider.tsx +1 -1
- package/src/views/Theme.tsx +129 -132
- package/src/views/ThemeDebug.native.tsx +2 -2
- package/src/views/ThemeDebug.tsx +17 -39
- package/src/views/ThemeProvider.tsx +2 -2
- package/types/Tamagui.d.ts +0 -2
- package/types/Tamagui.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createShallowSetState.d.ts +1 -1
- package/types/helpers/createShallowSetState.d.ts.map +1 -1
- package/types/hooks/doesRootSchemeMatchSystem.d.ts +2 -0
- package/types/hooks/doesRootSchemeMatchSystem.d.ts.map +1 -0
- package/types/hooks/doesRootSchemeMatchSystem.native.d.ts +2 -0
- package/types/hooks/doesRootSchemeMatchSystem.native.d.ts.map +1 -0
- package/types/hooks/getThemeProxied.d.ts +25 -0
- package/types/hooks/getThemeProxied.d.ts.map +1 -0
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useConfiguration.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +9 -36
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/hooks/useThemeName.d.ts +1 -3
- package/types/hooks/useThemeName.d.ts.map +1 -1
- package/types/hooks/useThemeState.d.ts +22 -0
- package/types/hooks/useThemeState.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts +3 -3
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts +2 -2
- package/types/views/ThemeDebug.d.ts.map +1 -1
- package/types/views/ThemeDebug.native.d.ts +2 -2
- package/types/views/ThemeDebug.native.d.ts.map +1 -1
- package/dist/cjs/helpers/ThemeManager.cjs +0 -202
- package/dist/cjs/helpers/ThemeManager.js +0 -183
- package/dist/cjs/helpers/ThemeManager.js.map +0 -6
- package/dist/cjs/helpers/ThemeManager.native.js +0 -282
- package/dist/cjs/helpers/ThemeManager.native.js.map +0 -6
- package/dist/cjs/helpers/ThemeManagerContext.cjs +0 -38
- package/dist/cjs/helpers/ThemeManagerContext.js +0 -30
- package/dist/cjs/helpers/ThemeManagerContext.js.map +0 -6
- package/dist/cjs/helpers/ThemeManagerContext.native.js +0 -34
- package/dist/cjs/helpers/ThemeManagerContext.native.js.map +0 -6
- package/dist/cjs/hooks/shouldDeoptDueToParentScheme.js.map +0 -6
- package/dist/cjs/hooks/shouldDeoptDueToParentScheme.native.js +0 -50
- package/dist/cjs/hooks/shouldDeoptDueToParentScheme.native.js.map +0 -6
- package/dist/esm/helpers/ThemeManager.js +0 -169
- package/dist/esm/helpers/ThemeManager.js.map +0 -6
- package/dist/esm/helpers/ThemeManager.mjs +0 -177
- package/dist/esm/helpers/ThemeManager.mjs.map +0 -1
- package/dist/esm/helpers/ThemeManager.native.js +0 -261
- package/dist/esm/helpers/ThemeManager.native.js.map +0 -6
- package/dist/esm/helpers/ThemeManagerContext.js +0 -6
- package/dist/esm/helpers/ThemeManagerContext.js.map +0 -6
- package/dist/esm/helpers/ThemeManagerContext.mjs +0 -4
- package/dist/esm/helpers/ThemeManagerContext.mjs.map +0 -1
- package/dist/esm/helpers/ThemeManagerContext.native.js +0 -6
- package/dist/esm/helpers/ThemeManagerContext.native.js.map +0 -6
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.js +0 -7
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.js.map +0 -6
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.mjs +0 -5
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.mjs.map +0 -1
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.native.js +0 -29
- package/dist/esm/hooks/shouldDeoptDueToParentScheme.native.js.map +0 -6
- package/src/helpers/ThemeManager.tsx +0 -405
- package/src/helpers/ThemeManagerContext.tsx +0 -4
- package/src/hooks/shouldDeoptDueToParentScheme.native.tsx +0 -37
- package/src/hooks/shouldDeoptDueToParentScheme.tsx +0 -6
- package/types/helpers/ThemeManager.d.ts +0 -45
- package/types/helpers/ThemeManager.d.ts.map +0 -1
- package/types/helpers/ThemeManagerContext.d.ts +0 -4
- package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
- package/types/hooks/shouldDeoptDueToParentScheme.d.ts +0 -3
- package/types/hooks/shouldDeoptDueToParentScheme.d.ts.map +0 -1
- package/types/hooks/shouldDeoptDueToParentScheme.native.d.ts +0 -3
- package/types/hooks/shouldDeoptDueToParentScheme.native.d.ts.map +0 -1
package/src/views/Theme.tsx
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
2
|
import type { MutableRefObject } from 'react'
|
|
3
|
-
import 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 {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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 =
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
-
<
|
|
123
|
-
{
|
|
124
|
-
</
|
|
82
|
+
children = (
|
|
83
|
+
<ThemeStateContext.Provider value={themeState.id}>
|
|
84
|
+
{children}
|
|
85
|
+
</ThemeStateContext.Provider>
|
|
125
86
|
)
|
|
126
87
|
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
|
176
|
+
return children
|
|
186
177
|
}
|
|
187
178
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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 {
|
|
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:
|
|
9
|
+
themeState: ThemeState
|
|
10
10
|
themeProps: ThemeProps
|
|
11
11
|
children: any
|
|
12
12
|
}) {
|
package/src/views/ThemeDebug.tsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
|
|
3
|
-
import {
|
|
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:
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
<Theme {id} />
|
|
53
|
+
<Theme {themeState.id} />
|
|
72
54
|
{JSON.stringify(
|
|
73
55
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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>
|
package/types/Tamagui.d.ts
CHANGED
|
@@ -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;
|
package/types/Tamagui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tamagui.d.ts","sourceRoot":"","sources":["../src/Tamagui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,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,SAEhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAmBxC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAG/E,OAAO,KAAK,EAEV,SAAS,EAGT,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAElB,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EAMf,MAAM,SAAS,CAAA;AAYhB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AAuF9D,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,wEAukC3B;AAoBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,OAEjD;yBAFe,QAAQ;;;AAkBxB,eAAO,MAAM,MAAM,yFA0CjB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,GAAG,OAAO,CAAA;IACpC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,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,
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"doesRootSchemeMatchSystem.d.ts","sourceRoot":"","sources":["../../src/hooks/doesRootSchemeMatchSystem.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,YAGxC"}
|
|
@@ -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,YAAY,GAAG;KACxB,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,KAAK,aAAa,CAAC,GAAG,IAAI,GAAG,GAAG;IAC9B;;;;;;;;;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;AAWD,wBAAgB,eAAe,CAE7B,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,GAC1C,YAAY,CAsGd"}
|
|
@@ -1 +1 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;
|
|
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 {
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeName.d.ts","sourceRoot":"","sources":["../../src/hooks/useThemeName.tsx"],"names":[],"mappings":"
|
|
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
|