react-native-input-select 0.18.0 → 0.20.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.
- package/README.md +15 -9
- package/lib/commonjs/asset/check.png +0 -0
- package/lib/commonjs/components/CheckBox/index.js +66 -0
- package/lib/commonjs/components/CheckBox/index.js.map +1 -0
- package/lib/commonjs/components/CheckBox/types.js +6 -0
- package/lib/commonjs/components/CheckBox/types.js.map +1 -0
- package/lib/commonjs/{Modal.js → components/CustomModal/index.js} +2 -2
- package/lib/commonjs/{Modal.js.map → components/CustomModal/index.js.map} +1 -1
- package/lib/commonjs/components/Dropdown/Dropdown.js +99 -0
- package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -0
- package/lib/commonjs/{DropdownList.js → components/Dropdown/DropdownList.js} +13 -4
- package/lib/commonjs/components/Dropdown/DropdownList.js.map +1 -0
- package/lib/commonjs/{DropdownListItem.js → components/Dropdown/DropdownListItem.js} +13 -20
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -0
- package/lib/commonjs/{Dropdown.js → components/Dropdown/SelectedItemsView.js} +10 -50
- package/lib/commonjs/components/Dropdown/SelectedItemsView.js.map +1 -0
- package/lib/commonjs/{Input.js → components/Input/index.js} +2 -2
- package/lib/commonjs/{Input.js.map → components/Input/index.js.map} +1 -1
- package/lib/commonjs/constants/index.js +3 -1
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/index.js +21 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/asset/check.png +0 -0
- package/lib/module/components/CheckBox/index.js +53 -0
- package/lib/module/components/CheckBox/index.js.map +1 -0
- package/lib/module/components/CheckBox/types.js +2 -0
- package/lib/module/components/CheckBox/types.js.map +1 -0
- package/lib/module/{Modal.js → components/CustomModal/index.js} +2 -2
- package/lib/module/{Modal.js.map → components/CustomModal/index.js.map} +1 -1
- package/lib/module/components/Dropdown/Dropdown.js +84 -0
- package/lib/module/components/Dropdown/Dropdown.js.map +1 -0
- package/lib/module/{DropdownList.js → components/Dropdown/DropdownList.js} +13 -4
- package/lib/module/components/Dropdown/DropdownList.js.map +1 -0
- package/lib/module/{DropdownListItem.js → components/Dropdown/DropdownListItem.js} +13 -20
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -0
- package/lib/module/{Dropdown.js → components/Dropdown/SelectedItemsView.js} +10 -49
- package/lib/module/components/Dropdown/SelectedItemsView.js.map +1 -0
- package/lib/module/{Input.js → components/Input/index.js} +2 -2
- package/lib/module/{Input.js.map → components/Input/index.js.map} +1 -1
- package/lib/module/constants/index.js +1 -0
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/index.js +19 -9
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/CheckBox/index.d.ts +4 -0
- package/lib/typescript/components/CheckBox/types.d.ts +10 -0
- package/lib/typescript/{Modal.d.ts → components/CustomModal/index.d.ts} +1 -0
- package/lib/typescript/{Dropdown.d.ts → components/Dropdown/Dropdown.d.ts} +1 -0
- package/lib/typescript/{DropdownList.d.ts → components/Dropdown/DropdownList.d.ts} +2 -1
- package/lib/typescript/{DropdownListItem.d.ts → components/Dropdown/DropdownListItem.d.ts} +1 -1
- package/lib/typescript/components/Dropdown/SelectedItemsView.d.ts +3 -0
- package/lib/typescript/{Input.d.ts → components/Input/index.d.ts} +1 -0
- package/lib/typescript/constants/index.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/types/index.types.d.ts +25 -22
- package/package.json +8 -9
- package/src/asset/check.png +0 -0
- package/src/components/CheckBox/index.tsx +58 -0
- package/src/components/CheckBox/types.ts +11 -0
- package/src/{Modal.tsx → components/CustomModal/index.tsx} +1 -1
- package/src/components/Dropdown/Dropdown.tsx +75 -0
- package/src/{DropdownList.tsx → components/Dropdown/DropdownList.tsx} +10 -1
- package/src/components/Dropdown/DropdownListItem.tsx +50 -0
- package/src/components/Dropdown/SelectedItemsView.tsx +114 -0
- package/src/{Input.tsx → components/Input/index.tsx} +1 -1
- package/src/constants/index.ts +1 -0
- package/src/index.tsx +43 -36
- package/src/types/index.types.ts +25 -22
- package/lib/commonjs/Dropdown.js.map +0 -1
- package/lib/commonjs/DropdownList.js.map +0 -1
- package/lib/commonjs/DropdownListItem.js.map +0 -1
- package/lib/module/Dropdown.js.map +0 -1
- package/lib/module/DropdownList.js.map +0 -1
- package/lib/module/DropdownListItem.js.map +0 -1
- package/src/Dropdown.tsx +0 -145
- package/src/DropdownListItem.tsx +0 -52
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["React","useState","TextInput","StyleSheet","View","inputStyles","Input","placeholder","value","onChangeText","style","primaryColor","rest","isFocused","setFocus","styles","container","input","inputFocusState","borderColor","create","margin"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,SAAT,EAAoBC,UAApB,EAAgCC,IAAhC,QAA4C,cAA5C;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,OAAO,MAAMC,KAAK,GAAG,QAOV;AAAA,MAPW;AACpBC,IAAAA,WADoB;AAEpBC,IAAAA,KAFoB;AAGpBC,IAAAA,YAHoB;AAIpBC,IAAAA,KAJoB;AAKpBC,IAAAA,YALoB;AAMpB,OAAGC;AANiB,GAOX;AACT,QAAM,CAACC,SAAD,EAAYC,QAAZ,IAAwBb,QAAQ,CAAC,KAAD,CAAtC;AAEA,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEc,MAAM,CAACC;AAApB,kBACE,oBAAC,SAAD;AACE,IAAA,WAAW,EAAET,WADf;AAEE,IAAA,KAAK,EAAE,CACLF,WAAW,CAACY,KADP,EAELJ,SAAS,IACPR,WAAW,CAACa,eADd,IACiC;AAAEC,MAAAA,WAAW,EAAER;AAAf,KAH5B,EAILD,KAJK,CAFT;AAQE,IAAA,OAAO,EAAE,MAAM;AACbI,MAAAA,QAAQ,CAAC,IAAD,CAAR;AACD,KAVH;AAWE,IAAA,MAAM,EAAE,MAAMA,QAAQ,CAAC,KAAD,CAXxB;AAYE,IAAA,KAAK,EAAEN,KAZT;AAaE,IAAA,YAAY,EAAEC;AAbhB,KAcMG,IAdN,EADF,CADF;AAoBD,CA9BM;AAgCP,MAAMG,MAAM,GAAGZ,UAAU,CAACiB,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,IAAAA,MAAM,EAAE;AAAV;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useState } from 'react';\nimport { TextInput, StyleSheet, View } from 'react-native';\nimport { inputStyles } from '../../styles/input';\n\nexport const Input = ({\n placeholder,\n value,\n onChangeText,\n style,\n primaryColor,\n ...rest\n}: any) => {\n const [isFocused, setFocus] = useState(false);\n\n return (\n <View style={styles.container}>\n <TextInput\n placeholder={placeholder}\n style={[\n inputStyles.input,\n isFocused &&\n inputStyles.inputFocusState && { borderColor: primaryColor },\n style,\n ]}\n onFocus={() => {\n setFocus(true);\n }}\n onBlur={() => setFocus(false)}\n value={value}\n onChangeText={onChangeText}\n {...rest}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { margin: 23 },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,OAA7B;AACP,OAAO,MAAMC,oBAAoB,GAAG,OAA7B","sourcesContent":["export const DEFAULT_OPTION_LABEL = 'label';\nexport const DEFAULT_OPTION_VALUE = 'value';\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","CHECKBOX_SIZE"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,OAA7B;AACP,OAAO,MAAMC,oBAAoB,GAAG,OAA7B;AACP,OAAO,MAAMC,aAAa,GAAG,EAAtB","sourcesContent":["export const DEFAULT_OPTION_LABEL = 'label';\nexport const DEFAULT_OPTION_VALUE = 'value';\nexport const CHECKBOX_SIZE = 14;\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
|
-
import Dropdown from './Dropdown';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import Dropdown from './components/Dropdown/Dropdown';
|
|
5
|
+
import DropdownList from './components/Dropdown/DropdownList';
|
|
6
|
+
import CustomModal from './components/CustomModal';
|
|
7
7
|
import { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';
|
|
8
|
-
import { Input } from './Input';
|
|
9
|
-
|
|
8
|
+
import { Input } from './components/Input';
|
|
9
|
+
import { colors } from './styles/colors';
|
|
10
|
+
export const DropdownSelect = _ref => {
|
|
10
11
|
let {
|
|
11
12
|
placeholder,
|
|
12
13
|
label,
|
|
@@ -31,7 +32,11 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
31
32
|
modalOptionsContainer,
|
|
32
33
|
searchInputStyle,
|
|
33
34
|
primaryColor,
|
|
34
|
-
disabled
|
|
35
|
+
disabled,
|
|
36
|
+
checkboxSize,
|
|
37
|
+
checkboxStyle,
|
|
38
|
+
checkboxLabelStyle,
|
|
39
|
+
...rest
|
|
35
40
|
} = _ref;
|
|
36
41
|
const [newOptions, setNewOptions] = useState(options ? options : []);
|
|
37
42
|
const [open, setOpen] = useState(false);
|
|
@@ -65,6 +70,7 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
setSelectedItems(selectedValues);
|
|
73
|
+
onValueChange(selectedValues); //send value to parent
|
|
68
74
|
};
|
|
69
75
|
/*===========================================
|
|
70
76
|
* Get label handler
|
|
@@ -113,6 +119,7 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
113
119
|
setNewOptions(options);
|
|
114
120
|
};
|
|
115
121
|
|
|
122
|
+
let primary = primaryColor || colors.gray;
|
|
116
123
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
117
124
|
label: label,
|
|
118
125
|
placeholder: placeholder,
|
|
@@ -131,7 +138,7 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
131
138
|
selectedItemStyle: selectedItemStyle,
|
|
132
139
|
multipleSelectedItemStyle: multipleSelectedItemStyle,
|
|
133
140
|
isMultiple: isMultiple,
|
|
134
|
-
primaryColor:
|
|
141
|
+
primaryColor: primary,
|
|
135
142
|
disabled: disabled
|
|
136
143
|
}, rest)), /*#__PURE__*/React.createElement(CustomModal, {
|
|
137
144
|
open: open,
|
|
@@ -143,7 +150,7 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
143
150
|
value: searchValue,
|
|
144
151
|
onChangeText: text => onSearch(text),
|
|
145
152
|
style: searchInputStyle,
|
|
146
|
-
primaryColor:
|
|
153
|
+
primaryColor: primary
|
|
147
154
|
}), /*#__PURE__*/React.createElement(DropdownList, {
|
|
148
155
|
options: newOptions,
|
|
149
156
|
optionLabel: optionLabel,
|
|
@@ -153,7 +160,10 @@ export const DropdownSelect = (_ref, rest) => {
|
|
|
153
160
|
selectedItem: selectedItem,
|
|
154
161
|
handleMultipleSelections: handleMultipleSelections,
|
|
155
162
|
handleSingleSelection: handleSingleSelection,
|
|
156
|
-
primaryColor:
|
|
163
|
+
primaryColor: primary,
|
|
164
|
+
checkboxSize: checkboxSize,
|
|
165
|
+
checkboxStyle: checkboxStyle,
|
|
166
|
+
checkboxLabelStyle: checkboxLabelStyle
|
|
157
167
|
})));
|
|
158
168
|
};
|
|
159
169
|
export default DropdownSelect;
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["React","useState","Dropdown","CustomModal","DropdownList","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","Input","DropdownSelect","rest","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","labelStyle","dropdownStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainer","searchInputStyle","primaryColor","disabled","newOptions","setNewOptions","open","setOpen","selectedItem","setSelectedItem","selectedItems","setSelectedItems","Array","isArray","undefined","searchValue","setSearchValue","handleSingleSelection","value","handleMultipleSelections","selectedValues","includes","filter","item","push","getSelectedItemsLabel","selectedLabels","forEach","element","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","searchResults","toLowerCase","search","handleToggleModal","text"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,WAAP,MAAwB,SAAxB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,aAA3D;AAEA,SAASC,KAAT,QAAsB,SAAtB;AAEA,OAAO,MAAMC,cAAc,GAAG,OA2B5BC,IA3B4B,KA4BzB;AAAA,MA3BH;AACEC,IAAAA,WADF;AAEEC,IAAAA,KAFF;AAGEC,IAAAA,KAHF;AAIEC,IAAAA,UAJF;AAKEC,IAAAA,OALF;AAMEC,IAAAA,WANF;AAOEC,IAAAA,WAPF;AAQEC,IAAAA,aARF;AASEC,IAAAA,aATF;AAUEC,IAAAA,UAVF;AAWEC,IAAAA,YAXF;AAYEC,IAAAA,UAZF;AAaEC,IAAAA,aAbF;AAcEC,IAAAA,sBAdF;AAeEC,IAAAA,kBAfF;AAgBEC,IAAA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AyB,EAAEC,yBAhB7B;AAiBE,IAAA,UAAU,EAAET,UAjBd;AAkBE,IAAA,YAAY,EAAEa,YAlBhB;AAmBE,IAAA,QAAQ,EAAEC;AAnBZ,KAoBMxB,IApBN,EADF,eAuBE,oBAAC,WAAD;AACE,IAAA,IAAI,EAAE2B,IADR;AAEE,IAAA,iBAAiB,EAAEmC,iBAFrB;AAGE,IAAA,oBAAoB,EAAE1C,oBAHxB;AAIE,IAAA,qBAAqB,EAAEC,qBAJzB;AAKE,IAAA,cAAc,EAAE,MAAM,CAAE;AAL1B,KAOGV,YAAY,iBACX,oBAAC,KAAD;AACE,IAAA,KAAK,EAAEyB,WADT;AAEE,IAAA,YAAY,EAAG2B,IAAD,IAAkBX,QAAQ,CAACW,IAAD,CAF1C;AAGE,IAAA,KAAK,EAAEzC,gBAHT;AAIE,IAAA,YAAY,EAAEC;AAJhB,IARJ,eAeE,oBAAC,YAAD;AACE,IAAA,OAAO,EAAEE,UADX;AAEE,IAAA,WAAW,EAAEnB,WAFf;AAGE,IAAA,WAAW,EAAEC,WAHf;AAIE,IAAA,UAAU,EAAEG,UAJd;AAKE,IAAA,aAAa,EAAEqB,aALjB;AAME,IAAA,YAAY,EAAEF,YANhB;AAOE,IAAA,wBAAwB,EAAEW,wBAP5B;AAQE,IAAA,qBAAqB,EAAEF,qBARzB;AASE,IAAA,YAAY,EAAEf;AAThB,IAfF,CAvBF,CADF;AAqDD,CAvLM;AAyLP,eAAexB,cAAf","sourcesContent":["import React, { useState } from 'react';\nimport Dropdown from './Dropdown';\nimport CustomModal from './Modal';\nimport DropdownList from './DropdownList';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type { DropdownProps } from './types/index.types';\nimport { Input } from './Input';\n\nexport const DropdownSelect = (\n {\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainer,\n searchInputStyle,\n primaryColor,\n disabled,\n }: DropdownProps,\n rest: any\n) => {\n const [newOptions, setNewOptions] = useState(options ? options : []);\n const [open, setOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection\n const [selectedItems, setSelectedItems] = useState(\n Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue === '' || selectedValue === undefined\n ? []\n : [selectedValue]\n ); //for multiple selection\n const [searchValue, setSearchValue] = useState('');\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: any) => {\n if (selectedItem === value) {\n setSelectedItem(null);\n } else {\n setSelectedItem(value);\n onValueChange(value); //send value to parent\n setOpen(false); //close modal upon selection\n }\n };\n\n const handleMultipleSelections = (value: any) => {\n let selectedValues = [...selectedItems];\n\n if (selectedValues.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n setSelectedItems(selectedValues);\n };\n\n /*===========================================\n * Get label handler\n *==========================================*/\n const getSelectedItemsLabel = () => {\n if (isMultiple) {\n let selectedLabels: Array<string> = [];\n selectedItems &&\n selectedItems.forEach((element) => {\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === element\n )?.[optionLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem\n );\n return selectedItemLabel?.[optionLabel ?? DEFAULT_OPTION_LABEL];\n };\n\n /*===========================================\n * Search\n *==========================================*/\n const onSearch = (value: string) => {\n setSearchValue(value);\n\n let searchText = value.toString().toLocaleLowerCase().trim();\n\n const regexFilter = new RegExp(searchText, 'i');\n\n const searchResults = options.filter((item: any) => {\n if (\n item[optionLabel ?? DEFAULT_OPTION_LABEL]\n .toString()\n .toLowerCase()\n .search(regexFilter) !== -1 ||\n item[optionValue ?? DEFAULT_OPTION_VALUE]\n .toString(regexFilter)\n .toLowerCase()\n .search(regexFilter) !== -1\n ) {\n return item;\n }\n });\n\n setNewOptions(searchResults);\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n };\n\n return (\n <>\n <Dropdown\n label={label}\n placeholder={placeholder}\n helperText={helperText}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n handleToggleModal={handleToggleModal}\n labelStyle={labelStyle}\n dropdownStyle={dropdownStyle}\n dropdownContainerStyle={dropdownContainerStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n dropdownErrorTextStyle={dropdownErrorTextStyle}\n dropdownHelperTextStyle={dropdownHelperTextStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n isMultiple={isMultiple}\n primaryColor={primaryColor}\n disabled={disabled}\n {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainer={modalOptionsContainer}\n onRequestClose={() => {}}\n >\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primaryColor}\n />\n )}\n <DropdownList\n options={newOptions}\n optionLabel={optionLabel}\n optionValue={optionValue}\n isMultiple={isMultiple}\n selectedItems={selectedItems}\n selectedItem={selectedItem}\n handleMultipleSelections={handleMultipleSelections}\n handleSingleSelection={handleSingleSelection}\n primaryColor={primaryColor}\n />\n </CustomModal>\n </>\n );\n};\n\nexport default DropdownSelect;\n"]}
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["React","useState","Dropdown","DropdownList","CustomModal","DEFAULT_OPTION_LABEL","DEFAULT_OPTION_VALUE","Input","colors","DropdownSelect","placeholder","label","error","helperText","options","optionLabel","optionValue","onValueChange","selectedValue","isMultiple","isSearchable","labelStyle","dropdownStyle","dropdownContainerStyle","dropdownErrorStyle","dropdownErrorTextStyle","dropdownHelperTextStyle","selectedItemStyle","multipleSelectedItemStyle","modalBackgroundStyle","modalOptionsContainer","searchInputStyle","primaryColor","disabled","checkboxSize","checkboxStyle","checkboxLabelStyle","rest","newOptions","setNewOptions","open","setOpen","selectedItem","setSelectedItem","selectedItems","setSelectedItems","Array","isArray","undefined","searchValue","setSearchValue","handleSingleSelection","value","handleMultipleSelections","selectedValues","includes","filter","item","push","getSelectedItemsLabel","selectedLabels","forEach","element","selectedItemLabel","find","onSearch","searchText","toString","toLocaleLowerCase","trim","regexFilter","RegExp","searchResults","toLowerCase","search","handleToggleModal","primary","gray","text"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,OAAOC,QAAP,MAAqB,gCAArB;AACA,OAAOC,YAAP,MAAyB,oCAAzB;AACA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,aAA3D;AAEA,SAASC,KAAT,QAAsB,oBAAtB;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAEA,OAAO,MAAMC,cAAc,GAAG,QA6BT;AAAA,MA7BU;AAC7BC,IAAAA,WAD6B;AAE7BC,IAAAA,KAF6B;AAG7BC,IAAAA,KAH6B;AAI7BC,IAAAA,UAJ6B;AAK7BC,IAAAA,OAL6B;AAM7BC,IAAAA,WAN6B;AAO7BC,IAAAA,WAP6B;AAQ7BC,IAAAA,aAR6B;AAS7BC,IAAAA,aAT6B;AAU7BC,IAAAA,UAV6B;AAW7BC,IAAAA,YAX6B;AAY7BC,IAAAA,UAZ6B;AAa7BC,IAAAA,aAb6B;AAc7BC,IAAAA,sBAd6B;AAe7BC,IAAAA,kBAf6B;AAgB7BC,IAAA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D,CA7LM;AA+LP,eAAe3B,cAAf","sourcesContent":["import React, { useState } from 'react';\nimport Dropdown from './components/Dropdown/Dropdown';\nimport DropdownList from './components/Dropdown/DropdownList';\nimport CustomModal from './components/CustomModal';\nimport { DEFAULT_OPTION_LABEL, DEFAULT_OPTION_VALUE } from './constants';\nimport type { DropdownProps } from './types/index.types';\nimport { Input } from './components/Input';\nimport { colors } from './styles/colors';\n\nexport const DropdownSelect = ({\n placeholder,\n label,\n error,\n helperText,\n options,\n optionLabel,\n optionValue,\n onValueChange,\n selectedValue,\n isMultiple,\n isSearchable,\n labelStyle,\n dropdownStyle,\n dropdownContainerStyle,\n dropdownErrorStyle,\n dropdownErrorTextStyle,\n dropdownHelperTextStyle,\n selectedItemStyle,\n multipleSelectedItemStyle,\n modalBackgroundStyle,\n modalOptionsContainer,\n searchInputStyle,\n primaryColor,\n disabled,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n ...rest\n}: DropdownProps) => {\n const [newOptions, setNewOptions] = useState(options ? options : []);\n const [open, setOpen] = useState(false);\n const [selectedItem, setSelectedItem] = useState(selectedValue); //for single selection\n const [selectedItems, setSelectedItems] = useState(\n Array.isArray(selectedValue)\n ? selectedValue\n : selectedValue === '' || selectedValue === undefined\n ? []\n : [selectedValue]\n ); //for multiple selection\n const [searchValue, setSearchValue] = useState('');\n\n /*===========================================\n * Selection handlers\n *==========================================*/\n const handleSingleSelection = (value: any) => {\n if (selectedItem === value) {\n setSelectedItem(null);\n } else {\n setSelectedItem(value);\n onValueChange(value); //send value to parent\n setOpen(false); //close modal upon selection\n }\n };\n\n const handleMultipleSelections = (value: any) => {\n let selectedValues = [...selectedItems];\n\n if (selectedValues.includes(value)) {\n selectedValues = selectedValues.filter((item) => item !== value);\n } else {\n selectedValues.push(value);\n }\n setSelectedItems(selectedValues);\n onValueChange(selectedValues); //send value to parent\n };\n\n /*===========================================\n * Get label handler\n *==========================================*/\n const getSelectedItemsLabel = () => {\n if (isMultiple) {\n let selectedLabels: Array<string> = [];\n selectedItems &&\n selectedItems.forEach((element) => {\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === element\n )?.[optionLabel];\n selectedLabels.push(selectedItemLabel);\n });\n return selectedLabels;\n }\n\n let selectedItemLabel =\n options &&\n options.find(\n (item: any) =>\n item[optionValue ?? DEFAULT_OPTION_VALUE] === selectedItem\n );\n return selectedItemLabel?.[optionLabel ?? DEFAULT_OPTION_LABEL];\n };\n\n /*===========================================\n * Search\n *==========================================*/\n const onSearch = (value: string) => {\n setSearchValue(value);\n\n let searchText = value.toString().toLocaleLowerCase().trim();\n\n const regexFilter = new RegExp(searchText, 'i');\n\n const searchResults = options.filter((item: any) => {\n if (\n item[optionLabel ?? DEFAULT_OPTION_LABEL]\n .toString()\n .toLowerCase()\n .search(regexFilter) !== -1 ||\n item[optionValue ?? DEFAULT_OPTION_VALUE]\n .toString(regexFilter)\n .toLowerCase()\n .search(regexFilter) !== -1\n ) {\n return item;\n }\n });\n\n setNewOptions(searchResults);\n };\n\n /*===========================================\n * Modal\n *==========================================*/\n const handleToggleModal = () => {\n setOpen(!open);\n setSearchValue('');\n setNewOptions(options);\n };\n\n let primary = primaryColor || colors.gray;\n return (\n <>\n <Dropdown\n label={label}\n placeholder={placeholder}\n helperText={helperText}\n error={error}\n getSelectedItemsLabel={getSelectedItemsLabel}\n selectedItem={selectedItem}\n selectedItems={selectedItems}\n handleToggleModal={handleToggleModal}\n labelStyle={labelStyle}\n dropdownStyle={dropdownStyle}\n dropdownContainerStyle={dropdownContainerStyle}\n dropdownErrorStyle={dropdownErrorStyle}\n dropdownErrorTextStyle={dropdownErrorTextStyle}\n dropdownHelperTextStyle={dropdownHelperTextStyle}\n selectedItemStyle={selectedItemStyle}\n multipleSelectedItemStyle={multipleSelectedItemStyle}\n isMultiple={isMultiple}\n primaryColor={primary}\n disabled={disabled}\n {...rest}\n />\n <CustomModal\n open={open}\n handleToggleModal={handleToggleModal}\n modalBackgroundStyle={modalBackgroundStyle}\n modalOptionsContainer={modalOptionsContainer}\n onRequestClose={() => {}}\n >\n {isSearchable && (\n <Input\n value={searchValue}\n onChangeText={(text: string) => onSearch(text)}\n style={searchInputStyle}\n primaryColor={primary}\n />\n )}\n <DropdownList\n options={newOptions}\n optionLabel={optionLabel}\n optionValue={optionValue}\n isMultiple={isMultiple}\n selectedItems={selectedItems}\n selectedItem={selectedItem}\n handleMultipleSelections={handleMultipleSelections}\n handleSingleSelection={handleSingleSelection}\n primaryColor={primary}\n checkboxSize={checkboxSize}\n checkboxStyle={checkboxStyle}\n checkboxLabelStyle={checkboxLabelStyle}\n />\n </CustomModal>\n </>\n );\n};\n\nexport default DropdownSelect;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ColorValue, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
export declare type CheckboxProps = {
|
|
3
|
+
label?: string;
|
|
4
|
+
value?: boolean;
|
|
5
|
+
primaryColor?: ColorValue;
|
|
6
|
+
checkboxSize?: number;
|
|
7
|
+
checkboxStyle?: ViewStyle;
|
|
8
|
+
checkboxLabelStyle?: TextStyle;
|
|
9
|
+
onChange?: (value: boolean | string | number) => void;
|
|
10
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare const Dropdown: ({ label, placeholder, helperText, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, labelStyle, dropdownStyle, dropdownContainerStyle, selectedItemStyle, multipleSelectedItemStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, primaryColor, disabled, }: any) => JSX.Element;
|
|
2
3
|
export default Dropdown;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const DropdownList: ({ options, optionLabel, optionValue, isMultiple, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, }: any) => JSX.Element;
|
|
2
3
|
export default DropdownList;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const _default: React.MemoExoticComponent<({ item, optionLabel, optionValue, isMultiple, selectedOption, onChange, primaryColor, }: any) => JSX.Element>;
|
|
2
|
+
declare const _default: React.MemoExoticComponent<({ item, optionLabel, optionValue, isMultiple, selectedOption, onChange, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, }: any) => JSX.Element>;
|
|
3
3
|
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { DropdownProps } from './types/index.types';
|
|
2
|
-
export declare const DropdownSelect: ({ placeholder, label, error, helperText, options, optionLabel, optionValue, onValueChange, selectedValue, isMultiple, isSearchable, labelStyle, dropdownStyle, dropdownContainerStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, selectedItemStyle, multipleSelectedItemStyle, modalBackgroundStyle, modalOptionsContainer, searchInputStyle, primaryColor, disabled,
|
|
3
|
+
export declare const DropdownSelect: ({ placeholder, label, error, helperText, options, optionLabel, optionValue, onValueChange, selectedValue, isMultiple, isSearchable, labelStyle, dropdownStyle, dropdownContainerStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, selectedItemStyle, multipleSelectedItemStyle, modalBackgroundStyle, modalOptionsContainer, searchInputStyle, primaryColor, disabled, checkboxSize, checkboxStyle, checkboxLabelStyle, ...rest }: DropdownProps) => JSX.Element;
|
|
3
4
|
export default DropdownSelect;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewStyle, ColorValue, TextStyle } from 'react-native';
|
|
2
2
|
export declare type DropdownProps = {
|
|
3
|
-
placeholder
|
|
4
|
-
label
|
|
5
|
-
error
|
|
6
|
-
helperText
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
helperText?: string;
|
|
7
7
|
options: any[];
|
|
8
8
|
optionLabel: string;
|
|
9
|
-
optionValue
|
|
9
|
+
optionValue?: string;
|
|
10
10
|
onValueChange: Function;
|
|
11
|
-
selectedValue
|
|
12
|
-
isMultiple
|
|
13
|
-
isSearchable
|
|
14
|
-
labelStyle
|
|
15
|
-
dropdownStyle
|
|
16
|
-
dropdownContainerStyle
|
|
17
|
-
dropdownErrorStyle
|
|
18
|
-
dropdownErrorTextStyle
|
|
19
|
-
dropdownHelperTextStyle
|
|
20
|
-
selectedItemStyle
|
|
21
|
-
multipleSelectedItemStyle
|
|
22
|
-
modalBackgroundStyle
|
|
23
|
-
modalOptionsContainer
|
|
24
|
-
searchInputStyle
|
|
25
|
-
primaryColor
|
|
26
|
-
disabled
|
|
11
|
+
selectedValue?: string | any[] | null;
|
|
12
|
+
isMultiple?: boolean;
|
|
13
|
+
isSearchable?: boolean;
|
|
14
|
+
labelStyle?: TextStyle;
|
|
15
|
+
dropdownStyle?: ViewStyle;
|
|
16
|
+
dropdownContainerStyle?: ViewStyle;
|
|
17
|
+
dropdownErrorStyle?: ViewStyle;
|
|
18
|
+
dropdownErrorTextStyle?: TextStyle;
|
|
19
|
+
dropdownHelperTextStyle?: TextStyle;
|
|
20
|
+
selectedItemStyle?: ViewStyle;
|
|
21
|
+
multipleSelectedItemStyle?: ViewStyle;
|
|
22
|
+
modalBackgroundStyle?: ViewStyle;
|
|
23
|
+
modalOptionsContainer?: ViewStyle;
|
|
24
|
+
searchInputStyle?: ViewStyle;
|
|
25
|
+
primaryColor?: ColorValue;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
checkboxSize?: number;
|
|
28
|
+
checkboxStyle?: ViewStyle;
|
|
29
|
+
checkboxLabelStyle?: TextStyle;
|
|
27
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-input-select",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -32,14 +32,17 @@
|
|
|
32
32
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
33
33
|
"start": "yarn example start",
|
|
34
34
|
"android": "yarn example android",
|
|
35
|
-
"ios": "yarn example ios"
|
|
35
|
+
"ios": "yarn example ios",
|
|
36
|
+
"clean": "yarn example clean",
|
|
37
|
+
"watchman:clear": "watchman watch-del-all"
|
|
36
38
|
},
|
|
37
39
|
"keywords": [
|
|
38
40
|
"react-native",
|
|
39
41
|
"ios",
|
|
40
42
|
"android",
|
|
41
43
|
"dropdown",
|
|
42
|
-
"selection"
|
|
44
|
+
"selection",
|
|
45
|
+
"multiple select"
|
|
43
46
|
],
|
|
44
47
|
"repository": "https://github.com/azeezat/react-native-select",
|
|
45
48
|
"author": "Azeezat <azeezat94@gmail.com> (https://github.com/azeezat)",
|
|
@@ -56,8 +59,8 @@
|
|
|
56
59
|
"@react-native-community/eslint-config": "^2.0.0",
|
|
57
60
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
58
61
|
"@types/jest": "^26.0.0",
|
|
59
|
-
"@types/react": "
|
|
60
|
-
"@types/react-native": "^0.66.
|
|
62
|
+
"@types/react": "17.0.14",
|
|
63
|
+
"@types/react-native": "^0.66.27",
|
|
61
64
|
"commitlint": "^11.0.0",
|
|
62
65
|
"eslint": "^7.2.0",
|
|
63
66
|
"eslint-config-prettier": "^7.0.0",
|
|
@@ -73,7 +76,6 @@
|
|
|
73
76
|
"typescript": "^4.1.3"
|
|
74
77
|
},
|
|
75
78
|
"peerDependencies": {
|
|
76
|
-
"@react-native-community/checkbox": "^0.5.9",
|
|
77
79
|
"react": "*",
|
|
78
80
|
"react-native": "*"
|
|
79
81
|
},
|
|
@@ -149,8 +151,5 @@
|
|
|
149
151
|
}
|
|
150
152
|
]
|
|
151
153
|
]
|
|
152
|
-
},
|
|
153
|
-
"dependencies": {
|
|
154
|
-
"@react-native-community/checkbox": "^0.5.9"
|
|
155
154
|
}
|
|
156
155
|
}
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Pressable, Text, StyleSheet, Image, View } from 'react-native';
|
|
4
|
+
import { CHECKBOX_SIZE } from '../../constants';
|
|
5
|
+
import type { CheckboxProps } from './types';
|
|
6
|
+
|
|
7
|
+
const CheckBox = ({
|
|
8
|
+
label,
|
|
9
|
+
value,
|
|
10
|
+
primaryColor,
|
|
11
|
+
checkboxSize,
|
|
12
|
+
checkboxStyle,
|
|
13
|
+
checkboxLabelStyle,
|
|
14
|
+
onChange,
|
|
15
|
+
}: CheckboxProps) => {
|
|
16
|
+
const fillColor = {
|
|
17
|
+
backgroundColor: value ? primaryColor || 'green' : 'white',
|
|
18
|
+
};
|
|
19
|
+
return (
|
|
20
|
+
<Pressable
|
|
21
|
+
onPress={onChange ? () => onChange(!value) : () => {}}
|
|
22
|
+
style={[styles.checkboxContainer]}
|
|
23
|
+
>
|
|
24
|
+
<View style={[styles.checkbox, checkboxStyle, fillColor]}>
|
|
25
|
+
<Image
|
|
26
|
+
source={require('../../asset/check.png')}
|
|
27
|
+
style={[
|
|
28
|
+
{
|
|
29
|
+
height: checkboxSize || CHECKBOX_SIZE,
|
|
30
|
+
width: checkboxSize || CHECKBOX_SIZE,
|
|
31
|
+
},
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
</View>
|
|
35
|
+
{label && (
|
|
36
|
+
<Text style={[checkboxLabelStyle, styles.labelStyle]}>{label}</Text>
|
|
37
|
+
)}
|
|
38
|
+
</Pressable>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
checkboxContainer: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
flexWrap: 'nowrap',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
},
|
|
48
|
+
checkbox: {
|
|
49
|
+
padding: 4,
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
borderStyle: 'solid',
|
|
52
|
+
borderRadius: 4,
|
|
53
|
+
borderColor: 'black',
|
|
54
|
+
},
|
|
55
|
+
labelStyle: { marginLeft: 10 },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default CheckBox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ColorValue, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type CheckboxProps = {
|
|
4
|
+
label?: string;
|
|
5
|
+
value?: boolean;
|
|
6
|
+
primaryColor?: ColorValue;
|
|
7
|
+
checkboxSize?: number;
|
|
8
|
+
checkboxStyle?: ViewStyle;
|
|
9
|
+
checkboxLabelStyle?: TextStyle;
|
|
10
|
+
onChange?: (value: boolean | string | number) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import SelectedItemsView from './SelectedItemsView';
|
|
4
|
+
import { colors } from '../../styles/colors';
|
|
5
|
+
import { typography } from '../../styles/typography';
|
|
6
|
+
|
|
7
|
+
const Dropdown = ({
|
|
8
|
+
label,
|
|
9
|
+
placeholder,
|
|
10
|
+
helperText,
|
|
11
|
+
error,
|
|
12
|
+
getSelectedItemsLabel,
|
|
13
|
+
handleToggleModal,
|
|
14
|
+
isMultiple,
|
|
15
|
+
selectedItem,
|
|
16
|
+
selectedItems,
|
|
17
|
+
labelStyle,
|
|
18
|
+
dropdownStyle,
|
|
19
|
+
dropdownContainerStyle,
|
|
20
|
+
selectedItemStyle,
|
|
21
|
+
multipleSelectedItemStyle,
|
|
22
|
+
dropdownErrorStyle,
|
|
23
|
+
dropdownErrorTextStyle,
|
|
24
|
+
dropdownHelperTextStyle,
|
|
25
|
+
primaryColor,
|
|
26
|
+
disabled,
|
|
27
|
+
}: any) => {
|
|
28
|
+
return (
|
|
29
|
+
<View style={[styles.dropdownInputContainer, dropdownContainerStyle]}>
|
|
30
|
+
{label && label !== '' && (
|
|
31
|
+
<Text style={[styles.label, labelStyle]}>{label}</Text>
|
|
32
|
+
)}
|
|
33
|
+
<SelectedItemsView
|
|
34
|
+
placeholder={placeholder}
|
|
35
|
+
error={error}
|
|
36
|
+
getSelectedItemsLabel={getSelectedItemsLabel}
|
|
37
|
+
handleToggleModal={handleToggleModal}
|
|
38
|
+
isMultiple={isMultiple}
|
|
39
|
+
selectedItem={selectedItem}
|
|
40
|
+
selectedItems={selectedItems}
|
|
41
|
+
dropdownStyle={dropdownStyle}
|
|
42
|
+
selectedItemStyle={selectedItemStyle}
|
|
43
|
+
multipleSelectedItemStyle={multipleSelectedItemStyle}
|
|
44
|
+
dropdownErrorStyle={dropdownErrorStyle}
|
|
45
|
+
primaryColor={primaryColor}
|
|
46
|
+
disabled={disabled}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
{error && error !== '' && (
|
|
50
|
+
<Text style={[styles.error, dropdownErrorTextStyle]}>{error}</Text>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{helperText && helperText !== '' && !error && (
|
|
54
|
+
<Text style={[styles.helper, dropdownHelperTextStyle]}>
|
|
55
|
+
{helperText}
|
|
56
|
+
</Text>
|
|
57
|
+
)}
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const styles = StyleSheet.create({
|
|
63
|
+
label: { marginBottom: 16, color: colors.gray, ...typography.caption },
|
|
64
|
+
inputFocusErrorState: {
|
|
65
|
+
borderWidth: 2,
|
|
66
|
+
borderStyle: 'solid',
|
|
67
|
+
borderColor: colors.red,
|
|
68
|
+
},
|
|
69
|
+
error: { color: colors.red, marginTop: 8, ...typography.caption },
|
|
70
|
+
helper: { marginTop: 8, color: colors.primary, ...typography.caption },
|
|
71
|
+
dropdownInputContainer: { marginBottom: 23, width: '100%' },
|
|
72
|
+
blackText: { color: colors.black },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default Dropdown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, FlatList, StyleSheet, Text } from 'react-native';
|
|
3
3
|
import DropdownListItem from './DropdownListItem';
|
|
4
|
-
import { colors } from '
|
|
4
|
+
import { colors } from '../../styles/colors';
|
|
5
5
|
|
|
6
6
|
const DropdownList = ({
|
|
7
7
|
options,
|
|
@@ -13,6 +13,9 @@ const DropdownList = ({
|
|
|
13
13
|
handleMultipleSelections,
|
|
14
14
|
handleSingleSelection,
|
|
15
15
|
primaryColor,
|
|
16
|
+
checkboxSize,
|
|
17
|
+
checkboxStyle,
|
|
18
|
+
checkboxLabelStyle,
|
|
16
19
|
}: any) => {
|
|
17
20
|
return (
|
|
18
21
|
<FlatList
|
|
@@ -35,6 +38,9 @@ const DropdownList = ({
|
|
|
35
38
|
? handleMultipleSelections
|
|
36
39
|
: handleSingleSelection,
|
|
37
40
|
primaryColor,
|
|
41
|
+
checkboxSize,
|
|
42
|
+
checkboxStyle,
|
|
43
|
+
checkboxLabelStyle,
|
|
38
44
|
})
|
|
39
45
|
}
|
|
40
46
|
keyExtractor={(_item, index) => `Options${index}`}
|
|
@@ -52,6 +58,9 @@ const _renderItem = ({ item }: any, props: any) => {
|
|
|
52
58
|
selectedOption={props.selectedOption}
|
|
53
59
|
onChange={props.onChange}
|
|
54
60
|
primaryColor={props.primaryColor}
|
|
61
|
+
checkboxSize={props.checkboxSize}
|
|
62
|
+
checkboxStyle={props.checkboxStyle}
|
|
63
|
+
checkboxLabelStyle={props.checkboxLabelStyle}
|
|
55
64
|
/>
|
|
56
65
|
);
|
|
57
66
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
+
import CheckBox from '../CheckBox';
|
|
4
|
+
import { colors } from '../../styles/colors';
|
|
5
|
+
|
|
6
|
+
const DropdownListItem = ({
|
|
7
|
+
item,
|
|
8
|
+
optionLabel,
|
|
9
|
+
optionValue,
|
|
10
|
+
isMultiple,
|
|
11
|
+
selectedOption,
|
|
12
|
+
onChange,
|
|
13
|
+
primaryColor,
|
|
14
|
+
checkboxSize,
|
|
15
|
+
checkboxStyle,
|
|
16
|
+
checkboxLabelStyle,
|
|
17
|
+
}: any) => {
|
|
18
|
+
const selectedOptionValue = optionValue ?? 'value';
|
|
19
|
+
return (
|
|
20
|
+
<TouchableOpacity
|
|
21
|
+
style={styles.modalOptions}
|
|
22
|
+
onPress={() => onChange(item[selectedOptionValue])}
|
|
23
|
+
>
|
|
24
|
+
<CheckBox
|
|
25
|
+
value={
|
|
26
|
+
isMultiple
|
|
27
|
+
? selectedOption.includes(item[selectedOptionValue])
|
|
28
|
+
: [selectedOption].includes(item[selectedOptionValue])
|
|
29
|
+
}
|
|
30
|
+
label={item[optionLabel ?? '']}
|
|
31
|
+
onChange={() => onChange(item[selectedOptionValue])}
|
|
32
|
+
primaryColor={primaryColor || colors.primary}
|
|
33
|
+
checkboxSize={checkboxSize}
|
|
34
|
+
checkboxStyle={checkboxStyle}
|
|
35
|
+
checkboxLabelStyle={checkboxLabelStyle}
|
|
36
|
+
/>
|
|
37
|
+
</TouchableOpacity>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
modalOptions: {
|
|
43
|
+
paddingHorizontal: 20,
|
|
44
|
+
paddingVertical: 10,
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default memo(DropdownListItem);
|