@codeleap/mobile 2.2.1 → 2.2.4
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/components/ActionIcon/styles.d.ts +11 -10
- package/dist/components/ActionIcon/styles.js +5 -1
- package/dist/components/ActionIcon/styles.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.d.ts +10 -10
- package/dist/components/Animated.d.ts +1 -0
- package/dist/components/AutoComplete/index.d.ts +3 -3
- package/dist/components/AutoComplete/index.js +3 -3
- package/dist/components/AutoComplete/index.js.map +1 -1
- package/dist/components/AutoComplete/styles.d.ts +10 -10
- package/dist/components/AutoComplete/styles.js +1 -3
- package/dist/components/AutoComplete/styles.js.map +1 -1
- package/dist/components/Backdrop/styles.d.ts +10 -10
- package/dist/components/Button/index.d.ts +24 -24
- package/dist/components/Button/styles.d.ts +10 -10
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/Checkbox/styles.d.ts +10 -10
- package/dist/components/ContentView/styles.d.ts +10 -10
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/styles.d.ts +10 -10
- package/dist/components/Drawer/styles.js +6 -2
- package/dist/components/Drawer/styles.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.d.ts +9 -9
- package/dist/components/FileInput/styles.d.ts +10 -10
- package/dist/components/Icon/index.js +7 -3
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.d.ts +11 -10
- package/dist/components/Icon/styles.js +4 -0
- package/dist/components/Icon/styles.js.map +1 -1
- package/dist/components/Image/styles.d.ts +10 -10
- package/dist/components/List/PaginationIndicator.d.ts +10 -10
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Modal/index.js +8 -2
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +10 -10
- package/dist/components/Modal/styles.js +9 -5
- package/dist/components/Modal/styles.js.map +1 -1
- package/dist/components/MultiSelect/index.js +3 -1
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/MultiSelect/styles.d.ts +10 -10
- package/dist/components/Pager/styles.d.ts +10 -10
- package/dist/components/RadioInput/styles.d.ts +10 -10
- package/dist/components/Scroll/index.d.ts +1 -1
- package/dist/components/Scroll/index.js +7 -5
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Sections/index.d.ts +1 -1
- package/dist/components/SegmentedControl/styles.d.ts +10 -10
- package/dist/components/Select/index.js +12 -14
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.d.ts +10 -10
- package/dist/components/Select/styles.js +1 -4
- package/dist/components/Select/styles.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +10 -10
- package/dist/components/Switch/styles.d.ts +10 -10
- package/dist/components/Text/styles.d.ts +10 -10
- package/dist/components/TextInput/index.d.ts +20 -20
- package/dist/components/TextInput/index.js +18 -10
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.d.ts +10 -10
- package/dist/components/Touchable/index.d.ts +1 -0
- package/dist/components/Touchable/index.js +21 -35
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.d.ts +10 -10
- package/dist/components/View/index.d.ts +3 -0
- package/dist/components/View/index.js +5 -2
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.d.ts +10 -10
- package/dist/components/defaultStyles.d.ts +251 -249
- package/dist/components/legacy/Modal/styles.d.ts +10 -10
- package/dist/components/legacy/Pager/styles.d.ts +10 -10
- package/dist/types/utility.d.ts +6 -0
- package/dist/utils/KeyboardAware/context.d.ts +13 -0
- package/dist/utils/KeyboardAware/context.js +65 -0
- package/dist/utils/KeyboardAware/context.js.map +1 -0
- package/dist/utils/KeyboardAware/index.d.ts +1 -0
- package/dist/utils/KeyboardAware/index.js +1 -0
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +9 -13
- package/dist/utils/KeyboardAware/keyboardHooks.js +17 -40
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/ModalManager/context.js +8 -5
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme.d.ts +36 -0
- package/dist/utils/theme.js +48 -0
- package/dist/utils/theme.js.map +1 -0
- package/package.json +1 -1
- package/src/components/ActionIcon/styles.ts +5 -0
- package/src/components/AutoComplete/index.tsx +10 -5
- package/src/components/AutoComplete/styles.ts +2 -6
- package/src/components/Drawer/index.tsx +1 -2
- package/src/components/Drawer/styles.ts +7 -2
- package/src/components/Icon/index.tsx +14 -8
- package/src/components/Icon/styles.ts +5 -0
- package/src/components/Modal/index.tsx +14 -1
- package/src/components/Modal/styles.ts +13 -6
- package/src/components/MultiSelect/index.tsx +3 -1
- package/src/components/Scroll/index.tsx +7 -2
- package/src/components/Select/index.tsx +25 -12
- package/src/components/Select/styles.ts +6 -5
- package/src/components/TextInput/index.tsx +30 -10
- package/src/components/Touchable/index.tsx +22 -39
- package/src/components/View/index.tsx +16 -2
- package/src/types/utility.ts +6 -0
- package/src/utils/KeyboardAware/context.tsx +73 -0
- package/src/utils/KeyboardAware/index.ts +1 -0
- package/src/utils/KeyboardAware/keyboardHooks.ts +30 -61
- package/src/utils/ModalManager/context.tsx +21 -18
- package/src/utils/index.ts +1 -0
- package/src/utils/theme.ts +50 -0
|
@@ -4,6 +4,7 @@ import { ComponentVariants,
|
|
|
4
4
|
getNestedStylesByKey,
|
|
5
5
|
IconPlaceholder,
|
|
6
6
|
onUpdate,
|
|
7
|
+
PropsOf,
|
|
7
8
|
ReactStateProps,
|
|
8
9
|
TypeGuards,
|
|
9
10
|
useDebounce,
|
|
@@ -21,7 +22,9 @@ import { StyleSheet } from 'react-native'
|
|
|
21
22
|
import { Text } from '../Text'
|
|
22
23
|
import { Button } from '../Button'
|
|
23
24
|
|
|
24
|
-
export type AutoCompleteHeaderProps = ReactStateProps<'search', string> &
|
|
25
|
+
export type AutoCompleteHeaderProps = ReactStateProps<'search', string> &
|
|
26
|
+
Omit<PropsOf<typeof View>, 'style'|'styles'|'variants'>
|
|
27
|
+
& {
|
|
25
28
|
label: FormTypes.Label
|
|
26
29
|
searchInputProps?: Partial<TextInputProps>
|
|
27
30
|
styles: ModalHeaderProps['styles'] & { searchInput?: TextInputProps['styles']; titleWrapper?:ViewProps['style']}
|
|
@@ -31,9 +34,9 @@ export type AutoCompleteHeaderProps = ReactStateProps<'search', string> & {
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export const AutoCompleteHeader:React.FC<AutoCompleteHeaderProps> = (props) => {
|
|
34
|
-
const { search, setSearch, icon = 'search', debugName, label, styles, toggle, searchInputProps } = props
|
|
37
|
+
const { search, setSearch, icon = 'search', debugName, label, styles, toggle, searchInputProps, ...viewProps } = props
|
|
35
38
|
|
|
36
|
-
return <View style={[styles.wrapper]}>
|
|
39
|
+
return <View style={[styles.wrapper]} {...viewProps}>
|
|
37
40
|
<View style={styles.titleWrapper}>
|
|
38
41
|
<Text style={styles.title} text={label}/>
|
|
39
42
|
<Button
|
|
@@ -42,7 +45,7 @@ export const AutoCompleteHeader:React.FC<AutoCompleteHeaderProps> = (props) => {
|
|
|
42
45
|
onPress={toggle} variants={['icon']}
|
|
43
46
|
styles={styles.closeButton}/>
|
|
44
47
|
</View>
|
|
45
|
-
<TextInput leftIcon={{
|
|
48
|
+
<TextInput subtitle={() => null} leftIcon={{
|
|
46
49
|
icon: icon as IconPlaceholder,
|
|
47
50
|
}} debugName={`AutoComplete ${debugName} search input`} value={search} onChangeText={setSearch} styles={styles.searchInput} {...searchInputProps}/>
|
|
48
51
|
</View>
|
|
@@ -77,6 +80,7 @@ export const AutoComplete = <T extends string|number = string>(props: AutoComple
|
|
|
77
80
|
const [search, setSearch] = useState('')
|
|
78
81
|
const [debouncedSearch, resetDebounce] = useDebounce(search, debounce)
|
|
79
82
|
const [filteredOptions, setFilteredOptions] = useState(options)
|
|
83
|
+
|
|
80
84
|
const [loading, setLoading] = useState(false)
|
|
81
85
|
const variantStyles = useDefaultComponentStyle<'u:AutoComplete', typeof AutoCompleteStyles>('u:AutoComplete', {
|
|
82
86
|
variants,
|
|
@@ -123,7 +127,6 @@ export const AutoComplete = <T extends string|number = string>(props: AutoComple
|
|
|
123
127
|
resetDebounce()
|
|
124
128
|
}
|
|
125
129
|
}, [debouncedSearch, caseSensitive, options.length, filterFn])
|
|
126
|
-
|
|
127
130
|
return <Select
|
|
128
131
|
styles={variantStyles}
|
|
129
132
|
options={ loading ? [] : filteredOptions}
|
|
@@ -141,9 +144,11 @@ export const AutoComplete = <T extends string|number = string>(props: AutoComple
|
|
|
141
144
|
searchInput: searchInputStyles,
|
|
142
145
|
titleWrapper: variantStyles.titleWrapper,
|
|
143
146
|
}}
|
|
147
|
+
|
|
144
148
|
{...headerProps}
|
|
145
149
|
/>
|
|
146
150
|
}
|
|
151
|
+
|
|
147
152
|
{...selectProps}
|
|
148
153
|
listProps={{
|
|
149
154
|
...selectProps?.listProps,
|
|
@@ -15,15 +15,11 @@ export const AutoCompleteStyles = {
|
|
|
15
15
|
...defaultStyle,
|
|
16
16
|
header: {
|
|
17
17
|
...theme.spacing.paddingHorizontal(2),
|
|
18
|
+
...theme.spacing.paddingTop(1),
|
|
18
19
|
...theme.presets.column,
|
|
19
20
|
...theme.presets.alignStart,
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
-
maxHeight: theme.values.window.height * 0.85,
|
|
23
|
-
},
|
|
24
|
-
listContent: {
|
|
25
|
-
...theme.presets.safeAreaBottom(0, true),
|
|
26
|
-
},
|
|
22
|
+
|
|
27
23
|
searchInputWrapper: {
|
|
28
24
|
...theme.presets.fullWidth,
|
|
29
25
|
...theme.spacing.marginTop(2),
|
|
@@ -13,15 +13,20 @@ export const DrawerStyles = {
|
|
|
13
13
|
...defaultStyle,
|
|
14
14
|
box: {
|
|
15
15
|
width: '100%',
|
|
16
|
-
|
|
16
|
+
paddingBottom: 0,
|
|
17
|
+
paddingTop: 0,
|
|
18
|
+
borderBottomLeftRadius: 0,
|
|
19
|
+
borderBottomRightRadius: 0,
|
|
20
|
+
maxHeight: '100%',
|
|
17
21
|
|
|
18
22
|
},
|
|
19
23
|
innerWrapper: {
|
|
20
24
|
...theme.presets.justifyEnd,
|
|
25
|
+
|
|
21
26
|
},
|
|
22
27
|
|
|
23
28
|
'box:hidden': {
|
|
24
|
-
translateY: theme.values.
|
|
29
|
+
translateY: theme.values.height,
|
|
25
30
|
opacity: 1,
|
|
26
31
|
scale: 1,
|
|
27
32
|
},
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
useCodeleapContext,
|
|
7
7
|
arePropsEqual,
|
|
8
8
|
IconPlaceholder,
|
|
9
|
+
onMount,
|
|
10
|
+
onUpdate,
|
|
9
11
|
} from '@codeleap/common'
|
|
10
12
|
import { StyleSheet } from 'react-native'
|
|
11
13
|
import { View } from '../View'
|
|
@@ -27,7 +29,7 @@ export type IconProps = {
|
|
|
27
29
|
export const IconComponent: React.FC<IconProps> = ({ name, style, variants, renderEmptySpace, ...otherProps }) => {
|
|
28
30
|
const { Theme, logger } = useCodeleapContext()
|
|
29
31
|
|
|
30
|
-
const variantStyles = useDefaultComponentStyle('Icon', {
|
|
32
|
+
const variantStyles = useDefaultComponentStyle<'u:Icon', typeof IconStyles>('u:Icon', {
|
|
31
33
|
variants,
|
|
32
34
|
transform: StyleSheet.flatten,
|
|
33
35
|
styles: {
|
|
@@ -35,19 +37,23 @@ export const IconComponent: React.FC<IconProps> = ({ name, style, variants, rend
|
|
|
35
37
|
},
|
|
36
38
|
rootElement: 'icon',
|
|
37
39
|
})
|
|
40
|
+
const Component = Theme?.icons?.[name]
|
|
41
|
+
onUpdate(() => {
|
|
42
|
+
if (!Component && !!name) {
|
|
43
|
+
logger.warn(
|
|
44
|
+
`Icon: No icon found in theme for name "${name}".`,
|
|
45
|
+
{ props: { style, name, variants, variantStyles }},
|
|
46
|
+
'Component',
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}, [name])
|
|
38
50
|
|
|
39
51
|
if (!name) {
|
|
40
52
|
return renderEmptySpace ? <View style={variantStyles.icon}/> : null
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
const Component = Theme?.icons?.[name]
|
|
44
|
-
|
|
45
55
|
if (!Component) {
|
|
46
|
-
|
|
47
|
-
`Icon: No icon found in theme for name "${name}".`,
|
|
48
|
-
{ props: { style, name, variants, variantStyles }},
|
|
49
|
-
'Component',
|
|
50
|
-
)
|
|
56
|
+
|
|
51
57
|
return null
|
|
52
58
|
}
|
|
53
59
|
return <Component {...otherProps} style={variantStyles.icon} />
|
|
@@ -24,6 +24,7 @@ import { Backdrop } from '../Backdrop'
|
|
|
24
24
|
import { useBackButton, useStaticAnimationStyles } from '../../utils/hooks'
|
|
25
25
|
import { Text, TextProps } from '../Text'
|
|
26
26
|
import { Touchable } from '../Touchable'
|
|
27
|
+
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
27
28
|
|
|
28
29
|
export * from './styles'
|
|
29
30
|
|
|
@@ -46,6 +47,7 @@ export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
|
46
47
|
header?: React.ReactElement
|
|
47
48
|
closeOnHardwareBackPress?: boolean
|
|
48
49
|
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
50
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
49
51
|
scrollProps?: PropsOf<typeof Scroll>
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -129,6 +131,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
129
131
|
boxAnimation.animateTo(visible ? boxAnimationStates['box:visible'] : boxAnimationStates['box:hidden'])
|
|
130
132
|
}, [visible])
|
|
131
133
|
const wrapperStyle = getStyles('wrapper')
|
|
134
|
+
|
|
132
135
|
const ScrollComponent = scroll ? Scroll : View
|
|
133
136
|
const scrollStyle = scroll ? getStyles('scroll') : getStyles('innerWrapper')
|
|
134
137
|
|
|
@@ -167,11 +170,20 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
167
170
|
<ScrollComponent
|
|
168
171
|
style={scrollStyle}
|
|
169
172
|
contentContainerStyle={getStyles('scrollContent')}
|
|
170
|
-
{
|
|
173
|
+
keyboardAware= {{
|
|
174
|
+
adapt: 'marginBottom',
|
|
175
|
+
baseStyleProp: 'style',
|
|
176
|
+
animated: true,
|
|
177
|
+
enabled: visible,
|
|
178
|
+
enableOnAndroid: true,
|
|
179
|
+
}}
|
|
180
|
+
animated
|
|
181
|
+
{ ...scrollProps}
|
|
171
182
|
>
|
|
172
183
|
{dismissOnBackdrop &&
|
|
173
184
|
<Touchable
|
|
174
185
|
onPress={ closable ? toggle : (() => {})}
|
|
186
|
+
debounce={400}
|
|
175
187
|
debugName={'Modal backdrop touchable'}
|
|
176
188
|
style={variantStyles.backdropTouchable}
|
|
177
189
|
android_ripple={null}
|
|
@@ -183,6 +195,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
183
195
|
state={boxAnimation}
|
|
184
196
|
style={getStyles('box')}
|
|
185
197
|
transition={{ ...variantStyles['box:transition'] }}
|
|
198
|
+
|
|
186
199
|
{...props}
|
|
187
200
|
>
|
|
188
201
|
|
|
@@ -38,8 +38,9 @@ export const ModalStyles = {
|
|
|
38
38
|
const fullSize = {
|
|
39
39
|
...theme.presets.whole,
|
|
40
40
|
position: 'absolute',
|
|
41
|
-
width:
|
|
42
|
-
height:
|
|
41
|
+
width: theme.values.width,
|
|
42
|
+
height: theme.values.height,
|
|
43
|
+
maxHeight: theme.values.height,
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return {
|
|
@@ -49,6 +50,8 @@ export const ModalStyles = {
|
|
|
49
50
|
width: theme.values.width,
|
|
50
51
|
...theme.presets.whole,
|
|
51
52
|
position: 'absolute',
|
|
53
|
+
...theme.presets.safeAreaTop(),
|
|
54
|
+
paddingBottom: theme.values.bottomNavHeight,
|
|
52
55
|
},
|
|
53
56
|
'box:transition': {
|
|
54
57
|
scale: {
|
|
@@ -83,16 +86,20 @@ export const ModalStyles = {
|
|
|
83
86
|
innerWrapper: {
|
|
84
87
|
...theme.presets.alignCenter,
|
|
85
88
|
...theme.presets.justifyCenter,
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
width: theme.values.width,
|
|
90
|
+
flex: 1,
|
|
88
91
|
},
|
|
89
92
|
scroll: {
|
|
90
|
-
|
|
93
|
+
width: theme.values.width,
|
|
94
|
+
height: theme.values.window.height,
|
|
95
|
+
maxHeight: theme.values.window.height,
|
|
91
96
|
},
|
|
92
97
|
scrollContent: {
|
|
93
98
|
...theme.presets.alignCenter,
|
|
94
99
|
...theme.presets.justifyCenter,
|
|
95
|
-
...theme.
|
|
100
|
+
...theme.spacing.paddingVertical(2),
|
|
101
|
+
...theme.presets.fullWidth,
|
|
102
|
+
flex: 1,
|
|
96
103
|
},
|
|
97
104
|
box: {
|
|
98
105
|
width: '80%',
|
|
@@ -119,7 +119,9 @@ export const MultiSelect = <T extends string|number = string>(selectProps:MultiS
|
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
<ModalManager.Drawer scroll={false} title={label}
|
|
122
|
+
<ModalManager.Drawer scroll={false} title={label} keyboardAware={{
|
|
123
|
+
enabled: false,
|
|
124
|
+
}} {...drawerProps} styles={variantStyles}>
|
|
123
125
|
<List<MultiSelectProps<any>['options']>
|
|
124
126
|
data={options}
|
|
125
127
|
style={variantStyles.list}
|
|
@@ -13,6 +13,7 @@ import { KeyboardAwareScrollViewTypes } from '../../modules'
|
|
|
13
13
|
import { StylesOf } from '../../types'
|
|
14
14
|
import { ScrollComposition, ScrollStyles } from './styles'
|
|
15
15
|
import { GetKeyboardAwarePropsOptions, useKeyboardAwareView } from '../../utils'
|
|
16
|
+
import { ScrollView as MotiScrollView } from 'moti'
|
|
16
17
|
// import { KeyboardAwareScrollView } from '../../utils'
|
|
17
18
|
|
|
18
19
|
type KeyboardAwareScrollViewProps = KeyboardAwareScrollViewTypes.KeyboardAwareScrollViewProps
|
|
@@ -42,6 +43,7 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
42
43
|
contentContainerStyle,
|
|
43
44
|
keyboardAware,
|
|
44
45
|
debugName = '',
|
|
46
|
+
animated = true,
|
|
45
47
|
...props
|
|
46
48
|
} = scrollProps
|
|
47
49
|
const hasRefresh = !!props.onRefresh
|
|
@@ -103,16 +105,19 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
103
105
|
const rootProps = keyboard.getKeyboardAwareProps(_scrollProps, {
|
|
104
106
|
adapt: 'marginBottom',
|
|
105
107
|
baseStyleProp: 'style',
|
|
108
|
+
animated,
|
|
106
109
|
...keyboardAware,
|
|
107
110
|
|
|
108
111
|
})
|
|
112
|
+
const Component = animated ? MotiScrollView : ScrollView
|
|
109
113
|
|
|
110
114
|
return (
|
|
111
|
-
<
|
|
115
|
+
<Component
|
|
112
116
|
{...rootProps}
|
|
117
|
+
|
|
113
118
|
>
|
|
114
119
|
{children}
|
|
115
|
-
</
|
|
120
|
+
</Component>
|
|
116
121
|
)
|
|
117
122
|
},
|
|
118
123
|
)
|
|
@@ -10,7 +10,7 @@ import { TextInput } from '../TextInput'
|
|
|
10
10
|
import { Touchable } from '../Touchable'
|
|
11
11
|
import { SelectStyles } from './styles'
|
|
12
12
|
import { CustomSelectProps } from './types'
|
|
13
|
-
import { ModalManager
|
|
13
|
+
import { ModalManager } from '../../utils'
|
|
14
14
|
import { Icon } from '../Icon'
|
|
15
15
|
|
|
16
16
|
export const SelectItem = ({ item, icon = null, isSelected, styles, onPress }) => {
|
|
@@ -104,15 +104,6 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
104
104
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const baseListProps = {
|
|
108
|
-
data: options,
|
|
109
|
-
style: variantStyles.list,
|
|
110
|
-
contentContainerStyle: variantStyles.listContent,
|
|
111
|
-
keyExtractor: (i) => i.value,
|
|
112
|
-
renderItem: renderListItem,
|
|
113
|
-
...listProps,
|
|
114
|
-
}
|
|
115
|
-
|
|
116
107
|
return <>
|
|
117
108
|
{
|
|
118
109
|
!hideInput && (
|
|
@@ -141,9 +132,31 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
141
132
|
)
|
|
142
133
|
}
|
|
143
134
|
|
|
144
|
-
<ModalManager.Drawer
|
|
135
|
+
<ModalManager.Drawer
|
|
136
|
+
scroll={false}
|
|
137
|
+
title={label}
|
|
138
|
+
{...drawerProps}
|
|
139
|
+
keyboardAware={{
|
|
140
|
+
baseStyleProp: 'style',
|
|
141
|
+
adapt: 'paddingBottom',
|
|
142
|
+
enabled: true,
|
|
143
|
+
enableOnAndroid: true,
|
|
144
|
+
}}
|
|
145
|
+
styles={variantStyles}
|
|
146
|
+
>
|
|
145
147
|
<List<CustomSelectProps<any>['options']>
|
|
146
|
-
{
|
|
148
|
+
data={options}
|
|
149
|
+
style={variantStyles.list}
|
|
150
|
+
contentContainerStyle={variantStyles.listContent}
|
|
151
|
+
keyExtractor={(i) => i.value}
|
|
152
|
+
renderItem={renderListItem}
|
|
153
|
+
keyboardAware={{
|
|
154
|
+
baseStyleProp: 'style',
|
|
155
|
+
adapt: 'maxHeight',
|
|
156
|
+
enabled: true,
|
|
157
|
+
enableOnAndroid: true,
|
|
158
|
+
}}
|
|
159
|
+
{...listProps}
|
|
147
160
|
/>
|
|
148
161
|
</ModalManager.Drawer>
|
|
149
162
|
|
|
@@ -18,6 +18,7 @@ export const SelectStyles = {
|
|
|
18
18
|
...DrawerStyles,
|
|
19
19
|
default: createSelectStyle((theme) => {
|
|
20
20
|
const defaultStyle = DrawerStyles.default(theme)
|
|
21
|
+
|
|
21
22
|
return {
|
|
22
23
|
...defaultStyle,
|
|
23
24
|
box: {
|
|
@@ -49,12 +50,12 @@ export const SelectStyles = {
|
|
|
49
50
|
list: {
|
|
50
51
|
height: 'auto',
|
|
51
52
|
|
|
52
|
-
maxHeight: theme.values.window.height * 0.
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
listContent: {
|
|
56
|
-
paddingBottom: theme.values.bottomNavHeight + theme.spacing.value(1),
|
|
53
|
+
maxHeight: theme.values.window.height * 0.75,
|
|
54
|
+
|
|
57
55
|
},
|
|
56
|
+
// listContent: {
|
|
57
|
+
// paddingBottom: theme.values.safeAreaTop,
|
|
58
|
+
// },
|
|
58
59
|
|
|
59
60
|
}
|
|
60
61
|
}),
|
|
@@ -84,7 +84,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
84
84
|
password,
|
|
85
85
|
visibilityToggle,
|
|
86
86
|
innerWrapperProps,
|
|
87
|
-
masking
|
|
87
|
+
masking,
|
|
88
88
|
subtitle = '',
|
|
89
89
|
onChangeMask,
|
|
90
90
|
debugName,
|
|
@@ -96,6 +96,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
96
96
|
const [editedState, setEdited] = useState(edited)
|
|
97
97
|
|
|
98
98
|
const input = useRef<any>(null)
|
|
99
|
+
const maskInputRef = useRef<any>(null)
|
|
99
100
|
const [textIsVisible, setTextVisible] = useBooleanToggle(false)
|
|
100
101
|
const variantStyles = useDefaultComponentStyle<'u:TextInput', typeof TextInputStyles>('u:TextInput', {
|
|
101
102
|
variants,
|
|
@@ -120,7 +121,8 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
const handleMaskChange = (masked, unmasked) => {
|
|
123
|
-
|
|
124
|
+
|
|
125
|
+
if (onChangeText) onChangeText(masking?.saveFormatted ? masked : masked)
|
|
124
126
|
if (onChangeMask) onChangeMask(masked, unmasked)
|
|
125
127
|
}
|
|
126
128
|
const handleChange = (event: NativeSyntheticEvent<TextInputChangeEventData>) => {
|
|
@@ -130,9 +132,16 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
130
132
|
if (onChangeText) onChangeText(text)
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
useImperativeHandle(inputRef, () =>
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
useImperativeHandle(inputRef, () => {
|
|
136
|
+
return {
|
|
137
|
+
...input.current,
|
|
138
|
+
focus: () => {
|
|
139
|
+
input.current?.focus?.()
|
|
140
|
+
},
|
|
141
|
+
isTextInput: true,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}, [!!masking, !!input?.current?.focus])
|
|
136
145
|
|
|
137
146
|
const { showError, error } = useValidate(value, validate)
|
|
138
147
|
|
|
@@ -177,7 +186,6 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
177
186
|
<FormError {...errorProps}/>
|
|
178
187
|
{TypeGuards.isString(subtitle) ? <Text text={subtitle} style={subtitleStyles.subtitle}/> : (subtitle || null)}
|
|
179
188
|
</View>
|
|
180
|
-
|
|
181
189
|
return (
|
|
182
190
|
<Touchable
|
|
183
191
|
style={getStyles('wrapper')}
|
|
@@ -209,7 +217,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
209
217
|
/>
|
|
210
218
|
{/* @ts-ignore */}
|
|
211
219
|
<InputElement
|
|
212
|
-
|
|
220
|
+
|
|
213
221
|
secureTextEntry={password && !textIsVisible}
|
|
214
222
|
onChange={(e) => masking ? onChange?.(e) : handleChange(e)}
|
|
215
223
|
value={value}
|
|
@@ -220,9 +228,21 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
220
228
|
selectionColor={StyleSheet.flatten(getStyles('selection'))?.color}
|
|
221
229
|
includeRawValueInChangeText={true}
|
|
222
230
|
{...props}
|
|
223
|
-
{...
|
|
224
|
-
|
|
225
|
-
|
|
231
|
+
{...masking}
|
|
232
|
+
{...(!!masking ? {
|
|
233
|
+
onChangeText: handleMaskChange,
|
|
234
|
+
ref: maskInputRef,
|
|
235
|
+
refInput: (inputRef) => {
|
|
236
|
+
// console.log(inputRef)
|
|
237
|
+
if (!!inputRef) {
|
|
238
|
+
input.current = inputRef
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
...masking,
|
|
243
|
+
} : {
|
|
244
|
+
ref: input,
|
|
245
|
+
})}
|
|
226
246
|
style={getStyles('textField')}
|
|
227
247
|
/>
|
|
228
248
|
<InputIcon
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
useCodeleapContext,
|
|
9
9
|
AnyFunction,
|
|
10
|
+
TypeGuards,
|
|
10
11
|
} from '@codeleap/common'
|
|
11
12
|
import { Pressable, StyleSheet, View as RNView } from 'react-native'
|
|
12
13
|
|
|
@@ -27,42 +28,11 @@ export type TouchableProps = Omit<
|
|
|
27
28
|
debugComponent?: string
|
|
28
29
|
onPress?: AnyFunction
|
|
29
30
|
noFeedback?: boolean
|
|
31
|
+
debounce?: number
|
|
30
32
|
styles?: StylesOf<TouchableComposition>
|
|
31
33
|
} & BaseViewProps
|
|
32
34
|
export * from './styles'
|
|
33
35
|
|
|
34
|
-
const defaultWrapperStyles = {
|
|
35
|
-
paddingTop: 0,
|
|
36
|
-
paddingLeft: 0,
|
|
37
|
-
paddingRight: 0,
|
|
38
|
-
paddingBottom: 0,
|
|
39
|
-
overflow: 'hidden',
|
|
40
|
-
alignItems: 'stretch',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultPressableStyles = {
|
|
44
|
-
marginTop: 0,
|
|
45
|
-
marginLeft: 0,
|
|
46
|
-
marginRight: 0,
|
|
47
|
-
marginBottom: 0,
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const ripplePressableStyles = {
|
|
52
|
-
// position: 'absolute',
|
|
53
|
-
// top: 0,
|
|
54
|
-
// left: 0,
|
|
55
|
-
// right: 0,
|
|
56
|
-
// bottom: 0,
|
|
57
|
-
// width: '100%',
|
|
58
|
-
// minWidth: '100%',
|
|
59
|
-
// maxWidth: '100%',
|
|
60
|
-
// height: '100%',
|
|
61
|
-
// minHeight: '100%',
|
|
62
|
-
// maxHeight: '100%',
|
|
63
|
-
// flex: 1,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
36
|
export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
67
37
|
RNView,
|
|
68
38
|
TouchableProps
|
|
@@ -74,11 +44,12 @@ export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
|
74
44
|
style,
|
|
75
45
|
debugName,
|
|
76
46
|
debugComponent,
|
|
47
|
+
debounce = null,
|
|
77
48
|
noFeedback = false,
|
|
78
49
|
styles,
|
|
79
50
|
...props
|
|
80
51
|
} = touchableProps
|
|
81
|
-
|
|
52
|
+
const [pressed, setPressed] = React.useState(false)
|
|
82
53
|
const variantStyles = useDefaultComponentStyle<'u:Touchable', typeof TouchableStyles>('u:Touchable', {
|
|
83
54
|
variants,
|
|
84
55
|
transform: StyleSheet.flatten,
|
|
@@ -95,13 +66,25 @@ export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
|
95
66
|
}, 'User Interaction')
|
|
96
67
|
return
|
|
97
68
|
}
|
|
69
|
+
const _onPress = () => {
|
|
70
|
+
logger.log(
|
|
71
|
+
`<${debugComponent || 'Touchable'}/> pressed`,
|
|
72
|
+
debugName || variants,
|
|
73
|
+
'User interaction',
|
|
74
|
+
)
|
|
75
|
+
onPress && onPress()
|
|
76
|
+
}
|
|
77
|
+
if (TypeGuards.isNumber(debounce)) {
|
|
78
|
+
if (pressed) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
setPressed(true)
|
|
82
|
+
_onPress()
|
|
83
|
+
setTimeout(() => setPressed(false), debounce)
|
|
84
|
+
} else {
|
|
85
|
+
_onPress()
|
|
86
|
+
}
|
|
98
87
|
|
|
99
|
-
logger.log(
|
|
100
|
-
`<${debugComponent || 'Touchable'}/> pressed`,
|
|
101
|
-
debugName || variants,
|
|
102
|
-
'User interaction',
|
|
103
|
-
)
|
|
104
|
-
onPress && onPress()
|
|
105
88
|
}
|
|
106
89
|
|
|
107
90
|
const _styles = StyleSheet.flatten([variantStyles.wrapper, style])
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@codeleap/common'
|
|
11
11
|
import { View as NativeView } from 'react-native'
|
|
12
12
|
import { MotiView, MotiProps } from 'moti'
|
|
13
|
+
import { GetKeyboardAwarePropsOptions, useKeyboardAwareView } from '../../utils'
|
|
13
14
|
|
|
14
15
|
export * from './styles'
|
|
15
16
|
|
|
@@ -18,6 +19,7 @@ export type ViewProps = ComponentPropsWithoutRef<typeof NativeView> &
|
|
|
18
19
|
ref?: any
|
|
19
20
|
component?: any
|
|
20
21
|
animated?: boolean
|
|
22
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
21
23
|
} & BaseViewProps
|
|
22
24
|
|
|
23
25
|
export const View: React.FC<ViewProps & Partial<MotiProps>> = forwardRef<NativeView, ViewProps & Partial<MotiProps>>((viewProps, ref) => {
|
|
@@ -26,7 +28,7 @@ export const View: React.FC<ViewProps & Partial<MotiProps>> = forwardRef<NativeV
|
|
|
26
28
|
variants = [],
|
|
27
29
|
children,
|
|
28
30
|
style,
|
|
29
|
-
|
|
31
|
+
keyboardAware,
|
|
30
32
|
component,
|
|
31
33
|
animated = false,
|
|
32
34
|
...props
|
|
@@ -37,9 +39,21 @@ export const View: React.FC<ViewProps & Partial<MotiProps>> = forwardRef<NativeV
|
|
|
37
39
|
variants,
|
|
38
40
|
})
|
|
39
41
|
const Component = animated ? MotiView : (component || NativeView)
|
|
42
|
+
const keyboard = useKeyboardAwareView()
|
|
43
|
+
const _props = keyboard.getKeyboardAwareProps(
|
|
44
|
+
{
|
|
45
|
+
style: [variantStyles.wrapper, style], ref: ref, ...props,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
adapt: 'paddingBottom',
|
|
49
|
+
baseStyleProp: 'style',
|
|
40
50
|
|
|
51
|
+
enabled: false,
|
|
52
|
+
...keyboardAware,
|
|
53
|
+
},
|
|
54
|
+
)
|
|
41
55
|
return (
|
|
42
|
-
<Component
|
|
56
|
+
<Component {..._props}>
|
|
43
57
|
{children}
|
|
44
58
|
</Component>
|
|
45
59
|
)
|
package/src/types/utility.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { StyleProp } from 'react-native'
|
|
2
|
+
import { EasingFunction } from 'react-native-animatable'
|
|
2
3
|
|
|
3
4
|
export type StylesOf<C extends string> = Partial<Record<C, StyleProp<any>>>
|
|
5
|
+
export type TransitionConfig = {
|
|
6
|
+
easing?: EasingFunction
|
|
7
|
+
type?: 'timing' | 'spring'
|
|
8
|
+
duration?: number
|
|
9
|
+
}
|