react-native-input-select 1.1.1 → 1.1.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/README.md +18 -0
- package/lib/commonjs/components/CheckBox/index.js +20 -9
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CheckBox/types.js.map +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +4 -2
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js +34 -6
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +4 -2
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js +29 -2
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +41 -9
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/index.js +64 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/module/components/CheckBox/index.js +20 -8
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CheckBox/types.js.map +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +4 -2
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownFlatList.js +32 -6
- package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownListItem.js +4 -2
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSectionList.js +30 -3
- package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +42 -10
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/index.js +65 -17
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/typescript/components/CheckBox/index.d.ts +17 -5
- package/lib/typescript/components/CheckBox/types.d.ts +2 -0
- package/lib/typescript/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +1 -1
- package/lib/typescript/types/index.types.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/CheckBox/index.tsx +42 -22
- package/src/components/CheckBox/types.ts +2 -0
- package/src/components/Dropdown/Dropdown.tsx +3 -0
- package/src/components/Dropdown/DropdownFlatList.tsx +27 -1
- package/src/components/Dropdown/DropdownListItem.tsx +2 -0
- package/src/components/Dropdown/DropdownSectionList.tsx +30 -1
- package/src/components/Dropdown/DropdownSelectedItemsView.tsx +32 -13
- package/src/index.tsx +64 -18
- package/src/types/index.types.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","_input","obj","__esModule","default","DropdownSelectedItemsView","_ref","_getSelectedItemsLabe","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","dropdownStyle","dropdownIconStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","createElement","Pressable","onPress","style","_ref2","pressed","inputStyles","inputFocusState","borderColor","input","inputFocusErrorState","ScrollView","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","View","styles","selectedItemsContainer","onStartShouldSetResponder","map","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","_input","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","DropdownSelectedItemsView","_ref","_getSelectedItemsLabe","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","dropdownStyle","dropdownIconStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","setIndexOfSelectedItem","createElement","Pressable","onPress","style","_ref2","pressed","inputStyles","inputFocusState","borderColor","input","inputFocusErrorState","ScrollView","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","View","styles","selectedItemsContainer","onStartShouldSetResponder","map","label","DropdownContent","Math","random","backgroundColor","blackText","iconStyle","Image","_ref3","rest","TouchableOpacity","Text","StyleSheet","create","position","right","top","flexDirection","flexWrap","alignItems","color","colors","white","paddingHorizontal","paddingVertical","borderRadius","primary","marginRight","overflow","black","_default","exports"],"sources":["DropdownSelectedItemsView.tsx"],"sourcesContent":["import React from 'react';\nimport {\n View,\n Text,\n Pressable,\n ScrollView,\n StyleSheet,\n Image,\n TouchableOpacity,\n} from 'react-native';\nimport { colors } from '../../styles/colors';\nimport { inputStyles } from '../../styles/input';\n\nconst DropdownSelectedItemsView = ({\n placeholder,\n error,\n getSelectedItemsLabel,\n handleToggleModal,\n isMultiple,\n selectedItem,\n selectedItems,\n dropdownIcon,\n dropdownStyle,\n dropdownIconStyle,\n selectedItemStyle,\n placeholderStyle,\n multipleSelectedItemStyle,\n dropdownErrorStyle,\n primaryColor,\n disabled,\n setIndexOfSelectedItem,\n}: any) => {\n return (\n <Pressable\n onPress={() => handleToggleModal()}\n style={({ pressed }) => [\n pressed && {\n ...inputStyles.inputFocusState,\n borderColor: primaryColor,\n },\n { ...inputStyles.input, ...dropdownStyle },\n error && //this must be last\n error !== '' &&\n !pressed && {\n ...inputStyles.inputFocusErrorState,\n ...dropdownErrorStyle,\n },\n ]}\n disabled={disabled}\n >\n <ScrollView\n horizontal\n alwaysBounceHorizontal\n showsHorizontalScrollIndicator={false}\n >\n <View\n style={styles.selectedItemsContainer}\n onStartShouldSetResponder={() => true}\n >\n {isMultiple ? (\n getSelectedItemsLabel()?.map((label: string, i: Number) => (\n <DropdownContent\n onPress={() => {\n handleToggleModal();\n setIndexOfSelectedItem(label); // immediately scrolls to list item with the specified label when modal\n }}\n key={`react-native-input-select-${Math.random()}-${i}`}\n style={[\n styles.selectedItems,\n { backgroundColor: primaryColor },\n multipleSelectedItemStyle,\n ]}\n label={label}\n />\n ))\n ) : (\n <DropdownContent\n onPress={() => {\n handleToggleModal();\n setIndexOfSelectedItem(getSelectedItemsLabel()); // immediately scrolls to list item with the specified label when modal\n }}\n style={[styles.blackText, selectedItemStyle]}\n label={getSelectedItemsLabel()}\n />\n )}\n {!selectedItem && selectedItems?.length === 0 && (\n <DropdownContent\n onPress={() => handleToggleModal()}\n style={[styles.blackText, placeholderStyle]}\n label={placeholder ?? 'Select an option'}\n />\n )}\n </View>\n </ScrollView>\n <View style={[styles.iconStyle, dropdownIconStyle]}>\n {dropdownIcon || (\n <Image source={require('../../asset/arrow-down.png')} />\n )}\n </View>\n </Pressable>\n );\n};\n\nconst DropdownContent = ({ onPress, style, label, ...rest }: any) => {\n return (\n <TouchableOpacity onPress={() => onPress()} {...rest}>\n <Text style={style}>{label}</Text>\n </TouchableOpacity>\n );\n};\n\nconst styles = StyleSheet.create({\n iconStyle: { position: 'absolute', right: 25, top: 25 },\n selectedItemsContainer: {\n flexDirection: 'row',\n flexWrap: 'nowrap',\n alignItems: 'center',\n },\n selectedItems: {\n color: colors.white,\n paddingHorizontal: 10,\n paddingVertical: 5,\n borderRadius: 10,\n backgroundColor: colors.primary,\n marginRight: 10,\n overflow: 'hidden',\n },\n blackText: { color: colors.black },\n});\n\nexport default DropdownSelectedItemsView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAi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,QAAQ,EAAE,UAAU;IAAEC,KAAK,EAAE,EAAE;IAAEC,GAAG,EAAE;EAAG,CAAC;EACvDnB,sBAAsB,EAAE;IACtBoB,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,QAAQ;IAClBC,UAAU,EAAE;EACd,CAAC;EACDlD,aAAa,EAAE;IACbmD,KAAK,EAAEC,cAAM,CAACC,KAAK;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,CAAC;IAClBC,YAAY,EAAE,EAAE;IAChBrB,eAAe,EAAEiB,cAAM,CAACK,OAAO;IAC/BC,WAAW,EAAE,EAAE;IACfC,QAAQ,EAAE;EACZ,CAAC;EACDvB,SAAS,EAAE;IAAEe,KAAK,EAAEC,cAAM,CAACQ;EAAM;AACnC,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEYtE,yBAAyB;AAAAuE,OAAA,CAAAtF,OAAA,GAAAqF,QAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -55,6 +55,7 @@ const DropdownSelect = _ref => {
|
|
|
55
55
|
checkboxLabelStyle,
|
|
56
56
|
// kept for backwards compatibility
|
|
57
57
|
checkboxComponentStyles,
|
|
58
|
+
checkboxComponent,
|
|
58
59
|
listHeaderComponent,
|
|
59
60
|
listFooterComponent,
|
|
60
61
|
listComponentStyles,
|
|
@@ -65,9 +66,13 @@ const DropdownSelect = _ref => {
|
|
|
65
66
|
const [newOptions, setNewOptions] = (0, _react.useState)([]);
|
|
66
67
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
67
68
|
const [selectAll, setSelectAll] = (0, _react.useState)(false);
|
|
68
|
-
const [selectedItem, setSelectedItem] = (0, _react.useState)(''); //for single selection
|
|
69
|
-
const [selectedItems, setSelectedItems] = (0, _react.useState)([]); //for multiple selection
|
|
69
|
+
const [selectedItem, setSelectedItem] = (0, _react.useState)(''); // for single selection
|
|
70
|
+
const [selectedItems, setSelectedItems] = (0, _react.useState)([]); // for multiple selection
|
|
70
71
|
const [searchValue, setSearchValue] = (0, _react.useState)('');
|
|
72
|
+
const [listIndex, setListIndex] = (0, _react.useState)({
|
|
73
|
+
itemIndex: 0
|
|
74
|
+
}); // for scrollToIndex in Sectionlist and Flatlist
|
|
75
|
+
|
|
71
76
|
(0, _react.useEffect)(() => {
|
|
72
77
|
if (options) {
|
|
73
78
|
setNewOptions(options);
|
|
@@ -85,10 +90,11 @@ const DropdownSelect = _ref => {
|
|
|
85
90
|
|
|
86
91
|
const isSectionList = newOptions.some(item => item.title && item.data && Array.isArray(item.data));
|
|
87
92
|
const ListTypeComponent = isSectionList ? _DropdownSectionList.default : _DropdownFlatList.default;
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
const modifiedSectionData = (0, _utils.extractPropertyFromArray)(newOptions, 'data').flat();
|
|
94
|
+
const modifiedOptions = isSectionList ? modifiedSectionData : newOptions;
|
|
90
95
|
const optLabel = optionLabel || _constants.DEFAULT_OPTION_LABEL;
|
|
91
96
|
const optValue = optionValue || _constants.DEFAULT_OPTION_VALUE;
|
|
97
|
+
const optionsCopy = JSON.parse(JSON.stringify(options)); //copy of the original options array
|
|
92
98
|
|
|
93
99
|
/*===========================================
|
|
94
100
|
* Selection handlers
|
|
@@ -113,15 +119,7 @@ const DropdownSelect = _ref => {
|
|
|
113
119
|
} else {
|
|
114
120
|
selectedValues.push(value);
|
|
115
121
|
}
|
|
116
|
-
setSelectedItems(selectedValues);
|
|
117
122
|
onValueChange(selectedValues); //send value to parent
|
|
118
|
-
|
|
119
|
-
//select all checkbox should not be checked if the list contains disabled values
|
|
120
|
-
if (modifiedOptions.filter(item => !item.disabled).length === selectedValues.length) {
|
|
121
|
-
setSelectAll(true);
|
|
122
|
-
} else {
|
|
123
|
-
setSelectAll(false);
|
|
124
|
-
}
|
|
125
123
|
return selectedValues;
|
|
126
124
|
});
|
|
127
125
|
};
|
|
@@ -142,6 +140,26 @@ const DropdownSelect = _ref => {
|
|
|
142
140
|
});
|
|
143
141
|
};
|
|
144
142
|
|
|
143
|
+
/*===========================================
|
|
144
|
+
* Handle side effects
|
|
145
|
+
*==========================================*/
|
|
146
|
+
const checkSelectAll = (0, _react.useCallback)(selectedValues => {
|
|
147
|
+
//if the list contains disabled values, those values will not be selected
|
|
148
|
+
if (modifiedOptions.filter(item => !item.disabled).length === selectedValues.length) {
|
|
149
|
+
setSelectAll(true);
|
|
150
|
+
} else {
|
|
151
|
+
setSelectAll(false);
|
|
152
|
+
}
|
|
153
|
+
}, [modifiedOptions]);
|
|
154
|
+
|
|
155
|
+
// anytime the selected items change, check if it is time to set `selectAll` to true
|
|
156
|
+
(0, _react.useEffect)(() => {
|
|
157
|
+
if (isMultiple) {
|
|
158
|
+
checkSelectAll(selectedItems);
|
|
159
|
+
}
|
|
160
|
+
return () => {};
|
|
161
|
+
}, [checkSelectAll, isMultiple, selectedItems]);
|
|
162
|
+
|
|
145
163
|
/*===========================================
|
|
146
164
|
* Get label handler
|
|
147
165
|
*==========================================*/
|
|
@@ -168,7 +186,6 @@ const DropdownSelect = _ref => {
|
|
|
168
186
|
const regexFilter = new RegExp(searchText, 'i');
|
|
169
187
|
|
|
170
188
|
//Because Search mutates the initial state, we have to search with a copy of the original array
|
|
171
|
-
const optionsCopy = JSON.parse(JSON.stringify(options));
|
|
172
189
|
const searchResults = isSectionList ? searchSectionList(optionsCopy, regexFilter) : searchFlatList(optionsCopy, regexFilter);
|
|
173
190
|
setNewOptions(searchResults);
|
|
174
191
|
};
|
|
@@ -201,6 +218,10 @@ const DropdownSelect = _ref => {
|
|
|
201
218
|
setOpen(!open);
|
|
202
219
|
setSearchValue('');
|
|
203
220
|
setNewOptions(options);
|
|
221
|
+
setListIndex({
|
|
222
|
+
itemIndex: 0,
|
|
223
|
+
sectionIndex: 0
|
|
224
|
+
});
|
|
204
225
|
};
|
|
205
226
|
(0, _react.useEffect)(() => {
|
|
206
227
|
if (hideModal) {
|
|
@@ -211,6 +232,29 @@ const DropdownSelect = _ref => {
|
|
|
211
232
|
let primary = primaryColor || _colors.colors.gray;
|
|
212
233
|
const sectionListMaxLength = (0, _utils.getMaxLengthOfSectionListProperty)(newOptions, 'data');
|
|
213
234
|
const listIsEmpty = isSectionList ? sectionListMaxLength > 1 : newOptions.length > 1;
|
|
235
|
+
|
|
236
|
+
/*===========================================
|
|
237
|
+
* setIndexOfSelectedItem - For ScrollToIndex
|
|
238
|
+
*==========================================*/
|
|
239
|
+
const setIndexOfSelectedItem = selectedLabel => {
|
|
240
|
+
isSectionList ? optionsCopy.map((item, sectionIndex) => {
|
|
241
|
+
var _item$data;
|
|
242
|
+
(_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.find((dataItem, itemIndex) => {
|
|
243
|
+
if (dataItem[optLabel] === selectedLabel) {
|
|
244
|
+
setListIndex({
|
|
245
|
+
sectionIndex,
|
|
246
|
+
itemIndex
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}) : optionsCopy === null || optionsCopy === void 0 ? void 0 : optionsCopy.find((item, itemIndex) => {
|
|
251
|
+
if (item[optLabel] === selectedLabel) {
|
|
252
|
+
setListIndex({
|
|
253
|
+
itemIndex
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
};
|
|
214
258
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Dropdown.default, _extends({
|
|
215
259
|
label: label,
|
|
216
260
|
placeholder: placeholder,
|
|
@@ -233,7 +277,8 @@ const DropdownSelect = _ref => {
|
|
|
233
277
|
isMultiple: isMultiple,
|
|
234
278
|
primaryColor: primary,
|
|
235
279
|
disabled: disabled,
|
|
236
|
-
placeholderStyle: placeholderStyle
|
|
280
|
+
placeholderStyle: placeholderStyle,
|
|
281
|
+
setIndexOfSelectedItem: setIndexOfSelectedItem
|
|
237
282
|
}, rest)), /*#__PURE__*/_react.default.createElement(_CustomModal.default, {
|
|
238
283
|
open: open,
|
|
239
284
|
handleToggleModal: handleToggleModal,
|
|
@@ -259,7 +304,8 @@ const DropdownSelect = _ref => {
|
|
|
259
304
|
checkboxSize: checkboxSize,
|
|
260
305
|
checkboxStyle: checkboxStyle,
|
|
261
306
|
checkboxLabelStyle: checkboxLabelStyle,
|
|
262
|
-
checkboxComponentStyles: checkboxComponentStyles
|
|
307
|
+
checkboxComponentStyles: checkboxComponentStyles,
|
|
308
|
+
checkboxComponent: checkboxComponent
|
|
263
309
|
})))),
|
|
264
310
|
ListFooterComponent: listFooterComponent,
|
|
265
311
|
listComponentStyles: listComponentStyles,
|
|
@@ -276,7 +322,9 @@ const DropdownSelect = _ref => {
|
|
|
276
322
|
checkboxSize: checkboxSize,
|
|
277
323
|
checkboxStyle: checkboxStyle,
|
|
278
324
|
checkboxLabelStyle: checkboxLabelStyle,
|
|
279
|
-
checkboxComponentStyles: checkboxComponentStyles
|
|
325
|
+
checkboxComponentStyles: checkboxComponentStyles,
|
|
326
|
+
checkboxComponent: checkboxComponent,
|
|
327
|
+
listIndex: listIndex
|
|
280
328
|
})));
|
|
281
329
|
};
|
|
282
330
|
exports.DropdownSelect = DropdownSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_Input","_interopRequireDefault","_CheckBox","_Dropdown","_DropdownFlatList","_DropdownSectionList","_CustomModal","_colors","_constants","_utils","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownSelect","_ref","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","dropdownIcon","labelStyle","placeholderStyle","dropdownStyle","dropdownIconStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainerStyle","searchInputStyle","primaryColor","disabled","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","listHeaderComponent","listFooterComponent","listComponentStyles","modalProps","hideModal","rest","newOptions","setNewOptions","useState","open","setOpen","selectAll","setSelectAll","selectedItem","setSelectedItem","selectedItems","setSelectedItems","searchValue","setSearchValue","useEffect","Array","isArray","isSectionList","some","item","title","data","ListTypeComponent","DropdownSectionList","DropdownFlatList","modifiedSectionData","extractPropertyFromArray","flat","modifiedOptions","optLabel","DEFAULT_OPTION_LABEL","optValue","DEFAULT_OPTION_VALUE","handleSingleSelection","value","handleMultipleSelections","prevVal","_selectedValues","selectedValues","includes","filter","push","handleSelectAll","filteredOptions","getSelectedItemsLabel","selectedLabels","forEach","element","_modifiedOptions$find","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","optionsCopy","JSON","parse","stringify","searchResults","searchSectionList","searchFlatList","flatList","toLowerCase","search","sectionList","map","listItem","handleToggleModal","primary","colors","gray","sectionListMaxLength","getMaxLengthOfSectionListProperty","listIsEmpty","createElement","Fragment","onRequestClose","ListHeaderComponent","onChangeText","text","style","View","styles","optionsContainerStyle","TouchableOpacity","onPress","onChange","ListFooterComponent","exports","StyleSheet","create","paddingHorizontal","paddingVertical","flexDirection","_default"],"sources":["index.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { TouchableOpacity, StyleSheet, View } from 'react-native';\nimport Input from './components/Input';\nimport CheckBox from './components/CheckBox';\nimport Dropdown from './components/Dropdown/Dropdown';\nimport DropdownFlatList from './components/Dropdown/DropdownFlatList';\nimport DropdownSectionList from './components/Dropdown/DropdownSectionList';\nimport CustomModal from './components/CustomModal';\nimport { colors } from './styles/colors';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type {\n DropdownProps,\n TFlatList,\n TFlatListItem,\n TSectionList,\n TSectionListItem,\n} from './types/index.types';\nimport {\n extractPropertyFromArray,\n getMaxLengthOfSectionListProperty,\n} from './utils';\n\nexport const DropdownSelect: React.FC<DropdownProps> = ({\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n dropdownIcon,\n labelStyle,\n placeholderStyle,\n dropdownStyle,\n dropdownIconStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainerStyle,\n searchInputStyle,\n primaryColor,\n disabled,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles,\n listHeaderComponent,\n listFooterComponent,\n listComponentStyles,\n modalProps,\n hideModal = false,\n ...rest\n}) => {\n const [newOptions, setNewOptions] = useState<TFlatList | TSectionList>([]);\n const [open, setOpen] = useState<boolean>(false);\n const [selectAll, setSelectAll] = useState<boolean>(false);\n const [selectedItem, setSelectedItem] = useState<any>(''); //for single selection\n const [selectedItems, setSelectedItems] = useState<any[]>([]); //for multiple selection\n const [searchValue, setSearchValue] = useState<string>('');\n\n useEffect(() => {\n if (options) {\n setNewOptions(options);\n }\n return () => {};\n }, [options]);\n\n useEffect(() => {\n isMultiple\n ? setSelectedItems(Array.isArray(selectedValue) ? selectedValue : [])\n : setSelectedItem(selectedValue);\n\n return () => {};\n }, [selectedValue, isMultiple, onValueChange]);\n\n /*===========================================\n * List type\n *==========================================*/\n\n const isSectionList = newOptions.some(\n (item) => item.title && item.data && Array.isArray(item.data)\n );\n\n const ListTypeComponent = isSectionList\n ? DropdownSectionList\n : DropdownFlatList;\n let modifiedSectionData = extractPropertyFromArray(newOptions, 'data').flat();\n let modifiedOptions = isSectionList ? modifiedSectionData : newOptions;\n\n const optLabel = optionLabel || DEFAULT_OPTION_LABEL;\n const optValue = optionValue || DEFAULT_OPTION_VALUE;\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: string | number) => {\n if (selectedItem === value) {\n setSelectedItem(null);\n onValueChange(null); //send value to parent\n } else {\n setSelectedItem(value);\n onValueChange(value); //send value to parent\n setOpen(false); //close modal upon selection\n }\n };\n\n const handleMultipleSelections = (value: string[] | number[]) => {\n setSelectedItems((prevVal) => {\n let selectedValues = [...prevVal];\n\n if (selectedValues?.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n\n //select all checkbox should not be checked if the list contains disabled values\n if (\n modifiedOptions.filter((item: TFlatListItem) => !item.disabled)\n .length === selectedValues.length\n ) {\n setSelectAll(true);\n } else {\n setSelectAll(false);\n }\n return selectedValues;\n });\n };\n\n const handleSelectAll = () => {\n setSelectAll((prevVal) => {\n const selectedValues = [];\n\n //don't select disabled items\n const filteredOptions = modifiedOptions.filter(\n (item: TFlatListItem) => !item.disabled\n );\n\n if (!prevVal) {\n for (let i = 0; i < filteredOptions.length; i++) {\n selectedValues.push(filteredOptions[i][optValue]);\n }\n }\n\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n return !prevVal;\n });\n };\n\n /*===========================================\n * Get label handler\n *==========================================*/\n const getSelectedItemsLabel = () => {\n if (isMultiple && Array.isArray(selectedItems)) {\n let selectedLabels: Array<string> = [];\n\n selectedItems?.forEach((element: number | string) => {\n let selectedItemLabel = modifiedOptions?.find(\n (item: TFlatListItem) => item[optValue] === element\n )?.[optLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel = modifiedOptions?.find(\n (item: TFlatListItem) => item[optValue] === selectedItem\n );\n return selectedItemLabel?.[optLabel];\n };\n\n /*===========================================\n * Search\n *==========================================*/\n const onSearch = (value: string) => {\n setSearchValue(value);\n\n let searchText = value.toString().toLocaleLowerCase().trim();\n\n const regexFilter = new RegExp(searchText, 'i');\n\n //Because Search mutates the initial state, we have to search with a copy of the original array\n const optionsCopy = JSON.parse(JSON.stringify(options));\n const searchResults = isSectionList\n ? searchSectionList(optionsCopy as TSectionList, regexFilter)\n : searchFlatList(optionsCopy as TFlatList, regexFilter);\n\n setNewOptions(searchResults);\n };\n\n const searchFlatList = (flatList: TFlatList, regexFilter: RegExp) => {\n const searchResults = flatList.filter((item: TFlatListItem) => {\n if (\n item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||\n item[optValue].toString().toLowerCase().search(regexFilter) !== -1\n ) {\n return item;\n }\n return;\n });\n return searchResults;\n };\n\n const searchSectionList = (\n sectionList: TSectionList,\n regexFilter: RegExp\n ) => {\n const searchResults = sectionList.map((listItem: TSectionListItem) => {\n listItem.data = listItem.data.filter((item: TFlatListItem) => {\n if (\n item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||\n item[optValue].toString().toLowerCase().search(regexFilter) !== -1\n ) {\n return listItem.data.push(item);\n }\n return;\n });\n\n return listItem;\n });\n\n return searchResults;\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n };\n\n useEffect(() => {\n if (hideModal) {\n setOpen(false);\n }\n return () => {};\n }, [hideModal]);\n\n let primary = primaryColor || colors.gray;\n\n const sectionListMaxLength = getMaxLengthOfSectionListProperty(\n newOptions as TSectionList,\n 'data'\n );\n\n const listIsEmpty = isSectionList\n ? sectionListMaxLength > 1\n : newOptions.length > 1;\n\n return (\n <>\n <Dropdown\n label={label}\n placeholder={placeholder}\n helperText={helperText}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n handleToggleModal={handleToggleModal}\n labelStyle={labelStyle}\n dropdownIcon={dropdownIcon}\n dropdownStyle={dropdownStyle}\n dropdownIconStyle={dropdownIconStyle}\n dropdownContainerStyle={dropdownContainerStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n dropdownErrorTextStyle={dropdownErrorTextStyle}\n dropdownHelperTextStyle={dropdownHelperTextStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n isMultiple={isMultiple}\n primaryColor={primary}\n disabled={disabled}\n placeholderStyle={placeholderStyle}\n {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainerStyle={modalOptionsContainerStyle}\n onRequestClose={() => {}}\n modalProps={modalProps}\n >\n <ListTypeComponent\n ListHeaderComponent={\n <>\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primary}\n />\n )}\n {listHeaderComponent}\n {isMultiple && listIsEmpty && (\n <View style={styles.optionsContainerStyle}>\n <TouchableOpacity onPress={() => {}}>\n <CheckBox\n value={selectAll}\n label={selectAll ? 'Clear all' : 'Select all'}\n onChange={() => handleSelectAll()}\n primaryColor={primary}\n checkboxSize={checkboxSize}\n checkboxStyle={checkboxStyle}\n checkboxLabelStyle={checkboxLabelStyle}\n checkboxComponentStyles={checkboxComponentStyles}\n />\n </TouchableOpacity>\n </View>\n )}\n </>\n }\n ListFooterComponent={listFooterComponent}\n listComponentStyles={listComponentStyles}\n options={newOptions}\n optionLabel={optLabel}\n optionValue={optValue}\n isMultiple={isMultiple}\n isSearchable={isSearchable}\n selectedItems={selectedItems}\n selectedItem={selectedItem}\n handleMultipleSelections={handleMultipleSelections}\n handleSingleSelection={handleSingleSelection}\n primaryColor={primary}\n checkboxSize={checkboxSize}\n checkboxStyle={checkboxStyle}\n checkboxLabelStyle={checkboxLabelStyle}\n checkboxComponentStyles={checkboxComponentStyles}\n />\n </CustomModal>\n </>\n );\n};\n\nconst styles = StyleSheet.create({\n optionsContainerStyle: {\n paddingHorizontal: 20,\n paddingVertical: 10,\n flexDirection: 'row',\n },\n});\n\nexport default DropdownSelect;\n"],"m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BC,kBAAkB,EAAEA,kBAAmB;MACvCC,uBAAuB,EAAEA;IAAwB,CAClD,CACe,CACd,CAER,CACH;IACDiG,mBAAmB,EAAE/F,mBAAoB;IACzCC,mBAAmB,EAAEA,mBAAoB;IACzC7B,OAAO,EAAEiC,UAAW;IACpBhC,WAAW,EAAE4D,QAAS;IACtB3D,WAAW,EAAE6D,QAAS;IACtB1D,UAAU,EAAEA,UAAW;IACvBC,YAAY,EAAEA,YAAa;IAC3BoC,aAAa,EAAEA,aAAc;IAC7BF,YAAY,EAAEA,YAAa;IAC3B2B,wBAAwB,EAAEA,wBAAyB;IACnDF,qBAAqB,EAAEA,qBAAsB;IAC7C5C,YAAY,EAAEmF,OAAQ;IACtBjF,YAAY,EAAEA,YAAa;IAC3BC,aAAa,EAAEA,aAAc;IAC7BC,kBAAkB,EAAEA,kBAAmB;IACvCC,uBAAuB,EAAEA;EAAwB,CAClD,CACU,CACb,CAAC;AAEP,CAAC;AAACkG,OAAA,CAAAlI,cAAA,GAAAA,cAAA;AAEF,MAAM4H,MAAM,GAAGO,uBAAU,CAACC,MAAM,CAAC;EAC/BP,qBAAqB,EAAE;IACrBQ,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEYxI,cAAc;AAAAkI,OAAA,CAAA/J,OAAA,GAAAqK,QAAA"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_Input","_interopRequireDefault","_CheckBox","_Dropdown","_DropdownFlatList","_DropdownSectionList","_CustomModal","_colors","_constants","_utils","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownSelect","_ref","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","dropdownIcon","labelStyle","placeholderStyle","dropdownStyle","dropdownIconStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainerStyle","searchInputStyle","primaryColor","disabled","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","listHeaderComponent","listFooterComponent","listComponentStyles","modalProps","hideModal","rest","newOptions","setNewOptions","useState","open","setOpen","selectAll","setSelectAll","selectedItem","setSelectedItem","selectedItems","setSelectedItems","searchValue","setSearchValue","listIndex","setListIndex","itemIndex","useEffect","Array","isArray","isSectionList","some","item","title","data","ListTypeComponent","DropdownSectionList","DropdownFlatList","modifiedSectionData","extractPropertyFromArray","flat","modifiedOptions","optLabel","DEFAULT_OPTION_LABEL","optValue","DEFAULT_OPTION_VALUE","optionsCopy","JSON","parse","stringify","handleSingleSelection","value","handleMultipleSelections","prevVal","_selectedValues","selectedValues","includes","filter","push","handleSelectAll","filteredOptions","checkSelectAll","useCallback","getSelectedItemsLabel","selectedLabels","forEach","element","_modifiedOptions$find","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","searchResults","searchSectionList","searchFlatList","flatList","toLowerCase","search","sectionList","map","listItem","handleToggleModal","sectionIndex","primary","colors","gray","sectionListMaxLength","getMaxLengthOfSectionListProperty","listIsEmpty","setIndexOfSelectedItem","selectedLabel","_item$data","dataItem","createElement","Fragment","onRequestClose","ListHeaderComponent","onChangeText","text","style","View","styles","optionsContainerStyle","TouchableOpacity","onPress","onChange","ListFooterComponent","exports","StyleSheet","create","paddingHorizontal","paddingVertical","flexDirection","_default"],"sources":["index.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback } from 'react';\nimport { TouchableOpacity, StyleSheet, View } from 'react-native';\nimport Input from './components/Input';\nimport CheckBox from './components/CheckBox';\nimport Dropdown from './components/Dropdown/Dropdown';\nimport DropdownFlatList from './components/Dropdown/DropdownFlatList';\nimport DropdownSectionList from './components/Dropdown/DropdownSectionList';\nimport CustomModal from './components/CustomModal';\nimport { colors } from './styles/colors';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type {\n DropdownProps,\n TFlatList,\n TFlatListItem,\n TSectionList,\n TSectionListItem,\n} from './types/index.types';\nimport {\n extractPropertyFromArray,\n getMaxLengthOfSectionListProperty,\n} from './utils';\n\nexport const DropdownSelect: React.FC<DropdownProps> = ({\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n dropdownIcon,\n labelStyle,\n placeholderStyle,\n dropdownStyle,\n dropdownIconStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainerStyle,\n searchInputStyle,\n primaryColor,\n disabled,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles,\n checkboxComponent,\n listHeaderComponent,\n listFooterComponent,\n listComponentStyles,\n modalProps,\n hideModal = false,\n ...rest\n}) => {\n const [newOptions, setNewOptions] = useState<TFlatList | TSectionList>([]);\n const [open, setOpen] = useState<boolean>(false);\n const [selectAll, setSelectAll] = useState<boolean>(false);\n const [selectedItem, setSelectedItem] = useState<any>(''); // for single selection\n const [selectedItems, setSelectedItems] = useState<any[]>([]); // for multiple selection\n const [searchValue, setSearchValue] = useState<string>('');\n const [listIndex, setListIndex] = useState<{\n sectionIndex?: number;\n itemIndex: number;\n }>({ itemIndex: 0 }); // for scrollToIndex in Sectionlist and Flatlist\n\n useEffect(() => {\n if (options) {\n setNewOptions(options);\n }\n return () => {};\n }, [options]);\n\n useEffect(() => {\n isMultiple\n ? setSelectedItems(Array.isArray(selectedValue) ? selectedValue : [])\n : setSelectedItem(selectedValue);\n\n return () => {};\n }, [selectedValue, isMultiple, onValueChange]);\n\n /*===========================================\n * List type\n *==========================================*/\n\n const isSectionList = newOptions.some(\n (item) => item.title && item.data && Array.isArray(item.data)\n );\n\n const ListTypeComponent = isSectionList\n ? DropdownSectionList\n : DropdownFlatList;\n const modifiedSectionData = extractPropertyFromArray(\n newOptions,\n 'data'\n ).flat();\n const modifiedOptions = isSectionList ? modifiedSectionData : newOptions;\n\n const optLabel = optionLabel || DEFAULT_OPTION_LABEL;\n const optValue = optionValue || DEFAULT_OPTION_VALUE;\n const optionsCopy = JSON.parse(JSON.stringify(options)); //copy of the original options array\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: string | number) => {\n if (selectedItem === value) {\n setSelectedItem(null);\n onValueChange(null); //send value to parent\n } else {\n setSelectedItem(value);\n onValueChange(value); //send value to parent\n setOpen(false); //close modal upon selection\n }\n };\n\n const handleMultipleSelections = (value: string[] | number[]) => {\n setSelectedItems((prevVal) => {\n let selectedValues = [...prevVal];\n\n if (selectedValues?.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n onValueChange(selectedValues); //send value to parent\n return selectedValues;\n });\n };\n\n const handleSelectAll = () => {\n setSelectAll((prevVal) => {\n const selectedValues = [];\n\n //don't select disabled items\n const filteredOptions = modifiedOptions.filter(\n (item: TFlatListItem) => !item.disabled\n );\n\n if (!prevVal) {\n for (let i = 0; i < filteredOptions.length; i++) {\n selectedValues.push(filteredOptions[i][optValue]);\n }\n }\n\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n return !prevVal;\n });\n };\n\n /*===========================================\n * Handle side effects\n *==========================================*/\n const checkSelectAll = useCallback(\n (selectedValues: any[]) => {\n //if the list contains disabled values, those values will not be selected\n if (\n modifiedOptions.filter((item: TFlatListItem) => !item.disabled)\n .length === selectedValues.length\n ) {\n setSelectAll(true);\n } else {\n setSelectAll(false);\n }\n },\n [modifiedOptions]\n );\n\n // anytime the selected items change, check if it is time to set `selectAll` to true\n useEffect(() => {\n if (isMultiple) {\n checkSelectAll(selectedItems);\n }\n return () => {};\n }, [checkSelectAll, isMultiple, selectedItems]);\n\n /*===========================================\n * Get label handler\n *==========================================*/\n const getSelectedItemsLabel = () => {\n if (isMultiple && Array.isArray(selectedItems)) {\n let selectedLabels: Array<string> = [];\n\n selectedItems?.forEach((element: number | string) => {\n let selectedItemLabel = modifiedOptions?.find(\n (item: TFlatListItem) => item[optValue] === element\n )?.[optLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel = modifiedOptions?.find(\n (item: TFlatListItem) => item[optValue] === selectedItem\n );\n return selectedItemLabel?.[optLabel];\n };\n\n /*===========================================\n * Search\n *==========================================*/\n const onSearch = (value: string) => {\n setSearchValue(value);\n\n let searchText = value.toString().toLocaleLowerCase().trim();\n\n const regexFilter = new RegExp(searchText, 'i');\n\n //Because Search mutates the initial state, we have to search with a copy of the original array\n const searchResults = isSectionList\n ? searchSectionList(optionsCopy as TSectionList, regexFilter)\n : searchFlatList(optionsCopy as TFlatList, regexFilter);\n\n setNewOptions(searchResults);\n };\n\n const searchFlatList = (flatList: TFlatList, regexFilter: RegExp) => {\n const searchResults = flatList.filter((item: TFlatListItem) => {\n if (\n item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||\n item[optValue].toString().toLowerCase().search(regexFilter) !== -1\n ) {\n return item;\n }\n return;\n });\n return searchResults;\n };\n\n const searchSectionList = (\n sectionList: TSectionList,\n regexFilter: RegExp\n ) => {\n const searchResults = sectionList.map((listItem: TSectionListItem) => {\n listItem.data = listItem.data.filter((item: TFlatListItem) => {\n if (\n item[optLabel].toString().toLowerCase().search(regexFilter) !== -1 ||\n item[optValue].toString().toLowerCase().search(regexFilter) !== -1\n ) {\n return listItem.data.push(item);\n }\n return;\n });\n\n return listItem;\n });\n\n return searchResults;\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n setListIndex({ itemIndex: 0, sectionIndex: 0 });\n };\n\n useEffect(() => {\n if (hideModal) {\n setOpen(false);\n }\n return () => {};\n }, [hideModal]);\n\n let primary = primaryColor || colors.gray;\n\n const sectionListMaxLength = getMaxLengthOfSectionListProperty(\n newOptions as TSectionList,\n 'data'\n );\n\n const listIsEmpty = isSectionList\n ? sectionListMaxLength > 1\n : newOptions.length > 1;\n\n /*===========================================\n * setIndexOfSelectedItem - For ScrollToIndex\n *==========================================*/\n const setIndexOfSelectedItem = (selectedLabel: string) => {\n isSectionList\n ? optionsCopy.map((item: TSectionListItem, sectionIndex: number) => {\n item.data?.find((dataItem: TFlatListItem, itemIndex: number) => {\n if (dataItem[optLabel] === selectedLabel) {\n setListIndex({ sectionIndex, itemIndex });\n }\n });\n })\n : optionsCopy?.find((item: TFlatListItem, itemIndex: number) => {\n if (item[optLabel] === selectedLabel) {\n setListIndex({ itemIndex });\n }\n });\n };\n\n return (\n <>\n <Dropdown\n label={label}\n placeholder={placeholder}\n helperText={helperText}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n handleToggleModal={handleToggleModal}\n labelStyle={labelStyle}\n dropdownIcon={dropdownIcon}\n dropdownStyle={dropdownStyle}\n dropdownIconStyle={dropdownIconStyle}\n dropdownContainerStyle={dropdownContainerStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n dropdownErrorTextStyle={dropdownErrorTextStyle}\n dropdownHelperTextStyle={dropdownHelperTextStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n isMultiple={isMultiple}\n primaryColor={primary}\n disabled={disabled}\n placeholderStyle={placeholderStyle}\n setIndexOfSelectedItem={setIndexOfSelectedItem}\n {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainerStyle={modalOptionsContainerStyle}\n onRequestClose={() => {}}\n modalProps={modalProps}\n >\n <ListTypeComponent\n ListHeaderComponent={\n <>\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primary}\n />\n )}\n {listHeaderComponent}\n {isMultiple && listIsEmpty && (\n <View style={styles.optionsContainerStyle}>\n <TouchableOpacity onPress={() => {}}>\n <CheckBox\n value={selectAll}\n label={selectAll ? 'Clear all' : 'Select all'}\n onChange={() => handleSelectAll()}\n primaryColor={primary}\n checkboxSize={checkboxSize}\n checkboxStyle={checkboxStyle}\n checkboxLabelStyle={checkboxLabelStyle}\n checkboxComponentStyles={checkboxComponentStyles}\n checkboxComponent={checkboxComponent}\n />\n </TouchableOpacity>\n </View>\n )}\n </>\n }\n ListFooterComponent={listFooterComponent}\n listComponentStyles={listComponentStyles}\n options={newOptions}\n optionLabel={optLabel}\n optionValue={optValue}\n isMultiple={isMultiple}\n isSearchable={isSearchable}\n selectedItems={selectedItems}\n selectedItem={selectedItem}\n handleMultipleSelections={handleMultipleSelections}\n handleSingleSelection={handleSingleSelection}\n primaryColor={primary}\n checkboxSize={checkboxSize}\n checkboxStyle={checkboxStyle}\n checkboxLabelStyle={checkboxLabelStyle}\n checkboxComponentStyles={checkboxComponentStyles}\n checkboxComponent={checkboxComponent}\n listIndex={listIndex}\n />\n </CustomModal>\n </>\n );\n};\n\nconst styles = StyleSheet.create({\n optionsContainerStyle: {\n paddingHorizontal: 20,\n paddingVertical: 10,\n flexDirection: 'row',\n },\n});\n\nexport default DropdownSelect;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;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BAAoB;IACzC9B,OAAO,EAAEkC,UAAW;IACpBjC,WAAW,EAAEgE,QAAS;IACtB/D,WAAW,EAAEiE,QAAS;IACtB9D,UAAU,EAAEA,UAAW;IACvBC,YAAY,EAAEA,YAAa;IAC3BqC,aAAa,EAAEA,aAAc;IAC7BF,YAAY,EAAEA,YAAa;IAC3BkC,wBAAwB,EAAEA,wBAAyB;IACnDF,qBAAqB,EAAEA,qBAAsB;IAC7CpD,YAAY,EAAE0F,OAAQ;IACtBxF,YAAY,EAAEA,YAAa;IAC3BC,aAAa,EAAEA,aAAc;IAC7BC,kBAAkB,EAAEA,kBAAmB;IACvCC,uBAAuB,EAAEA,uBAAwB;IACjDC,iBAAiB,EAAEA,iBAAkB;IACrCoB,SAAS,EAAEA;EAAU,CACtB,CACU,CACb,CAAC;AAEP,CAAC;AAACwF,OAAA,CAAA7I,cAAA,GAAAA,cAAA;AAEF,MAAMuI,MAAM,GAAGO,uBAAU,CAACC,MAAM,CAAC;EAC/BP,qBAAqB,EAAE;IACrBQ,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEYnJ,cAAc;AAAA6I,OAAA,CAAA1K,OAAA,GAAAgL,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.types.ts"],"sourcesContent":["import type {\n ViewStyle,\n ColorValue,\n TextStyle,\n ModalProps,\n} from 'react-native';\n\nexport type DropdownProps = {\n placeholder?: string;\n label?: string;\n error?: string;\n helperText?: string;\n options: TFlatList | TSectionList;\n optionLabel?: string;\n optionValue?: string;\n onValueChange: Function;\n selectedValue?:\n | string\n | boolean\n | number\n | string[]\n | boolean[]\n | number[]\n | null;\n isMultiple?: boolean;\n isSearchable?: boolean;\n dropdownIcon?: React.ReactNode;\n labelStyle?: TextStyle;\n dropdownStyle?: ViewStyle;\n dropdownIconStyle?: ViewStyle;\n dropdownContainerStyle?: ViewStyle;\n dropdownErrorStyle?: ViewStyle;\n dropdownErrorTextStyle?: TextStyle;\n dropdownHelperTextStyle?: TextStyle;\n selectedItemStyle?: TextStyle;\n multipleSelectedItemStyle?: TextStyle;\n modalBackgroundStyle?: ViewStyle;\n modalOptionsContainerStyle?: ViewStyle;\n searchInputStyle?: ViewStyle;\n primaryColor?: ColorValue;\n disabled?: boolean;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n placeholderStyle?: TextStyle;\n listHeaderComponent?: React.ReactNode;\n listFooterComponent?: React.ReactNode;\n hideModal?: boolean;\n modalProps?: ModalProps;\n listComponentStyles?: {\n listEmptyComponentStyle?: TextStyle;\n itemSeparatorStyle?: ViewStyle;\n sectionHeaderStyle?: TextStyle;\n };\n};\n\nexport type TFlatList = TFlatListItem[];\nexport type TFlatListItem = {\n [key: string]: string | number | boolean;\n}\n\nexport type TSectionList = TSectionListItem[];\nexport type TSectionListItem = { title: string; data: TFlatList };\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.types.ts"],"sourcesContent":["import type {\n ViewStyle,\n ColorValue,\n TextStyle,\n ModalProps,\n} from 'react-native';\n\nexport type DropdownProps = {\n placeholder?: string;\n label?: string;\n error?: string;\n helperText?: string;\n options: TFlatList | TSectionList;\n optionLabel?: string;\n optionValue?: string;\n onValueChange: Function;\n selectedValue?:\n | string\n | boolean\n | number\n | string[]\n | boolean[]\n | number[]\n | null;\n isMultiple?: boolean;\n isSearchable?: boolean;\n dropdownIcon?: React.ReactNode;\n labelStyle?: TextStyle;\n dropdownStyle?: ViewStyle;\n dropdownIconStyle?: ViewStyle;\n dropdownContainerStyle?: ViewStyle;\n dropdownErrorStyle?: ViewStyle;\n dropdownErrorTextStyle?: TextStyle;\n dropdownHelperTextStyle?: TextStyle;\n selectedItemStyle?: TextStyle;\n multipleSelectedItemStyle?: TextStyle;\n modalBackgroundStyle?: ViewStyle;\n modalOptionsContainerStyle?: ViewStyle;\n searchInputStyle?: ViewStyle;\n primaryColor?: ColorValue;\n disabled?: boolean;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n checkboxComponent?: React.ReactNode;\n placeholderStyle?: TextStyle;\n listHeaderComponent?: React.ReactNode;\n listFooterComponent?: React.ReactNode;\n hideModal?: boolean;\n modalProps?: ModalProps;\n listComponentStyles?: {\n listEmptyComponentStyle?: TextStyle;\n itemSeparatorStyle?: ViewStyle;\n sectionHeaderStyle?: TextStyle;\n };\n};\n\nexport type TFlatList = TFlatListItem[];\nexport type TFlatListItem = {\n [key: string]: string | number | boolean;\n}\n\nexport type TSectionList = TSectionListItem[];\nexport type TSectionListItem = { title: string; data: TFlatList };\n"],"mappings":""}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
/* eslint-disable react-native/no-inline-styles */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { Pressable, Text, StyleSheet, Image, View } from 'react-native';
|
|
4
3
|
import { colors } from '../../styles/colors';
|
|
5
4
|
import { CHECKBOX_SIZE } from '../../constants';
|
|
6
5
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
* Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced in future releases
|
|
7
|
+
* and replaced with a single object `checkboxComponentStyles` e.g
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
const checkboxComponentStyles = {
|
|
11
|
+
checkboxSize: 20,
|
|
12
|
+
checkboxStyle: {
|
|
13
|
+
backgroundColor: 'purple',
|
|
14
|
+
borderRadius: 30,
|
|
15
|
+
padding: 10,
|
|
16
|
+
borderColor: 'red',
|
|
17
|
+
},
|
|
18
|
+
checkboxLabelStyle: { color: 'red', fontSize: 20 },
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
*/
|
|
11
22
|
|
|
12
23
|
const CheckBox = _ref => {
|
|
13
24
|
var _checkboxComponentSty, _checkboxComponentSty2;
|
|
@@ -20,10 +31,11 @@ const CheckBox = _ref => {
|
|
|
20
31
|
checkboxStyle,
|
|
21
32
|
checkboxLabelStyle,
|
|
22
33
|
checkboxComponentStyles,
|
|
34
|
+
checkboxComponent,
|
|
23
35
|
onChange
|
|
24
36
|
} = _ref;
|
|
25
37
|
// const { checkboxSize, checkboxStyle, checkboxLabelStyle } =
|
|
26
|
-
// checkboxComponentStyles;
|
|
38
|
+
// checkboxComponentStyles || undefined;
|
|
27
39
|
const fillColor = {
|
|
28
40
|
backgroundColor: disabled ? '#d3d3d3' : value ? (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty === void 0 ? void 0 : _checkboxComponentSty.backgroundColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.backgroundColor) || primaryColor || 'green' : 'white',
|
|
29
41
|
borderColor: disabled ? colors.disabled : (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty2 = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty2 === void 0 ? void 0 : _checkboxComponentSty2.borderColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.borderColor) || styles.checkbox.borderColor
|
|
@@ -33,8 +45,8 @@ const CheckBox = _ref => {
|
|
|
33
45
|
style: [styles.checkboxContainer],
|
|
34
46
|
disabled: disabled
|
|
35
47
|
}, /*#__PURE__*/React.createElement(View, {
|
|
36
|
-
style: [styles.checkbox, checkboxStyle, fillColor]
|
|
37
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
48
|
+
style: [styles.checkbox, (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxStyle) || checkboxStyle, fillColor]
|
|
49
|
+
}, checkboxComponent || /*#__PURE__*/React.createElement(Image, {
|
|
38
50
|
source: require('../../asset/check.png'),
|
|
39
51
|
style: [{
|
|
40
52
|
height: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize || CHECKBOX_SIZE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Pressable","Text","StyleSheet","Image","View","colors","CHECKBOX_SIZE","CheckBox","_ref","_checkboxComponentSty","_checkboxComponentSty2","label","value","disabled","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","onChange","fillColor","backgroundColor","borderColor","styles","checkbox","createElement","onPress","style","checkboxContainer","source","require","height","width","labelStyle","create","flexDirection","flexWrap","alignItems","padding","borderWidth","borderStyle","borderRadius","marginLeft"],"sources":["index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["React","Pressable","Text","StyleSheet","Image","View","colors","CHECKBOX_SIZE","CheckBox","_ref","_checkboxComponentSty","_checkboxComponentSty2","label","value","disabled","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","onChange","fillColor","backgroundColor","borderColor","styles","checkbox","createElement","onPress","style","checkboxContainer","source","require","height","width","labelStyle","create","flexDirection","flexWrap","alignItems","padding","borderWidth","borderStyle","borderRadius","marginLeft"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { Pressable, Text, StyleSheet, Image, View } from 'react-native';\nimport { colors } from '../../styles/colors';\nimport { CHECKBOX_SIZE } from '../../constants';\nimport type { CheckboxProps } from './types';\n\n/**\n * Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced in future releases\n * and replaced with a single object `checkboxComponentStyles` e.g\n\n```js\nconst checkboxComponentStyles = {\n checkboxSize: 20,\n checkboxStyle: {\n backgroundColor: 'purple',\n borderRadius: 30,\n padding: 10,\n borderColor: 'red',\n },\n checkboxLabelStyle: { color: 'red', fontSize: 20 },\n};\n```\n */\n\nconst CheckBox = ({\n label,\n value,\n disabled,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n onChange,\n}: CheckboxProps) => {\n // const { checkboxSize, checkboxStyle, checkboxLabelStyle } =\n // checkboxComponentStyles || undefined;\n const fillColor = {\n backgroundColor: disabled\n ? '#d3d3d3'\n : value\n ? checkboxComponentStyles?.checkboxStyle?.backgroundColor ||\n checkboxStyle?.backgroundColor ||\n primaryColor ||\n 'green'\n : 'white',\n borderColor: disabled\n ? colors.disabled\n : checkboxComponentStyles?.checkboxStyle?.borderColor ||\n checkboxStyle?.borderColor ||\n styles.checkbox.borderColor,\n };\n\n return (\n <Pressable\n onPress={onChange ? () => onChange(!value) : null}\n style={[styles.checkboxContainer]}\n disabled={disabled}\n >\n <View\n style={[\n styles.checkbox,\n checkboxComponentStyles?.checkboxStyle || checkboxStyle,\n fillColor,\n ]}\n >\n {checkboxComponent || (\n <Image\n source={require('../../asset/check.png')}\n style={[\n {\n height:\n checkboxComponentStyles?.checkboxSize ||\n checkboxSize ||\n CHECKBOX_SIZE,\n width:\n checkboxComponentStyles?.checkboxSize ||\n checkboxSize ||\n CHECKBOX_SIZE,\n },\n ]}\n />\n )}\n </View>\n {label && (\n <Text\n style={[\n checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle,\n styles.labelStyle,\n ]}\n >\n {label}\n </Text>\n )}\n </Pressable>\n );\n};\n\nconst styles = StyleSheet.create({\n checkboxContainer: {\n flexDirection: 'row',\n flexWrap: 'nowrap',\n alignItems: 'center',\n },\n checkbox: {\n padding: 4,\n borderWidth: 1,\n borderStyle: 'solid',\n borderRadius: 4,\n borderColor: 'black',\n },\n labelStyle: { marginLeft: 10 },\n});\n\nexport default CheckBox;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,O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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ColorValue, ViewStyle, TextStyle } from 'react-native';\n\nexport type CheckboxProps = {\n label?: string;\n value?: boolean;\n disabled?: boolean;\n primaryColor?: ColorValue;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n onChange?: (value: boolean | string | number) => void;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import React from 'react';\nimport type { ColorValue, ViewStyle, TextStyle } from 'react-native';\n\nexport type CheckboxProps = {\n label?: string;\n value?: boolean;\n disabled?: boolean;\n primaryColor?: ColorValue;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n checkboxComponent?: React.ReactNode;\n onChange?: (value: boolean | string | number) => void;\n};\n"],"mappings":""}
|
|
@@ -26,7 +26,8 @@ const Dropdown = _ref => {
|
|
|
26
26
|
dropdownErrorTextStyle,
|
|
27
27
|
dropdownHelperTextStyle,
|
|
28
28
|
primaryColor,
|
|
29
|
-
disabled
|
|
29
|
+
disabled,
|
|
30
|
+
setIndexOfSelectedItem
|
|
30
31
|
} = _ref;
|
|
31
32
|
return /*#__PURE__*/React.createElement(View, {
|
|
32
33
|
style: [styles.dropdownInputContainer, dropdownContainerStyle]
|
|
@@ -48,7 +49,8 @@ const Dropdown = _ref => {
|
|
|
48
49
|
dropdownErrorStyle: dropdownErrorStyle,
|
|
49
50
|
primaryColor: primaryColor,
|
|
50
51
|
disabled: disabled,
|
|
51
|
-
placeholderStyle: placeholderStyle
|
|
52
|
+
placeholderStyle: placeholderStyle,
|
|
53
|
+
setIndexOfSelectedItem: setIndexOfSelectedItem
|
|
52
54
|
}), error && error !== '' && /*#__PURE__*/React.createElement(Text, {
|
|
53
55
|
style: [styles.error, dropdownErrorTextStyle]
|
|
54
56
|
}, error), helperText && helperText !== '' && !error && /*#__PURE__*/React.createElement(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Text","StyleSheet","DropdownSelectedItemsView","colors","typography","Dropdown","_ref","label","placeholder","helperText","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","labelStyle","dropdownStyle","dropdownIconStyle","dropdownContainerStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","primaryColor","disabled","createElement","style","styles","dropdownInputContainer","helper","create","marginBottom","color","gray","caption","red","marginTop","primary","width","blackText","black"],"sources":["Dropdown.tsx"],"sourcesContent":["import React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport DropdownSelectedItemsView from './DropdownSelectedItemsView';\nimport { colors } from '../../styles/colors';\nimport { typography } from '../../styles/typography';\n\nconst Dropdown = ({\n label,\n placeholder,\n helperText,\n error,\n getSelectedItemsLabel,\n handleToggleModal,\n isMultiple,\n selectedItem,\n selectedItems,\n dropdownIcon,\n labelStyle,\n dropdownStyle,\n dropdownIconStyle,\n dropdownContainerStyle,\n selectedItemStyle,\n placeholderStyle,\n multipleSelectedItemStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n primaryColor,\n disabled,\n}: any) => {\n return (\n <View style={[styles.dropdownInputContainer, dropdownContainerStyle]}>\n {label && label !== '' && (\n <Text style={[styles.label, labelStyle]}>{label}</Text>\n )}\n <DropdownSelectedItemsView\n placeholder={placeholder}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n handleToggleModal={handleToggleModal}\n isMultiple={isMultiple}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n dropdownIcon={dropdownIcon}\n dropdownStyle={dropdownStyle}\n dropdownIconStyle={dropdownIconStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n primaryColor={primaryColor}\n disabled={disabled}\n placeholderStyle={placeholderStyle}\n />\n\n {error && error !== '' && (\n <Text style={[styles.error, dropdownErrorTextStyle]}>{error}</Text>\n )}\n\n {helperText && helperText !== '' && !error && (\n <Text style={[styles.helper, dropdownHelperTextStyle]}>\n {helperText}\n </Text>\n )}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n label: { marginBottom: 16, color: colors.gray, ...typography.caption },\n error: { color: colors.red, marginTop: 8, ...typography.caption },\n helper: { marginTop: 8, color: colors.primary, ...typography.caption },\n dropdownInputContainer: { marginBottom: 23, width: '100%' },\n blackText: { color: colors.black },\n});\n\nexport default Dropdown;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AACrD,OAAOC,yBAAyB,MAAM,6BAA6B;AACnE,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,UAAU,QAAQ,yBAAyB;AAEpD,MAAMC,QAAQ,GAAGC,IAAA,
|
|
1
|
+
{"version":3,"names":["React","View","Text","StyleSheet","DropdownSelectedItemsView","colors","typography","Dropdown","_ref","label","placeholder","helperText","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","labelStyle","dropdownStyle","dropdownIconStyle","dropdownContainerStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","primaryColor","disabled","setIndexOfSelectedItem","createElement","style","styles","dropdownInputContainer","helper","create","marginBottom","color","gray","caption","red","marginTop","primary","width","blackText","black"],"sources":["Dropdown.tsx"],"sourcesContent":["import React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport DropdownSelectedItemsView from './DropdownSelectedItemsView';\nimport { colors } from '../../styles/colors';\nimport { typography } from '../../styles/typography';\n\nconst Dropdown = ({\n label,\n placeholder,\n helperText,\n error,\n getSelectedItemsLabel,\n handleToggleModal,\n isMultiple,\n selectedItem,\n selectedItems,\n dropdownIcon,\n labelStyle,\n dropdownStyle,\n dropdownIconStyle,\n dropdownContainerStyle,\n selectedItemStyle,\n placeholderStyle,\n multipleSelectedItemStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n primaryColor,\n disabled,\n setIndexOfSelectedItem,\n}: any) => {\n return (\n <View style={[styles.dropdownInputContainer, dropdownContainerStyle]}>\n {label && label !== '' && (\n <Text style={[styles.label, labelStyle]}>{label}</Text>\n )}\n\n <DropdownSelectedItemsView\n placeholder={placeholder}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n handleToggleModal={handleToggleModal}\n isMultiple={isMultiple}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n dropdownIcon={dropdownIcon}\n dropdownStyle={dropdownStyle}\n dropdownIconStyle={dropdownIconStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n primaryColor={primaryColor}\n disabled={disabled}\n placeholderStyle={placeholderStyle}\n setIndexOfSelectedItem={setIndexOfSelectedItem}\n />\n\n {error && error !== '' && (\n <Text style={[styles.error, dropdownErrorTextStyle]}>{error}</Text>\n )}\n\n {helperText && helperText !== '' && !error && (\n <Text style={[styles.helper, dropdownHelperTextStyle]}>\n {helperText}\n </Text>\n )}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n label: { marginBottom: 16, color: colors.gray, ...typography.caption },\n error: { color: colors.red, marginTop: 8, ...typography.caption },\n helper: { marginTop: 8, color: colors.primary, ...typography.caption },\n dropdownInputContainer: { marginBottom: 23, width: '100%' },\n blackText: { color: colors.black },\n});\n\nexport default Dropdown;\n"],"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object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
/* eslint-disable react-native/no-inline-styles */
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useEffect, useRef } from 'react';
|
|
4
4
|
import { FlatList, StyleSheet } from 'react-native';
|
|
5
5
|
import DropdownListItem from './DropdownListItem';
|
|
6
6
|
import { ItemSeparatorComponent, ListEmptyComponent } from '../Others';
|
|
@@ -23,9 +23,22 @@ const DropdownFlatList = _ref => {
|
|
|
23
23
|
checkboxLabelStyle,
|
|
24
24
|
// kept for backwards compatibility to be removed in future release
|
|
25
25
|
checkboxComponentStyles,
|
|
26
|
+
checkboxComponent,
|
|
26
27
|
listComponentStyles,
|
|
28
|
+
listIndex,
|
|
27
29
|
...rest
|
|
28
30
|
} = _ref;
|
|
31
|
+
const flatlistRef = useRef(null);
|
|
32
|
+
const scrollToItem = index => {
|
|
33
|
+
var _flatlistRef$current;
|
|
34
|
+
(_flatlistRef$current = flatlistRef.current) === null || _flatlistRef$current === void 0 ? void 0 : _flatlistRef$current.scrollToIndex({
|
|
35
|
+
index,
|
|
36
|
+
animated: true
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
scrollToItem(listIndex.itemIndex);
|
|
41
|
+
}, [listIndex]);
|
|
29
42
|
return /*#__PURE__*/React.createElement(FlatList, _extends({
|
|
30
43
|
data: options,
|
|
31
44
|
extraData: isMultiple ? selectedItems : selectedItem,
|
|
@@ -45,6 +58,7 @@ const DropdownFlatList = _ref => {
|
|
|
45
58
|
isMultiple,
|
|
46
59
|
selectedOption: isMultiple ? selectedItems : selectedItem,
|
|
47
60
|
onChange: isMultiple ? handleMultipleSelections : handleSingleSelection,
|
|
61
|
+
scrollToItem,
|
|
48
62
|
primaryColor,
|
|
49
63
|
checkboxSize,
|
|
50
64
|
// kept for backwards compatibility
|
|
@@ -52,15 +66,25 @@ const DropdownFlatList = _ref => {
|
|
|
52
66
|
// kept for backwards compatibility
|
|
53
67
|
checkboxLabelStyle,
|
|
54
68
|
// kept for backwards compatibility
|
|
55
|
-
checkboxComponentStyles
|
|
69
|
+
checkboxComponentStyles,
|
|
70
|
+
checkboxComponent
|
|
56
71
|
}),
|
|
57
|
-
keyExtractor: (_item, index) => `Options${index}
|
|
72
|
+
keyExtractor: (_item, index) => `Options${index}`,
|
|
73
|
+
ref: flatlistRef,
|
|
74
|
+
onScrollToIndexFailed: _ref2 => {
|
|
75
|
+
let {
|
|
76
|
+
index
|
|
77
|
+
} = _ref2;
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
scrollToItem(index);
|
|
80
|
+
}, 500);
|
|
81
|
+
}
|
|
58
82
|
}, rest));
|
|
59
83
|
};
|
|
60
|
-
const _renderItem = (
|
|
84
|
+
const _renderItem = (_ref3, props) => {
|
|
61
85
|
let {
|
|
62
86
|
item
|
|
63
|
-
} =
|
|
87
|
+
} = _ref3;
|
|
64
88
|
return /*#__PURE__*/React.createElement(DropdownListItem, {
|
|
65
89
|
item: item,
|
|
66
90
|
optionLabel: props.optionLabel,
|
|
@@ -72,7 +96,9 @@ const _renderItem = (_ref2, props) => {
|
|
|
72
96
|
checkboxSize: props.checkboxSize,
|
|
73
97
|
checkboxStyle: props.checkboxStyle,
|
|
74
98
|
checkboxLabelStyle: props.checkboxLabelStyle,
|
|
75
|
-
|
|
99
|
+
scrollToItem: props.scrollToItem,
|
|
100
|
+
checkboxComponentStyles: props.checkboxComponentStyles,
|
|
101
|
+
checkboxComponent: props.checkboxComponent
|
|
76
102
|
});
|
|
77
103
|
};
|
|
78
104
|
const styles = StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FlatList","StyleSheet","DropdownListItem","ItemSeparatorComponent","ListEmptyComponent","DropdownFlatList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","listComponentStyles","rest","createElement","_extends","data","extraData","initialNumToRender","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","keyExtractor","_item","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","FlatList","StyleSheet","DropdownListItem","ItemSeparatorComponent","ListEmptyComponent","DropdownFlatList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","listComponentStyles","listIndex","rest","flatlistRef","scrollToItem","index","_flatlistRef$current","current","scrollToIndex","animated","itemIndex","createElement","_extends","data","extraData","initialNumToRender","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","keyExtractor","_item","ref","onScrollToIndexFailed","_ref2","setTimeout","_ref3","props","create"],"sources":["DropdownFlatList.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React, { useEffect, useRef } from 'react';\nimport { FlatList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { ItemSeparatorComponent, ListEmptyComponent } from '../Others';\nimport { TFlatList } from 'src/types/index.types';\n\nconst DropdownFlatList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize, // kept for backwards compatibility to be removed in future release\n checkboxStyle, // kept for backwards compatibility to be removed in future release\n checkboxLabelStyle, // kept for backwards compatibility to be removed in future release\n checkboxComponentStyles,\n checkboxComponent,\n listComponentStyles,\n listIndex,\n ...rest\n}: any) => {\n const flatlistRef = useRef<FlatList<TFlatList>>(null);\n\n const scrollToItem = (index: number) => {\n flatlistRef.current?.scrollToIndex({\n index,\n animated: true,\n });\n };\n\n useEffect(() => {\n scrollToItem(listIndex.itemIndex);\n }, [listIndex]);\n\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <ListEmptyComponent\n listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}\n />\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => (\n <ItemSeparatorComponent\n itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}\n />\n )}\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 scrollToItem,\n primaryColor,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles,\n checkboxComponent\n })\n }\n keyExtractor={(_item, index) => `Options${index}`}\n ref={flatlistRef}\n onScrollToIndexFailed={({ index }) => {\n setTimeout(() => {\n scrollToItem(index);\n }, 500);\n }}\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 scrollToItem={props.scrollToItem}\n checkboxComponentStyles={props.checkboxComponentStyles}\n checkboxComponent={props.checkboxComponent}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownFlatList;\n"],"mappings":";AAAA;AACA,OAAOA,KAAK,IA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