@tamagui/web 1.52.6 → 1.52.8
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/config.js +14 -10
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/createTamagui.js +20 -11
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createVariables.js +10 -4
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js +31 -32
- package/dist/cjs/helpers/ThemeManager.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
- package/dist/cjs/helpers/propMapper.js +1 -1
- package/dist/cjs/helpers/propMapper.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeToParents.js +5 -2
- package/dist/cjs/helpers/proxyThemeToParents.js.map +1 -1
- package/dist/cjs/helpers/themeable.js +5 -1
- package/dist/cjs/helpers/themeable.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +6 -2
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/views/ThemeDebug.js +2 -2
- package/dist/cjs/views/ThemeDebug.js.map +1 -1
- package/dist/esm/config.js +12 -10
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/createTamagui.js +21 -12
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createVariables.js +10 -4
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js +31 -32
- package/dist/esm/helpers/ThemeManager.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.js.map +1 -1
- package/dist/esm/helpers/propMapper.js +1 -1
- package/dist/esm/helpers/propMapper.js.map +1 -1
- package/dist/esm/helpers/proxyThemeToParents.js +6 -3
- package/dist/esm/helpers/proxyThemeToParents.js.map +1 -1
- package/dist/esm/helpers/themeable.js +5 -1
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +6 -2
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/views/ThemeDebug.js +2 -2
- package/dist/esm/views/ThemeDebug.js.map +1 -1
- package/package.json +10 -10
- package/src/config.ts +19 -13
- package/src/createTamagui.ts +28 -15
- package/src/createVariables.ts +15 -4
- package/src/helpers/ThemeManager.tsx +32 -35
- package/src/helpers/insertStyleRule.tsx +2 -5
- package/src/helpers/propMapper.ts +1 -1
- package/src/helpers/proxyThemeToParents.ts +11 -3
- package/src/helpers/themeable.tsx +5 -1
- package/src/hooks/useTheme.tsx +33 -7
- package/src/types.tsx +5 -3
- package/src/views/ThemeDebug.tsx +2 -2
- package/types/config.d.ts +19 -17
- package/types/config.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createVariables.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +3 -2
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/proxyThemeToParents.d.ts.map +1 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +8 -4
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +6 -3
- package/types/types.d.ts.map +1 -1
package/src/createTamagui.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
2
|
|
|
3
|
-
import { configListeners, setConfig } from './config'
|
|
4
|
-
import { Variable } from './createVariable'
|
|
3
|
+
import { configListeners, setConfig, setTokens } from './config'
|
|
4
|
+
import { Variable, createVariable, isVariable } from './createVariable'
|
|
5
5
|
import { createVariables } from './createVariables'
|
|
6
6
|
import { getThemeCSSRules } from './helpers/getThemeCSSRules'
|
|
7
7
|
import {
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
TamaguiInternalConfig,
|
|
25
25
|
ThemeParsed,
|
|
26
26
|
ThemesLikeObject,
|
|
27
|
+
TokensMerged,
|
|
28
|
+
TokensParsed,
|
|
27
29
|
} from './types'
|
|
28
30
|
|
|
29
31
|
// config is re-run by the @tamagui/static, dont double validate
|
|
@@ -48,13 +50,25 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
53
|
+
// ensure variables
|
|
54
|
+
const tokens = createVariables(configIn.tokens)
|
|
55
|
+
|
|
56
|
+
// faster lookups
|
|
57
|
+
const tokensParsed: TokensParsed = {} as any
|
|
58
|
+
const tokensMerged: TokensMerged = {} as any
|
|
59
|
+
for (const cat in tokens) {
|
|
60
|
+
tokensParsed[cat] = {}
|
|
61
|
+
tokensMerged[cat] = {}
|
|
62
|
+
const tokenCat = tokens[cat]
|
|
63
|
+
for (const key in tokenCat) {
|
|
64
|
+
const val = tokenCat[key]
|
|
65
|
+
const prefixedKey = `$${key}`
|
|
66
|
+
tokensParsed[cat][prefixedKey] = val as any
|
|
67
|
+
tokensMerged[cat][prefixedKey] = val as any
|
|
68
|
+
tokensMerged[cat][key] = val as any
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
setTokens(tokensMerged)
|
|
58
72
|
|
|
59
73
|
const noThemes = Object.keys(configIn.themes).length === 0
|
|
60
74
|
const foundThemes = scanAllSheets(noThemes, tokensParsed)
|
|
@@ -93,9 +107,9 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
|
|
|
93
107
|
{ name: string; declarations: string[]; language?: string }
|
|
94
108
|
> = {}
|
|
95
109
|
|
|
96
|
-
for (const key in
|
|
97
|
-
for (const skey in
|
|
98
|
-
const variable =
|
|
110
|
+
for (const key in tokens) {
|
|
111
|
+
for (const skey in tokens[key]) {
|
|
112
|
+
const variable = tokens[key][skey] as any as Variable
|
|
99
113
|
|
|
100
114
|
// set specific tokens (like $size.sm)
|
|
101
115
|
specificTokens[`$${key}.${skey}`] = variable
|
|
@@ -240,8 +254,7 @@ ${runtimeStyles}`
|
|
|
240
254
|
animations: {} as any,
|
|
241
255
|
media: {},
|
|
242
256
|
...configIn,
|
|
243
|
-
|
|
244
|
-
tokens: configIn.tokens as any,
|
|
257
|
+
tokens: tokens as any,
|
|
245
258
|
// vite made this into a function if it wasn't set
|
|
246
259
|
shorthands,
|
|
247
260
|
inverseShorthands: shorthands
|
|
@@ -250,7 +263,7 @@ ${runtimeStyles}`
|
|
|
250
263
|
themes: themeConfig.themes as any,
|
|
251
264
|
fontsParsed,
|
|
252
265
|
themeConfig,
|
|
253
|
-
tokensParsed,
|
|
266
|
+
tokensParsed: tokensParsed as any,
|
|
254
267
|
parsed: true,
|
|
255
268
|
getNewCSS,
|
|
256
269
|
getCSS,
|
package/src/createVariables.ts
CHANGED
|
@@ -14,18 +14,25 @@ export type DeepVariableObject<A extends DeepTokenObject> = {
|
|
|
14
14
|
: never
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const cache = new WeakMap()
|
|
18
|
+
|
|
19
|
+
// recursive...
|
|
20
|
+
|
|
17
21
|
export const createVariables = <A extends DeepTokenObject>(
|
|
18
22
|
tokens: A,
|
|
19
23
|
parentPath = '',
|
|
20
24
|
isFont = false
|
|
21
25
|
): DeepVariableObject<A> => {
|
|
26
|
+
if (cache.has(tokens)) return tokens
|
|
27
|
+
|
|
22
28
|
const res: any = {}
|
|
23
29
|
let i = 0
|
|
24
30
|
for (let keyIn in tokens) {
|
|
25
31
|
i++
|
|
26
32
|
const val = tokens[keyIn]
|
|
27
|
-
const
|
|
28
|
-
const
|
|
33
|
+
const isPrefixed = keyIn[0] === '$'
|
|
34
|
+
const keyWithPrefix = isPrefixed ? keyIn : `$${keyIn}`
|
|
35
|
+
const key = isPrefixed ? keyWithPrefix.slice(1) : keyIn
|
|
29
36
|
if (isVariable(val)) {
|
|
30
37
|
res[key] = val
|
|
31
38
|
continue
|
|
@@ -35,11 +42,15 @@ export const createVariables = <A extends DeepTokenObject>(
|
|
|
35
42
|
name = parentPath ? `${parentPath}-${name}` : niceKey
|
|
36
43
|
if (val && typeof val === 'object') {
|
|
37
44
|
// recurse
|
|
38
|
-
res[key] = createVariables(tokens[key] as any, name)
|
|
45
|
+
res[key] = createVariables(tokens[key] as any, name, isFont)
|
|
39
46
|
continue
|
|
40
47
|
}
|
|
41
|
-
|
|
48
|
+
const finalValue = isVariable(val)
|
|
49
|
+
? val
|
|
50
|
+
: createVariable({ val, name, key: keyWithPrefix })
|
|
51
|
+
res[key] = finalValue
|
|
42
52
|
}
|
|
43
53
|
|
|
54
|
+
cache.set(res, true)
|
|
44
55
|
return res
|
|
45
56
|
}
|
|
@@ -46,7 +46,7 @@ export class ThemeManager {
|
|
|
46
46
|
parentManagerIn?: ThemeManager | 'root' | null | undefined
|
|
47
47
|
) {
|
|
48
48
|
if (parentManagerIn === 'root') {
|
|
49
|
-
this.
|
|
49
|
+
this.updateStateFromProps(props, false)
|
|
50
50
|
return
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -66,51 +66,47 @@ export class ThemeManager {
|
|
|
66
66
|
|
|
67
67
|
this.parentManager = parentManagerIn
|
|
68
68
|
|
|
69
|
-
if (this.
|
|
69
|
+
if (this.updateStateFromProps(props, false)) {
|
|
70
70
|
return
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return parentManagerIn || this
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
updateStateFromProps(
|
|
77
77
|
props: ThemeProps & { forceTheme?: ThemeParsed } = this.props || {},
|
|
78
78
|
shouldNotify = true
|
|
79
79
|
) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})()
|
|
93
|
-
|
|
94
|
-
if (isChanging) {
|
|
95
|
-
const names = this.state.name.split('_')
|
|
96
|
-
const lastName = names[names.length - 1][0]
|
|
97
|
-
this.isComponent = lastName[0] === lastName[0].toUpperCase()
|
|
98
|
-
this._allKeys = null
|
|
99
|
-
this.scheme = names[0] === 'light' ? 'light' : names[0] === 'dark' ? 'dark' : null
|
|
100
|
-
|
|
101
|
-
if (process.env.NODE_ENV === 'development') {
|
|
102
|
-
this['_numChangeEventsSent'] ??= 0
|
|
103
|
-
this['_numChangeEventsSent']++
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (shouldNotify) {
|
|
107
|
-
queueMicrotask(() => {
|
|
108
|
-
this.notify(!!props.forceTheme)
|
|
109
|
-
})
|
|
110
|
-
}
|
|
80
|
+
this.props = props
|
|
81
|
+
if (props.forceTheme) {
|
|
82
|
+
this.state.theme = props.forceTheme
|
|
83
|
+
this.state.name = props.name || ''
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
const nextState = this.getStateIfChanged(props)
|
|
87
|
+
if (nextState) {
|
|
88
|
+
this.updateState(nextState, shouldNotify)
|
|
89
|
+
return nextState
|
|
90
|
+
}
|
|
91
|
+
}
|
|
111
92
|
|
|
112
|
-
|
|
93
|
+
updateState(nextState: ThemeManagerState, shouldNotify = true) {
|
|
94
|
+
this.state = nextState
|
|
95
|
+
const names = this.state.name.split('_')
|
|
96
|
+
const lastName = names[names.length - 1][0]
|
|
97
|
+
this.isComponent = lastName[0] === lastName[0].toUpperCase()
|
|
98
|
+
this._allKeys = null
|
|
99
|
+
this.scheme = names[0] === 'light' ? 'light' : names[0] === 'dark' ? 'dark' : null
|
|
100
|
+
if (process.env.NODE_ENV === 'development') {
|
|
101
|
+
this['_numChangeEventsSent'] ??= 0
|
|
102
|
+
this['_numChangeEventsSent']++
|
|
113
103
|
}
|
|
104
|
+
if (shouldNotify) {
|
|
105
|
+
queueMicrotask(() => {
|
|
106
|
+
this.notify()
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
return this.state
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
getStateIfChanged(
|
|
@@ -119,6 +115,7 @@ export class ThemeManager {
|
|
|
119
115
|
parentManager = this.parentManager
|
|
120
116
|
) {
|
|
121
117
|
const _ = this.getState(props, parentManager)
|
|
118
|
+
|
|
122
119
|
// is removing
|
|
123
120
|
if (state && state !== emptyState && !_) {
|
|
124
121
|
return parentManager?.state
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { isClient } from '@tamagui/constants'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { Variable, createVariable } from '../createVariable'
|
|
3
|
+
import { createVariable } from '../createVariable'
|
|
5
4
|
import type {
|
|
6
5
|
DedupedTheme,
|
|
7
6
|
DedupedThemes,
|
|
8
7
|
RulesToInsert,
|
|
9
8
|
ThemeParsed,
|
|
10
|
-
Tokens,
|
|
11
9
|
TokensParsed,
|
|
12
10
|
} from '../types'
|
|
13
|
-
import { ensureThemeVariable } from './themes'
|
|
14
11
|
|
|
15
12
|
const allSelectors: Record<string, string> = {}
|
|
16
13
|
const allRules: Record<string, string> = {}
|
|
@@ -255,7 +252,7 @@ function addThemesFromCSS(cssStyleRule: CSSStyleRule, tokens?: TokensParsed) {
|
|
|
255
252
|
val: value,
|
|
256
253
|
},
|
|
257
254
|
true
|
|
258
|
-
)
|
|
255
|
+
) as any
|
|
259
256
|
}
|
|
260
257
|
|
|
261
258
|
const dedupedEntry: DedupedTheme = {
|
|
@@ -56,7 +56,7 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
|
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
if (variants && key in variants
|
|
59
|
+
if (variants && key in variants) {
|
|
60
60
|
styleState.curProps[key] = value
|
|
61
61
|
|
|
62
62
|
const variantValue = resolveVariants(key, value, styleProps, styleState, '')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getToken } from '../config'
|
|
1
|
+
import { getToken, getTokenObject, getTokens } from '../config'
|
|
2
2
|
import { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'
|
|
3
3
|
import { DedupedThemes, ThemeParsed } from '../types'
|
|
4
4
|
|
|
@@ -51,7 +51,15 @@ export function proxyThemeToParents(themeName: string, theme: ThemeParsed) {
|
|
|
51
51
|
return new Proxy(theme, {
|
|
52
52
|
get(target, key) {
|
|
53
53
|
if (key === GetThemeUnwrapped) return theme
|
|
54
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
key == null ||
|
|
56
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
57
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
58
|
+
key == 'undefined' ||
|
|
59
|
+
Reflect.has(target, key)
|
|
60
|
+
) {
|
|
61
|
+
return Reflect.get(target, key)
|
|
62
|
+
}
|
|
55
63
|
// check parents
|
|
56
64
|
for (let i = numParents - 1; i >= 0; i--) {
|
|
57
65
|
const parent = themesRaw[parents[i]]
|
|
@@ -60,7 +68,7 @@ export function proxyThemeToParents(themeName: string, theme: ThemeParsed) {
|
|
|
60
68
|
return Reflect.get(parent, key)
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
|
-
return
|
|
71
|
+
return getTokenObject(key as any) ?? Reflect.get(target, key)
|
|
64
72
|
},
|
|
65
73
|
})
|
|
66
74
|
}
|
|
@@ -18,7 +18,11 @@ export function themeable<Component extends (props: any) => any>(
|
|
|
18
18
|
const withThemeComponent = forwardRef(function WithTheme(props: ThemeableProps, ref) {
|
|
19
19
|
const { themeInverse, theme, componentName, themeReset, ...rest } = props
|
|
20
20
|
|
|
21
|
-
const element = React.createElement(component, {
|
|
21
|
+
const element = React.createElement(component, {
|
|
22
|
+
...rest,
|
|
23
|
+
ref,
|
|
24
|
+
'data-disable-theme': true,
|
|
25
|
+
} as any)
|
|
22
26
|
|
|
23
27
|
let contents = (
|
|
24
28
|
<Theme
|
package/src/hooks/useTheme.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { isClient, isServer, isWeb } from '@tamagui/constants'
|
|
|
3
3
|
import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
4
4
|
|
|
5
5
|
import { getConfig } from '../config'
|
|
6
|
-
import { getVariable } from '../createVariable'
|
|
6
|
+
import { Variable, getVariable } from '../createVariable'
|
|
7
7
|
import { createProxy } from '../helpers/createProxy'
|
|
8
8
|
import {
|
|
9
9
|
ThemeManager,
|
|
@@ -11,7 +11,14 @@ import {
|
|
|
11
11
|
getHasThemeUpdatingProps,
|
|
12
12
|
} from '../helpers/ThemeManager'
|
|
13
13
|
import { ThemeManagerContext } from '../helpers/ThemeManagerContext'
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
DebugProp,
|
|
16
|
+
ThemeParsed,
|
|
17
|
+
ThemeProps,
|
|
18
|
+
Tokens,
|
|
19
|
+
VariableVal,
|
|
20
|
+
VariableValGeneric,
|
|
21
|
+
} from '../types'
|
|
15
22
|
import { GetThemeUnwrapped } from './getThemeUnwrapped'
|
|
16
23
|
|
|
17
24
|
export type ChangedThemeResponse = {
|
|
@@ -30,10 +37,22 @@ function getDefaultThemeProxied() {
|
|
|
30
37
|
})
|
|
31
38
|
}
|
|
32
39
|
|
|
40
|
+
type ThemeGettable<Val> = Val & {
|
|
41
|
+
get: () =>
|
|
42
|
+
| string
|
|
43
|
+
| (Val extends Variable<infer X>
|
|
44
|
+
? X extends VariableValGeneric
|
|
45
|
+
? any
|
|
46
|
+
: X
|
|
47
|
+
: Val extends VariableVal
|
|
48
|
+
? string | number
|
|
49
|
+
: unknown)
|
|
50
|
+
}
|
|
51
|
+
|
|
33
52
|
type UseThemeResult = {
|
|
34
|
-
[
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
[Key in keyof ThemeParsed]: ThemeGettable<ThemeParsed[Key]>
|
|
54
|
+
} & {
|
|
55
|
+
[Key in keyof Tokens['color']]: ThemeGettable<string>
|
|
37
56
|
}
|
|
38
57
|
|
|
39
58
|
export const useTheme = (props: ThemeProps = emptyProps) => {
|
|
@@ -125,7 +144,13 @@ export function getThemeProxied(
|
|
|
125
144
|
if (key === GetThemeUnwrapped) {
|
|
126
145
|
return theme
|
|
127
146
|
}
|
|
128
|
-
if (
|
|
147
|
+
if (
|
|
148
|
+
// dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
|
|
149
|
+
// if someone is crazy enough to use "undefined" as a theme key then this not working is on them
|
|
150
|
+
key !== 'undefined' &&
|
|
151
|
+
typeof key === 'string' &&
|
|
152
|
+
keys
|
|
153
|
+
) {
|
|
129
154
|
// auto convert variables to plain
|
|
130
155
|
const keyString = key[0] === '$' ? key.slice(1) : key
|
|
131
156
|
const val = theme[keyString]
|
|
@@ -236,6 +261,7 @@ export const useChangeThemeEffect = (
|
|
|
236
261
|
const disposeChangeListener = parentManager?.onChangeTheme((name, manager) => {
|
|
237
262
|
const force = shouldUpdate?.()
|
|
238
263
|
const doUpdate = force ?? Boolean(keys?.length || isNewTheme)
|
|
264
|
+
|
|
239
265
|
if (process.env.NODE_ENV === 'development' && props.debug) {
|
|
240
266
|
// prettier-ignore
|
|
241
267
|
// rome-ignore lint/nursery/noConsoleLog: <explanation>
|
|
@@ -337,7 +363,7 @@ export const useChangeThemeEffect = (
|
|
|
337
363
|
if (!prev.isNewTheme || !isWeb) {
|
|
338
364
|
themeManager = getNewThemeManager()
|
|
339
365
|
} else {
|
|
340
|
-
themeManager.updateState(nextState
|
|
366
|
+
themeManager.updateState(nextState)
|
|
341
367
|
}
|
|
342
368
|
} else {
|
|
343
369
|
if (prev.isNewTheme) {
|
package/src/types.tsx
CHANGED
|
@@ -191,7 +191,7 @@ export type ConfigListener = (conf: TamaguiInternalConfig) => void
|
|
|
191
191
|
// to prevent things from going circular, hoisting some types in this file
|
|
192
192
|
// to generally order them as building up towards TamaguiConfig
|
|
193
193
|
|
|
194
|
-
export type VariableVal = number | string | Variable
|
|
194
|
+
export type VariableVal = number | string | Variable | VariableValGeneric
|
|
195
195
|
export type VariableColorVal = string | Variable
|
|
196
196
|
|
|
197
197
|
type GenericKey = string
|
|
@@ -246,6 +246,8 @@ export type TamaguiBaseTheme = {
|
|
|
246
246
|
shadowColorFocus: VariableColorVal
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
export type VariableValGeneric = { __generic: 1 }
|
|
250
|
+
|
|
249
251
|
type GenericTokens = CreateTokens
|
|
250
252
|
type GenericThemes = {
|
|
251
253
|
[key: string]:
|
|
@@ -317,7 +319,7 @@ export type CreateTamaguiConfig<
|
|
|
317
319
|
// parsed
|
|
318
320
|
themes: {
|
|
319
321
|
[Name in keyof B]: {
|
|
320
|
-
[Key in keyof B[Name]]: Variable
|
|
322
|
+
[Key in keyof B[Name]]: Variable<B[Name][Key]>
|
|
321
323
|
}
|
|
322
324
|
}
|
|
323
325
|
shorthands: C
|
|
@@ -411,7 +413,7 @@ export type ThemeDefinition = BaseThemeDefinitions extends never
|
|
|
411
413
|
: BaseThemeDefinitions
|
|
412
414
|
export type ThemeKeys = keyof ThemeDefinition
|
|
413
415
|
export type ThemeParsed = {
|
|
414
|
-
[key in ThemeKeys]:
|
|
416
|
+
[key in ThemeKeys]: ThemeDefinition[key]
|
|
415
417
|
}
|
|
416
418
|
|
|
417
419
|
export type Tokens = TamaguiConfig['tokens']
|
package/src/views/ThemeDebug.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export function ThemeDebug({
|
|
|
33
33
|
node.style.overflowY = 'scroll'
|
|
34
34
|
node.style.position = 'fixed'
|
|
35
35
|
node.style.zIndex = 10000000
|
|
36
|
-
node.style.
|
|
36
|
+
node.style.bottom = '30px'
|
|
37
37
|
node.style.left = '30px'
|
|
38
38
|
node.style.right = '30px'
|
|
39
39
|
node.style.display = 'flex'
|
|
@@ -48,7 +48,7 @@ export function ThemeDebug({
|
|
|
48
48
|
themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {
|
|
49
49
|
setOnChangeCount((p) => ++p)
|
|
50
50
|
console.warn(
|
|
51
|
-
`theme changed for ${themeState.themeManager?.id} from parent ${themeState.themeManager?.parentManager?.id}`,
|
|
51
|
+
`theme changed for ${themeState.themeManager?.id} from parent ${themeState.themeManager?.parentManager?.id} to new name`,
|
|
52
52
|
name
|
|
53
53
|
)
|
|
54
54
|
})
|
package/types/config.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { ConfigListener, TamaguiInternalConfig, Token, Tokens, TokensMerged } fr
|
|
|
2
2
|
export declare const setConfig: (next: TamaguiInternalConfig) => void;
|
|
3
3
|
export declare const setConfigFont: (name: string, font: any, fontParsed: any) => void;
|
|
4
4
|
export declare const getConfig: () => TamaguiInternalConfig;
|
|
5
|
+
export declare function setTokens(_: TokensMerged): void;
|
|
5
6
|
export declare const getTokens: ({ prefixed, }?: {
|
|
6
7
|
/**
|
|
7
8
|
* Force either with $ or without $ prefix
|
|
8
9
|
*/
|
|
9
10
|
prefixed?: boolean | undefined;
|
|
10
11
|
}) => TokensMerged;
|
|
12
|
+
export declare const getTokenObject: (value: Token, group?: keyof Tokens) => import("./createVariable").Variable<any>;
|
|
11
13
|
export declare const getToken: (value: Token, group?: keyof Tokens, useVariable?: boolean) => any;
|
|
12
14
|
export declare const getTokenValue: (value: Token, group?: keyof Tokens) => any;
|
|
13
15
|
/**
|
|
@@ -21,23 +23,23 @@ export declare const useTokens: ({ prefixed, }?: {
|
|
|
21
23
|
}) => TokensMerged;
|
|
22
24
|
export declare const getThemes: () => {
|
|
23
25
|
[x: string]: {
|
|
24
|
-
[x: string]: import("./createVariable").Variable<
|
|
25
|
-
background?: import("./createVariable").Variable<
|
|
26
|
-
backgroundHover?: import("./createVariable").Variable<
|
|
27
|
-
backgroundPress?: import("./createVariable").Variable<
|
|
28
|
-
backgroundFocus?: import("./createVariable").Variable<
|
|
29
|
-
color?: import("./createVariable").Variable<
|
|
30
|
-
colorHover?: import("./createVariable").Variable<
|
|
31
|
-
colorPress?: import("./createVariable").Variable<
|
|
32
|
-
colorFocus?: import("./createVariable").Variable<
|
|
33
|
-
borderColor?: import("./createVariable").Variable<
|
|
34
|
-
borderColorHover?: import("./createVariable").Variable<
|
|
35
|
-
borderColorPress?: import("./createVariable").Variable<
|
|
36
|
-
borderColorFocus?: import("./createVariable").Variable<
|
|
37
|
-
shadowColor?: import("./createVariable").Variable<
|
|
38
|
-
shadowColorHover?: import("./createVariable").Variable<
|
|
39
|
-
shadowColorPress?: import("./createVariable").Variable<
|
|
40
|
-
shadowColorFocus?: import("./createVariable").Variable<
|
|
26
|
+
[x: string]: import("./createVariable").Variable<import("./types").VariableVal>;
|
|
27
|
+
background?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
28
|
+
backgroundHover?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
29
|
+
backgroundPress?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
30
|
+
backgroundFocus?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
31
|
+
color?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
32
|
+
colorHover?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
33
|
+
colorPress?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
34
|
+
colorFocus?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
35
|
+
borderColor?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
36
|
+
borderColorHover?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
37
|
+
borderColorPress?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
38
|
+
borderColorFocus?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
39
|
+
shadowColor?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
40
|
+
shadowColorHover?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
41
|
+
shadowColorPress?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
42
|
+
shadowColorFocus?: import("./createVariable").Variable<import("./types").VariableColorVal | undefined> | undefined;
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
45
|
export declare const configListeners: Set<ConfigListener>;
|
package/types/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,KAAK,EACL,MAAM,EACN,YAAY,EACb,MAAM,SAAS,CAAA;AAIhB,eAAO,MAAM,SAAS,SAAU,qBAAqB,SAGpD,CAAA;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,QAAQ,GAAG,cAAc,GAAG,SAMrE,CAAA;AAED,eAAO,MAAM,SAAS,6BASrB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,KAAK,EACL,MAAM,EACN,YAAY,EACb,MAAM,SAAS,CAAA;AAIhB,eAAO,MAAM,SAAS,SAAU,qBAAqB,SAGpD,CAAA;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,QAAQ,GAAG,cAAc,GAAG,SAMrE,CAAA;AAED,eAAO,MAAM,SAAS,6BASrB,CAAA;AAGD,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,QAExC;AAED,eAAO,MAAM,SAAS;IAGpB;;OAEG;;MAEI,YAQR,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,KAAK,UAAU,MAAM,MAAM,6CAShE,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,KAAK,UAAU,MAAM,MAAM,+BAG1D,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,KAAK,UAAU,MAAM,MAAM,QAE/D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;IArCpB;;OAEG;;MAEI,YAiCyB,CAAA;AAElC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAAqB,CAAA;AAE3C,eAAO,MAAM,eAAe,qBAA4B,CAAA;AAExD,eAAO,MAAM,gBAAgB,OAAQ,cAAc,SAMlD,CAAA;AAED,eAAO,MAAM,YAAY,QAAS,MAAM,SAAS,GAAG,SAGnD,CAAA;AAGD,eAAO,MAAM,OAAO,SAAU,MAAM,4DAQnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,kBAAkB,EAIlB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,kBAAkB,EAIlB,kBAAkB,EAMnB,MAAM,SAAS,CAAA;AAKhB,wBAAgB,aAAa,CAAC,IAAI,SAAS,kBAAkB,EAC3D,QAAQ,EAAE,IAAI,GACb,kBAAkB,CAAC,IAAI,CAAC,CAsQ1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVariables.d.ts","sourceRoot":"","sources":["../src/createVariables.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAA8B,MAAM,kBAAkB,CAAA;AAEvE,KAAK,eAAe,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,GAAG,GAAG,IAAI;IACxD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,eAAe,IAAI;KACzD,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,MAAM,GAC5C,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAChB,CAAC,CAAC,GAAG,CAAC,SAAS,eAAe,GAC9B,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAC1B,KAAK;CACV,CAAA;
|
|
1
|
+
{"version":3,"file":"createVariables.d.ts","sourceRoot":"","sources":["../src/createVariables.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAA8B,MAAM,kBAAkB,CAAA;AAEvE,KAAK,eAAe,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,GAAG,GAAG,IAAI;IACxD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,eAAe,IAAI;KACzD,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,MAAM,GAC5C,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAChB,CAAC,CAAC,GAAG,CAAC,SAAS,eAAe,GAC9B,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAC1B,KAAK;CACV,CAAA;AAMD,eAAO,MAAM,eAAe,6GAmC3B,CAAA"}
|
|
@@ -25,9 +25,10 @@ export declare class ThemeManager {
|
|
|
25
25
|
state: ThemeManagerState;
|
|
26
26
|
scheme: 'light' | 'dark' | null;
|
|
27
27
|
constructor(props?: ThemeProps, parentManagerIn?: ThemeManager | 'root' | null | undefined);
|
|
28
|
-
|
|
28
|
+
updateStateFromProps(props?: ThemeProps & {
|
|
29
29
|
forceTheme?: ThemeParsed;
|
|
30
|
-
}, shouldNotify?: boolean): ThemeManagerState | undefined;
|
|
30
|
+
}, shouldNotify?: boolean): true | ThemeManagerState | undefined;
|
|
31
|
+
updateState(nextState: ThemeManagerState, shouldNotify?: boolean): ThemeManagerState;
|
|
31
32
|
getStateIfChanged(props?: ThemeProps, state?: ThemeManagerState | null, parentManager?: ThemeManager | null): ThemeManagerState | null | undefined;
|
|
32
33
|
getStateShouldChange(nextState: ThemeManagerState | null, state?: ThemeManagerState | null): boolean;
|
|
33
34
|
getState(props?: ThemeProps, parentManager?: ThemeManager | null): ThemeManagerState | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../../src/helpers/ThemeManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAElD,KAAK,aAAa,GAAG,CACnB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,OAAO,KACZ,IAAI,CAAA;AAET,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAID,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,WAEzD;AAID,qBAAa,YAAY;IASd,KAAK,EAAE,UAAU;IAR1B,EAAE,SAAQ;IACV,WAAW,UAAQ;IACnB,cAAc,qBAA2B;IACzC,aAAa,EAAE,YAAY,GAAG,IAAI,CAAO;IACzC,KAAK,EAAE,iBAAiB,CAAa;IACrC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAO;gBAG7B,KAAK,GAAE,UAAe,EAC7B,eAAe,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IA8B5D,
|
|
1
|
+
{"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../../src/helpers/ThemeManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAElD,KAAK,aAAa,GAAG,CACnB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,OAAO,KACZ,IAAI,CAAA;AAET,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAID,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,WAEzD;AAID,qBAAa,YAAY;IASd,KAAK,EAAE,UAAU;IAR1B,EAAE,SAAQ;IACV,WAAW,UAAQ;IACnB,cAAc,qBAA2B;IACzC,aAAa,EAAE,YAAY,GAAG,IAAI,CAAO;IACzC,KAAK,EAAE,iBAAiB,CAAa;IACrC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAO;gBAG7B,KAAK,GAAE,UAAe,EAC7B,eAAe,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IA8B5D,oBAAoB,CAClB,KAAK,GAAE,UAAU,GAAG;QAAE,UAAU,CAAC,EAAE,WAAW,CAAA;KAAqB,EACnE,YAAY,UAAO;IAerB,WAAW,CAAC,SAAS,EAAE,iBAAiB,EAAE,YAAY,UAAO;IAmB7D,iBAAiB,CACf,KAAK,aAAa,EAClB,KAAK,GAAE,iBAAiB,GAAG,IAAiB,EAC5C,aAAa,sBAAqB;IAapC,oBAAoB,CAClB,SAAS,EAAE,iBAAiB,GAAG,IAAI,EACnC,KAAK,GAAE,iBAAiB,GAAG,IAAiB;IAQ9C,QAAQ,CAAC,KAAK,aAAa,EAAE,aAAa,sBAAqB;IAO/D,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAO;IACnC,IAAI,OAAO,gBAMV;IAED,MAAM,CAAC,MAAM,UAAQ;IAIrB,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM;CAalD;AAuKD,wBAAgB,4BAA4B,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,4CAe9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertStyleRule.d.ts","sourceRoot":"","sources":["../../src/helpers/insertStyleRule.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"insertStyleRule.d.ts","sourceRoot":"","sources":["../../src/helpers/insertStyleRule.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,aAAa,EACb,aAAa,EAEb,YAAY,EACb,MAAM,UAAU,CAAA;AAIjB,eAAO,MAAM,kBAAkB,IAAK,CAAA;AAEpC,eAAO,MAAM,eAAe,8BAAqB,CAAA;AACjD,eAAO,MAAM,WAAW,gBAAgC,CAAA;AACxD,eAAO,MAAM,gBAAgB,UAA2B,CAAA;AAiCxD,wBAAgB,qBAAqB,SAkBpC;AAID,wBAAgB,aAAa,CAC3B,aAAa,UAAQ,EACrB,MAAM,CAAC,EAAE,YAAY,GACpB,aAAa,GAAG,SAAS,CA8B3B;AAiOD,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,uBAS9D;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,QAgC5D;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,WAOxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyThemeToParents.d.ts","sourceRoot":"","sources":["../../src/helpers/proxyThemeToParents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAM,CAAA;AAIxD,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAC3B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAsB7B;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"proxyThemeToParents.d.ts","sourceRoot":"","sources":["../../src/helpers/proxyThemeToParents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAM,CAAA;AAIxD,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAC3B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAsB7B;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,eAuCxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeable.d.ts","sourceRoot":"","sources":["../../src/helpers/themeable.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG7D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EAC7D,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"themeable.d.ts","sourceRoot":"","sources":["../../src/helpers/themeable.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG7D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EAC7D,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,8HAmCrC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { Variable } from '../createVariable';
|
|
1
2
|
import { ThemeManager, ThemeManagerState } from '../helpers/ThemeManager';
|
|
2
|
-
import type { DebugProp, ThemeParsed, ThemeProps } from '../types';
|
|
3
|
+
import type { DebugProp, ThemeParsed, ThemeProps, Tokens, VariableVal, VariableValGeneric } from '../types';
|
|
3
4
|
export type ChangedThemeResponse = {
|
|
4
5
|
state: ThemeManagerState;
|
|
5
6
|
themeManager: ThemeManager;
|
|
6
7
|
isNewTheme: boolean;
|
|
7
8
|
mounted?: boolean;
|
|
8
9
|
};
|
|
10
|
+
type ThemeGettable<Val> = Val & {
|
|
11
|
+
get: () => string | (Val extends Variable<infer X> ? X extends VariableValGeneric ? any : X : Val extends VariableVal ? string | number : unknown);
|
|
12
|
+
};
|
|
9
13
|
type UseThemeResult = {
|
|
10
|
-
[
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
[Key in keyof ThemeParsed]: ThemeGettable<ThemeParsed[Key]>;
|
|
15
|
+
} & {
|
|
16
|
+
[Key in keyof Tokens['color']]: ThemeGettable<string>;
|
|
13
17
|
};
|
|
14
18
|
export declare const useTheme: (props?: ThemeProps) => UseThemeResult;
|
|
15
19
|
export declare const useThemeWithState: (props: ThemeProps) => [ChangedThemeResponse, ThemeParsed];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAe,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EACL,YAAY,EACZ,iBAAiB,EAElB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,EACN,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,iBAAiB,CAAA;IACxB,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAWD,KAAK,aAAa,CAAC,GAAG,IAAI,GAAG,GAAG;IAC9B,GAAG,EAAE,MACD,MAAM,GACN,CAAC,GAAG,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAC1B,CAAC,SAAS,kBAAkB,GAC1B,GAAG,GACH,CAAC,GACH,GAAG,SAAS,WAAW,GACvB,MAAM,GAAG,MAAM,GACf,OAAO,CAAC,CAAA;CACjB,CAAA;AAED,KAAK,cAAc,GAAG;KACnB,GAAG,IAAI,MAAM,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAC5D,GAAG;KACD,GAAG,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;CACtD,CAAA;AAED,eAAO,MAAM,QAAQ,WAAW,UAAU,mBAIzC,CAAA;AAED,eAAO,MAAM,iBAAiB,UACrB,UAAU,KAChB,CAAC,oBAAoB,EAAE,WAAW,CAwDpC,CAAA;AAED,wBAAgB,eAAe,CAC7B,EACE,KAAK,EACL,YAAY,GACb,EAAE;IACD,KAAK,EAAE,WAAW,CAAA;IAClB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,EACD,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,KAAK,CAAC,EAAE,SAAS,GAChB,cAAc,CAqDhB;AAED,eAAO,MAAM,mBAAmB,mBAA0B,CAAA;AAE1D,eAAO,MAAM,oBAAoB,UACxB,UAAU,yBAEV,MAAM,EAAE,iBACA,MAAM,OAAO,GAAG,SAAS,KACvC,oBAuOF,CAAA"}
|
package/types/types.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export type TamaguiComponentPropsBase = {
|
|
|
75
75
|
};
|
|
76
76
|
export type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<Props & RefAttributes<Ref>>;
|
|
77
77
|
export type ConfigListener = (conf: TamaguiInternalConfig) => void;
|
|
78
|
-
export type VariableVal = number | string | Variable;
|
|
78
|
+
export type VariableVal = number | string | Variable | VariableValGeneric;
|
|
79
79
|
export type VariableColorVal = string | Variable;
|
|
80
80
|
type GenericKey = string;
|
|
81
81
|
export type CreateTokens<Val extends VariableVal = VariableVal> = Record<string, {
|
|
@@ -127,6 +127,9 @@ export type TamaguiBaseTheme = {
|
|
|
127
127
|
shadowColorPress: VariableColorVal;
|
|
128
128
|
shadowColorFocus: VariableColorVal;
|
|
129
129
|
};
|
|
130
|
+
export type VariableValGeneric = {
|
|
131
|
+
__generic: 1;
|
|
132
|
+
};
|
|
130
133
|
type GenericTokens = CreateTokens;
|
|
131
134
|
type GenericThemes = {
|
|
132
135
|
[key: string]: (Partial<TamaguiBaseTheme> & {
|
|
@@ -160,7 +163,7 @@ export type CreateTamaguiConfig<A extends GenericTokens, B extends GenericThemes
|
|
|
160
163
|
tokens: A;
|
|
161
164
|
themes: {
|
|
162
165
|
[Name in keyof B]: {
|
|
163
|
-
[Key in keyof B[Name]]: Variable
|
|
166
|
+
[Key in keyof B[Name]]: Variable<B[Name][Key]>;
|
|
164
167
|
};
|
|
165
168
|
};
|
|
166
169
|
shorthands: C;
|
|
@@ -195,7 +198,7 @@ type GenericThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['theme
|
|
|
195
198
|
export type ThemeDefinition = BaseThemeDefinitions extends never ? GenericThemeDefinition : BaseThemeDefinitions;
|
|
196
199
|
export type ThemeKeys = keyof ThemeDefinition;
|
|
197
200
|
export type ThemeParsed = {
|
|
198
|
-
[key in ThemeKeys]:
|
|
201
|
+
[key in ThemeKeys]: ThemeDefinition[key];
|
|
199
202
|
};
|
|
200
203
|
export type Tokens = TamaguiConfig['tokens'];
|
|
201
204
|
export type TokensParsed = {
|