react-native-input-select 0.2.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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/lib/commonjs/Dropdown.js +138 -0
  4. package/lib/commonjs/Dropdown.js.map +1 -0
  5. package/lib/commonjs/DropdownList.js +90 -0
  6. package/lib/commonjs/DropdownList.js.map +1 -0
  7. package/lib/commonjs/DropdownListItem.js +68 -0
  8. package/lib/commonjs/DropdownListItem.js.map +1 -0
  9. package/lib/commonjs/Modal.js +56 -0
  10. package/lib/commonjs/Modal.js.map +1 -0
  11. package/lib/commonjs/asset/arrow-down.png +0 -0
  12. package/lib/commonjs/index.js +129 -0
  13. package/lib/commonjs/index.js.map +1 -0
  14. package/lib/commonjs/styles/colors.js +16 -0
  15. package/lib/commonjs/styles/colors.js.map +1 -0
  16. package/lib/commonjs/styles/typography.js +20 -0
  17. package/lib/commonjs/styles/typography.js.map +1 -0
  18. package/lib/module/Dropdown.js +124 -0
  19. package/lib/module/Dropdown.js.map +1 -0
  20. package/lib/module/DropdownList.js +76 -0
  21. package/lib/module/DropdownList.js.map +1 -0
  22. package/lib/module/DropdownListItem.js +49 -0
  23. package/lib/module/DropdownListItem.js.map +1 -0
  24. package/lib/module/Modal.js +43 -0
  25. package/lib/module/Modal.js.map +1 -0
  26. package/lib/module/asset/arrow-down.png +0 -0
  27. package/lib/module/index.js +109 -0
  28. package/lib/module/index.js.map +1 -0
  29. package/lib/module/styles/colors.js +9 -0
  30. package/lib/module/styles/colors.js.map +1 -0
  31. package/lib/module/styles/typography.js +10 -0
  32. package/lib/module/styles/typography.js.map +1 -0
  33. package/lib/typescript/Dropdown.d.ts +2 -0
  34. package/lib/typescript/DropdownList.d.ts +2 -0
  35. package/lib/typescript/DropdownListItem.d.ts +3 -0
  36. package/lib/typescript/Modal.d.ts +2 -0
  37. package/lib/typescript/index.d.ts +2 -0
  38. package/lib/typescript/styles/colors.d.ts +1 -0
  39. package/lib/typescript/styles/typography.d.ts +1 -0
  40. package/package.json +151 -0
  41. package/src/Dropdown.tsx +125 -0
  42. package/src/DropdownList.tsx +76 -0
  43. package/src/DropdownListItem.tsx +51 -0
  44. package/src/Modal.tsx +57 -0
  45. package/src/asset/arrow-down.png +0 -0
  46. package/src/index.tsx +120 -0
  47. package/src/styles/colors.ts +8 -0
  48. package/src/styles/typography.ts +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Azeezat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # react-native-select
2
+
3
+ Dropdown package for react-native
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-select
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import * as React from 'react';
15
+
16
+ import { StyleSheet, View } from 'react-native';
17
+ import DropdownSelect from 'react-native-select';
18
+
19
+ export default function App() {
20
+ const [result, setResult] = React.useState<number | undefined>();
21
+
22
+ return (
23
+ <DropdownSelect
24
+ label="Country"
25
+ placeholder="Select an option..."
26
+ options={[
27
+ { name: 'Albania', code: 'AL' },
28
+ { name: 'Åland Islands', code: 'AX' },
29
+ { name: 'Algeria', code: 'DZ' },
30
+ { name: 'American Samoa', code: 'AS' },
31
+ { name: 'Andorra', code: 'AD' },
32
+ { name: 'Angola', code: 'AO' },
33
+ { name: 'Anguilla', code: 'AI' },
34
+ { name: 'Antarctica', code: 'AQ' },
35
+ { name: 'Antigua and Barbuda', code: 'AG' },
36
+ ]}
37
+ optionLabel={'name'}
38
+ optionValue={'code'}
39
+ selectedValue={result}
40
+ onValueChange={(itemValue) => setResult(itemValue)}
41
+ />
42
+ );
43
+ }
44
+ ```
45
+
46
+ | Proptypes | Datatype | Example |
47
+ | ---------------------- | ------------------- | ------------------------------------------------ |
48
+ | label | `string` | `Countries` |
49
+ | placeholder | `string` | `Select a country` |
50
+ | options | `Array` | `[{ name: 'Albania', code: 'AL' }, { name: 'Åland Islands', code: 'AX' }]` |
51
+ | optionLabel | `string` | `name` |
52
+ | optionValue | `string` | `code` |
53
+ | selectedValue | `string` or `Array` | `AL` or `[AL, AX]` |
54
+ | onValueChange | `function` | `()=>{` |
55
+ | isMultiple | `Boolean` | `true` |
56
+ | labelStyle | `Object` | `{backgroundColor: 'red', borderRadius: 0, ...}` |
57
+ | dropdownStyle | `Object` | `{backgroundColor: 'red', margin: 5, ...}` |
58
+ | dropdownContainerStyle | `Object` | `{backgroundColor: 'red', borderRadius: 0, ...}` |
59
+ | selectedItemStyle | `Object` | `{backgroundColor: 'red', color: 'yellow', ...}` |
60
+ | modalBackgroundStyle | `Object` | `{backgroundColor: 'blue', ...}` |
61
+ | modalOptionsContainer | `Object` | `{padding: 5}` |
62
+
63
+ ## Contributing
64
+
65
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
66
+
67
+ ## License
68
+
69
+ MIT
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _colors = require("./styles/colors");
13
+
14
+ var _typography = require("./styles/typography");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const Dropdown = _ref => {
19
+ let {
20
+ label,
21
+ placeholder,
22
+ helperText,
23
+ error,
24
+ getSelectedItemsLabel,
25
+ setOpen,
26
+ open,
27
+ isMultiple,
28
+ selectedItem,
29
+ selectedItems,
30
+ labelStyle,
31
+ dropdownStyle,
32
+ dropdownContainerStyle,
33
+ selectedItemStyle
34
+ } = _ref;
35
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
36
+ style: [styles.dropdownInputContainer, dropdownContainerStyle]
37
+ }, label && label !== '' && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
38
+ style: [styles.label, labelStyle]
39
+ }, label), /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, {
40
+ onPress: () => setOpen(!open),
41
+ style: _ref2 => {
42
+ let {
43
+ pressed
44
+ } = _ref2;
45
+ return [pressed && styles.inputFocusState, styles.input, dropdownStyle];
46
+ }
47
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
48
+ horizontal: true,
49
+ alwaysBounceHorizontal: true,
50
+ showsHorizontalScrollIndicator: false
51
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
52
+ style: styles.selectedItemsContainer,
53
+ onStartShouldSetResponder: () => true
54
+ }, isMultiple ? getSelectedItemsLabel().map((item, i) => /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
55
+ key: `SelectedItems${i}`,
56
+ style: [styles.selectedItems, selectedItemStyle]
57
+ }, item)) : /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
58
+ style: styles.blackText
59
+ }, getSelectedItemsLabel())), !selectedItem && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) === 0 && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
60
+ style: styles.blackText
61
+ }, placeholder !== null && placeholder !== void 0 ? placeholder : 'Select an option')), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
62
+ style: styles.iconStyle
63
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
64
+ source: require('../src/asset/arrow-down.png')
65
+ }))), error && error !== '' && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
66
+ style: styles.error
67
+ }, error), helperText && helperText !== '' && !error && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
68
+ style: styles.helper
69
+ }, helperText));
70
+ };
71
+
72
+ const styles = _reactNative.StyleSheet.create({
73
+ label: {
74
+ marginBottom: 16,
75
+ color: _colors.colors.gray,
76
+ ..._typography.typography.caption
77
+ },
78
+ input: {
79
+ paddingVertical: 18,
80
+ paddingHorizontal: 23,
81
+ backgroundColor: _colors.colors.lightGray,
82
+ borderRadius: 8,
83
+ borderColor: _colors.colors.dark,
84
+ borderWidth: 1,
85
+ color: _colors.colors.dark,
86
+ width: '100%',
87
+ minHeight: 64
88
+ },
89
+ inputFocusState: {
90
+ borderWidth: 2,
91
+ borderStyle: 'solid',
92
+ borderColor: _colors.colors.primary,
93
+ borderRadius: 8
94
+ },
95
+ inputFocusErrorState: {
96
+ borderWidth: 2,
97
+ borderStyle: 'solid',
98
+ borderColor: _colors.colors.cliqkiRed
99
+ },
100
+ iconStyle: {
101
+ position: 'absolute',
102
+ right: 25,
103
+ top: 25
104
+ },
105
+ error: {
106
+ color: _colors.colors.cliqkiRed,
107
+ marginTop: 8,
108
+ ..._typography.typography.caption
109
+ },
110
+ helper: {
111
+ marginTop: 8,
112
+ color: _colors.colors.primary,
113
+ ..._typography.typography.caption
114
+ },
115
+ dropdownInputContainer: {
116
+ marginBottom: 23,
117
+ width: '100%'
118
+ },
119
+ selectedItemsContainer: {
120
+ flexDirection: 'row',
121
+ flexWrap: 'nowrap'
122
+ },
123
+ selectedItems: {
124
+ color: _colors.colors.white,
125
+ paddingHorizontal: 10,
126
+ paddingVertical: 5,
127
+ borderRadius: 10,
128
+ backgroundColor: _colors.colors.primary,
129
+ marginRight: 10
130
+ },
131
+ blackText: {
132
+ color: _colors.colors.black
133
+ }
134
+ });
135
+
136
+ var _default = Dropdown;
137
+ exports.default = _default;
138
+ //# sourceMappingURL=Dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Dropdown.tsx"],"names":["Dropdown","label","placeholder","helperText","error","getSelectedItemsLabel","setOpen","open","isMultiple","selectedItem","selectedItems","labelStyle","dropdownStyle","dropdownContainerStyle","selectedItemStyle","styles","dropdownInputContainer","pressed","inputFocusState","input","selectedItemsContainer","map","item","i","blackText","length","iconStyle","require","helper","StyleSheet","create","marginBottom","color","colors","gray","typography","caption","paddingVertical","paddingHorizontal","backgroundColor","lightGray","borderRadius","borderColor","dark","borderWidth","width","minHeight","borderStyle","primary","inputFocusErrorState","cliqkiRed","position","right","top","marginTop","flexDirection","flexWrap","white","marginRight","black"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;;;AAEA,MAAMA,QAAQ,GAAG,QAeN;AAAA,MAfO;AAChBC,IAAAA,KADgB;AAEhBC,IAAAA,WAFgB;AAGhBC,IAAAA,UAHgB;AAIhBC,IAAAA,KAJgB;AAKhBC,IAAAA,qBALgB;AAMhBC,IAAAA,OANgB;AAOhBC,IAAAA,IAPgB;AAQhBC,IAAAA,UARgB;AAShBC,IAAAA,YATgB;AAUhBC,IAAAA,aAVgB;AAWhBC,IAAAA,UAXgB;AAYhBC,IAAAA,aAZgB;AAahBC,IAAAA,sBAbgB;AAchBC,IAAAA;AAdgB,GAeP;AACT,sBACE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAACC,MAAM,CAACC,sBAAR,EAAgCH,sBAAhC;AAA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AAA,WAAW,EAAET,eAAOiB;AAHA,GAnBS;AAwB/BxB,EAAAA,SAAS,EAAE;AAAEyB,IAAAA,QAAQ,EAAE,UAAZ;AAAwBC,IAAAA,KAAK,EAAE,EAA/B;AAAmCC,IAAAA,GAAG,EAAE;AAAxC,GAxBoB;AAyB/BjD,EAAAA,KAAK,EAAE;AAAE4B,IAAAA,KAAK,EAAEC,eAAOiB,SAAhB;AAA2BI,IAAAA,SAAS,EAAE,CAAtC;AAAyC,OAAGnB,uBAAWC;AAAvD,GAzBwB;AA0B/BR,EAAAA,MAAM,EAAE;AAAE0B,IAAAA,SAAS,EAAE,CAAb;AAAgBtB,IAAAA,KAAK,EAAEC,eAAOe,OAA9B;AAAuC,OAAGb,uBAAWC;AAArD,GA1BuB;AA2B/BpB,EAAAA,sBAAsB,EAAE;AAAEe,IAAAA,YAAY,EAAE,EAAhB;AAAoBc,IAAAA,KAAK,EAAE;AAA3B,GA3BO;AA4B/BzB,EAAAA,sBAAsB,EAAE;AAAEmC,IAAAA,aAAa,EAAE,KAAjB;AAAwBC,IAAAA,QAAQ,EAAE;AAAlC,GA5BO;AA6B/B9C,EAAAA,aAAa,EAAE;AACbsB,IAAAA,KAAK,EAAEC,eAAOwB,KADD;AAEbnB,IAAAA,iBAAiB,EAAE,EAFN;AAGbD,IAAAA,eAAe,EAAE,CAHJ;AAIbI,IAAAA,YAAY,EAAE,EAJD;AAKbF,IAAAA,eAAe,EAAEN,eAAOe,OALX;AAMbU,IAAAA,WAAW,EAAE;AANA,GA7BgB;AAqC/BlC,EAAAA,SAAS,EAAE;AAAEQ,IAAAA,KAAK,EAAEC,eAAO0B;AAAhB;AArCoB,CAAlB,CAAf;;eAwCe3D,Q","sourcesContent":["import React from 'react';\nimport {\n View,\n Text,\n Pressable,\n ScrollView,\n StyleSheet,\n Image,\n} from 'react-native';\nimport { colors } from './styles/colors';\nimport { typography } from './styles/typography';\n\nconst Dropdown = ({\n label,\n placeholder,\n helperText,\n error,\n getSelectedItemsLabel,\n setOpen,\n open,\n isMultiple,\n selectedItem,\n selectedItems,\n labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n selectedItemStyle,\n}: any) => {\n return (\n <View style={[styles.dropdownInputContainer, dropdownContainerStyle]}>\n {label && label !== '' && (\n <Text style={[styles.label, labelStyle]}>{label}</Text>\n )}\n <Pressable\n onPress={() => setOpen(!open)}\n style={({ pressed }) => [\n pressed && styles.inputFocusState,\n styles.input,\n dropdownStyle,\n ]}\n >\n <ScrollView\n horizontal\n alwaysBounceHorizontal\n showsHorizontalScrollIndicator={false}\n >\n <View\n style={styles.selectedItemsContainer}\n onStartShouldSetResponder={() => true}\n >\n {isMultiple ? (\n getSelectedItemsLabel().map((item: any, i: Number) => (\n <Text\n key={`SelectedItems${i}`}\n style={[styles.selectedItems, selectedItemStyle]}\n >\n {item}\n </Text>\n ))\n ) : (\n <Text style={styles.blackText}>{getSelectedItemsLabel()}</Text>\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('../src/asset/arrow-down.png')} />\n </View>\n </Pressable>\n\n {error && error !== '' && <Text style={styles.error}>{error}</Text>}\n\n {helperText && helperText !== '' && !error && (\n <Text style={styles.helper}>{helperText}</Text>\n )}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n label: { marginBottom: 16, color: colors.gray, ...typography.caption },\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 inputFocusState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.primary,\n borderRadius: 8,\n },\n inputFocusErrorState: {\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: colors.cliqkiRed,\n },\n iconStyle: { position: 'absolute', right: 25, top: 25 },\n error: { color: colors.cliqkiRed, marginTop: 8, ...typography.caption },\n helper: { marginTop: 8, color: colors.primary, ...typography.caption },\n dropdownInputContainer: { marginBottom: 23, width: '100%' },\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 Dropdown;\n"]}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _DropdownListItem = _interopRequireDefault(require("./DropdownListItem"));
13
+
14
+ var _colors = require("./styles/colors");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const DropdownList = _ref => {
19
+ let {
20
+ options,
21
+ optionLabel,
22
+ optionValue,
23
+ isMultiple,
24
+ selectedItems,
25
+ selectedItem,
26
+ handleMultipleSelections,
27
+ handleSingleSelection
28
+ } = _ref;
29
+ return /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
30
+ data: options,
31
+ extraData: isMultiple ? selectedItems : selectedItem,
32
+ initialNumToRender: 5 // ListEmptyComponent={
33
+ // <EmptyStateComponent
34
+ // style={{alignItems: 'flex-start', marginTop: 30}}
35
+ // message="Be the first to reply"
36
+ // />
37
+ // }
38
+ ,
39
+ ItemSeparatorComponent: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
40
+ style: styles.itemSeparatorStyle
41
+ }),
42
+ renderItem: item => _renderItem(item, {
43
+ optionLabel,
44
+ optionValue,
45
+ isMultiple,
46
+ selectedOption: isMultiple ? selectedItems : selectedItem,
47
+ onChange: isMultiple ? handleMultipleSelections : handleSingleSelection
48
+ }),
49
+ keyExtractor: (_item, index) => `Options${index}`
50
+ });
51
+ };
52
+
53
+ const _renderItem = (_ref2, props) => {
54
+ let {
55
+ item
56
+ } = _ref2;
57
+ return /*#__PURE__*/_react.default.createElement(_DropdownListItem.default, {
58
+ item: item,
59
+ optionLabel: props.optionLabel,
60
+ optionValue: props.optionValue,
61
+ isMultiple: props.isMultiple,
62
+ selectedOption: props.selectedOption,
63
+ onChange: props.onChange
64
+ });
65
+ };
66
+
67
+ const styles = _reactNative.StyleSheet.create({
68
+ modalContainer: {
69
+ flex: 1,
70
+ justifyContent: 'flex-end'
71
+ },
72
+ modalBackgroundStyle: {
73
+ backgroundColor: 'rgba(0, 0, 0, 0.5)'
74
+ },
75
+ modalOptionsContainer: {
76
+ maxHeight: '50%',
77
+ backgroundColor: _colors.colors.white,
78
+ borderTopLeftRadius: 16,
79
+ borderTopRightRadius: 16
80
+ },
81
+ itemSeparatorStyle: {
82
+ backgroundColor: _colors.colors.gray,
83
+ height: 1,
84
+ opacity: 0.15
85
+ }
86
+ });
87
+
88
+ var _default = DropdownList;
89
+ exports.default = _default;
90
+ //# sourceMappingURL=DropdownList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DropdownList.tsx"],"names":["DropdownList","options","optionLabel","optionValue","isMultiple","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","styles","itemSeparatorStyle","item","_renderItem","selectedOption","onChange","_item","index","props","StyleSheet","create","modalContainer","flex","justifyContent","modalBackgroundStyle","backgroundColor","modalOptionsContainer","maxHeight","colors","white","borderTopLeftRadius","borderTopRightRadius","gray","height","opacity"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG,QASV;AAAA,MATW;AACpBC,IAAAA,OADoB;AAEpBC,IAAAA,WAFoB;AAGpBC,IAAAA,WAHoB;AAIpBC,IAAAA,UAJoB;AAKpBC,IAAAA,aALoB;AAMpBC,IAAAA,YANoB;AAOpBC,IAAAA,wBAPoB;AAQpBC,IAAAA;AARoB,GASX;AACT,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AnB,GALS;AAM/BC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,SAAS,EAAE,KADU;AAErBF,IAAAA,eAAe,EAAEG,eAAOC,KAFH;AAGrBC,IAAAA,mBAAmB,EAAE,EAHA;AAIrBC,IAAAA,oBAAoB,EAAE;AAJD,GANQ;AAY/BpB,EAAAA,kBAAkB,EAAE;AAClBc,IAAAA,eAAe,EAAEG,eAAOI,IADN;AAElBC,IAAAA,MAAM,EAAE,CAFU;AAGlBC,IAAAA,OAAO,EAAE;AAHS;AAZW,CAAlB,CAAf;;eAmBejC,Y","sourcesContent":["import React from 'react';\nimport { View, FlatList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { colors } from './styles/colors';\n\nconst DropdownList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n}: any) => {\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n // ListEmptyComponent={\n // <EmptyStateComponent\n // style={{alignItems: 'flex-start', marginTop: 30}}\n // message=\"Be the first to reply\"\n // />\n // }\n ItemSeparatorComponent={() => <View style={styles.itemSeparatorStyle} />}\n renderItem={(item) =>\n _renderItem(item, {\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption: isMultiple ? selectedItems : selectedItem,\n onChange: isMultiple\n ? handleMultipleSelections\n : handleSingleSelection,\n })\n }\n keyExtractor={(_item, index) => `Options${index}`}\n />\n );\n};\n\nconst _renderItem = ({ item }: any, props: any) => {\n return (\n <DropdownListItem\n item={item}\n optionLabel={props.optionLabel}\n optionValue={props.optionValue}\n isMultiple={props.isMultiple}\n selectedOption={props.selectedOption}\n onChange={props.onChange}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n modalContainer: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n modalBackgroundStyle: { backgroundColor: 'rgba(0, 0, 0, 0.5)' },\n modalOptionsContainer: {\n maxHeight: '50%',\n backgroundColor: colors.white,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n itemSeparatorStyle: {\n backgroundColor: colors.gray,\n height: 1,\n opacity: 0.15,\n },\n});\n\nexport default DropdownList;\n"]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _checkbox = _interopRequireDefault(require("@react-native-community/checkbox"));
13
+
14
+ var _colors = require("./styles/colors");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const DropdownListItem = _ref => {
23
+ let {
24
+ item,
25
+ optionLabel,
26
+ optionValue,
27
+ isMultiple,
28
+ selectedOption,
29
+ onChange
30
+ } = _ref;
31
+ const selectedOptionValue = optionValue !== null && optionValue !== void 0 ? optionValue : 'value';
32
+ return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
33
+ style: styles.modalOptions,
34
+ onPress: () => onChange(item[selectedOptionValue])
35
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
36
+ style: styles.spacing
37
+ }, /*#__PURE__*/_react.default.createElement(_checkbox.default, {
38
+ value: isMultiple ? selectedOption.includes(item[selectedOptionValue]) : [selectedOption].includes(item[selectedOptionValue]),
39
+ onChange: () => onChange(item[selectedOptionValue]),
40
+ boxType: "circle" //works on ios only
41
+ ,
42
+ tintColors: {
43
+ true: _colors.colors.primary
44
+ } //android control
45
+ ,
46
+ onCheckColor: _colors.colors.primary //ios checkmark colour control
47
+ ,
48
+ onTintColor: _colors.colors.primary //ios box colour control
49
+
50
+ })), /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, item[optionLabel !== null && optionLabel !== void 0 ? optionLabel : 'label'])));
51
+ };
52
+
53
+ const styles = _reactNative.StyleSheet.create({
54
+ spacing: {
55
+ marginRight: 10
56
+ },
57
+ modalOptions: {
58
+ paddingHorizontal: 20,
59
+ paddingVertical: 10,
60
+ flexDirection: 'row',
61
+ alignItems: 'center'
62
+ }
63
+ });
64
+
65
+ var _default = /*#__PURE__*/(0, _react.memo)(DropdownListItem);
66
+
67
+ exports.default = _default;
68
+ //# sourceMappingURL=DropdownListItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DropdownListItem.tsx"],"names":["DropdownListItem","item","optionLabel","optionValue","isMultiple","selectedOption","onChange","selectedOptionValue","styles","modalOptions","spacing","includes","true","colors","primary","StyleSheet","create","marginRight","paddingHorizontal","paddingVertical","flexDirection","alignItems"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEA,MAAMA,gBAAgB,GAAG,QAOd;AAAA,MAPe;AACxBC,IAAAA,IADwB;AAExBC,IAAAA,WAFwB;AAGxBC,IAAAA,WAHwB;AAIxBC,I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KAHH;AAIZC,IAAAA,UAAU,EAAE;AAJA;AAFiB,CAAlB,CAAf;;4BAUe,iBAAKrB,gBAAL,C","sourcesContent":["import React, { memo } from 'react';\nimport { View, Text, TouchableOpacity, StyleSheet } from 'react-native';\nimport CheckBox from '@react-native-community/checkbox';\nimport { colors } from './styles/colors';\n\nconst DropdownListItem = ({\n item,\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption,\n onChange,\n}: any) => {\n const selectedOptionValue = optionValue ?? 'value';\n return (\n <TouchableOpacity\n style={styles.modalOptions}\n onPress={() => onChange(item[selectedOptionValue])}\n >\n <View style={styles.spacing}>\n <CheckBox\n value={\n isMultiple\n ? selectedOption.includes(item[selectedOptionValue])\n : [selectedOption].includes(item[selectedOptionValue])\n }\n onChange={() => onChange(item[selectedOptionValue])}\n boxType=\"circle\" //works on ios only\n tintColors={{ true: colors.primary }} //android control\n onCheckColor={colors.primary} //ios checkmark colour control\n onTintColor={colors.primary} //ios box colour control\n />\n </View>\n <View>\n <Text>{item[optionLabel ?? 'label']}</Text>\n </View>\n </TouchableOpacity>\n );\n};\n\nconst styles = StyleSheet.create({\n spacing: { marginRight: 10 },\n modalOptions: {\n paddingHorizontal: 20,\n paddingVertical: 10,\n flexDirection: 'row',\n alignItems: 'center',\n },\n});\n\nexport default memo(DropdownListItem);\n"]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _colors = require("./styles/colors");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const CustomModal = _ref => {
17
+ let {
18
+ open,
19
+ setOpen,
20
+ onRequestClose,
21
+ modalBackgroundStyle,
22
+ modalOptionsContainerStyle,
23
+ children
24
+ } = _ref;
25
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Modal, {
26
+ transparent: true,
27
+ visible: open,
28
+ onRequestClose: () => onRequestClose(),
29
+ animationType: "fade"
30
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
31
+ onPress: () => setOpen(!open),
32
+ style: [styles.modalContainer, styles.modalBackgroundStyle, modalBackgroundStyle]
33
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
34
+ style: [styles.modalOptionsContainer, modalOptionsContainerStyle]
35
+ }, children)));
36
+ };
37
+
38
+ const styles = _reactNative.StyleSheet.create({
39
+ modalContainer: {
40
+ flex: 1,
41
+ justifyContent: 'flex-end'
42
+ },
43
+ modalBackgroundStyle: {
44
+ backgroundColor: 'rgba(0, 0, 0, 0.5)'
45
+ },
46
+ modalOptionsContainer: {
47
+ maxHeight: '50%',
48
+ backgroundColor: _colors.colors.white,
49
+ borderTopLeftRadius: 16,
50
+ borderTopRightRadius: 16
51
+ }
52
+ });
53
+
54
+ var _default = CustomModal;
55
+ exports.default = _default;
56
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Modal.tsx"],"names":["CustomModal","open","setOpen","onRequestClose","modalBackgroundStyle","modalOptionsContainerStyle","children","styles","modalContainer","modalOptionsContainer","StyleSheet","create","flex","justifyContent","backgroundColor","maxHeight","colors","white","borderTopLeftRadius","borderTopRightRadius"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;;;AAEA,MAAMA,WAAW,GAAG,QAOT;AAAA,MAPU;AACnBC,IAAAA,IADmB;AAEnBC,IAAAA,OAFmB;AAGnBC,IAAAA,cAHmB;AAInBC,IAAAA,oBAJmB;AAKnBC,IAAAA,0BALmB;AAMnBC,IAAAA;AANmB,GAOV;AACT,sBACE,6BAAC,kBAAD;AACE,IAAA,WAAW,EAAE,IADf;AAEE,IAAA,OAAO,EAAEL,IAFX;AAGE,IAAA,cAAc,EAAE,MAAME,cAAc,EAHtC;AAIE,IAAA,aAAa,EAAC;AAJhB,kBAME,6BAAC,6BAAD;AACE,IAAA,OAAO,EAAE,MAAMD,OAAO,CAAC,CAACD,IAAF,CADxB;AAEE,IAAA,KAAK,EAAE,CACLM,MAAM,CAACC,cADF,EAELD,MAAM,CAACH,oBAFF,EAGLA,oBAHK;AAFT,kBAQE,6BAAC,yBAAD;AACE,IAAA,KAAK,EAAE,CAACG,MAAM,CAACE,qBAAR,EAA+BJ,0BAA/B;AADT,KAGGC,QAHH,CARF,CANF,CADF;AAuBD,CA/BD;;AAiCA,MAAMC,MAAM,GAAGG,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,cAAc,EAAE;AACdI,IAAAA,IAAI,EAAE,CADQ;AAEdC,IAAAA,cAAc,EAAE;AAFF,GADe;AAK/BT,EAAAA,oBAAoB,EAAE;AAAEU,IAAAA,eAAe,EAAE;AAAnB,GALS;AAM/BL,EAAAA,qBAAqB,EAAE;AACrBM,IAAAA,SAAS,EAAE,KADU;AAErBD,IAAAA,eAAe,EAAEE,eAAOC,KAFH;AAGrBC,IAAAA,mBAAmB,EAAE,EAHA;AAIrBC,IAAAA,oBAAoB,EAAE;AAJD;AANQ,CAAlB,CAAf;;eAcenB,W","sourcesContent":["import React from 'react';\nimport {\n Modal,\n TouchableOpacity,\n SafeAreaView,\n StyleSheet,\n} from 'react-native';\nimport { colors } from './styles/colors';\n\nconst CustomModal = ({\n open,\n setOpen,\n onRequestClose,\n modalBackgroundStyle,\n modalOptionsContainerStyle,\n children,\n}: any) => {\n return (\n <Modal\n transparent={true}\n visible={open}\n onRequestClose={() => onRequestClose()}\n animationType=\"fade\"\n >\n <TouchableOpacity\n onPress={() => setOpen(!open)}\n style={[\n styles.modalContainer,\n styles.modalBackgroundStyle,\n modalBackgroundStyle,\n ]}\n >\n <SafeAreaView\n style={[styles.modalOptionsContainer, modalOptionsContainerStyle]}\n >\n {children}\n </SafeAreaView>\n </TouchableOpacity>\n </Modal>\n );\n};\n\nconst styles = StyleSheet.create({\n modalContainer: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n modalBackgroundStyle: { backgroundColor: 'rgba(0, 0, 0, 0.5)' },\n modalOptionsContainer: {\n maxHeight: '50%',\n backgroundColor: colors.white,\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n});\n\nexport default CustomModal;\n"]}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.DropdownSelect = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _Dropdown = _interopRequireDefault(require("./Dropdown"));
11
+
12
+ var _Modal = _interopRequireDefault(require("./Modal"));
13
+
14
+ var _DropdownList = _interopRequireDefault(require("./DropdownList"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const DropdownSelect = _ref => {
23
+ let {
24
+ placeholder,
25
+ label,
26
+ error,
27
+ helperText,
28
+ options,
29
+ optionLabel,
30
+ optionValue,
31
+ onValueChange,
32
+ selectedValue,
33
+ isMultiple,
34
+ labelStyle,
35
+ dropdownStyle,
36
+ dropdownContainerStyle,
37
+ selectedItemStyle,
38
+ modalBackgroundStyle,
39
+ modalOptionsContainer
40
+ } = _ref;
41
+ const [open, setOpen] = (0, _react.useState)(false);
42
+ const [selectedItem, setSelectedItem] = (0, _react.useState)(selectedValue); //for single selection
43
+
44
+ const [selectedItems, setSelectedItems] = (0, _react.useState)(Array.isArray(selectedValue) ? selectedValue : []); //for multiple selection
45
+
46
+ /*===========================================
47
+ * Selection handlers
48
+ *==========================================*/
49
+
50
+ const handleSingleSelection = value => {
51
+ if (selectedItem === value) {
52
+ setSelectedItem(null);
53
+ } else {
54
+ setSelectedItem(value);
55
+ onValueChange(value); //send value to parent
56
+
57
+ setOpen(false); //close modal upon selection
58
+ }
59
+ };
60
+
61
+ const handleMultipleSelections = value => {
62
+ let selectedValues = [...selectedItems];
63
+
64
+ if (selectedValues.includes(value)) {
65
+ selectedValues = selectedValues.filter(item => item !== value);
66
+ } else {
67
+ selectedValues.push(value);
68
+ }
69
+
70
+ setSelectedItems(selectedValues);
71
+ };
72
+ /*===========================================
73
+ * Get label handler
74
+ *==========================================*/
75
+
76
+
77
+ const getSelectedItemsLabel = () => {
78
+ if (isMultiple) {
79
+ let selectedLabels = [];
80
+ selectedItems && selectedItems.forEach(element => {
81
+ var _options$find;
82
+
83
+ let selectedItemLabel = options && ((_options$find = options.find(item => item[optionValue !== null && optionValue !== void 0 ? optionValue : 'value'] === element)) === null || _options$find === void 0 ? void 0 : _options$find[optionLabel]);
84
+ selectedLabels.push(selectedItemLabel);
85
+ });
86
+ return selectedLabels;
87
+ }
88
+
89
+ let selectedItemLabel = options && options.find(item => item[optionValue !== null && optionValue !== void 0 ? optionValue : 'value'] === selectedItem);
90
+ return selectedItemLabel === null || selectedItemLabel === void 0 ? void 0 : selectedItemLabel[optionLabel];
91
+ };
92
+
93
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
94
+ label: label,
95
+ placeholder: placeholder,
96
+ helperText: helperText,
97
+ error: error,
98
+ getSelectedItemsLabel: getSelectedItemsLabel,
99
+ selectedItem: selectedItem,
100
+ selectedItems: selectedItems,
101
+ setOpen: setOpen,
102
+ open: open,
103
+ labelStyle: labelStyle,
104
+ dropdownStyle: dropdownStyle,
105
+ dropdownContainerStyle: dropdownContainerStyle,
106
+ selectedItemStyle: selectedItemStyle,
107
+ isMultiple: isMultiple
108
+ }), /*#__PURE__*/_react.default.createElement(_Modal.default, {
109
+ open: open,
110
+ setOpen: setOpen,
111
+ modalBackgroundStyle: modalBackgroundStyle,
112
+ modalOptionsContainer: modalOptionsContainer,
113
+ onRequestClose: () => {}
114
+ }, /*#__PURE__*/_react.default.createElement(_DropdownList.default, {
115
+ options: options,
116
+ optionLabel: optionLabel,
117
+ optionValue: optionValue,
118
+ isMultiple: isMultiple,
119
+ selectedItems: selectedItems,
120
+ selectedItem: selectedItem,
121
+ handleMultipleSelections: handleMultipleSelections,
122
+ handleSingleSelection: handleSingleSelection
123
+ })));
124
+ };
125
+
126
+ exports.DropdownSelect = DropdownSelect;
127
+ var _default = DropdownSelect;
128
+ exports.default = _default;
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.tsx"],"names":["DropdownSelect","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","labelStyle","dropdownStyle","dropdownContainerStyle","selectedItemStyle","modalBackgroundStyle","modalOptionsContainer","open","setOpen","selectedItem","setSelectedItem","selectedItems","setSelectedItems","Array","isArray","handleSingleSelection","value","handleMultipleSelections","selectedValues","includes","filter","item","push","getSelectedItemsLabel","selectedLabels","forEach","element","selectedItemLabel","find"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,cAAc,GAAG,QAiBnB;AAAA,MAjBoB;AAC7BC,IAA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sBAZ1B;AAaE,IAAA,iBAAiB,EAAEC,iBAbrB;AAcE,IAAA,UAAU,EAAEJ;AAdd,IADF,eAiBE,6BAAC,cAAD;AACE,IAAA,IAAI,EAAEO,IADR;AAEE,IAAA,OAAO,EAAEC,OAFX;AAGE,IAAA,oBAAoB,EAAEH,oBAHxB;AAIE,IAAA,qBAAqB,EAAEC,qBAJzB;AAKE,IAAA,cAAc,EAAE,MAAM,CAAE;AAL1B,kBAOE,6BAAC,qBAAD;AACE,IAAA,OAAO,EAAEX,OADX;AAEE,IAAA,WAAW,EAAEC,WAFf;AAGE,IAAA,WAAW,EAAEC,WAHf;AAIE,IAAA,UAAU,EAAEG,UAJd;AAKE,IAAA,aAAa,EAAEW,aALjB;AAME,IAAA,YAAY,EAAEF,YANhB;AAOE,IAAA,wBAAwB,EAAEQ,wBAP5B;AAQE,IAAA,qBAAqB,EAAEF;AARzB,IAPF,CAjBF,CADF;AAsCD,CAhHM;;;eAkHQzB,c","sourcesContent":["import React, { useState } from 'react';\nimport Dropdown from './Dropdown';\nimport CustomModal from './Modal';\nimport DropdownList from './DropdownList';\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 labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n selectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainer,\n}: any) => {\n const [open, setOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection\n const [selectedItems, setSelectedItems] = useState(\n Array.isArray(selectedValue) ? selectedValue : []\n ); //for multiple selection\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 };\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: string) => item[optionValue ?? 'value'] === element\n )?.[optionLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel =\n options &&\n options.find(\n (item: string) => item[optionValue ?? 'value'] === selectedItem\n );\n return selectedItemLabel?.[optionLabel];\n };\n\n return (\n <>\n <Dropdown\n label={label}\n placeholder={placeholder}\n helperText={helperText}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n setOpen={setOpen}\n open={open}\n labelStyle={labelStyle}\n dropdownStyle={dropdownStyle}\n dropdownContainerStyle={dropdownContainerStyle}\n selectedItemStyle={selectedItemStyle}\n isMultiple={isMultiple}\n />\n <CustomModal\n open={open}\n setOpen={setOpen}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainer={modalOptionsContainer}\n onRequestClose={() => {}}\n >\n <DropdownList\n options={options}\n optionLabel={optionLabel}\n optionValue={optionValue}\n isMultiple={isMultiple}\n selectedItems={selectedItems}\n selectedItem={selectedItem}\n handleMultipleSelections={handleMultipleSelections}\n handleSingleSelection={handleSingleSelection}\n />\n </CustomModal>\n </>\n );\n};\n\nexport default DropdownSelect;\n"]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.colors = void 0;
7
+ const colors = {
8
+ primary: '#EF8031',
9
+ black: '#000000',
10
+ white: '#FFFFFF',
11
+ dark: '#11142D',
12
+ gray: '#808191',
13
+ lightGray: '#F7F7F7'
14
+ };
15
+ exports.colors = colors;
16
+ //# sourceMappingURL=colors.js.map