@codeleap/mobile 3.24.3 → 4.0.0
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/package.json +6 -4
- package/src/Registry.ts +52 -0
- package/src/components/ActionIcon/index.tsx +55 -37
- package/src/components/ActionIcon/styles.ts +2 -4
- package/src/components/ActionIcon/types.ts +15 -0
- package/src/components/ActivityIndicator/index.tsx +42 -64
- package/src/components/ActivityIndicator/styles.ts +1 -10
- package/src/components/ActivityIndicator/types.ts +9 -0
- package/src/components/Autocomplete/index.tsx +46 -54
- package/src/components/Autocomplete/styles.ts +2 -5
- package/src/components/Autocomplete/types.ts +13 -23
- package/src/components/Avatar/index.tsx +59 -71
- package/src/components/Avatar/styles.ts +1 -9
- package/src/components/Avatar/types.ts +23 -0
- package/src/components/AvatarGroup/index.tsx +30 -44
- package/src/components/AvatarGroup/styles.ts +0 -6
- package/src/components/AvatarGroup/types.ts +10 -0
- package/src/components/Backdrop/index.tsx +51 -34
- package/src/components/Backdrop/styles.ts +5 -10
- package/src/components/Backdrop/types.ts +14 -0
- package/src/components/Badge/index.tsx +36 -62
- package/src/components/Badge/styles.ts +3 -11
- package/src/components/Badge/types.ts +27 -0
- package/src/components/Button/index.tsx +55 -82
- package/src/components/Button/styles.ts +13 -14
- package/src/components/Button/types.ts +20 -0
- package/src/components/Calendar/index.tsx +35 -29
- package/src/components/Checkbox/index.tsx +43 -64
- package/src/components/Checkbox/styles.ts +1 -6
- package/src/components/Checkbox/types.ts +13 -0
- package/src/components/DatePickerModal/index.tsx +50 -65
- package/src/components/DatePickerModal/styles.ts +9 -10
- package/src/components/DatePickerModal/types.ts +36 -54
- package/src/components/EmptyPlaceholder/index.tsx +40 -63
- package/src/components/EmptyPlaceholder/styles.ts +0 -5
- package/src/components/EmptyPlaceholder/types.ts +21 -0
- package/src/components/FileInput/index.tsx +11 -49
- package/src/components/FileInput/types.ts +27 -0
- package/src/components/Grid/index.tsx +84 -116
- package/src/components/Grid/styles.ts +0 -5
- package/src/components/Grid/types.ts +20 -0
- package/src/components/Icon/index.tsx +44 -79
- package/src/components/Icon/styles.ts +0 -6
- package/src/components/Icon/types.ts +15 -0
- package/src/components/Image/index.tsx +58 -78
- package/src/components/Image/styles.ts +1 -6
- package/src/components/Image/types.ts +18 -0
- package/src/components/ImageView/Spotlight.tsx +1 -4
- package/src/components/ImageView/component.tsx +1 -2
- package/src/components/InputBase/index.tsx +33 -24
- package/src/components/InputBase/styles.ts +66 -75
- package/src/components/InputBase/types.ts +3 -4
- package/src/components/InputBase/utils.ts +6 -4
- package/src/components/List/index.tsx +99 -151
- package/src/components/List/styles.ts +0 -6
- package/src/components/List/types.ts +41 -0
- package/src/components/LoadingOverlay/index.tsx +42 -29
- package/src/components/LoadingOverlay/styles.ts +7 -7
- package/src/components/LoadingOverlay/types.ts +9 -0
- package/src/components/Modal/index.tsx +80 -127
- package/src/components/Modal/styles.ts +0 -8
- package/src/components/Modal/types.ts +41 -0
- package/src/components/Navigation/Navigation.tsx +1 -0
- package/src/components/Navigation/types.ts +2 -9
- package/src/components/NumberIncrement/index.tsx +50 -60
- package/src/components/NumberIncrement/styles.ts +0 -5
- package/src/components/NumberIncrement/types.ts +32 -39
- package/src/components/Pager/index.tsx +42 -94
- package/src/components/Pager/styles.ts +1 -13
- package/src/components/Pager/types.ts +37 -0
- package/src/components/PaginationIndicator/index.tsx +51 -0
- package/src/components/PaginationIndicator/styles.ts +3 -0
- package/src/components/PaginationIndicator/types.ts +10 -0
- package/src/components/RadioInput/index.tsx +32 -57
- package/src/components/RadioInput/styles.ts +5 -7
- package/src/components/RadioInput/types.ts +31 -0
- package/src/components/RefreshControl/index.tsx +39 -19
- package/src/components/RefreshControl/styles.ts +1 -6
- package/src/components/RefreshControl/types.ts +9 -0
- package/src/components/Scroll/index.tsx +89 -105
- package/src/components/Scroll/styles.ts +0 -5
- package/src/components/Scroll/types.ts +21 -0
- package/src/components/SearchInput/index.tsx +90 -0
- package/src/components/Sections/index.tsx +111 -161
- package/src/components/Sections/styles.ts +0 -5
- package/src/components/Sections/types.ts +39 -0
- package/src/components/SegmentedControl/Option.tsx +46 -31
- package/src/components/SegmentedControl/index.tsx +86 -121
- package/src/components/SegmentedControl/styles.ts +15 -22
- package/src/components/SegmentedControl/types.ts +31 -0
- package/src/components/Select/index.tsx +71 -82
- package/src/components/Select/styles.ts +3 -5
- package/src/components/Select/types.ts +20 -25
- package/src/components/Slider/index.tsx +58 -43
- package/src/components/Slider/styles.ts +15 -6
- package/src/components/Slider/types.ts +9 -14
- package/src/components/Switch/index.tsx +43 -56
- package/src/components/Switch/styles.ts +1 -7
- package/src/components/Switch/types.ts +12 -0
- package/src/components/Text/index.tsx +56 -52
- package/src/components/Text/styles.ts +1 -7
- package/src/components/Text/types.ts +18 -0
- package/src/components/TextInput/index.tsx +49 -162
- package/src/components/TextInput/styles.ts +2 -8
- package/src/components/TextInput/types.ts +23 -0
- package/src/components/Touchable/index.tsx +44 -87
- package/src/components/Touchable/styles.ts +0 -9
- package/src/components/Touchable/types.ts +27 -0
- package/src/components/View/index.tsx +23 -92
- package/src/components/View/styles.ts +0 -6
- package/src/components/View/types.ts +13 -0
- package/src/components/components.ts +2 -6
- package/src/hooks/index.ts +13 -0
- package/src/index.ts +2 -0
- package/src/modules/PressableRipple/type.ts +1 -0
- package/src/utils/KeyboardAware/context.tsx +0 -2
- package/src/utils/KeyboardAware/keyboardHooks.ts +1 -2
- package/src/utils/ModalManager/components.tsx +1 -30
- package/src/utils/ModalManager/context.tsx +4 -4
- package/src/utils/ModalManager/index.ts +1 -4
- package/src/utils/hooks.ts +12 -1
- package/src/components/Calendar/style.ts +0 -6
- package/src/components/ContentView/index.tsx +0 -63
- package/src/components/ContentView/styles.ts +0 -8
- package/src/components/Drawer/index.tsx +0 -28
- package/src/components/Drawer/styles.ts +0 -8
- package/src/components/FileInput/styles.ts +0 -8
- package/src/components/InputLabel/index.tsx +0 -38
- package/src/components/InputLabel/styles.ts +0 -7
- package/src/components/List/PaginationIndicator.tsx +0 -54
- package/src/components/defaultStyles.ts +0 -77
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
SliderComposition,
|
|
5
|
-
} from './styles'
|
|
6
|
-
|
|
1
|
+
import { SliderComposition } from './styles'
|
|
7
2
|
import { SliderProps as RNSliderProps } from '@miblanchard/react-native-slider/lib/types'
|
|
8
|
-
import { StylesOf } from '../../types'
|
|
9
|
-
import { View } from '../View'
|
|
10
3
|
import { InputBaseProps } from '../InputBase'
|
|
4
|
+
import { StyledProp } from '@codeleap/styles'
|
|
11
5
|
|
|
12
|
-
export type SliderProps =
|
|
6
|
+
export type SliderProps =
|
|
7
|
+
Partial<Omit<RNSliderProps, 'value' | 'onValueChange' | 'style'>> &
|
|
8
|
+
Pick<InputBaseProps, 'disabled' | 'debugName' | 'description' | 'label'> &
|
|
9
|
+
{
|
|
13
10
|
debounce?: number | null
|
|
14
11
|
trackMarklabels: string[]
|
|
15
12
|
value: number | number[]
|
|
16
|
-
onValueChange: (val: number| number[]) => void
|
|
17
|
-
variants?: ComponentVariants<typeof SliderStyles>['variants']
|
|
18
|
-
styles?: StylesOf<SliderComposition>
|
|
19
|
-
style?: PropsOf<typeof View>['style']
|
|
13
|
+
onValueChange: (val: number | number[]) => void
|
|
20
14
|
trackMarks?: RNSliderProps['trackMarks'] | Record<number, string>
|
|
21
15
|
trackMarksClickable?: boolean
|
|
22
16
|
labelClickable?: boolean
|
|
23
17
|
trackMarkComponent?: React.ComponentType<TrackMarkProps>
|
|
24
|
-
|
|
18
|
+
style?: StyledProp<SliderComposition>
|
|
19
|
+
}
|
|
25
20
|
|
|
26
21
|
export type TrackMarkProps = {
|
|
27
22
|
index: number
|
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ComponentVariants,
|
|
5
|
-
useDefaultComponentStyle,
|
|
6
|
-
StylesOf,
|
|
7
|
-
PropsOf,
|
|
8
|
-
} from '@codeleap/common'
|
|
9
|
-
import { StyleSheet } from 'react-native'
|
|
1
|
+
import React from 'react'
|
|
10
2
|
import { View } from '../View'
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
SwitchPresets,
|
|
14
|
-
SwitchComposition,
|
|
15
|
-
} from './styles'
|
|
16
|
-
import { InputBase, InputBaseDefaultOrder, InputBaseProps, selectInputBaseProps } from '../InputBase'
|
|
3
|
+
import { InputBase, InputBaseDefaultOrder, selectInputBaseProps } from '../InputBase'
|
|
17
4
|
import { useAnimatedVariantStyles } from '../..'
|
|
18
5
|
import { Touchable } from '../Touchable'
|
|
6
|
+
import { SwitchProps } from './types'
|
|
7
|
+
import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
|
|
8
|
+
import { MobileStyleRegistry } from '../../Registry'
|
|
9
|
+
import { useStylesFor } from '../../hooks'
|
|
19
10
|
|
|
20
11
|
export * from './styles'
|
|
21
|
-
|
|
22
|
-
export type SwitchProps = Pick<
|
|
23
|
-
InputBaseProps,
|
|
24
|
-
'debugName' | 'disabled' | 'label'
|
|
25
|
-
> & {
|
|
26
|
-
variants?: ComponentVariants<typeof SwitchPresets>['variants']
|
|
27
|
-
styles?: StylesOf<SwitchComposition>
|
|
28
|
-
value: boolean
|
|
29
|
-
onValueChange: (value: boolean) => void
|
|
30
|
-
style?: PropsOf<typeof View>['style']
|
|
31
|
-
switchOnLeft?: boolean
|
|
32
|
-
}
|
|
12
|
+
export * from './types'
|
|
33
13
|
|
|
34
14
|
const reversedOrder = [...InputBaseDefaultOrder].reverse()
|
|
35
15
|
|
|
@@ -37,11 +17,13 @@ export const Switch = (props: SwitchProps) => {
|
|
|
37
17
|
const {
|
|
38
18
|
inputBaseProps,
|
|
39
19
|
others,
|
|
40
|
-
} = selectInputBaseProps(
|
|
20
|
+
} = selectInputBaseProps({
|
|
21
|
+
...Switch.defaultProps,
|
|
22
|
+
...props,
|
|
23
|
+
})
|
|
24
|
+
|
|
41
25
|
const {
|
|
42
|
-
|
|
43
|
-
style = {},
|
|
44
|
-
styles = {},
|
|
26
|
+
style,
|
|
45
27
|
value,
|
|
46
28
|
disabled,
|
|
47
29
|
debugName,
|
|
@@ -49,45 +31,39 @@ export const Switch = (props: SwitchProps) => {
|
|
|
49
31
|
switchOnLeft,
|
|
50
32
|
} = others
|
|
51
33
|
|
|
52
|
-
const
|
|
53
|
-
variants,
|
|
54
|
-
styles,
|
|
55
|
-
rootElement: 'wrapper',
|
|
56
|
-
transform: StyleSheet.flatten,
|
|
57
|
-
})
|
|
34
|
+
const styles = useStylesFor(Switch.styleRegistryName, style)
|
|
58
35
|
|
|
59
36
|
const trackAnimation = useAnimatedVariantStyles({
|
|
60
|
-
variantStyles,
|
|
37
|
+
variantStyles: styles,
|
|
61
38
|
animatedProperties: ['track:off', 'track:disabled', 'track:on', 'track:disabled-on', 'track:disabled-off'],
|
|
62
|
-
transition:
|
|
39
|
+
transition: styles['track:transition'],
|
|
63
40
|
updater: () => {
|
|
64
41
|
'worklet'
|
|
65
42
|
let disabledStyle = {}
|
|
66
43
|
if (disabled) {
|
|
67
|
-
disabledStyle = value ?
|
|
44
|
+
disabledStyle = value ? styles['track:disabled-on'] : styles['track:disabled-off']
|
|
68
45
|
}
|
|
69
|
-
const style = value ?
|
|
46
|
+
const style = value ? styles['track:on'] : styles['track:off']
|
|
70
47
|
|
|
71
48
|
return {
|
|
72
49
|
...style,
|
|
73
50
|
...disabledStyle,
|
|
74
51
|
}
|
|
75
|
-
|
|
76
52
|
},
|
|
77
53
|
dependencies: [value, disabled],
|
|
78
54
|
})
|
|
79
55
|
|
|
80
56
|
const thumbAnimation = useAnimatedVariantStyles({
|
|
81
|
-
variantStyles,
|
|
57
|
+
variantStyles: styles,
|
|
82
58
|
animatedProperties: ['thumb:off', 'thumb:disabled', 'thumb:on', 'thumb:disabled-off', 'thumb:disabled-on'],
|
|
83
|
-
transition:
|
|
59
|
+
transition: styles['thumb:transition'],
|
|
84
60
|
updater: () => {
|
|
85
61
|
'worklet'
|
|
86
62
|
let disabledStyle = {}
|
|
87
63
|
if (disabled) {
|
|
88
|
-
disabledStyle = value ?
|
|
64
|
+
disabledStyle = value ? styles['thumb:disabled-on'] : styles['thumb:disabled-off']
|
|
89
65
|
}
|
|
90
|
-
const style = value ?
|
|
66
|
+
const style = value ? styles['thumb:on'] : styles['thumb:off']
|
|
91
67
|
return {
|
|
92
68
|
...style,
|
|
93
69
|
...disabledStyle,
|
|
@@ -97,13 +73,14 @@ export const Switch = (props: SwitchProps) => {
|
|
|
97
73
|
dependencies: [value, disabled],
|
|
98
74
|
})
|
|
99
75
|
|
|
100
|
-
|
|
76
|
+
// @ts-expect-error
|
|
77
|
+
const _switchOnLeft = switchOnLeft ?? styles?.__props?.switchOnLeft
|
|
101
78
|
|
|
102
79
|
return <InputBase
|
|
103
80
|
{...inputBaseProps}
|
|
104
81
|
debugName={debugName}
|
|
105
82
|
wrapper={Touchable}
|
|
106
|
-
|
|
83
|
+
style={styles}
|
|
107
84
|
wrapperProps={{
|
|
108
85
|
onPress: () => {
|
|
109
86
|
onValueChange(!value)
|
|
@@ -112,26 +89,36 @@ export const Switch = (props: SwitchProps) => {
|
|
|
112
89
|
rippleDisabled: true,
|
|
113
90
|
}}
|
|
114
91
|
order={_switchOnLeft ? reversedOrder : InputBaseDefaultOrder}
|
|
115
|
-
style={style}
|
|
116
92
|
disabled={disabled}
|
|
117
|
-
|
|
118
93
|
>
|
|
119
94
|
<View
|
|
120
95
|
animated
|
|
96
|
+
animatedStyle={trackAnimation}
|
|
121
97
|
style={[
|
|
122
|
-
|
|
123
|
-
disabled &&
|
|
124
|
-
trackAnimation,
|
|
98
|
+
styles?.track,
|
|
99
|
+
disabled && styles['track:disabled'],
|
|
125
100
|
]}
|
|
126
101
|
>
|
|
127
102
|
<View
|
|
128
103
|
animated
|
|
104
|
+
animatedStyle={thumbAnimation}
|
|
129
105
|
style={[
|
|
130
|
-
|
|
131
|
-
disabled &&
|
|
132
|
-
thumbAnimation,
|
|
106
|
+
styles?.thumb,
|
|
107
|
+
disabled && styles['thumb:disabled'],
|
|
133
108
|
]}
|
|
134
109
|
/>
|
|
135
110
|
</View>
|
|
136
111
|
</InputBase>
|
|
137
112
|
}
|
|
113
|
+
|
|
114
|
+
Switch.styleRegistryName = 'Switch'
|
|
115
|
+
Switch.elements = [...InputBase.elements, 'track', 'thumb']
|
|
116
|
+
Switch.rootElement = 'wrapper'
|
|
117
|
+
|
|
118
|
+
Switch.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
119
|
+
return Switch as (props: StyledComponentProps<SwitchProps, typeof styles>) => IJSX
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Switch.defaultProps = {} as Partial<SwitchProps>
|
|
123
|
+
|
|
124
|
+
MobileStyleRegistry.registerComponent(Switch)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
1
|
import { InputBaseParts, InputBaseStates } from '../InputBase'
|
|
3
2
|
|
|
4
3
|
type AnimatableParts = 'track' | 'thumb'
|
|
5
|
-
export type SwitchParts = InputBaseParts | AnimatableParts
|
|
4
|
+
export type SwitchParts = InputBaseParts | AnimatableParts
|
|
6
5
|
|
|
7
6
|
export type SwitchAnimationStates = 'on' | 'off' | 'disabled-on' | 'disabled-off'
|
|
8
7
|
|
|
@@ -14,8 +13,3 @@ export type SwitchComposition =
|
|
|
14
13
|
| `${AnimatableParts}:transition`
|
|
15
14
|
| `${AnimatableParts}:${SwitchAnimationStates}`
|
|
16
15
|
| '__props'
|
|
17
|
-
|
|
18
|
-
const createSwitchStyle = createDefaultVariantFactory<SwitchComposition>()
|
|
19
|
-
|
|
20
|
-
export const SwitchPresets = includePresets((styles) => createSwitchStyle(() => ({ wrapper: styles })))
|
|
21
|
-
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyledProp } from '@codeleap/styles'
|
|
2
|
+
import { InputBaseProps } from '../InputBase'
|
|
3
|
+
import { SwitchComposition } from './styles'
|
|
4
|
+
|
|
5
|
+
export type SwitchProps =
|
|
6
|
+
Omit<InputBaseProps, 'style'> &
|
|
7
|
+
{
|
|
8
|
+
value: boolean
|
|
9
|
+
onValueChange: (value: boolean) => void
|
|
10
|
+
style?: StyledProp<SwitchComposition>
|
|
11
|
+
switchOnLeft?: boolean
|
|
12
|
+
}
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '@codeleap/common'
|
|
10
|
-
import { Animated, Platform, StyleSheet, Text as NativeText, TextProps as RNTextProps } from 'react-native'
|
|
11
|
-
import { usePressableFeedback } from '../../utils'
|
|
12
|
-
import { TextPresets } from './styles'
|
|
13
|
-
import { ComponentWithDefaultProps } from '../../types'
|
|
1
|
+
import React, { forwardRef, useState } from 'react'
|
|
2
|
+
import { TypeGuards } from '@codeleap/common'
|
|
3
|
+
import { Animated, Platform, Text as NativeText } from 'react-native'
|
|
4
|
+
import { TouchableFeedbackConfig, usePressableFeedback } from '../../utils'
|
|
5
|
+
import { TextProps } from './types'
|
|
6
|
+
import { AnyRecord, IJSX, StyledComponentProps, StyledComponentWithProps } from '@codeleap/styles'
|
|
7
|
+
import { MobileStyleRegistry } from '../../Registry'
|
|
8
|
+
import { useStylesFor } from '../../hooks'
|
|
14
9
|
|
|
15
10
|
export * from './styles'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
export * from './types'
|
|
12
|
+
|
|
13
|
+
export const Text = forwardRef<NativeText, TextProps>((textProps, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
text,
|
|
16
|
+
children,
|
|
17
|
+
onPress,
|
|
18
|
+
style,
|
|
19
|
+
debounce,
|
|
20
|
+
pressDisabled,
|
|
21
|
+
animated,
|
|
22
|
+
animatedStyle,
|
|
23
|
+
...props
|
|
24
|
+
} = {
|
|
29
25
|
...Text.defaultProps,
|
|
30
26
|
...textProps,
|
|
31
27
|
}
|
|
@@ -38,7 +34,7 @@ const _Text = forwardRef<NativeText, TextProps>((textProps, ref) => {
|
|
|
38
34
|
const [pressed, setPressed] = useState(false)
|
|
39
35
|
const pressedRef = React.useRef(false)
|
|
40
36
|
|
|
41
|
-
const _onPress:TextProps['onPress'] = (e) => {
|
|
37
|
+
const _onPress: TextProps['onPress'] = (e) => {
|
|
42
38
|
if (!onPress) return
|
|
43
39
|
|
|
44
40
|
if (TypeGuards.isNumber(debounce)) {
|
|
@@ -65,48 +61,56 @@ const _Text = forwardRef<NativeText, TextProps>((textProps, ref) => {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
const variantStyles = useDefaultComponentStyle<'u:Text', typeof TextPresets>('u:Text', {
|
|
69
|
-
variants,
|
|
70
|
-
transform: StyleSheet.flatten,
|
|
71
|
-
rootElement: 'text',
|
|
72
|
-
})
|
|
73
64
|
|
|
74
|
-
const styles =
|
|
65
|
+
const styles = useStylesFor(Text.styleRegistryName, style)
|
|
75
66
|
|
|
76
67
|
if (!!text && !TypeGuards.isString(text)) return <>{text}</>
|
|
77
68
|
|
|
78
|
-
const Component =
|
|
69
|
+
const Component = animated ? Animated.Text : NativeText
|
|
79
70
|
|
|
80
71
|
const { getFeedbackStyle } = usePressableFeedback(styles, {
|
|
81
72
|
disabled: !pressPolyfillEnabled,
|
|
82
|
-
feedbackConfig:
|
|
73
|
+
feedbackConfig: styles?.pressFeedback as TouchableFeedbackConfig,
|
|
83
74
|
hightlightPropertyIn: 'color',
|
|
84
75
|
hightlightPropertyOut: 'backgroundColor',
|
|
85
76
|
})
|
|
77
|
+
|
|
86
78
|
const feedbackStyle = pressPolyfillEnabled ? getFeedbackStyle(pressed) : undefined
|
|
87
79
|
|
|
88
80
|
const pressProps = !!onPress ? {
|
|
89
81
|
onPress: pressDisabled ? null : _onPress,
|
|
90
82
|
} : {}
|
|
91
83
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
const disabled = !!onPress && pressDisabled
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Component
|
|
88
|
+
{...props}
|
|
89
|
+
onPressIn={handlePress(true)} onPressOut={handlePress(false)}
|
|
90
|
+
style={[styles?.text, animatedStyle, feedbackStyle, disabled ? styles['text:disabled'] : null]}
|
|
91
|
+
allowFontScaling={false}
|
|
92
|
+
{...pressProps}
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
ref={ref}
|
|
95
|
+
>
|
|
96
|
+
{text}
|
|
97
|
+
{children}
|
|
98
|
+
</Component>
|
|
99
|
+
)
|
|
100
|
+
}) as StyledComponentWithProps<TextProps>
|
|
101
|
+
|
|
102
|
+
Text.styleRegistryName = 'Text'
|
|
103
|
+
Text.elements = ['text', 'pressFeedback']
|
|
104
|
+
Text.rootElement = 'text'
|
|
105
|
+
|
|
106
|
+
Text.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
107
|
+
return Text as (props: StyledComponentProps<TextProps & { ref?: React.MutableRefObject<NativeText> }, typeof styles>) => IJSX
|
|
108
|
+
}
|
|
107
109
|
|
|
108
110
|
Text.defaultProps = {
|
|
109
|
-
|
|
111
|
+
debounce: 1000,
|
|
112
|
+
} as Partial<TextProps>
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
MobileStyleRegistry.registerComponent(Text)
|
|
112
115
|
|
|
116
|
+
export const AnimatedText = Animated.createAnimatedComponent(Text)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StylesOf } from '@codeleap/common'
|
|
2
2
|
import { FeedbackConfig } from '../../utils'
|
|
3
3
|
|
|
4
4
|
export type TextComposition = 'text' | 'pressFeedback' | 'text:disabled'
|
|
@@ -6,9 +6,3 @@ export type TextComposition = 'text' | 'pressFeedback' | 'text:disabled'
|
|
|
6
6
|
export type TextStylesGen<TCSS = any> = StylesOf<'text', TCSS> & {
|
|
7
7
|
'pressFeedback'?: FeedbackConfig
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
const createTextStyle = createDefaultVariantFactory<
|
|
11
|
-
TextComposition, TextStylesGen
|
|
12
|
-
>()
|
|
13
|
-
|
|
14
|
-
export const TextPresets = includePresets((styles) => createTextStyle(() => ({ text: styles })))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StyledProp } from '@codeleap/styles'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { TextProps as RNTextProps, Animated, ViewStyle, ImageStyle, TextStyle } from 'react-native'
|
|
4
|
+
import { AnimatedStyleProp } from 'react-native-reanimated'
|
|
5
|
+
import { TextComposition } from './styles'
|
|
6
|
+
|
|
7
|
+
export type TextProps =
|
|
8
|
+
Omit<RNTextProps, 'style'> &
|
|
9
|
+
{
|
|
10
|
+
text?: ReactNode
|
|
11
|
+
animated?: boolean
|
|
12
|
+
colorChangeConfig?: Partial<Animated.TimingAnimationConfig>
|
|
13
|
+
debugName?: string
|
|
14
|
+
debounce?: number
|
|
15
|
+
pressDisabled?: boolean
|
|
16
|
+
style?: StyledProp<TextComposition>
|
|
17
|
+
animatedStyle?: AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>
|
|
18
|
+
}
|