@tamagui/core 1.0.1-beta.187 → 1.0.1-beta.189
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/createComponent.js +1 -1
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +6 -11
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +0 -2
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +5 -10
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +0 -2
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/package.json +11 -11
- package/src/createComponent.tsx +3 -2
- package/src/hooks/useMedia.tsx +5 -15
- package/src/index.ts +3 -2
- package/src/views/TamaguiProvider.tsx +0 -2
- package/types/hooks/useMedia.d.ts +1 -1
- package/types/index.d.ts +3 -2
- package/src/hooks/useIsSSR.tsx +0 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.189",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/match-media": "^0.3.0",
|
|
31
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/constants": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/rnw": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/rnw-lite": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/use-
|
|
38
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
39
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
31
|
+
"@tamagui/compose-refs": "^1.0.1-beta.189",
|
|
32
|
+
"@tamagui/constants": "^1.0.1-beta.189",
|
|
33
|
+
"@tamagui/helpers": "^1.0.1-beta.189",
|
|
34
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.189",
|
|
35
|
+
"@tamagui/rnw": "^1.0.1-beta.189",
|
|
36
|
+
"@tamagui/rnw-lite": "^1.0.1-beta.189",
|
|
37
|
+
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.189",
|
|
38
|
+
"@tamagui/use-event": "^1.0.1-beta.189",
|
|
39
|
+
"@tamagui/use-force-update": "^1.0.1-beta.189",
|
|
40
40
|
"expo-screen-orientation": "^4.3.0",
|
|
41
41
|
"hyphenate-style-name": "^1.0.4"
|
|
42
42
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"react-dom": "*"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
48
|
+
"@tamagui/build": "^1.0.1-beta.189",
|
|
49
49
|
"@types/node": "^16.11.9",
|
|
50
50
|
"@types/react": "^18.0.15",
|
|
51
51
|
"csstype": "^3.0.10",
|
package/src/createComponent.tsx
CHANGED
|
@@ -42,7 +42,7 @@ import { getAllSelectors } from './helpers/insertStyleRule'
|
|
|
42
42
|
import { mergeProps } from './helpers/mergeProps'
|
|
43
43
|
import { proxyThemeVariables } from './helpers/proxyThemeVariables'
|
|
44
44
|
import { useShallowSetState } from './helpers/useShallowSetState'
|
|
45
|
-
import { addMediaQueryListener,
|
|
45
|
+
import { addMediaQueryListener, getInitialMediaState } from './hooks/useMedia'
|
|
46
46
|
import { usePressable } from './hooks/usePressable'
|
|
47
47
|
import { useServerRef, useServerState } from './hooks/useServerHooks'
|
|
48
48
|
import { getThemeManager, useTheme } from './hooks/useTheme'
|
|
@@ -68,6 +68,7 @@ import { wrapThemeManagerContext } from './views/Theme'
|
|
|
68
68
|
React['keep']
|
|
69
69
|
|
|
70
70
|
let defaultComponentState: TamaguiComponentState | null = null
|
|
71
|
+
|
|
71
72
|
export const mouseUps = new Set<Function>()
|
|
72
73
|
if (typeof document !== 'undefined') {
|
|
73
74
|
const cancelTouches = () => {
|
|
@@ -1099,7 +1100,7 @@ export function createComponent<
|
|
|
1099
1100
|
// only used by enterStyle
|
|
1100
1101
|
mounted: false,
|
|
1101
1102
|
animation: null,
|
|
1102
|
-
mediaState:
|
|
1103
|
+
mediaState: getInitialMediaState(),
|
|
1103
1104
|
})
|
|
1104
1105
|
}
|
|
1105
1106
|
|
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
2
|
import { startTransition, useEffect, useMemo, useState } from 'react'
|
|
3
3
|
|
|
4
|
+
import { getConfig } from '../config'
|
|
4
5
|
import { matchMedia } from '../helpers/matchMedia'
|
|
5
6
|
import {
|
|
6
7
|
MediaQueries,
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
TamaguiInternalConfig,
|
|
11
12
|
} from '../types'
|
|
12
13
|
import { useSafeRef } from './useSafeRef'
|
|
13
|
-
import { getConfig } from '..'
|
|
14
14
|
|
|
15
15
|
export const mediaState: MediaQueryState =
|
|
16
16
|
// development time safeguard
|
|
@@ -55,10 +55,9 @@ export const getMedia = () => {
|
|
|
55
55
|
// for SSR capture it at time of startup
|
|
56
56
|
let currentMediaState: MediaQueryState | null
|
|
57
57
|
let initialMediaState: MediaQueryState | null
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (getConfig().disableSSR || hasFinishedInitialRender) {
|
|
58
|
+
|
|
59
|
+
export const getInitialMediaState = () => {
|
|
60
|
+
if (getConfig().disableSSR) {
|
|
62
61
|
return currentMediaState || {}
|
|
63
62
|
}
|
|
64
63
|
return initialMediaState || {}
|
|
@@ -132,21 +131,12 @@ function setupMediaListeners() {
|
|
|
132
131
|
})
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
const onIdle =
|
|
136
|
-
typeof requestIdleCallback === 'undefined' ? (cb) => setTimeout(cb, 100) : requestIdleCallback
|
|
137
|
-
|
|
138
134
|
export function useMediaQueryListeners(config: TamaguiInternalConfig) {
|
|
139
135
|
if (config.disableSSR) {
|
|
140
136
|
return
|
|
141
137
|
}
|
|
142
|
-
|
|
143
138
|
useEffect(() => {
|
|
144
139
|
setupMediaListeners()
|
|
145
|
-
|
|
146
|
-
onIdle(() => {
|
|
147
|
-
hasFinishedInitialRender = true
|
|
148
|
-
})
|
|
149
|
-
|
|
150
140
|
return unlisten
|
|
151
141
|
}, [])
|
|
152
142
|
}
|
|
@@ -154,7 +144,7 @@ export function useMediaQueryListeners(config: TamaguiInternalConfig) {
|
|
|
154
144
|
export function useMedia(): {
|
|
155
145
|
[key in MediaQueryKey]: boolean
|
|
156
146
|
} {
|
|
157
|
-
const [state, setState] = useState(
|
|
147
|
+
const [state, setState] = useState<MediaQueryState>(initialMediaState || {})
|
|
158
148
|
const keys = useSafeRef({} as Record<string, boolean>)
|
|
159
149
|
|
|
160
150
|
function updateState() {
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,6 @@ export type { RNWTextProps, RNWViewProps } from './types-rnw'
|
|
|
18
18
|
export { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config'
|
|
19
19
|
|
|
20
20
|
export * from './constants/constants'
|
|
21
|
-
export * from '@tamagui/constants'
|
|
22
21
|
export { createDOMProps } from '@tamagui/rnw'
|
|
23
22
|
|
|
24
23
|
export * from './helpers/calc'
|
|
@@ -62,7 +61,6 @@ export {
|
|
|
62
61
|
} from './hooks/useMedia'
|
|
63
62
|
export * from './hooks/usePressable'
|
|
64
63
|
export * from './hooks/useTheme'
|
|
65
|
-
export * from './hooks/useIsSSR'
|
|
66
64
|
export * from './hooks/useUnmountEffect'
|
|
67
65
|
export * from './hooks/useSafeRef'
|
|
68
66
|
|
|
@@ -78,5 +76,8 @@ export * from './views/FontLanguage'
|
|
|
78
76
|
export * from './views/TamaguiProvider'
|
|
79
77
|
|
|
80
78
|
export * from '@tamagui/use-force-update'
|
|
79
|
+
export * from '@tamagui/use-did-finish-ssr'
|
|
81
80
|
export * from '@tamagui/use-event'
|
|
81
|
+
export * from '@tamagui/compose-refs'
|
|
82
82
|
export * from '@tamagui/helpers'
|
|
83
|
+
export * from '@tamagui/constants'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isClient, isRSC, isServer } from '@tamagui/constants'
|
|
2
|
-
import { useSetupHasSSRRendered } from '@tamagui/use-did-finish-ssr'
|
|
3
2
|
import * as React from 'react'
|
|
4
3
|
|
|
5
4
|
import { ButtonInsideButtonContext } from '../contexts/ButtonInsideButtonContext'
|
|
@@ -23,7 +22,6 @@ export function TamaguiProvider({
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
if (!isServer) {
|
|
26
|
-
useSetupHasSSRRendered()
|
|
27
25
|
useMediaQueryListeners(config)
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -5,7 +5,7 @@ export declare function addMediaQueryListener(key: MediaQueryKey, cb: MediaListe
|
|
|
5
5
|
export declare function removeMediaQueryListener(key: MediaQueryKey, cb: MediaListener): void;
|
|
6
6
|
export declare const mediaQueryConfig: MediaQueries;
|
|
7
7
|
export declare const getMedia: () => MediaQueryState;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const getInitialMediaState: () => MediaQueryState;
|
|
9
9
|
export declare const configureMedia: (config: TamaguiInternalConfig) => void;
|
|
10
10
|
export declare function useMediaQueryListeners(config: TamaguiInternalConfig): void;
|
|
11
11
|
export declare function useMedia(): {
|
package/types/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export * from './types';
|
|
|
15
15
|
export type { RNWTextProps, RNWViewProps } from './types-rnw';
|
|
16
16
|
export { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config';
|
|
17
17
|
export * from './constants/constants';
|
|
18
|
-
export * from '@tamagui/constants';
|
|
19
18
|
export { createDOMProps } from '@tamagui/rnw';
|
|
20
19
|
export * from './helpers/calc';
|
|
21
20
|
export * from './helpers/useShallowSetState';
|
|
@@ -45,7 +44,6 @@ export * from './hooks/useIsTouchDevice';
|
|
|
45
44
|
export { configureMedia, getMedia, mediaState, useMedia, useMediaPropsActive, mediaObjectToString, addMediaQueryListener, removeMediaQueryListener, mediaQueryConfig, } from './hooks/useMedia';
|
|
46
45
|
export * from './hooks/usePressable';
|
|
47
46
|
export * from './hooks/useTheme';
|
|
48
|
-
export * from './hooks/useIsSSR';
|
|
49
47
|
export * from './hooks/useUnmountEffect';
|
|
50
48
|
export * from './hooks/useSafeRef';
|
|
51
49
|
export * from './views/Slot';
|
|
@@ -59,6 +57,9 @@ export * from './views/ThemeReset';
|
|
|
59
57
|
export * from './views/FontLanguage';
|
|
60
58
|
export * from './views/TamaguiProvider';
|
|
61
59
|
export * from '@tamagui/use-force-update';
|
|
60
|
+
export * from '@tamagui/use-did-finish-ssr';
|
|
62
61
|
export * from '@tamagui/use-event';
|
|
62
|
+
export * from '@tamagui/compose-refs';
|
|
63
63
|
export * from '@tamagui/helpers';
|
|
64
|
+
export * from '@tamagui/constants';
|
|
64
65
|
//# sourceMappingURL=index.d.ts.map
|
package/src/hooks/useIsSSR.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { isServer, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import { startTransition } from '../helpers/startTransition'
|
|
5
|
-
|
|
6
|
-
// because any change before first useEffect causes hydration / mismatch issues
|
|
7
|
-
|
|
8
|
-
export const useIsSSR = (props?: { immediate?: boolean }) => {
|
|
9
|
-
const [val, setVal] = useState(true)
|
|
10
|
-
|
|
11
|
-
if (isWeb && !isServer) {
|
|
12
|
-
useIsomorphicLayoutEffect(() => {
|
|
13
|
-
// could also have a global tamagui `config.immediateSSRTransition`
|
|
14
|
-
if (props?.immediate) {
|
|
15
|
-
setVal(false)
|
|
16
|
-
} else {
|
|
17
|
-
startTransition(() => {
|
|
18
|
-
setVal(false)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
}, [])
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return val
|
|
25
|
-
}
|