react-native-input-select 1.3.3 → 1.3.5
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 +63 -53
- package/lib/commonjs/components/CheckBox/{types.js → checkbox.types.js} +1 -1
- package/lib/commonjs/components/CheckBox/checkbox.types.js.map +1 -0
- package/lib/commonjs/components/CheckBox/index.js +9 -28
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CustomModal/index.js +11 -7
- package/lib/commonjs/components/CustomModal/index.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js +7 -2
- package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +3 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js +7 -2
- package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/commonjs/components/Others/index.js.map +1 -1
- package/lib/commonjs/index.js +16 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.types.js.map +1 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/CheckBox/checkbox.types.js +2 -0
- package/lib/module/components/CheckBox/checkbox.types.js.map +1 -0
- package/lib/module/components/CheckBox/index.js +9 -28
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CustomModal/index.js +11 -7
- package/lib/module/components/CustomModal/index.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownFlatList.js +7 -2
- package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownListItem.js +3 -1
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSectionList.js +7 -2
- package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
- package/lib/module/components/Others/index.js.map +1 -1
- package/lib/module/index.js +16 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.types.js.map +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/components/CheckBox/checkbox.types.d.ts +9 -0
- package/lib/typescript/components/CheckBox/index.d.ts +2 -19
- package/lib/typescript/components/CustomModal/index.d.ts +3 -1
- package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +1 -1
- package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +1 -1
- package/lib/typescript/components/Others/index.d.ts +3 -1
- package/lib/typescript/types/index.types.d.ts +46 -15
- package/lib/typescript/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/CheckBox/checkbox.types.ts +10 -0
- package/src/components/CheckBox/index.tsx +15 -26
- package/src/components/CustomModal/index.tsx +19 -11
- package/src/components/Dropdown/DropdownFlatList.tsx +5 -2
- package/src/components/Dropdown/DropdownListItem.tsx +2 -0
- package/src/components/Dropdown/DropdownSectionList.tsx +6 -3
- package/src/components/Others/index.tsx +5 -1
- package/src/index.tsx +14 -9
- package/src/types/index.types.ts +56 -15
- package/src/utils/index.ts +1 -1
- package/lib/commonjs/components/CheckBox/types.js.map +0 -1
- package/lib/module/components/CheckBox/types.js +0 -2
- package/lib/module/components/CheckBox/types.js.map +0 -1
- package/lib/typescript/components/CheckBox/types.d.ts +0 -18
- package/src/components/CheckBox/types.ts +0 -19
package/README.md
CHANGED
|
@@ -109,19 +109,21 @@ export default function App() {
|
|
|
109
109
|
<Text>You can add any component to the bottom of this list</Text>
|
|
110
110
|
</View>
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
modalControls={{
|
|
113
|
+
modalOptionsContainerStyle: {
|
|
114
|
+
padding: 10,
|
|
115
|
+
backgroundColor: 'cyan',
|
|
116
|
+
},
|
|
117
|
+
modalProps: {
|
|
118
|
+
supportedOrientations: [
|
|
119
|
+
'portrait',
|
|
120
|
+
'portrait-upside-down',
|
|
121
|
+
'landscape',
|
|
122
|
+
'landscape-left',
|
|
123
|
+
'landscape-right',
|
|
124
|
+
],
|
|
125
|
+
transparent: false,
|
|
126
|
+
},
|
|
125
127
|
}}
|
|
126
128
|
listComponentStyles={{
|
|
127
129
|
listEmptyComponentStyle: {
|
|
@@ -239,52 +241,49 @@ For more examples visit our [wiki page](https://github.com/azeezat/react-native-
|
|
|
239
241
|
|
|
240
242
|
## Props
|
|
241
243
|
|
|
242
|
-
| Proptypes
|
|
243
|
-
|
|
|
244
|
-
| label
|
|
245
|
-
| placeholder
|
|
246
|
-
| options
|
|
247
|
-
| optionLabel
|
|
248
|
-
| optionValue
|
|
249
|
-
| error
|
|
250
|
-
| helperText
|
|
251
|
-
| selectedValue
|
|
252
|
-
| onValueChange
|
|
253
|
-
| isMultiple
|
|
254
|
-
| isSearchable
|
|
255
|
-
| disabled
|
|
256
|
-
| dropdownIcon
|
|
257
|
-
| labelStyle
|
|
258
|
-
| placeholderStyle
|
|
259
|
-
| dropdownStyle
|
|
260
|
-
| dropdownContainerStyle
|
|
261
|
-
| dropdownIconStyle
|
|
262
|
-
| selectedItemStyle
|
|
263
|
-
| multipleSelectedItemStyle
|
|
264
|
-
|
|
|
265
|
-
|
|
|
266
|
-
|
|
|
267
|
-
|
|
|
268
|
-
|
|
|
269
|
-
|
|
|
270
|
-
|
|
|
271
|
-
|
|
|
272
|
-
|
|
|
273
|
-
|
|
|
274
|
-
|
|
|
275
|
-
|
|
|
276
|
-
| checkboxComponent | `React Component` | `<View style={styles.radioButton} />` |
|
|
277
|
-
| listControls | `Object` | `{ selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, hideSelectAll: boolean, emptyListMessage: 'No record found'}` |
|
|
278
|
-
| searchControls | `Object` | `{ textInputStyle: ViewStyle \| TextStyle, textInputContainerStyle: ViewStyle, textInputProps: TextInputProps}` |
|
|
244
|
+
| Proptypes | Datatype | Example |
|
|
245
|
+
| ------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
246
|
+
| label | `string` | Countries |
|
|
247
|
+
| placeholder | `string` | Select a country |
|
|
248
|
+
| options | `Array` | `[{ name: 'Nigeria', code: 'NG' }, { name: 'Albania', code: 'AL' }]` |
|
|
249
|
+
| optionLabel | `string` | `name` |
|
|
250
|
+
| optionValue | `string` | `code` |
|
|
251
|
+
| error | `string` | `This is a requiredfield` |
|
|
252
|
+
| helperText | `string` | `Only few countries are listed` |
|
|
253
|
+
| selectedValue | `string` or `Array` | `AL` or `[AL, AX]` |
|
|
254
|
+
| onValueChange | `function` | `()=>{}` |
|
|
255
|
+
| isMultiple | `Boolean` | `true` |
|
|
256
|
+
| isSearchable | `Boolean` | `true` |
|
|
257
|
+
| disabled | `Boolean` | `true` |
|
|
258
|
+
| dropdownIcon | `React Component` | `Image` or `<Text> Show <Text>` |
|
|
259
|
+
| labelStyle | `Object` | `{color: 'red', fontSize: 15, fontWeight: '500'}` |
|
|
260
|
+
| placeholderStyle | `Object` | `{color: 'blue', fontSize: 15, fontWeight: '500'}` |
|
|
261
|
+
| dropdownStyle | `Object` | `{borderColor: 'blue', margin: 5, borderWidth:0 ...}` |
|
|
262
|
+
| dropdownContainerStyle | `Object` | `{backgroundColor: 'red', width: '30%', ...}` |
|
|
263
|
+
| dropdownIconStyle | `Object` | `{top: 10 , right: 10, ...}` |
|
|
264
|
+
| selectedItemStyle | `Object` | `{fontWeight: '600', color: 'yellow', ...}` |
|
|
265
|
+
| multipleSelectedItemStyle | `Object` | `{backgroundColor: 'red', color: 'yellow', ...}` |
|
|
266
|
+
| dropdownErrorStyle | `Object` | `{borderWidth: 2, borderStyle: 'solid'}` |
|
|
267
|
+
| dropdownErrorTextStyle | `Object` | `{color: 'red', fontWeight:'500'}` |
|
|
268
|
+
| dropdownHelperTextStyle | `Object` | `{color: 'green', fontWeight:'500'}` |
|
|
269
|
+
| primaryColor | `string` | `blue` |
|
|
270
|
+
| listHeaderComponent | `React Component` | `<Text> You can add any component here </Text>` |
|
|
271
|
+
| listFooterComponent | `React Component` | `<Text> You can add any component here <Text>` |
|
|
272
|
+
| hideModal | `Boolean` | Use this to hide the modal as needed |
|
|
273
|
+
| listComponentStyles | `Object` | `{listEmptyComponentStyle: ViewStyle, itemSeparatorStyle: ViewStyle, sectionHeaderStyle: TextStyle}` |
|
|
274
|
+
| checkboxControls | `Object` | `{checkboxSize: number, checkboxStyle: ViewStyle, checkboxLabelStyle: TextStyle, checkboxComponent?: React.ReactNode}` |
|
|
275
|
+
| listControls | `Object` | `{ selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, hideSelectAll: boolean, emptyListMessage: 'No record found'}` |
|
|
276
|
+
| searchControls | `Object` | `{ textInputStyle: ViewStyle \| TextStyle, textInputContainerStyle: ViewStyle, textInputProps: TextInputProps}` |
|
|
277
|
+
| modalControls | `Object` | `{ modalBackgroundStyle: ViewStyle, modalOptionsContainerStyle: ViewStyle, modalProps: ModalProps}` |
|
|
279
278
|
|
|
280
279
|
## Deprecation Notice
|
|
281
280
|
|
|
282
281
|
The following props would be removed in coming releases.
|
|
283
282
|
|
|
284
|
-
- Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced with a single object `
|
|
283
|
+
- Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle`, `checkboxComponent` would be replaced with a single object `checkboxControls` e.g
|
|
285
284
|
|
|
286
285
|
```js
|
|
287
|
-
|
|
286
|
+
checkboxControls = {
|
|
288
287
|
checkboxSize: 20,
|
|
289
288
|
checkboxStyle: {
|
|
290
289
|
backgroundColor: 'purple',
|
|
@@ -293,11 +292,12 @@ checkboxComponentStyles = {
|
|
|
293
292
|
borderColor: 'red',
|
|
294
293
|
},
|
|
295
294
|
checkboxLabelStyle: { color: 'red', fontSize: 20 },
|
|
295
|
+
checkboxComponent: <View style={styles.radioButton} />
|
|
296
296
|
...
|
|
297
297
|
};
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
- `searchInputStyle` would now be
|
|
300
|
+
- `searchInputStyle` would now be replaced with `textInputStyle` in the `searchControls` object
|
|
301
301
|
|
|
302
302
|
```js
|
|
303
303
|
searchControls = {
|
|
@@ -324,6 +324,16 @@ searchControls = {
|
|
|
324
324
|
};
|
|
325
325
|
```
|
|
326
326
|
|
|
327
|
+
- Individual props `modalBackgroundStyle`, `modalOptionsContainerStyle`, `modalProps` would be replaced with a single object `modalControls`
|
|
328
|
+
|
|
329
|
+
```js
|
|
330
|
+
modalControls = {
|
|
331
|
+
modalBackgroundStyle: ViewStyle,
|
|
332
|
+
modalOptionsContainerStyle: ViewStyle,
|
|
333
|
+
modalProps: ModalProps, //Use this to pass in react-native default modal props
|
|
334
|
+
};
|
|
335
|
+
```
|
|
336
|
+
|
|
327
337
|
## Contributing
|
|
328
338
|
|
|
329
339
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["checkbox.types.ts"],"sourcesContent":["import type { ColorValue } from 'react-native';\nimport { TCheckboxControls } from 'src/types/index.types';\n\nexport type CheckboxProps = {\n label?: string;\n value?: boolean;\n disabled?: boolean;\n primaryColor?: ColorValue;\n onChange?: (value: boolean | string | number) => void;\n} & TCheckboxControls;\n"],"mappings":""}
|
|
@@ -9,26 +9,8 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _colors = require("../../styles/colors");
|
|
10
10
|
var _constants = require("../../constants");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/**
|
|
13
|
-
* Individual props `checkboxSize`, `checkboxStyle`, `checkboxLabelStyle` would be replaced in future releases
|
|
14
|
-
* and replaced with a single object `checkboxComponentStyles` e.g
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
const checkboxComponentStyles = {
|
|
18
|
-
checkboxSize: 20,
|
|
19
|
-
checkboxStyle: {
|
|
20
|
-
backgroundColor: 'purple',
|
|
21
|
-
borderRadius: 30,
|
|
22
|
-
padding: 10,
|
|
23
|
-
borderColor: 'red',
|
|
24
|
-
},
|
|
25
|
-
checkboxLabelStyle: { color: 'red', fontSize: 20 },
|
|
26
|
-
};
|
|
27
|
-
```
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
12
|
const CheckBox = _ref => {
|
|
31
|
-
var _checkboxComponentSty, _checkboxComponentSty2;
|
|
13
|
+
var _checkboxControls$che, _checkboxComponentSty, _checkboxControls$che2, _checkboxComponentSty2;
|
|
32
14
|
let {
|
|
33
15
|
label,
|
|
34
16
|
value,
|
|
@@ -39,28 +21,27 @@ const CheckBox = _ref => {
|
|
|
39
21
|
checkboxLabelStyle,
|
|
40
22
|
checkboxComponentStyles,
|
|
41
23
|
checkboxComponent,
|
|
24
|
+
checkboxControls,
|
|
42
25
|
onChange
|
|
43
26
|
} = _ref;
|
|
44
|
-
// const { checkboxSize, checkboxStyle, checkboxLabelStyle } =
|
|
45
|
-
// checkboxComponentStyles || undefined;
|
|
46
27
|
const fillColor = {
|
|
47
|
-
backgroundColor: disabled ? '#d3d3d3' : value ? (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty === void 0 ? void 0 : _checkboxComponentSty.backgroundColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.backgroundColor) || primaryColor || 'green' : 'white',
|
|
48
|
-
borderColor: disabled ? _colors.colors.disabled : (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty2 = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty2 === void 0 ? void 0 : _checkboxComponentSty2.borderColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.borderColor) || styles.checkbox.borderColor
|
|
28
|
+
backgroundColor: disabled ? '#d3d3d3' : value ? (checkboxControls === null || checkboxControls === void 0 || (_checkboxControls$che = checkboxControls.checkboxStyle) === null || _checkboxControls$che === void 0 ? void 0 : _checkboxControls$che.backgroundColor) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty === void 0 ? void 0 : _checkboxComponentSty.backgroundColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.backgroundColor) || primaryColor || 'green' : 'white',
|
|
29
|
+
borderColor: disabled ? _colors.colors.disabled : (checkboxControls === null || checkboxControls === void 0 || (_checkboxControls$che2 = checkboxControls.checkboxStyle) === null || _checkboxControls$che2 === void 0 ? void 0 : _checkboxControls$che2.borderColor) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 || (_checkboxComponentSty2 = checkboxComponentStyles.checkboxStyle) === null || _checkboxComponentSty2 === void 0 ? void 0 : _checkboxComponentSty2.borderColor) || (checkboxStyle === null || checkboxStyle === void 0 ? void 0 : checkboxStyle.borderColor) || styles.checkbox.borderColor
|
|
49
30
|
};
|
|
50
31
|
return /*#__PURE__*/_react.default.createElement(_reactNative.Pressable, {
|
|
51
32
|
onPress: onChange ? () => onChange(!value) : null,
|
|
52
33
|
style: [styles.checkboxContainer],
|
|
53
34
|
disabled: disabled
|
|
54
35
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
55
|
-
style: [styles.checkbox, (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxStyle) || checkboxStyle, fillColor]
|
|
56
|
-
}, checkboxComponent || /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
36
|
+
style: [styles.checkbox, (checkboxControls === null || checkboxControls === void 0 ? void 0 : checkboxControls.checkboxStyle) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxStyle) || checkboxStyle, fillColor]
|
|
37
|
+
}, (checkboxControls === null || checkboxControls === void 0 ? void 0 : checkboxControls.checkboxComponent) || checkboxComponent || /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
57
38
|
source: require('../../asset/check.png'),
|
|
58
39
|
style: [{
|
|
59
|
-
height: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize || _constants.CHECKBOX_SIZE,
|
|
60
|
-
width: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize || _constants.CHECKBOX_SIZE
|
|
40
|
+
height: (checkboxControls === null || checkboxControls === void 0 ? void 0 : checkboxControls.checkboxSize) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize || _constants.CHECKBOX_SIZE,
|
|
41
|
+
width: (checkboxControls === null || checkboxControls === void 0 ? void 0 : checkboxControls.checkboxSize) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize || _constants.CHECKBOX_SIZE
|
|
61
42
|
}]
|
|
62
43
|
})), label && label !== '' && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
63
|
-
style: [(checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxLabelStyle) || checkboxLabelStyle, styles.labelStyle]
|
|
44
|
+
style: [(checkboxControls === null || checkboxControls === void 0 ? void 0 : checkboxControls.checkboxLabelStyle) || (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxLabelStyle) || checkboxLabelStyle, styles.labelStyle]
|
|
64
45
|
}, label));
|
|
65
46
|
};
|
|
66
47
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","_constants","obj","__esModule","default","CheckBox","_ref","_checkboxComponentSty","_checkboxComponentSty2","label","value","disabled","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","onChange","fillColor","backgroundColor","borderColor","colors","styles","checkbox","createElement","Pressable","onPress","style","checkboxContainer","View","Image","source","height","CHECKBOX_SIZE","width","Text","labelStyle","StyleSheet","create","flexDirection","flexWrap","alignItems","padding","borderWidth","borderStyle","borderRadius","marginLeft","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { Pressable, Text, StyleSheet, Image, View } from 'react-native';\nimport { colors } from '../../styles/colors';\nimport { CHECKBOX_SIZE } from '../../constants';\nimport type { CheckboxProps } from './types';\n\
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","_constants","obj","__esModule","default","CheckBox","_ref","_checkboxControls$che","_checkboxComponentSty","_checkboxControls$che2","_checkboxComponentSty2","label","value","disabled","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","checkboxControls","onChange","fillColor","backgroundColor","borderColor","colors","styles","checkbox","createElement","Pressable","onPress","style","checkboxContainer","View","Image","source","height","CHECKBOX_SIZE","width","Text","labelStyle","StyleSheet","create","flexDirection","flexWrap","alignItems","padding","borderWidth","borderStyle","borderRadius","marginLeft","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { Pressable, Text, StyleSheet, Image, View } from 'react-native';\nimport { colors } from '../../styles/colors';\nimport { CHECKBOX_SIZE } from '../../constants';\nimport type { CheckboxProps } from './checkbox.types';\n\nconst CheckBox = ({\n label,\n value,\n disabled,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n checkboxControls,\n onChange,\n}: CheckboxProps) => {\n const fillColor = {\n backgroundColor: disabled\n ? '#d3d3d3'\n : value\n ? checkboxControls?.checkboxStyle?.backgroundColor ||\n checkboxComponentStyles?.checkboxStyle?.backgroundColor ||\n checkboxStyle?.backgroundColor ||\n primaryColor ||\n 'green'\n : 'white',\n borderColor: disabled\n ? colors.disabled\n : checkboxControls?.checkboxStyle?.borderColor ||\n checkboxComponentStyles?.checkboxStyle?.borderColor ||\n checkboxStyle?.borderColor ||\n styles.checkbox.borderColor,\n };\n\n return (\n <Pressable\n onPress={onChange ? () => onChange(!value) : null}\n style={[styles.checkboxContainer]}\n disabled={disabled}\n >\n <View\n style={[\n styles.checkbox,\n checkboxControls?.checkboxStyle ||\n checkboxComponentStyles?.checkboxStyle ||\n checkboxStyle,\n fillColor,\n ]}\n >\n {checkboxControls?.checkboxComponent || checkboxComponent || (\n <Image\n source={require('../../asset/check.png')}\n style={[\n {\n height:\n checkboxControls?.checkboxSize ||\n checkboxComponentStyles?.checkboxSize ||\n checkboxSize ||\n CHECKBOX_SIZE,\n width:\n checkboxControls?.checkboxSize ||\n checkboxComponentStyles?.checkboxSize ||\n checkboxSize ||\n CHECKBOX_SIZE,\n },\n ]}\n />\n )}\n </View>\n {label && label !== '' && (\n <Text\n style={[\n checkboxControls?.checkboxLabelStyle ||\n checkboxComponentStyles?.checkboxLabelStyle ||\n checkboxLabelStyle,\n styles.labelStyle,\n ]}\n >\n {label}\n </Text>\n )}\n </Pressable>\n );\n};\n\nconst styles = StyleSheet.create({\n checkboxContainer: {\n flexDirection: 'row',\n flexWrap: 'nowrap',\n alignItems: 'center',\n },\n checkbox: {\n padding: 4,\n borderWidth: 1,\n borderStyle: 'solid',\n borderRadius: 4,\n borderColor: 'black',\n },\n labelStyle: { marginLeft: 10 },\n});\n\nexport default CheckBox;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAA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AAAwC,IAAI;IACHR,KAAK,EAAE,CACL,CAAAX,gBAAgB,aAAhBA,gBAAgB,uBAAhBA,gBAAgB,CAAEH,kBAAkB,MAClCC,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAED,kBAAkB,KAC3CA,kBAAkB,EACpBS,MAAM,CAACc,UAAU;EACjB,GAED7B,KACG,CAEC,CAAC;AAEhB,CAAC;AAED,MAAMe,MAAM,GAAGe,uBAAU,CAACC,MAAM,CAAC;EAC/BV,iBAAiB,EAAE;IACjBW,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE,QAAQ;IAClBC,UAAU,EAAE;EACd,CAAC;EACDlB,QAAQ,EAAE;IACRmB,OAAO,EAAE,CAAC;IACVC,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,OAAO;IACpBC,YAAY,EAAE,CAAC;IACfzB,WAAW,EAAE;EACf,CAAC;EACDgB,UAAU,EAAE;IAAEU,UAAU,EAAE;EAAG;AAC/B,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEY9C,QAAQ;AAAA+C,OAAA,CAAAhD,OAAA,GAAA+C,QAAA"}
|
|
@@ -11,25 +11,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
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); }
|
|
12
12
|
const CustomModal = _ref => {
|
|
13
13
|
let {
|
|
14
|
-
|
|
14
|
+
visible,
|
|
15
15
|
onRequestClose,
|
|
16
16
|
modalBackgroundStyle,
|
|
17
|
+
//kept for backwards compatibility
|
|
17
18
|
modalOptionsContainerStyle,
|
|
19
|
+
//kept for backwards compatibility
|
|
20
|
+
modalControls,
|
|
18
21
|
modalProps,
|
|
22
|
+
//kept for backwards compatibility
|
|
19
23
|
children
|
|
20
24
|
} = _ref;
|
|
21
25
|
return /*#__PURE__*/_react.default.createElement(_reactNative.Modal, _extends({
|
|
22
26
|
transparent: true,
|
|
23
|
-
visible:
|
|
24
|
-
onRequestClose: () => onRequestClose(),
|
|
27
|
+
visible: visible,
|
|
28
|
+
onRequestClose: () => onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose(),
|
|
25
29
|
animationType: "fade"
|
|
26
|
-
}, modalProps), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
27
|
-
onPress: () => onRequestClose(),
|
|
28
|
-
style: [styles.modalContainer, styles.modalBackgroundStyle, modalBackgroundStyle]
|
|
30
|
+
}, modalControls === null || modalControls === void 0 ? void 0 : modalControls.modalProps, modalProps), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
31
|
+
onPress: () => onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose(),
|
|
32
|
+
style: [styles.modalContainer, styles.modalBackgroundStyle, (modalControls === null || modalControls === void 0 ? void 0 : modalControls.modalBackgroundStyle) || modalBackgroundStyle]
|
|
29
33
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableWithoutFeedback, {
|
|
30
34
|
onPress: () => {}
|
|
31
35
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
|
|
32
|
-
style: [styles.modalOptionsContainer, modalOptionsContainerStyle]
|
|
36
|
+
style: [styles.modalOptionsContainer, (modalControls === null || modalControls === void 0 ? void 0 : modalControls.modalOptionsContainerStyle) || modalOptionsContainerStyle]
|
|
33
37
|
}, children))));
|
|
34
38
|
};
|
|
35
39
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","CustomModal","_ref","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_colors","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","CustomModal","_ref","visible","onRequestClose","modalBackgroundStyle","modalOptionsContainerStyle","modalControls","modalProps","children","createElement","Modal","transparent","animationType","TouchableOpacity","onPress","style","styles","modalContainer","TouchableWithoutFeedback","SafeAreaView","modalOptionsContainer","StyleSheet","create","flex","justifyContent","backgroundColor","maxHeight","colors","white","borderTopLeftRadius","borderTopRightRadius","zIndex","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Modal,\n TouchableOpacity,\n SafeAreaView,\n StyleSheet,\n TouchableWithoutFeedback,\n ModalProps,\n} from 'react-native';\nimport { colors } from '../../styles/colors';\nimport { TCustomModalControls } from 'src/types/index.types';\n\nconst CustomModal = ({\n visible,\n onRequestClose,\n modalBackgroundStyle, //kept for backwards compatibility\n modalOptionsContainerStyle, //kept for backwards compatibility\n modalControls,\n modalProps, //kept for backwards compatibility\n children,\n}: TCustomModalControls & ModalProps) => {\n return (\n <Modal\n transparent={true}\n visible={visible}\n onRequestClose={() => onRequestClose?.()}\n animationType=\"fade\"\n {...modalControls?.modalProps}\n {...modalProps} //kept for backwards compatibility\n >\n <TouchableOpacity\n onPress={() => onRequestClose?.()}\n style={[\n styles.modalContainer,\n styles.modalBackgroundStyle,\n modalControls?.modalBackgroundStyle || modalBackgroundStyle,\n ]}\n >\n {/* Added this `TouchableWithoutFeedback` wrapper because of the closing modal on expo web */}\n <TouchableWithoutFeedback onPress={() => {}}>\n <SafeAreaView\n style={[\n styles.modalOptionsContainer,\n modalControls?.modalOptionsContainerStyle ||\n modalOptionsContainerStyle,\n ]}\n >\n {children}\n </SafeAreaView>\n </TouchableWithoutFeedback>\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 modalOptionsCont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// kept for backwards compatibility to be removed in future release
|
|
33
33
|
checkboxComponentStyles,
|
|
34
34
|
checkboxComponent,
|
|
35
|
+
checkboxControls,
|
|
35
36
|
listComponentStyles,
|
|
36
37
|
listIndex,
|
|
37
38
|
emptyListMessage,
|
|
@@ -79,7 +80,10 @@ const DropdownFlatList = _ref => {
|
|
|
79
80
|
checkboxLabelStyle,
|
|
80
81
|
// kept for backwards compatibility
|
|
81
82
|
checkboxComponentStyles,
|
|
82
|
-
|
|
83
|
+
// kept for backwards compatibility
|
|
84
|
+
checkboxComponent,
|
|
85
|
+
// kept for backwards compatibility
|
|
86
|
+
checkboxControls
|
|
83
87
|
}),
|
|
84
88
|
keyExtractor: (_item, index) => `Options${index}`,
|
|
85
89
|
ref: flatlistRef,
|
|
@@ -110,7 +114,8 @@ const _renderItem = (_ref3, props) => {
|
|
|
110
114
|
checkboxLabelStyle: props.checkboxLabelStyle,
|
|
111
115
|
scrollToItem: props.scrollToItem,
|
|
112
116
|
checkboxComponentStyles: props.checkboxComponentStyles,
|
|
113
|
-
checkboxComponent: props.checkboxComponent
|
|
117
|
+
checkboxComponent: props.checkboxComponent,
|
|
118
|
+
checkboxControls: props.checkboxControls
|
|
114
119
|
});
|
|
115
120
|
};
|
|
116
121
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_DropdownListItem","_interopRequireDefault","_Others","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownFlatList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","listComponentStyles","listIndex","emptyListMessage","rest","flatlistRef","useRef","scrollToItem","index","_flatlistRef$current","current","scrollToIndex","animated","useEffect","itemIndex","createElement","FlatList","data","extraData","initialNumToRender","ListEmptyComponent","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","ItemSeparatorComponent","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","keyExtractor","_item","ref","onScrollToIndexFailed","_ref2","setTimeout","_ref3","props","StyleSheet","create","_default","exports"],"sources":["DropdownFlatList.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React, { useEffect, useRef } from 'react';\nimport { FlatList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { ItemSeparatorComponent, ListEmptyComponent } from '../Others';\nimport { TFlatList } from 'src/types/index.types';\n\nconst DropdownFlatList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize, // kept for backwards compatibility to be removed in future release\n checkboxStyle, // kept for backwards compatibility to be removed in future release\n checkboxLabelStyle, // kept for backwards compatibility to be removed in future release\n checkboxComponentStyles,\n checkboxComponent,\n listComponentStyles,\n listIndex,\n emptyListMessage,\n ...rest\n}: any) => {\n const flatlistRef = useRef<FlatList<TFlatList>>(null);\n\n const scrollToItem = (index: number) => {\n flatlistRef.current?.scrollToIndex({\n index,\n animated: true,\n });\n };\n\n useEffect(() => {\n if (listIndex.itemIndex >= 0) {\n scrollToItem(listIndex.itemIndex);\n }\n }, [listIndex]);\n\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <ListEmptyComponent\n listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}\n emptyListMessage={emptyListMessage}\n />\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => (\n <ItemSeparatorComponent\n itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}\n />\n )}\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 scrollToItem,\n primaryColor,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_DropdownListItem","_interopRequireDefault","_Others","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownFlatList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","checkboxControls","listComponentStyles","listIndex","emptyListMessage","rest","flatlistRef","useRef","scrollToItem","index","_flatlistRef$current","current","scrollToIndex","animated","useEffect","itemIndex","createElement","FlatList","data","extraData","initialNumToRender","ListEmptyComponent","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","ItemSeparatorComponent","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","keyExtractor","_item","ref","onScrollToIndexFailed","_ref2","setTimeout","_ref3","props","StyleSheet","create","_default","exports"],"sources":["DropdownFlatList.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React, { useEffect, useRef } from 'react';\nimport { FlatList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport { ItemSeparatorComponent, ListEmptyComponent } from '../Others';\nimport { TFlatList } from 'src/types/index.types';\n\nconst DropdownFlatList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize, // kept for backwards compatibility to be removed in future release\n checkboxStyle, // kept for backwards compatibility to be removed in future release\n checkboxLabelStyle, // kept for backwards compatibility to be removed in future release\n checkboxComponentStyles,\n checkboxComponent,\n checkboxControls,\n listComponentStyles,\n listIndex,\n emptyListMessage,\n ...rest\n}: any) => {\n const flatlistRef = useRef<FlatList<TFlatList>>(null);\n\n const scrollToItem = (index: number) => {\n flatlistRef.current?.scrollToIndex({\n index,\n animated: true,\n });\n };\n\n useEffect(() => {\n if (listIndex.itemIndex >= 0) {\n scrollToItem(listIndex.itemIndex);\n }\n }, [listIndex]);\n\n return (\n <FlatList\n data={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <ListEmptyComponent\n listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}\n emptyListMessage={emptyListMessage}\n />\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => (\n <ItemSeparatorComponent\n itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}\n />\n )}\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 scrollToItem,\n primaryColor,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles, // kept for backwards compatibility\n checkboxComponent, // kept for backwards compatibility\n checkboxControls,\n })\n }\n keyExtractor={(_item, index) => `Options${index}`}\n ref={flatlistRef}\n onScrollToIndexFailed={({ index }) => {\n setTimeout(() => {\n scrollToItem(index);\n }, 500);\n }}\n {...rest}\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 primaryColor={props.primaryColor}\n checkboxSize={props.checkboxSize}\n checkboxStyle={props.checkboxStyle}\n checkboxLabelStyle={props.checkboxLabelStyle}\n scrollToItem={props.scrollToItem}\n checkboxComponentStyles={props.checkboxComponentStyles}\n checkboxComponent={props.checkboxComponent}\n checkboxControls={props.checkboxControls}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownFlatList;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAAuE,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAM,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,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5C,YAAa;IACjCC,aAAa,EAAE2C,KAAK,CAAC3C,aAAc;IACnCC,kBAAkB,EAAE0C,KAAK,CAAC1C,kBAAmB;IAC7CU,YAAY,EAAEgC,KAAK,CAAChC,YAAa;IACjCT,uBAAuB,EAAEyC,KAAK,CAACzC,uBAAwB;IACvDC,iBAAiB,EAAEwC,KAAK,CAACxC,iBAAkB;IAC3CC,gBAAgB,EAAEuC,KAAK,CAACvC;EAAiB,CAC1C,CAAC;AAEN,CAAC;AAED,MAAMwB,MAAM,GAAGgB,uBAAU,CAACC,MAAM,CAAC;EAC/BnB,qBAAqB,EAAE;IAAEC,UAAU,EAAE;EAAG;AAC1C,CAAC,CAAC;AAAC,IAAAmB,QAAA,GAEY3D,gBAAgB;AAAA4D,OAAA,CAAAzF,OAAA,GAAAwF,QAAA"}
|
|
@@ -23,7 +23,8 @@ const DropdownListItem = _ref => {
|
|
|
23
23
|
checkboxStyle,
|
|
24
24
|
checkboxLabelStyle,
|
|
25
25
|
checkboxComponentStyles,
|
|
26
|
-
checkboxComponent
|
|
26
|
+
checkboxComponent,
|
|
27
|
+
checkboxControls
|
|
27
28
|
} = _ref;
|
|
28
29
|
return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
29
30
|
style: styles.listItemContainerStyle,
|
|
@@ -33,6 +34,7 @@ const DropdownListItem = _ref => {
|
|
|
33
34
|
label: item[optionLabel],
|
|
34
35
|
onChange: () => onChange(item[optionValue]),
|
|
35
36
|
primaryColor: primaryColor,
|
|
37
|
+
checkboxControls: checkboxControls,
|
|
36
38
|
checkboxSize: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxSize) || checkboxSize,
|
|
37
39
|
checkboxStyle: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxStyle) || checkboxStyle,
|
|
38
40
|
checkboxLabelStyle: (checkboxComponentStyles === null || checkboxComponentStyles === void 0 ? void 0 : checkboxComponentStyles.checkboxLabelStyle) || checkboxLabelStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_CheckBox","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","DropdownListItem","_ref","item","optionLabel","optionValue","isMultiple","selectedOption","onChange","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","createElement","TouchableOpacity","style","styles","listItemContainerStyle","onPress","disabled","value","includes","label","StyleSheet","create","paddingHorizontal","paddingVertical","flexDirection","alignItems","_default","memo","exports"],"sources":["DropdownListItem.tsx"],"sourcesContent":["import React, { memo } from 'react';\nimport { TouchableOpacity, StyleSheet } from 'react-native';\nimport CheckBox from '../CheckBox';\n\nconst DropdownListItem = ({\n item,\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption,\n onChange,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n}: any) => {\n return (\n <TouchableOpacity\n style={styles.listItemContainerStyle}\n onPress={\n item.disabled ? () => {} : () => onChange(item[optionValue]) // intentionally didn't use the disable property\n }\n >\n <CheckBox\n value={\n isMultiple\n ? selectedOption.includes(item[optionValue])\n : [selectedOption].includes(item[optionValue])\n }\n label={item[optionLabel]}\n onChange={() => onChange(item[optionValue])}\n primaryColor={primaryColor}\n checkboxSize={checkboxComponentStyles?.checkboxSize || checkboxSize}\n checkboxStyle={checkboxComponentStyles?.checkboxStyle || checkboxStyle}\n checkboxLabelStyle={\n checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle\n }\n disabled={item.disabled}\n checkboxComponent={checkboxComponent}\n />\n </TouchableOpacity>\n );\n};\n\nconst styles = StyleSheet.create({\n listItemContainerStyle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MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAhB,GAAA,CAAAgB,GAAA,SAAAL,MAAA,CAAAT,OAAA,GAAAF,GAAA,MAAAQ,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAArB,GAAA,EAAAW,MAAA,YAAAA,MAAA;AAEnC,MAAMW,gBAAgB,GAAGC,IAAA,
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_CheckBox","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","DropdownListItem","_ref","item","optionLabel","optionValue","isMultiple","selectedOption","onChange","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","checkboxControls","createElement","TouchableOpacity","style","styles","listItemContainerStyle","onPress","disabled","value","includes","label","StyleSheet","create","paddingHorizontal","paddingVertical","flexDirection","alignItems","_default","memo","exports"],"sources":["DropdownListItem.tsx"],"sourcesContent":["import React, { memo } from 'react';\nimport { TouchableOpacity, StyleSheet } from 'react-native';\nimport CheckBox from '../CheckBox';\n\nconst DropdownListItem = ({\n item,\n optionLabel,\n optionValue,\n isMultiple,\n selectedOption,\n onChange,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n checkboxControls,\n}: any) => {\n return (\n <TouchableOpacity\n style={styles.listItemContainerStyle}\n onPress={\n item.disabled ? () => {} : () => onChange(item[optionValue]) // intentionally didn't use the disable property\n }\n >\n <CheckBox\n value={\n isMultiple\n ? selectedOption.includes(item[optionValue])\n : [selectedOption].includes(item[optionValue])\n }\n label={item[optionLabel]}\n onChange={() => onChange(item[optionValue])}\n primaryColor={primaryColor}\n checkboxControls={checkboxControls}\n checkboxSize={checkboxComponentStyles?.checkboxSize || checkboxSize}\n checkboxStyle={checkboxComponentStyles?.checkboxStyle || checkboxStyle}\n checkboxLabelStyle={\n checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle\n }\n disabled={item.disabled}\n checkboxComponent={checkboxComponent}\n />\n </TouchableOpacity>\n );\n};\n\nconst styles = StyleSheet.create({\n listItemContainerStyle: {\n paddingHorizontal: 20,\n paddingVertical: 10,\n flexDirection: 'row',\n alignItems: 'center',\n },\n});\n\nexport default memo(DropdownListItem);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAmC,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAT,wBAAAK,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAhB,GAAA,QAAAgB,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,C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,CAAA,KAAMA,QAAQ,CAACL,IAAI,CAACE,WAAW,CAAC,CAAE;IAC5CI,YAAY,EAAEA,YAAa;IAC3BM,gBAAgB,EAAEA,gBAAiB;IACnCL,YAAY,EAAE,CAAAG,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAEH,YAAY,KAAIA,YAAa;IACpEC,aAAa,EAAE,CAAAE,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAEF,aAAa,KAAIA,aAAc;IACvEC,kBAAkB,EAChB,CAAAC,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAED,kBAAkB,KAAIA,kBAChD;IACDU,QAAQ,EAAEnB,IAAI,CAACmB,QAAS;IACxBR,iBAAiB,EAAEA;EAAkB,CACtC,CACe,CAAC;AAEvB,CAAC;AAED,MAAMK,MAAM,GAAGO,uBAAU,CAACC,MAAM,CAAC;EAC/BP,sBAAsB,EAAE;IACtBQ,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,gBAEY,IAAAC,WAAI,EAAChC,gBAAgB,CAAC;AAAAiC,OAAA,CAAArD,OAAA,GAAAmD,QAAA"}
|
|
@@ -30,6 +30,7 @@ const DropdownSectionList = _ref => {
|
|
|
30
30
|
checkboxLabelStyle,
|
|
31
31
|
checkboxComponentStyles,
|
|
32
32
|
checkboxComponent,
|
|
33
|
+
checkboxControls,
|
|
33
34
|
listComponentStyles,
|
|
34
35
|
listIndex,
|
|
35
36
|
emptyListMessage,
|
|
@@ -68,7 +69,7 @@ const DropdownSectionList = _ref => {
|
|
|
68
69
|
const sectionlistRef = (0, _react.useRef)(null);
|
|
69
70
|
const scrollToLocation = listIndex => {
|
|
70
71
|
var _sectionlistRef$curre;
|
|
71
|
-
(_sectionlistRef$curre = sectionlistRef.current) === null || _sectionlistRef$curre === void 0 ? void 0 : _sectionlistRef$curre.scrollToLocation({
|
|
72
|
+
sectionlistRef === null || sectionlistRef === void 0 || (_sectionlistRef$curre = sectionlistRef.current) === null || _sectionlistRef$curre === void 0 ? void 0 : _sectionlistRef$curre.scrollToLocation({
|
|
72
73
|
sectionIndex: listIndex.sectionIndex,
|
|
73
74
|
animated: true,
|
|
74
75
|
itemIndex: listIndex.itemIndex
|
|
@@ -107,7 +108,10 @@ const DropdownSectionList = _ref => {
|
|
|
107
108
|
checkboxLabelStyle,
|
|
108
109
|
// kept for backwards compatibility
|
|
109
110
|
checkboxComponentStyles,
|
|
111
|
+
// kept for backwards compatibility
|
|
110
112
|
checkboxComponent,
|
|
113
|
+
// kept for backwards compatibility
|
|
114
|
+
checkboxControls,
|
|
111
115
|
expandedSections
|
|
112
116
|
}),
|
|
113
117
|
renderSectionHeader: _ref2 => {
|
|
@@ -156,7 +160,8 @@ const _renderItem = (_ref3, props) => {
|
|
|
156
160
|
checkboxStyle: props.checkboxStyle,
|
|
157
161
|
checkboxLabelStyle: props.checkboxLabelStyle,
|
|
158
162
|
checkboxComponentStyles: props.checkboxComponentStyles,
|
|
159
|
-
checkboxComponent: props.checkboxComponent
|
|
163
|
+
checkboxComponent: props.checkboxComponent,
|
|
164
|
+
checkboxControls: props.checkboxControls
|
|
160
165
|
});
|
|
161
166
|
};
|
|
162
167
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_DropdownListItem","_interopRequireDefault","_Others","_utils","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownSectionList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","listComponentStyles","listIndex","emptyListMessage","rest","expandedSections","setExpandedSections","useState","Set","useEffect","initialState","extractPropertyFromArray","handleToggleListExpansion","title","expandedSectionsState","next","delete","add","sectionlistRef","useRef","scrollToLocation","_sectionlistRef$curre","current","sectionIndex","animated","itemIndex","createElement","SectionList","sections","extraData","initialNumToRender","ListEmptyComponent","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","ItemSeparatorComponent","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","renderSectionHeader","_ref2","section","SectionHeaderTitle","sectionHeaderStyle","onPress","isExpanded","keyExtractor","_item","index","stickySectionHeadersEnabled","ref","onScrollToIndexFailed","setTimeout","_ref3","props","StyleSheet","create","_default","exports"],"sources":["DropdownSectionList.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React, { useEffect, useState, useRef } from 'react';\nimport { SectionList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport {\n ItemSeparatorComponent,\n ListEmptyComponent,\n SectionHeaderTitle,\n} from '../Others';\nimport { extractPropertyFromArray } from '../../utils';\nimport { TSectionList } from 'src/types/index.types';\n\nconst DropdownSectionList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n listComponentStyles,\n listIndex,\n emptyListMessage,\n ...rest\n}: any) => {\n const [expandedSections, setExpandedSections] = useState(new Set());\n\n /**\n * Expand all sections\n */\n useEffect(() => {\n let initialState = new Set(extractPropertyFromArray(options, 'title'));\n setExpandedSections(initialState);\n }, [options]);\n\n /**\n * @param title\n */\n const handleToggleListExpansion = (title: string) => {\n setExpandedSections((expandedSectionsState) => {\n // Using Set here but you can use an array too\n const next = new Set(expandedSectionsState);\n if (next.has(title)) {\n next.delete(title);\n } else {\n next.add(title);\n }\n return next;\n });\n };\n\n /**\n * @description Scroll to item location\n */\n\n const sectionlistRef = useRef<SectionList<TSectionList>>(null);\n\n const scrollToLocation = (listIndex: any) => {\n sectionlistRef.current?.scrollToLocation({\n sectionIndex: listIndex.sectionIndex,\n animated: true,\n itemIndex: listIndex.itemIndex,\n });\n };\n\n useEffect(() => {\n if (listIndex.itemIndex >= 0 && listIndex.sectionIndex >= 0) {\n scrollToLocation(listIndex);\n }\n }, [listIndex]);\n\n return (\n <SectionList\n sections={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <ListEmptyComponent\n listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}\n emptyListMessage={emptyListMessage}\n />\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => (\n <ItemSeparatorComponent\n itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}\n />\n )}\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 primaryColor,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles,\n checkboxComponent,\n expandedSections,\n })\n }\n renderSectionHeader={({ section: { title } }) => (\n <SectionHeaderTitle\n title={title}\n sectionHeaderStyle={listComponentStyles?.sectionHeaderStyle}\n onPress={() => handleToggleListExpansion(title)}\n isExpanded={expandedSections.has(title)}\n />\n )}\n keyExtractor={(_item, index) => `Options${index}`}\n stickySectionHeadersEnabled={false}\n ref={sectionlistRef}\n onScrollToIndexFailed={() => {\n setTimeout(() => {\n scrollToLocation(listIndex);\n }, 500);\n }}\n {...rest}\n />\n );\n};\n\nconst _renderItem = ({ section: { title }, item }: any, props: any) => {\n const isExpanded = props?.expandedSections.has(title);\n\n //return null if it is not expanded\n if (!isExpanded) return null;\n\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 primaryColor={props.primaryColor}\n checkboxSize={props.checkboxSize}\n checkboxStyle={props.checkboxStyle}\n checkboxLabelStyle={props.checkboxLabelStyle}\n checkboxComponentStyles={props.checkboxComponentStyles}\n checkboxComponent={props.checkboxComponent}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownSectionList;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAuD,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAX,wBAAAO,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAA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C,WAAW,EAAEsE,KAAK,CAACtE,WAAY;IAC/BC,UAAU,EAAEqE,KAAK,CAACrE,UAAW;IAC7BoD,cAAc,EAAEiB,KAAK,CAACjB,cAAe;IACrCC,QAAQ,EAAEgB,KAAK,CAAChB,QAAS;IACzB/C,YAAY,EAAE+D,KAAK,CAAC/D,YAAa;IACjCC,YAAY,EAAE8D,KAAK,CAAC9D,YAAa;IACjCC,aAAa,EAAE6D,KAAK,CAAC7D,aAAc;IACnCC,kBAAkB,EAAE4D,KAAK,CAAC5D,kBAAmB;IAC7CC,uBAAuB,EAAE2D,KAAK,CAAC3D,uBAAwB;IACvDC,iBAAiB,EAAE0D,KAAK,CAAC1D;EAAkB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMmC,MAAM,GAAGwB,uBAAU,CAACC,MAAM,CAAC;EAC/B3B,qBAAqB,EAAE;IAAEC,UAAU,EAAE;EAAG;AAC1C,CAAC,CAAC;AAAC,IAAA2B,QAAA,GAEY7E,mBAAmB;AAAA8E,OAAA,CAAA3G,OAAA,GAAA0G,QAAA"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_DropdownListItem","_interopRequireDefault","_Others","_utils","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","DropdownSectionList","_ref","options","optionLabel","optionValue","isMultiple","isSearchable","selectedItems","selectedItem","handleMultipleSelections","handleSingleSelection","primaryColor","checkboxSize","checkboxStyle","checkboxLabelStyle","checkboxComponentStyles","checkboxComponent","checkboxControls","listComponentStyles","listIndex","emptyListMessage","rest","expandedSections","setExpandedSections","useState","Set","useEffect","initialState","extractPropertyFromArray","handleToggleListExpansion","title","expandedSectionsState","next","delete","add","sectionlistRef","useRef","scrollToLocation","_sectionlistRef$curre","current","sectionIndex","animated","itemIndex","createElement","SectionList","sections","extraData","initialNumToRender","ListEmptyComponent","listEmptyComponentStyle","contentContainerStyle","paddingTop","styles","ItemSeparatorComponent","itemSeparatorStyle","renderItem","item","_renderItem","selectedOption","onChange","renderSectionHeader","_ref2","section","SectionHeaderTitle","sectionHeaderStyle","onPress","isExpanded","keyExtractor","_item","index","stickySectionHeadersEnabled","ref","onScrollToIndexFailed","setTimeout","_ref3","props","StyleSheet","create","_default","exports"],"sources":["DropdownSectionList.tsx"],"sourcesContent":["/* eslint-disable react-native/no-inline-styles */\nimport React, { useEffect, useState, useRef } from 'react';\nimport { SectionList, StyleSheet } from 'react-native';\nimport DropdownListItem from './DropdownListItem';\nimport {\n ItemSeparatorComponent,\n ListEmptyComponent,\n SectionHeaderTitle,\n} from '../Others';\nimport { extractPropertyFromArray } from '../../utils';\nimport { TSectionList } from 'src/types/index.types';\n\nconst DropdownSectionList = ({\n options,\n optionLabel,\n optionValue,\n isMultiple,\n isSearchable,\n selectedItems,\n selectedItem,\n handleMultipleSelections,\n handleSingleSelection,\n primaryColor,\n checkboxSize,\n checkboxStyle,\n checkboxLabelStyle,\n checkboxComponentStyles,\n checkboxComponent,\n checkboxControls,\n listComponentStyles,\n listIndex,\n emptyListMessage,\n ...rest\n}: any) => {\n const [expandedSections, setExpandedSections] = useState(new Set());\n\n /**\n * Expand all sections\n */\n useEffect(() => {\n let initialState = new Set(extractPropertyFromArray(options, 'title'));\n setExpandedSections(initialState);\n }, [options]);\n\n /**\n * @param title\n */\n const handleToggleListExpansion = (title: string) => {\n setExpandedSections((expandedSectionsState) => {\n // Using Set here but you can use an array too\n const next = new Set(expandedSectionsState);\n if (next.has(title)) {\n next.delete(title);\n } else {\n next.add(title);\n }\n return next;\n });\n };\n\n /**\n * @description Scroll to item location\n */\n\n const sectionlistRef = useRef<SectionList<TSectionList>>(null);\n\n const scrollToLocation = (listIndex: any) => {\n sectionlistRef?.current?.scrollToLocation({\n sectionIndex: listIndex.sectionIndex,\n animated: true,\n itemIndex: listIndex.itemIndex,\n });\n };\n\n useEffect(() => {\n if (listIndex.itemIndex >= 0 && listIndex.sectionIndex >= 0) {\n scrollToLocation(listIndex);\n }\n }, [listIndex]);\n\n return (\n <SectionList\n sections={options}\n extraData={isMultiple ? selectedItems : selectedItem}\n initialNumToRender={5}\n ListEmptyComponent={\n <ListEmptyComponent\n listEmptyComponentStyle={listComponentStyles?.listEmptyComponentStyle}\n emptyListMessage={emptyListMessage}\n />\n }\n contentContainerStyle={[\n isSearchable ? { paddingTop: 0 } : styles.contentContainerStyle,\n ]}\n ItemSeparatorComponent={() => (\n <ItemSeparatorComponent\n itemSeparatorStyle={listComponentStyles?.itemSeparatorStyle}\n />\n )}\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 primaryColor,\n checkboxSize, // kept for backwards compatibility\n checkboxStyle, // kept for backwards compatibility\n checkboxLabelStyle, // kept for backwards compatibility\n checkboxComponentStyles, // kept for backwards compatibility\n checkboxComponent, // kept for backwards compatibility\n checkboxControls,\n expandedSections,\n })\n }\n renderSectionHeader={({ section: { title } }) => (\n <SectionHeaderTitle\n title={title}\n sectionHeaderStyle={listComponentStyles?.sectionHeaderStyle}\n onPress={() => handleToggleListExpansion(title)}\n isExpanded={expandedSections.has(title)}\n />\n )}\n keyExtractor={(_item, index) => `Options${index}`}\n stickySectionHeadersEnabled={false}\n ref={sectionlistRef}\n onScrollToIndexFailed={() => {\n setTimeout(() => {\n scrollToLocation(listIndex);\n }, 500);\n }}\n {...rest}\n />\n );\n};\n\nconst _renderItem = ({ section: { title }, item }: any, props: any) => {\n const isExpanded = props?.expandedSections.has(title);\n\n //return null if it is not expanded\n if (!isExpanded) return null;\n\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 primaryColor={props.primaryColor}\n checkboxSize={props.checkboxSize}\n checkboxStyle={props.checkboxStyle}\n checkboxLabelStyle={props.checkboxLabelStyle}\n checkboxComponentStyles={props.checkboxComponentStyles}\n checkboxComponent={props.checkboxComponent}\n checkboxControls={props.checkboxControls}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n contentContainerStyle: { paddingTop: 20 },\n});\n\nexport default DropdownSectionList;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAuD,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAX,wBAAAO,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAhB,GAAA,QAAAgB,GAAA,kBAAAH,MAA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