@tamagui/core 1.0.0-alpha.21 → 1.0.0-alpha.25
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/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/package.json +8 -9
- package/types/helpers/createMediaStyle.d.ts +1 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +1 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/src/constants/constants.ts +0 -12
- package/src/constants/platform.ts +0 -15
- package/src/constants/pseudos.ts +0 -14
- package/src/constants/rnw.tsx +0 -20
- package/src/createComponent.tsx +0 -614
- package/src/createFont.ts +0 -31
- package/src/createShorthands.ts +0 -5
- package/src/createTamagui.ts +0 -218
- package/src/createTheme.ts +0 -22
- package/src/createTokens.ts +0 -88
- package/src/createVariable.ts +0 -26
- package/src/helpers/addStylesUsingClassname.tsx +0 -60
- package/src/helpers/createMediaStyle.ts +0 -46
- package/src/helpers/createPropMapper.ts +0 -192
- package/src/helpers/createTamaguiProvider.tsx +0 -22
- package/src/helpers/extendStaticConfig.ts +0 -68
- package/src/helpers/fixNativeShadow.native.tsx +0 -27
- package/src/helpers/fixNativeShadow.tsx +0 -2
- package/src/helpers/getSplitStyles.tsx +0 -200
- package/src/helpers/getStylesAtomic.native.ts +0 -3
- package/src/helpers/getStylesAtomic.ts +0 -103
- package/src/helpers/insertStyleRule.tsx +0 -18
- package/src/helpers/isObj.ts +0 -1
- package/src/helpers/isTamaguiElement.tsx +0 -5
- package/src/helpers/matchMedia.native.ts +0 -6
- package/src/helpers/matchMedia.ts +0 -17
- package/src/helpers/themeable.tsx +0 -42
- package/src/helpers/validate.ts +0 -59
- package/src/hooks/useConstant.tsx +0 -10
- package/src/hooks/useFeatures.tsx +0 -79
- package/src/hooks/useMedia.tsx +0 -196
- package/src/hooks/usePressable.tsx +0 -9
- package/src/hooks/useTheme.tsx +0 -107
- package/src/index.ts +0 -32
- package/src/static/postProcessStyles.tsx +0 -20
- package/src/static.ts +0 -22
- package/src/styled.ts +0 -82
- package/src/types.tsx +0 -562
- package/src/views/Animated.tsx +0 -121
- package/src/views/Stack.tsx +0 -21
- package/src/views/Text.tsx +0 -67
- package/src/views/TextAncestorContext.tsx +0 -11
- package/src/views/Theme.tsx +0 -94
- package/src/views/ThemeContext.tsx +0 -5
- package/src/views/ThemeInverse.tsx +0 -22
- package/src/views/ThemeManagerContext.tsx +0 -62
- package/src/views/ThemeProvider.tsx +0 -52
package/src/views/Text.tsx
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'
|
|
2
|
-
|
|
3
|
-
import { isWeb } from '../constants/platform'
|
|
4
|
-
import { createComponent } from '../createComponent'
|
|
5
|
-
import { TextProps } from '../types'
|
|
6
|
-
|
|
7
|
-
const ellipseStyle = {
|
|
8
|
-
maxWidth: '100%',
|
|
9
|
-
overflow: 'hidden',
|
|
10
|
-
textOverflow: 'ellipsis',
|
|
11
|
-
whiteSpace: 'nowrap',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Text = createComponent<TextProps>({
|
|
15
|
-
isText: true,
|
|
16
|
-
defaultProps: {
|
|
17
|
-
display: isWeb ? 'inline' : 'inline-flex',
|
|
18
|
-
boxSizing: 'border-box',
|
|
19
|
-
fontFamily: 'System',
|
|
20
|
-
wordWrap: 'break-word',
|
|
21
|
-
},
|
|
22
|
-
variants: {
|
|
23
|
-
numberOfLines: {
|
|
24
|
-
1: ellipseStyle,
|
|
25
|
-
// TODO imply fn, test 1, could do types `>1` `<2`
|
|
26
|
-
'[number]': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
selectable: {
|
|
30
|
-
true: {
|
|
31
|
-
userSelect: 'text',
|
|
32
|
-
},
|
|
33
|
-
false: {
|
|
34
|
-
userSelect: 'none',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
pressable: {
|
|
39
|
-
true: {
|
|
40
|
-
cursor: 'pointer',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
ellipse: {
|
|
45
|
-
true: isWeb
|
|
46
|
-
? ellipseStyle
|
|
47
|
-
: {
|
|
48
|
-
numberOfLines: 1,
|
|
49
|
-
lineBreakMode: 'clip',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
// TODO document
|
|
54
|
-
deoptProps: new Set(isWeb ? [] : ['ellipse']),
|
|
55
|
-
validStyles: {
|
|
56
|
-
...validStyles,
|
|
57
|
-
...stylePropsTextOnly,
|
|
58
|
-
...(isWeb && {
|
|
59
|
-
userSelect: true,
|
|
60
|
-
textOverflow: true,
|
|
61
|
-
whiteSpace: true,
|
|
62
|
-
wordWrap: true,
|
|
63
|
-
selectable: true,
|
|
64
|
-
cursor: true,
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React, { createContext } from 'react'
|
|
2
|
-
|
|
3
|
-
import { rnw } from '../constants/rnw'
|
|
4
|
-
|
|
5
|
-
export const FallbackNativeContext = createContext(false)
|
|
6
|
-
|
|
7
|
-
export const TextAncestorContext = rnw?.TextAncestorContext ?? FallbackNativeContext
|
|
8
|
-
|
|
9
|
-
export const TextAncestorProvider = (props) => {
|
|
10
|
-
return <TextAncestorContext.Provider value={false}>{props.children}</TextAncestorContext.Provider>
|
|
11
|
-
}
|
package/src/views/Theme.tsx
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'
|
|
4
|
-
import { getThemeParentClassName } from '../createTamagui'
|
|
5
|
-
import { useConstant } from '../hooks/useConstant'
|
|
6
|
-
import { ThemeName } from '../types'
|
|
7
|
-
import { ThemeContext } from './ThemeContext'
|
|
8
|
-
import { ThemeManager, ThemeManagerContext } from './ThemeManagerContext'
|
|
9
|
-
|
|
10
|
-
export type ThemeProps = {
|
|
11
|
-
disableThemeClass?: boolean
|
|
12
|
-
name: Exclude<ThemeName, number> | null
|
|
13
|
-
children?: any
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const Theme = (props: ThemeProps) => {
|
|
17
|
-
const parent = useContext(ThemeManagerContext)
|
|
18
|
-
const themes = useContext(ThemeContext)
|
|
19
|
-
const [parentName, setParentName] = useState(parent.name || 'light')
|
|
20
|
-
if (!themes) {
|
|
21
|
-
console.warn('Error, no themes in context', props)
|
|
22
|
-
return props.children
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const nextNameParent = `${props.name}-${parentName}`
|
|
26
|
-
const nextNameParentParent = `${props.name}-${parent.parentName}`
|
|
27
|
-
const name = !props.name
|
|
28
|
-
? null
|
|
29
|
-
: props.name in themes
|
|
30
|
-
? props.name
|
|
31
|
-
: nextNameParent in themes
|
|
32
|
-
? nextNameParent
|
|
33
|
-
: nextNameParentParent in themes
|
|
34
|
-
? nextNameParentParent
|
|
35
|
-
: null
|
|
36
|
-
const theme = name ? themes[name] : null
|
|
37
|
-
const themeManager = useConstant<ThemeManager | null>(() => {
|
|
38
|
-
if (!theme) {
|
|
39
|
-
return null
|
|
40
|
-
}
|
|
41
|
-
const manager = new ThemeManager()
|
|
42
|
-
if (name) {
|
|
43
|
-
manager.setActiveTheme({ name, theme: themes[name], parentName })
|
|
44
|
-
}
|
|
45
|
-
return manager
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
useIsomorphicLayoutEffect(() => {
|
|
49
|
-
if (!themeManager) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
if (name) {
|
|
53
|
-
themeManager.setActiveTheme({ name, theme, parentName })
|
|
54
|
-
}
|
|
55
|
-
return parent.onChangeTheme((next) => {
|
|
56
|
-
if (next) {
|
|
57
|
-
themeManager.setActiveTheme({ name: next, theme: themes[next], parentName })
|
|
58
|
-
setParentName(next)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}, [themes, name, parentName])
|
|
62
|
-
|
|
63
|
-
if (!name || !theme) {
|
|
64
|
-
return props.children
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const contents = themeManager ? (
|
|
68
|
-
<ThemeManagerContext.Provider value={themeManager}>
|
|
69
|
-
{props.children}
|
|
70
|
-
</ThemeManagerContext.Provider>
|
|
71
|
-
) : (
|
|
72
|
-
props.children
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
if (isWeb) {
|
|
76
|
-
if (props.disableThemeClass) {
|
|
77
|
-
return contents
|
|
78
|
-
}
|
|
79
|
-
if (name) {
|
|
80
|
-
const color = themes[name]?.['color']?.['variable']
|
|
81
|
-
return (
|
|
82
|
-
<div
|
|
83
|
-
className={getThemeParentClassName(props.name)}
|
|
84
|
-
// in order to provide currentColor, set color by default
|
|
85
|
-
style={{ display: 'contents', color }}
|
|
86
|
-
>
|
|
87
|
-
{contents}
|
|
88
|
-
</div>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return contents
|
|
94
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import { useDefaultThemeName, useThemeName } from '../hooks/useTheme'
|
|
4
|
-
import { Theme } from './Theme'
|
|
5
|
-
|
|
6
|
-
type StringRecord = { [key: string]: string }
|
|
7
|
-
|
|
8
|
-
let inversions: StringRecord = {
|
|
9
|
-
light: 'dark',
|
|
10
|
-
dark: 'light',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function setThemeInversions(next: StringRecord) {
|
|
14
|
-
inversions = next
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const ThemeInverse = (props: { children: any }) => {
|
|
18
|
-
const themeName = useThemeName()
|
|
19
|
-
const defaultTheme = useDefaultThemeName()
|
|
20
|
-
const name = inversions[themeName] || inversions[defaultTheme] || null
|
|
21
|
-
return <Theme name={name}>{props.children}</Theme>
|
|
22
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react'
|
|
2
|
-
|
|
3
|
-
type ThemeListener = (name: string | null, themeManager: ThemeManager) => void
|
|
4
|
-
|
|
5
|
-
export class ThemeManager {
|
|
6
|
-
name: string | null = 'light'
|
|
7
|
-
parentName: string | null = null
|
|
8
|
-
keys = new Map<any, Set<string>>()
|
|
9
|
-
listeners = new Map<any, Function>()
|
|
10
|
-
themeListeners = new Set<ThemeListener>()
|
|
11
|
-
theme = null
|
|
12
|
-
|
|
13
|
-
setActiveTheme({
|
|
14
|
-
name,
|
|
15
|
-
theme,
|
|
16
|
-
parentName,
|
|
17
|
-
}: {
|
|
18
|
-
parentName?: string | null
|
|
19
|
-
name: string | null
|
|
20
|
-
theme?: any
|
|
21
|
-
}) {
|
|
22
|
-
if (name === this.name) return
|
|
23
|
-
this.name = name
|
|
24
|
-
this.theme = theme
|
|
25
|
-
this.parentName = parentName || null
|
|
26
|
-
this.update()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
track(uuid: any, keys: Set<string>) {
|
|
30
|
-
if (!this.name) return
|
|
31
|
-
this.keys.set(uuid, keys)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
update() {
|
|
35
|
-
if (!this.name) {
|
|
36
|
-
this.keys.clear()
|
|
37
|
-
}
|
|
38
|
-
for (const [uuid, keys] of this.keys.entries()) {
|
|
39
|
-
if (keys.size) {
|
|
40
|
-
this.listeners.get(uuid)?.()
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
this.themeListeners.forEach((cb) => cb(this.name, this))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
onChangeTheme(cb: ThemeListener) {
|
|
47
|
-
this.themeListeners.add(cb)
|
|
48
|
-
return () => {
|
|
49
|
-
this.themeListeners.delete(cb)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
onUpdate(uuid: any, cb: Function) {
|
|
54
|
-
this.listeners.set(uuid, cb)
|
|
55
|
-
return () => {
|
|
56
|
-
this.listeners.delete(uuid)
|
|
57
|
-
this.keys.delete(uuid)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const ThemeManagerContext = createContext<ThemeManager>(new ThemeManager())
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useIsomorphicLayoutEffect } from '../constants/platform'
|
|
4
|
-
import { getHasConfigured, getThemeParentClassName } from '../createTamagui'
|
|
5
|
-
import { Theme } from './Theme'
|
|
6
|
-
import { ThemeContext } from './ThemeContext'
|
|
7
|
-
|
|
8
|
-
export type ThemeProviderProps = {
|
|
9
|
-
themes: any
|
|
10
|
-
defaultTheme: string
|
|
11
|
-
disableRootThemeClass?: boolean
|
|
12
|
-
children?: any
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const GET_DEFAULT_THEME = '___TGUI'
|
|
16
|
-
|
|
17
|
-
export const ThemeProvider = (props: ThemeProviderProps) => {
|
|
18
|
-
if (!getHasConfigured()) {
|
|
19
|
-
throw new Error(`Missing configureThemes() call, add to your root file`)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// ensure theme is attached to root body node as well to work with modals by default
|
|
23
|
-
useIsomorphicLayoutEffect(() => {
|
|
24
|
-
if (props.disableRootThemeClass) {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
if (typeof document !== 'undefined') {
|
|
28
|
-
const cns = getThemeParentClassName(`${props.defaultTheme}`).split(' ')
|
|
29
|
-
cns.forEach((cn) => document.body.classList.add(cn))
|
|
30
|
-
return () => {
|
|
31
|
-
cns.forEach((cn) => document.body.classList.remove(cn))
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}, [])
|
|
35
|
-
|
|
36
|
-
const themeContext = useMemo(() => {
|
|
37
|
-
return new Proxy(props.themes, {
|
|
38
|
-
get(target, key) {
|
|
39
|
-
if (key === GET_DEFAULT_THEME) return props.defaultTheme
|
|
40
|
-
return Reflect.get(target, key)
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
}, [props.themes])
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<ThemeContext.Provider value={themeContext}>
|
|
47
|
-
<Theme name={props.defaultTheme} disableThemeClass={props.disableRootThemeClass}>
|
|
48
|
-
{props.children}
|
|
49
|
-
</Theme>
|
|
50
|
-
</ThemeContext.Provider>
|
|
51
|
-
)
|
|
52
|
-
}
|