react-native-input-select 2.0.0 → 2.1.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 +2 -59
- package/lib/commonjs/components/CheckBox/index.js +16 -12
- package/lib/commonjs/components/CheckBox/index.js.map +1 -1
- package/lib/commonjs/components/CustomModal/index.js +3 -9
- package/lib/commonjs/components/CustomModal/index.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownListItem.js +1 -10
- package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +1 -1
- package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/commonjs/components/List/DropdownFlatList.js +0 -23
- package/lib/commonjs/components/List/DropdownFlatList.js.map +1 -1
- package/lib/commonjs/components/List/DropdownSectionList.js +0 -20
- package/lib/commonjs/components/List/DropdownSectionList.js.map +1 -1
- package/lib/commonjs/hooks/use-modal.js +0 -3
- package/lib/commonjs/hooks/use-modal.js.map +1 -1
- package/lib/commonjs/hooks/use-search.js +1 -1
- package/lib/commonjs/hooks/use-search.js.map +1 -1
- package/lib/commonjs/index.js +4 -38
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/index.js +1 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/CheckBox/index.js +16 -12
- package/lib/module/components/CheckBox/index.js.map +1 -1
- package/lib/module/components/CustomModal/index.js +3 -9
- package/lib/module/components/CustomModal/index.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownListItem.js +1 -10
- package/lib/module/components/Dropdown/DropdownListItem.js.map +1 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +1 -1
- package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
- package/lib/module/components/List/DropdownFlatList.js +0 -23
- package/lib/module/components/List/DropdownFlatList.js.map +1 -1
- package/lib/module/components/List/DropdownSectionList.js +0 -20
- package/lib/module/components/List/DropdownSectionList.js.map +1 -1
- package/lib/module/hooks/use-modal.js +0 -3
- package/lib/module/hooks/use-modal.js.map +1 -1
- package/lib/module/hooks/use-search.js +1 -1
- package/lib/module/hooks/use-search.js.map +1 -1
- package/lib/module/index.js +4 -38
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/components/CheckBox/checkbox.types.d.ts +2 -2
- package/lib/typescript/src/components/CheckBox/checkbox.types.d.ts.map +1 -1
- package/lib/typescript/src/components/CheckBox/index.d.ts +1 -1
- package/lib/typescript/src/components/CheckBox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/CustomModal/index.d.ts +2 -2
- package/lib/typescript/src/components/CustomModal/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Dropdown/DropdownListItem.d.ts +1 -1
- package/lib/typescript/src/components/Dropdown/DropdownListItem.d.ts.map +1 -1
- package/lib/typescript/src/components/List/DropdownFlatList.d.ts +1 -1
- package/lib/typescript/src/components/List/DropdownFlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/List/DropdownSectionList.d.ts +1 -1
- package/lib/typescript/src/components/List/DropdownSectionList.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-modal.d.ts +1 -3
- package/lib/typescript/src/hooks/use-modal.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.types.d.ts +3 -39
- package/lib/typescript/src/types/index.types.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/CheckBox/checkbox.types.ts +2 -2
- package/src/components/CheckBox/index.tsx +20 -46
- package/src/components/CustomModal/index.tsx +4 -9
- package/src/components/Dropdown/DropdownListItem.tsx +0 -11
- package/src/components/Dropdown/DropdownSelectedItemsView.tsx +1 -1
- package/src/components/List/DropdownFlatList.tsx +0 -15
- package/src/components/List/DropdownSectionList.tsx +0 -15
- package/src/hooks/use-modal.ts +1 -5
- package/src/hooks/use-search.ts +2 -2
- package/src/index.tsx +3 -26
- package/src/types/index.types.ts +4 -46
- package/src/utils/index.ts +1 -1
package/src/hooks/use-modal.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
3
|
import { TCustomModalControls } from '../types/index.types';
|
|
4
4
|
|
|
5
5
|
interface UseModalProps {
|
|
6
6
|
resetOptionsRelatedState: () => void;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
-
modalProps?: ModalProps;
|
|
9
8
|
modalControls?: TCustomModalControls;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export const useModal = ({
|
|
13
12
|
resetOptionsRelatedState,
|
|
14
13
|
disabled,
|
|
15
|
-
modalProps,
|
|
16
14
|
modalControls,
|
|
17
15
|
}: UseModalProps) => {
|
|
18
16
|
const [isVisible, setIsVisible] = useState(false);
|
|
@@ -30,8 +28,6 @@ export const useModal = ({
|
|
|
30
28
|
// iOS supports the onDismiss prop but android does not, so we do this explicitly here
|
|
31
29
|
// https://reactnative.dev/docs/modal#ondismiss-ios
|
|
32
30
|
if (Platform.OS === 'android') {
|
|
33
|
-
modalControls?.modalProps?.closeModal?.(); //kept for backwards compatibility
|
|
34
|
-
modalProps?.onDismiss?.(); //kept for backwards compatibility
|
|
35
31
|
modalControls?.modalProps?.onDismiss?.();
|
|
36
32
|
}
|
|
37
33
|
};
|
package/src/hooks/use-search.ts
CHANGED
|
@@ -34,9 +34,9 @@ export const useSearch = ({
|
|
|
34
34
|
(flatList: TFlatList, regexFilter: RegExp) => {
|
|
35
35
|
return flatList.filter((item: TFlatListItem) => {
|
|
36
36
|
return (
|
|
37
|
-
item[optionLabel]
|
|
37
|
+
item[optionLabel]?.toString().toLowerCase().search(regexFilter) !==
|
|
38
38
|
-1 ||
|
|
39
|
-
item[optionValue]
|
|
39
|
+
item[optionValue]?.toString().toLowerCase().search(regexFilter) !== -1
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
},
|
package/src/index.tsx
CHANGED
|
@@ -53,21 +53,12 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
53
53
|
dropdownHelperTextStyle,
|
|
54
54
|
selectedItemStyle,
|
|
55
55
|
multipleSelectedItemStyle,
|
|
56
|
-
modalBackgroundStyle, // kept for backwards compatibility
|
|
57
|
-
modalOptionsContainerStyle, // kept for backwards compatibility
|
|
58
|
-
searchInputStyle, // kept for backwards compatibility
|
|
59
56
|
primaryColor = colors.gray,
|
|
60
57
|
disabled = false,
|
|
61
|
-
checkboxSize, // kept for backwards compatibility
|
|
62
|
-
checkboxStyle, // kept for backwards compatibility
|
|
63
|
-
checkboxLabelStyle, // kept for backwards compatibility
|
|
64
|
-
checkboxComponentStyles, // kept for backwards compatibility
|
|
65
|
-
checkboxComponent, // kept for backwards compatibility
|
|
66
58
|
listHeaderComponent,
|
|
67
59
|
listFooterComponent,
|
|
68
60
|
listComponentStyles,
|
|
69
61
|
listEmptyComponent,
|
|
70
|
-
modalProps, // kept for backwards compatibility
|
|
71
62
|
listControls,
|
|
72
63
|
searchControls,
|
|
73
64
|
modalControls,
|
|
@@ -131,7 +122,6 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
131
122
|
const { isVisible, openModal, closeModal } = useModal({
|
|
132
123
|
resetOptionsRelatedState,
|
|
133
124
|
disabled,
|
|
134
|
-
modalProps,
|
|
135
125
|
modalControls,
|
|
136
126
|
});
|
|
137
127
|
|
|
@@ -156,8 +146,8 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
156
146
|
|
|
157
147
|
useEffect(() => {
|
|
158
148
|
isMultiple
|
|
159
|
-
? setSelectedItems(
|
|
160
|
-
: setSelectedItem(
|
|
149
|
+
? setSelectedItems(selectedValue as TSelectedItem[])
|
|
150
|
+
: setSelectedItem(selectedValue as TSelectedItem);
|
|
161
151
|
|
|
162
152
|
return () => {};
|
|
163
153
|
}, [
|
|
@@ -240,10 +230,7 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
240
230
|
<CustomModal
|
|
241
231
|
visible={isVisible}
|
|
242
232
|
onRequestClose={() => closeModal()}
|
|
243
|
-
modalBackgroundStyle={modalBackgroundStyle} // kept for backwards compatibility
|
|
244
|
-
modalOptionsContainerStyle={modalOptionsContainerStyle} // kept for backwards compatibility
|
|
245
233
|
modalControls={modalControls}
|
|
246
|
-
modalProps={modalProps} // kept for backwards compatibility
|
|
247
234
|
>
|
|
248
235
|
<ListTypeComponent
|
|
249
236
|
ListHeaderComponent={
|
|
@@ -252,7 +239,7 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
252
239
|
<Input
|
|
253
240
|
value={searchValue}
|
|
254
241
|
onChangeText={(text: string) => setSearchValue(text)}
|
|
255
|
-
style={searchControls?.textInputStyle
|
|
242
|
+
style={searchControls?.textInputStyle}
|
|
256
243
|
primaryColor={primaryColor}
|
|
257
244
|
textInputContainerStyle={
|
|
258
245
|
searchControls?.textInputContainerStyle
|
|
@@ -282,11 +269,6 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
282
269
|
onChange={() => handleSelectAll()}
|
|
283
270
|
primaryColor={primaryColor}
|
|
284
271
|
checkboxControls={checkboxControls}
|
|
285
|
-
checkboxSize={checkboxSize}
|
|
286
|
-
checkboxStyle={checkboxStyle}
|
|
287
|
-
checkboxLabelStyle={checkboxLabelStyle}
|
|
288
|
-
checkboxComponentStyles={checkboxComponentStyles}
|
|
289
|
-
checkboxComponent={checkboxComponent}
|
|
290
272
|
/>
|
|
291
273
|
</TouchableOpacity>
|
|
292
274
|
</View>
|
|
@@ -305,11 +287,6 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
|
|
|
305
287
|
handleMultipleSelections={handleMultipleSelections}
|
|
306
288
|
handleSingleSelection={handleSingleSelection}
|
|
307
289
|
primaryColor={primaryColor}
|
|
308
|
-
checkboxSize={checkboxSize}
|
|
309
|
-
checkboxStyle={checkboxStyle}
|
|
310
|
-
checkboxLabelStyle={checkboxLabelStyle}
|
|
311
|
-
checkboxComponentStyles={checkboxComponentStyles}
|
|
312
|
-
checkboxComponent={checkboxComponent}
|
|
313
290
|
checkboxControls={checkboxControls}
|
|
314
291
|
listIndex={listIndex}
|
|
315
292
|
listEmptyComponent={listEmptyComponent}
|
package/src/types/index.types.ts
CHANGED
|
@@ -9,11 +9,8 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
export type DropdownProps = CommonDropdownProps &
|
|
11
11
|
TDropdownInputProps &
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
TCustomModalProps &
|
|
15
|
-
TListProps &
|
|
16
|
-
TControls;
|
|
12
|
+
TControls &
|
|
13
|
+
TListProps;
|
|
17
14
|
|
|
18
15
|
export type CommonDropdownProps = {
|
|
19
16
|
testID?: string;
|
|
@@ -46,8 +43,6 @@ export type TDropdownInputProps = {
|
|
|
46
43
|
primaryColor?: ColorValue;
|
|
47
44
|
disabled?: boolean;
|
|
48
45
|
placeholderStyle?: TextStyle;
|
|
49
|
-
/** @deprecated Use useRef to access the open and close props.*/
|
|
50
|
-
hideModal?: boolean;
|
|
51
46
|
};
|
|
52
47
|
|
|
53
48
|
type TControls = {
|
|
@@ -57,11 +52,6 @@ type TControls = {
|
|
|
57
52
|
listControls?: TListControls;
|
|
58
53
|
};
|
|
59
54
|
|
|
60
|
-
export type TSearchProps = {
|
|
61
|
-
/** @deprecated Use `searchControls = {{textInputStyle: ViewStyle | TextStyle }}` instead.*/
|
|
62
|
-
searchInputStyle?: ViewStyle;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
55
|
type TSearchControls = {
|
|
66
56
|
textInputStyle?: ViewStyle | TextStyle;
|
|
67
57
|
textInputContainerStyle?: ViewStyle;
|
|
@@ -69,23 +59,6 @@ type TSearchControls = {
|
|
|
69
59
|
searchCallback?: (value: string) => void;
|
|
70
60
|
};
|
|
71
61
|
|
|
72
|
-
export type TCheckboxProps = {
|
|
73
|
-
/** @deprecated Use `checkboxControls = {{checkboxSize: number }}` instead.*/
|
|
74
|
-
checkboxSize?: number;
|
|
75
|
-
/** @deprecated Use `checkboxControls = {{checkboxStyle: ViewStyle }}` instead.*/
|
|
76
|
-
checkboxStyle?: ViewStyle;
|
|
77
|
-
/** @deprecated Use `checkboxControls = {{checkboxLabelStyle: TextStyle }}` instead.*/
|
|
78
|
-
checkboxLabelStyle?: TextStyle;
|
|
79
|
-
/** @deprecated Use `checkboxControls` instead.*/
|
|
80
|
-
checkboxComponentStyles?: {
|
|
81
|
-
checkboxSize?: number;
|
|
82
|
-
checkboxStyle?: ViewStyle;
|
|
83
|
-
checkboxLabelStyle?: TextStyle;
|
|
84
|
-
};
|
|
85
|
-
/** @deprecated Use `checkboxControls = {{checkboxComponent: <View></View> }}` instead.*/
|
|
86
|
-
checkboxComponent?: React.ReactNode;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
62
|
export type TCheckboxControls = {
|
|
90
63
|
checkboxSize?: number;
|
|
91
64
|
checkboxStyle?: ViewStyle;
|
|
@@ -95,25 +68,10 @@ export type TCheckboxControls = {
|
|
|
95
68
|
checkboxUnselectedColor?: ColorValue;
|
|
96
69
|
};
|
|
97
70
|
|
|
98
|
-
export type TCustomModalProps = {
|
|
99
|
-
/** @deprecated Use `modalControls = {{modalBackgroundStyle: ViewStyle}} instead.*/
|
|
100
|
-
modalBackgroundStyle?: ViewStyle;
|
|
101
|
-
/** @deprecated Use `modalControls = {{ modalOptionsContainerStyle: ViewStyle}} instead.*/
|
|
102
|
-
modalOptionsContainerStyle?: ViewStyle;
|
|
103
|
-
/** @deprecated Use `modalControls = {{modalProps: ModalProps }}` instead.*/
|
|
104
|
-
modalProps?: ModalProps & {
|
|
105
|
-
/** @deprecated Use `onDismiss` instead.*/
|
|
106
|
-
closeModal?: () => void;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
|
|
110
71
|
export type TCustomModalControls = {
|
|
111
72
|
modalBackgroundStyle?: ViewStyle;
|
|
112
73
|
modalOptionsContainerStyle?: ViewStyle;
|
|
113
|
-
modalProps?: ModalProps
|
|
114
|
-
/** @deprecated Use `onDismiss` instead.*/
|
|
115
|
-
closeModal?: () => void;
|
|
116
|
-
};
|
|
74
|
+
modalProps?: ModalProps;
|
|
117
75
|
};
|
|
118
76
|
|
|
119
77
|
export type TListProps = {
|
|
@@ -136,7 +94,7 @@ type TListControls = {
|
|
|
136
94
|
emptyListMessage?: string;
|
|
137
95
|
};
|
|
138
96
|
|
|
139
|
-
export type TSelectedItem = string | number | boolean;
|
|
97
|
+
export type TSelectedItem = string | number | boolean | undefined;
|
|
140
98
|
export type TSelectedItemWithReactComponent =
|
|
141
99
|
| TSelectedItem
|
|
142
100
|
| React.ReactElement;
|
package/src/utils/index.ts
CHANGED