@codeleap/mobile 3.25.0 → 3.25.3
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 +4 -6
- package/src/components/ActionIcon/index.tsx +37 -55
- package/src/components/ActionIcon/styles.ts +4 -2
- package/src/components/ActivityIndicator/index.tsx +64 -42
- package/src/components/ActivityIndicator/styles.ts +10 -1
- package/src/components/Autocomplete/index.tsx +54 -46
- package/src/components/Autocomplete/styles.ts +5 -2
- package/src/components/Autocomplete/types.ts +23 -13
- package/src/components/Avatar/index.tsx +71 -59
- package/src/components/Avatar/styles.ts +9 -1
- package/src/components/AvatarGroup/index.tsx +44 -30
- package/src/components/AvatarGroup/styles.ts +6 -0
- package/src/components/Backdrop/index.tsx +34 -51
- package/src/components/Backdrop/styles.ts +10 -5
- package/src/components/Badge/index.tsx +62 -36
- package/src/components/Badge/styles.ts +11 -3
- package/src/components/Button/index.tsx +82 -55
- package/src/components/Button/styles.ts +14 -13
- package/src/components/Calendar/index.tsx +29 -35
- package/src/components/Calendar/style.ts +6 -0
- package/src/components/Checkbox/index.tsx +64 -43
- package/src/components/Checkbox/styles.ts +6 -1
- package/src/components/ContentView/index.tsx +63 -0
- package/src/components/ContentView/styles.ts +8 -0
- package/src/components/DatePickerModal/index.tsx +65 -50
- package/src/components/DatePickerModal/styles.ts +10 -9
- package/src/components/DatePickerModal/types.ts +54 -36
- package/src/components/Drawer/index.tsx +28 -0
- package/src/components/Drawer/styles.ts +8 -0
- package/src/components/EmptyPlaceholder/index.tsx +63 -40
- package/src/components/EmptyPlaceholder/styles.ts +5 -0
- package/src/components/FileInput/index.tsx +49 -11
- package/src/components/FileInput/styles.ts +8 -0
- package/src/components/Grid/index.tsx +116 -84
- package/src/components/Grid/styles.ts +5 -0
- package/src/components/Icon/index.tsx +79 -44
- package/src/components/Icon/styles.ts +6 -0
- package/src/components/Image/index.tsx +78 -58
- package/src/components/Image/styles.ts +6 -1
- package/src/components/ImageView/Spotlight.tsx +4 -1
- package/src/components/ImageView/component.tsx +2 -1
- package/src/components/InputBase/index.tsx +24 -33
- package/src/components/InputBase/styles.ts +75 -66
- package/src/components/InputBase/types.ts +4 -3
- package/src/components/InputBase/utils.ts +4 -6
- package/src/components/InputLabel/index.tsx +38 -0
- package/src/components/InputLabel/styles.ts +7 -0
- package/src/components/List/PaginationIndicator.tsx +54 -0
- package/src/components/List/index.tsx +151 -99
- package/src/components/List/styles.ts +6 -0
- package/src/components/LoadingOverlay/index.tsx +29 -42
- package/src/components/LoadingOverlay/styles.ts +7 -7
- package/src/components/Modal/index.tsx +127 -80
- package/src/components/Modal/styles.ts +8 -0
- package/src/components/Navigation/Navigation.tsx +0 -1
- package/src/components/Navigation/types.ts +9 -2
- package/src/components/NumberIncrement/index.tsx +60 -50
- package/src/components/NumberIncrement/styles.ts +5 -0
- package/src/components/NumberIncrement/types.ts +39 -32
- package/src/components/Pager/index.tsx +94 -42
- package/src/components/Pager/styles.ts +13 -1
- package/src/components/RadioInput/index.tsx +57 -32
- package/src/components/RadioInput/styles.ts +7 -5
- package/src/components/RefreshControl/index.tsx +19 -39
- package/src/components/RefreshControl/styles.ts +6 -1
- package/src/components/Scroll/index.tsx +105 -89
- package/src/components/Scroll/styles.ts +5 -0
- package/src/components/Sections/index.tsx +161 -111
- package/src/components/Sections/styles.ts +5 -0
- package/src/components/SegmentedControl/Option.tsx +31 -46
- package/src/components/SegmentedControl/index.tsx +121 -86
- package/src/components/SegmentedControl/styles.ts +22 -15
- package/src/components/Select/index.tsx +82 -71
- package/src/components/Select/styles.ts +5 -3
- package/src/components/Select/types.ts +25 -20
- package/src/components/Slider/index.tsx +43 -58
- package/src/components/Slider/styles.ts +6 -15
- package/src/components/Slider/types.ts +14 -9
- package/src/components/Switch/index.tsx +56 -43
- package/src/components/Switch/styles.ts +7 -1
- package/src/components/Text/index.tsx +52 -56
- package/src/components/Text/styles.ts +7 -1
- package/src/components/TextInput/index.tsx +162 -49
- package/src/components/TextInput/styles.ts +8 -2
- package/src/components/Touchable/index.tsx +87 -44
- package/src/components/Touchable/styles.ts +9 -0
- package/src/components/View/index.tsx +92 -23
- package/src/components/View/styles.ts +6 -0
- package/src/components/components.ts +6 -2
- package/src/components/defaultStyles.ts +77 -0
- package/src/index.ts +0 -2
- package/src/modules/PressableRipple/type.ts +0 -1
- package/src/utils/KeyboardAware/context.tsx +2 -0
- package/src/utils/KeyboardAware/keyboardHooks.ts +2 -1
- package/src/utils/ModalManager/components.tsx +30 -1
- package/src/utils/ModalManager/context.tsx +4 -4
- package/src/utils/ModalManager/index.ts +4 -1
- package/src/utils/hooks.ts +1 -12
- package/src/Registry.ts +0 -52
- package/src/components/ActionIcon/types.ts +0 -15
- package/src/components/ActivityIndicator/types.ts +0 -9
- package/src/components/Avatar/types.ts +0 -23
- package/src/components/AvatarGroup/types.ts +0 -10
- package/src/components/Backdrop/types.ts +0 -14
- package/src/components/Badge/types.ts +0 -27
- package/src/components/Button/types.ts +0 -20
- package/src/components/Checkbox/types.ts +0 -13
- package/src/components/EmptyPlaceholder/types.ts +0 -21
- package/src/components/FileInput/types.ts +0 -27
- package/src/components/Grid/types.ts +0 -20
- package/src/components/Icon/types.ts +0 -15
- package/src/components/Image/types.ts +0 -18
- package/src/components/List/types.ts +0 -41
- package/src/components/LoadingOverlay/types.ts +0 -9
- package/src/components/Modal/types.ts +0 -41
- package/src/components/Pager/types.ts +0 -37
- package/src/components/PaginationIndicator/index.tsx +0 -51
- package/src/components/PaginationIndicator/styles.ts +0 -3
- package/src/components/PaginationIndicator/types.ts +0 -10
- package/src/components/RadioInput/types.ts +0 -31
- package/src/components/RefreshControl/types.ts +0 -9
- package/src/components/Scroll/types.ts +0 -21
- package/src/components/SearchInput/index.tsx +0 -90
- package/src/components/Sections/types.ts +0 -39
- package/src/components/SegmentedControl/types.ts +0 -31
- package/src/components/Switch/types.ts +0 -12
- package/src/components/Text/types.ts +0 -18
- package/src/components/TextInput/types.ts +0 -23
- package/src/components/Touchable/types.ts +0 -27
- package/src/components/View/types.ts +0 -13
- package/src/hooks/index.ts +0 -13
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { StylesOf } from '@codeleap/common'
|
|
1
|
+
import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
|
|
2
2
|
import { BadgeComposition } from '../Badge'
|
|
3
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
3
4
|
import { TouchableStylesGen } from '../Touchable'
|
|
4
5
|
|
|
5
6
|
export type SegmentedControlStates = 'selected' | 'disabled'
|
|
6
7
|
|
|
7
8
|
export type SegmentedControlComposition =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
'selectedBubble' |
|
|
10
|
+
'wrapper' |
|
|
11
|
+
'innerWrapper' |
|
|
12
|
+
'scroll' |
|
|
13
|
+
'scrollContent' |
|
|
14
|
+
'text' |
|
|
15
|
+
`text:${SegmentedControlStates}` |
|
|
16
|
+
'icon' |
|
|
17
|
+
'button' |
|
|
18
|
+
'buttonFeedback' |
|
|
19
|
+
`button:${SegmentedControlStates}` |
|
|
19
20
|
`selectedBubble:${SegmentedControlStates}` |
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`badge${Capitalize<BadgeComposition>}`
|
|
21
|
+
`label${Capitalize<InputLabelComposition>}` |
|
|
22
|
+
`badge${Capitalize<BadgeComposition>}`
|
|
23
23
|
|
|
24
24
|
export type SegmentedControlStylesGen<TCSS = any> =
|
|
25
25
|
StylesOf<
|
|
@@ -27,3 +27,10 @@ export type SegmentedControlStylesGen<TCSS = any> =
|
|
|
27
27
|
> & {
|
|
28
28
|
buttonFeedback?: TouchableStylesGen['feedback']
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
const createSegmentedControlStyle = createDefaultVariantFactory<
|
|
32
|
+
SegmentedControlComposition,
|
|
33
|
+
SegmentedControlStylesGen
|
|
34
|
+
>()
|
|
35
|
+
|
|
36
|
+
export const SegmentedControlPresets = includePresets((style) => createSegmentedControlStyle(() => ({ wrapper: style })))
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import {
|
|
3
|
+
IconPlaceholder,
|
|
4
|
+
useDefaultComponentStyle,
|
|
3
5
|
TypeGuards,
|
|
6
|
+
useNestedStylesByKey,
|
|
4
7
|
FormTypes,
|
|
5
8
|
onMount,
|
|
6
9
|
onUpdate,
|
|
@@ -9,19 +12,16 @@ import {
|
|
|
9
12
|
useBooleanToggle,
|
|
10
13
|
} from '@codeleap/common'
|
|
11
14
|
import React, { useCallback, useMemo } from 'react'
|
|
15
|
+
import { StyleSheet } from 'react-native'
|
|
12
16
|
import { List } from '../List'
|
|
13
|
-
import { TextInput } from '../TextInput'
|
|
17
|
+
import { SearchInput, TextInput } from '../TextInput'
|
|
18
|
+
import { SelectPresets } from './styles'
|
|
14
19
|
import { SelectProps, ValueBoundSelectProps } from './types'
|
|
15
20
|
import { ModalManager } from '../../utils'
|
|
16
21
|
import { Button } from '../Button'
|
|
17
|
-
|
|
18
|
-
import Modal from '../Modal'
|
|
19
|
-
import { MobileStyleRegistry } from '../../Registry'
|
|
20
|
-
import { SearchInput } from '../SearchInput'
|
|
21
|
-
import { useStylesFor } from '../../hooks'
|
|
22
|
+
export * from './styles'
|
|
22
23
|
|
|
23
24
|
export * from './styles'
|
|
24
|
-
export * from './types'
|
|
25
25
|
|
|
26
26
|
const defaultFilterFunction = (search: string, options: FormTypes.Options<any>) => {
|
|
27
27
|
return options.filter((option) => {
|
|
@@ -33,18 +33,6 @@ const defaultFilterFunction = (search: string, options: FormTypes.Options<any>)
|
|
|
33
33
|
})
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const defaultGetLabel = (option) => {
|
|
37
|
-
if (TypeGuards.isArray(option)) {
|
|
38
|
-
if (option.length === 0) return null
|
|
39
|
-
|
|
40
|
-
return option.map(o => o.label).join(', ')
|
|
41
|
-
|
|
42
|
-
} else {
|
|
43
|
-
if (!option) return null
|
|
44
|
-
return option?.label
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
36
|
const OuterInput: ValueBoundSelectProps<any, boolean>['outerInputComponent'] = (props) => {
|
|
49
37
|
const {
|
|
50
38
|
currentValueLabel,
|
|
@@ -52,6 +40,7 @@ const OuterInput: ValueBoundSelectProps<any, boolean>['outerInputComponent'] = (
|
|
|
52
40
|
clearIcon,
|
|
53
41
|
label,
|
|
54
42
|
toggle,
|
|
43
|
+
styles,
|
|
55
44
|
style,
|
|
56
45
|
placeholder,
|
|
57
46
|
disabled = false,
|
|
@@ -65,6 +54,7 @@ const OuterInput: ValueBoundSelectProps<any, boolean>['outerInputComponent'] = (
|
|
|
65
54
|
disabled={disabled}
|
|
66
55
|
label={label}
|
|
67
56
|
debugName={debugName}
|
|
57
|
+
styles={styles}
|
|
68
58
|
style={style}
|
|
69
59
|
innerWrapperProps={{
|
|
70
60
|
rippleDisabled: true,
|
|
@@ -74,48 +64,69 @@ const OuterInput: ValueBoundSelectProps<any, boolean>['outerInputComponent'] = (
|
|
|
74
64
|
/>
|
|
75
65
|
}
|
|
76
66
|
|
|
67
|
+
const defaultProps: Partial<SelectProps<any, boolean>> = {
|
|
68
|
+
getLabel(option) {
|
|
69
|
+
|
|
70
|
+
if (TypeGuards.isArray(option)) {
|
|
71
|
+
|
|
72
|
+
if (option.length === 0) return null
|
|
73
|
+
|
|
74
|
+
return option.map(o => o.label).join(', ')
|
|
75
|
+
|
|
76
|
+
} else {
|
|
77
|
+
if (!option) return null
|
|
78
|
+
return option?.label
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
outerInputComponent: OuterInput,
|
|
82
|
+
searchInputProps: {},
|
|
83
|
+
arrowIconName: 'chevrons-up-down' as IconPlaceholder,
|
|
84
|
+
clearIconName: 'x' as IconPlaceholder,
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
export const Select = <T extends string | number = string, Multi extends boolean = false>(selectProps: SelectProps<T, Multi>) => {
|
|
78
88
|
const allProps = {
|
|
79
|
-
...
|
|
89
|
+
...defaultProps,
|
|
80
90
|
...selectProps,
|
|
81
91
|
}
|
|
82
|
-
|
|
83
92
|
const {
|
|
84
93
|
value,
|
|
85
94
|
onValueChange,
|
|
86
95
|
label,
|
|
96
|
+
styles = {},
|
|
87
97
|
options = [],
|
|
88
98
|
style,
|
|
99
|
+
variants,
|
|
89
100
|
description,
|
|
90
|
-
renderItem
|
|
101
|
+
renderItem,
|
|
91
102
|
listProps,
|
|
92
103
|
debugName,
|
|
93
|
-
placeholder,
|
|
104
|
+
placeholder = 'Select',
|
|
94
105
|
arrowIconName,
|
|
95
106
|
clearIconName,
|
|
96
|
-
clearable,
|
|
97
|
-
selectedIcon,
|
|
107
|
+
clearable = false,
|
|
108
|
+
selectedIcon = 'check',
|
|
98
109
|
inputProps = {},
|
|
99
|
-
hideInput,
|
|
110
|
+
hideInput = false,
|
|
100
111
|
itemProps = {},
|
|
101
112
|
searchable,
|
|
102
113
|
loadOptions,
|
|
103
|
-
multiple,
|
|
114
|
+
multiple = false,
|
|
104
115
|
closeOnSelect = !multiple,
|
|
105
116
|
limit = null,
|
|
106
117
|
defaultOptions = options,
|
|
107
118
|
visible: _visible,
|
|
108
119
|
toggle: _toggle,
|
|
109
120
|
ListHeaderComponent,
|
|
110
|
-
ListComponent,
|
|
121
|
+
ListComponent = List,
|
|
111
122
|
onLoadOptionsError,
|
|
112
123
|
loadOptionsOnMount = defaultOptions.length === 0,
|
|
113
|
-
loadOptionsOnOpen,
|
|
114
|
-
filterItems,
|
|
124
|
+
loadOptionsOnOpen = false,
|
|
125
|
+
filterItems = defaultFilterFunction,
|
|
115
126
|
getLabel,
|
|
116
127
|
searchInputProps,
|
|
117
128
|
outerInputComponent,
|
|
118
|
-
disabled,
|
|
129
|
+
disabled = false,
|
|
119
130
|
...modalProps
|
|
120
131
|
} = allProps
|
|
121
132
|
|
|
@@ -145,7 +156,9 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
145
156
|
const currentValueLabel = useMemo(() => {
|
|
146
157
|
const _options = (multiple ? labelOptions : labelOptions?.[0]) as Multi extends true ? FormTypes.Options<T> : FormTypes.Options<T>[number]
|
|
147
158
|
|
|
148
|
-
const label = getLabel(
|
|
159
|
+
const label = getLabel(
|
|
160
|
+
_options,
|
|
161
|
+
)
|
|
149
162
|
|
|
150
163
|
return label
|
|
151
164
|
}, [labelOptions])
|
|
@@ -164,15 +177,27 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
164
177
|
}
|
|
165
178
|
}, [visible, prevVisible])
|
|
166
179
|
|
|
167
|
-
const
|
|
180
|
+
const variantStyles = useDefaultComponentStyle<'u:Select', typeof SelectPresets>('u:Select', {
|
|
181
|
+
transform: StyleSheet.flatten,
|
|
182
|
+
rootElement: 'inputWrapper',
|
|
183
|
+
styles,
|
|
184
|
+
variants,
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
const itemStyles = useNestedStylesByKey('item', variantStyles)
|
|
168
188
|
|
|
169
|
-
const
|
|
189
|
+
const listStyles = useNestedStylesByKey('list', variantStyles)
|
|
190
|
+
|
|
191
|
+
const inputStyles = useNestedStylesByKey('input', variantStyles)
|
|
192
|
+
|
|
193
|
+
const searchInputStyles = useNestedStylesByKey('searchInput', variantStyles)
|
|
170
194
|
|
|
171
195
|
const currentOptions = searchable ? filteredOptions : defaultOptions
|
|
172
196
|
|
|
173
197
|
const close = () => toggle?.()
|
|
174
198
|
|
|
175
199
|
const select = useCallback((selectedValue) => {
|
|
200
|
+
|
|
176
201
|
let newValue = null
|
|
177
202
|
|
|
178
203
|
let newOption = null
|
|
@@ -218,9 +243,13 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
218
243
|
if (closeOnSelect) {
|
|
219
244
|
close?.()
|
|
220
245
|
}
|
|
246
|
+
|
|
221
247
|
}, [isValueArray, (isValueArray ? value : [value]), limit, multiple])
|
|
222
248
|
|
|
249
|
+
const Item = renderItem || Button
|
|
250
|
+
|
|
223
251
|
const renderListItem = useCallback(({ item, index }) => {
|
|
252
|
+
|
|
224
253
|
let selected = false
|
|
225
254
|
|
|
226
255
|
if (multiple && isValueArray) {
|
|
@@ -239,7 +268,7 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
239
268
|
icon={selectedIcon}
|
|
240
269
|
// @ts-ignore
|
|
241
270
|
rightIcon={selectedIcon}
|
|
242
|
-
|
|
271
|
+
styles={itemStyles}
|
|
243
272
|
index={index}
|
|
244
273
|
{...itemProps}
|
|
245
274
|
/>
|
|
@@ -268,7 +297,7 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
268
297
|
}}
|
|
269
298
|
debounce={!!loadOptions ? 800 : null}
|
|
270
299
|
onSearchChange={onChangeSearch}
|
|
271
|
-
|
|
300
|
+
styles={searchInputStyles}
|
|
272
301
|
{...searchInputProps}
|
|
273
302
|
/> : null
|
|
274
303
|
|
|
@@ -287,22 +316,26 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
287
316
|
|
|
288
317
|
return <>
|
|
289
318
|
{
|
|
290
|
-
!hideInput
|
|
319
|
+
!hideInput && (
|
|
291
320
|
// @ts-ignore
|
|
292
321
|
<Input
|
|
322
|
+
|
|
293
323
|
clearIcon={{
|
|
294
|
-
icon: inputIcon as
|
|
324
|
+
icon: inputIcon as IconPlaceholder,
|
|
295
325
|
onPress: disabled ? null : onPressInputIcon,
|
|
296
326
|
}}
|
|
327
|
+
|
|
297
328
|
currentValueLabel={currentValueLabel}
|
|
329
|
+
|
|
298
330
|
debugName={`${debugName} select input`}
|
|
299
|
-
|
|
331
|
+
styles={inputStyles}
|
|
332
|
+
style={style}
|
|
300
333
|
{...allProps}
|
|
301
334
|
{...inputProps}
|
|
302
335
|
visible={visible}
|
|
303
336
|
toggle={toggle}
|
|
304
337
|
/>
|
|
305
|
-
)
|
|
338
|
+
)
|
|
306
339
|
}
|
|
307
340
|
|
|
308
341
|
<ModalManager.Modal
|
|
@@ -310,17 +343,18 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
310
343
|
description={description}
|
|
311
344
|
{...modalProps}
|
|
312
345
|
debugName={`${debugName} modal`}
|
|
313
|
-
|
|
346
|
+
styles={variantStyles}
|
|
314
347
|
id={null}
|
|
315
348
|
visible={visible}
|
|
316
349
|
toggle={toggle}
|
|
350
|
+
|
|
317
351
|
>
|
|
318
|
-
<ListComponent
|
|
352
|
+
<ListComponent<SelectProps<any>['options']>
|
|
319
353
|
data={searchable ? filteredOptions : options}
|
|
320
354
|
scrollEnabled={false}
|
|
321
355
|
showsHorizontalScrollIndicator={false}
|
|
322
|
-
|
|
323
|
-
keyExtractor={(i
|
|
356
|
+
styles={listStyles}
|
|
357
|
+
keyExtractor={(i) => i.value}
|
|
324
358
|
renderItem={renderListItem}
|
|
325
359
|
fakeEmpty={loading}
|
|
326
360
|
separators
|
|
@@ -332,34 +366,11 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
332
366
|
}}
|
|
333
367
|
/>
|
|
334
368
|
</ModalManager.Modal>
|
|
369
|
+
|
|
335
370
|
</>
|
|
336
371
|
}
|
|
337
372
|
|
|
373
|
+
export * from './styles'
|
|
374
|
+
export * from './types'
|
|
338
375
|
|
|
339
|
-
Select.
|
|
340
|
-
Select.elements = [...Modal.elements, 'input', 'list', 'item', 'searchInput']
|
|
341
|
-
Select.rootElement = 'inputWrapper'
|
|
342
|
-
|
|
343
|
-
Select.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
344
|
-
return Select as (<T extends string | number = string, Multi extends boolean = false>(props: StyledComponentProps<SelectProps<T, Multi>, typeof styles>) => IJSX)
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
Select.defaultProps = {
|
|
348
|
-
getLabel: defaultGetLabel,
|
|
349
|
-
outerInputComponent: OuterInput,
|
|
350
|
-
searchInputProps: {},
|
|
351
|
-
arrowIconName: 'chevrons-up-down' as AppIcon,
|
|
352
|
-
clearIconName: 'x' as AppIcon,
|
|
353
|
-
placeholder: 'Select',
|
|
354
|
-
clearable: false,
|
|
355
|
-
selectedIcon: 'check' as AppIcon,
|
|
356
|
-
hideInput: false,
|
|
357
|
-
multiple: false,
|
|
358
|
-
loadOptionsOnOpen: false,
|
|
359
|
-
disabled: false,
|
|
360
|
-
filterItems: defaultFilterFunction,
|
|
361
|
-
renderItem: Button,
|
|
362
|
-
ListComponent: List,
|
|
363
|
-
} as Partial<SelectProps<any, boolean>>
|
|
364
|
-
|
|
365
|
-
MobileStyleRegistry.registerComponent(Select)
|
|
376
|
+
Select.defaultProps = defaultProps
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ButtonComposition } from '
|
|
1
|
+
import { ButtonComposition, createDefaultVariantFactory, includePresets, TextInputComposition } from '@codeleap/common'
|
|
2
2
|
import { ListComposition } from '../List'
|
|
3
3
|
import { ModalComposition } from '../Modal'
|
|
4
|
-
import { TextInputComposition } from '../TextInput'
|
|
5
|
-
|
|
6
4
|
type ItemStates = '' | ':selected'
|
|
7
5
|
|
|
8
6
|
type ItemParts = ButtonComposition
|
|
@@ -15,3 +13,7 @@ export type SelectComposition =
|
|
|
15
13
|
`list${Capitalize<ListComposition>}` |
|
|
16
14
|
`item${Capitalize<ItemComposition>}` |
|
|
17
15
|
`searchInput${Capitalize<TextInputComposition>}`
|
|
16
|
+
|
|
17
|
+
const createSelectStyle = createDefaultVariantFactory<SelectComposition>()
|
|
18
|
+
|
|
19
|
+
export const SelectPresets = includePresets((style) => createSelectStyle(() => ({ body: style })))
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ComponentVariants,
|
|
3
|
+
FormTypes,
|
|
4
|
+
IconPlaceholder,
|
|
5
|
+
PropsOf,
|
|
6
|
+
} from '@codeleap/common'
|
|
3
7
|
import { StylesOf } from '../../types/utility'
|
|
4
8
|
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
5
9
|
import { ActionIconProps } from '../ActionIcon'
|
|
@@ -7,27 +11,25 @@ import { Icon } from '../Icon'
|
|
|
7
11
|
import { FlatListProps } from '../List'
|
|
8
12
|
import { ModalProps } from '../Modal'
|
|
9
13
|
import { Text } from '../Text'
|
|
10
|
-
import { TextInputComposition } from '../TextInput'
|
|
11
|
-
import { SearchInputProps } from '../SearchInput'
|
|
14
|
+
import { SearchInputProps, TextInputComposition, TextInputProps } from '../TextInput'
|
|
12
15
|
import { Touchable } from '../Touchable'
|
|
13
|
-
import { SelectComposition } from './styles'
|
|
16
|
+
import { SelectComposition, SelectPresets } from './styles'
|
|
14
17
|
|
|
15
18
|
export type SelectRenderFNProps<T> = {
|
|
16
|
-
|
|
19
|
+
styles: StylesOf<SelectComposition>
|
|
17
20
|
onPress: () => void
|
|
18
|
-
|
|
21
|
+
isSelected?: boolean
|
|
19
22
|
item: FormTypes.Options<T>[number]
|
|
20
23
|
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
21
24
|
textProps?: Partial<PropsOf<typeof Text>>
|
|
22
25
|
iconProps?: Partial<PropsOf<typeof Icon>>
|
|
23
26
|
index: number
|
|
24
27
|
debugName: string
|
|
25
|
-
text?: string
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export type SelectRenderFN<T> = (props: SelectRenderFNProps<T>) => JSX.Element
|
|
29
31
|
|
|
30
|
-
type SelectModalProps = Omit<ModalProps, '
|
|
32
|
+
type SelectModalProps = Omit<ModalProps, 'variants' | 'styles'>
|
|
31
33
|
|
|
32
34
|
export type SelectValue<T, Multi extends boolean = false> = Multi extends true ? T[] : T
|
|
33
35
|
|
|
@@ -35,7 +37,7 @@ type SelectHeaderProps = {
|
|
|
35
37
|
searchComponent?: React.ReactNode
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export type SelectOuterInputProps<T = any, Multi extends boolean = false> = SelectProps<T, Multi> & {
|
|
40
|
+
export type SelectOuterInputProps<T = any, Multi extends boolean = false> = Omit<SelectProps<T, Multi>, 'variants'| 'styles'> & {
|
|
39
41
|
currentValueLabel: FormTypes.Label
|
|
40
42
|
styles?: StylesOf<TextInputComposition>
|
|
41
43
|
clearIcon?: Partial<ActionIconProps>
|
|
@@ -67,22 +69,24 @@ export type ReplaceSelectProps<Props, T, Multi extends boolean = false> = Omit<
|
|
|
67
69
|
keyof ValueBoundSelectProps<T, Multi>
|
|
68
70
|
> & ValueBoundSelectProps<T, Multi>
|
|
69
71
|
|
|
70
|
-
export type SelectProps<T = any, Multi extends boolean = false> =
|
|
71
|
-
SelectModalProps &
|
|
72
|
-
ValueBoundSelectProps<T, Multi> &
|
|
73
|
-
{
|
|
72
|
+
export type SelectProps<T = any, Multi extends boolean = false> = {
|
|
74
73
|
placeholder?: FormTypes.Label
|
|
75
74
|
label?: FormTypes.Label
|
|
75
|
+
styles?: StylesOf<SelectComposition>
|
|
76
|
+
style?: TextInputProps['style']
|
|
76
77
|
hideInput?: boolean
|
|
77
|
-
selectedIcon?:
|
|
78
|
-
arrowIconName?:
|
|
78
|
+
selectedIcon?: IconPlaceholder
|
|
79
|
+
arrowIconName?: IconPlaceholder
|
|
79
80
|
closeOnSelect?: boolean
|
|
81
|
+
|
|
80
82
|
listProps?: Partial<FlatListProps>
|
|
81
83
|
clearable?: boolean
|
|
82
|
-
clearIconName?:
|
|
84
|
+
clearIconName?: IconPlaceholder
|
|
83
85
|
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
84
86
|
multiple?: Multi
|
|
85
|
-
itemProps?: Partial<
|
|
87
|
+
itemProps?: Partial<
|
|
88
|
+
Pick<SelectRenderFNProps<any>, 'iconProps'|'textProps'|'touchableProps'
|
|
89
|
+
>>
|
|
86
90
|
searchable?: boolean
|
|
87
91
|
limit?: number
|
|
88
92
|
ListHeaderComponent?: React.ComponentType<SelectHeaderProps>
|
|
@@ -90,5 +94,6 @@ export type SelectProps<T = any, Multi extends boolean = false> =
|
|
|
90
94
|
searchInputProps?: Partial<SearchInputProps>
|
|
91
95
|
loadOptionsOnMount?: boolean
|
|
92
96
|
loadOptionsOnOpen?: boolean
|
|
93
|
-
|
|
94
|
-
}
|
|
97
|
+
|
|
98
|
+
} & ComponentVariants<typeof SelectPresets> & SelectModalProps & ValueBoundSelectProps<T, Multi>
|
|
99
|
+
|