react-native-input-select 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/CheckBox/checkbox.types.js.map +1 -1
- package/lib/commonjs/components/CheckBox/index.js +21 -24
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CustomModal/index.js +31 -21
- package/lib/commonjs/components/CustomModal/index.js.map +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +26 -28
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js +37 -42
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +21 -23
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js +45 -52
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +42 -51
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/components/Input/index.js +12 -14
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Others/index.js +17 -21
- package/lib/commonjs/components/Others/index.js.map +1 -1
- package/lib/commonjs/constants/index.js +3 -6
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/index.js +92 -84
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/styles/colors.js +1 -2
- package/lib/commonjs/styles/colors.js.map +1 -1
- package/lib/commonjs/styles/input.js +1 -2
- package/lib/commonjs/styles/input.js.map +1 -1
- package/lib/commonjs/styles/typography.js +1 -2
- package/lib/commonjs/styles/typography.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/commonjs/utils/index.js +1 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/CheckBox/checkbox.types.js.map +1 -1
- package/lib/module/components/CheckBox/index.js +20 -22
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CustomModal/index.js +31 -20
- package/lib/module/components/CustomModal/index.js.map +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +25 -26
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownFlatList.js +34 -38
- package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownListItem.js +18 -19
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSectionList.js +42 -48
- package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +41 -49
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/components/Input/index.js +9 -10
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Others/index.js +17 -21
- package/lib/module/components/Others/index.js.map +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/index.js +91 -82
- package/lib/module/index.js.map +1 -1
- package/lib/module/styles/colors.js.map +1 -1
- package/lib/module/styles/input.js.map +1 -1
- package/lib/module/styles/typography.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/components/CheckBox/checkbox.types.d.ts +1 -0
- package/lib/typescript/components/CheckBox/checkbox.types.d.ts.map +1 -0
- package/lib/typescript/components/CheckBox/index.d.ts +3 -2
- package/lib/typescript/components/CheckBox/index.d.ts.map +1 -0
- package/lib/typescript/components/CustomModal/index.d.ts +3 -2
- package/lib/typescript/components/CustomModal/index.d.ts.map +1 -0
- package/lib/typescript/components/Dropdown/Dropdown.d.ts +3 -2
- package/lib/typescript/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +3 -2
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts.map +1 -0
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +2 -1
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts.map +1 -0
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +3 -2
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts.map +1 -0
- package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +3 -2
- package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts.map +1 -0
- package/lib/typescript/components/Input/index.d.ts +3 -2
- package/lib/typescript/components/Input/index.d.ts.map +1 -0
- package/lib/typescript/components/Others/index.d.ts +8 -7
- package/lib/typescript/components/Others/index.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +1 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/styles/colors.d.ts +1 -0
- package/lib/typescript/styles/colors.d.ts.map +1 -0
- package/lib/typescript/styles/input.d.ts +1 -0
- package/lib/typescript/styles/input.d.ts.map +1 -0
- package/lib/typescript/styles/typography.d.ts +1 -0
- package/lib/typescript/styles/typography.d.ts.map +1 -0
- package/lib/typescript/types/index.types.d.ts +1 -0
- package/lib/typescript/types/index.types.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/package.json +21 -20
- package/src/components/CustomModal/index.tsx +48 -25
- package/src/index.tsx +24 -2
|
@@ -3,46 +3,41 @@ import React from 'react';
|
|
|
3
3
|
import { View, Text, Pressable, ScrollView, StyleSheet, Image, TouchableOpacity } from 'react-native';
|
|
4
4
|
import { colors } from '../../styles/colors';
|
|
5
5
|
import { inputStyles } from '../../styles/input';
|
|
6
|
-
const DropdownSelectedItemsView =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setIndexOfSelectedItem
|
|
26
|
-
} = _ref;
|
|
6
|
+
const DropdownSelectedItemsView = ({
|
|
7
|
+
placeholder,
|
|
8
|
+
error,
|
|
9
|
+
getSelectedItemsLabel,
|
|
10
|
+
handleToggleModal,
|
|
11
|
+
isMultiple,
|
|
12
|
+
selectedItem,
|
|
13
|
+
selectedItems,
|
|
14
|
+
dropdownIcon,
|
|
15
|
+
dropdownStyle,
|
|
16
|
+
dropdownIconStyle,
|
|
17
|
+
selectedItemStyle,
|
|
18
|
+
placeholderStyle,
|
|
19
|
+
multipleSelectedItemStyle,
|
|
20
|
+
dropdownErrorStyle,
|
|
21
|
+
primaryColor,
|
|
22
|
+
disabled,
|
|
23
|
+
setIndexOfSelectedItem
|
|
24
|
+
}) => {
|
|
27
25
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
28
26
|
onPress: () => handleToggleModal(),
|
|
29
|
-
style:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...dropdownErrorStyle
|
|
44
|
-
}];
|
|
45
|
-
},
|
|
27
|
+
style: ({
|
|
28
|
+
pressed
|
|
29
|
+
}) => [pressed && {
|
|
30
|
+
...inputStyles.inputFocusState,
|
|
31
|
+
borderColor: primaryColor
|
|
32
|
+
}, {
|
|
33
|
+
...inputStyles.input,
|
|
34
|
+
...dropdownStyle
|
|
35
|
+
}, error &&
|
|
36
|
+
//this must be last
|
|
37
|
+
error !== '' && !pressed && {
|
|
38
|
+
...inputStyles.inputFocusErrorState,
|
|
39
|
+
...dropdownErrorStyle
|
|
40
|
+
}],
|
|
46
41
|
disabled: disabled
|
|
47
42
|
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
48
43
|
horizontal: true,
|
|
@@ -51,12 +46,11 @@ const DropdownSelectedItemsView = _ref => {
|
|
|
51
46
|
}, /*#__PURE__*/React.createElement(View, {
|
|
52
47
|
style: styles.selectedItemsContainer,
|
|
53
48
|
onStartShouldSetResponder: () => true
|
|
54
|
-
}, isMultiple ?
|
|
49
|
+
}, isMultiple ? getSelectedItemsLabel()?.map((label, i) => /*#__PURE__*/React.createElement(DropdownContent, {
|
|
55
50
|
onPress: () => {
|
|
56
51
|
handleToggleModal();
|
|
57
52
|
setIndexOfSelectedItem(label); // immediately scrolls to list item with the specified label when modal
|
|
58
53
|
},
|
|
59
|
-
|
|
60
54
|
key: `react-native-input-select-${Math.random()}-${i}`,
|
|
61
55
|
style: [styles.selectedItems, {
|
|
62
56
|
backgroundColor: primaryColor
|
|
@@ -68,11 +62,10 @@ const DropdownSelectedItemsView = _ref => {
|
|
|
68
62
|
handleToggleModal();
|
|
69
63
|
setIndexOfSelectedItem(getSelectedItemsLabel()); // immediately scrolls to list item with the specified label when modal
|
|
70
64
|
},
|
|
71
|
-
|
|
72
65
|
style: [styles.blackText, selectedItemStyle],
|
|
73
66
|
label: getSelectedItemsLabel(),
|
|
74
67
|
disabled: disabled
|
|
75
|
-
}), !selectedItem &&
|
|
68
|
+
}), !selectedItem && selectedItems?.length === 0 && /*#__PURE__*/React.createElement(DropdownContent, {
|
|
76
69
|
onPress: () => handleToggleModal(),
|
|
77
70
|
style: [styles.blackText, placeholderStyle],
|
|
78
71
|
label: placeholder ?? 'Select an option',
|
|
@@ -83,13 +76,12 @@ const DropdownSelectedItemsView = _ref => {
|
|
|
83
76
|
source: require('../../asset/arrow-down.png')
|
|
84
77
|
})));
|
|
85
78
|
};
|
|
86
|
-
const DropdownContent =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} = _ref3;
|
|
79
|
+
const DropdownContent = ({
|
|
80
|
+
onPress,
|
|
81
|
+
style,
|
|
82
|
+
label,
|
|
83
|
+
...rest
|
|
84
|
+
}) => {
|
|
93
85
|
return /*#__PURE__*/React.createElement(TouchableOpacity, _extends({
|
|
94
86
|
onPress: () => onPress()
|
|
95
87
|
}, rest), /*#__PURE__*/React.createElement(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","TouchableOpacity","colors","inputStyles","DropdownSelectedItemsView","
|
|
1
|
+
{"version":3,"names":["React","View","Text","Pressable","ScrollView","StyleSheet","Image","TouchableOpacity","colors","inputStyles","DropdownSelectedItemsView","placeholder","error","getSelectedItemsLabel","handleToggleModal","isMultiple","selectedItem","selectedItems","dropdownIcon","dropdownStyle","dropdownIconStyle","selectedItemStyle","placeholderStyle","multipleSelectedItemStyle","dropdownErrorStyle","primaryColor","disabled","setIndexOfSelectedItem","createElement","onPress","style","pressed","inputFocusState","borderColor","input","inputFocusErrorState","horizontal","alwaysBounceHorizontal","showsHorizontalScrollIndicator","styles","selectedItemsContainer","onStartShouldSetResponder","map","label","i","DropdownContent","key","Math","random","backgroundColor","blackText","length","iconStyle","source","require","rest","_extends","create","position","right","top","flexDirection","flexWrap","alignItems","color","white","paddingHorizontal","paddingVertical","borderRadius","primary","marginRight","overflow","black"],"sourceRoot":"../../../../src","sources":["components/Dropdown/DropdownSelectedItemsView.tsx"],"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,GAAGA,CAAC;EACjCC,WAAW;EACXC,KAAK;EACLC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A;IAAC3B,OAAO,EAAEA,CAAA,KAAMA,OAAO,CAAC;EAAE,GAAK0B,IAAI,gBAClDvD,KAAA,CAAA4B,aAAA,CAAC1B,IAAI;IAAC4B,KAAK,EAAEA;EAAM,GAAEa,KAAY,CACjB,CAAC;AAEvB,CAAC;AAED,MAAMJ,MAAM,GAAGlC,UAAU,CAACoD,MAAM,CAAC;EAC/BL,SAAS,EAAE;IAAEM,QAAQ,EAAE,UAAU;IAAEC,KAAK,EAAE,EAAE;IAAEC,GAAG,EAAE;EAAG,CAAC;EACvDpB,sBAAsB,EAAE;IACtBqB,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,QAAQ;IAClBC,UAAU,EAAE;EACd,CAAC;EACD9C,aAAa,EAAE;IACb+C,KAAK,EAAExD,MAAM,CAACyD,KAAK;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,CAAC;IAClBC,YAAY,EAAE,EAAE;IAChBnB,eAAe,EAAEzC,MAAM,CAAC6D,OAAO;IAC/BC,WAAW,EAAE,EAAE;IACfC,QAAQ,EAAE;EACZ,CAAC;EACDrB,SAAS,EAAE;IAAEc,KAAK,EAAExD,MAAM,CAACgE;EAAM;AACnC,CAAC,CAAC;AAEF,eAAe9D,yBAAyB","ignoreList":[]}
|
|
@@ -2,16 +2,15 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { TextInput, StyleSheet, View, Platform } from 'react-native';
|
|
4
4
|
import { inputStyles } from '../../styles/input';
|
|
5
|
-
export const Input =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
5
|
+
export const Input = ({
|
|
6
|
+
placeholder,
|
|
7
|
+
value,
|
|
8
|
+
onChangeText,
|
|
9
|
+
style,
|
|
10
|
+
primaryColor,
|
|
11
|
+
textInputContainerStyle,
|
|
12
|
+
...rest
|
|
13
|
+
}) => {
|
|
15
14
|
const [isFocused, setFocus] = useState(false);
|
|
16
15
|
return /*#__PURE__*/React.createElement(View, {
|
|
17
16
|
style: [styles.container, textInputContainerStyle]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TextInput","StyleSheet","View","Platform","inputStyles","Input","
|
|
1
|
+
{"version":3,"names":["React","useState","TextInput","StyleSheet","View","Platform","inputStyles","Input","placeholder","value","onChangeText","style","primaryColor","textInputContainerStyle","rest","isFocused","setFocus","createElement","styles","container","_extends","input","select","web","outlineColor","borderColor","onFocus","onBlur","returnKeyType","create","margin"],"sourceRoot":"../../../../src","sources":["components/Input/index.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,cAAc;AACpE,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,OAAO,MAAMC,KAAK,GAAGA,CAAC;EACpBC,WAAW;EACXC,KAAK;EACLC,YAAY;EACZC,KAAK;EACLC,YAAY;EACZC,uBAAuB;EACvB,GAAGC;AACA,CAAC,KAAK;EACT,MAAM,CAACC,SAAS,EAAEC,QAAQ,CAAC,GAAGf,QAAQ,CAAC,KAAK,CAAC;EAE7C,oBACED,KAAA,CAAAiB,aAAA,CAACb,IAAI;IAACO,KAAK,EAAE,CAACO,MAAM,CAACC,SAAS,EAAEN,uBAAuB;EAAE,gBACvDb,KAAA,CAAAiB,aAAA,CAACf,SAAS,EAAAkB,QAAA;IACRZ,WAAW,EAAEA,WAAY;IACzBG,KAAK,EAAE,CACLL,WAAW,CAACe,KAAK,EACjBhB,QAAQ,CAACiB,MAAM,CAAC;MACdC,GAAG,EAAE;QACHC,YAAY,EAAEZ;MAChB;IACF,CAAC,CAAC,EACFG,SAAS,IAAI;MAAEU,WAAW,EAAEb;IAAa,CAAC,EAC1CD,KAAK,CACL;IACFe,OAAO,EAAEA,CAAA,KAAM;MACbV,QAAQ,CAAC,IAAI,CAAC;IAChB,CAAE;IACFW,MAAM,EAAEA,CAAA,KAAMX,QAAQ,CAAC,KAAK,CAAE;IAC9BP,KAAK,EAAEA,KAAM;IACbC,YAAY,EAAEA,YAAa;IAC3BkB,aAAa,EAAC;EAAQ,GAClBd,IAAI,CACT,CACG,CAAC;AAEX,CAAC;AAED,MAAMI,MAAM,GAAGf,UAAU,CAAC0B,MAAM,CAAC;EAC/BV,SAAS,EAAE;IAAEW,MAAM,EAAE;EAAG;AAC1B,CAAC,CAAC;AAEF,eAAevB,KAAK","ignoreList":[]}
|
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { colors } from '../../styles/colors';
|
|
4
|
-
export const ListEmptyComponent =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} = _ref;
|
|
4
|
+
export const ListEmptyComponent = ({
|
|
5
|
+
listEmptyComponentStyle,
|
|
6
|
+
emptyListMessage
|
|
7
|
+
}) => {
|
|
9
8
|
return /*#__PURE__*/React.createElement(View, {
|
|
10
9
|
style: styles.listEmptyComponentStyle
|
|
11
10
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
12
11
|
style: listEmptyComponentStyle
|
|
13
12
|
}, emptyListMessage || 'No options available'));
|
|
14
13
|
};
|
|
15
|
-
export const ItemSeparatorComponent =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref2;
|
|
14
|
+
export const ItemSeparatorComponent = ({
|
|
15
|
+
itemSeparatorStyle
|
|
16
|
+
}) => {
|
|
19
17
|
return /*#__PURE__*/React.createElement(View, {
|
|
20
18
|
style: [styles.itemSeparatorStyle, itemSeparatorStyle]
|
|
21
19
|
});
|
|
22
20
|
};
|
|
23
|
-
export const ListItemContainer =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref3;
|
|
21
|
+
export const ListItemContainer = ({
|
|
22
|
+
children,
|
|
23
|
+
listItemContainerStyle
|
|
24
|
+
}) => {
|
|
28
25
|
return /*#__PURE__*/React.createElement(View, {
|
|
29
26
|
style: [styles.listItemContainerStyle, listItemContainerStyle]
|
|
30
27
|
}, children);
|
|
31
28
|
};
|
|
32
|
-
export const SectionHeaderTitle =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} = _ref4;
|
|
29
|
+
export const SectionHeaderTitle = ({
|
|
30
|
+
title,
|
|
31
|
+
sectionHeaderStyle,
|
|
32
|
+
onPress,
|
|
33
|
+
isExpanded
|
|
34
|
+
}) => {
|
|
39
35
|
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
40
36
|
onPress: onPress
|
|
41
37
|
}, /*#__PURE__*/React.createElement(ListItemContainer, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Text","StyleSheet","TouchableOpacity","Image","colors","ListEmptyComponent","
|
|
1
|
+
{"version":3,"names":["React","View","Text","StyleSheet","TouchableOpacity","Image","colors","ListEmptyComponent","listEmptyComponentStyle","emptyListMessage","createElement","style","styles","ItemSeparatorComponent","itemSeparatorStyle","ListItemContainer","children","listItemContainerStyle","SectionHeaderTitle","title","sectionHeaderStyle","onPress","isExpanded","accordionStyle","rotatedIcon90","source","require","create","alignItems","width","marginVertical","backgroundColor","gray","height","opacity","paddingHorizontal","paddingVertical","flexDirection","fontWeight","flexWrap","justifyContent","alignContent","transform","rotate"],"sourceRoot":"../../../../src","sources":["components/Others/index.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAqB,OAAO;AACxC,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAEhBC,KAAK,QAEA,cAAc;AACrB,SAASC,MAAM,QAAQ,qBAAqB;AAE5C,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,u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CAAE,CACnD,CACW,CACH,CAAC;AAEvB,CAAC;AAED,MAAMd,MAAM,GAAGT,UAAU,CAACwB,MAAM,CAAC;EAC/BnB,uBAAuB,EAAE;IACvBoB,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,cAAc,EAAE;EAClB,CAAC;EACDhB,kBAAkB,EAAE;IAClBiB,eAAe,EAAEzB,MAAM,CAAC0B,IAAI;IAC5BC,MAAM,EAAE,CAAC;IACTC,OAAO,EAAE;EACX,CAAC;EACDjB,sBAAsB,EAAE;IACtBkB,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE,KAAK;IACpBT,UAAU,EAAE;EACd,CAAC;EACDR,kBAAkB,EAAE;IAAEkB,UAAU,EAAE;EAAM,CAAC;EACzCf,cAAc,EAAE;IACdc,aAAa,EAAE,KAAK;IACpBE,QAAQ,EAAE,QAAQ;IAClBC,cAAc,EAAE,eAAe;IAC/BC,YAAY,EAAE;EAChB,CAAC;EACDjB,aAAa,EAAE;IACbkB,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAS,CAAC;EAClC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","CHECKBOX_SIZE"],"
|
|
1
|
+
{"version":3,"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","CHECKBOX_SIZE"],"sourceRoot":"../../../src","sources":["constants/index.ts"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,OAAO;AAC3C,OAAO,MAAMC,oBAAoB,GAAG,OAAO;AAC3C,OAAO,MAAMC,aAAa,GAAG,EAAE","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, useCallback } from 'react';
|
|
3
|
-
import { TouchableOpacity, StyleSheet, View } from 'react-native';
|
|
2
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
3
|
+
import { TouchableOpacity, StyleSheet, View, Platform } from 'react-native';
|
|
4
4
|
import Input from './components/Input';
|
|
5
5
|
import CheckBox from './components/CheckBox';
|
|
6
6
|
import Dropdown from './components/Dropdown/Dropdown';
|
|
@@ -10,61 +10,59 @@ import CustomModal from './components/CustomModal';
|
|
|
10
10
|
import { colors } from './styles/colors';
|
|
11
11
|
import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
|
|
12
12
|
import { escapeRegExp, extractPropertyFromArray } from './utils';
|
|
13
|
-
export const DropdownSelect =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...rest
|
|
67
|
-
} = _ref;
|
|
13
|
+
export const DropdownSelect = ({
|
|
14
|
+
placeholder,
|
|
15
|
+
label,
|
|
16
|
+
error,
|
|
17
|
+
helperText,
|
|
18
|
+
options,
|
|
19
|
+
optionLabel,
|
|
20
|
+
optionValue,
|
|
21
|
+
onValueChange,
|
|
22
|
+
selectedValue,
|
|
23
|
+
isMultiple,
|
|
24
|
+
isSearchable,
|
|
25
|
+
dropdownIcon,
|
|
26
|
+
labelStyle,
|
|
27
|
+
placeholderStyle,
|
|
28
|
+
dropdownStyle,
|
|
29
|
+
dropdownIconStyle,
|
|
30
|
+
dropdownContainerStyle,
|
|
31
|
+
dropdownErrorStyle,
|
|
32
|
+
dropdownErrorTextStyle,
|
|
33
|
+
dropdownHelperTextStyle,
|
|
34
|
+
selectedItemStyle,
|
|
35
|
+
multipleSelectedItemStyle,
|
|
36
|
+
modalBackgroundStyle,
|
|
37
|
+
// kept for backwards compatibility
|
|
38
|
+
modalOptionsContainerStyle,
|
|
39
|
+
// kept for backwards compatibility
|
|
40
|
+
searchInputStyle,
|
|
41
|
+
// kept for backwards compatibility
|
|
42
|
+
primaryColor,
|
|
43
|
+
disabled,
|
|
44
|
+
checkboxSize,
|
|
45
|
+
// kept for backwards compatibility
|
|
46
|
+
checkboxStyle,
|
|
47
|
+
// kept for backwards compatibility
|
|
48
|
+
checkboxLabelStyle,
|
|
49
|
+
// kept for backwards compatibility
|
|
50
|
+
checkboxComponentStyles,
|
|
51
|
+
// kept for backwards compatibility
|
|
52
|
+
checkboxComponent,
|
|
53
|
+
// kept for backwards compatibility
|
|
54
|
+
listHeaderComponent,
|
|
55
|
+
listFooterComponent,
|
|
56
|
+
listComponentStyles,
|
|
57
|
+
modalProps,
|
|
58
|
+
// kept for backwards compatibility
|
|
59
|
+
hideModal = false,
|
|
60
|
+
listControls,
|
|
61
|
+
searchControls,
|
|
62
|
+
modalControls,
|
|
63
|
+
checkboxControls,
|
|
64
|
+
...rest
|
|
65
|
+
}) => {
|
|
68
66
|
const [newOptions, setNewOptions] = useState([]);
|
|
69
67
|
const [open, setOpen] = useState(false);
|
|
70
68
|
const [selectAll, setSelectAll] = useState(false);
|
|
@@ -90,9 +88,9 @@ export const DropdownSelect = _ref => {
|
|
|
90
88
|
*==========================================*/
|
|
91
89
|
|
|
92
90
|
// check the structure of the new options array to determine if it is a section list or a
|
|
93
|
-
const isSectionList = newOptions
|
|
91
|
+
const isSectionList = newOptions?.some(item => item.title && item.data && Array.isArray(item.data));
|
|
94
92
|
const ListTypeComponent = isSectionList ? DropdownSectionList : DropdownFlatList;
|
|
95
|
-
const modifiedSectionData =
|
|
93
|
+
const modifiedSectionData = extractPropertyFromArray(newOptions, 'data')?.flat();
|
|
96
94
|
|
|
97
95
|
/**
|
|
98
96
|
* `options` is the original array, it never changes. (Do not use except you really need the original array) .
|
|
@@ -116,12 +114,10 @@ export const DropdownSelect = _ref => {
|
|
|
116
114
|
setOpen(false); // close modal upon selection
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
|
-
|
|
120
117
|
const handleMultipleSelections = value => {
|
|
121
118
|
setSelectedItems(prevVal => {
|
|
122
|
-
var _selectedValues;
|
|
123
119
|
let selectedValues = [...prevVal];
|
|
124
|
-
if (
|
|
120
|
+
if (selectedValues?.includes(value)) {
|
|
125
121
|
selectedValues = selectedValues.filter(item => item !== value);
|
|
126
122
|
} else {
|
|
127
123
|
selectedValues.push(value);
|
|
@@ -131,7 +127,7 @@ export const DropdownSelect = _ref => {
|
|
|
131
127
|
});
|
|
132
128
|
};
|
|
133
129
|
const removeDisabledItems = items => {
|
|
134
|
-
return items
|
|
130
|
+
return items?.filter(item => !item.disabled);
|
|
135
131
|
};
|
|
136
132
|
const handleSelectAll = () => {
|
|
137
133
|
setSelectAll(prevVal => {
|
|
@@ -148,10 +144,10 @@ export const DropdownSelect = _ref => {
|
|
|
148
144
|
onValueChange(selectedValues); // send value to parent
|
|
149
145
|
return !prevVal;
|
|
150
146
|
});
|
|
151
|
-
if (typeof
|
|
147
|
+
if (typeof listControls?.selectAllCallback === 'function' && !selectAll) {
|
|
152
148
|
listControls.selectAllCallback();
|
|
153
149
|
}
|
|
154
|
-
if (typeof
|
|
150
|
+
if (typeof listControls?.unselectAllCallback === 'function' && selectAll) {
|
|
155
151
|
listControls.unselectAllCallback();
|
|
156
152
|
}
|
|
157
153
|
};
|
|
@@ -160,9 +156,8 @@ export const DropdownSelect = _ref => {
|
|
|
160
156
|
* Handle side effects
|
|
161
157
|
*==========================================*/
|
|
162
158
|
const checkSelectAll = useCallback(selectedValues => {
|
|
163
|
-
var _removeDisabledItems;
|
|
164
159
|
//if the list contains disabled values, those values will not be selected
|
|
165
|
-
if (
|
|
160
|
+
if (removeDisabledItems(modifiedOptions)?.length === selectedValues?.length) {
|
|
166
161
|
setSelectAll(true);
|
|
167
162
|
} else {
|
|
168
163
|
setSelectAll(false);
|
|
@@ -183,15 +178,14 @@ export const DropdownSelect = _ref => {
|
|
|
183
178
|
const getSelectedItemsLabel = () => {
|
|
184
179
|
if (isMultiple && Array.isArray(selectedItems)) {
|
|
185
180
|
let selectedLabels = [];
|
|
186
|
-
selectedItems
|
|
187
|
-
|
|
188
|
-
let selectedItemLabel = modifiedOptions === null || modifiedOptions === void 0 || (_modifiedOptions$find = modifiedOptions.find(item => item[optValue] === element)) === null || _modifiedOptions$find === void 0 ? void 0 : _modifiedOptions$find[optLabel];
|
|
181
|
+
selectedItems?.forEach(element => {
|
|
182
|
+
let selectedItemLabel = modifiedOptions?.find(item => item[optValue] === element)?.[optLabel];
|
|
189
183
|
selectedLabels.push(selectedItemLabel);
|
|
190
184
|
});
|
|
191
185
|
return selectedLabels;
|
|
192
186
|
}
|
|
193
|
-
let selectedItemLabel = modifiedOptions
|
|
194
|
-
return selectedItemLabel
|
|
187
|
+
let selectedItemLabel = modifiedOptions?.find(item => item[optValue] === selectedItem);
|
|
188
|
+
return selectedItemLabel?.[optLabel];
|
|
195
189
|
};
|
|
196
190
|
|
|
197
191
|
/*===========================================
|
|
@@ -231,6 +225,22 @@ export const DropdownSelect = _ref => {
|
|
|
231
225
|
return searchResults;
|
|
232
226
|
};
|
|
233
227
|
|
|
228
|
+
/**
|
|
229
|
+
* To prevent triggering on modalProps.onDismiss on first render, we perform this check
|
|
230
|
+
*/
|
|
231
|
+
const hasComponentBeenRendered = useRef(false);
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Explicitly adding this here because the onDismiss only works on iOS Modals
|
|
235
|
+
* https://reactnative.dev/docs/modal#ondismiss-ios
|
|
236
|
+
*/
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (hasComponentBeenRendered.current && !open && Platform.OS === 'android') {
|
|
239
|
+
modalControls?.modalProps?.onDismiss?.();
|
|
240
|
+
}
|
|
241
|
+
hasComponentBeenRendered.current = true;
|
|
242
|
+
}, [open]);
|
|
243
|
+
|
|
234
244
|
/*===========================================
|
|
235
245
|
* Modal
|
|
236
246
|
*==========================================*/
|
|
@@ -259,9 +269,8 @@ export const DropdownSelect = _ref => {
|
|
|
259
269
|
* setIndexOfSelectedItem - For ScrollToIndex
|
|
260
270
|
*==========================================*/
|
|
261
271
|
const setIndexOfSelectedItem = selectedLabel => {
|
|
262
|
-
isSectionList ? options
|
|
263
|
-
|
|
264
|
-
item === null || item === void 0 || (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.find((dataItem, itemIndex) => {
|
|
272
|
+
isSectionList ? options?.map((item, sectionIndex) => {
|
|
273
|
+
item?.data?.find((dataItem, itemIndex) => {
|
|
265
274
|
if (dataItem[optLabel] === selectedLabel) {
|
|
266
275
|
setListIndex({
|
|
267
276
|
sectionIndex,
|
|
@@ -269,7 +278,7 @@ export const DropdownSelect = _ref => {
|
|
|
269
278
|
});
|
|
270
279
|
}
|
|
271
280
|
});
|
|
272
|
-
}) : options
|
|
281
|
+
}) : options?.find((item, itemIndex) => {
|
|
273
282
|
if (item[optLabel] === selectedLabel) {
|
|
274
283
|
setListIndex({
|
|
275
284
|
itemIndex
|
|
@@ -314,17 +323,17 @@ export const DropdownSelect = _ref => {
|
|
|
314
323
|
ListHeaderComponent: /*#__PURE__*/React.createElement(React.Fragment, null, isSearchable && /*#__PURE__*/React.createElement(Input, _extends({
|
|
315
324
|
value: searchValue,
|
|
316
325
|
onChangeText: text => onSearch(text),
|
|
317
|
-
style:
|
|
326
|
+
style: searchControls?.textInputStyle || searchInputStyle,
|
|
318
327
|
primaryColor: primary,
|
|
319
|
-
textInputContainerStyle: searchControls
|
|
320
|
-
placeholder:
|
|
321
|
-
}, searchControls
|
|
328
|
+
textInputContainerStyle: searchControls?.textInputContainerStyle,
|
|
329
|
+
placeholder: searchControls?.textInputProps?.placeholder || 'Search'
|
|
330
|
+
}, searchControls?.textInputProps)), listHeaderComponent, !listControls?.hideSelectAll && isMultiple && modifiedOptions?.length > 1 && /*#__PURE__*/React.createElement(View, {
|
|
322
331
|
style: styles.optionsContainerStyle
|
|
323
332
|
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
324
333
|
onPress: () => {}
|
|
325
334
|
}, /*#__PURE__*/React.createElement(CheckBox, {
|
|
326
335
|
value: selectAll,
|
|
327
|
-
label: selectAll ?
|
|
336
|
+
label: selectAll ? listControls?.unselectAllText || 'Clear all' : listControls?.selectAllText || 'Select all',
|
|
328
337
|
onChange: () => handleSelectAll(),
|
|
329
338
|
primaryColor: primary,
|
|
330
339
|
checkboxControls: checkboxControls,
|
|
@@ -353,7 +362,7 @@ export const DropdownSelect = _ref => {
|
|
|
353
362
|
checkboxComponent: checkboxComponent,
|
|
354
363
|
checkboxControls: checkboxControls,
|
|
355
364
|
listIndex: listIndex,
|
|
356
|
-
emptyListMessage: listControls
|
|
365
|
+
emptyListMessage: listControls?.emptyListMessage
|
|
357
366
|
})));
|
|
358
367
|
};
|
|
359
368
|
const styles = StyleSheet.create({
|