react-native-input-select 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +17 -6
  2. package/lib/commonjs/components/CheckBox/index.js +2 -8
  3. package/lib/commonjs/components/CheckBox/index.js.map +1 -1
  4. package/lib/commonjs/components/CheckBox/types.js.map +1 -1
  5. package/lib/commonjs/components/CustomModal/index.js +0 -7
  6. package/lib/commonjs/components/CustomModal/index.js.map +1 -1
  7. package/lib/commonjs/components/Dropdown/Dropdown.js +2 -11
  8. package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
  9. package/lib/commonjs/components/Dropdown/DropdownList.js +0 -22
  10. package/lib/commonjs/components/Dropdown/DropdownList.js.map +1 -1
  11. package/lib/commonjs/components/Dropdown/DropdownListItem.js +5 -17
  12. package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
  13. package/lib/commonjs/components/Dropdown/{SelectedItemsView.js → DropdownSelectedItemsView.js} +12 -16
  14. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -0
  15. package/lib/commonjs/components/Input/index.js +1 -10
  16. package/lib/commonjs/components/Input/index.js.map +1 -1
  17. package/lib/commonjs/constants/index.js.map +1 -1
  18. package/lib/commonjs/index.js +52 -35
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/styles/colors.js +1 -1
  21. package/lib/commonjs/styles/colors.js.map +1 -1
  22. package/lib/commonjs/styles/input.js +0 -4
  23. package/lib/commonjs/styles/input.js.map +1 -1
  24. package/lib/commonjs/styles/typography.js +0 -3
  25. package/lib/commonjs/styles/typography.js.map +1 -1
  26. package/lib/commonjs/types/index.types.js.map +1 -1
  27. package/lib/module/components/CheckBox/index.js +1 -3
  28. package/lib/module/components/CheckBox/index.js.map +1 -1
  29. package/lib/module/components/CheckBox/types.js.map +1 -1
  30. package/lib/module/components/CustomModal/index.js +0 -2
  31. package/lib/module/components/CustomModal/index.js.map +1 -1
  32. package/lib/module/components/Dropdown/Dropdown.js +2 -4
  33. package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
  34. package/lib/module/components/Dropdown/DropdownList.js +0 -16
  35. package/lib/module/components/Dropdown/DropdownList.js.map +1 -1
  36. package/lib/module/components/Dropdown/DropdownListItem.js +5 -8
  37. package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
  38. package/lib/module/components/Dropdown/{SelectedItemsView.js → DropdownSelectedItemsView.js} +12 -10
  39. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -0
  40. package/lib/module/components/Input/index.js +1 -2
  41. package/lib/module/components/Input/index.js.map +1 -1
  42. package/lib/module/constants/index.js.map +1 -1
  43. package/lib/module/index.js +52 -23
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/styles/colors.js +1 -1
  46. package/lib/module/styles/colors.js.map +1 -1
  47. package/lib/module/styles/input.js.map +1 -1
  48. package/lib/module/styles/typography.js.map +1 -1
  49. package/lib/module/types/index.types.js.map +1 -1
  50. package/lib/typescript/components/CheckBox/types.d.ts +1 -1
  51. package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +3 -0
  52. package/lib/typescript/types/index.types.d.ts +2 -2
  53. package/package.json +1 -1
  54. package/src/components/CheckBox/index.tsx +3 -1
  55. package/src/components/Dropdown/Dropdown.tsx +2 -2
  56. package/src/components/Dropdown/DropdownList.tsx +0 -11
  57. package/src/components/Dropdown/DropdownListItem.tsx +3 -4
  58. package/src/components/Dropdown/{SelectedItemsView.tsx → DropdownSelectedItemsView.tsx} +3 -2
  59. package/src/index.tsx +50 -2
  60. package/src/styles/colors.ts +1 -1
  61. package/src/types/index.types.ts +1 -1
  62. package/lib/commonjs/components/Dropdown/SelectedItemsView.js.map +0 -1
  63. package/lib/module/components/Dropdown/SelectedItemsView.js.map +0 -1
  64. package/lib/typescript/components/Dropdown/SelectedItemsView.d.ts +0 -3
@@ -2,8 +2,7 @@ import React from 'react';
2
2
  import { View, Text, Pressable, ScrollView, StyleSheet, Image, TouchableOpacity } from 'react-native';
3
3
  import { colors } from '../../styles/colors';
4
4
  import { inputStyles } from '../../styles/input';
5
-
6
- const SelectedItemsView = _ref => {
5
+ const DropdownSelectedItemsView = _ref => {
7
6
  let {
8
7
  placeholder,
9
8
  error,
@@ -25,10 +24,13 @@ const SelectedItemsView = _ref => {
25
24
  let {
26
25
  pressed
27
26
  } = _ref2;
28
- return [pressed && { ...inputStyles.inputFocusState,
27
+ return [pressed && {
28
+ ...inputStyles.inputFocusState,
29
29
  borderColor: primaryColor
30
- }, inputStyles.input, dropdownStyle, error && //this must be last
31
- error !== '' && !pressed && { ...inputStyles.inputFocusErrorState,
30
+ }, inputStyles.input, dropdownStyle, error &&
31
+ //this must be last
32
+ error !== '' && !pressed && {
33
+ ...inputStyles.inputFocusErrorState,
32
34
  ...dropdownErrorStyle
33
35
  }];
34
36
  },
@@ -55,13 +57,12 @@ const SelectedItemsView = _ref => {
55
57
  style: [styles.blackText, selectedItemStyle]
56
58
  }, getSelectedItemsLabel()))), !selectedItem && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) === 0 && /*#__PURE__*/React.createElement(Text, {
57
59
  style: styles.blackText
58
- }, placeholder !== null && placeholder !== void 0 ? placeholder : 'Select an option')), /*#__PURE__*/React.createElement(View, {
60
+ }, placeholder ?? 'Select an option')), /*#__PURE__*/React.createElement(View, {
59
61
  style: styles.iconStyle
60
62
  }, /*#__PURE__*/React.createElement(Image, {
61
63
  source: require('../../asset/arrow-down.png')
62
64
  })));
63
65
  };
64
-
65
66
  const styles = StyleSheet.create({
66
67
  iconStyle: {
67
68
  position: 'absolute',
@@ -78,11 +79,12 @@ const styles = StyleSheet.create({
78
79
  paddingVertical: 5,
79
80
  borderRadius: 10,
80
81
  backgroundColor: colors.primary,
81
- marginRight: 10
82
+ marginRight: 10,
83
+ overflow: 'hidden'
82
84
  },
83
85
  blackText: {
84
86
  color: colors.black
85
87
  }
86
88
  });
87
- export default SelectedItemsView;
88
- //# sourceMappingURL=SelectedItemsView.js.map
89
+ export default DropdownSelectedItemsView;
90
+ //# sourceMappingURL=DropdownSelectedItemsView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","TouchableOpacity","colors","inputStyles","DropdownSelectedItemsView","_ref","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownStyle","selectedItemStyle","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","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 dropdownStyle,\n selectedItemStyle,\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 <TouchableOpacity\n onPress={() => handleToggleModal()}\n key={`react-native-input-select-${Math.random()}-${i}`}\n disabled={disabled}\n >\n <Text\n style={[\n styles.selectedItems,\n { backgroundColor: primaryColor },\n multipleSelectedItemStyle,\n ]}\n >\n {item}\n </Text>\n </TouchableOpacity>\n ))\n ) : (\n <TouchableOpacity\n onPress={() => handleToggleModal()}\n disabled={disabled}\n >\n <Text style={[styles.blackText, selectedItemStyle]}>\n {getSelectedItemsLabel()}\n </Text>\n </TouchableOpacity>\n )}\n </View>\n\n {!selectedItem && selectedItems?.length === 0 && (\n <Text style={styles.blackText}>\n {placeholder ?? 'Select an option'}\n </Text>\n )}\n </ScrollView>\n <View style={styles.iconStyle}>\n <Image source={require('../../asset/arrow-down.png')} />\n </View>\n </Pressable>\n );\n};\n\nconst styles = StyleSheet.create({\n iconStyle: { position: 'absolute', right: 25, top: 25 },\n selectedItemsContainer: { flexDirection: 'row', flexWrap: 'nowrap' },\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,IAcvB;EAAA,IAdwB;IACjCC,WAAW;IACXC,KAAK;IACLC,qBAAqB;IACrBC,iBAAiB;IACjBC,UAAU;IACVC,YAAY;IACZC,aAAa;IACbC,aAAa;IACbC,iBAAiB;IACjBC,yBAAy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AAEF,eAAexD,yBAAyB"}
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || 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
-
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); }
3
2
  import React, { useState } from 'react';
4
3
  import { TextInput, StyleSheet, View } from 'react-native';
5
4
  import { inputStyles } from '../../styles/input';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["React","useState","TextInput","StyleSheet","View","inputStyles","Input","placeholder","value","onChangeText","style","primaryColor","rest","isFocused","setFocus","styles","container","input","inputFocusState","borderColor","create","margin"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,SAAT,EAAoBC,UAApB,EAAgCC,IAAhC,QAA4C,cAA5C;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,OAAO,MAAMC,KAAK,GAAG,QAOV;AAAA,MAPW;AACpBC,IAAAA,WADoB;AAEpBC,IAAAA,KAFoB;AAGpBC,IAAAA,YAHoB;AAIpBC,IAAAA,KAJoB;AAKpBC,IAAAA,YALoB;AAMpB,OAAGC;AANiB,GAOX;AACT,QAAM,CAACC,SAAD,EAAYC,QAAZ,IAAwBb,QAAQ,CAAC,KAAD,CAAtC;AAEA,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEc,MAAM,CAACC;AAApB,kBACE,oBAAC,SAAD;AACE,IAAA,WAAW,EAAET,WADf;AAEE,IAAA,KAAK,EAAE,CACLF,WAAW,CAACY,KADP,EAELJ,SAAS,IACPR,WAAW,CAACa,eADd,IACiC;AAAEC,MAAAA,WAAW,EAAER;AAAf,KAH5B,EAILD,KAJK,CAFT;AAQE,IAAA,OAAO,EAAE,MAAM;AACbI,MAAAA,QAAQ,CAAC,IAAD,CAAR;AACD,KAVH;AAWE,IAAA,MAAM,EAAE,MAAMA,QAAQ,CAAC,KAAD,CAXxB;AAYE,IAAA,KAAK,EAAEN,KAZT;AAaE,IAAA,YAAY,EAAEC;AAbhB,KAcMG,IAdN,EADF,CADF;AAoBD,CA9BM;AAgCP,MAAMG,MAAM,GAAGZ,UAAU,CAACiB,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,IAAAA,MAAM,EAAE;AAAV;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useState } from 'react';\nimport { TextInput, StyleSheet, View } from 'react-native';\nimport { inputStyles } from '../../styles/input';\n\nexport const Input = ({\n placeholder,\n value,\n onChangeText,\n style,\n primaryColor,\n ...rest\n}: any) => {\n const [isFocused, setFocus] = useState(false);\n\n return (\n <View style={styles.container}>\n <TextInput\n placeholder={placeholder}\n style={[\n inputStyles.input,\n isFocused &&\n inputStyles.inputFocusState && { borderColor: primaryColor },\n style,\n ]}\n onFocus={() => {\n setFocus(true);\n }}\n onBlur={() => setFocus(false)}\n value={value}\n onChangeText={onChangeText}\n {...rest}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { margin: 23 },\n});\n"]}
1
+ {"version":3,"names":["React","useState","TextInput","StyleSheet","View","inputStyles","Input","_ref","placeholder","value","onChangeText","style","primaryColor","rest","isFocused","setFocus","createElement","styles","container","_extends","input","inputFocusState","borderColor","onFocus","onBlur","create","margin"],"sources":["index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { TextInput, StyleSheet, View } from 'react-native';\nimport { inputStyles } from '../../styles/input';\n\nexport const Input = ({\n placeholder,\n value,\n onChangeText,\n style,\n primaryColor,\n ...rest\n}: any) => {\n const [isFocused, setFocus] = useState(false);\n\n return (\n <View style={styles.container}>\n <TextInput\n placeholder={placeholder}\n style={[\n inputStyles.input,\n isFocused &&\n inputStyles.inputFocusState && { borderColor: primaryColor },\n style,\n ]}\n onFocus={() => {\n setFocus(true);\n }}\n onBlur={() => setFocus(false)}\n value={value}\n onChangeText={onChangeText}\n {...rest}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { margin: 23 },\n});\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC1D,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,OAAO,MAAMC,KAAK,GAAGC,IAAA,IAOV;EAAA,IAPW;IACpBC,WAAW;IACXC,KAAK;IACLC,YAAY;IACZC,KAAK;IACLC,YAAY;IACZ,GAAGC;EACA,CAAC,GAAAN,IAAA;EACJ,MAAM,CAACO,SAAS,EAAEC,QAAQ,CAAC,GAAGd,QAAQ,CAAC,KAAK,CAAC;EAE7C,oBACED,KAAA,CAAAgB,aAAA,CAACZ,IAAI;IAACO,KAAK,EAAEM,MAAM,CAACC;EAAU,gBAC5BlB,KAAA,CAAAgB,aAAA,CAACd,SAAS,EAAAiB,QAAA;IACRX,WAAW,EAAEA,WAAY;IACzBG,KAAK,EAAE,CACLN,WAAW,CAACe,KAAK,EACjBN,SAAS,IACPT,WAAW,CAACgB,eAAe,IAAI;MAAEC,WAAW,EAAEV;IAAa,CAAC,EAC9DD,KAAK,CACL;IACFY,OAAO,EAAEA,CAAA,KAAM;MACbR,QAAQ,CAAC,IAAI,CAAC;IAChB,CAAE;IACFS,MAAM,EAAEA,CAAA,KAAMT,QAAQ,CAAC,KAAK,CAAE;IAC9BN,KAAK,EAAEA,KAAM;IACbC,YAAY,EAAEA;EAAa,GACvBG,IAAI,EACR,CACG;AAEX,CAAC;AAED,MAAMI,MAAM,GAAGd,UAAU,CAACsB,MAAM,CAAC;EAC/BP,SAAS,EAAE;IAAEQ,MAAM,EAAE;EAAG;AAC1B,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","CHECKBOX_SIZE"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,OAA7B;AACP,OAAO,MAAMC,oBAAoB,GAAG,OAA7B;AACP,OAAO,MAAMC,aAAa,GAAG,EAAtB","sourcesContent":["export const DEFAULT_OPTION_LABEL = 'label';\nexport const DEFAULT_OPTION_VALUE = 'value';\nexport const CHECKBOX_SIZE = 14;\n"]}
1
+ {"version":3,"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","CHECKBOX_SIZE"],"sources":["index.ts"],"sourcesContent":["export const DEFAULT_OPTION_LABEL = 'label';\nexport const DEFAULT_OPTION_VALUE = 'value';\nexport const CHECKBOX_SIZE = 14;\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,OAAO;AAC3C,OAAO,MAAMC,oBAAoB,GAAG,OAAO;AAC3C,OAAO,MAAMC,aAAa,GAAG,EAAE"}
@@ -1,12 +1,13 @@
1
- function _extends() { _extends = Object.assign || 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
-
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); }
3
2
  import React, { useState } from 'react';
3
+ import { TouchableOpacity, StyleSheet, View } from 'react-native';
4
4
  import Dropdown from './components/Dropdown/Dropdown';
5
5
  import DropdownList from './components/Dropdown/DropdownList';
6
6
  import CustomModal from './components/CustomModal';
7
- import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
8
7
  import { Input } from './components/Input';
8
+ import CheckBox from './components/CheckBox';
9
9
  import { colors } from './styles/colors';
10
+ import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
10
11
  export const DropdownSelect = _ref => {
11
12
  let {
12
13
  placeholder,
@@ -40,85 +41,94 @@ export const DropdownSelect = _ref => {
40
41
  } = _ref;
41
42
  const [newOptions, setNewOptions] = useState(options ? options : []);
42
43
  const [open, setOpen] = useState(false);
44
+ const [selectAll, setSelectAll] = useState(false);
43
45
  const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection
44
-
45
46
  const [selectedItems, setSelectedItems] = useState(Array.isArray(selectedValue) ? selectedValue : selectedValue === '' || selectedValue === undefined ? [] : [selectedValue]); //for multiple selection
46
-
47
47
  const [searchValue, setSearchValue] = useState('');
48
+
48
49
  /*===========================================
49
50
  * Selection handlers
50
51
  *==========================================*/
51
-
52
52
  const handleSingleSelection = value => {
53
53
  if (selectedItem === value) {
54
54
  setSelectedItem(null);
55
55
  } else {
56
56
  setSelectedItem(value);
57
57
  onValueChange(value); //send value to parent
58
-
59
58
  setOpen(false); //close modal upon selection
60
59
  }
61
60
  };
62
61
 
63
62
  const handleMultipleSelections = value => {
64
63
  let selectedValues = [...selectedItems];
65
-
66
64
  if (selectedValues.includes(value)) {
67
65
  selectedValues = selectedValues.filter(item => item !== value);
68
66
  } else {
69
67
  selectedValues.push(value);
70
68
  }
71
-
72
69
  setSelectedItems(selectedValues);
73
70
  onValueChange(selectedValues); //send value to parent
71
+
72
+ if (newOptions.length === selectedValues.length) {
73
+ setSelectAll(true);
74
+ } else {
75
+ setSelectAll(false);
76
+ }
77
+ };
78
+ const handleSelectAll = () => {
79
+ setSelectAll(prevVal => {
80
+ const selectedValues = [];
81
+ if (!prevVal) {
82
+ for (let i = 0; i < newOptions.length; i++) {
83
+ selectedValues.push(newOptions[i][optionValue]);
84
+ }
85
+ }
86
+ setSelectedItems(selectedValues);
87
+ onValueChange(selectedValues); //send value to parent
88
+ return !prevVal;
89
+ });
74
90
  };
91
+
75
92
  /*===========================================
76
93
  * Get label handler
77
94
  *==========================================*/
78
-
79
-
80
95
  const getSelectedItemsLabel = () => {
81
96
  if (isMultiple) {
82
97
  let selectedLabels = [];
83
98
  selectedItems && selectedItems.forEach(element => {
84
99
  var _options$find;
85
-
86
- let selectedItemLabel = options && ((_options$find = options.find(item => item[optionValue !== null && optionValue !== void 0 ? optionValue : DEFAULT_OPTION_VALUE] === element)) === null || _options$find === void 0 ? void 0 : _options$find[optionLabel]);
100
+ let selectedItemLabel = options && ((_options$find = options.find(item => item[optionValue ?? DEFAULT_OPTION_VALUE] === element)) === null || _options$find === void 0 ? void 0 : _options$find[optionLabel]);
87
101
  selectedLabels.push(selectedItemLabel);
88
102
  });
89
103
  return selectedLabels;
90
104
  }
91
-
92
- let selectedItemLabel = options && options.find(item => item[optionValue !== null && optionValue !== void 0 ? optionValue : DEFAULT_OPTION_VALUE] === selectedItem);
93
- return selectedItemLabel === null || selectedItemLabel === void 0 ? void 0 : selectedItemLabel[optionLabel !== null && optionLabel !== void 0 ? optionLabel : DEFAULT_OPTION_LABEL];
105
+ let selectedItemLabel = options && options.find(item => item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem);
106
+ return selectedItemLabel === null || selectedItemLabel === void 0 ? void 0 : selectedItemLabel[optionLabel ?? DEFAULT_OPTION_LABEL];
94
107
  };
108
+
95
109
  /*===========================================
96
110
  * Search
97
111
  *==========================================*/
98
-
99
-
100
112
  const onSearch = value => {
101
113
  setSearchValue(value);
102
114
  let searchText = value.toString().toLocaleLowerCase().trim();
103
115
  const regexFilter = new RegExp(searchText, 'i');
104
116
  const searchResults = options.filter(item => {
105
- if (item[optionLabel !== null && optionLabel !== void 0 ? optionLabel : DEFAULT_OPTION_LABEL].toString().toLowerCase().search(regexFilter) !== -1 || item[optionValue !== null && optionValue !== void 0 ? optionValue : DEFAULT_OPTION_VALUE].toString(regexFilter).toLowerCase().search(regexFilter) !== -1) {
117
+ if (item[optionLabel ?? DEFAULT_OPTION_LABEL].toString().toLowerCase().search(regexFilter) !== -1 || item[optionValue ?? DEFAULT_OPTION_VALUE].toString(regexFilter).toLowerCase().search(regexFilter) !== -1) {
106
118
  return item;
107
119
  }
108
120
  });
109
121
  setNewOptions(searchResults);
110
122
  };
123
+
111
124
  /*===========================================
112
125
  * Modal
113
126
  *==========================================*/
114
-
115
-
116
127
  const handleToggleModal = () => {
117
128
  setOpen(!open);
118
129
  setSearchValue('');
119
130
  setNewOptions(options);
120
131
  };
121
-
122
132
  let primary = primaryColor || colors.gray;
123
133
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, _extends({
124
134
  label: label,
@@ -151,7 +161,19 @@ export const DropdownSelect = _ref => {
151
161
  onChangeText: text => onSearch(text),
152
162
  style: searchInputStyle,
153
163
  primaryColor: primary
154
- }), /*#__PURE__*/React.createElement(DropdownList, {
164
+ }), isMultiple && newOptions.length > 1 && /*#__PURE__*/React.createElement(View, {
165
+ style: styles.optionsContainerStyle
166
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
167
+ onPress: () => {}
168
+ }, /*#__PURE__*/React.createElement(CheckBox, {
169
+ value: selectAll,
170
+ label: selectAll ? 'Clear all' : 'Select all',
171
+ onChange: () => handleSelectAll(),
172
+ primaryColor: primary,
173
+ checkboxSize: checkboxSize,
174
+ checkboxStyle: checkboxStyle,
175
+ checkboxLabelStyle: checkboxLabelStyle
176
+ }))), /*#__PURE__*/React.createElement(DropdownList, {
155
177
  options: newOptions,
156
178
  optionLabel: optionLabel,
157
179
  optionValue: optionValue,
@@ -166,5 +188,12 @@ export const DropdownSelect = _ref => {
166
188
  checkboxLabelStyle: checkboxLabelStyle
167
189
  })));
168
190
  };
191
+ const styles = StyleSheet.create({
192
+ optionsContainerStyle: {
193
+ paddingHorizontal: 20,
194
+ paddingVertical: 10,
195
+ flexDirection: 'row'
196
+ }
197
+ });
169
198
  export default DropdownSelect;
170
199
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["React","useState","Dropdown","DropdownList","CustomModal","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","Input","colors","DropdownSelect","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","labelStyle","dropdownStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainer","searchInputStyle","primaryColor","disabled","checkboxSize","checkboxStyle","checkboxLabelStyle","rest","newOptions","setNewOptions","open","setOpen","selectedItem","setSelectedItem","selectedItems","setSelectedItems","Array","isArray","undefined","searchValue","setSearchValue","handleSingleSelection","value","handleMultipleSelections","selectedValues","includes","filter","item","push","getSelectedItemsLabel","selectedLabels","forEach","element","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","searchResults","toLowerCase","search","handleToggleModal","primary","gray","text"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,OAAOC,QAAP,MAAqB,gCAArB;AACA,OAAOC,YAAP,MAAyB,oCAAzB;AACA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,aAA3D;AAEA,SAASC,KAAT,QAAsB,oBAAtB;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAEA,OAAO,MAAMC,cAAc,GAAG,QA6BT;AAAA,MA7BU;AAC7BC,IAAAA,WAD6B;AAE7BC,IAAAA,KAF6B;AAG7BC,IAAAA,KAH6B;AAI7BC,IAAAA,UAJ6B;AAK7BC,IAAAA,OAL6B;AAM7BC,IAAAA,WAN6B;AAO7BC,IAAAA,WAP6B;AAQ7BC,IAAAA,aAR6B;AAS7BC,IAAAA,aAT6B;AAU7BC,IAAAA,UAV6B;AAW7BC,IAAAA,YAX6B;AAY7BC,IAAAA,UAZ6B;AAa7BC,IAAAA,aAb6B;AAc7BC,IA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IAAA,kBAAkB,EAAEC;AAZtB,IAfF,CAvBF,CADF;AAwDD,CA7LM;AA+LP,eAAe3B,cAAf","sourcesContent":["import React, { useState } from 'react';\nimport Dropdown from './components/Dropdown/Dropdown';\nimport DropdownList from './components/Dropdown/DropdownList';\nimport CustomModal from './components/CustomModal';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type { DropdownProps } from './types/index.types';\nimport { Input } from './components/Input';\nimport { colors } from './styles/colors';\n\nexport const DropdownSelect = ({\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainer,\n searchInputStyle,\n primaryColor,\n disabled,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n ...rest\n}: DropdownProps) => {\n const [newOptions, setNewOptions] = useState(options ? options : []);\n const [open, setOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection\n const [selectedItems, setSelectedItems] = useState(\n Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue === '' || selectedValue === undefined\n ? []\n : [selectedValue]\n ); //for multiple selection\n const [searchValue, setSearchValue] = useState('');\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: any) => {\n if (selectedItem === value) {\n setSelectedItem(null);\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: any) => {\n let selectedValues = [...selectedItems];\n\n if (selectedValues.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n };\n\n /*===========================================\n * Get label handler\n *==========================================*/\n const getSelectedItemsLabel = () => {\n if (isMultiple) {\n let selectedLabels: Array<string> = [];\n selectedItems &&\n selectedItems.forEach((element) => {\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === element\n )?.[optionLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem\n );\n return selectedItemLabel?.[optionLabel ?? DEFAULT_OPTION_LABEL];\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 const searchResults = options.filter((item: any) => {\n if (\n item[optionLabel ?? DEFAULT_OPTION_LABEL]\n .toString()\n .toLowerCase()\n .search(regexFilter) !== -1 ||\n item[optionValue ?? DEFAULT_OPTION_VALUE]\n .toString(regexFilter)\n .toLowerCase()\n .search(regexFilter) !== -1\n ) {\n return item;\n }\n });\n\n setNewOptions(searchResults);\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n };\n\n let primary = primaryColor || colors.gray;\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 dropdownStyle={dropdownStyle}\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 {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainer={modalOptionsContainer}\n onRequestClose={() => {}}\n >\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primary}\n />\n )}\n <DropdownList\n options={newOptions}\n optionLabel={optionLabel}\n optionValue={optionValue}\n isMultiple={isMultiple}\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 />\n </CustomModal>\n </>\n );\n};\n\nexport default DropdownSelect;\n"]}
1
+ {"version":3,"names":["React","useState","TouchableOpacity","StyleSheet","View","Dropdown","DropdownList","CustomModal","Input","CheckBox","colors","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","DropdownSelect","_ref","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","labelStyle","dropdownStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainer","searchInputStyle","primaryColor","disabled","checkboxSize","checkboxStyle","checkboxLabelStyle","rest","newOptions","setNewOptions","open","setOpen","selectAll","setSelectAll","selectedItem","setSelectedItem","selectedItems","setSelectedItems","Array","isArray","undefined","searchValue","setSearchValue","handleSingleSelection","value","handleMultipleSelections","selectedValues","includes","filter","item","push","length","handleSelectAll","prevVal","i","getSelectedItemsLabel","selectedLabels","forEach","element","_options$find","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","searchResults","toLowerCase","search","handleToggleModal","primary","gray","createElement","Fragment","_extends","onRequestClose","onChangeText","text","style","styles","optionsContainerStyle","onPress","onChange","create","paddingHorizontal","paddingVertical","flexDirection"],"sources":["index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { TouchableOpacity, StyleSheet, View } from 'react-native';\nimport Dropdown from './components/Dropdown/Dropdown';\nimport DropdownList from './components/Dropdown/DropdownList';\nimport CustomModal from './components/CustomModal';\nimport { Input } from './components/Input';\nimport CheckBox from './components/CheckBox';\nimport { colors } from './styles/colors';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type { DropdownProps } from './types/index.types';\n\nexport const DropdownSelect = ({\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainer,\n searchInputStyle,\n primaryColor,\n disabled,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n ...rest\n}: DropdownProps) => {\n const [newOptions, setNewOptions] = useState(options ? options : []);\n const [open, setOpen] = useState(false);\n const [selectAll, setSelectAll] = useState(false);\n const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection\n const [selectedItems, setSelectedItems] = useState(\n Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue === '' || selectedValue === undefined\n ? []\n : [selectedValue]\n ); //for multiple selection\n const [searchValue, setSearchValue] = useState('');\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: any) => {\n if (selectedItem === value) {\n setSelectedItem(null);\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: any) => {\n let selectedValues = [...selectedItems];\n\n if (selectedValues.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n\n if (newOptions.length === selectedValues.length) {\n setSelectAll(true);\n } else {\n setSelectAll(false);\n }\n };\n\n const handleSelectAll = () => {\n setSelectAll((prevVal) => {\n const selectedValues = [];\n\n if (!prevVal) {\n for (let i = 0; i < newOptions.length; i++) {\n selectedValues.push(newOptions[i][optionValue]);\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) {\n let selectedLabels: Array<string> = [];\n selectedItems &&\n selectedItems.forEach((element) => {\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === element\n )?.[optionLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem\n );\n return selectedItemLabel?.[optionLabel ?? DEFAULT_OPTION_LABEL];\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 const searchResults = options.filter((item: any) => {\n if (\n item[optionLabel ?? DEFAULT_OPTION_LABEL]\n .toString()\n .toLowerCase()\n .search(regexFilter) !== -1 ||\n item[optionValue ?? DEFAULT_OPTION_VALUE]\n .toString(regexFilter)\n .toLowerCase()\n .search(regexFilter) !== -1\n ) {\n return item;\n }\n });\n\n setNewOptions(searchResults);\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n };\n\n let primary = primaryColor || colors.gray;\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 dropdownStyle={dropdownStyle}\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 {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainer={modalOptionsContainer}\n onRequestClose={() => {}}\n >\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primary}\n />\n )}\n {isMultiple && newOptions.length > 1 && (\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 />\n </TouchableOpacity>\n </View>\n )}\n <DropdownList\n options={newOptions}\n optionLabel={optionLabel}\n optionValue={optionValue}\n isMultiple={isMultiple}\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 />\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,QAAQ,OAAO;AACvC,SAASC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ACzBC,WAAW,EAAEA,WAAY;IACzBG,UAAU,EAAEA,UAAW;IACvB2B,aAAa,EAAEA,aAAc;IAC7BF,YAAY,EAAEA,YAAa;IAC3BW,wBAAwB,EAAEA,wBAAyB;IACnDF,qBAAqB,EAAEA,qBAAsB;IAC7CrB,YAAY,EAAEmD,OAAQ;IACtBjD,YAAY,EAAEA,YAAa;IAC3BC,aAAa,EAAEA,aAAc;IAC7BC,kBAAkB,EAAEA;EAAmB,EACvC,CACU,CACb;AAEP,CAAC;AAED,MAAMwD,MAAM,GAAG9F,UAAU,CAACkG,MAAM,CAAC;EAC/BH,qBAAqB,EAAE;IACrBI,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAEF,eAAe3F,cAAc"}
@@ -1,5 +1,5 @@
1
1
  export const colors = {
2
- primary: '#EF8031',
2
+ primary: 'green',
3
3
  red: '#FA4169',
4
4
  black: '#000000',
5
5
  white: '#FFFFFF',
@@ -1 +1 @@
1
- {"version":3,"sources":["colors.ts"],"names":["colors","primary","red","black","white","dark","gray","lightGray"],"mappings":"AAAA,OAAO,MAAMA,MAAW,GAAG;AACzBC,EAAAA,OAAO,EAAE,SADgB;AAEzBC,EAAAA,GAAG,EAAE,SAFoB;AAGzBC,EAAAA,KAAK,EAAE,SAHkB;AAIzBC,EAAAA,KAAK,EAAE,SAJkB;AAKzBC,EAAAA,IAAI,EAAE,SALmB;AAMzBC,EAAAA,IAAI,EAAE,SANmB;AAOzBC,EAAAA,SAAS,EAAE;AAPc,CAApB","sourcesContent":["export const colors: any = {\n primary: '#EF8031',\n red: '#FA4169',\n black: '#000000',\n white: '#FFFFFF',\n dark: '#11142D',\n gray: '#808191',\n lightGray: '#F7F7F7',\n};\n"]}
1
+ {"version":3,"names":["colors","primary","red","black","white","dark","gray","lightGray"],"sources":["colors.ts"],"sourcesContent":["export const colors: any = {\n primary: 'green',\n red: '#FA4169',\n black: '#000000',\n white: '#FFFFFF',\n dark: '#11142D',\n gray: '#808191',\n lightGray: '#F7F7F7',\n};\n"],"mappings":"AAAA,OAAO,MAAMA,MAAW,GAAG;EACzBC,OAAO,EAAE,OAAO;EAChBC,GAAG,EAAE,SAAS;EACdC,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE,SAAS;EACfC,IAAI,EAAE,SAAS;EACfC,SAAS,EAAE;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["input.ts"],"names":["StyleSheet","colors","inputStyles","create","input","paddingVertical","paddingHorizontal","backgroundColor","lightGray","borderRadius","borderColor","dark","borderWidth","color","width","minHeight","inputFocusErrorState","borderStyle","red","inputFocusState","primary"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,MAAT,QAAuB,UAAvB;AAEA,OAAO,MAAMC,WAAgB,GAAGF,UAAU,CAACG,MAAX,CAAkB;AAChDC,EAAAA,KAAK,EAAE;AACLC,IAAAA,eAAe,EAAE,EADZ;AAELC,IAAAA,iBAAiB,EAAE,EAFd;AAGLC,IAAAA,eAAe,EAAEN,MAAM,CAACO,SAHnB;AAILC,IAAAA,YAAY,EAAE,CAJT;AAKLC,IAAAA,WAAW,EAAET,MAAM,CAACU,IALf;AAMLC,IAAAA,WAAW,EAAE,CANR;AAOLC,IAAAA,KAAK,EAAEZ,MAAM,CAACU,IAPT;AAQLG,IAAAA,KAAK,EAAE,MARF;AASLC,IAAAA,SAAS,EAAE;AATN,GADyC;AAYhDC,EAAAA,oBAAoB,EAAE;AACpBJ,IAAAA,WAAW,EAAE,CADO;AAEpBK,IAAAA,WAAW,EAAE,OAFO;AAGpBP,IAAAA,WAAW,EAAET,MAAM,CAACiB;AAHA,GAZ0B;AAiBhDC,EAAAA,eAAe,EAAE;AACfP,IAAAA,WAAW,EAAE,CADE;AAEfK,IAAAA,WAAW,EAAE,OAFE;AAGfP,IAAAA,WAAW,EAAET,MAAM,CAACmB;AAHL;AAjB+B,CAAlB,CAAzB","sourcesContent":["import { StyleSheet } from 'react-native';\nimport { colors } from './colors';\n\nexport const inputStyles: any = StyleSheet.create({\n input: {\n paddingVertical: 18,\n paddingHorizontal: 23,\n backgroundColor: colors.lightGray,\n borderRadius: 8,\n borderColor: colors.dark,\n borderWidth: 1,\n color: colors.dark,\n width: '100%',\n minHeight: 64,\n },\n inputFocusErrorState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.red,\n },\n inputFocusState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.primary,\n },\n});\n"]}
1
+ {"version":3,"names":["StyleSheet","colors","inputStyles","create","input","paddingVertical","paddingHorizontal","backgroundColor","lightGray","borderRadius","borderColor","dark","borderWidth","color","width","minHeight","inputFocusErrorState","borderStyle","red","inputFocusState","primary"],"sources":["input.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\nimport { colors } from './colors';\n\nexport const inputStyles: any = StyleSheet.create({\n input: {\n paddingVertical: 18,\n paddingHorizontal: 23,\n backgroundColor: colors.lightGray,\n borderRadius: 8,\n borderColor: colors.dark,\n borderWidth: 1,\n color: colors.dark,\n width: '100%',\n minHeight: 64,\n },\n inputFocusErrorState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.red,\n },\n inputFocusState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.primary,\n },\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,MAAM,QAAQ,UAAU;AAEjC,OAAO,MAAMC,WAAgB,GAAGF,UAAU,CAACG,MAAM,CAAC;EAChDC,KAAK,EAAE;IACLC,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAEN,MAAM,CAACO,SAAS;IACjCC,YAAY,EAAE,CAAC;IACfC,WAAW,EAAET,MAAM,CAACU,IAAI;IACxBC,WAAW,EAAE,CAAC;IACdC,KAAK,EAAEZ,MAAM,CAACU,IAAI;IAClBG,KAAK,EAAE,MAAM;IACbC,SAAS,EAAE;EACb,CAAC;EACDC,oBAAoB,EAAE;IACpBJ,WAAW,EAAE,CAAC;IACdK,WAAW,EAAE,OAAO;IACpBP,WAAW,EAAET,MAAM,CAACiB;EACtB,CAAC;EACDC,eAAe,EAAE;IACfP,WAAW,EAAE,CAAC;IACdK,WAAW,EAAE,OAAO;IACpBP,WAAW,EAAET,MAAM,CAACmB;EACtB;AACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["typography.ts"],"names":["StyleSheet","typography","create","caption","fontStyle","fontWeight","fontSize","lineHeight"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AAEA,OAAO,MAAMC,UAAe,GAAGD,UAAU,CAACE,MAAX,CAAkB;AAC/CC,EAAAA,OAAO,EAAE;AACPC,IAAAA,SAAS,EAAE,QADJ;AAEPC,IAAAA,UAAU,EAAE,QAFL;AAGPC,IAAAA,QAAQ,EAAE,EAHH;AAIPC,IAAAA,UAAU,EAAE;AAJL;AADsC,CAAlB,CAAxB","sourcesContent":["import { StyleSheet } from 'react-native';\n\nexport const typography: any = StyleSheet.create({\n caption: {\n fontStyle: 'normal',\n fontWeight: 'normal',\n fontSize: 12,\n lineHeight: 15,\n },\n});\n"]}
1
+ {"version":3,"names":["StyleSheet","typography","create","caption","fontStyle","fontWeight","fontSize","lineHeight"],"sources":["typography.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\n\nexport const typography: any = StyleSheet.create({\n caption: {\n fontStyle: 'normal',\n fontWeight: 'normal',\n fontSize: 12,\n lineHeight: 15,\n },\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,UAAe,GAAGD,UAAU,CAACE,MAAM,CAAC;EAC/CC,OAAO,EAAE;IACPC,SAAS,EAAE,QAAQ;IACnBC,UAAU,EAAE,QAAQ;IACpBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["index.types.ts"],"sourcesContent":["import type { ViewStyle, ColorValue, TextStyle } from 'react-native';\n\nexport type DropdownProps = {\n placeholder?: string;\n label?: string;\n error?: string;\n helperText?: string;\n options: any[];\n optionLabel: string;\n optionValue: string;\n onValueChange: Function;\n selectedValue?: string | any[] | null;\n isMultiple?: boolean;\n isSearchable?: boolean;\n labelStyle?: TextStyle;\n dropdownStyle?: ViewStyle;\n dropdownContainerStyle?: ViewStyle;\n dropdownErrorStyle?: ViewStyle;\n dropdownErrorTextStyle?: TextStyle;\n dropdownHelperTextStyle?: TextStyle;\n selectedItemStyle?: ViewStyle;\n multipleSelectedItemStyle?: ViewStyle;\n modalBackgroundStyle?: ViewStyle;\n modalOptionsContainer?: ViewStyle;\n searchInputStyle?: ViewStyle;\n primaryColor?: ColorValue;\n disabled?: boolean;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n};\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import type { ColorValue, ViewStyle, TextStyle } from 'react-native';
2
- export declare type CheckboxProps = {
2
+ export type CheckboxProps = {
3
3
  label?: string;
4
4
  value?: boolean;
5
5
  primaryColor?: ColorValue;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const DropdownSelectedItemsView: ({ placeholder, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownStyle, selectedItemStyle, multipleSelectedItemStyle, dropdownErrorStyle, primaryColor, disabled, }: any) => JSX.Element;
3
+ export default DropdownSelectedItemsView;
@@ -1,12 +1,12 @@
1
1
  import type { ViewStyle, ColorValue, TextStyle } from 'react-native';
2
- export declare type DropdownProps = {
2
+ export type DropdownProps = {
3
3
  placeholder?: string;
4
4
  label?: string;
5
5
  error?: string;
6
6
  helperText?: string;
7
7
  options: any[];
8
8
  optionLabel: string;
9
- optionValue?: string;
9
+ optionValue: string;
10
10
  onValueChange: Function;
11
11
  selectedValue?: string | any[] | null;
12
12
  isMultiple?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-input-select",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
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",
@@ -14,7 +14,9 @@ const CheckBox = ({
14
14
  onChange,
15
15
  }: CheckboxProps) => {
16
16
  const fillColor = {
17
- backgroundColor: value ? primaryColor || 'green' : 'white',
17
+ backgroundColor: value
18
+ ? checkboxStyle?.backgroundColor || primaryColor || 'green'
19
+ : 'white',
18
20
  };
19
21
  return (
20
22
  <Pressable
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { View, Text, StyleSheet } from 'react-native';
3
- import SelectedItemsView from './SelectedItemsView';
3
+ import DropdownSelectedItemsView from './DropdownSelectedItemsView';
4
4
  import { colors } from '../../styles/colors';
5
5
  import { typography } from '../../styles/typography';
6
6
 
@@ -30,7 +30,7 @@ const Dropdown = ({
30
30
  {label && label !== '' && (
31
31
  <Text style={[styles.label, labelStyle]}>{label}</Text>
32
32
  )}
33
- <SelectedItemsView
33
+ <DropdownSelectedItemsView
34
34
  placeholder={placeholder}
35
35
  error={error}
36
36
  getSelectedItemsLabel={getSelectedItemsLabel}
@@ -66,17 +66,6 @@ const _renderItem = ({ item }: any, props: any) => {
66
66
  };
67
67
 
68
68
  const styles = StyleSheet.create({
69
- modalContainer: {
70
- flex: 1,
71
- justifyContent: 'flex-end',
72
- },
73
- modalBackgroundStyle: { backgroundColor: 'rgba(0, 0, 0, 0.5)' },
74
- modalOptionsContainer: {
75
- maxHeight: '50%',
76
- backgroundColor: colors.white,
77
- borderTopLeftRadius: 16,
78
- borderTopRightRadius: 16,
79
- },
80
69
  itemSeparatorStyle: {
81
70
  backgroundColor: colors.gray,
82
71
  height: 1,
@@ -1,7 +1,6 @@
1
1
  import React, { memo } from 'react';
2
2
  import { TouchableOpacity, StyleSheet } from 'react-native';
3
3
  import CheckBox from '../CheckBox';
4
- import { colors } from '../../styles/colors';
5
4
 
6
5
  const DropdownListItem = ({
7
6
  item,
@@ -18,7 +17,7 @@ const DropdownListItem = ({
18
17
  const selectedOptionValue = optionValue ?? 'value';
19
18
  return (
20
19
  <TouchableOpacity
21
- style={styles.modalOptions}
20
+ style={styles.dropdownModalOptions}
22
21
  onPress={() => onChange(item[selectedOptionValue])}
23
22
  >
24
23
  <CheckBox
@@ -29,7 +28,7 @@ const DropdownListItem = ({
29
28
  }
30
29
  label={item[optionLabel ?? '']}
31
30
  onChange={() => onChange(item[selectedOptionValue])}
32
- primaryColor={primaryColor || colors.primary}
31
+ primaryColor={primaryColor}
33
32
  checkboxSize={checkboxSize}
34
33
  checkboxStyle={checkboxStyle}
35
34
  checkboxLabelStyle={checkboxLabelStyle}
@@ -39,7 +38,7 @@ const DropdownListItem = ({
39
38
  };
40
39
 
41
40
  const styles = StyleSheet.create({
42
- modalOptions: {
41
+ dropdownModalOptions: {
43
42
  paddingHorizontal: 20,
44
43
  paddingVertical: 10,
45
44
  flexDirection: 'row',
@@ -11,7 +11,7 @@ import {
11
11
  import { colors } from '../../styles/colors';
12
12
  import { inputStyles } from '../../styles/input';
13
13
 
14
- const SelectedItemsView = ({
14
+ const DropdownSelectedItemsView = ({
15
15
  placeholder,
16
16
  error,
17
17
  getSelectedItemsLabel,
@@ -107,8 +107,9 @@ const styles = StyleSheet.create({
107
107
  borderRadius: 10,
108
108
  backgroundColor: colors.primary,
109
109
  marginRight: 10,
110
+ overflow: 'hidden',
110
111
  },
111
112
  blackText: { color: colors.black },
112
113
  });
113
114
 
114
- export default SelectedItemsView;
115
+ export default DropdownSelectedItemsView;
package/src/index.tsx CHANGED
@@ -1,11 +1,13 @@
1
1
  import React, { useState } from 'react';
2
+ import { TouchableOpacity, StyleSheet, View } from 'react-native';
2
3
  import Dropdown from './components/Dropdown/Dropdown';
3
4
  import DropdownList from './components/Dropdown/DropdownList';
4
5
  import CustomModal from './components/CustomModal';
5
- import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
6
- import type { DropdownProps } from './types/index.types';
7
6
  import { Input } from './components/Input';
7
+ import CheckBox from './components/CheckBox';
8
8
  import { colors } from './styles/colors';
9
+ import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
10
+ import type { DropdownProps } from './types/index.types';
9
11
 
10
12
  export const DropdownSelect = ({
11
13
  placeholder,
@@ -39,6 +41,7 @@ export const DropdownSelect = ({
39
41
  }: DropdownProps) => {
40
42
  const [newOptions, setNewOptions] = useState(options ? options : []);
41
43
  const [open, setOpen] = useState(false);
44
+ const [selectAll, setSelectAll] = useState(false);
42
45
  const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection
43
46
  const [selectedItems, setSelectedItems] = useState(
44
47
  Array.isArray(selectedValue)
@@ -72,6 +75,28 @@ export const DropdownSelect = ({
72
75
  }
73
76
  setSelectedItems(selectedValues);
74
77
  onValueChange(selectedValues); //send value to parent
78
+
79
+ if (newOptions.length === selectedValues.length) {
80
+ setSelectAll(true);
81
+ } else {
82
+ setSelectAll(false);
83
+ }
84
+ };
85
+
86
+ const handleSelectAll = () => {
87
+ setSelectAll((prevVal) => {
88
+ const selectedValues = [];
89
+
90
+ if (!prevVal) {
91
+ for (let i = 0; i < newOptions.length; i++) {
92
+ selectedValues.push(newOptions[i][optionValue]);
93
+ }
94
+ }
95
+
96
+ setSelectedItems(selectedValues);
97
+ onValueChange(selectedValues); //send value to parent
98
+ return !prevVal;
99
+ });
75
100
  };
76
101
 
77
102
  /*===========================================
@@ -179,6 +204,21 @@ export const DropdownSelect = ({
179
204
  primaryColor={primary}
180
205
  />
181
206
  )}
207
+ {isMultiple && newOptions.length > 1 && (
208
+ <View style={styles.optionsContainerStyle}>
209
+ <TouchableOpacity onPress={() => {}}>
210
+ <CheckBox
211
+ value={selectAll}
212
+ label={selectAll ? 'Clear all' : 'Select all'}
213
+ onChange={() => handleSelectAll()}
214
+ primaryColor={primary}
215
+ checkboxSize={checkboxSize}
216
+ checkboxStyle={checkboxStyle}
217
+ checkboxLabelStyle={checkboxLabelStyle}
218
+ />
219
+ </TouchableOpacity>
220
+ </View>
221
+ )}
182
222
  <DropdownList
183
223
  options={newOptions}
184
224
  optionLabel={optionLabel}
@@ -198,4 +238,12 @@ export const DropdownSelect = ({
198
238
  );
199
239
  };
200
240
 
241
+ const styles = StyleSheet.create({
242
+ optionsContainerStyle: {
243
+ paddingHorizontal: 20,
244
+ paddingVertical: 10,
245
+ flexDirection: 'row',
246
+ },
247
+ });
248
+
201
249
  export default DropdownSelect;
@@ -1,5 +1,5 @@
1
1
  export const colors: any = {
2
- primary: '#EF8031',
2
+ primary: 'green',
3
3
  red: '#FA4169',
4
4
  black: '#000000',
5
5
  white: '#FFFFFF',
@@ -7,7 +7,7 @@ export type DropdownProps = {
7
7
  helperText?: string;
8
8
  options: any[];
9
9
  optionLabel: string;
10
- optionValue?: string;
10
+ optionValue: string;
11
11
  onValueChange: Function;
12
12
  selectedValue?: string | any[] | null;
13
13
  isMultiple?: boolean;