react-native-input-select 1.1.1 → 1.1.2

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.
Files changed (36) hide show
  1. package/lib/commonjs/components/CheckBox/index.js +17 -7
  2. package/lib/commonjs/components/CheckBox/index.js.map +1 -1
  3. package/lib/commonjs/components/Dropdown/Dropdown.js +4 -2
  4. package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
  5. package/lib/commonjs/components/Dropdown/DropdownFlatList.js +29 -4
  6. package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
  7. package/lib/commonjs/components/Dropdown/DropdownSectionList.js +25 -1
  8. package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
  9. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +41 -9
  10. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
  11. package/lib/commonjs/index.js +60 -15
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/module/components/CheckBox/index.js +17 -6
  14. package/lib/module/components/CheckBox/index.js.map +1 -1
  15. package/lib/module/components/Dropdown/Dropdown.js +4 -2
  16. package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
  17. package/lib/module/components/Dropdown/DropdownFlatList.js +27 -4
  18. package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
  19. package/lib/module/components/Dropdown/DropdownSectionList.js +26 -2
  20. package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
  21. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +42 -10
  22. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
  23. package/lib/module/index.js +61 -16
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/typescript/components/CheckBox/index.d.ts +16 -4
  26. package/lib/typescript/components/Dropdown/Dropdown.d.ts +1 -1
  27. package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +1 -1
  28. package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +1 -1
  29. package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +1 -1
  30. package/package.json +1 -1
  31. package/src/components/CheckBox/index.tsx +17 -6
  32. package/src/components/Dropdown/Dropdown.tsx +3 -0
  33. package/src/components/Dropdown/DropdownFlatList.tsx +24 -1
  34. package/src/components/Dropdown/DropdownSectionList.tsx +27 -1
  35. package/src/components/Dropdown/DropdownSelectedItemsView.tsx +32 -13
  36. package/src/index.tsx +61 -18
@@ -1,5 +1,6 @@
1
+ function _extends() { _extends = 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); }
1
2
  import React from 'react';
2
- import { View, Text, Pressable, ScrollView, StyleSheet, Image } from 'react-native';
3
+ import { View, Text, Pressable, ScrollView, StyleSheet, Image, TouchableOpacity } from 'react-native';
3
4
  import { colors } from '../../styles/colors';
4
5
  import { inputStyles } from '../../styles/input';
5
6
  const DropdownSelectedItemsView = _ref => {
@@ -20,7 +21,8 @@ const DropdownSelectedItemsView = _ref => {
20
21
  multipleSelectedItemStyle,
21
22
  dropdownErrorStyle,
22
23
  primaryColor,
23
- disabled
24
+ disabled,
25
+ setIndexOfSelectedItem
24
26
  } = _ref;
25
27
  return /*#__PURE__*/React.createElement(Pressable, {
26
28
  onPress: () => handleToggleModal(),
@@ -31,7 +33,10 @@ const DropdownSelectedItemsView = _ref => {
31
33
  return [pressed && {
32
34
  ...inputStyles.inputFocusState,
33
35
  borderColor: primaryColor
34
- }, inputStyles.input, dropdownStyle, error &&
36
+ }, {
37
+ ...inputStyles.input,
38
+ ...dropdownStyle
39
+ }, error &&
35
40
  //this must be last
36
41
  error !== '' && !pressed && {
37
42
  ...inputStyles.inputFocusErrorState,
@@ -46,21 +51,48 @@ const DropdownSelectedItemsView = _ref => {
46
51
  }, /*#__PURE__*/React.createElement(View, {
47
52
  style: styles.selectedItemsContainer,
48
53
  onStartShouldSetResponder: () => true
49
- }, isMultiple ? (_getSelectedItemsLabe = getSelectedItemsLabel()) === null || _getSelectedItemsLabe === void 0 ? void 0 : _getSelectedItemsLabe.map((item, i) => /*#__PURE__*/React.createElement(Text, {
54
+ }, isMultiple ? (_getSelectedItemsLabe = getSelectedItemsLabel()) === null || _getSelectedItemsLabe === void 0 ? void 0 : _getSelectedItemsLabe.map((label, i) => /*#__PURE__*/React.createElement(DropdownContent, {
55
+ onPress: () => {
56
+ handleToggleModal();
57
+ setIndexOfSelectedItem(label); // immediately scrolls to list item with the specified label when modal
58
+ },
59
+
50
60
  key: `react-native-input-select-${Math.random()}-${i}`,
51
61
  style: [styles.selectedItems, {
52
62
  backgroundColor: primaryColor
53
- }, multipleSelectedItemStyle]
54
- }, item)) : /*#__PURE__*/React.createElement(Text, {
55
- style: [styles.blackText, selectedItemStyle]
56
- }, getSelectedItemsLabel()), !selectedItem && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) === 0 && /*#__PURE__*/React.createElement(Text, {
57
- style: [styles.blackText, placeholderStyle]
58
- }, placeholder ?? 'Select an option'))), /*#__PURE__*/React.createElement(View, {
63
+ }, multipleSelectedItemStyle],
64
+ label: label
65
+ })) : /*#__PURE__*/React.createElement(DropdownContent, {
66
+ onPress: () => {
67
+ handleToggleModal();
68
+ setIndexOfSelectedItem(getSelectedItemsLabel()); // immediately scrolls to list item with the specified label when modal
69
+ },
70
+
71
+ style: [styles.blackText, selectedItemStyle],
72
+ label: getSelectedItemsLabel()
73
+ }), !selectedItem && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) === 0 && /*#__PURE__*/React.createElement(DropdownContent, {
74
+ onPress: () => handleToggleModal(),
75
+ style: [styles.blackText, placeholderStyle],
76
+ label: placeholder ?? 'Select an option'
77
+ }))), /*#__PURE__*/React.createElement(View, {
59
78
  style: [styles.iconStyle, dropdownIconStyle]
60
79
  }, dropdownIcon || /*#__PURE__*/React.createElement(Image, {
61
80
  source: require('../../asset/arrow-down.png')
62
81
  })));
63
82
  };
83
+ const DropdownContent = _ref3 => {
84
+ let {
85
+ onPress,
86
+ style,
87
+ label,
88
+ ...rest
89
+ } = _ref3;
90
+ return /*#__PURE__*/React.createElement(TouchableOpacity, _extends({
91
+ onPress: () => onPress()
92
+ }, rest), /*#__PURE__*/React.createElement(Text, {
93
+ style: style
94
+ }, label));
95
+ };
64
96
  const styles = StyleSheet.create({
65
97
  iconStyle: {
66
98
  position: 'absolute',
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","colors","inputStyles","DropdownSelectedItemsView","_ref","_getSelectedItemsLabe","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","dropdownStyle","dropdownIconStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","createElement","onPress","style","_ref2","pressed","inputFocusState","borderColor","input","inputFocusErrorState","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","styles","selectedItemsContainer","onStartShouldSetResponder","map","item","i","key","Math","random","backgroundColor","blackText","length","iconStyle","source","require","create","position","right","top","flexDirection","flexWrap","alignItems","color","white","paddingHorizontal","paddingVertical","borderRadius","primary","marginRight","overflow","black"],"sources":["DropdownSelectedItemsView.tsx"],"sourcesContent":["import React from 'react';\nimport {\n View,\n Text,\n Pressable,\n ScrollView,\n StyleSheet,\n Image,\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}: any) => {\n return (\n <Pressable\n onPress={() => handleToggleModal()}\n style={({ pressed }) => [\n pressed && {\n ...inputStyles.inputFocusState,\n borderColor: primaryColor,\n },\n inputStyles.input,\n 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((item: any, i: Number) => (\n <Text\n key={`react-native-input-select-${Math.random()}-${i}`}\n style={[\n styles.selectedItems,\n { backgroundColor: primaryColor },\n multipleSelectedItemStyle,\n ]}\n >\n {item}\n </Text>\n ))\n ) : (\n <Text style={[styles.blackText, selectedItemStyle]}>\n {getSelectedItemsLabel()}\n </Text>\n )}\n {!selectedItem && selectedItems?.length === 0 && (\n <Text style={[styles.blackText, placeholderStyle]}>\n {placeholder ?? 'Select an option'}\n </Text>\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 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,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,KAAK,QACA,cAAc;AACrB,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,WAAW,QAAQ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E;IAChBjB,eAAe,EAAE1C,MAAM,CAAC4D,OAAO;IAC/BC,WAAW,EAAE,EAAE;IACfC,QAAQ,EAAE;EACZ,CAAC;EACDnB,SAAS,EAAE;IAAEY,KAAK,EAAEvD,MAAM,CAAC+D;EAAM;AACnC,CAAC,CAAC;AAEF,eAAe7D,yBAAyB"}
1
+ {"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","TouchableOpacity","colors","inputStyles","DropdownSelectedItemsView","_ref","_getSelectedItemsLabe","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","dropdownStyle","dropdownIconStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","setIndexOfSelectedItem","createElement","onPress","style","_ref2","pressed","inputFocusState","borderColor","input","inputFocusErrorState","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","styles","selectedItemsContainer","onStartShouldSetResponder","map","label","i","DropdownContent","key","Math","random","backgroundColor","blackText","length","iconStyle","source","require","_ref3","rest","_extends","create","position","right","top","flexDirection","flexWrap","alignItems","color","white","paddingHorizontal","paddingVertical","borderRadius","primary","marginRight","overflow","black"],"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,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,gBAAgB,QACX,cAAc;AACrB,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,MAAMC,yBAAyB,GAAGC,IAAA,IAkBvB;EAAA,IAAAC,qBAAA;EAAA,IAlBwB;IACjCC,WAAW;IACXC,KAAK;IACLC,qBAAqB;IACrBC,iBAAiB;IACjBC,UAAU;IACVC,YAAY;IACZC,aAAa;IACbC,YAAY;IACZC,aAAa;IACbC,iBAAiB;IACjBC,iBAAiB;IACjBC,gBAAgB;IAChBC,yBAAyB;IACzBC,kBAAkB;IAClBC,YAAY;IACZC,QAAQ;IACRC;EACG,CAAC,GAAAlB,IAAA;EACJ,oBACEX,KAAA,CAAA8B,aAAA,CAAC3B,SAAS;IACR4B,OAAO,EAAEA,CAAA,KAAMf,iBAAiB,CAAC,CAAE;IACnCgB,KAAK,EAAEC,KAAA;MAAA,IAAC;QAAEC;MAAQ,CAAC,GAAAD,KAAA;MAAA,OAAK,CACtBC,OAAO,IAAI;QACT,GAAGzB,WAAW,CAAC0B,eAAe;QAC9BC,WAAW,EAAET;MACf,CAAC,EACD;QAAE,GAAGlB,WAAW,CAAC4B,KAAK;QAAE,GAAGhB;MAAc,CAAC,EAC1CP,KAAK;MAAI;MACPA,KAAK,KAAK,EAAE,IACZ,CAACoB,OAAO,IAAI;QACV,GAAGzB,WAAW,CAAC6B,oBAAoB;QACnC,GAAGZ;MACL,CAAC,CACJ;IAAA,CAAC;IACFE,QAAQ,EAAEA;EAAS,gBAEnB5B,KAAA,CAAA8B,aAAA,CAAC1B,UAAU;IACTmC,UAAU;IACVC,sBAAsB;IACtBC,8BAA8B,EAAE;EAAM,gBAEtCzC,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AAEF,eAAelE,yBAAyB"}
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = 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
- import React, { useState, useEffect } from 'react';
2
+ import React, { useState, useEffect, useCallback } from 'react';
3
3
  import { TouchableOpacity, StyleSheet, View } from 'react-native';
4
4
  import Input from './components/Input';
5
5
  import CheckBox from './components/CheckBox';
@@ -56,9 +56,13 @@ export const DropdownSelect = _ref => {
56
56
  const [newOptions, setNewOptions] = useState([]);
57
57
  const [open, setOpen] = useState(false);
58
58
  const [selectAll, setSelectAll] = useState(false);
59
- const [selectedItem, setSelectedItem] = useState(''); //for single selection
60
- const [selectedItems, setSelectedItems] = useState([]); //for multiple selection
59
+ const [selectedItem, setSelectedItem] = useState(''); // for single selection
60
+ const [selectedItems, setSelectedItems] = useState([]); // for multiple selection
61
61
  const [searchValue, setSearchValue] = useState('');
62
+ const [listIndex, setListIndex] = useState({
63
+ itemIndex: 0
64
+ }); // for scrollToIndex in Sectionlist and Flatlist
65
+
62
66
  useEffect(() => {
63
67
  if (options) {
64
68
  setNewOptions(options);
@@ -76,10 +80,11 @@ export const DropdownSelect = _ref => {
76
80
 
77
81
  const isSectionList = newOptions.some(item => item.title && item.data && Array.isArray(item.data));
78
82
  const ListTypeComponent = isSectionList ? DropdownSectionList : DropdownFlatList;
79
- let modifiedSectionData = extractPropertyFromArray(newOptions, 'data').flat();
80
- let modifiedOptions = isSectionList ? modifiedSectionData : newOptions;
83
+ const modifiedSectionData = extractPropertyFromArray(newOptions, 'data').flat();
84
+ const modifiedOptions = isSectionList ? modifiedSectionData : newOptions;
81
85
  const optLabel = optionLabel || DEFAULT_OPTION_LABEL;
82
86
  const optValue = optionValue || DEFAULT_OPTION_VALUE;
87
+ const optionsCopy = JSON.parse(JSON.stringify(options)); //copy of the original options array
83
88
 
84
89
  /*===========================================
85
90
  * Selection handlers
@@ -104,15 +109,7 @@ export const DropdownSelect = _ref => {
104
109
  } else {
105
110
  selectedValues.push(value);
106
111
  }
107
- setSelectedItems(selectedValues);
108
112
  onValueChange(selectedValues); //send value to parent
109
-
110
- //select all checkbox should not be checked if the list contains disabled values
111
- if (modifiedOptions.filter(item => !item.disabled).length === selectedValues.length) {
112
- setSelectAll(true);
113
- } else {
114
- setSelectAll(false);
115
- }
116
113
  return selectedValues;
117
114
  });
118
115
  };
@@ -133,6 +130,26 @@ export const DropdownSelect = _ref => {
133
130
  });
134
131
  };
135
132
 
133
+ /*===========================================
134
+ * Handle side effects
135
+ *==========================================*/
136
+ const checkSelectAll = useCallback(selectedValues => {
137
+ //if the list contains disabled values, those values will not be selected
138
+ if (modifiedOptions.filter(item => !item.disabled).length === selectedValues.length) {
139
+ setSelectAll(true);
140
+ } else {
141
+ setSelectAll(false);
142
+ }
143
+ }, [modifiedOptions]);
144
+
145
+ // anytime the selected items change, check if it is time to set `selectAll` to true
146
+ useEffect(() => {
147
+ if (isMultiple) {
148
+ checkSelectAll(selectedItems);
149
+ }
150
+ return () => {};
151
+ }, [checkSelectAll, isMultiple, selectedItems]);
152
+
136
153
  /*===========================================
137
154
  * Get label handler
138
155
  *==========================================*/
@@ -159,7 +176,6 @@ export const DropdownSelect = _ref => {
159
176
  const regexFilter = new RegExp(searchText, 'i');
160
177
 
161
178
  //Because Search mutates the initial state, we have to search with a copy of the original array
162
- const optionsCopy = JSON.parse(JSON.stringify(options));
163
179
  const searchResults = isSectionList ? searchSectionList(optionsCopy, regexFilter) : searchFlatList(optionsCopy, regexFilter);
164
180
  setNewOptions(searchResults);
165
181
  };
@@ -192,6 +208,10 @@ export const DropdownSelect = _ref => {
192
208
  setOpen(!open);
193
209
  setSearchValue('');
194
210
  setNewOptions(options);
211
+ setListIndex({
212
+ itemIndex: 0,
213
+ sectionIndex: 0
214
+ });
195
215
  };
196
216
  useEffect(() => {
197
217
  if (hideModal) {
@@ -202,6 +222,29 @@ export const DropdownSelect = _ref => {
202
222
  let primary = primaryColor || colors.gray;
203
223
  const sectionListMaxLength = getMaxLengthOfSectionListProperty(newOptions, 'data');
204
224
  const listIsEmpty = isSectionList ? sectionListMaxLength > 1 : newOptions.length > 1;
225
+
226
+ /*===========================================
227
+ * setIndexOfSelectedItem - For ScrollToIndex
228
+ *==========================================*/
229
+ const setIndexOfSelectedItem = selectedLabel => {
230
+ isSectionList ? optionsCopy.map((item, sectionIndex) => {
231
+ var _item$data;
232
+ (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.find((dataItem, itemIndex) => {
233
+ if (dataItem[optLabel] === selectedLabel) {
234
+ setListIndex({
235
+ sectionIndex,
236
+ itemIndex
237
+ });
238
+ }
239
+ });
240
+ }) : optionsCopy === null || optionsCopy === void 0 ? void 0 : optionsCopy.find((item, itemIndex) => {
241
+ if (item[optLabel] === selectedLabel) {
242
+ setListIndex({
243
+ itemIndex
244
+ });
245
+ }
246
+ });
247
+ };
205
248
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, _extends({
206
249
  label: label,
207
250
  placeholder: placeholder,
@@ -224,7 +267,8 @@ export const DropdownSelect = _ref => {
224
267
  isMultiple: isMultiple,
225
268
  primaryColor: primary,
226
269
  disabled: disabled,
227
- placeholderStyle: placeholderStyle
270
+ placeholderStyle: placeholderStyle,
271
+ setIndexOfSelectedItem: setIndexOfSelectedItem
228
272
  }, rest)), /*#__PURE__*/React.createElement(CustomModal, {
229
273
  open: open,
230
274
  handleToggleModal: handleToggleModal,
@@ -267,7 +311,8 @@ export const DropdownSelect = _ref => {
267
311
  checkboxSize: checkboxSize,
268
312
  checkboxStyle: checkboxStyle,
269
313
  checkboxLabelStyle: checkboxLabelStyle,
270
- checkboxComponentStyles: checkboxComponentStyles
314
+ checkboxComponentStyles: checkboxComponentStyles,
315
+ listIndex: listIndex
271
316
  })));
272
317
  };
273
318
  const styles = StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","useEffect","TouchableOpacity","StyleSheet","View","Input","CheckBox","Dropdown","DropdownFlatList","DropdownSectionList","CustomModal","colors","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","extractPropertyFromArray","getMaxLengthOfSectionListProperty","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","open","setOpen","selectAll","setSelectAll","selectedItem","setSelectedItem","selectedItems","setSelectedItems","searchValue","setSearchValue","Array","isArray","isSectionList","some","item","title","data","ListTypeComponent","modifiedSectionData","flat","modifiedOptions","optLabel","optValue","handleSingleSelection","value","handleMultipleSelections","prevVal","_selectedValues","selectedValues","includes","filter","push","length","handleSelectAll","filteredOptions","i","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","gray","sectionListMaxLength","listIsEmpty","createElement","Fragment","_extends","onRequestClose","ListHeaderComponent","onChangeText","text","style","styles","optionsContainerStyle","onPress","onChange","ListFooterComponent","create","paddingHorizontal","paddingVertical","flexDirection"],"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"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACjE,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,QAAQ,MAAM,uBAAuB;AAC5C,OAAOC,QAAQ,MAAM,gCAAgC;AACrD,OAAOC,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,mBAAmB,MAAM,2CAA2C;AAC3E,OAAOC,WAAW,MAAM,0BAA0B;AAClD,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,aAAa;AAQxE,SACEC,wBAAwB,EACxBC,iCAAiC,QAC5B,SAAS;AAEhB,OAAO,MAAMC,cAAuC,GAAGC,IAAA,IAsCjD;EAAA,IAtCkD;IACtDC,WAAW;IACXC,KAAK;IACLC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,WAAW;IACXC,WAAW;IACXC,aAAa;IACbC,aAAa;IACbC,UAAU;IACVC,YAAY;IACZC,YAAY;IACZC,UAAU;IACVC,gBAAgB;IAChBC,aAAa;IACbC,iBAAiB;IACjBC,sBAAsB;IACtBC,kBAAkB;IAClBC,sBAAsB;IACtBC,uBAAuB;IACvBC,iBAAiB;IACjBC,yBAAyB;IACzBC,oBAAoB;IACpBC,0BAA0B;IAC1BC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,YAAY;IAAE;IACdC,aAAa;IAAE;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YAAY,EAAE8E,OAAQ;IACtB5E,YAAY,EAAEA,YAAa;IAC3BC,aAAa,EAAEA,aAAc;IAC7BC,kBAAkB,EAAEA,kBAAmB;IACvCC,uBAAuB,EAAEA;EAAwB,CAClD,CACU,CACb,CAAC;AAEP,CAAC;AAED,MAAMqF,MAAM,GAAGlI,UAAU,CAACuI,MAAM,CAAC;EAC/BJ,qBAAqB,EAAE;IACrBK,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAEF,eAAe7H,cAAc"}
1
+ {"version":3,"names":["React","useState","useEffect","useCallback","TouchableOpacity","StyleSheet","View","Input","CheckBox","Dropdown","DropdownFlatList","DropdownSectionList","CustomModal","colors","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","extractPropertyFromArray","getMaxLengthOfSectionListProperty","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","open","setOpen","selectAll","setSelectAll","selectedItem","setSelectedItem","selectedItems","setSelectedItems","searchValue","setSearchValue","listIndex","setListIndex","itemIndex","Array","isArray","isSectionList","some","item","title","data","ListTypeComponent","modifiedSectionData","flat","modifiedOptions","optLabel","optValue","optionsCopy","JSON","parse","stringify","handleSingleSelection","value","handleMultipleSelections","prevVal","_selectedValues","selectedValues","includes","filter","push","handleSelectAll","filteredOptions","i","length","checkSelectAll","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","gray","sectionListMaxLength","listIsEmpty","setIndexOfSelectedItem","selectedLabel","_item$data","dataItem","createElement","Fragment","_extends","onRequestClose","ListHeaderComponent","onChangeText","text","style","styles","optionsContainerStyle","onPress","onChange","ListFooterComponent","create","paddingHorizontal","paddingVertical","flexDirection"],"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 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 />\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 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,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,WAAW,QAAQ,OAAO;AAC/D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACjE,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,QAAQ,MAAM,uBAAuB;AAC5C,OAAOC,QAAQ,MAAM,gCAAgC;AACrD,OAAOC,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,mBAAmB,MAAM,2CAA2C;AAC3E,OAAOC,WAAW,MAAM,0BAA0B;AAClD,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,aAAa;AAQxE,SACEC,wBAAwB,EACxBC,iCAAiC,QAC5B,SAAS;AAEhB,OAAO,MAAMC,cAAuC,GAAGC,IAAA,IAsCjD;EAAA,IAtCkD;IACtDC,WAAW;IACXC,KAAK;IACLC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,WAAW;IACXC,WAAW;IACXC,aAAa;IACbC,aAAa;IACbC,UAAU;IACVC,YAAY;IACZC,YAAY;IACZC,UAAU;IACVC,gBAAgB;IAChBC,aAAa;IACbC,iBAAiB;IACjBC,sBAAsB;IACtBC,kBAAkB;IAClBC,sBAAsB;IACtBC,uBAAuB;IACvBC,iBAAiB;IACjBC,yBAAyB;IACzBC,oBAAoB;IACpBC,0BAA0B;IAC1BC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,YAAY;IAAE;IACdC,aAAa;IAAE;IACfC,kBAAkB;IAAE;IACpBC,uBAAuB;IACvBC,mBAAmB;IACnBC,mBAAmB;IACn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AAEA,aAAc;IAC7BC,kBAAkB,EAAEA,kBAAmB;IACvCC,uBAAuB,EAAEA,uBAAwB;IACjDmB,SAAS,EAAEA;EAAU,CACtB,CACU,CACb,CAAC;AAEP,CAAC;AAED,MAAM2E,MAAM,GAAG3I,UAAU,CAACgJ,MAAM,CAAC;EAC/BJ,qBAAqB,EAAE;IACrBK,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAEF,eAAetI,cAAc"}
@@ -1,9 +1,21 @@
1
1
  /// <reference types="react" />
2
2
  import type { CheckboxProps } from './types';
3
3
  /**
4
- *
5
- *`checkboxSize`, `checkboxStyle`,`checkboxLabelStyle` Will be deleted in version 1.0.
6
- * and replaced with `checkboxComponentStyles`
7
- */
4
+ * Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced in future releases
5
+ * and replaced with a single object `checkboxComponentStyles` e.g
6
+
7
+ ```js
8
+ const checkboxComponentStyles = {
9
+ checkboxSize: 20,
10
+ checkboxStyle: {
11
+ backgroundColor: 'purple',
12
+ borderRadius: 30,
13
+ padding: 10,
14
+ borderColor: 'red',
15
+ },
16
+ checkboxLabelStyle: { color: 'red', fontSize: 20 },
17
+ };
18
+ ```
19
+ */
8
20
  declare const CheckBox: ({ label, value, disabled, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, onChange, }: CheckboxProps) => JSX.Element;
9
21
  export default CheckBox;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const Dropdown: ({ label, placeholder, helperText, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, labelStyle, dropdownStyle, dropdownIconStyle, dropdownContainerStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, primaryColor, disabled, }: any) => JSX.Element;
2
+ declare const Dropdown: ({ label, placeholder, helperText, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, labelStyle, dropdownStyle, dropdownIconStyle, dropdownContainerStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, primaryColor, disabled, setIndexOfSelectedItem, }: any) => JSX.Element;
3
3
  export default Dropdown;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DropdownFlatList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, ...rest }: any) => JSX.Element;
2
+ declare const DropdownFlatList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
3
3
  export default DropdownFlatList;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DropdownSectionList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, ...rest }: any) => JSX.Element;
2
+ declare const DropdownSectionList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
3
3
  export default DropdownSectionList;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DropdownSelectedItemsView: ({ placeholder, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, dropdownStyle, dropdownIconStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, primaryColor, disabled, }: any) => JSX.Element;
2
+ declare const DropdownSelectedItemsView: ({ placeholder, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, dropdownStyle, dropdownIconStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, primaryColor, disabled, setIndexOfSelectedItem, }: any) => JSX.Element;
3
3
  export default DropdownSelectedItemsView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-input-select",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,4 +1,3 @@
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';
@@ -6,10 +5,22 @@ import { CHECKBOX_SIZE } from '../../constants';
6
5
  import type { CheckboxProps } from './types';
7
6
 
8
7
  /**
9
- *
10
- *`checkboxSize`, `checkboxStyle`,`checkboxLabelStyle` Will be deleted in version 1.0.
11
- * and replaced with `checkboxComponentStyles`
12
- */
8
+ * Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced in future releases
9
+ * and replaced with a single object `checkboxComponentStyles` e.g
10
+
11
+ ```js
12
+ const checkboxComponentStyles = {
13
+ checkboxSize: 20,
14
+ checkboxStyle: {
15
+ backgroundColor: 'purple',
16
+ borderRadius: 30,
17
+ padding: 10,
18
+ borderColor: 'red',
19
+ },
20
+ checkboxLabelStyle: { color: 'red', fontSize: 20 },
21
+ };
22
+ ```
23
+ */
13
24
 
14
25
  const CheckBox = ({
15
26
  label,
@@ -23,7 +34,7 @@ const CheckBox = ({
23
34
  onChange,
24
35
  }: CheckboxProps) => {
25
36
  // const { checkboxSize, checkboxStyle, checkboxLabelStyle } =
26
- // checkboxComponentStyles;
37
+ // checkboxComponentStyles || undefined;
27
38
  const fillColor = {
28
39
  backgroundColor: disabled
29
40
  ? '#d3d3d3'
@@ -27,12 +27,14 @@ const Dropdown = ({
27
27
  dropdownHelperTextStyle,
28
28
  primaryColor,
29
29
  disabled,
30
+ setIndexOfSelectedItem,
30
31
  }: any) => {
31
32
  return (
32
33
  <View style={[styles.dropdownInputContainer, dropdownContainerStyle]}>
33
34
  {label && label !== '' && (
34
35
  <Text style={[styles.label, labelStyle]}>{label}</Text>
35
36
  )}
37
+
36
38
  <DropdownSelectedItemsView
37
39
  placeholder={placeholder}
38
40
  error={error}
@@ -50,6 +52,7 @@ const Dropdown = ({
50
52
  primaryColor={primaryColor}
51
53
  disabled={disabled}
52
54
  placeholderStyle={placeholderStyle}
55
+ setIndexOfSelectedItem={setIndexOfSelectedItem}
53
56
  />
54
57
 
55
58
  {error && error !== '' && (
@@ -1,8 +1,9 @@
1
1
  /* eslint-disable react-native/no-inline-styles */
2
- import React from 'react';
2
+ import React, { useEffect, useRef } from 'react';
3
3
  import { FlatList, StyleSheet } from 'react-native';
4
4
  import DropdownListItem from './DropdownListItem';
5
5
  import { ItemSeparatorComponent, ListEmptyComponent } from '../Others';
6
+ import { TFlatList } from 'src/types/index.types';
6
7
 
7
8
  const DropdownFlatList = ({
8
9
  options,
@@ -20,8 +21,22 @@ const DropdownFlatList = ({
20
21
  checkboxLabelStyle, // kept for backwards compatibility to be removed in future release
21
22
  checkboxComponentStyles,
22
23
  listComponentStyles,
24
+ listIndex,
23
25
  ...rest
24
26
  }: any) => {
27
+ const flatlistRef = useRef<FlatList<TFlatList>>(null);
28
+
29
+ const scrollToItem = (index: number) => {
30
+ flatlistRef.current?.scrollToIndex({
31
+ index,
32
+ animated: true,
33
+ });
34
+ };
35
+
36
+ useEffect(() => {
37
+ scrollToItem(listIndex.itemIndex);
38
+ }, [listIndex]);
39
+
25
40
  return (
26
41
  <FlatList
27
42
  data={options}
@@ -49,6 +64,7 @@ const DropdownFlatList = ({
49
64
  onChange: isMultiple
50
65
  ? handleMultipleSelections
51
66
  : handleSingleSelection,
67
+ scrollToItem,
52
68
  primaryColor,
53
69
  checkboxSize, // kept for backwards compatibility
54
70
  checkboxStyle, // kept for backwards compatibility
@@ -57,6 +73,12 @@ const DropdownFlatList = ({
57
73
  })
58
74
  }
59
75
  keyExtractor={(_item, index) => `Options${index}`}
76
+ ref={flatlistRef}
77
+ onScrollToIndexFailed={({ index }) => {
78
+ setTimeout(() => {
79
+ scrollToItem(index);
80
+ }, 500);
81
+ }}
60
82
  {...rest}
61
83
  />
62
84
  );
@@ -75,6 +97,7 @@ const _renderItem = ({ item }: any, props: any) => {
75
97
  checkboxSize={props.checkboxSize}
76
98
  checkboxStyle={props.checkboxStyle}
77
99
  checkboxLabelStyle={props.checkboxLabelStyle}
100
+ scrollToItem={props.scrollToItem}
78
101
  checkboxComponentStyles={props.checkboxComponentStyles}
79
102
  />
80
103
  );