react-native-input-select 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +56 -41
  2. package/lib/commonjs/components/CheckBox/index.js +3 -2
  3. package/lib/commonjs/components/CheckBox/index.js.map +1 -1
  4. package/lib/commonjs/components/CheckBox/types.js.map +1 -1
  5. package/lib/commonjs/components/Dropdown/DropdownFlatList.js +5 -2
  6. package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
  7. package/lib/commonjs/components/Dropdown/DropdownListItem.js +4 -2
  8. package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
  9. package/lib/commonjs/components/Dropdown/DropdownSectionList.js +4 -1
  10. package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
  11. package/lib/commonjs/index.js +12 -2
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/types/index.types.js.map +1 -1
  14. package/lib/module/components/CheckBox/index.js +3 -2
  15. package/lib/module/components/CheckBox/index.js.map +1 -1
  16. package/lib/module/components/CheckBox/types.js.map +1 -1
  17. package/lib/module/components/Dropdown/DropdownFlatList.js +5 -2
  18. package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
  19. package/lib/module/components/Dropdown/DropdownListItem.js +4 -2
  20. package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
  21. package/lib/module/components/Dropdown/DropdownSectionList.js +4 -1
  22. package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
  23. package/lib/module/index.js +12 -2
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/types/index.types.js.map +1 -1
  26. package/lib/typescript/components/CheckBox/index.d.ts +1 -1
  27. package/lib/typescript/components/CheckBox/types.d.ts +2 -0
  28. package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts +1 -1
  29. package/lib/typescript/components/Dropdown/DropdownListItem.d.ts +1 -1
  30. package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts +1 -1
  31. package/lib/typescript/types/index.types.d.ts +7 -0
  32. package/package.json +2 -2
  33. package/src/components/CheckBox/index.tsx +25 -16
  34. package/src/components/CheckBox/types.ts +2 -0
  35. package/src/components/Dropdown/DropdownFlatList.tsx +3 -0
  36. package/src/components/Dropdown/DropdownListItem.tsx +2 -0
  37. package/src/components/Dropdown/DropdownSectionList.tsx +3 -0
  38. package/src/index.tsx +23 -1
  39. package/src/types/index.types.ts +8 -1
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.types.ts"],"sourcesContent":["import type {\n ViewStyle,\n ColorValue,\n TextStyle,\n ModalProps,\n} from 'react-native';\n\nexport type DropdownProps = {\n placeholder?: string;\n label?: string;\n error?: string;\n helperText?: string;\n options: TFlatList | TSectionList;\n optionLabel?: string;\n optionValue?: string;\n onValueChange: Function;\n selectedValue?:\n | string\n | boolean\n | number\n | string[]\n | boolean[]\n | number[]\n | null;\n isMultiple?: boolean;\n isSearchable?: boolean;\n dropdownIcon?: React.ReactNode;\n labelStyle?: TextStyle;\n dropdownStyle?: ViewStyle;\n dropdownIconStyle?: ViewStyle;\n dropdownContainerStyle?: ViewStyle;\n dropdownErrorStyle?: ViewStyle;\n dropdownErrorTextStyle?: TextStyle;\n dropdownHelperTextStyle?: TextStyle;\n selectedItemStyle?: TextStyle;\n multipleSelectedItemStyle?: TextStyle;\n modalBackgroundStyle?: ViewStyle;\n modalOptionsContainerStyle?: ViewStyle;\n searchInputStyle?: ViewStyle;\n primaryColor?: ColorValue;\n disabled?: boolean;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n placeholderStyle?: TextStyle;\n listHeaderComponent?: React.ReactNode;\n listFooterComponent?: React.ReactNode;\n hideModal?: boolean;\n modalProps?: ModalProps;\n listComponentStyles?: {\n listEmptyComponentStyle?: TextStyle;\n itemSeparatorStyle?: ViewStyle;\n sectionHeaderStyle?: TextStyle;\n };\n};\n\nexport type TFlatList = TFlatListItem[];\nexport type TFlatListItem = {\n [key: string]: string | number | boolean;\n}\n\nexport type TSectionList = TSectionListItem[];\nexport type TSectionListItem = { title: string; data: TFlatList };\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["index.types.ts"],"sourcesContent":["import type {\n ViewStyle,\n ColorValue,\n TextStyle,\n ModalProps,\n} from 'react-native';\n\nexport type DropdownProps = {\n placeholder?: string;\n label?: string;\n error?: string;\n helperText?: string;\n options: TFlatList | TSectionList;\n optionLabel?: string;\n optionValue?: string;\n onValueChange: Function;\n selectedValue?:\n | string\n | boolean\n | number\n | string[]\n | boolean[]\n | number[]\n | null;\n isMultiple?: boolean;\n isSearchable?: boolean;\n dropdownIcon?: React.ReactNode;\n labelStyle?: TextStyle;\n dropdownStyle?: ViewStyle;\n dropdownIconStyle?: ViewStyle;\n dropdownContainerStyle?: ViewStyle;\n dropdownErrorStyle?: ViewStyle;\n dropdownErrorTextStyle?: TextStyle;\n dropdownHelperTextStyle?: TextStyle;\n selectedItemStyle?: TextStyle;\n multipleSelectedItemStyle?: TextStyle;\n modalBackgroundStyle?: ViewStyle;\n modalOptionsContainerStyle?: ViewStyle;\n searchInputStyle?: ViewStyle;\n primaryColor?: ColorValue;\n disabled?: boolean;\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n checkboxComponentStyles?: {\n checkboxSize?: number;\n checkboxStyle?: ViewStyle;\n checkboxLabelStyle?: TextStyle;\n };\n checkboxComponent?: React.ReactNode;\n placeholderStyle?: TextStyle;\n listHeaderComponent?: React.ReactNode;\n listFooterComponent?: React.ReactNode;\n hideModal?: boolean;\n modalProps?: ModalProps;\n listComponentStyles?: {\n listEmptyComponentStyle?: TextStyle;\n itemSeparatorStyle?: ViewStyle;\n sectionHeaderStyle?: TextStyle;\n };\n selectAllControls?: {\n selectAllText?: string;\n unselectAllText?: string;\n selectAllCallback?: () => void;\n unselectAllCallback?: () => void;\n };\n};\n\nexport type TFlatList = TFlatListItem[];\nexport type TFlatListItem = {\n [key: string]: string | number | boolean;\n};\n\nexport type TSectionList = TSectionListItem[];\nexport type TSectionListItem = { title: string; data: TFlatList };\n"],"mappings":""}
@@ -17,5 +17,5 @@ const checkboxComponentStyles = {
17
17
  };
18
18
  ```
19
19
  */
20
- declare const CheckBox: ({ label, value, disabled, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, onChange, }: CheckboxProps) => JSX.Element;
20
+ declare const CheckBox: ({ label, value, disabled, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, checkboxComponent, onChange, }: CheckboxProps) => JSX.Element;
21
21
  export default CheckBox;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { ColorValue, ViewStyle, TextStyle } from 'react-native';
2
3
  export type CheckboxProps = {
3
4
  label?: string;
@@ -12,5 +13,6 @@ export type CheckboxProps = {
12
13
  checkboxStyle?: ViewStyle;
13
14
  checkboxLabelStyle?: TextStyle;
14
15
  };
16
+ checkboxComponent?: React.ReactNode;
15
17
  onChange?: (value: boolean | string | number) => void;
16
18
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DropdownFlatList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
2
+ declare const DropdownFlatList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, checkboxComponent, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
3
3
  export default DropdownFlatList;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- declare const _default: React.MemoExoticComponent<({ item, optionLabel, optionValue, isMultiple, selectedOption, onChange, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, }: any) => JSX.Element>;
2
+ declare const _default: React.MemoExoticComponent<({ item, optionLabel, optionValue, isMultiple, selectedOption, onChange, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, checkboxComponent, }: any) => JSX.Element>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DropdownSectionList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
2
+ declare const DropdownSectionList: ({ options, optionLabel, optionValue, isMultiple, isSearchable, selectedItems, selectedItem, handleMultipleSelections, handleSingleSelection, primaryColor, checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponentStyles, checkboxComponent, listComponentStyles, listIndex, ...rest }: any) => JSX.Element;
3
3
  export default DropdownSectionList;
@@ -35,6 +35,7 @@ export type DropdownProps = {
35
35
  checkboxStyle?: ViewStyle;
36
36
  checkboxLabelStyle?: TextStyle;
37
37
  };
38
+ checkboxComponent?: React.ReactNode;
38
39
  placeholderStyle?: TextStyle;
39
40
  listHeaderComponent?: React.ReactNode;
40
41
  listFooterComponent?: React.ReactNode;
@@ -45,6 +46,12 @@ export type DropdownProps = {
45
46
  itemSeparatorStyle?: ViewStyle;
46
47
  sectionHeaderStyle?: TextStyle;
47
48
  };
49
+ selectAllControls?: {
50
+ selectAllText?: string;
51
+ unselectAllText?: string;
52
+ selectAllCallback?: () => void;
53
+ unselectAllCallback?: () => void;
54
+ };
48
55
  };
49
56
  export type TFlatList = TFlatListItem[];
50
57
  export type TFlatListItem = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-input-select",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
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",
@@ -26,7 +26,7 @@
26
26
  "typescript": "tsc --noEmit",
27
27
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
28
28
  "prepare": "bob build",
29
- "release": "release-it -- patch --ci",
29
+ "release": "release-it --ci",
30
30
  "example": "yarn --cwd example",
31
31
  "pods": "cd example && pod-install --quiet",
32
32
  "bootstrap": "yarn example && yarn && yarn pods",
@@ -31,6 +31,7 @@ const CheckBox = ({
31
31
  checkboxStyle,
32
32
  checkboxLabelStyle,
33
33
  checkboxComponentStyles,
34
+ checkboxComponent,
34
35
  onChange,
35
36
  }: CheckboxProps) => {
36
37
  // const { checkboxSize, checkboxStyle, checkboxLabelStyle } =
@@ -57,22 +58,30 @@ const CheckBox = ({
57
58
  style={[styles.checkboxContainer]}
58
59
  disabled={disabled}
59
60
  >
60
- <View style={[styles.checkbox, checkboxStyle, fillColor]}>
61
- <Image
62
- source={require('../../asset/check.png')}
63
- style={[
64
- {
65
- height:
66
- checkboxComponentStyles?.checkboxSize ||
67
- checkboxSize ||
68
- CHECKBOX_SIZE,
69
- width:
70
- checkboxComponentStyles?.checkboxSize ||
71
- checkboxSize ||
72
- CHECKBOX_SIZE,
73
- },
74
- ]}
75
- />
61
+ <View
62
+ style={[
63
+ styles.checkbox,
64
+ checkboxComponentStyles?.checkboxStyle || checkboxStyle,
65
+ fillColor,
66
+ ]}
67
+ >
68
+ {checkboxComponent || (
69
+ <Image
70
+ source={require('../../asset/check.png')}
71
+ style={[
72
+ {
73
+ height:
74
+ checkboxComponentStyles?.checkboxSize ||
75
+ checkboxSize ||
76
+ CHECKBOX_SIZE,
77
+ width:
78
+ checkboxComponentStyles?.checkboxSize ||
79
+ checkboxSize ||
80
+ CHECKBOX_SIZE,
81
+ },
82
+ ]}
83
+ />
84
+ )}
76
85
  </View>
77
86
  {label && (
78
87
  <Text
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { ColorValue, ViewStyle, TextStyle } from 'react-native';
2
3
 
3
4
  export type CheckboxProps = {
@@ -13,5 +14,6 @@ export type CheckboxProps = {
13
14
  checkboxStyle?: ViewStyle;
14
15
  checkboxLabelStyle?: TextStyle;
15
16
  };
17
+ checkboxComponent?: React.ReactNode;
16
18
  onChange?: (value: boolean | string | number) => void;
17
19
  };
@@ -20,6 +20,7 @@ const DropdownFlatList = ({
20
20
  checkboxStyle, // kept for backwards compatibility to be removed in future release
21
21
  checkboxLabelStyle, // kept for backwards compatibility to be removed in future release
22
22
  checkboxComponentStyles,
23
+ checkboxComponent,
23
24
  listComponentStyles,
24
25
  listIndex,
25
26
  ...rest
@@ -70,6 +71,7 @@ const DropdownFlatList = ({
70
71
  checkboxStyle, // kept for backwards compatibility
71
72
  checkboxLabelStyle, // kept for backwards compatibility
72
73
  checkboxComponentStyles,
74
+ checkboxComponent
73
75
  })
74
76
  }
75
77
  keyExtractor={(_item, index) => `Options${index}`}
@@ -99,6 +101,7 @@ const _renderItem = ({ item }: any, props: any) => {
99
101
  checkboxLabelStyle={props.checkboxLabelStyle}
100
102
  scrollToItem={props.scrollToItem}
101
103
  checkboxComponentStyles={props.checkboxComponentStyles}
104
+ checkboxComponent={props.checkboxComponent}
102
105
  />
103
106
  );
104
107
  };
@@ -14,6 +14,7 @@ const DropdownListItem = ({
14
14
  checkboxStyle,
15
15
  checkboxLabelStyle,
16
16
  checkboxComponentStyles,
17
+ checkboxComponent,
17
18
  }: any) => {
18
19
  return (
19
20
  <TouchableOpacity
@@ -37,6 +38,7 @@ const DropdownListItem = ({
37
38
  checkboxComponentStyles?.checkboxLabelStyle || checkboxLabelStyle
38
39
  }
39
40
  disabled={item.disabled}
41
+ checkboxComponent={checkboxComponent}
40
42
  />
41
43
  </TouchableOpacity>
42
44
  );
@@ -25,6 +25,7 @@ const DropdownSectionList = ({
25
25
  checkboxStyle,
26
26
  checkboxLabelStyle,
27
27
  checkboxComponentStyles,
28
+ checkboxComponent,
28
29
  listComponentStyles,
29
30
  listIndex,
30
31
  ...rest
@@ -105,6 +106,7 @@ const DropdownSectionList = ({
105
106
  checkboxStyle, // kept for backwards compatibility
106
107
  checkboxLabelStyle, // kept for backwards compatibility
107
108
  checkboxComponentStyles,
109
+ checkboxComponent,
108
110
  expandedSections,
109
111
  })
110
112
  }
@@ -150,6 +152,7 @@ const _renderItem = ({ section: { title }, item }: any, props: any) => {
150
152
  checkboxStyle={props.checkboxStyle}
151
153
  checkboxLabelStyle={props.checkboxLabelStyle}
152
154
  checkboxComponentStyles={props.checkboxComponentStyles}
155
+ checkboxComponent={props.checkboxComponent}
153
156
  />
154
157
  );
155
158
  };
package/src/index.tsx CHANGED
@@ -52,11 +52,13 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
52
52
  checkboxStyle, // kept for backwards compatibility
53
53
  checkboxLabelStyle, // kept for backwards compatibility
54
54
  checkboxComponentStyles,
55
+ checkboxComponent,
55
56
  listHeaderComponent,
56
57
  listFooterComponent,
57
58
  listComponentStyles,
58
59
  modalProps,
59
60
  hideModal = false,
61
+ selectAllControls,
60
62
  ...rest
61
63
  }) => {
62
64
  const [newOptions, setNewOptions] = useState<TFlatList | TSectionList>([]);
@@ -153,6 +155,20 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
153
155
  onValueChange(selectedValues); //send value to parent
154
156
  return !prevVal;
155
157
  });
158
+
159
+ if (
160
+ typeof selectAllControls?.selectAllCallback === 'function' &&
161
+ !selectAll
162
+ ) {
163
+ selectAllControls.selectAllCallback();
164
+ }
165
+
166
+ if (
167
+ typeof selectAllControls?.unselectAllCallback === 'function' &&
168
+ selectAll
169
+ ) {
170
+ selectAllControls.unselectAllCallback();
171
+ }
156
172
  };
157
173
 
158
174
  /*===========================================
@@ -355,13 +371,18 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
355
371
  <TouchableOpacity onPress={() => {}}>
356
372
  <CheckBox
357
373
  value={selectAll}
358
- label={selectAll ? 'Clear all' : 'Select all'}
374
+ label={
375
+ selectAll
376
+ ? selectAllControls?.unselectAllText || 'Clear all'
377
+ : selectAllControls?.selectAllText || 'Select all'
378
+ }
359
379
  onChange={() => handleSelectAll()}
360
380
  primaryColor={primary}
361
381
  checkboxSize={checkboxSize}
362
382
  checkboxStyle={checkboxStyle}
363
383
  checkboxLabelStyle={checkboxLabelStyle}
364
384
  checkboxComponentStyles={checkboxComponentStyles}
385
+ checkboxComponent={checkboxComponent}
365
386
  />
366
387
  </TouchableOpacity>
367
388
  </View>
@@ -384,6 +405,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
384
405
  checkboxStyle={checkboxStyle}
385
406
  checkboxLabelStyle={checkboxLabelStyle}
386
407
  checkboxComponentStyles={checkboxComponentStyles}
408
+ checkboxComponent={checkboxComponent}
387
409
  listIndex={listIndex}
388
410
  />
389
411
  </CustomModal>
@@ -47,6 +47,7 @@ export type DropdownProps = {
47
47
  checkboxStyle?: ViewStyle;
48
48
  checkboxLabelStyle?: TextStyle;
49
49
  };
50
+ checkboxComponent?: React.ReactNode;
50
51
  placeholderStyle?: TextStyle;
51
52
  listHeaderComponent?: React.ReactNode;
52
53
  listFooterComponent?: React.ReactNode;
@@ -57,12 +58,18 @@ export type DropdownProps = {
57
58
  itemSeparatorStyle?: ViewStyle;
58
59
  sectionHeaderStyle?: TextStyle;
59
60
  };
61
+ selectAllControls?: {
62
+ selectAllText?: string;
63
+ unselectAllText?: string;
64
+ selectAllCallback?: () => void;
65
+ unselectAllCallback?: () => void;
66
+ };
60
67
  };
61
68
 
62
69
  export type TFlatList = TFlatListItem[];
63
70
  export type TFlatListItem = {
64
71
  [key: string]: string | number | boolean;
65
- }
72
+ };
66
73
 
67
74
  export type TSectionList = TSectionListItem[];
68
75
  export type TSectionListItem = { title: string; data: TFlatList };