@codeleap/mobile 2.3.19 → 2.3.20
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/AutoComplete/index.d.ts +1 -0
- package/dist/components/AutoComplete/index.js +2 -1
- package/dist/components/AutoComplete/index.js.map +1 -1
- package/dist/components/AutoComplete/styles.js +67 -3
- package/dist/components/AutoComplete/styles.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/EmptyPlaceholder/index.d.ts +5 -2
- package/dist/components/EmptyPlaceholder/index.js +19 -5
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.d.ts +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +5 -7
- package/dist/components/EmptyPlaceholder/styles.js.map +1 -1
- package/dist/components/Grid/styles.d.ts +49 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Image/index.js +21 -3
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/List/styles.d.ts +49 -0
- package/dist/components/List/styles.js +5 -4
- package/dist/components/List/styles.js.map +1 -1
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Modal/index.js +11 -9
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +2 -2
- package/dist/components/Modal/styles.js +18 -19
- package/dist/components/Modal/styles.js.map +1 -1
- package/dist/components/MultiSelect/index.js +7 -5
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/MultiSelect/styles.d.ts +0 -51
- package/dist/components/MultiSelect/styles.js +67 -5
- package/dist/components/MultiSelect/styles.js.map +1 -1
- package/dist/components/MultiSelect/types.d.ts +8 -1
- package/dist/components/Scroll/styles.d.ts +49 -0
- package/dist/components/Scroll/styles.js +3 -4
- package/dist/components/Scroll/styles.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +5 -4
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.d.ts +1 -1
- package/dist/components/SegmentedControl/styles.js +9 -9
- package/dist/components/SegmentedControl/styles.js.map +1 -1
- package/dist/components/Select/index.d.ts +4 -1
- package/dist/components/Select/index.js +16 -21
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.d.ts +54 -53
- package/dist/components/Select/styles.js +61 -10
- package/dist/components/Select/styles.js.map +1 -1
- package/dist/components/Select/types.d.ts +8 -1
- package/dist/components/TextInput/index.js +4 -1
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/Touchable/index.js +5 -1
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/View/index.js +19 -13
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/defaultStyles.d.ts +147 -51
- package/dist/utils/KeyboardAware/context.js +1 -6
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/PermissionManager/context.js +3 -2
- package/dist/utils/PermissionManager/context.js.map +1 -1
- package/dist/utils/hooks.d.ts +2 -0
- package/dist/utils/hooks.js +44 -1
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/theme.js +3 -3
- package/dist/utils/theme.js.map +1 -1
- package/package.json +3 -2
- package/src/components/AutoComplete/index.tsx +5 -1
- package/src/components/AutoComplete/styles.ts +112 -6
- package/src/components/EmptyPlaceholder/index.tsx +32 -8
- package/src/components/EmptyPlaceholder/styles.ts +18 -15
- package/src/components/Image/index.tsx +33 -3
- package/src/components/List/styles.ts +7 -1
- package/src/components/Modal/index.tsx +12 -7
- package/src/components/Modal/styles.ts +36 -46
- package/src/components/MultiSelect/index.tsx +10 -4
- package/src/components/MultiSelect/styles.ts +117 -4
- package/src/components/MultiSelect/types.ts +8 -0
- package/src/components/Scroll/styles.ts +4 -1
- package/src/components/SegmentedControl/index.tsx +5 -4
- package/src/components/SegmentedControl/styles.ts +13 -10
- package/src/components/Select/index.tsx +50 -27
- package/src/components/Select/styles.ts +103 -25
- package/src/components/Select/types.ts +11 -1
- package/src/components/TextInput/index.tsx +3 -1
- package/src/components/Touchable/index.tsx +5 -3
- package/src/components/View/index.tsx +25 -13
- package/src/utils/KeyboardAware/context.tsx +2 -7
- package/src/utils/PermissionManager/context.tsx +1 -1
- package/src/utils/hooks.ts +50 -0
- package/src/utils/theme.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createDefaultVariantFactory } from '@codeleap/common'
|
|
1
|
+
import { assignTextStyle, createDefaultVariantFactory } from '@codeleap/common'
|
|
2
2
|
import { SelectComposition, SelectStyles } from '../Select'
|
|
3
3
|
type ItemStates = '' | ':selected'
|
|
4
4
|
export type MultiSelectComposition =
|
|
@@ -7,11 +7,124 @@ export type MultiSelectComposition =
|
|
|
7
7
|
const createMultiSelectStyle = createDefaultVariantFactory<MultiSelectComposition>()
|
|
8
8
|
|
|
9
9
|
export const MultiSelectStyles = {
|
|
10
|
-
...SelectStyles,
|
|
11
10
|
default: createMultiSelectStyle((theme) => {
|
|
12
|
-
const defaultStyle = SelectStyles.default(theme)
|
|
13
11
|
return {
|
|
14
|
-
|
|
12
|
+
wrapper: {
|
|
13
|
+
...theme.presets.absolute,
|
|
14
|
+
// ...theme.presets.whole,
|
|
15
|
+
...theme.presets.fullHeight,
|
|
16
|
+
...theme.presets.fullWidth,
|
|
17
|
+
},
|
|
18
|
+
'box:transition': {
|
|
19
|
+
scale: {
|
|
20
|
+
duration: theme.values.transitions.modal.duration,
|
|
21
|
+
type: 'timing',
|
|
22
|
+
},
|
|
23
|
+
opacity: {
|
|
24
|
+
duration: theme.values.transitions.modal.duration,
|
|
25
|
+
type: 'timing',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
'backdrop:transition': {
|
|
29
|
+
opacity: {
|
|
30
|
+
duration: theme.values.transitions.modal.duration,
|
|
31
|
+
type: 'timing',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
backdrop: {
|
|
35
|
+
...theme.presets.absolute,
|
|
36
|
+
...theme.presets.whole,
|
|
37
|
+
|
|
38
|
+
backgroundColor: theme.colors.black,
|
|
39
|
+
|
|
40
|
+
},
|
|
41
|
+
backdropTouchable: {
|
|
42
|
+
// height: '100%',
|
|
43
|
+
...theme.presets.absolute,
|
|
44
|
+
...theme.presets.whole,
|
|
45
|
+
|
|
46
|
+
},
|
|
47
|
+
'backdrop:visible': {
|
|
48
|
+
opacity: 0.5,
|
|
49
|
+
},
|
|
50
|
+
'backdrop:hidden': {
|
|
51
|
+
opacity: 0,
|
|
52
|
+
},
|
|
53
|
+
innerWrapper: {
|
|
54
|
+
|
|
55
|
+
},
|
|
56
|
+
scroll: {
|
|
57
|
+
flex: 1,
|
|
58
|
+
// maxHeight: theme.values.height,
|
|
59
|
+
},
|
|
60
|
+
scrollContent: {
|
|
61
|
+
...theme.presets.alignCenter,
|
|
62
|
+
...theme.presets.justifyCenter,
|
|
63
|
+
minHeight: '100%',
|
|
64
|
+
...theme.presets.safeAreaTop(theme.values.innerSpacing.Y),
|
|
65
|
+
...theme.presets.safeAreaBottom(theme.values.innerSpacing.Y),
|
|
66
|
+
},
|
|
67
|
+
box: {
|
|
68
|
+
backgroundColor: theme.colors.background,
|
|
69
|
+
width: theme.values.width - theme.spacing.value(theme.values.innerSpacing.X * 2),
|
|
70
|
+
borderRadius: theme.borderRadius.modalOuter,
|
|
71
|
+
...theme.spacing.paddingHorizontal(theme.values.innerSpacing.X),
|
|
72
|
+
...theme.spacing.paddingVertical(theme.values.innerSpacing.Y),
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
'box:hidden': {
|
|
76
|
+
opacity: 0,
|
|
77
|
+
scale: 0.8,
|
|
78
|
+
|
|
79
|
+
},
|
|
80
|
+
'box:visible': {
|
|
81
|
+
opacity: 1,
|
|
82
|
+
scale: 1,
|
|
83
|
+
},
|
|
84
|
+
header: {
|
|
85
|
+
flexDirection: 'row',
|
|
86
|
+
...theme.presets.justifySpaceBetween,
|
|
87
|
+
...theme.presets.alignCenter,
|
|
88
|
+
},
|
|
89
|
+
closeButtonTouchableWrapper: {
|
|
90
|
+
alignSelf: 'center',
|
|
91
|
+
...theme.spacing.marginLeft('auto'),
|
|
92
|
+
},
|
|
93
|
+
closeButtonIcon: {
|
|
94
|
+
color: theme.colors.text,
|
|
95
|
+
},
|
|
96
|
+
title: {
|
|
97
|
+
...assignTextStyle('h3')(theme).text,
|
|
98
|
+
},
|
|
99
|
+
listWrapper: {
|
|
100
|
+
height: 'auto',
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
itemWrapper: {
|
|
104
|
+
...theme.presets.row,
|
|
105
|
+
...theme.presets.justifySpaceBetween,
|
|
106
|
+
...theme.presets.alignCenter,
|
|
107
|
+
borderRadius: theme.borderRadius.medium,
|
|
108
|
+
...theme.spacing.padding(1),
|
|
109
|
+
backgroundColor: theme.colors.backgroundSecondary,
|
|
110
|
+
},
|
|
111
|
+
'itemWrapper:selected': {
|
|
112
|
+
backgroundColor: theme.colors.primary,
|
|
113
|
+
},
|
|
114
|
+
'itemIcon:selected': {
|
|
115
|
+
color: theme.colors.backgroundSecondary,
|
|
116
|
+
...theme.sized(2),
|
|
117
|
+
|
|
118
|
+
},
|
|
119
|
+
'itemText:selected': {
|
|
120
|
+
color: theme.colors.backgroundSecondary,
|
|
121
|
+
|
|
122
|
+
},
|
|
123
|
+
itemIcon: {
|
|
124
|
+
height: 0,
|
|
125
|
+
width: 0,
|
|
126
|
+
|
|
127
|
+
},
|
|
15
128
|
|
|
16
129
|
}
|
|
17
130
|
}),
|
|
@@ -2,11 +2,15 @@ import {
|
|
|
2
2
|
ComponentVariants,
|
|
3
3
|
FormTypes,
|
|
4
4
|
IconPlaceholder,
|
|
5
|
+
PropsOf,
|
|
5
6
|
} from '@codeleap/common'
|
|
6
7
|
import { StylesOf } from '../../types/utility'
|
|
7
8
|
import { DrawerProps } from '../Drawer'
|
|
9
|
+
import { Icon } from '../Icon'
|
|
8
10
|
import { FlatListProps } from '../List'
|
|
11
|
+
import { Text } from '../Text'
|
|
9
12
|
import { TextInputProps } from '../TextInput'
|
|
13
|
+
import { Touchable } from '../Touchable'
|
|
10
14
|
import { MultiSelectComposition, MultiSelectStyles } from './styles'
|
|
11
15
|
|
|
12
16
|
export type MultiSelectRenderFNProps<T> = {
|
|
@@ -15,6 +19,9 @@ export type MultiSelectRenderFNProps<T> = {
|
|
|
15
19
|
isSelected?: boolean
|
|
16
20
|
item: FormTypes.Options<T>[number]
|
|
17
21
|
icon?: IconPlaceholder
|
|
22
|
+
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
23
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
24
|
+
iconProps?: Partial<PropsOf<typeof Icon>>
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export type MultiSelectRenderFN<T> = (props: MultiSelectRenderFNProps<T>) => JSX.Element
|
|
@@ -39,5 +46,6 @@ export type MultiSelectProps<T> = MultiSelectDrawerProps & {
|
|
|
39
46
|
clearable?: boolean
|
|
40
47
|
clearIconName?: IconPlaceholder
|
|
41
48
|
validate?: TextInputProps['validate']
|
|
49
|
+
itemProps?: Partial<Pick<MultiSelectRenderFNProps<any>, 'iconProps'|'textProps'|'touchableProps'>>
|
|
42
50
|
} & ComponentVariants<typeof MultiSelectStyles>
|
|
43
51
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { createDefaultVariantFactory } from '@codeleap/common'
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
2
|
|
|
3
3
|
export type ScrollComposition = 'wrapper' |'content' | 'refreshControl'
|
|
4
4
|
|
|
5
5
|
const createScrollStyle = createDefaultVariantFactory<ScrollComposition>()
|
|
6
6
|
|
|
7
|
+
const presets = includePresets(style => createScrollStyle(() => ({ content: style })))
|
|
8
|
+
|
|
7
9
|
export const ScrollStyles = {
|
|
10
|
+
...presets,
|
|
8
11
|
default: createScrollStyle((theme) => {
|
|
9
12
|
return {
|
|
10
13
|
wrapper: {
|
|
@@ -69,6 +69,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
69
69
|
styles,
|
|
70
70
|
transform: StyleSheet.flatten,
|
|
71
71
|
variants,
|
|
72
|
+
rootElement: 'scroll',
|
|
72
73
|
})
|
|
73
74
|
|
|
74
75
|
const scrollRef = useRef<KeyboardAwareScrollViewTypes.KeyboardAwareScrollView>(null)
|
|
@@ -123,7 +124,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
123
124
|
_animation = JSON.parse(JSON.stringify(_animation))
|
|
124
125
|
|
|
125
126
|
const labelStyles = getNestedStylesByKey('label', variantStyles)
|
|
126
|
-
return (
|
|
127
|
+
return (<View style={variantStyles.wrapper}>
|
|
127
128
|
<InputLabel label={label} styles={labelStyles} required={false}/>
|
|
128
129
|
<Scroll
|
|
129
130
|
horizontal
|
|
@@ -136,7 +137,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
136
137
|
}}
|
|
137
138
|
ref={scrollRef}
|
|
138
139
|
>
|
|
139
|
-
<View style={variantStyles.
|
|
140
|
+
<View style={variantStyles.innerWrapper}>
|
|
140
141
|
<AnimatedView
|
|
141
142
|
options={options}
|
|
142
143
|
styles={variantStyles}
|
|
@@ -158,7 +159,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
158
159
|
key: idx,
|
|
159
160
|
debugName: `Segmented Control ${debugName}, option ${o.label}`,
|
|
160
161
|
onPress: onPress(o.value, idx),
|
|
161
|
-
style: [widthStyle, variantStyles.button],
|
|
162
|
+
style: [widthStyle, variantStyles.button, selected && variantStyles['button:selected']],
|
|
162
163
|
...props.touchableProps,
|
|
163
164
|
|
|
164
165
|
}
|
|
@@ -194,7 +195,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
194
195
|
})}
|
|
195
196
|
</View>
|
|
196
197
|
</Scroll>
|
|
197
|
-
|
|
198
|
+
</View>
|
|
198
199
|
)
|
|
199
200
|
|
|
200
201
|
})
|
|
@@ -7,6 +7,7 @@ export type SegmentedControlStates = 'selected'
|
|
|
7
7
|
export type SegmentedControlComposition =
|
|
8
8
|
'selectedBubble' |
|
|
9
9
|
'wrapper' |
|
|
10
|
+
'innerWrapper' |
|
|
10
11
|
'scroll' |
|
|
11
12
|
'scrollContent' |
|
|
12
13
|
'text' |
|
|
@@ -28,7 +29,7 @@ SegmentedControlComposition,
|
|
|
28
29
|
SegmentedControlStylesGen
|
|
29
30
|
>()
|
|
30
31
|
|
|
31
|
-
const presets = includePresets((style) => createSegmentedControlStyle(() => ({
|
|
32
|
+
const presets = includePresets((style) => createSegmentedControlStyle(() => ({ wrapper: style })))
|
|
32
33
|
|
|
33
34
|
export const SegmentedControlStyles = {
|
|
34
35
|
...presets,
|
|
@@ -45,22 +46,25 @@ export const SegmentedControlStyles = {
|
|
|
45
46
|
'text:selected': {
|
|
46
47
|
color: theme.colors.white,
|
|
47
48
|
},
|
|
49
|
+
wrapper: {
|
|
50
|
+
height: 'auto',
|
|
51
|
+
},
|
|
48
52
|
scroll: {
|
|
49
53
|
height: theme.values.buttons.default.height,
|
|
50
|
-
|
|
54
|
+
maxHeight: theme.values.buttons.default.height,
|
|
51
55
|
},
|
|
52
56
|
scrollContent: {
|
|
53
|
-
// borderRadius: Theme.borderRadius.large,
|
|
54
57
|
...theme.presets.row,
|
|
55
|
-
...theme.spacing.paddingHorizontal(2),
|
|
56
58
|
...theme.presets.alignStretch,
|
|
59
|
+
height: theme.values.buttons.default.height,
|
|
60
|
+
|
|
57
61
|
},
|
|
58
62
|
button: {
|
|
59
63
|
backgroundColor: 'transparent',
|
|
60
64
|
...theme.presets.alignCenter,
|
|
61
65
|
...theme.presets.justifyCenter,
|
|
62
66
|
|
|
63
|
-
borderRadius: theme.borderRadius.
|
|
67
|
+
borderRadius: theme.borderRadius.medium,
|
|
64
68
|
...theme.spacing.padding(1),
|
|
65
69
|
minHeight: '100%',
|
|
66
70
|
|
|
@@ -69,18 +73,17 @@ export const SegmentedControlStyles = {
|
|
|
69
73
|
position: 'absolute',
|
|
70
74
|
zIndex: -1,
|
|
71
75
|
...theme.spacing.padding(2),
|
|
72
|
-
// maxHeight: 50,
|
|
73
|
-
// minHeight: 50,
|
|
74
76
|
top: 0,
|
|
75
77
|
bottom: 0,
|
|
76
|
-
borderRadius: theme.borderRadius.
|
|
78
|
+
borderRadius: theme.borderRadius.medium,
|
|
77
79
|
backgroundColor: theme.colors.primary,
|
|
78
80
|
},
|
|
79
|
-
|
|
80
|
-
borderRadius: theme.borderRadius.
|
|
81
|
+
innerWrapper: {
|
|
82
|
+
borderRadius: theme.borderRadius.medium,
|
|
81
83
|
backgroundColor: theme.colors.backgroundSecondary,
|
|
82
84
|
...theme.presets.row,
|
|
83
85
|
position: 'relative',
|
|
86
|
+
height: theme.values.buttons.default.height,
|
|
84
87
|
},
|
|
85
88
|
|
|
86
89
|
}
|
|
@@ -2,7 +2,7 @@ import { IconPlaceholder,
|
|
|
2
2
|
getNestedStylesByKey,
|
|
3
3
|
useDefaultComponentStyle,
|
|
4
4
|
TypeGuards } from '@codeleap/common'
|
|
5
|
-
import React, { useMemo } from 'react'
|
|
5
|
+
import React, { useCallback, useMemo } from 'react'
|
|
6
6
|
import { StyleSheet } from 'react-native'
|
|
7
7
|
import { List } from '../List'
|
|
8
8
|
import { Text } from '../Text'
|
|
@@ -13,16 +13,39 @@ import { CustomSelectProps } from './types'
|
|
|
13
13
|
import { ModalManager } from '../../utils'
|
|
14
14
|
import { Icon } from '../Icon'
|
|
15
15
|
|
|
16
|
-
export const SelectItem = ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
export const SelectItem = ({
|
|
17
|
+
item,
|
|
18
|
+
icon = null,
|
|
19
|
+
isSelected,
|
|
20
|
+
styles,
|
|
21
|
+
onPress,
|
|
22
|
+
iconProps = {},
|
|
23
|
+
textProps = {},
|
|
24
|
+
...touchableProps
|
|
25
|
+
}) => {
|
|
26
|
+
return <Touchable
|
|
27
|
+
style={[
|
|
28
|
+
styles.itemWrapper,
|
|
29
|
+
isSelected && styles['itemWrapper:selected'],
|
|
30
|
+
]}
|
|
31
|
+
onPress={onPress}
|
|
32
|
+
debugName={`Select ${item.value}`}
|
|
33
|
+
debounce={null}
|
|
34
|
+
{...touchableProps}
|
|
35
|
+
>
|
|
36
|
+
<Text
|
|
37
|
+
text={item.label}
|
|
38
|
+
style={[
|
|
39
|
+
styles.itemText,
|
|
40
|
+
isSelected && styles['itemText:selected'],
|
|
41
|
+
]}
|
|
42
|
+
{...textProps}
|
|
43
|
+
/>
|
|
44
|
+
{icon ? <Icon
|
|
45
|
+
name={icon}
|
|
46
|
+
style={[styles?.itemIcon, isSelected && styles?.['itemIcon:selected']]}
|
|
47
|
+
{...iconProps}
|
|
48
|
+
/> : null}
|
|
26
49
|
</Touchable>
|
|
27
50
|
}
|
|
28
51
|
|
|
@@ -46,7 +69,7 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
46
69
|
selectedIcon = 'selectMarker',
|
|
47
70
|
inputProps = {},
|
|
48
71
|
hideInput = false,
|
|
49
|
-
|
|
72
|
+
itemProps = {},
|
|
50
73
|
...drawerProps
|
|
51
74
|
} = selectProps
|
|
52
75
|
|
|
@@ -81,15 +104,17 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
81
104
|
}, [value, placeholder, options])
|
|
82
105
|
const Item = renderItem || SelectItem
|
|
83
106
|
|
|
84
|
-
const renderListItem = ({ item }) => {
|
|
107
|
+
const renderListItem = useCallback(({ item }) => {
|
|
108
|
+
|
|
85
109
|
return <Item
|
|
86
110
|
isSelected={value === item.value}
|
|
87
111
|
item={item}
|
|
88
112
|
onPress={() => select(item.value)}
|
|
89
113
|
icon={selectedIcon}
|
|
90
114
|
styles={variantStyles}
|
|
115
|
+
{...itemProps}
|
|
91
116
|
/>
|
|
92
|
-
}
|
|
117
|
+
}, [value, select])
|
|
93
118
|
const isEmpty = TypeGuards.isNil(value)
|
|
94
119
|
const showClearIcon = !isEmpty && clearable
|
|
95
120
|
|
|
@@ -132,33 +157,31 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
132
157
|
)
|
|
133
158
|
}
|
|
134
159
|
|
|
135
|
-
<ModalManager.
|
|
136
|
-
scroll={false}
|
|
160
|
+
<ModalManager.Modal
|
|
137
161
|
title={label}
|
|
138
162
|
keyboardAware={{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
enabled: true,
|
|
142
|
-
enableOnAndroid: true,
|
|
163
|
+
|
|
164
|
+
enabled: false,
|
|
143
165
|
}}
|
|
144
166
|
{...drawerProps}
|
|
145
167
|
styles={variantStyles}
|
|
168
|
+
id={null}
|
|
146
169
|
>
|
|
147
170
|
<List<CustomSelectProps<any>['options']>
|
|
148
171
|
data={options}
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
scrollEnabled={false}
|
|
173
|
+
showsHorizontalScrollIndicator={false}
|
|
174
|
+
styles={getNestedStylesByKey('list', variantStyles)}
|
|
151
175
|
keyExtractor={(i) => i.value}
|
|
152
176
|
renderItem={renderListItem}
|
|
153
177
|
keyboardAware={{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
enabled: true,
|
|
157
|
-
enableOnAndroid: true,
|
|
178
|
+
enabled: false,
|
|
179
|
+
enableOnAndroid: false,
|
|
158
180
|
}}
|
|
181
|
+
separators
|
|
159
182
|
{...listProps}
|
|
160
183
|
/>
|
|
161
|
-
</ModalManager.
|
|
184
|
+
</ModalManager.Modal>
|
|
162
185
|
|
|
163
186
|
</>
|
|
164
187
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createDefaultVariantFactory, TextInputComposition } from '@codeleap/common'
|
|
1
|
+
import { assignTextStyle, createDefaultVariantFactory, TextInputComposition } from '@codeleap/common'
|
|
2
2
|
import { DrawerComposition, DrawerStyles } from '../Drawer'
|
|
3
|
+
import { ListComposition } from '../List'
|
|
4
|
+
import { ModalComposition } from '../Modal'
|
|
3
5
|
type ItemStates = '' | ':selected'
|
|
4
6
|
export type SelectComposition =
|
|
5
|
-
|
|
7
|
+
ModalComposition |
|
|
6
8
|
`input${TextInputComposition}` |
|
|
7
|
-
|
|
9
|
+
`list${Capitalize<ListComposition>}` |
|
|
8
10
|
'listContent' |
|
|
9
11
|
`itemWrapper${ItemStates}` |
|
|
10
12
|
`itemText${ItemStates}` |
|
|
11
|
-
'scroll' |
|
|
12
|
-
'scrollContent' |
|
|
13
13
|
`itemIcon${ItemStates}`
|
|
14
14
|
|
|
15
15
|
const createSelectStyle = createDefaultVariantFactory<SelectComposition>()
|
|
@@ -17,46 +17,124 @@ const createSelectStyle = createDefaultVariantFactory<SelectComposition>()
|
|
|
17
17
|
export const SelectStyles = {
|
|
18
18
|
...DrawerStyles,
|
|
19
19
|
default: createSelectStyle((theme) => {
|
|
20
|
-
const defaultStyle = DrawerStyles.default(theme)
|
|
21
20
|
|
|
22
21
|
return {
|
|
23
|
-
|
|
22
|
+
wrapper: {
|
|
23
|
+
...theme.presets.absolute,
|
|
24
|
+
// ...theme.presets.whole,
|
|
25
|
+
...theme.presets.fullHeight,
|
|
26
|
+
...theme.presets.fullWidth,
|
|
27
|
+
},
|
|
28
|
+
'box:transition': {
|
|
29
|
+
scale: {
|
|
30
|
+
duration: theme.values.transitions.modal.duration,
|
|
31
|
+
type: 'timing',
|
|
32
|
+
},
|
|
33
|
+
opacity: {
|
|
34
|
+
duration: theme.values.transitions.modal.duration,
|
|
35
|
+
type: 'timing',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'backdrop:transition': {
|
|
39
|
+
opacity: {
|
|
40
|
+
duration: theme.values.transitions.modal.duration,
|
|
41
|
+
type: 'timing',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
backdrop: {
|
|
45
|
+
...theme.presets.absolute,
|
|
46
|
+
...theme.presets.whole,
|
|
47
|
+
|
|
48
|
+
backgroundColor: theme.colors.black,
|
|
49
|
+
|
|
50
|
+
},
|
|
51
|
+
backdropTouchable: {
|
|
52
|
+
// height: '100%',
|
|
53
|
+
...theme.presets.absolute,
|
|
54
|
+
...theme.presets.whole,
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
'backdrop:visible': {
|
|
58
|
+
opacity: 0.5,
|
|
59
|
+
},
|
|
60
|
+
'backdrop:hidden': {
|
|
61
|
+
opacity: 0,
|
|
62
|
+
},
|
|
63
|
+
innerWrapper: {
|
|
64
|
+
|
|
65
|
+
},
|
|
66
|
+
scroll: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
// maxHeight: theme.values.height,
|
|
69
|
+
},
|
|
70
|
+
scrollContent: {
|
|
71
|
+
...theme.presets.alignCenter,
|
|
72
|
+
...theme.presets.justifyCenter,
|
|
73
|
+
minHeight: '100%',
|
|
74
|
+
...theme.presets.safeAreaTop(theme.values.innerSpacing.Y),
|
|
75
|
+
...theme.presets.safeAreaBottom(theme.values.innerSpacing.Y),
|
|
76
|
+
},
|
|
24
77
|
box: {
|
|
25
|
-
|
|
78
|
+
backgroundColor: theme.colors.background,
|
|
79
|
+
width: theme.values.width - theme.spacing.value(theme.values.innerSpacing.X * 2),
|
|
80
|
+
borderRadius: theme.borderRadius.modalOuter,
|
|
81
|
+
...theme.spacing.paddingHorizontal(theme.values.innerSpacing.X),
|
|
82
|
+
...theme.spacing.paddingVertical(theme.values.innerSpacing.Y),
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
'box:hidden': {
|
|
86
|
+
opacity: 0,
|
|
87
|
+
scale: 0.8,
|
|
26
88
|
|
|
27
89
|
},
|
|
90
|
+
'box:visible': {
|
|
91
|
+
opacity: 1,
|
|
92
|
+
scale: 1,
|
|
93
|
+
},
|
|
94
|
+
header: {
|
|
95
|
+
flexDirection: 'row',
|
|
96
|
+
...theme.presets.justifySpaceBetween,
|
|
97
|
+
...theme.presets.alignCenter,
|
|
98
|
+
},
|
|
99
|
+
closeButtonTouchableWrapper: {
|
|
100
|
+
alignSelf: 'center',
|
|
101
|
+
...theme.spacing.marginLeft('auto'),
|
|
102
|
+
},
|
|
103
|
+
closeButtonIcon: {
|
|
104
|
+
color: theme.colors.text,
|
|
105
|
+
},
|
|
106
|
+
title: {
|
|
107
|
+
...assignTextStyle('h3')(theme).text,
|
|
108
|
+
},
|
|
109
|
+
listWrapper: {
|
|
110
|
+
height: 'auto',
|
|
111
|
+
},
|
|
112
|
+
|
|
28
113
|
itemWrapper: {
|
|
29
114
|
...theme.presets.row,
|
|
30
115
|
...theme.presets.justifySpaceBetween,
|
|
31
116
|
...theme.presets.alignCenter,
|
|
32
|
-
|
|
33
|
-
|
|
117
|
+
borderRadius: theme.borderRadius.medium,
|
|
118
|
+
...theme.spacing.padding(1),
|
|
119
|
+
backgroundColor: theme.colors.backgroundSecondary,
|
|
34
120
|
},
|
|
35
121
|
'itemWrapper:selected': {
|
|
36
122
|
backgroundColor: theme.colors.primary,
|
|
37
123
|
},
|
|
38
|
-
'
|
|
39
|
-
color: theme.colors.
|
|
124
|
+
'itemIcon:selected': {
|
|
125
|
+
color: theme.colors.backgroundSecondary,
|
|
126
|
+
...theme.sized(2),
|
|
40
127
|
|
|
41
128
|
},
|
|
42
|
-
'
|
|
43
|
-
color: theme.colors.
|
|
44
|
-
|
|
129
|
+
'itemText:selected': {
|
|
130
|
+
color: theme.colors.backgroundSecondary,
|
|
131
|
+
|
|
45
132
|
},
|
|
46
133
|
itemIcon: {
|
|
47
|
-
width: 0,
|
|
48
134
|
height: 0,
|
|
49
|
-
|
|
50
|
-
list: {
|
|
51
|
-
height: 'auto',
|
|
52
|
-
|
|
53
|
-
maxHeight: theme.values.window.height * 0.75,
|
|
135
|
+
width: 0,
|
|
54
136
|
|
|
55
137
|
},
|
|
56
|
-
// listContent: {
|
|
57
|
-
// paddingBottom: theme.values.safeAreaTop,
|
|
58
|
-
// },
|
|
59
|
-
|
|
60
138
|
}
|
|
61
139
|
}),
|
|
62
140
|
}
|
|
@@ -2,19 +2,26 @@ import {
|
|
|
2
2
|
ComponentVariants,
|
|
3
3
|
FormTypes,
|
|
4
4
|
IconPlaceholder,
|
|
5
|
+
PropsOf,
|
|
5
6
|
} from '@codeleap/common'
|
|
6
7
|
import { StylesOf } from '../../types/utility'
|
|
7
8
|
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
8
9
|
import { DrawerProps } from '../Drawer'
|
|
10
|
+
import { Icon } from '../Icon'
|
|
9
11
|
import { FlatListProps } from '../List'
|
|
12
|
+
import { Text } from '../Text'
|
|
10
13
|
import { TextInputProps } from '../TextInput'
|
|
14
|
+
import { Touchable } from '../Touchable'
|
|
11
15
|
import { SelectComposition, SelectStyles } from './styles'
|
|
12
16
|
|
|
13
|
-
export type SelectRenderFNProps<T> =
|
|
17
|
+
export type SelectRenderFNProps<T> = {
|
|
14
18
|
styles: StylesOf<SelectComposition>
|
|
15
19
|
onPress: () => void
|
|
16
20
|
isSelected?: boolean
|
|
17
21
|
item: FormTypes.Options<T>[number]
|
|
22
|
+
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
23
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
24
|
+
iconProps?: Partial<PropsOf<typeof Icon>>
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export type SelectRenderFN<T> = (props: SelectRenderFNProps<T>) => JSX.Element
|
|
@@ -39,5 +46,8 @@ export type CustomSelectProps<T> = SelectDrawerProps & {
|
|
|
39
46
|
clearable?: boolean
|
|
40
47
|
clearIconName?: IconPlaceholder
|
|
41
48
|
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
49
|
+
itemProps?: Partial<
|
|
50
|
+
Pick<SelectRenderFNProps<any>, 'iconProps'|'textProps'|'touchableProps'
|
|
51
|
+
>>
|
|
42
52
|
} & ComponentVariants<typeof SelectStyles>
|
|
43
53
|
|
|
@@ -211,7 +211,9 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
211
211
|
styles={leftIconStyles}
|
|
212
212
|
commonStyles={commonIconStyles}
|
|
213
213
|
debugName={`${debugName} left icon`}
|
|
214
|
-
onPress={() => {
|
|
214
|
+
onPress={() => {
|
|
215
|
+
input?.current?.focus?.()
|
|
216
|
+
}}
|
|
215
217
|
noFeedback={!leftIcon?.onPress}
|
|
216
218
|
{...leftIcon}
|
|
217
219
|
/>
|
|
@@ -44,7 +44,7 @@ export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
|
44
44
|
style,
|
|
45
45
|
debugName,
|
|
46
46
|
debugComponent,
|
|
47
|
-
debounce =
|
|
47
|
+
debounce = 500,
|
|
48
48
|
noFeedback = false,
|
|
49
49
|
styles,
|
|
50
50
|
...props
|
|
@@ -119,7 +119,6 @@ export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
|
119
119
|
'height!',
|
|
120
120
|
'flex!',
|
|
121
121
|
'backgroundColor!',
|
|
122
|
-
|
|
123
122
|
]
|
|
124
123
|
|
|
125
124
|
const wrapperStyle = {} as any
|
|
@@ -144,7 +143,10 @@ export const Touchable: React.FC<TouchableProps> = forwardRef<
|
|
|
144
143
|
pressableStyle[key] = value
|
|
145
144
|
}
|
|
146
145
|
})
|
|
147
|
-
|
|
146
|
+
if (wrapperStyle.position === 'absolute') {
|
|
147
|
+
pressableStyle.width = '100%'
|
|
148
|
+
pressableStyle.height = '100%'
|
|
149
|
+
}
|
|
148
150
|
wrapperStyle.overflow = 'hidden'
|
|
149
151
|
// wrapperStyle.flexDirection = 'row'
|
|
150
152
|
// wrapperStyle.alignItems = 'stretch'
|