react-native-input-select 0.23.0 → 0.25.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 (50) hide show
  1. package/lib/commonjs/components/CheckBox/index.js +6 -2
  2. package/lib/commonjs/components/CheckBox/index.js.map +1 -1
  3. package/lib/commonjs/components/CheckBox/types.js.map +1 -1
  4. package/lib/commonjs/components/Dropdown/Dropdown.js +2 -2
  5. package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
  6. package/lib/commonjs/components/Dropdown/DropdownList.js +12 -16
  7. package/lib/commonjs/components/Dropdown/DropdownList.js.map +1 -1
  8. package/lib/commonjs/components/Dropdown/DropdownListItem.js +6 -6
  9. package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
  10. package/lib/commonjs/components/Dropdown/{SelectedItemsView.js → DropdownSelectedItemsView.js} +5 -4
  11. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -0
  12. package/lib/commonjs/index.js +51 -7
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/styles/colors.js +3 -2
  15. package/lib/commonjs/styles/colors.js.map +1 -1
  16. package/lib/commonjs/types/index.types.js.map +1 -1
  17. package/lib/module/components/CheckBox/index.js +6 -2
  18. package/lib/module/components/CheckBox/index.js.map +1 -1
  19. package/lib/module/components/CheckBox/types.js.map +1 -1
  20. package/lib/module/components/Dropdown/Dropdown.js +2 -2
  21. package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
  22. package/lib/module/components/Dropdown/DropdownList.js +13 -16
  23. package/lib/module/components/Dropdown/DropdownList.js.map +1 -1
  24. package/lib/module/components/Dropdown/DropdownListItem.js +6 -6
  25. package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
  26. package/lib/module/components/Dropdown/{SelectedItemsView.js → DropdownSelectedItemsView.js} +5 -4
  27. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -0
  28. package/lib/module/index.js +51 -7
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/styles/colors.js +3 -2
  31. package/lib/module/styles/colors.js.map +1 -1
  32. package/lib/module/types/index.types.js.map +1 -1
  33. package/lib/typescript/components/CheckBox/index.d.ts +1 -1
  34. package/lib/typescript/components/CheckBox/types.d.ts +1 -0
  35. package/lib/typescript/components/Dropdown/DropdownList.d.ts +1 -1
  36. package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +3 -0
  37. package/lib/typescript/types/index.types.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/src/components/CheckBox/index.tsx +10 -1
  40. package/src/components/CheckBox/types.ts +1 -0
  41. package/src/components/Dropdown/Dropdown.tsx +2 -2
  42. package/src/components/Dropdown/DropdownList.tsx +8 -11
  43. package/src/components/Dropdown/DropdownListItem.tsx +7 -5
  44. package/src/components/Dropdown/{SelectedItemsView.tsx → DropdownSelectedItemsView.tsx} +3 -2
  45. package/src/index.tsx +63 -10
  46. package/src/styles/colors.ts +2 -1
  47. package/src/types/index.types.ts +1 -1
  48. package/lib/commonjs/components/Dropdown/SelectedItemsView.js.map +0 -1
  49. package/lib/module/components/Dropdown/SelectedItemsView.js.map +0 -1
  50. package/lib/typescript/components/Dropdown/SelectedItemsView.d.ts +0 -3
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-native/no-inline-styles */
1
2
  import React from 'react';
2
3
  import { View, FlatList, StyleSheet, Text } from 'react-native';
3
4
  import DropdownListItem from './DropdownListItem';
@@ -8,6 +9,7 @@ const DropdownList = ({
8
9
  optionLabel,
9
10
  optionValue,
10
11
  isMultiple,
12
+ isSearchable,
11
13
  selectedItems,
12
14
  selectedItem,
13
15
  handleMultipleSelections,
@@ -16,6 +18,7 @@ const DropdownList = ({
16
18
  checkboxSize,
17
19
  checkboxStyle,
18
20
  checkboxLabelStyle,
21
+ ...rest
19
22
  }: any) => {
20
23
  return (
21
24
  <FlatList
@@ -27,6 +30,9 @@ const DropdownList = ({
27
30
  <Text>No options available</Text>
28
31
  </View>
29
32
  }
33
+ contentContainerStyle={[
34
+ isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,
35
+ ]}
30
36
  ItemSeparatorComponent={() => <View style={styles.itemSeparatorStyle} />}
31
37
  renderItem={(item) =>
32
38
  _renderItem(item, {
@@ -44,6 +50,7 @@ const DropdownList = ({
44
50
  })
45
51
  }
46
52
  keyExtractor={(_item, index) => `Options${index}`}
53
+ {...rest}
47
54
  />
48
55
  );
49
56
  };
@@ -66,23 +73,13 @@ const _renderItem = ({ item }: any, props: any) => {
66
73
  };
67
74
 
68
75
  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
76
  itemSeparatorStyle: {
81
77
  backgroundColor: colors.gray,
82
78
  height: 1,
83
79
  opacity: 0.15,
84
80
  },
85
81
  emptyListStyle: { alignItems: 'center', width: '100%', marginVertical: 20 },
82
+ contentContainerStyle: { paddingTop: 20 },
86
83
  });
87
84
 
88
85
  export default DropdownList;
@@ -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,8 +17,10 @@ const DropdownListItem = ({
18
17
  const selectedOptionValue = optionValue ?? 'value';
19
18
  return (
20
19
  <TouchableOpacity
21
- style={styles.modalOptions}
22
- onPress={() => onChange(item[selectedOptionValue])}
20
+ style={styles.dropdownModalOptions}
21
+ onPress={
22
+ item.disabled ? () => {} : () => onChange(item[selectedOptionValue]) // intentionally didn't use the disable property
23
+ }
23
24
  >
24
25
  <CheckBox
25
26
  value={
@@ -29,17 +30,18 @@ const DropdownListItem = ({
29
30
  }
30
31
  label={item[optionLabel ?? '']}
31
32
  onChange={() => onChange(item[selectedOptionValue])}
32
- primaryColor={primaryColor || colors.primary}
33
+ primaryColor={primaryColor}
33
34
  checkboxSize={checkboxSize}
34
35
  checkboxStyle={checkboxStyle}
35
36
  checkboxLabelStyle={checkboxLabelStyle}
37
+ disabled={item.disabled}
36
38
  />
37
39
  </TouchableOpacity>
38
40
  );
39
41
  };
40
42
 
41
43
  const styles = StyleSheet.create({
42
- modalOptions: {
44
+ dropdownModalOptions: {
43
45
  paddingHorizontal: 20,
44
46
  paddingVertical: 10,
45
47
  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 (options.length === selectedValues.length) {
80
+ setSelectAll(true);
81
+ } else {
82
+ setSelectAll(false);
83
+ }
84
+ };
85
+
86
+ const handleSelectAll = () => {
87
+ setSelectAll((prevVal) => {
88
+ const selectedValues = [];
89
+ const filteredOptions = newOptions.filter((item) => !item.disabled); //don't select disabled items
90
+ if (!prevVal) {
91
+ for (let i = 0; i < filteredOptions.length; i++) {
92
+ selectedValues.push(filteredOptions[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
  /*===========================================
@@ -171,19 +196,39 @@ export const DropdownSelect = ({
171
196
  modalOptionsContainer={modalOptionsContainer}
172
197
  onRequestClose={() => {}}
173
198
  >
174
- {isSearchable && (
175
- <Input
176
- value={searchValue}
177
- onChangeText={(text: string) => onSearch(text)}
178
- style={searchInputStyle}
179
- primaryColor={primary}
180
- />
181
- )}
182
199
  <DropdownList
200
+ ListHeaderComponent={
201
+ <>
202
+ {isSearchable && (
203
+ <Input
204
+ value={searchValue}
205
+ onChangeText={(text: string) => onSearch(text)}
206
+ style={searchInputStyle}
207
+ primaryColor={primary}
208
+ />
209
+ )}
210
+ {isMultiple && newOptions.length > 1 && (
211
+ <View style={styles.optionsContainerStyle}>
212
+ <TouchableOpacity onPress={() => {}}>
213
+ <CheckBox
214
+ value={selectAll}
215
+ label={selectAll ? 'Clear all' : 'Select all'}
216
+ onChange={() => handleSelectAll()}
217
+ primaryColor={primary}
218
+ checkboxSize={checkboxSize}
219
+ checkboxStyle={checkboxStyle}
220
+ checkboxLabelStyle={checkboxLabelStyle}
221
+ />
222
+ </TouchableOpacity>
223
+ </View>
224
+ )}
225
+ </>
226
+ }
183
227
  options={newOptions}
184
228
  optionLabel={optionLabel}
185
229
  optionValue={optionValue}
186
230
  isMultiple={isMultiple}
231
+ isSearchable={isSearchable}
187
232
  selectedItems={selectedItems}
188
233
  selectedItem={selectedItem}
189
234
  handleMultipleSelections={handleMultipleSelections}
@@ -198,4 +243,12 @@ export const DropdownSelect = ({
198
243
  );
199
244
  };
200
245
 
246
+ const styles = StyleSheet.create({
247
+ optionsContainerStyle: {
248
+ paddingHorizontal: 20,
249
+ paddingVertical: 10,
250
+ flexDirection: 'row',
251
+ },
252
+ });
253
+
201
254
  export default DropdownSelect;
@@ -1,9 +1,10 @@
1
1
  export const colors: any = {
2
- primary: '#EF8031',
2
+ primary: 'green',
3
3
  red: '#FA4169',
4
4
  black: '#000000',
5
5
  white: '#FFFFFF',
6
6
  dark: '#11142D',
7
7
  gray: '#808191',
8
8
  lightGray: '#F7F7F7',
9
+ disabled: '#d3d3d3',
9
10
  };
@@ -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;
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","_input","obj","__esModule","default","SelectedItemsView","_ref","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownStyle","selectedItemStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","createElement","Pressable","onPress","style","_ref2","pressed","inputStyles","inputFocusState","borderColor","input","inputFocusErrorState","ScrollView","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","View","styles","selectedItemsContainer","onStartShouldSetResponder","map","item","i","TouchableOpacity","key","Math","random","Text","backgroundColor","blackText","length","iconStyle","Image","source","StyleSheet","create","position","right","top","flexDirection","flexWrap","color","colors","white","paddingHorizontal","paddingVertical","borderRadius","primary","marginRight","black","_default","exports"],"sources":["SelectedItemsView.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 SelectedItemsView = ({\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 },\n blackText: { color: colors.black },\n});\n\nexport default SelectedItemsView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAiD,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjD,MAAMG,iBAAiB,GAAGC,IAAA,IAcf;EAAA,IAdgB;IACzBC,WAAW;IACXC,KAAK;IACLC,qBAAqB;IACrBC,iBAAiB;IACjBC,UAAU;IACVC,YAAY;IACZC,aAAa;IACbC,aAAa;IACbC,iBAAiB;IACjBC,yBAAyB;IACzBC,kBAAkB;IAClBC,YAAY;IACZC;EACG,CAAC,GAAAb,IAAA;EACJ,oBACEV,MAAA,CAAAQ,OAAA,CAAAgB,aAAA,CAACrB,YAAA,CAAAsB,SAAS;IACRC,OAAO,EAAEA,CAAA,KAAMZ,iBAAiB,EAAG;IACnCa,KAAK,EAAEC,KAAA;MAAA,IAAC;QAAEC;MAAQ,CAAC,GAAAD,KAAA;MAAA,OAAK,CACtBC,OAAO,IAAI;QACT,GAAGC,kBAAW,CAACC,eAAe;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,GAAAiE,QAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","TouchableOpacity","colors","inputStyles","SelectedItemsView","_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","black"],"sources":["SelectedItemsView.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 SelectedItemsView = ({\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 },\n blackText: { color: colors.black },\n});\n\nexport default SelectedItemsView;\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,iBAAiB,GAAGC,IAAA,IAcf;EAAA,IAdgB;IACzBC,WAAW;IACXC,KAAK;IACLC,qBAAqB;IACrBC,iBAAiB;IACjBC,UAAU;IACVC,YAAY;IACZC,aAAa;IACbC,aAAa;IACbC,iBAAiB;IACjBC,yBAAyB;IACzBC,kBAAkB;IAClBC,YAAY;IACZC;EACG,CAAC,GAAAb,IAAA;EACJ,oBACEX,KAAA,CAAAyB,aAAA,CAACtB,SAAS;IACRuB,OAAO,EAAEA,CAAA,KAAMX,i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ACvB,IAAI;IAACyB,KAAK,EAAE,CAACU,MAAM,CAACU,SAAS,EAAE3B,iBAAiB;EAAE,GAChDN,qBAAqB,EAAE,CACnB,CAEV,CACI,EAEN,CAACG,YAAY,IAAI,CAAAC,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAE8B,MAAM,MAAK,CAAC,iBAC3ChD,KAAA,CAAAyB,aAAA,CAACvB,IAAI;IAACyB,KAAK,EAAEU,MAAM,CAACU;EAAU,GAC3BnC,WAAW,IAAI,kBAAkB,CAErC,CACU,eACbZ,KAAA,CAAAyB,aAAA,CAACxB,IAAI;IAAC0B,KAAK,EAAEU,MAAM,CAACY;EAAU,gBAC5BjD,KAAA,CAAAyB,aAAA,CAACnB,KAAK;IAAC4C,MAAM,EAAEC,OAAO,CAAC,4BAA4B;EAAE,EAAG,CACnD,CACG;AAEhB,CAAC;AAED,MAAMd,MAAM,GAAGhC,UAAU,CAAC+C,MAAM,CAAC;EAC/BH,SAAS,EAAE;IAAEI,QAAQ,EAAE,UAAU;IAAEC,KAAK,EAAE,EAAE;IAAEC,GAAG,EAAE;EAAG,CAAC;EACvDjB,sBAAsB,EAAE;IAAEkB,aAAa,EAAE,KAAK;IAAEC,QAAQ,EAAE;EAAS,CAAC;EACpEvC,aAAa,EAAE;IACbwC,KAAK,EAAElD,MAAM,CAACmD,KAAK;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,CAAC;IAClBC,YAAY,EAAE,EAAE;IAChBhB,eAAe,EAAEtC,MAAM,CAACuD,OAAO;IAC/BC,WAAW,EAAE;EACf,CAAC;EACDjB,SAAS,EAAE;IAAEW,KAAK,EAAElD,MAAM,CAACyD;EAAM;AACnC,CAAC,CAAC;AAEF,eAAevD,iBAAiB"}
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare const SelectedItemsView: ({ placeholder, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownStyle, selectedItemStyle, multipleSelectedItemStyle, dropdownErrorStyle, primaryColor, disabled, }: any) => JSX.Element;
3
- export default SelectedItemsView;