react-native-input-select 0.35.0 → 1.1.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/README.md +103 -30
- package/lib/commonjs/components/CheckBox/index.js +16 -13
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CheckBox/types.js.map +1 -1
- package/lib/commonjs/components/CustomModal/index.js +1 -9
- package/lib/commonjs/components/CustomModal/index.js.map +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +0 -9
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/commonjs/components/Dropdown/{DropdownList.js → DropdownFlatList.js} +22 -32
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -0
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +11 -22
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js +139 -0
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -0
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +10 -22
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/components/Input/index.js +4 -11
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Others/index.js +93 -0
- package/lib/commonjs/components/Others/index.js.map +1 -0
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/index.js +73 -59
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/styles/colors.js.map +1 -1
- package/lib/commonjs/styles/input.js +0 -4
- package/lib/commonjs/styles/input.js.map +1 -1
- package/lib/commonjs/styles/typography.js +0 -3
- package/lib/commonjs/styles/typography.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/commonjs/utils/index.js +26 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/components/CheckBox/index.js +14 -6
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CheckBox/types.js.map +1 -1
- package/lib/module/components/CustomModal/index.js +1 -4
- package/lib/module/components/CustomModal/index.js.map +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +0 -2
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/Dropdown/{DropdownList.js → DropdownFlatList.js} +23 -27
- package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -0
- package/lib/module/components/Dropdown/DropdownListItem.js +11 -14
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSectionList.js +130 -0
- package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -0
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +11 -17
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/components/Input/index.js +2 -2
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Others/index.js +82 -0
- package/lib/module/components/Others/index.js.map +1 -0
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/index.js +72 -42
- package/lib/module/index.js.map +1 -1
- package/lib/module/styles/colors.js.map +1 -1
- package/lib/module/styles/input.js.map +1 -1
- package/lib/module/styles/typography.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/module/utils/index.js +18 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/components/CheckBox/index.d.ts +6 -1
- package/lib/typescript/components/CheckBox/types.d.ts +6 -1
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +3 -0
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +3 -0
- package/lib/typescript/components/Input/index.d.ts +1 -0
- package/lib/typescript/components/Others/index.d.ts +14 -0
- package/lib/typescript/types/index.types.d.ts +24 -5
- package/lib/typescript/utils/index.d.ts +6 -0
- package/package.json +2 -2
- package/src/components/CheckBox/index.tsx +32 -5
- package/src/components/CheckBox/types.ts +5 -0
- package/src/components/Dropdown/{DropdownList.tsx → DropdownFlatList.tsx} +22 -20
- package/src/components/Dropdown/DropdownListItem.tsx +13 -11
- package/src/components/Dropdown/DropdownSectionList.tsx +135 -0
- package/src/components/Dropdown/DropdownSelectedItemsView.tsx +16 -28
- package/src/components/Input/index.tsx +2 -0
- package/src/components/Others/index.tsx +91 -0
- package/src/index.tsx +114 -41
- package/src/types/index.types.ts +22 -4
- package/src/utils/index.ts +25 -0
- package/lib/commonjs/components/Dropdown/DropdownList.js.map +0 -1
- package/lib/module/components/Dropdown/DropdownList.js.map +0 -1
- package/lib/typescript/components/Dropdown/DropdownList.d.ts +0 -3
package/src/index.tsx
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { TouchableOpacity, StyleSheet, View } from 'react-native';
|
|
3
|
+
import Input from './components/Input';
|
|
4
|
+
import CheckBox from './components/CheckBox';
|
|
3
5
|
import Dropdown from './components/Dropdown/Dropdown';
|
|
4
|
-
import
|
|
6
|
+
import DropdownFlatList from './components/Dropdown/DropdownFlatList';
|
|
7
|
+
import DropdownSectionList from './components/Dropdown/DropdownSectionList';
|
|
5
8
|
import CustomModal from './components/CustomModal';
|
|
6
|
-
import { Input } from './components/Input';
|
|
7
|
-
import CheckBox from './components/CheckBox';
|
|
8
9
|
import { colors } from './styles/colors';
|
|
9
10
|
import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
|
|
10
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
DropdownProps,
|
|
13
|
+
TFlatList,
|
|
14
|
+
TFlatListItem,
|
|
15
|
+
TSectionList,
|
|
16
|
+
TSectionListItem,
|
|
17
|
+
} from './types/index.types';
|
|
18
|
+
import {
|
|
19
|
+
extractPropertyFromArray,
|
|
20
|
+
getMaxLengthOfSectionListProperty,
|
|
21
|
+
} from './utils';
|
|
11
22
|
|
|
12
23
|
export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
13
24
|
placeholder,
|
|
@@ -37,16 +48,18 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
37
48
|
searchInputStyle,
|
|
38
49
|
primaryColor,
|
|
39
50
|
disabled,
|
|
40
|
-
checkboxSize,
|
|
41
|
-
checkboxStyle,
|
|
42
|
-
checkboxLabelStyle,
|
|
51
|
+
checkboxSize, // kept for backwards compatibility
|
|
52
|
+
checkboxStyle, // kept for backwards compatibility
|
|
53
|
+
checkboxLabelStyle, // kept for backwards compatibility
|
|
54
|
+
checkboxComponentStyles,
|
|
43
55
|
listHeaderComponent,
|
|
44
56
|
listFooterComponent,
|
|
57
|
+
listComponentStyles,
|
|
45
58
|
modalProps,
|
|
46
59
|
hideModal = false,
|
|
47
60
|
...rest
|
|
48
61
|
}) => {
|
|
49
|
-
const [newOptions, setNewOptions] = useState<
|
|
62
|
+
const [newOptions, setNewOptions] = useState<TFlatList | TSectionList>([]);
|
|
50
63
|
const [open, setOpen] = useState<boolean>(false);
|
|
51
64
|
const [selectAll, setSelectAll] = useState<boolean>(false);
|
|
52
65
|
const [selectedItem, setSelectedItem] = useState<any>(''); //for single selection
|
|
@@ -57,18 +70,38 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
57
70
|
if (options) {
|
|
58
71
|
setNewOptions(options);
|
|
59
72
|
}
|
|
73
|
+
return () => {};
|
|
60
74
|
}, [options]);
|
|
61
75
|
|
|
62
76
|
useEffect(() => {
|
|
63
77
|
isMultiple
|
|
64
78
|
? setSelectedItems(Array.isArray(selectedValue) ? selectedValue : [])
|
|
65
79
|
: setSelectedItem(selectedValue);
|
|
80
|
+
|
|
81
|
+
return () => {};
|
|
66
82
|
}, [selectedValue, isMultiple, onValueChange]);
|
|
67
83
|
|
|
84
|
+
/*===========================================
|
|
85
|
+
* List type
|
|
86
|
+
*==========================================*/
|
|
87
|
+
|
|
88
|
+
const isSectionList = newOptions.some(
|
|
89
|
+
(item) => item.title && item.data && Array.isArray(item.data)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const ListTypeComponent = isSectionList
|
|
93
|
+
? DropdownSectionList
|
|
94
|
+
: DropdownFlatList;
|
|
95
|
+
let modifiedSectionData = extractPropertyFromArray(newOptions, 'data').flat();
|
|
96
|
+
let modifiedOptions = isSectionList ? modifiedSectionData : newOptions;
|
|
97
|
+
|
|
98
|
+
const optLabel = optionLabel || DEFAULT_OPTION_LABEL;
|
|
99
|
+
const optValue = optionValue || DEFAULT_OPTION_VALUE;
|
|
100
|
+
|
|
68
101
|
/*===========================================
|
|
69
102
|
* Selection handlers
|
|
70
103
|
*==========================================*/
|
|
71
|
-
const handleSingleSelection = (value:
|
|
104
|
+
const handleSingleSelection = (value: string | number) => {
|
|
72
105
|
if (selectedItem === value) {
|
|
73
106
|
setSelectedItem(null);
|
|
74
107
|
onValueChange(null); //send value to parent
|
|
@@ -79,7 +112,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
79
112
|
}
|
|
80
113
|
};
|
|
81
114
|
|
|
82
|
-
const handleMultipleSelections = (value:
|
|
115
|
+
const handleMultipleSelections = (value: string[] | number[]) => {
|
|
83
116
|
setSelectedItems((prevVal) => {
|
|
84
117
|
let selectedValues = [...prevVal];
|
|
85
118
|
|
|
@@ -94,8 +127,8 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
94
127
|
|
|
95
128
|
//select all checkbox should not be checked if the list contains disabled values
|
|
96
129
|
if (
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
modifiedOptions.filter((item: TFlatListItem) => !item.disabled)
|
|
131
|
+
.length === selectedValues.length
|
|
99
132
|
) {
|
|
100
133
|
setSelectAll(true);
|
|
101
134
|
} else {
|
|
@@ -108,10 +141,15 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
108
141
|
const handleSelectAll = () => {
|
|
109
142
|
setSelectAll((prevVal) => {
|
|
110
143
|
const selectedValues = [];
|
|
111
|
-
|
|
144
|
+
|
|
145
|
+
//don't select disabled items
|
|
146
|
+
const filteredOptions = modifiedOptions.filter(
|
|
147
|
+
(item: TFlatListItem) => !item.disabled
|
|
148
|
+
);
|
|
149
|
+
|
|
112
150
|
if (!prevVal) {
|
|
113
151
|
for (let i = 0; i < filteredOptions.length; i++) {
|
|
114
|
-
selectedValues.push(filteredOptions[i][
|
|
152
|
+
selectedValues.push(filteredOptions[i][optValue]);
|
|
115
153
|
}
|
|
116
154
|
}
|
|
117
155
|
|
|
@@ -127,24 +165,20 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
127
165
|
const getSelectedItemsLabel = () => {
|
|
128
166
|
if (isMultiple && Array.isArray(selectedItems)) {
|
|
129
167
|
let selectedLabels: Array<string> = [];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)?.[optionLabel];
|
|
168
|
+
|
|
169
|
+
selectedItems?.forEach((element: number | string) => {
|
|
170
|
+
let selectedItemLabel = modifiedOptions?.find(
|
|
171
|
+
(item: TFlatListItem) => item[optValue] === element
|
|
172
|
+
)?.[optLabel];
|
|
136
173
|
selectedLabels.push(selectedItemLabel);
|
|
137
174
|
});
|
|
138
175
|
return selectedLabels;
|
|
139
176
|
}
|
|
140
177
|
|
|
141
|
-
let selectedItemLabel =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem
|
|
146
|
-
);
|
|
147
|
-
return selectedItemLabel?.[optionLabel ?? DEFAULT_OPTION_LABEL];
|
|
178
|
+
let selectedItemLabel = modifiedOptions?.find(
|
|
179
|
+
(item: TFlatListItem) => item[optValue] === selectedItem
|
|
180
|
+
);
|
|
181
|
+
return selectedItemLabel?.[optLabel];
|
|
148
182
|
};
|
|
149
183
|
|
|
150
184
|
/*===========================================
|
|
@@ -157,22 +191,47 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
157
191
|
|
|
158
192
|
const regexFilter = new RegExp(searchText, 'i');
|
|
159
193
|
|
|
160
|
-
|
|
194
|
+
//Because Search mutates the initial state, we have to search with a copy of the original array
|
|
195
|
+
const optionsCopy = JSON.parse(JSON.stringify(options));
|
|
196
|
+
const searchResults = isSectionList
|
|
197
|
+
? searchSectionList(optionsCopy as TSectionList, regexFilter)
|
|
198
|
+
: searchFlatList(optionsCopy as TFlatList, regexFilter);
|
|
199
|
+
|
|
200
|
+
setNewOptions(searchResults);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const searchFlatList = (flatList: TFlatList, regexFilter: RegExp) => {
|
|
204
|
+
const searchResults = flatList.filter((item: TFlatListItem) => {
|
|
161
205
|
if (
|
|
162
|
-
item[
|
|
163
|
-
|
|
164
|
-
.toLowerCase()
|
|
165
|
-
.search(regexFilter) !== -1 ||
|
|
166
|
-
item[optionValue ?? DEFAULT_OPTION_VALUE]
|
|
167
|
-
.toString(regexFilter)
|
|
168
|
-
.toLowerCase()
|
|
169
|
-
.search(regexFilter) !== -1
|
|
206
|
+
item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||
|
|
207
|
+
item[optValue].toString().toLowerCase().search(regexFilter) !== -1
|
|
170
208
|
) {
|
|
171
209
|
return item;
|
|
172
210
|
}
|
|
211
|
+
return;
|
|
173
212
|
});
|
|
213
|
+
return searchResults;
|
|
214
|
+
};
|
|
174
215
|
|
|
175
|
-
|
|
216
|
+
const searchSectionList = (
|
|
217
|
+
sectionList: TSectionList,
|
|
218
|
+
regexFilter: RegExp
|
|
219
|
+
) => {
|
|
220
|
+
const searchResults = sectionList.map((listItem: TSectionListItem) => {
|
|
221
|
+
listItem.data = listItem.data.filter((item: TFlatListItem) => {
|
|
222
|
+
if (
|
|
223
|
+
item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||
|
|
224
|
+
item[optValue].toString().toLowerCase().search(regexFilter) !== -1
|
|
225
|
+
) {
|
|
226
|
+
return listItem.data.push(item);
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return listItem;
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return searchResults;
|
|
176
235
|
};
|
|
177
236
|
|
|
178
237
|
/*===========================================
|
|
@@ -188,9 +247,20 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
188
247
|
if (hideModal) {
|
|
189
248
|
setOpen(false);
|
|
190
249
|
}
|
|
250
|
+
return () => {};
|
|
191
251
|
}, [hideModal]);
|
|
192
252
|
|
|
193
253
|
let primary = primaryColor || colors.gray;
|
|
254
|
+
|
|
255
|
+
const sectionListMaxLength = getMaxLengthOfSectionListProperty(
|
|
256
|
+
newOptions as TSectionList,
|
|
257
|
+
'data'
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const listIsEmpty = isSectionList
|
|
261
|
+
? sectionListMaxLength > 1
|
|
262
|
+
: newOptions.length > 1;
|
|
263
|
+
|
|
194
264
|
return (
|
|
195
265
|
<>
|
|
196
266
|
<Dropdown
|
|
@@ -226,7 +296,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
226
296
|
onRequestClose={() => {}}
|
|
227
297
|
modalProps={modalProps}
|
|
228
298
|
>
|
|
229
|
-
<
|
|
299
|
+
<ListTypeComponent
|
|
230
300
|
ListHeaderComponent={
|
|
231
301
|
<>
|
|
232
302
|
{isSearchable && (
|
|
@@ -238,7 +308,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
238
308
|
/>
|
|
239
309
|
)}
|
|
240
310
|
{listHeaderComponent}
|
|
241
|
-
{isMultiple &&
|
|
311
|
+
{isMultiple && listIsEmpty && (
|
|
242
312
|
<View style={styles.optionsContainerStyle}>
|
|
243
313
|
<TouchableOpacity onPress={() => {}}>
|
|
244
314
|
<CheckBox
|
|
@@ -249,6 +319,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
249
319
|
checkboxSize={checkboxSize}
|
|
250
320
|
checkboxStyle={checkboxStyle}
|
|
251
321
|
checkboxLabelStyle={checkboxLabelStyle}
|
|
322
|
+
checkboxComponentStyles={checkboxComponentStyles}
|
|
252
323
|
/>
|
|
253
324
|
</TouchableOpacity>
|
|
254
325
|
</View>
|
|
@@ -256,9 +327,10 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
256
327
|
</>
|
|
257
328
|
}
|
|
258
329
|
ListFooterComponent={listFooterComponent}
|
|
330
|
+
listComponentStyles={listComponentStyles}
|
|
259
331
|
options={newOptions}
|
|
260
|
-
optionLabel={
|
|
261
|
-
optionValue={
|
|
332
|
+
optionLabel={optLabel}
|
|
333
|
+
optionValue={optValue}
|
|
262
334
|
isMultiple={isMultiple}
|
|
263
335
|
isSearchable={isSearchable}
|
|
264
336
|
selectedItems={selectedItems}
|
|
@@ -269,6 +341,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
|
|
|
269
341
|
checkboxSize={checkboxSize}
|
|
270
342
|
checkboxStyle={checkboxStyle}
|
|
271
343
|
checkboxLabelStyle={checkboxLabelStyle}
|
|
344
|
+
checkboxComponentStyles={checkboxComponentStyles}
|
|
272
345
|
/>
|
|
273
346
|
</CustomModal>
|
|
274
347
|
</>
|
package/src/types/index.types.ts
CHANGED
|
@@ -10,9 +10,9 @@ export type DropdownProps = {
|
|
|
10
10
|
label?: string;
|
|
11
11
|
error?: string;
|
|
12
12
|
helperText?: string;
|
|
13
|
-
options:
|
|
14
|
-
optionLabel
|
|
15
|
-
optionValue
|
|
13
|
+
options: TFlatList | TSectionList;
|
|
14
|
+
optionLabel?: string;
|
|
15
|
+
optionValue?: string;
|
|
16
16
|
onValueChange: Function;
|
|
17
17
|
selectedValue?:
|
|
18
18
|
| string
|
|
@@ -33,7 +33,7 @@ export type DropdownProps = {
|
|
|
33
33
|
dropdownErrorTextStyle?: TextStyle;
|
|
34
34
|
dropdownHelperTextStyle?: TextStyle;
|
|
35
35
|
selectedItemStyle?: TextStyle;
|
|
36
|
-
multipleSelectedItemStyle?:
|
|
36
|
+
multipleSelectedItemStyle?: TextStyle;
|
|
37
37
|
modalBackgroundStyle?: ViewStyle;
|
|
38
38
|
modalOptionsContainerStyle?: ViewStyle;
|
|
39
39
|
searchInputStyle?: ViewStyle;
|
|
@@ -42,9 +42,27 @@ export type DropdownProps = {
|
|
|
42
42
|
checkboxSize?: number;
|
|
43
43
|
checkboxStyle?: ViewStyle;
|
|
44
44
|
checkboxLabelStyle?: TextStyle;
|
|
45
|
+
checkboxComponentStyles?: {
|
|
46
|
+
checkboxSize?: number;
|
|
47
|
+
checkboxStyle?: ViewStyle;
|
|
48
|
+
checkboxLabelStyle?: TextStyle;
|
|
49
|
+
};
|
|
45
50
|
placeholderStyle?: TextStyle;
|
|
46
51
|
listHeaderComponent?: React.ReactNode;
|
|
47
52
|
listFooterComponent?: React.ReactNode;
|
|
48
53
|
hideModal?: boolean;
|
|
49
54
|
modalProps?: ModalProps;
|
|
55
|
+
listComponentStyles?: {
|
|
56
|
+
listEmptyComponentStyle?: TextStyle;
|
|
57
|
+
itemSeparatorStyle?: ViewStyle;
|
|
58
|
+
sectionHeaderStyle?: TextStyle;
|
|
59
|
+
};
|
|
50
60
|
};
|
|
61
|
+
|
|
62
|
+
export type TFlatList = TFlatListItem[];
|
|
63
|
+
export type TFlatListItem = {
|
|
64
|
+
[key: string]: string | number | boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type TSectionList = TSectionListItem[];
|
|
68
|
+
export type TSectionListItem = { title: string; data: TFlatList };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TSectionList } from 'src/types/index.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract property from array
|
|
5
|
+
*/
|
|
6
|
+
export const extractPropertyFromArray = (arr: any, property: string) => {
|
|
7
|
+
let extractedValue = arr.map((item: any) => item[property]);
|
|
8
|
+
|
|
9
|
+
return extractedValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getMaxLengthOfSectionListProperty = (
|
|
13
|
+
sectionList: TSectionList,
|
|
14
|
+
property: 'title' | 'data'
|
|
15
|
+
) => {
|
|
16
|
+
let maxLength = 0;
|
|
17
|
+
|
|
18
|
+
sectionList.forEach((obj) => {
|
|
19
|
+
if (obj[property]?.length > maxLength) {
|
|
20
|
+
maxLength = obj.data.length;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return maxLength;
|
|
25
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["DropdownList.tsx"],"names":["DropdownList","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","rest","styles","emptyListStyle","paddingTop","contentContainerStyle","itemSeparatorStyle","item","_renderItem","selectedOption","onChange","_item","index","props","StyleSheet","create","backgroundColor","colors","gray","height","opacity","alignItems","width","marginVertical"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,YAAY,GAAG,QAeV;AAAA,MAfW;AACpBC,IAAAA,OADoB;AAEpBC,IAAAA,WAFoB;AAGpBC,IAAAA,WAHoB;AAIpBC,IAAAA,UAJoB;AAKpBC,IAAAA,YALoB;AAMpBC,IAAAA,aANoB;AAOpBC,IAAAA,YAPoB;AAQpBC,IAAAA,wBARoB;AASpBC,IAAAA,qBAToB;AAUpBC,IAAAA,YAVoB;AAWpBC,IAAAA,YAXoB;AAYpBC,IAAAA,aAZoB;AAapBC,IAAAA,kBAboB;AAcpB,OAAGC;AAdiB,GAeX;AACT,sBACE,6BAAC,qBAAD;AACE,IAAA,IAAI,EAAEb,OADR;AAEE,IAAA,SAAS,EAAEG,UAAU,GAAGE,aAAH,GAAmBC,YAF1C;AAGE,IAAA,kBAAkB,EAAE,CAHtB;AAIE,IAAA,kBAAkB,eAChB,6BAAC,iBAAD;AAAM,MAAA,KAAK,E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EAAEe,KAAK,CAACd,aATvB;AAUE,IAAA,kBAAkB,EAAEc,KAAK,CAACb;AAV5B,IADF;AAcD,CAfD;;AAiBA,MAAME,MAAM,GAAGY,wBAAWC,MAAX,CAAkB;AAC/BT,EAAAA,kBAAkB,EAAE;AAClBU,IAAAA,eAAe,EAAEC,eAAOC,IADN;AAElBC,IAAAA,MAAM,EAAE,CAFU;AAGlBC,IAAAA,OAAO,EAAE;AAHS,GADW;AAM/BjB,EAAAA,cAAc,EAAE;AAAEkB,IAAAA,UAAU,EAAE,QAAd;AAAwBC,IAAAA,KAAK,EAAE,MAA/B;AAAuCC,IAAAA,cAAc,EAAE;AAAvD,GANe;AAO/BlB,EAAAA,qBAAqB,EAAE;AAAED,IAAAA,UAAU,EAAE;AAAd;AAPQ,CAAlB,CAAf;;eAUejB,Y","sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React from 'react';\nimport { View, FlatList, StyleSheet, Text } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { colors } from '../../styles/colors';\n\nconst DropdownList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n ...rest\n}: any) => {\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <View style={styles.emptyListStyle}>\n <Text>No options available</Text>\n </View>\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => <View style={styles.itemSeparatorStyle} />}\n renderItem={(item) =>\n _renderItem(item, {\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption: isMultiple ? selectedItems : selectedItem,\n onChange: isMultiple\n ? handleMultipleSelections\n : handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n })\n }\n keyExtractor={(_item, index) => `Options${index}`}\n {...rest}\n />\n );\n};\n\nconst _renderItem = ({ item }: any, props: any) => {\n return (\n <DropdownListItem\n item={item}\n optionLabel={props.optionLabel}\n optionValue={props.optionValue}\n isMultiple={props.isMultiple}\n selectedOption={props.selectedOption}\n onChange={props.onChange}\n primaryColor={props.primaryColor}\n checkboxSize={props.checkboxSize}\n checkboxStyle={props.checkboxStyle}\n checkboxLabelStyle={props.checkboxLabelStyle}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n itemSeparatorStyle: {\n backgroundColor: colors.gray,\n height: 1,\n opacity: 0.15,\n },\n emptyListStyle: { alignItems: 'center', width: '100%', marginVertical: 20 },\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownList;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["DropdownList.tsx"],"names":["React","View","FlatList","StyleSheet","Text","DropdownListItem","colors","DropdownList","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","rest","styles","emptyListStyle","paddingTop","contentContainerStyle","itemSeparatorStyle","item","_renderItem","selectedOption","onChange","_item","index","props","create","backgroundColor","gray","height","opacity","alignItems","width","marginVertical"],"mappings":";;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,UAAzB,EAAqCC,IAArC,QAAiD,cAAjD;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,SAASC,MAAT,QAAuB,qBAAvB;;AAEA,MAAMC,YAAY,GAAG,QAeV;AAAA,MAfW;AACpBC,IAAAA,OADoB;AAEpBC,IAAAA,WAFoB;AAGpBC,IAAAA,WAHoB;AAIpBC,IAAAA,UAJoB;AAKpBC,IAAAA,YALoB;AAMpBC,IAAAA,aANoB;AAOpBC,IAAAA,YAPoB;AAQpBC,IAAAA,wBARoB;AASpBC,IAAAA,q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AA,WAAW,EAAEM,KAAK,CAACxB,WAFrB;AAGE,IAAA,WAAW,EAAEwB,KAAK,CAACvB,WAHrB;AAIE,IAAA,UAAU,EAAEuB,KAAK,CAACtB,UAJpB;AAKE,IAAA,cAAc,EAAEsB,KAAK,CAACJ,cALxB;AAME,IAAA,QAAQ,EAAEI,KAAK,CAACH,QANlB;AAOE,IAAA,YAAY,EAAEG,KAAK,CAAChB,YAPtB;AAQE,IAAA,YAAY,EAAEgB,KAAK,CAACf,YARtB;AASE,IAAA,aAAa,EAAEe,KAAK,CAACd,aATvB;AAUE,IAAA,kBAAkB,EAAEc,KAAK,CAACb;AAV5B,IADF;AAcD,CAfD;;AAiBA,MAAME,MAAM,GAAGnB,UAAU,CAAC+B,MAAX,CAAkB;AAC/BR,EAAAA,kBAAkB,EAAE;AAClBS,IAAAA,eAAe,EAAE7B,MAAM,CAAC8B,IADN;AAElBC,IAAAA,MAAM,EAAE,CAFU;AAGlBC,IAAAA,OAAO,EAAE;AAHS,GADW;AAM/Bf,EAAAA,cAAc,EAAE;AAAEgB,IAAAA,UAAU,EAAE,QAAd;AAAwBC,IAAAA,KAAK,EAAE,MAA/B;AAAuCC,IAAAA,cAAc,EAAE;AAAvD,GANe;AAO/BhB,EAAAA,qBAAqB,EAAE;AAAED,IAAAA,UAAU,EAAE;AAAd;AAPQ,CAAlB,CAAf;AAUA,eAAejB,YAAf","sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React from 'react';\nimport { View, FlatList, StyleSheet, Text } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { colors } from '../../styles/colors';\n\nconst DropdownList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n ...rest\n}: any) => {\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <View style={styles.emptyListStyle}>\n <Text>No options available</Text>\n </View>\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => <View style={styles.itemSeparatorStyle} />}\n renderItem={(item) =>\n _renderItem(item, {\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption: isMultiple ? selectedItems : selectedItem,\n onChange: isMultiple\n ? handleMultipleSelections\n : handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n })\n }\n keyExtractor={(_item, index) => `Options${index}`}\n {...rest}\n />\n );\n};\n\nconst _renderItem = ({ item }: any, props: any) => {\n return (\n <DropdownListItem\n item={item}\n optionLabel={props.optionLabel}\n optionValue={props.optionValue}\n isMultiple={props.isMultiple}\n selectedOption={props.selectedOption}\n onChange={props.onChange}\n primaryColor={props.primaryColor}\n checkboxSize={props.checkboxSize}\n checkboxStyle={props.checkboxStyle}\n checkboxLabelStyle={props.checkboxLabelStyle}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n itemSeparatorStyle: {\n backgroundColor: colors.gray,\n height: 1,\n opacity: 0.15,\n },\n emptyListStyle: { alignItems: 'center', width: '100%', marginVertical: 20 },\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownList;\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const DropdownList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, ...rest }: any) => JSX.Element;
|
|
3
|
-
export default DropdownList;
|