react-native-ui-lib 7.38.1-snapshot.6314 → 7.38.1-snapshot.6326
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/package.json +1 -1
- package/src/components/avatar/avatar.api.json +1 -1
- package/src/components/avatar/index.d.ts +20 -22
- package/src/components/avatar/index.js +1 -2
- package/src/components/badge/index.js +1 -10
- package/src/components/picker/PickerItemsList.js +11 -1
- package/src/components/picker/PickerSelectionControlBar.d.ts +7 -0
- package/src/components/picker/PickerSelectionControlBar.js +48 -0
- package/src/components/picker/helpers/usePickerSelection.d.ts +2 -0
- package/src/components/picker/helpers/usePickerSelection.js +6 -1
- package/src/components/picker/index.d.ts +3 -2
- package/src/components/picker/index.js +11 -6
- package/src/components/picker/types.d.ts +48 -1
- package/src/components/picker/types.js +6 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +7 -0
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"name": "animate",
|
|
14
14
|
"type": "boolean",
|
|
15
|
-
"description": "Adds fade in animation when Avatar image loads
|
|
15
|
+
"description": "Adds fade in animation when Avatar image loads",
|
|
16
16
|
"default": "false"
|
|
17
17
|
},
|
|
18
18
|
{"name": "backgroundColor", "type": "string", "description": "Background color for Avatar"},
|
|
@@ -162,30 +162,29 @@ declare const Avatar: React.ForwardRefExoticComponent<Pick<AccessibilityProps, "
|
|
|
162
162
|
* Image props object
|
|
163
163
|
*/
|
|
164
164
|
imageProps?: Partial<Omit<import("react-native").ImageProps, "source"> & Pick<import("react-native").ImageBackgroundProps, "imageStyle"> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & import("../..").RecorderProps & {
|
|
165
|
-
/**
|
|
166
|
-
* Avatar colors to be used when useAutoColors is true
|
|
167
|
-
*/
|
|
168
165
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
169
166
|
assetName?: string | undefined;
|
|
170
167
|
assetGroup?: string | undefined;
|
|
171
168
|
tintColor?: string | undefined;
|
|
172
|
-
supportRTL?: boolean | undefined;
|
|
173
|
-
* Background color for Avatar
|
|
174
|
-
*/
|
|
169
|
+
supportRTL?: boolean | undefined;
|
|
175
170
|
cover?: boolean | undefined;
|
|
176
171
|
aspectRatio?: number | undefined;
|
|
177
|
-
overlayType?: string | undefined;
|
|
178
|
-
* Image props object
|
|
179
|
-
*/
|
|
172
|
+
overlayType?: string | undefined;
|
|
180
173
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
181
174
|
overlayColor?: string | undefined;
|
|
182
175
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
183
176
|
errorSource?: import("../image").ImageSourceType;
|
|
184
|
-
imageId?: string | undefined;
|
|
177
|
+
imageId?: string | undefined; /**
|
|
178
|
+
* Listener-callback for when an image's (uri) loading
|
|
179
|
+
* fails (equiv. to Image.onError()).
|
|
180
|
+
*/
|
|
185
181
|
useBackgroundContainer?: boolean | undefined;
|
|
186
182
|
width?: string | number | undefined;
|
|
187
183
|
height?: string | number | undefined;
|
|
188
|
-
source: import("../image").ImageSourceType;
|
|
184
|
+
source: import("../image").ImageSourceType; /**
|
|
185
|
+
* Hash the name (or label) to get a color, so each name will have a specific color.
|
|
186
|
+
* Default is false.
|
|
187
|
+
*/
|
|
189
188
|
} & AnimatedImageProps> | undefined;
|
|
190
189
|
/**
|
|
191
190
|
* Image style object used to pass additional style props
|
|
@@ -291,30 +290,29 @@ declare const _default: React.ForwardRefExoticComponent<Pick<AccessibilityProps,
|
|
|
291
290
|
* Image props object
|
|
292
291
|
*/
|
|
293
292
|
imageProps?: Partial<Omit<import("react-native").ImageProps, "source"> & Pick<import("react-native").ImageBackgroundProps, "imageStyle"> & Partial<Record<"margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV", boolean>> & import("../..").RecorderProps & {
|
|
294
|
-
/**
|
|
295
|
-
* Avatar colors to be used when useAutoColors is true
|
|
296
|
-
*/
|
|
297
293
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
298
294
|
assetName?: string | undefined;
|
|
299
295
|
assetGroup?: string | undefined;
|
|
300
296
|
tintColor?: string | undefined;
|
|
301
|
-
supportRTL?: boolean | undefined;
|
|
302
|
-
* Background color for Avatar
|
|
303
|
-
*/
|
|
297
|
+
supportRTL?: boolean | undefined;
|
|
304
298
|
cover?: boolean | undefined;
|
|
305
299
|
aspectRatio?: number | undefined;
|
|
306
|
-
overlayType?: string | undefined;
|
|
307
|
-
* Image props object
|
|
308
|
-
*/
|
|
300
|
+
overlayType?: string | undefined;
|
|
309
301
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
310
302
|
overlayColor?: string | undefined;
|
|
311
303
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
312
304
|
errorSource?: import("../image").ImageSourceType;
|
|
313
|
-
imageId?: string | undefined;
|
|
305
|
+
imageId?: string | undefined; /**
|
|
306
|
+
* Listener-callback for when an image's (uri) loading
|
|
307
|
+
* fails (equiv. to Image.onError()).
|
|
308
|
+
*/
|
|
314
309
|
useBackgroundContainer?: boolean | undefined;
|
|
315
310
|
width?: string | number | undefined;
|
|
316
311
|
height?: string | number | undefined;
|
|
317
|
-
source: import("../image").ImageSourceType;
|
|
312
|
+
source: import("../image").ImageSourceType; /**
|
|
313
|
+
* Hash the name (or label) to get a color, so each name will have a specific color.
|
|
314
|
+
* Default is false.
|
|
315
|
+
*/
|
|
318
316
|
} & AnimatedImageProps> | undefined;
|
|
319
317
|
/**
|
|
320
318
|
* Image style object used to pass additional style props
|
|
@@ -16,7 +16,6 @@ import AnimatedImage from "../animatedImage";
|
|
|
16
16
|
import * as AvatarHelper from "../../helpers/AvatarHelper";
|
|
17
17
|
import { useThemeProps } from "../../hooks";
|
|
18
18
|
import { isSvg } from "../../utils/imageUtils";
|
|
19
|
-
import Constants from "../../commons/Constants";
|
|
20
19
|
export let BadgePosition = /*#__PURE__*/function (BadgePosition) {
|
|
21
20
|
BadgePosition["TOP_RIGHT"] = "TOP_RIGHT";
|
|
22
21
|
BadgePosition["TOP_LEFT"] = "TOP_LEFT";
|
|
@@ -150,7 +149,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
150
149
|
const renderImage = () => {
|
|
151
150
|
if (source !== undefined) {
|
|
152
151
|
// Looks like reanimated does not support SVG
|
|
153
|
-
const ImageContainer = animate && !isSvg(source)
|
|
152
|
+
const ImageContainer = animate && !isSvg(source) ? AnimatedImage : Image;
|
|
154
153
|
return <ImageContainer style={_imageStyle} source={source} onLoadStart={onImageLoadStart} onLoadEnd={onImageLoadEnd} onError={onImageLoadError} testID={`${testID}.image`} width={size} height={size} containerStyle={_baseContainerStyle} {...imageProps} />;
|
|
155
154
|
}
|
|
156
155
|
};
|
|
@@ -10,8 +10,6 @@ import Image from "../image";
|
|
|
10
10
|
import View from "../view";
|
|
11
11
|
import Text from "../text";
|
|
12
12
|
const LABEL_FORMATTER_VALUES = [1, 2, 3, 4];
|
|
13
|
-
const DEFAULT_PIMPLE_SIZE = 10;
|
|
14
|
-
const DEFAULT_BADGE_SIZE = 20;
|
|
15
13
|
/**
|
|
16
14
|
* @description: Round colored badge, typically used to show a number
|
|
17
15
|
* @extends: View
|
|
@@ -39,14 +37,7 @@ class Badge extends PureComponent {
|
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
39
|
get size() {
|
|
42
|
-
|
|
43
|
-
size,
|
|
44
|
-
label
|
|
45
|
-
} = this.props;
|
|
46
|
-
if (size !== undefined) {
|
|
47
|
-
return size;
|
|
48
|
-
}
|
|
49
|
-
return label === undefined ? DEFAULT_PIMPLE_SIZE : DEFAULT_BADGE_SIZE;
|
|
40
|
+
return this.props.size || 20;
|
|
50
41
|
}
|
|
51
42
|
isSmallBadge() {
|
|
52
43
|
return this.size <= 16;
|
|
@@ -15,6 +15,7 @@ import { PickerModes } from "./types";
|
|
|
15
15
|
import PickerContext from "./PickerContext";
|
|
16
16
|
import PickerItem from "./PickerItem";
|
|
17
17
|
import { Constants } from "../../commons/new";
|
|
18
|
+
import PickerSelectionControlBar from "./PickerSelectionControlBar";
|
|
18
19
|
const keyExtractor = (_item, index) => index.toString();
|
|
19
20
|
const PickerItemsList = props => {
|
|
20
21
|
const {
|
|
@@ -35,7 +36,8 @@ const PickerItemsList = props => {
|
|
|
35
36
|
testID,
|
|
36
37
|
showLoader,
|
|
37
38
|
customLoaderElement,
|
|
38
|
-
renderCustomTopElement
|
|
39
|
+
renderCustomTopElement,
|
|
40
|
+
selectionStatus
|
|
39
41
|
} = props;
|
|
40
42
|
const context = useContext(PickerContext);
|
|
41
43
|
const [wheelPickerValue, setWheelPickerValue] = useState(context.value ?? items?.[0]?.value);
|
|
@@ -130,10 +132,18 @@ const PickerItemsList = props => {
|
|
|
130
132
|
<ActivityIndicator />
|
|
131
133
|
</View>;
|
|
132
134
|
};
|
|
135
|
+
const renderSelectionStatus = useMemo(() => {
|
|
136
|
+
const props = {
|
|
137
|
+
...selectionStatus,
|
|
138
|
+
items
|
|
139
|
+
};
|
|
140
|
+
return <PickerSelectionControlBar {...props} value={context?.value} toggleAllItemsSelection={context?.toggleAllItemsSelection} />;
|
|
141
|
+
}, [selectionStatus, items, context?.value, context?.toggleAllItemsSelection]);
|
|
133
142
|
const renderContent = () => {
|
|
134
143
|
return useWheelPicker ? renderWheel() : <>
|
|
135
144
|
{renderSearchInput()}
|
|
136
145
|
{renderCustomTopElement?.(context.value)}
|
|
146
|
+
{mode === PickerModes.MULTI && renderSelectionStatus}
|
|
137
147
|
{renderList()}
|
|
138
148
|
</>;
|
|
139
149
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PickerItemProps, PickerProps, PickerContextProps, PickerMultiValue } from './types';
|
|
3
|
+
export type PickerSelectionControlBarProps = PickerProps['selectionStatus'] & Partial<PickerContextProps> & {
|
|
4
|
+
value?: PickerMultiValue;
|
|
5
|
+
items?: PickerItemProps[];
|
|
6
|
+
};
|
|
7
|
+
export default function PickerSelectionControlBar(props: PickerSelectionControlBarProps): React.JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useMemo, useCallback } from 'react';
|
|
2
|
+
import Button from "../button";
|
|
3
|
+
import Checkbox from "../checkbox";
|
|
4
|
+
import View from "../view";
|
|
5
|
+
import Text from "../text";
|
|
6
|
+
export default function PickerSelectionControlBar(props) {
|
|
7
|
+
const {
|
|
8
|
+
selectAllType = 'none',
|
|
9
|
+
buttonProps = {},
|
|
10
|
+
checkboxProps = {},
|
|
11
|
+
containerStyle,
|
|
12
|
+
value = [],
|
|
13
|
+
items = [],
|
|
14
|
+
toggleAllItemsSelection,
|
|
15
|
+
showLabel = true,
|
|
16
|
+
customLabel
|
|
17
|
+
} = props;
|
|
18
|
+
const availableItems = useMemo(() => items.filter(item => !item.disabled).map(item => item.value), [items]);
|
|
19
|
+
const isAllSelected = value.length === availableItems.length;
|
|
20
|
+
const checkboxIndeterminate = value.length > 0 && value.length < availableItems.length;
|
|
21
|
+
const defaultLabel = `${value.length} Selected ${isAllSelected ? '(All)' : ''}`;
|
|
22
|
+
const handlePress = useCallback(() => {
|
|
23
|
+
const newSelectionState = !isAllSelected;
|
|
24
|
+
toggleAllItemsSelection?.(availableItems, newSelectionState);
|
|
25
|
+
if (selectAllType === 'button') {
|
|
26
|
+
buttonProps.onPress?.(availableItems);
|
|
27
|
+
} else if (selectAllType === 'checkbox') {
|
|
28
|
+
checkboxProps.onValueChange?.(newSelectionState);
|
|
29
|
+
}
|
|
30
|
+
}, [isAllSelected, toggleAllItemsSelection, availableItems, selectAllType, buttonProps, checkboxProps]);
|
|
31
|
+
const renderSelectionStatus = () => {
|
|
32
|
+
if (selectAllType === 'button') {
|
|
33
|
+
return <Button label={isAllSelected ? 'Deselect All' : 'Select All'} link {...buttonProps} onPress={handlePress} />;
|
|
34
|
+
} else if (selectAllType === 'checkbox') {
|
|
35
|
+
return <Checkbox {...checkboxProps} value={value.length > 0} indeterminate={checkboxIndeterminate} onValueChange={handlePress} />;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const renderLabel = () => {
|
|
39
|
+
if (showLabel) {
|
|
40
|
+
return <Text>{customLabel || defaultLabel}</Text>;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
return <View row spread centerV paddingH-page style={containerStyle}>
|
|
45
|
+
{renderLabel()}
|
|
46
|
+
{renderSelectionStatus()}
|
|
47
|
+
</View>;
|
|
48
|
+
}
|
|
@@ -9,5 +9,7 @@ declare const usePickerSelection: (props: UsePickerSelectionProps) => {
|
|
|
9
9
|
onDoneSelecting: (item: PickerValue) => void;
|
|
10
10
|
toggleItemSelection: (item: PickerSingleValue) => void;
|
|
11
11
|
cancelSelect: () => void;
|
|
12
|
+
setMultiFinalValue: import("react").Dispatch<import("react").SetStateAction<PickerMultiValue>>;
|
|
13
|
+
toggleAllItemsSelection: (itemsToToggle: PickerMultiValue, select: boolean) => void;
|
|
12
14
|
};
|
|
13
15
|
export default usePickerSelection;
|
|
@@ -43,11 +43,16 @@ const usePickerSelection = props => {
|
|
|
43
43
|
pickerExpandableRef.current?.closeExpandable?.();
|
|
44
44
|
topBarProps?.onCancel?.();
|
|
45
45
|
}, [multiFinalValue, topBarProps]);
|
|
46
|
+
const toggleAllItemsSelection = useCallback((itemsToToggle, select) => {
|
|
47
|
+
setMultiDraftValue(select ? itemsToToggle : []);
|
|
48
|
+
}, []);
|
|
46
49
|
return {
|
|
47
50
|
multiDraftValue,
|
|
48
51
|
onDoneSelecting,
|
|
49
52
|
toggleItemSelection,
|
|
50
|
-
cancelSelect
|
|
53
|
+
cancelSelect,
|
|
54
|
+
setMultiFinalValue,
|
|
55
|
+
toggleAllItemsSelection
|
|
51
56
|
};
|
|
52
57
|
};
|
|
53
58
|
export default usePickerSelection;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PickerItem from './PickerItem';
|
|
3
3
|
import { extractPickerItems } from './PickerPresenter';
|
|
4
|
-
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from './types';
|
|
4
|
+
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType } from './types';
|
|
5
5
|
type PickerStatics = {
|
|
6
6
|
Item: typeof PickerItem;
|
|
7
7
|
modes: typeof PickerModes;
|
|
8
8
|
fieldTypes: typeof PickerFieldTypes;
|
|
9
9
|
extractPickerItems: typeof extractPickerItems;
|
|
10
|
+
selectAllType: typeof PickerSelectAllType;
|
|
10
11
|
};
|
|
11
12
|
declare const Picker: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>>;
|
|
12
|
-
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods };
|
|
13
|
+
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType };
|
|
13
14
|
export { Picker };
|
|
14
15
|
declare const _default: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>> & PickerStatics;
|
|
15
16
|
export default _default;
|
|
@@ -18,7 +18,7 @@ import useFieldType from "./helpers/useFieldType";
|
|
|
18
18
|
import useNewPickerProps from "./helpers/useNewPickerProps";
|
|
19
19
|
// import usePickerMigrationWarnings from './helpers/usePickerMigrationWarnings';
|
|
20
20
|
import { extractPickerItems } from "./PickerPresenter";
|
|
21
|
-
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from "./types";
|
|
21
|
+
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType } from "./types";
|
|
22
22
|
const DEFAULT_DIALOG_PROPS = {
|
|
23
23
|
bottom: true,
|
|
24
24
|
width: '100%'
|
|
@@ -58,6 +58,7 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
58
58
|
showLoader,
|
|
59
59
|
customLoaderElement,
|
|
60
60
|
renderCustomTopElement,
|
|
61
|
+
selectionStatus,
|
|
61
62
|
...others
|
|
62
63
|
} = themeProps;
|
|
63
64
|
const {
|
|
@@ -101,7 +102,8 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
101
102
|
multiDraftValue,
|
|
102
103
|
onDoneSelecting,
|
|
103
104
|
toggleItemSelection,
|
|
104
|
-
cancelSelect
|
|
105
|
+
cancelSelect,
|
|
106
|
+
toggleAllItemsSelection
|
|
105
107
|
} = usePickerSelection({
|
|
106
108
|
migrate,
|
|
107
109
|
value,
|
|
@@ -154,9 +156,10 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
154
156
|
getItemLabel,
|
|
155
157
|
onSelectedLayout: onSelectedItemLayout,
|
|
156
158
|
renderItem,
|
|
157
|
-
selectionLimit
|
|
159
|
+
selectionLimit,
|
|
160
|
+
toggleAllItemsSelection
|
|
158
161
|
};
|
|
159
|
-
}, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting]);
|
|
162
|
+
}, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting, toggleAllItemsSelection]);
|
|
160
163
|
const renderPickerItem = useCallback((item, index) => {
|
|
161
164
|
return <PickerItem key={`${index}-${item.value}`} {...item} />;
|
|
162
165
|
}, []);
|
|
@@ -201,7 +204,7 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
201
204
|
...topBarProps,
|
|
202
205
|
onCancel: cancelSelect,
|
|
203
206
|
onDone: mode === PickerModes.MULTI ? () => onDoneSelecting(multiDraftValue) : undefined
|
|
204
|
-
}} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement}>
|
|
207
|
+
}} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement} selectionStatus={selectionStatus}>
|
|
205
208
|
{filteredItems}
|
|
206
209
|
</PickerItemsList>;
|
|
207
210
|
}, [testID, mode, useDialog, selectedItemPosition, topBarProps, cancelSelect, onDoneSelecting, multiDraftValue, showSearch, searchStyle, searchPlaceholder, _onSearchChange, renderCustomSearch, renderHeader, listProps, filteredItems, useSafeArea, useWheelPicker, items, showLoader]);
|
|
@@ -221,6 +224,8 @@ Picker.modes = PickerModes;
|
|
|
221
224
|
Picker.fieldTypes = PickerFieldTypes;
|
|
222
225
|
// @ts-expect-error
|
|
223
226
|
Picker.extractPickerItems = extractPickerItems;
|
|
224
|
-
|
|
227
|
+
//@ts-ignore
|
|
228
|
+
Picker.selectAllType = PickerSelectAllType;
|
|
229
|
+
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType };
|
|
225
230
|
export { Picker }; // For tests
|
|
226
231
|
export default Picker;
|
|
@@ -4,6 +4,8 @@ import { ExpandableOverlayProps, ExpandableOverlayMethods } from '../../incubato
|
|
|
4
4
|
import { ModalTopBarProps } from '../modal/TopBar';
|
|
5
5
|
import { TextFieldMethods, TextFieldProps } from '../textField';
|
|
6
6
|
import { TouchableOpacityProps } from '../touchableOpacity';
|
|
7
|
+
import { ButtonProps } from '../button';
|
|
8
|
+
import { CheckboxProps } from '../checkbox';
|
|
7
9
|
export declare enum PickerModes {
|
|
8
10
|
SINGLE = "SINGLE",
|
|
9
11
|
MULTI = "MULTI"
|
|
@@ -13,6 +15,11 @@ export declare enum PickerFieldTypes {
|
|
|
13
15
|
filter = "filter",
|
|
14
16
|
settings = "settings"
|
|
15
17
|
}
|
|
18
|
+
export declare enum PickerSelectAllType {
|
|
19
|
+
none = "none",
|
|
20
|
+
button = "button",
|
|
21
|
+
checkbox = "checkbox"
|
|
22
|
+
}
|
|
16
23
|
export type PickerSingleValue = string | number;
|
|
17
24
|
export type PickerMultiValue = PickerSingleValue[];
|
|
18
25
|
export type PickerValue = PickerSingleValue | PickerMultiValue | undefined;
|
|
@@ -147,6 +154,41 @@ type PickerExpandableOverlayProps = {
|
|
|
147
154
|
*/
|
|
148
155
|
enableModalBlur?: boolean;
|
|
149
156
|
};
|
|
157
|
+
interface getLabelOptions {
|
|
158
|
+
selectedCount?: number;
|
|
159
|
+
value?: PickerItemProps[];
|
|
160
|
+
isSelectedAll?: boolean;
|
|
161
|
+
}
|
|
162
|
+
type PickerSelectionStatusProps = {
|
|
163
|
+
/**
|
|
164
|
+
* A function that returns the label to show for the selected Picker value
|
|
165
|
+
*/
|
|
166
|
+
getLabel?: (options?: getLabelOptions) => string;
|
|
167
|
+
/**
|
|
168
|
+
* Select all element type
|
|
169
|
+
*/
|
|
170
|
+
selectAllType?: PickerSelectAllType | `${PickerSelectAllType}`;
|
|
171
|
+
/**
|
|
172
|
+
* Button props
|
|
173
|
+
*/
|
|
174
|
+
buttonProps?: ButtonProps;
|
|
175
|
+
/**
|
|
176
|
+
* Checkbox props
|
|
177
|
+
*/
|
|
178
|
+
checkboxProps?: CheckboxProps;
|
|
179
|
+
/**
|
|
180
|
+
* Custom container style
|
|
181
|
+
*/
|
|
182
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
183
|
+
/**
|
|
184
|
+
* Control weather to show the label or not
|
|
185
|
+
*/
|
|
186
|
+
showLabel?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Custom label to show next to the selection element.
|
|
189
|
+
*/
|
|
190
|
+
customLabel?: string;
|
|
191
|
+
};
|
|
150
192
|
export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & PickerPropsDeprecation & PickerExpandableOverlayProps & PickerListProps & {
|
|
151
193
|
/**
|
|
152
194
|
* Use dialog instead of modal picker
|
|
@@ -193,6 +235,10 @@ export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & Picke
|
|
|
193
235
|
* Render custom top element
|
|
194
236
|
*/
|
|
195
237
|
renderCustomTopElement?: (value?: PickerValue) => React.ReactElement;
|
|
238
|
+
/**
|
|
239
|
+
*
|
|
240
|
+
*/
|
|
241
|
+
selectionStatus?: PickerSelectionStatusProps;
|
|
196
242
|
/**
|
|
197
243
|
* Add onPress callback for when pressing the picker
|
|
198
244
|
*/
|
|
@@ -286,8 +332,9 @@ export interface PickerContextProps extends Pick<PickerProps, 'migrate' | 'value
|
|
|
286
332
|
isMultiMode: boolean;
|
|
287
333
|
onSelectedLayout: (event: any) => any;
|
|
288
334
|
selectionLimit: PickerProps['selectionLimit'];
|
|
335
|
+
toggleAllItemsSelection?: (itemsToToggle: PickerMultiValue, select: boolean) => void;
|
|
289
336
|
}
|
|
290
|
-
export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'children' | 'useWheelPicker' | 'useDialog' | 'mode' | 'testID'> & {
|
|
337
|
+
export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | 'selectionStatus' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'children' | 'useWheelPicker' | 'useDialog' | 'mode' | 'testID'> & {
|
|
291
338
|
items?: {
|
|
292
339
|
value: any;
|
|
293
340
|
label: any;
|
|
@@ -10,6 +10,12 @@ export let PickerFieldTypes = /*#__PURE__*/function (PickerFieldTypes) {
|
|
|
10
10
|
PickerFieldTypes["settings"] = "settings";
|
|
11
11
|
return PickerFieldTypes;
|
|
12
12
|
}({});
|
|
13
|
+
export let PickerSelectAllType = /*#__PURE__*/function (PickerSelectAllType) {
|
|
14
|
+
PickerSelectAllType["none"] = "none";
|
|
15
|
+
PickerSelectAllType["button"] = "button";
|
|
16
|
+
PickerSelectAllType["checkbox"] = "checkbox";
|
|
17
|
+
return PickerSelectAllType;
|
|
18
|
+
}({});
|
|
13
19
|
|
|
14
20
|
// TODO: Remove type
|
|
15
21
|
// type PickerValueDeprecated = {value: string | number; label: string};
|
package/src/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export { default as PanningContext } from './components/panningViews/panningCont
|
|
|
67
67
|
export { default as PanningProvider, PanningDirections, PanLocationProps, PanAmountsProps, PanDirectionsProps } from './components/panningViews/panningProvider';
|
|
68
68
|
export { default as PanResponderView, PanResponderViewProps } from './components/panningViews/panResponderView';
|
|
69
69
|
export { default as asPanViewConsumer } from './components/panningViews/asPanViewConsumer';
|
|
70
|
-
export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from './components/picker';
|
|
70
|
+
export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType } from './components/picker';
|
|
71
71
|
export { default as PieChart, type PieChartProps, PieChartSegmentProps } from './components/pieChart';
|
|
72
72
|
export { default as ProgressBar, ProgressBarProps } from './components/progressBar';
|
|
73
73
|
export { default as ProgressiveImage, ProgressiveImageProps } from './components/progressiveImage';
|
package/src/index.js
CHANGED
|
@@ -166,6 +166,7 @@ var _exportNames = {
|
|
|
166
166
|
RenderCustomModalProps: true,
|
|
167
167
|
PickerItemsListProps: true,
|
|
168
168
|
PickerMethods: true,
|
|
169
|
+
PickerSelectAllType: true,
|
|
169
170
|
PieChart: true,
|
|
170
171
|
PieChartSegmentProps: true,
|
|
171
172
|
ProgressBar: true,
|
|
@@ -1110,6 +1111,12 @@ Object.defineProperty(exports, "PickerSearchStyle", {
|
|
|
1110
1111
|
return _picker().PickerSearchStyle;
|
|
1111
1112
|
}
|
|
1112
1113
|
});
|
|
1114
|
+
Object.defineProperty(exports, "PickerSelectAllType", {
|
|
1115
|
+
enumerable: true,
|
|
1116
|
+
get: function () {
|
|
1117
|
+
return _picker().PickerSelectAllType;
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1113
1120
|
Object.defineProperty(exports, "PickerValue", {
|
|
1114
1121
|
enumerable: true,
|
|
1115
1122
|
get: function () {
|