@tamagui/core 1.0.1-beta.190 → 1.0.1-beta.192
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/addTheme.js.map +2 -2
- package/dist/cjs/createComponent.js +14 -13
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createShorthands.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +4 -2
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createProxy.js +43 -0
- package/dist/cjs/helpers/createProxy.js.map +7 -0
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +11 -11
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +5 -9
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/proxyThemeVariables.js +5 -3
- package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +12 -18
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/addTheme.js.map +2 -2
- package/dist/esm/createComponent.js +14 -13
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createShorthands.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +4 -2
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createProxy.js +19 -0
- package/dist/esm/helpers/createProxy.js.map +7 -0
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +11 -11
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +5 -9
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/proxyThemeVariables.js +5 -3
- package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/esm/views/Slot.js +12 -12
- package/dist/esm/views/Slot.js.map +2 -2
- package/package.json +13 -12
- package/src/addTheme.ts +1 -0
- package/src/createComponent.tsx +16 -13
- package/src/createShorthands.ts +4 -2
- package/src/helpers/createPropMapper.ts +5 -2
- package/src/helpers/expandStyles.ts +1 -0
- package/src/helpers/getSplitStyles.tsx +10 -11
- package/src/helpers/insertStyleRule.tsx +11 -11
- package/src/helpers/proxyThemeVariables.tsx +6 -4
- package/src/types.tsx +58 -39
- package/src/views/Slot.tsx +16 -20
- package/types/Tamagui.d.ts +1 -1
- package/types/config.d.ts +1 -1
- package/types/createShorthands.d.ts +2 -1
- package/types/helpers/expandStyles.d.ts +5 -5
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/types.d.ts +30 -19
- package/types/views/Slot.d.ts +4 -4
- package/src/constants/platform.native.ts +0 -14
- package/src/constants/platform.ts +0 -41
- package/src/helpers/validate.ts +0 -80
- package/types/conf.d.ts +0 -26
- package/types/createComponent.server.d.ts +0 -36
- package/types/helpers/createShallowUpdate.d.ts +0 -3
- package/types/helpers/cssHash.d.ts +0 -2
- package/types/helpers/useAnimationDriver.d.ts +0 -1
- package/types/hooks/useAnimationDriver.d.ts +0 -1
- package/types/hooks/useDidFinishSSR.d.ts +0 -3
- package/types/hooks/useFeatures.d.ts +0 -23
- package/types/hooks/useIsSSR.d.ts +0 -4
- package/types/hooks/useServerContext.d.ts +0 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
2
|
|
|
3
3
|
import { getConfig } from '../config'
|
|
4
|
+
import { CreateShorthands } from '../types'
|
|
4
5
|
import { expandStyle } from './expandStyle'
|
|
5
6
|
import { colorToRGBA, normalizeColor } from './normalizeColor'
|
|
6
7
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
@@ -45,8 +45,11 @@ const skipProps = {
|
|
|
45
45
|
animateOnly: true,
|
|
46
46
|
debug: true,
|
|
47
47
|
componentName: true,
|
|
48
|
+
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
// native only skips
|
|
51
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
52
|
+
Object.assign(skipProps, {
|
|
50
53
|
tag: true,
|
|
51
54
|
whiteSpace: true,
|
|
52
55
|
wordWrap: true,
|
|
@@ -58,7 +61,7 @@ const skipProps = {
|
|
|
58
61
|
contain: true,
|
|
59
62
|
boxSizing: true,
|
|
60
63
|
boxShadow: true,
|
|
61
|
-
})
|
|
64
|
+
})
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
type TransformNamespaceKey = 'transform' | PseudoPropKeys | MediaQueryKey
|
|
@@ -478,17 +481,13 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
// should probably have a few more exceptions here!
|
|
487
|
-
if (key === 'pointerEvents' || !state.dynamicStylesInline) {
|
|
484
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
485
|
+
if (shouldDoClasses) {
|
|
486
|
+
const atomic = getStylesAtomic(style)
|
|
487
|
+
for (const atomicStyle of atomic) {
|
|
488
|
+
const key = atomicStyle.property
|
|
488
489
|
addStyleToInsertRules(rulesToInsert, atomicStyle)
|
|
489
490
|
mergeClassName(transforms, classNames, key, atomicStyle.identifier)
|
|
490
|
-
} else {
|
|
491
|
-
style[key] = atomicStyle.value
|
|
492
491
|
}
|
|
493
492
|
}
|
|
494
493
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// this should avoid re-inserts, but need to test the perf trade-offs
|
|
3
3
|
// i tested with the site itself and the initial insert was trivial
|
|
4
4
|
|
|
5
|
-
import { StyleObject } from '@tamagui/helpers'
|
|
5
|
+
import type { StyleObject } from '@tamagui/helpers'
|
|
6
6
|
|
|
7
7
|
const allSelectors = {}
|
|
8
8
|
const allRules = {}
|
|
@@ -17,17 +17,16 @@ function addTransform(identifier: string, css: string, rule?: CSSRule) {
|
|
|
17
17
|
const s = css.indexOf('transform:')
|
|
18
18
|
if (s === -1) {
|
|
19
19
|
if (process.env.NODE_ENV === 'development') {
|
|
20
|
-
//
|
|
21
|
-
if (css.indexOf('{ }')) {
|
|
22
|
-
console.log('wah wah')
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
25
21
|
console.groupCollapsed(`❌ Invalid transform, likely used deg/% improperly ${identifier}`)
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
26
23
|
console.log('rule:', rule)
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
27
25
|
console.trace()
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
28
27
|
console.groupEnd()
|
|
29
28
|
} else {
|
|
30
|
-
|
|
29
|
+
// missing transform
|
|
31
30
|
}
|
|
32
31
|
return false
|
|
33
32
|
}
|
|
@@ -95,11 +94,12 @@ export function updateInserted() {
|
|
|
95
94
|
|
|
96
95
|
function getTamaguiSelector(rule: CSSRule | null): readonly [string, CSSStyleRule] | null {
|
|
97
96
|
if (rule instanceof CSSStyleRule) {
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const text = rule.selectorText
|
|
98
|
+
if (text.startsWith('._')) {
|
|
99
|
+
return [text.slice(1), rule]
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
return [getIdentifierFromTamaguiSelector(
|
|
101
|
+
if (text.startsWith(':root') && text.includes('._')) {
|
|
102
|
+
return [getIdentifierFromTamaguiSelector(text), rule]
|
|
103
103
|
}
|
|
104
104
|
} else if (rule instanceof CSSMediaRule) {
|
|
105
105
|
// tamagui only ever inserts 1 rule per media
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export function proxyThemeVariables<A extends Object>(obj: A): A {
|
|
2
|
-
if (process.env.NODE_ENV === 'development'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
if (process.env.NODE_ENV === 'development') {
|
|
3
|
+
if (!obj || typeof obj !== 'object') {
|
|
4
|
+
// eslint-disable-next-line no-console
|
|
5
|
+
console.trace(`Empty value for proxyThemeVariables, broken config`, obj)
|
|
6
|
+
return obj
|
|
7
|
+
}
|
|
6
8
|
}
|
|
7
9
|
return new Proxy<A>(obj || {}, {
|
|
8
10
|
has(target, key) {
|
package/src/types.tsx
CHANGED
|
@@ -28,9 +28,8 @@ export type TamaguiElement = HTMLElement | View
|
|
|
28
28
|
|
|
29
29
|
export type DebugProp = boolean | 'break' | 'verbose'
|
|
30
30
|
|
|
31
|
-
//
|
|
32
31
|
// base props that are accepted by createComponent (additional to react-native-web)
|
|
33
|
-
|
|
32
|
+
|
|
34
33
|
export type TamaguiComponentPropsBase = {
|
|
35
34
|
hitSlop?: PressableProps['hitSlop']
|
|
36
35
|
asChild?: boolean
|
|
@@ -49,6 +48,9 @@ export type TamaguiComponentPropsBase = {
|
|
|
49
48
|
tag?: string
|
|
50
49
|
theme?: ThemeName | null
|
|
51
50
|
componentName?: string
|
|
51
|
+
/**
|
|
52
|
+
* Forces the pseudo style state to be on
|
|
53
|
+
*/
|
|
52
54
|
forceStyle?: 'hover' | 'press' | 'focus'
|
|
53
55
|
onHoverIn?: (e: MouseEvent) => any
|
|
54
56
|
onHoverOut?: (e: MouseEvent) => any
|
|
@@ -59,9 +61,6 @@ export type TamaguiComponentPropsBase = {
|
|
|
59
61
|
onMouseEnter?: (e: MouseEvent) => any
|
|
60
62
|
onMouseLeave?: (e: MouseEvent) => any
|
|
61
63
|
onMouseDown?: (e: MouseEvent) => any
|
|
62
|
-
// WEB STYLES
|
|
63
|
-
userSelect?: Properties['userSelect']
|
|
64
|
-
cursor?: Properties['cursor']
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
export type ReactComponentWithRef<Props, Ref> = React.ForwardRefExoticComponent<
|
|
@@ -116,7 +115,13 @@ type GenericThemes = {
|
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
type
|
|
118
|
+
type AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase
|
|
119
|
+
|
|
120
|
+
export type CreateShorthands = {
|
|
121
|
+
[key: string]: AllStyleKeys
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type GenericShorthands = {}
|
|
120
125
|
|
|
121
126
|
// sm: { minWidth: 100 }
|
|
122
127
|
type GenericMedia = {
|
|
@@ -256,14 +261,21 @@ type ArrayIntersection<A extends any[]> = A[keyof A]
|
|
|
256
261
|
|
|
257
262
|
type GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S
|
|
258
263
|
|
|
259
|
-
|
|
264
|
+
type SpacerPropsBase = {
|
|
260
265
|
size?: number | SpaceTokens | null
|
|
261
266
|
flex?: boolean | number
|
|
262
267
|
direction?: SpaceDirection
|
|
263
268
|
}
|
|
269
|
+
type SpacerOwnProps = SpacerPropsBase &
|
|
270
|
+
//
|
|
271
|
+
WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>
|
|
272
|
+
|
|
273
|
+
export type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &
|
|
274
|
+
//
|
|
275
|
+
SpacerOwnProps
|
|
264
276
|
|
|
265
277
|
export type CreateTamaguiProps = {
|
|
266
|
-
shorthands?:
|
|
278
|
+
shorthands?: CreateShorthands
|
|
267
279
|
media?: GenericTamaguiConfig['media']
|
|
268
280
|
animations?: AnimationDriver<any>
|
|
269
281
|
fonts: GenericTamaguiConfig['fonts']
|
|
@@ -574,46 +586,30 @@ type WithThemeShorthandsAndPseudos<A extends object> =
|
|
|
574
586
|
type WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &
|
|
575
587
|
MediaProps<WithThemeShorthandsAndPseudos<A>>
|
|
576
588
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
589
|
+
/**
|
|
590
|
+
* Base style-only props (no media, pseudo):
|
|
591
|
+
*/
|
|
580
592
|
|
|
581
|
-
type
|
|
593
|
+
type StylePropsWebOnly = {
|
|
594
|
+
// we make this a style prop as it is on web
|
|
595
|
+
pointerEvents?: ViewProps['pointerEvents']
|
|
582
596
|
// WEB ONLY
|
|
583
|
-
cursor?:
|
|
597
|
+
cursor?: Properties['cursor']
|
|
584
598
|
// WEB ONLY
|
|
585
|
-
contain?: '
|
|
599
|
+
contain?: Properties['contain']
|
|
586
600
|
// WEB ONLY values: inherit, inline, block, content
|
|
587
601
|
display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'
|
|
588
|
-
// WEB ONLY
|
|
589
|
-
|
|
602
|
+
// WEB ONLY
|
|
603
|
+
userSelect?: Properties['userSelect']
|
|
590
604
|
}
|
|
591
605
|
|
|
592
606
|
export type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &
|
|
593
607
|
TransformStyleProps &
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
export type StackPropsBaseShared = Omit<ViewProps, 'display' | 'children'> &
|
|
597
|
-
RNWViewProps &
|
|
598
|
-
TamaguiComponentPropsBase
|
|
599
|
-
|
|
600
|
-
export type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>
|
|
601
|
-
export type StackPropsBase = StackPropsBaseShared & WithThemeAndShorthands<StackStylePropsBase>
|
|
602
|
-
export type StackProps = StackPropsBaseShared & StackStyleProps
|
|
603
|
-
|
|
604
|
-
export type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (
|
|
605
|
-
event: infer Event
|
|
606
|
-
) => void
|
|
607
|
-
? Event
|
|
608
|
-
: never
|
|
609
|
-
|
|
610
|
-
//
|
|
611
|
-
// Text props
|
|
612
|
-
//
|
|
608
|
+
StylePropsWebOnly
|
|
613
609
|
|
|
614
610
|
export type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &
|
|
615
611
|
TransformStyleProps &
|
|
616
|
-
|
|
612
|
+
StylePropsWebOnly & {
|
|
617
613
|
ellipse?: boolean
|
|
618
614
|
selectable?: boolean
|
|
619
615
|
textDecorationDistance?: number
|
|
@@ -622,12 +618,29 @@ export type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility
|
|
|
622
618
|
wordWrap?: Properties['wordWrap']
|
|
623
619
|
}
|
|
624
620
|
|
|
625
|
-
|
|
621
|
+
//
|
|
622
|
+
// Stack
|
|
623
|
+
//
|
|
624
|
+
|
|
625
|
+
export type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &
|
|
626
|
+
RNWViewProps &
|
|
627
|
+
TamaguiComponentPropsBase
|
|
628
|
+
|
|
629
|
+
export type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>
|
|
630
|
+
export type StackPropsBase = StackNonStyleProps & WithThemeAndShorthands<StackStylePropsBase>
|
|
631
|
+
export type StackProps = StackNonStyleProps & StackStyleProps
|
|
632
|
+
|
|
633
|
+
//
|
|
634
|
+
// Text props
|
|
635
|
+
//
|
|
636
|
+
|
|
637
|
+
export type TextNonStyleProps = Omit<ReactTextProps, 'children'> &
|
|
626
638
|
RNWTextProps &
|
|
627
639
|
TamaguiComponentPropsBase
|
|
628
|
-
|
|
640
|
+
|
|
641
|
+
export type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>
|
|
629
642
|
export type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>
|
|
630
|
-
export type TextProps =
|
|
643
|
+
export type TextProps = TextNonStyleProps & TextStyleProps
|
|
631
644
|
|
|
632
645
|
// could actually infer from parent
|
|
633
646
|
export type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<
|
|
@@ -1305,3 +1318,9 @@ export type UseAnimationHook = (
|
|
|
1305
1318
|
) => null | {
|
|
1306
1319
|
style?: StackStylePropsBase | StackStylePropsBase[]
|
|
1307
1320
|
}
|
|
1321
|
+
|
|
1322
|
+
export type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (
|
|
1323
|
+
event: infer Event
|
|
1324
|
+
) => void
|
|
1325
|
+
? Event
|
|
1326
|
+
: never
|
package/src/views/Slot.tsx
CHANGED
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
4
4
|
import { isWeb } from '@tamagui/constants'
|
|
5
|
-
import
|
|
5
|
+
import { Children, ReactElement, ReactNode, cloneElement, forwardRef, isValidElement } from 'react'
|
|
6
6
|
|
|
7
7
|
/* -------------------------------------------------------------------------------------------------
|
|
8
8
|
* Slot
|
|
9
9
|
* -----------------------------------------------------------------------------------------------*/
|
|
10
10
|
|
|
11
11
|
export type SlotProps = {
|
|
12
|
-
children?:
|
|
12
|
+
children?: ReactNode
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const Slot =
|
|
15
|
+
export const Slot = forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {
|
|
16
16
|
const { children, ...slotProps } = props
|
|
17
|
-
const childrenArray =
|
|
17
|
+
const childrenArray = Children.toArray(children)
|
|
18
18
|
const slottable = childrenArray.find(isSlottable)
|
|
19
19
|
|
|
20
20
|
if (slottable) {
|
|
21
21
|
// the new element to render is the one passed as a child of `Slottable`
|
|
22
|
-
const newElement = slottable.props.children as
|
|
22
|
+
const newElement = slottable.props.children as ReactNode
|
|
23
23
|
|
|
24
24
|
const newChildren = childrenArray.map((child) => {
|
|
25
25
|
if (child === slottable) {
|
|
26
26
|
// because the new element will be the one rendered, we are only interested
|
|
27
27
|
// in grabbing its children (`newElement.props.children`)
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
? (newElement.props.children as React.ReactNode)
|
|
31
|
-
: null
|
|
28
|
+
if (Children.count(newElement) > 1) return Children.only(null)
|
|
29
|
+
return isValidElement(newElement) ? (newElement.props.children as ReactNode) : null
|
|
32
30
|
} else {
|
|
33
31
|
return child
|
|
34
32
|
}
|
|
@@ -36,9 +34,7 @@ export const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRe
|
|
|
36
34
|
|
|
37
35
|
return (
|
|
38
36
|
<SlotClone {...slotProps} ref={forwardedRef}>
|
|
39
|
-
{
|
|
40
|
-
? React.cloneElement(newElement, undefined, newChildren)
|
|
41
|
-
: null}
|
|
37
|
+
{isValidElement(newElement) ? cloneElement(newElement, undefined, newChildren) : null}
|
|
42
38
|
</SlotClone>
|
|
43
39
|
)
|
|
44
40
|
}
|
|
@@ -57,21 +53,21 @@ Slot.displayName = 'Slot'
|
|
|
57
53
|
* -----------------------------------------------------------------------------------------------*/
|
|
58
54
|
|
|
59
55
|
interface SlotCloneProps {
|
|
60
|
-
children:
|
|
56
|
+
children: ReactNode
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
const SlotClone =
|
|
59
|
+
const SlotClone = forwardRef<any, SlotCloneProps>((props, forwardedRef) => {
|
|
64
60
|
const { children, ...slotProps } = props
|
|
65
61
|
|
|
66
|
-
if (
|
|
62
|
+
if (isValidElement(children)) {
|
|
67
63
|
const childProps = {
|
|
68
64
|
...mergeSlotProps(children, slotProps),
|
|
69
65
|
ref: composeRefs(forwardedRef, (children as any).ref),
|
|
70
66
|
}
|
|
71
|
-
return
|
|
67
|
+
return cloneElement(children, childProps)
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
return
|
|
70
|
+
return Children.count(children) > 1 ? Children.only(null) : null
|
|
75
71
|
})
|
|
76
72
|
|
|
77
73
|
SlotClone.displayName = 'SlotClone'
|
|
@@ -80,7 +76,7 @@ SlotClone.displayName = 'SlotClone'
|
|
|
80
76
|
* Slottable
|
|
81
77
|
* -----------------------------------------------------------------------------------------------*/
|
|
82
78
|
|
|
83
|
-
export const Slottable = ({ children }: { children:
|
|
79
|
+
export const Slottable = ({ children }: { children: ReactNode }) => {
|
|
84
80
|
return <>{children}</>
|
|
85
81
|
}
|
|
86
82
|
|
|
@@ -88,8 +84,8 @@ export const Slottable = ({ children }: { children: React.ReactNode }) => {
|
|
|
88
84
|
|
|
89
85
|
type AnyProps = Record<string, any>
|
|
90
86
|
|
|
91
|
-
function isSlottable(child:
|
|
92
|
-
return
|
|
87
|
+
function isSlottable(child: ReactNode): child is ReactElement {
|
|
88
|
+
return isValidElement(child) && child.type === Slottable
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
const pressMap = isWeb
|
package/types/Tamagui.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class TamaguiManager {
|
|
|
7
7
|
[key: string]: Partial<import("./types").TamaguiBaseTheme> & {
|
|
8
8
|
[key: string]: import("./types").VariableVal;
|
|
9
9
|
};
|
|
10
|
-
},
|
|
10
|
+
}, import("./types").GenericShorthands, {
|
|
11
11
|
[key: string]: {
|
|
12
12
|
[key: string]: string | number;
|
|
13
13
|
};
|
package/types/config.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const getConfig: () => TamaguiInternalConfig<import("./types").Cr
|
|
|
6
6
|
[key: string]: Partial<import("./types").TamaguiBaseTheme> & {
|
|
7
7
|
[key: string]: import("./types").VariableVal;
|
|
8
8
|
};
|
|
9
|
-
},
|
|
9
|
+
}, import("./types").GenericShorthands, {
|
|
10
10
|
[key: string]: {
|
|
11
11
|
[key: string]: string | number;
|
|
12
12
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateShorthands } from './types';
|
|
2
|
+
export declare function createShorthands<A extends CreateShorthands>(shorthands: A): A;
|
|
2
3
|
//# sourceMappingURL=createShorthands.d.ts.map
|
|
@@ -9,11 +9,11 @@ export declare const defaultOffset: {
|
|
|
9
9
|
* 2. Normalizes various inconsistent styles to be more consistent
|
|
10
10
|
* 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight
|
|
11
11
|
*/
|
|
12
|
-
export declare function expandStyles(style: Record<string, any>, config?: import("
|
|
13
|
-
[key: string]: Partial<import("
|
|
14
|
-
[key: string]: import("
|
|
12
|
+
export declare function expandStyles(style: Record<string, any>, config?: import("../types").TamaguiInternalConfig<import("../types").CreateTokens<import("../types").VariableVal>, {
|
|
13
|
+
[key: string]: Partial<import("../types").TamaguiBaseTheme> & {
|
|
14
|
+
[key: string]: import("../types").VariableVal;
|
|
15
15
|
};
|
|
16
|
-
},
|
|
16
|
+
}, import("../types").GenericShorthands, {
|
|
17
17
|
[key: string]: {
|
|
18
18
|
[key: string]: string | number;
|
|
19
19
|
};
|
|
@@ -21,6 +21,6 @@ export declare function expandStyles(style: Record<string, any>, config?: import
|
|
|
21
21
|
[key: string]: string | any[] | {
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
|
-
}, import("
|
|
24
|
+
}, import("../types").GenericFonts>): Record<string, any>;
|
|
25
25
|
export declare function fixStyles(style: Record<string, any>): void;
|
|
26
26
|
//# sourceMappingURL=expandStyles.d.ts.map
|
package/types/types.d.ts
CHANGED
|
@@ -30,6 +30,9 @@ export declare type TamaguiComponentPropsBase = {
|
|
|
30
30
|
tag?: string;
|
|
31
31
|
theme?: ThemeName | null;
|
|
32
32
|
componentName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Forces the pseudo style state to be on
|
|
35
|
+
*/
|
|
33
36
|
forceStyle?: 'hover' | 'press' | 'focus';
|
|
34
37
|
onHoverIn?: (e: MouseEvent) => any;
|
|
35
38
|
onHoverOut?: (e: MouseEvent) => any;
|
|
@@ -39,8 +42,6 @@ export declare type TamaguiComponentPropsBase = {
|
|
|
39
42
|
onMouseEnter?: (e: MouseEvent) => any;
|
|
40
43
|
onMouseLeave?: (e: MouseEvent) => any;
|
|
41
44
|
onMouseDown?: (e: MouseEvent) => any;
|
|
42
|
-
userSelect?: Properties['userSelect'];
|
|
43
|
-
cursor?: Properties['cursor'];
|
|
44
45
|
};
|
|
45
46
|
export declare type ReactComponentWithRef<Props, Ref> = React.ForwardRefExoticComponent<Props & React.RefAttributes<Ref>>;
|
|
46
47
|
export declare type ConfigListener = (conf: TamaguiInternalConfig) => void;
|
|
@@ -88,7 +89,11 @@ declare type GenericThemes = {
|
|
|
88
89
|
[key: string]: VariableVal;
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
|
-
declare type
|
|
92
|
+
declare type AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase;
|
|
93
|
+
export declare type CreateShorthands = {
|
|
94
|
+
[key: string]: AllStyleKeys;
|
|
95
|
+
};
|
|
96
|
+
export declare type GenericShorthands = {};
|
|
92
97
|
declare type GenericMedia = {
|
|
93
98
|
[key: string]: {
|
|
94
99
|
[key: string]: number | string;
|
|
@@ -148,13 +153,15 @@ export declare type AnimationKeys = TamaguiConfig['animations'] extends Animatio
|
|
|
148
153
|
export declare type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>;
|
|
149
154
|
declare type ArrayIntersection<A extends any[]> = A[keyof A];
|
|
150
155
|
declare type GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S;
|
|
151
|
-
|
|
156
|
+
declare type SpacerPropsBase = {
|
|
152
157
|
size?: number | SpaceTokens | null;
|
|
153
158
|
flex?: boolean | number;
|
|
154
159
|
direction?: SpaceDirection;
|
|
155
160
|
};
|
|
161
|
+
declare type SpacerOwnProps = SpacerPropsBase & WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>;
|
|
162
|
+
export declare type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> & SpacerOwnProps;
|
|
156
163
|
export declare type CreateTamaguiProps = {
|
|
157
|
-
shorthands?:
|
|
164
|
+
shorthands?: CreateShorthands;
|
|
158
165
|
media?: GenericTamaguiConfig['media'];
|
|
159
166
|
animations?: AnimationDriver<any>;
|
|
160
167
|
fonts: GenericTamaguiConfig['fonts'];
|
|
@@ -333,19 +340,18 @@ export declare type PseudoStyles = {
|
|
|
333
340
|
declare type WithThemeAndShorthands<A extends object> = WithThemeValues<A> & WithShorthands<WithThemeValues<A>>;
|
|
334
341
|
declare type WithThemeShorthandsAndPseudos<A extends object> = WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>;
|
|
335
342
|
declare type WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> & MediaProps<WithThemeShorthandsAndPseudos<A>>;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Base style-only props (no media, pseudo):
|
|
345
|
+
*/
|
|
346
|
+
declare type StylePropsWebOnly = {
|
|
340
347
|
pointerEvents?: ViewProps['pointerEvents'];
|
|
348
|
+
cursor?: Properties['cursor'];
|
|
349
|
+
contain?: Properties['contain'];
|
|
350
|
+
display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex';
|
|
351
|
+
userSelect?: Properties['userSelect'];
|
|
341
352
|
};
|
|
342
|
-
export declare type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> & TransformStyleProps &
|
|
343
|
-
export declare type
|
|
344
|
-
export declare type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>;
|
|
345
|
-
export declare type StackPropsBase = StackPropsBaseShared & WithThemeAndShorthands<StackStylePropsBase>;
|
|
346
|
-
export declare type StackProps = StackPropsBaseShared & StackStyleProps;
|
|
347
|
-
export declare type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (event: infer Event) => void ? Event : never;
|
|
348
|
-
export declare type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps & WebOnlyStyleProps & {
|
|
353
|
+
export declare type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> & TransformStyleProps & StylePropsWebOnly;
|
|
354
|
+
export declare type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> & TransformStyleProps & StylePropsWebOnly & {
|
|
349
355
|
ellipse?: boolean;
|
|
350
356
|
selectable?: boolean;
|
|
351
357
|
textDecorationDistance?: number;
|
|
@@ -353,10 +359,14 @@ export declare type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVi
|
|
|
353
359
|
whiteSpace?: Properties['whiteSpace'];
|
|
354
360
|
wordWrap?: Properties['wordWrap'];
|
|
355
361
|
};
|
|
356
|
-
export declare type
|
|
357
|
-
export declare type
|
|
362
|
+
export declare type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> & RNWViewProps & TamaguiComponentPropsBase;
|
|
363
|
+
export declare type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>;
|
|
364
|
+
export declare type StackPropsBase = StackNonStyleProps & WithThemeAndShorthands<StackStylePropsBase>;
|
|
365
|
+
export declare type StackProps = StackNonStyleProps & StackStyleProps;
|
|
366
|
+
export declare type TextNonStyleProps = Omit<ReactTextProps, 'children'> & RNWTextProps & TamaguiComponentPropsBase;
|
|
367
|
+
export declare type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>;
|
|
358
368
|
export declare type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>;
|
|
359
|
-
export declare type TextProps =
|
|
369
|
+
export declare type TextProps = TextNonStyleProps & TextStyleProps;
|
|
360
370
|
export declare type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase>;
|
|
361
371
|
export declare type TamaguiComponent<Props = any, Ref = any, BaseProps = {}, VariantProps = {}> = ReactComponentWithRef<Props, Ref> & StaticComponentObject;
|
|
362
372
|
declare type StaticComponentObject = {
|
|
@@ -617,5 +627,6 @@ export declare type UseAnimationHelpers = {
|
|
|
617
627
|
export declare type UseAnimationHook = (props: UseAnimationProps, helpers: UseAnimationHelpers) => null | {
|
|
618
628
|
style?: StackStylePropsBase | StackStylePropsBase[];
|
|
619
629
|
};
|
|
630
|
+
export declare type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (event: infer Event) => void ? Event : never;
|
|
620
631
|
export {};
|
|
621
632
|
//# sourceMappingURL=types.d.ts.map
|
package/types/views/Slot.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export declare type SlotProps = {
|
|
3
|
-
children?:
|
|
3
|
+
children?: ReactNode;
|
|
4
4
|
};
|
|
5
|
-
export declare const Slot:
|
|
5
|
+
export declare const Slot: import("react").ForwardRefExoticComponent<SlotProps & import("react").RefAttributes<HTMLElement>>;
|
|
6
6
|
export declare const Slottable: ({ children }: {
|
|
7
|
-
children:
|
|
7
|
+
children: ReactNode;
|
|
8
8
|
}) => JSX.Element;
|
|
9
9
|
export declare function mergeEvent(a?: Function, b?: Function): (...args: unknown[]) => void;
|
|
10
10
|
//# sourceMappingURL=Slot.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect } from 'react'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
|
-
|
|
4
|
-
export const isAndroid = Platform?.OS === 'android'
|
|
5
|
-
export const isIOS = Platform?.OS === 'ios'
|
|
6
|
-
export const isWeb = false
|
|
7
|
-
export const isWindowDefined = false
|
|
8
|
-
export const isServer = false
|
|
9
|
-
export const isClient = false
|
|
10
|
-
export const isRSC = false
|
|
11
|
-
export const useIsomorphicLayoutEffect = useLayoutEffect
|
|
12
|
-
export const isChrome = false
|
|
13
|
-
export const isWebTouchable = false
|
|
14
|
-
export const isTouchable = true
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect } from 'react'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
|
-
|
|
4
|
-
export const isAndroid = Platform?.OS === 'android'
|
|
5
|
-
export const isIOS = Platform?.OS === 'ios'
|
|
6
|
-
export const isWeb = process.env.TAMAGUI_TARGET === 'web'
|
|
7
|
-
export const isWindowDefined = typeof window !== 'undefined'
|
|
8
|
-
export const isServer = isWeb && !isWindowDefined
|
|
9
|
-
export const isClient = isWeb && isWindowDefined
|
|
10
|
-
|
|
11
|
-
// may want to move to VITE_RSC_BUILD
|
|
12
|
-
export const isRSC = process.env.ENABLE_RSC
|
|
13
|
-
? // note this is statically analyzed so no funny business, just access it without optional chaining
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
import.meta.env
|
|
16
|
-
? // @ts-ignore
|
|
17
|
-
import.meta.env.SSR
|
|
18
|
-
: false
|
|
19
|
-
: false
|
|
20
|
-
|
|
21
|
-
const idFn = () => {}
|
|
22
|
-
export const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect
|
|
23
|
-
export const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')
|
|
24
|
-
export const isWebTouchable = isClient && 'ontouchstart' in window
|
|
25
|
-
export const isTouchable = !isWeb || isWebTouchable
|
|
26
|
-
|
|
27
|
-
if (process.env.NODE_ENV === 'development') {
|
|
28
|
-
if (!process.env.TAMAGUI_TARGET) {
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.warn(`Must set TAMAGUI_TARGET to "web" or "native"`)
|
|
31
|
-
} else if (
|
|
32
|
-
isClient &&
|
|
33
|
-
process.env.TAMAGUI_TARGET !== 'web' &&
|
|
34
|
-
process.env.TAMAGUI_IGNORE_TARGET !== '1'
|
|
35
|
-
) {
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
console.warn(
|
|
38
|
-
`Must set TAMAGUI_TARGET to "web" for web apps - if you have window defined outside of the browser, set TAMAGUI_IGNORE_TARGET=1 to hide this`
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
}
|