@tamagui/web 1.105.0 → 1.105.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 +7 -1
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/config.native.js +11 -1
- package/dist/cjs/config.native.js.map +2 -2
- package/dist/cjs/createComponent.js +18 -27
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +20 -46
- package/dist/cjs/createComponent.native.js.map +2 -2
- package/dist/cjs/createTamagui.js +3 -3
- package/dist/cjs/createTamagui.js.map +1 -1
- package/dist/cjs/createTamagui.native.js +4 -3
- package/dist/cjs/createTamagui.native.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.js.map +1 -1
- package/dist/cjs/helpers/createMediaStyle.native.js +1 -1
- package/dist/cjs/helpers/createMediaStyle.native.js.map +2 -2
- package/dist/cjs/helpers/createShallowSetState.js +1 -1
- package/dist/cjs/helpers/createShallowSetState.native.js +1 -1
- package/dist/cjs/helpers/createShallowSetState.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +35 -18
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +25 -17
- package/dist/cjs/helpers/getSplitStyles.native.js.map +2 -2
- package/dist/cjs/helpers/getThemeCSSRules.js +7 -6
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/cjs/helpers/log.js +9 -2
- package/dist/cjs/helpers/log.js.map +1 -1
- package/dist/cjs/helpers/log.native.js +10 -4
- package/dist/cjs/helpers/log.native.js.map +2 -2
- package/dist/cjs/helpers/propMapper.js +4 -3
- package/dist/cjs/helpers/propMapper.js.map +1 -1
- package/dist/cjs/helpers/propMapper.native.js +4 -3
- package/dist/cjs/helpers/propMapper.native.js.map +2 -2
- package/dist/cjs/hooks/useDisableSSR.js +1 -1
- package/dist/cjs/hooks/useDisableSSR.js.map +1 -1
- package/dist/cjs/hooks/useDisableSSR.native.js +1 -1
- package/dist/cjs/hooks/useDisableSSR.native.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +22 -3
- package/dist/cjs/hooks/useMedia.js.map +1 -1
- package/dist/cjs/hooks/useMedia.native.js +43 -6
- package/dist/cjs/hooks/useMedia.native.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +12 -5
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/hooks/useTheme.native.js +19 -8
- package/dist/cjs/hooks/useTheme.native.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +3 -3
- package/dist/cjs/views/TamaguiProvider.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.native.js +3 -3
- package/dist/cjs/views/TamaguiProvider.native.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +2 -2
- package/dist/cjs/views/ThemeProvider.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.native.js +2 -2
- package/dist/cjs/views/ThemeProvider.native.js.map +2 -2
- package/dist/cjs/views/html.js +1 -0
- package/dist/cjs/views/html.js.map +6 -0
- package/dist/cjs/views/html.native.js +2 -0
- package/dist/cjs/views/html.native.js.map +6 -0
- package/dist/esm/config.js +7 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/config.mjs +8 -2
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/config.native.js +10 -1
- package/dist/esm/config.native.js.map +2 -2
- package/dist/esm/createComponent.js +22 -27
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.mjs +18 -21
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +22 -48
- package/dist/esm/createComponent.native.js.map +2 -2
- package/dist/esm/createTamagui.js +3 -3
- package/dist/esm/createTamagui.js.map +1 -1
- package/dist/esm/createTamagui.mjs +3 -3
- package/dist/esm/createTamagui.mjs.map +1 -1
- package/dist/esm/createTamagui.native.js +4 -3
- package/dist/esm/createTamagui.native.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +2 -2
- package/dist/esm/helpers/createMediaStyle.js.map +1 -1
- package/dist/esm/helpers/createMediaStyle.mjs +2 -2
- package/dist/esm/helpers/createMediaStyle.mjs.map +1 -1
- package/dist/esm/helpers/createMediaStyle.native.js +2 -2
- package/dist/esm/helpers/createMediaStyle.native.js.map +2 -2
- package/dist/esm/helpers/createShallowSetState.js +1 -1
- package/dist/esm/helpers/createShallowSetState.mjs +1 -1
- package/dist/esm/helpers/createShallowSetState.mjs.map +1 -1
- package/dist/esm/helpers/createShallowSetState.native.js +1 -1
- package/dist/esm/helpers/createShallowSetState.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +35 -18
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +29 -19
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +25 -17
- package/dist/esm/helpers/getSplitStyles.native.js.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.js +7 -5
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.mjs +7 -5
- package/dist/esm/helpers/getThemeCSSRules.mjs.map +1 -1
- package/dist/esm/helpers/log.js +9 -2
- package/dist/esm/helpers/log.js.map +1 -1
- package/dist/esm/helpers/log.mjs +9 -1
- package/dist/esm/helpers/log.mjs.map +1 -1
- package/dist/esm/helpers/log.native.js +10 -4
- package/dist/esm/helpers/log.native.js.map +2 -2
- package/dist/esm/helpers/propMapper.js +4 -3
- package/dist/esm/helpers/propMapper.js.map +1 -1
- package/dist/esm/helpers/propMapper.mjs +8 -8
- package/dist/esm/helpers/propMapper.mjs.map +1 -1
- package/dist/esm/helpers/propMapper.native.js +4 -3
- package/dist/esm/helpers/propMapper.native.js.map +2 -2
- package/dist/esm/hooks/useDisableSSR.js +2 -2
- package/dist/esm/hooks/useDisableSSR.js.map +1 -1
- package/dist/esm/hooks/useDisableSSR.mjs +2 -2
- package/dist/esm/hooks/useDisableSSR.mjs.map +1 -1
- package/dist/esm/hooks/useDisableSSR.native.js +2 -2
- package/dist/esm/hooks/useDisableSSR.native.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +23 -4
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +21 -8
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +42 -7
- package/dist/esm/hooks/useMedia.native.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +13 -6
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/hooks/useTheme.mjs +12 -5
- package/dist/esm/hooks/useTheme.mjs.map +1 -1
- package/dist/esm/hooks/useTheme.native.js +20 -9
- package/dist/esm/hooks/useTheme.native.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +3 -2
- package/dist/esm/views/TamaguiProvider.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +3 -2
- package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
- package/dist/esm/views/TamaguiProvider.native.js +3 -2
- package/dist/esm/views/TamaguiProvider.native.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +2 -1
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeProvider.mjs +2 -1
- package/dist/esm/views/ThemeProvider.mjs.map +1 -1
- package/dist/esm/views/ThemeProvider.native.js +2 -1
- package/dist/esm/views/ThemeProvider.native.js.map +2 -2
- package/dist/esm/views/html.js +1 -0
- package/dist/esm/views/html.js.map +6 -0
- package/dist/esm/views/html.mjs +2 -0
- package/dist/esm/views/html.mjs.map +1 -0
- package/dist/esm/views/html.native.js +1 -0
- package/dist/esm/views/html.native.js.map +6 -0
- package/package.json +11 -11
- package/src/config.ts +14 -0
- package/src/createComponent.tsx +36 -43
- package/src/createTamagui.ts +5 -3
- package/src/helpers/createMediaStyle.ts +2 -2
- package/src/helpers/createShallowSetState.tsx +1 -1
- package/src/helpers/getSplitStyles.tsx +45 -15
- package/src/helpers/getThemeCSSRules.ts +7 -5
- package/src/helpers/log.ts +12 -5
- package/src/helpers/propMapper.ts +4 -3
- package/src/hooks/useDisableSSR.tsx +2 -2
- package/src/hooks/useMedia.tsx +30 -4
- package/src/hooks/useTheme.tsx +21 -4
- package/src/types.tsx +92 -15
- package/src/views/TamaguiProvider.tsx +7 -2
- package/src/views/ThemeProvider.tsx +6 -1
- package/types/config.d.ts +2 -1
- package/types/config.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/log.d.ts.map +1 -1
- package/types/helpers/propMapper.d.ts.map +1 -1
- package/types/hooks/useConfiguration.d.ts +2 -41
- package/types/hooks/useConfiguration.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +3 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +82 -12
- package/types/types.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/types/views/html.d.ts +1 -0
- package/types/views/html.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.105.
|
|
3
|
+
"version": "1.105.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.105.
|
|
31
|
-
"@tamagui/constants": "1.105.
|
|
32
|
-
"@tamagui/helpers": "1.105.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.105.
|
|
34
|
-
"@tamagui/timer": "1.105.
|
|
35
|
-
"@tamagui/types": "1.105.
|
|
36
|
-
"@tamagui/use-did-finish-ssr": "1.105.
|
|
37
|
-
"@tamagui/use-event": "1.105.
|
|
38
|
-
"@tamagui/use-force-update": "1.105.
|
|
30
|
+
"@tamagui/compose-refs": "1.105.2",
|
|
31
|
+
"@tamagui/constants": "1.105.2",
|
|
32
|
+
"@tamagui/helpers": "1.105.2",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.105.2",
|
|
34
|
+
"@tamagui/timer": "1.105.2",
|
|
35
|
+
"@tamagui/types": "1.105.2",
|
|
36
|
+
"@tamagui/use-did-finish-ssr": "1.105.2",
|
|
37
|
+
"@tamagui/use-event": "1.105.2",
|
|
38
|
+
"@tamagui/use-force-update": "1.105.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "1.105.
|
|
41
|
+
"@tamagui/build": "1.105.2",
|
|
42
42
|
"@testing-library/react": "^14.0.0",
|
|
43
43
|
"csstype": "^3.0.10",
|
|
44
44
|
"typescript": "^5.5.2",
|
package/src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { isWeb } from '@tamagui/constants'
|
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
ConfigListener,
|
|
5
|
+
GenericTamaguiSettings,
|
|
5
6
|
TamaguiInternalConfig,
|
|
6
7
|
Token,
|
|
7
8
|
Tokens,
|
|
@@ -10,6 +11,19 @@ import type {
|
|
|
10
11
|
|
|
11
12
|
let conf: TamaguiInternalConfig | null
|
|
12
13
|
|
|
14
|
+
export const getSetting = <Key extends keyof GenericTamaguiSettings>(
|
|
15
|
+
key: Key
|
|
16
|
+
): GenericTamaguiSettings[Key] => {
|
|
17
|
+
if (process.env.NODE_ENV === 'development') {
|
|
18
|
+
if (!conf) throw new Error(`Haven't called createTamagui yet`)
|
|
19
|
+
}
|
|
20
|
+
return (
|
|
21
|
+
conf!.settings[key] ??
|
|
22
|
+
// @ts-expect-error
|
|
23
|
+
conf[key]
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
export const setConfig = (next: TamaguiInternalConfig) => {
|
|
14
28
|
conf = next
|
|
15
29
|
}
|
package/src/createComponent.tsx
CHANGED
|
@@ -41,7 +41,12 @@ import { mergeProps } from './helpers/mergeProps'
|
|
|
41
41
|
import { setElementProps } from './helpers/setElementProps'
|
|
42
42
|
import { themeable } from './helpers/themeable'
|
|
43
43
|
import { useDidHydrateOnce } from './hooks/useDidHydrateOnce'
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
getMediaState,
|
|
46
|
+
mediaKeyMatch,
|
|
47
|
+
setMediaShouldUpdate,
|
|
48
|
+
useMedia,
|
|
49
|
+
} from './hooks/useMedia'
|
|
45
50
|
import { useThemeWithState } from './hooks/useTheme'
|
|
46
51
|
import type { TamaguiComponentEvents } from './interfaces/TamaguiComponentEvents'
|
|
47
52
|
import type { TamaguiComponentState } from './interfaces/TamaguiComponentState'
|
|
@@ -296,30 +301,14 @@ export const useComponentState = (
|
|
|
296
301
|
const isAnimatedAndHydrated =
|
|
297
302
|
isAnimated && !supportsCSSVars && didHydrateOnce && !isServer
|
|
298
303
|
|
|
304
|
+
const isClassNameDisabled =
|
|
305
|
+
!staticConfig.acceptsClassName && (config.disableSSR || didHydrateOnce)
|
|
306
|
+
|
|
299
307
|
const isDisabledManually =
|
|
300
308
|
disableClassName && !isServer && didHydrateOnce && state.unmounted === true
|
|
301
309
|
|
|
302
|
-
if (isAnimatedAndHydrated || isDisabledManually) {
|
|
310
|
+
if (isAnimatedAndHydrated || isDisabledManually || isClassNameDisabled) {
|
|
303
311
|
shouldAvoidClasses = true
|
|
304
|
-
|
|
305
|
-
// debug
|
|
306
|
-
if (process.env.NODE_ENV === 'development' && props.debug) {
|
|
307
|
-
console.info(
|
|
308
|
-
`❌⛹️ no className`,
|
|
309
|
-
{
|
|
310
|
-
isAnimatedAndHydrated,
|
|
311
|
-
isDisabledManually,
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
isAnimated,
|
|
315
|
-
supportsCSSVars,
|
|
316
|
-
didHydrateOnce,
|
|
317
|
-
disableClassName,
|
|
318
|
-
isServer,
|
|
319
|
-
willBeAnimated,
|
|
320
|
-
}
|
|
321
|
-
)
|
|
322
|
-
}
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
|
|
@@ -695,27 +684,28 @@ export function createComponent<
|
|
|
695
684
|
'[Unnamed Component]'
|
|
696
685
|
}`
|
|
697
686
|
const type =
|
|
698
|
-
(hasEnterStyle ? '(hasEnter)' : '') +
|
|
699
|
-
(isAnimated ? '(animated)' : '') +
|
|
700
|
-
(isReactNative ? '(rnw)' : '') +
|
|
687
|
+
(hasEnterStyle ? '(hasEnter)' : ' ') +
|
|
688
|
+
(isAnimated ? '(animated)' : ' ') +
|
|
689
|
+
(isReactNative ? '(rnw)' : ' ') +
|
|
690
|
+
(shouldAvoidClasses ? '(shouldAvoidClasses)' : ' ') +
|
|
691
|
+
(state.press || state.pressIn ? '(PRESSED)' : ' ') +
|
|
692
|
+
(state.hover ? '(HOVERED)' : ' ') +
|
|
693
|
+
(state.focus ? '(FOCUSED)' : ' ') +
|
|
701
694
|
(presenceState?.isPresent === false ? '(EXIT)' : '')
|
|
695
|
+
|
|
702
696
|
const dataIs = propsIn['data-is'] || ''
|
|
703
697
|
const banner = `${internalID} ${name}${dataIs ? ` ${dataIs}` : ''} ${type}`
|
|
704
698
|
console.info(
|
|
705
699
|
`%c ${banner} (hydrated: ${isHydrated}) (unmounted: ${state.unmounted})`,
|
|
706
700
|
'background: green; color: white;'
|
|
707
701
|
)
|
|
702
|
+
|
|
708
703
|
if (isServer) {
|
|
709
704
|
log({ noClassNames, isAnimated, shouldAvoidClasses, isWeb, supportsCSSVars })
|
|
710
705
|
} else {
|
|
711
706
|
// if strict mode or something messes with our nesting this fixes:
|
|
712
707
|
console.groupEnd()
|
|
713
708
|
|
|
714
|
-
const pressLog = `${state.press || state.pressIn ? ' PRESS ' : ''}`
|
|
715
|
-
const stateLog = `${pressLog}${state.hover ? ' HOVER ' : ''}${
|
|
716
|
-
state.focus ? ' FOCUS' : ' '
|
|
717
|
-
}`
|
|
718
|
-
|
|
719
709
|
const ch = propsIn.children
|
|
720
710
|
let childLog =
|
|
721
711
|
typeof ch === 'string' ? (ch.length > 4 ? ch.slice(0, 4) + '...' : ch) : ''
|
|
@@ -723,7 +713,7 @@ export function createComponent<
|
|
|
723
713
|
childLog = `(children: ${childLog})`
|
|
724
714
|
}
|
|
725
715
|
|
|
726
|
-
console.groupCollapsed(`${childLog}
|
|
716
|
+
console.groupCollapsed(`${childLog} Props:`)
|
|
727
717
|
log('props in:', propsIn)
|
|
728
718
|
log('final props:', props)
|
|
729
719
|
log({ state, staticConfig, elementType, themeStateProps })
|
|
@@ -964,7 +954,7 @@ export function createComponent<
|
|
|
964
954
|
|
|
965
955
|
const unPress = () => setStateShallow({ press: false, pressIn: false })
|
|
966
956
|
|
|
967
|
-
if (process.env.NODE_ENV === 'development') {
|
|
957
|
+
if (process.env.NODE_ENV === 'development' && isWeb) {
|
|
968
958
|
useIsomorphicLayoutEffect(() => {
|
|
969
959
|
if (debugProp) {
|
|
970
960
|
console.groupCollapsed(`Rendered style >`)
|
|
@@ -1059,6 +1049,20 @@ export function createComponent<
|
|
|
1059
1049
|
|
|
1060
1050
|
if (process.env.NODE_ENV === 'development' && time) time`events-setup`
|
|
1061
1051
|
|
|
1052
|
+
if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {
|
|
1053
|
+
log(`🪩 events()`, {
|
|
1054
|
+
runtimeFocusStyle,
|
|
1055
|
+
runtimePressStyle,
|
|
1056
|
+
runtimeHoverStyle,
|
|
1057
|
+
runtimeFocusVisibleStyle,
|
|
1058
|
+
attachPress,
|
|
1059
|
+
attachFocus,
|
|
1060
|
+
attachHover,
|
|
1061
|
+
shouldAttach,
|
|
1062
|
+
needsHoverState,
|
|
1063
|
+
})
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1062
1066
|
const events: TamaguiComponentEvents | null = shouldAttach
|
|
1063
1067
|
? {
|
|
1064
1068
|
onPressOut: attachPress
|
|
@@ -1346,7 +1350,7 @@ export function createComponent<
|
|
|
1346
1350
|
}
|
|
1347
1351
|
|
|
1348
1352
|
// add in <style> tags inline
|
|
1349
|
-
if (process.env.TAMAGUI_REACT_19) {
|
|
1353
|
+
if (process.env.TAMAGUI_REACT_19 && process.env.TAMAGUI_TARGET !== 'native') {
|
|
1350
1354
|
const { rulesToInsert } = splitStyles
|
|
1351
1355
|
const keys = Object.keys(splitStyles.rulesToInsert)
|
|
1352
1356
|
if (keys.length) {
|
|
@@ -1743,17 +1747,6 @@ function hasAnimatedStyleValue(style: Object) {
|
|
|
1743
1747
|
})
|
|
1744
1748
|
}
|
|
1745
1749
|
|
|
1746
|
-
function getMediaState(
|
|
1747
|
-
mediaGroups: Set<string>,
|
|
1748
|
-
layout: LayoutEvent['nativeEvent']['layout']
|
|
1749
|
-
) {
|
|
1750
|
-
return Object.fromEntries(
|
|
1751
|
-
[...mediaGroups].map((mediaKey) => {
|
|
1752
|
-
return [mediaKey, mediaKeyMatch(mediaKey, layout as any)]
|
|
1753
|
-
})
|
|
1754
|
-
)
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
1750
|
const fromPx = (val?: number | string) =>
|
|
1758
1751
|
typeof val !== 'string' ? val : +val.replace('px', '')
|
|
1759
1752
|
|
package/src/createTamagui.ts
CHANGED
|
@@ -227,8 +227,10 @@ ${runtimeStyles}`
|
|
|
227
227
|
|
|
228
228
|
const getNewCSS: GetCSS = (opts) => getCSS({ ...opts, sinceLastCall: true })
|
|
229
229
|
|
|
230
|
+
const defaultFontSetting = configIn.settings?.defaultFont ?? configIn.defaultFont
|
|
231
|
+
|
|
230
232
|
let defaultFontName =
|
|
231
|
-
|
|
233
|
+
defaultFontSetting ||
|
|
232
234
|
// uses font named "body" if present for compat
|
|
233
235
|
(configIn.fonts && ('body' in configIn.fonts ? 'body' : ''))
|
|
234
236
|
|
|
@@ -252,7 +254,7 @@ ${runtimeStyles}`
|
|
|
252
254
|
media: {},
|
|
253
255
|
...configIn,
|
|
254
256
|
unset: {
|
|
255
|
-
fontFamily:
|
|
257
|
+
fontFamily: defaultFontName ? defaultFont : undefined,
|
|
256
258
|
...configIn.unset,
|
|
257
259
|
},
|
|
258
260
|
settings: {
|
|
@@ -279,8 +281,8 @@ ${runtimeStyles}`
|
|
|
279
281
|
// .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }
|
|
280
282
|
}
|
|
281
283
|
|
|
282
|
-
configureMedia(config)
|
|
283
284
|
setConfig(config)
|
|
285
|
+
configureMedia(config)
|
|
284
286
|
|
|
285
287
|
createdConfigs.set(config, true)
|
|
286
288
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfig } from '../config'
|
|
1
|
+
import { getConfig, getSetting } from '../config'
|
|
2
2
|
import { mediaObjectToString } from '../hooks/useMedia'
|
|
3
3
|
import type { IsMediaType, MediaQueries, MediaStyleObject, StyleObject } from '../types'
|
|
4
4
|
import { getGroupPropParts } from './getGroupPropParts'
|
|
@@ -56,7 +56,7 @@ export const createMediaStyle = (
|
|
|
56
56
|
const selectorStart = styleInner.indexOf(':root')
|
|
57
57
|
const selectorEnd = styleInner.lastIndexOf('{')
|
|
58
58
|
const selector = styleInner.slice(selectorStart, selectorEnd)
|
|
59
|
-
const precedenceSpace =
|
|
59
|
+
const precedenceSpace = getSetting('themeClassNameOnRoot') && isTheme ? '' : ' '
|
|
60
60
|
const pseudoSelectorName = groupInfo.pseudo
|
|
61
61
|
? groupPseudoToPseudoCSSMap[groupInfo.pseudo] || groupInfo.pseudo
|
|
62
62
|
: undefined
|
|
@@ -30,7 +30,7 @@ export function mergeIfNotShallowEqual(
|
|
|
30
30
|
}
|
|
31
31
|
if (process.env.NODE_ENV === 'development') {
|
|
32
32
|
if (debug) {
|
|
33
|
-
console.
|
|
33
|
+
console.info(`setStateShallow CHANGE`, { prev, next })
|
|
34
34
|
if (debug === 'break') {
|
|
35
35
|
// biome-ignore lint/suspicious/noDebugger: <explanation>
|
|
36
36
|
debugger
|
|
@@ -72,6 +72,8 @@ import { pseudoDescriptors, pseudoPriorities } from './pseudoDescriptors'
|
|
|
72
72
|
import { skipProps } from './skipProps'
|
|
73
73
|
import { transformsToString } from './transformsToString'
|
|
74
74
|
|
|
75
|
+
const consoleGroupCollapsed = isWeb ? console.groupCollapsed : console.info
|
|
76
|
+
|
|
75
77
|
export type SplitStyles = ReturnType<typeof getSplitStyles>
|
|
76
78
|
|
|
77
79
|
export type SplitStyleResult = ReturnType<typeof getSplitStyles>
|
|
@@ -218,7 +220,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
218
220
|
debug !== 'profile' &&
|
|
219
221
|
isClient
|
|
220
222
|
) {
|
|
221
|
-
|
|
223
|
+
consoleGroupCollapsed('getSplitStyles (collapsed)')
|
|
222
224
|
log({
|
|
223
225
|
props,
|
|
224
226
|
staticConfig,
|
|
@@ -536,7 +538,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
536
538
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
537
539
|
console.groupEnd() // react native was not nesting right
|
|
538
540
|
console.groupEnd() // react native was not nesting right
|
|
539
|
-
|
|
541
|
+
consoleGroupCollapsed(
|
|
540
542
|
` 🔑 ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ''} ${
|
|
541
543
|
shouldPassThrough ? '(pass)' : ''
|
|
542
544
|
}`
|
|
@@ -620,7 +622,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
620
622
|
}
|
|
621
623
|
|
|
622
624
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
623
|
-
|
|
625
|
+
consoleGroupCollapsed(' 💠 expanded', keyInit, valInit)
|
|
624
626
|
try {
|
|
625
627
|
if (!isServer && isDevTools) {
|
|
626
628
|
log({
|
|
@@ -631,7 +633,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
631
633
|
variant: variants?.[keyInit],
|
|
632
634
|
shouldPassProp,
|
|
633
635
|
isHOCShouldPassThrough,
|
|
634
|
-
theme,
|
|
635
636
|
usedKeys: { ...usedKeys },
|
|
636
637
|
curProps: { ...styleState.curProps },
|
|
637
638
|
})
|
|
@@ -682,7 +683,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
682
683
|
if (shouldPassThrough) {
|
|
683
684
|
passDownProp(viewProps, key, val, isMediaOrPseudo)
|
|
684
685
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
685
|
-
|
|
686
|
+
consoleGroupCollapsed(` - passing down prop ${key}`)
|
|
686
687
|
log({ val, after: { ...viewProps[key] } })
|
|
687
688
|
console.groupEnd()
|
|
688
689
|
}
|
|
@@ -725,7 +726,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
725
726
|
|
|
726
727
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
727
728
|
// prettier-ignore
|
|
728
|
-
|
|
729
|
+
consoleGroupCollapsed('pseudo (classes)', key)
|
|
729
730
|
|
|
730
731
|
log({ pseudoStyleObject, pseudoStyles })
|
|
731
732
|
console.groupEnd()
|
|
@@ -764,7 +765,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
764
765
|
}
|
|
765
766
|
|
|
766
767
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
767
|
-
|
|
768
|
+
consoleGroupCollapsed('pseudo', key, { isDisabled })
|
|
768
769
|
log({ pseudoStyleObject, isDisabled, descriptor, componentState })
|
|
769
770
|
console.groupEnd()
|
|
770
771
|
}
|
|
@@ -953,7 +954,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
953
954
|
const groupContext = context?.groups.state[groupName]
|
|
954
955
|
if (!groupContext) {
|
|
955
956
|
if (process.env.NODE_ENV === 'development' && debug) {
|
|
956
|
-
|
|
957
|
+
log(`No parent with group prop, skipping styles: ${groupName}`)
|
|
957
958
|
}
|
|
958
959
|
continue
|
|
959
960
|
}
|
|
@@ -971,6 +972,9 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
971
972
|
if (!mediaState && groupContext.layout) {
|
|
972
973
|
isActive = mediaKeyMatch(groupMediaKey, groupContext.layout)
|
|
973
974
|
}
|
|
975
|
+
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
976
|
+
log(` 🏘️ GROUP media ${groupMediaKey} active? ${isActive}`)
|
|
977
|
+
}
|
|
974
978
|
if (!isActive) continue
|
|
975
979
|
importanceBump = 2
|
|
976
980
|
}
|
|
@@ -984,8 +988,13 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
984
988
|
context.groups.state[groupName]
|
|
985
989
|
).pseudo
|
|
986
990
|
const isActive = componentGroupPseudoState?.[groupPseudoKey]
|
|
987
|
-
if (!isActive) continue
|
|
988
991
|
const priority = pseudoPriorities[groupPseudoKey]
|
|
992
|
+
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
993
|
+
log(
|
|
994
|
+
` 🏘️ GROUP pseudo ${groupMediaKey} active? ${isActive}, priority ${priority}`
|
|
995
|
+
)
|
|
996
|
+
}
|
|
997
|
+
if (!isActive) continue
|
|
989
998
|
importanceBump = priority
|
|
990
999
|
}
|
|
991
1000
|
}
|
|
@@ -1003,7 +1012,8 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1003
1012
|
mediaStyle[subKey],
|
|
1004
1013
|
usedKeys,
|
|
1005
1014
|
mediaState[mediaKeyShort],
|
|
1006
|
-
importanceBump
|
|
1015
|
+
importanceBump,
|
|
1016
|
+
debug
|
|
1007
1017
|
)
|
|
1008
1018
|
if (key === 'fontFamily') {
|
|
1009
1019
|
styleState.fontFamily = mediaStyle.fontFamily as string
|
|
@@ -1158,7 +1168,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1158
1168
|
|
|
1159
1169
|
if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') {
|
|
1160
1170
|
console.groupEnd() // ensure group ended from loop above
|
|
1161
|
-
|
|
1171
|
+
consoleGroupCollapsed(`🔹 getSplitStyles final style object`)
|
|
1162
1172
|
console.info(styleState.style)
|
|
1163
1173
|
console.groupEnd()
|
|
1164
1174
|
}
|
|
@@ -1172,7 +1182,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1172
1182
|
for (const namespace in transforms) {
|
|
1173
1183
|
if (!transforms[namespace]) {
|
|
1174
1184
|
if (process.env.NODE_ENV === 'development') {
|
|
1175
|
-
|
|
1185
|
+
log('Error no transform', transforms, namespace)
|
|
1176
1186
|
}
|
|
1177
1187
|
continue
|
|
1178
1188
|
}
|
|
@@ -1365,7 +1375,7 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
1365
1375
|
|
|
1366
1376
|
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
1367
1377
|
if (isDevTools) {
|
|
1368
|
-
|
|
1378
|
+
consoleGroupCollapsed('🔹 getSplitStyles ===>')
|
|
1369
1379
|
try {
|
|
1370
1380
|
// prettier-ignore
|
|
1371
1381
|
const logs = {
|
|
@@ -1596,7 +1606,8 @@ function mergeMediaByImportance(
|
|
|
1596
1606
|
value: any,
|
|
1597
1607
|
importancesUsed: Record<string, number>,
|
|
1598
1608
|
isSizeMedia: boolean,
|
|
1599
|
-
importanceBump?: number
|
|
1609
|
+
importanceBump?: number,
|
|
1610
|
+
debugProp?: DebugProp
|
|
1600
1611
|
) {
|
|
1601
1612
|
let importance = getMediaImportanceIfMoreImportant(
|
|
1602
1613
|
mediaKey,
|
|
@@ -1607,11 +1618,30 @@ function mergeMediaByImportance(
|
|
|
1607
1618
|
if (importanceBump) {
|
|
1608
1619
|
importance = (importance || 0) + importanceBump
|
|
1609
1620
|
}
|
|
1621
|
+
if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {
|
|
1622
|
+
log(
|
|
1623
|
+
`mergeMediaByImportance ${key} importance existing ${importancesUsed[key]} next ${importance}`
|
|
1624
|
+
)
|
|
1625
|
+
}
|
|
1610
1626
|
if (importance === null) {
|
|
1611
1627
|
return false
|
|
1612
1628
|
}
|
|
1613
1629
|
importancesUsed[key] = importance
|
|
1614
|
-
|
|
1630
|
+
|
|
1631
|
+
if (key in pseudoDescriptors) {
|
|
1632
|
+
const descriptor = pseudoDescriptors[key]
|
|
1633
|
+
const descriptorKey = descriptor.stateKey || descriptor.name
|
|
1634
|
+
const isDisabled = styleState.componentState[descriptorKey] === false
|
|
1635
|
+
if (isDisabled) {
|
|
1636
|
+
return false
|
|
1637
|
+
}
|
|
1638
|
+
for (const subKey in value) {
|
|
1639
|
+
mergeStyle(styleState, subKey, value[subKey])
|
|
1640
|
+
}
|
|
1641
|
+
} else {
|
|
1642
|
+
mergeStyle(styleState, key, value)
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1615
1645
|
return true
|
|
1616
1646
|
}
|
|
1617
1647
|
|
|
@@ -5,6 +5,7 @@ import type { Variable } from '../createVariable'
|
|
|
5
5
|
import { variableToString } from '../createVariable'
|
|
6
6
|
import type { CreateTamaguiProps, ThemeParsed } from '../types'
|
|
7
7
|
import { tokensValueToVariable } from './registerCSSVariable'
|
|
8
|
+
import { getSetting } from '../config'
|
|
8
9
|
|
|
9
10
|
export function getThemeCSSRules(props: {
|
|
10
11
|
config: CreateTamaguiProps
|
|
@@ -59,7 +60,7 @@ export function getThemeCSSRules(props: {
|
|
|
59
60
|
// since we dont specify dark/light in classnames we have to do an awkward specificity war
|
|
60
61
|
// use config.maxDarkLightNesting to determine how deep you can nest until it breaks
|
|
61
62
|
if (hasDarkLight) {
|
|
62
|
-
const maxDepth =
|
|
63
|
+
const maxDepth = getSetting('maxDarkLightNesting') ?? 3
|
|
63
64
|
|
|
64
65
|
for (const subName of names) {
|
|
65
66
|
const isDark = isDarkBase || subName.startsWith('dark_')
|
|
@@ -115,7 +116,7 @@ export function getThemeCSSRules(props: {
|
|
|
115
116
|
// this isBaseTheme logic could probably be done more efficiently above
|
|
116
117
|
const selectorsString = selectors
|
|
117
118
|
.map((x) => {
|
|
118
|
-
const rootSep = isBaseTheme(x) &&
|
|
119
|
+
const rootSep = isBaseTheme(x) && getSetting('themeClassNameOnRoot') ? '' : ' '
|
|
119
120
|
return `:root${rootSep}${x}`
|
|
120
121
|
})
|
|
121
122
|
.join(', ')
|
|
@@ -123,7 +124,7 @@ export function getThemeCSSRules(props: {
|
|
|
123
124
|
const css = `${selectorsString} {${vars}}`
|
|
124
125
|
cssRuleSets.push(css)
|
|
125
126
|
|
|
126
|
-
if (
|
|
127
|
+
if (getSetting('shouldAddPrefersColorThemes')) {
|
|
127
128
|
const bgString = theme.background
|
|
128
129
|
? `background:${variableToString(theme.background)};`
|
|
129
130
|
: ''
|
|
@@ -154,8 +155,9 @@ export function getThemeCSSRules(props: {
|
|
|
154
155
|
cssRuleSets.push(prefersMediaSelectors)
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
const selectionStyles = getSetting('selectionStyles')
|
|
159
|
+
if (selectionStyles) {
|
|
160
|
+
const rules = selectionStyles(theme as any)
|
|
159
161
|
if (rules) {
|
|
160
162
|
const selectionSelectors = baseSelectors.map((s) => `${s} ::selection`).join(', ')
|
|
161
163
|
const styles = Object.entries(rules)
|
package/src/helpers/log.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { _dmt } from '../hooks/useMedia'
|
|
2
|
+
|
|
1
3
|
export function log(...args: any[]) {
|
|
2
4
|
if (process.env.NODE_ENV === 'production') return
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
_dmt(true)
|
|
6
|
+
try {
|
|
7
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
8
|
+
return console.info(...args)
|
|
9
|
+
}
|
|
10
|
+
// react native doesn't log in the cli unless it's log
|
|
11
|
+
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
|
|
12
|
+
return console.log(...args)
|
|
13
|
+
} finally {
|
|
14
|
+
_dmt(false)
|
|
5
15
|
}
|
|
6
|
-
// react native doesn't log in the cli unless it's log
|
|
7
|
-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
|
|
8
|
-
return console.log(...args)
|
|
9
16
|
}
|
|
@@ -28,8 +28,10 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
|
|
|
28
28
|
if (key === 'elevationAndroid') return
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
const { conf, styleProps, fontFamily, staticConfig } = styleStateIn
|
|
32
|
+
|
|
31
33
|
if (value === 'unset') {
|
|
32
|
-
const unsetVal =
|
|
34
|
+
const unsetVal = conf.unset?.[key]
|
|
33
35
|
if (unsetVal != null) {
|
|
34
36
|
value = unsetVal
|
|
35
37
|
} else {
|
|
@@ -41,7 +43,7 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
|
|
|
41
43
|
// we use this for the sub-props like pseudos so we need to overwrite the "props" in styleState
|
|
42
44
|
// fallbackProps is awkward thanks to static
|
|
43
45
|
// also we need to override the props here because subStyles pass in a sub-style props object
|
|
44
|
-
const subProps =
|
|
46
|
+
const subProps = styleProps.fallbackProps || subPropsIn
|
|
45
47
|
const styleState = subProps
|
|
46
48
|
? new Proxy(styleStateIn, {
|
|
47
49
|
get(_, k) {
|
|
@@ -50,7 +52,6 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
|
|
|
50
52
|
})
|
|
51
53
|
: styleStateIn
|
|
52
54
|
|
|
53
|
-
const { conf, styleProps, fontFamily, staticConfig } = styleState
|
|
54
55
|
const { variants } = staticConfig
|
|
55
56
|
|
|
56
57
|
if (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSetting } from '../config'
|
|
2
2
|
import type { ComponentContextI } from '../types'
|
|
3
3
|
|
|
4
4
|
export function getDisableSSR(componentContext?: ComponentContextI) {
|
|
5
|
-
return componentContext?.disableSSR ??
|
|
5
|
+
return componentContext?.disableSSR ?? getSetting('disableSSR')
|
|
6
6
|
}
|
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { isServer, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
2
|
import { useRef, useState, useSyncExternalStore } from 'react'
|
|
3
3
|
|
|
4
|
-
import { getConfig } from '../config'
|
|
4
|
+
import { getConfig, getSetting } from '../config'
|
|
5
5
|
import { matchMedia } from '../helpers/matchMedia'
|
|
6
6
|
import { pseudoDescriptors } from '../helpers/pseudoDescriptors'
|
|
7
7
|
import type {
|
|
8
8
|
ComponentContextI,
|
|
9
9
|
DebugProp,
|
|
10
10
|
IsMediaType,
|
|
11
|
+
LayoutEvent,
|
|
11
12
|
MediaQueries,
|
|
12
13
|
MediaQueryObject,
|
|
13
14
|
MediaQueryState,
|
|
@@ -83,7 +84,8 @@ const dispose = new Set<Function>()
|
|
|
83
84
|
let mediaVersion = 0
|
|
84
85
|
|
|
85
86
|
export const configureMedia = (config: TamaguiInternalConfig) => {
|
|
86
|
-
const { media
|
|
87
|
+
const { media } = config
|
|
88
|
+
const mediaQueryDefaultActive = getSetting('mediaQueryDefaultActive')
|
|
87
89
|
if (!media) return
|
|
88
90
|
mediaVersion++
|
|
89
91
|
for (const key in media) {
|
|
@@ -265,6 +267,7 @@ export function useMedia(
|
|
|
265
267
|
|
|
266
268
|
return new Proxy(state, {
|
|
267
269
|
get(_, key) {
|
|
270
|
+
if (disableMediaTouch) return
|
|
268
271
|
if (typeof key === 'string') {
|
|
269
272
|
componentState.keys ||= {}
|
|
270
273
|
componentState.keys[key] = true
|
|
@@ -277,15 +280,38 @@ export function useMedia(
|
|
|
277
280
|
})
|
|
278
281
|
}
|
|
279
282
|
|
|
283
|
+
let disableMediaTouch = false
|
|
284
|
+
|
|
285
|
+
export function _dmt(val: boolean) {
|
|
286
|
+
disableMediaTouch = val
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function getMediaState(
|
|
290
|
+
mediaGroups: Set<string>,
|
|
291
|
+
layout: LayoutEvent['nativeEvent']['layout']
|
|
292
|
+
) {
|
|
293
|
+
disableMediaTouch = true
|
|
294
|
+
let res: Record<string, boolean>
|
|
295
|
+
try {
|
|
296
|
+
res = Object.fromEntries(
|
|
297
|
+
[...mediaGroups].map((mediaKey) => {
|
|
298
|
+
return [mediaKey, mediaKeyMatch(mediaKey, layout as any)]
|
|
299
|
+
})
|
|
300
|
+
)
|
|
301
|
+
} finally {
|
|
302
|
+
disableMediaTouch = false
|
|
303
|
+
}
|
|
304
|
+
return res
|
|
305
|
+
}
|
|
306
|
+
|
|
280
307
|
export const getMediaImportanceIfMoreImportant = (
|
|
281
308
|
mediaKey: string,
|
|
282
309
|
key: string,
|
|
283
310
|
importancesUsed: Record<string, number>,
|
|
284
311
|
isSizeMedia: boolean
|
|
285
312
|
) => {
|
|
286
|
-
const conf = getConfig()
|
|
287
313
|
const importance =
|
|
288
|
-
isSizeMedia && !
|
|
314
|
+
isSizeMedia && !getSetting('mediaPropOrder')
|
|
289
315
|
? getMediaKeyImportance(mediaKey)
|
|
290
316
|
: defaultMediaImportance
|
|
291
317
|
return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null
|