@tamagui/core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config.js +3 -5
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +3 -15
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/cache.js +2 -2
- package/dist/cjs/helpers/cache.js.map +2 -2
- package/dist/cjs/helpers/getBoundingClientRect.js +3 -6
- package/dist/cjs/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +1 -1
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +2 -7
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +2 -7
- package/dist/cjs/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +1 -1
- package/dist/cjs/helpers/mergeProps.js.map +2 -2
- package/dist/cjs/hooks/getThemeUnwrapped.js +1 -4
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/views/FontLanguage.js.map +2 -2
- package/dist/cjs/views/Text.js +0 -5
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +5 -6
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/esm/config.js +3 -5
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +3 -15
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/cache.js +2 -2
- package/dist/esm/helpers/cache.js.map +2 -2
- package/dist/esm/helpers/getBoundingClientRect.js +3 -6
- package/dist/esm/helpers/getBoundingClientRect.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +1 -1
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +2 -7
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +2 -7
- package/dist/esm/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/esm/helpers/mergeProps.js +1 -1
- package/dist/esm/helpers/mergeProps.js.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.js +1 -4
- package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/FontLanguage.js.map +2 -2
- package/dist/esm/views/Text.js +0 -5
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +5 -6
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/package.json +10 -10
- package/src/config.ts +4 -6
- package/src/constants/constants.ts +0 -2
- package/src/createFont.ts +0 -2
- package/src/helpers/ThemeManager.tsx +4 -20
- package/src/helpers/cache.ts +2 -5
- package/src/helpers/getBoundingClientRect.tsx +2 -5
- package/src/helpers/getSplitStyles.tsx +1 -1
- package/src/helpers/getStylesAtomic.ts +1 -9
- package/src/helpers/isTamaguiComponent.tsx +2 -6
- package/src/helpers/mergeProps.ts +1 -1
- package/src/hooks/getThemeUnwrapped.tsx +1 -3
- package/src/styled.tsx +1 -1
- package/src/views/FontLanguage.tsx +0 -2
- package/src/views/Text.tsx +0 -6
- package/src/views/ThemeProvider.tsx +8 -8
- package/types/helpers/cache.d.ts +2 -2
package/src/config.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { ConfigListener, TamaguiInternalConfig,
|
|
1
|
+
import { ConfigListener, TamaguiInternalConfig, Tokens } from './types'
|
|
2
2
|
|
|
3
3
|
let conf: TamaguiInternalConfig | null
|
|
4
4
|
|
|
5
5
|
export const setConfig = (next: TamaguiInternalConfig) => {
|
|
6
6
|
conf = next
|
|
7
|
-
|
|
8
|
-
configListeners.forEach((cb) => cb(next))
|
|
9
|
-
}
|
|
7
|
+
configListeners.forEach((cb) => cb(next))
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export const setConfigFont = (name: string, font: any, fontParsed: any) => {
|
|
13
11
|
if (process.env.NODE_ENV === 'development') {
|
|
14
12
|
if (!conf) throw new Error(`Haven't called createTamagui yet`)
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
conf!.fonts[name] = font
|
|
15
|
+
conf!.fontsParsed[`$${name}`] = fontParsed
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
export const getConfig = () => {
|
package/src/createFont.ts
CHANGED
|
@@ -34,7 +34,6 @@ const processSection = <T>(
|
|
|
34
34
|
|
|
35
35
|
export const createFont = <A extends GenericFont>(font: A): A => {
|
|
36
36
|
const sizeKeys = Object.keys(font.size)
|
|
37
|
-
|
|
38
37
|
const processedFont = Object.fromEntries(
|
|
39
38
|
Object.entries(font).map(([key, section]) => {
|
|
40
39
|
return [
|
|
@@ -47,6 +46,5 @@ export const createFont = <A extends GenericFont>(font: A): A => {
|
|
|
47
46
|
]
|
|
48
47
|
})
|
|
49
48
|
)
|
|
50
|
-
|
|
51
49
|
return Object.freeze(processedFont) as A
|
|
52
50
|
}
|
|
@@ -39,10 +39,7 @@ export class ThemeManager {
|
|
|
39
39
|
this.updateState(props, false)
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
|
-
if (!parentManager)
|
|
43
|
-
throw new Error('Must set up root first')
|
|
44
|
-
}
|
|
45
|
-
|
|
42
|
+
if (!parentManager) throw `❌`
|
|
46
43
|
// copy over listeners
|
|
47
44
|
this.themeListeners = parentManager.themeListeners
|
|
48
45
|
|
|
@@ -205,22 +202,9 @@ function getState(
|
|
|
205
202
|
? max // component name only don't search upwards
|
|
206
203
|
: 0
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.groupCollapsed('ThemeManager.getState()', props, {
|
|
212
|
-
parentName,
|
|
213
|
-
parentBaseTheme,
|
|
214
|
-
base,
|
|
215
|
-
min,
|
|
216
|
-
max,
|
|
217
|
-
isParentAComponentTheme,
|
|
218
|
-
}),
|
|
219
|
-
// eslint-disable-next-line no-console
|
|
220
|
-
console.trace(),
|
|
221
|
-
// eslint-disable-next-line no-console
|
|
222
|
-
console.groupEnd(),
|
|
223
|
-
]
|
|
205
|
+
// prettier-ignore
|
|
206
|
+
// eslint-disable-next-line no-console
|
|
207
|
+
if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') [ console.groupCollapsed('ThemeManager.getState()', props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd() ]
|
|
224
208
|
|
|
225
209
|
for (let i = max; i >= min; i--) {
|
|
226
210
|
let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)
|
package/src/helpers/cache.ts
CHANGED
|
@@ -5,11 +5,8 @@ export type Style = { [key: string]: Value }
|
|
|
5
5
|
const v: Record<string, any> = {}
|
|
6
6
|
|
|
7
7
|
export const cache = {
|
|
8
|
-
get(key: string, valStr: string)
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
set(key: string, valStr: string, object: any) {
|
|
8
|
+
get: (key: string, valStr: string) => v[key]?.[valStr],
|
|
9
|
+
set: (key: string, valStr: string, object: any) => {
|
|
13
10
|
v[key] ??= {}
|
|
14
11
|
v[key][valStr] = object
|
|
15
12
|
},
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export const getBoundingClientRect = (node: HTMLElement | null): void | DOMRect => {
|
|
2
|
-
if (!node) return
|
|
3
|
-
|
|
4
|
-
if (node.getBoundingClientRect) {
|
|
5
|
-
return node.getBoundingClientRect()
|
|
6
|
-
}
|
|
2
|
+
if (!node || node.nodeType !== 1) return
|
|
3
|
+
return node.getBoundingClientRect?.()
|
|
7
4
|
}
|
|
@@ -643,7 +643,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
643
643
|
// we never animate in on server side just show the full thing
|
|
644
644
|
// on client side we use CSS to hide the fully in SSR items, then
|
|
645
645
|
// un-hide and replay with original animation.
|
|
646
|
-
if (!isClient && isEnter) {
|
|
646
|
+
if (isWeb && !isClient && isEnter) {
|
|
647
647
|
isDisabled = false
|
|
648
648
|
}
|
|
649
649
|
|
|
@@ -56,16 +56,8 @@ export function getAtomicStyle(
|
|
|
56
56
|
if (!style || typeof style !== 'object') {
|
|
57
57
|
throw new Error(`Wrong style type: "${typeof style}": ${style}`)
|
|
58
58
|
}
|
|
59
|
-
} else {
|
|
60
|
-
if (!style) {
|
|
61
|
-
if (process.env.NODE_ENV === 'development') {
|
|
62
|
-
// eslint-disable-next-line no-console
|
|
63
|
-
console.warn('Invalid style')
|
|
64
|
-
}
|
|
65
|
-
return []
|
|
66
|
-
}
|
|
67
59
|
}
|
|
68
|
-
|
|
60
|
+
if (!style) return []
|
|
69
61
|
return generateAtomicStyles(style, pseudo)
|
|
70
62
|
}
|
|
71
63
|
|
|
@@ -6,10 +6,6 @@ export function isTamaguiComponent<A>(
|
|
|
6
6
|
): comp is A & {
|
|
7
7
|
staticConfig: StaticConfig
|
|
8
8
|
} {
|
|
9
|
-
const config = comp
|
|
10
|
-
|
|
11
|
-
if (name) {
|
|
12
|
-
return name === config.componentName
|
|
13
|
-
}
|
|
14
|
-
return true
|
|
9
|
+
const config = comp?.['staticConfig'] as StaticConfigParsed | undefined
|
|
10
|
+
return (config?.parsed && (name ? name === config.componentName : true)) || false
|
|
15
11
|
}
|
|
@@ -41,7 +41,7 @@ function mergeProp(
|
|
|
41
41
|
inverseShorthands?: AnyRecord
|
|
42
42
|
) {
|
|
43
43
|
const val = a[key]
|
|
44
|
-
const shorthand = inverseShorthands
|
|
44
|
+
const shorthand = inverseShorthands?.[key] || null
|
|
45
45
|
if (b && (key in b || (shorthand && shorthand in b))) {
|
|
46
46
|
return
|
|
47
47
|
}
|
package/src/styled.tsx
CHANGED
package/src/views/Text.tsx
CHANGED
|
@@ -32,15 +32,15 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
|
|
|
32
32
|
}, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot])
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const value = useMemo(() => {
|
|
36
|
-
return {
|
|
37
|
-
defaultTheme: props.defaultTheme,
|
|
38
|
-
}
|
|
39
|
-
// NOTE DON'T CHANGE THIS ITS ONLY USED BY useThemeName for SSR safety for now...
|
|
40
|
-
}, [])
|
|
41
|
-
|
|
42
35
|
return (
|
|
43
|
-
<ThemeProviderRootContext.Provider
|
|
36
|
+
<ThemeProviderRootContext.Provider
|
|
37
|
+
value={useMemo(() => {
|
|
38
|
+
return {
|
|
39
|
+
defaultTheme: props.defaultTheme,
|
|
40
|
+
}
|
|
41
|
+
// NOTE DON'T CHANGE THIS ITS ONLY USED BY useThemeName for SSR safety for now...
|
|
42
|
+
}, [])}
|
|
43
|
+
>
|
|
44
44
|
<Theme
|
|
45
45
|
className={props.className}
|
|
46
46
|
name={props.defaultTheme}
|
package/types/helpers/cache.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type Style = {
|
|
|
3
3
|
[key: string]: Value;
|
|
4
4
|
};
|
|
5
5
|
export declare const cache: {
|
|
6
|
-
get(key: string, valStr: string)
|
|
7
|
-
set(key: string, valStr: string, object: any)
|
|
6
|
+
get: (key: string, valStr: string) => any;
|
|
7
|
+
set: (key: string, valStr: string, object: any) => void;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=cache.d.ts.map
|