react-native-ui-lib 7.38.1-snapshot.6326 → 7.38.1-snapshot.6335
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 +22 -20
- package/src/components/avatar/index.js +2 -1
- package/src/components/badge/index.js +10 -1
- package/src/components/picker/PickerItemsList.js +1 -11
- package/src/components/picker/helpers/usePickerSelection.d.ts +0 -2
- package/src/components/picker/helpers/usePickerSelection.js +1 -6
- package/src/components/picker/index.d.ts +2 -3
- package/src/components/picker/index.js +6 -11
- package/src/components/picker/types.d.ts +1 -48
- package/src/components/picker/types.js +0 -6
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -7
- package/src/components/picker/PickerSelectionControlBar.d.ts +0 -7
- package/src/components/picker/PickerSelectionControlBar.js +0 -48
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. This prop isn't supported on web (will be set to false by default when using web).",
|
|
16
16
|
"default": "false"
|
|
17
17
|
},
|
|
18
18
|
{"name": "backgroundColor", "type": "string", "description": "Background color for Avatar"},
|
|
@@ -162,29 +162,30 @@ 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
|
+
*/
|
|
165
168
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
166
169
|
assetName?: string | undefined;
|
|
167
170
|
assetGroup?: string | undefined;
|
|
168
171
|
tintColor?: string | undefined;
|
|
169
|
-
supportRTL?: boolean | undefined;
|
|
172
|
+
supportRTL?: boolean | undefined; /**
|
|
173
|
+
* Background color for Avatar
|
|
174
|
+
*/
|
|
170
175
|
cover?: boolean | undefined;
|
|
171
176
|
aspectRatio?: number | undefined;
|
|
172
|
-
overlayType?: string | undefined;
|
|
177
|
+
overlayType?: string | undefined; /**
|
|
178
|
+
* Image props object
|
|
179
|
+
*/
|
|
173
180
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
174
181
|
overlayColor?: string | undefined;
|
|
175
182
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
176
183
|
errorSource?: import("../image").ImageSourceType;
|
|
177
|
-
imageId?: string | undefined;
|
|
178
|
-
* Listener-callback for when an image's (uri) loading
|
|
179
|
-
* fails (equiv. to Image.onError()).
|
|
180
|
-
*/
|
|
184
|
+
imageId?: string | undefined;
|
|
181
185
|
useBackgroundContainer?: boolean | undefined;
|
|
182
186
|
width?: string | number | undefined;
|
|
183
187
|
height?: string | number | undefined;
|
|
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
|
-
*/
|
|
188
|
+
source: import("../image").ImageSourceType;
|
|
188
189
|
} & AnimatedImageProps> | undefined;
|
|
189
190
|
/**
|
|
190
191
|
* Image style object used to pass additional style props
|
|
@@ -290,29 +291,30 @@ declare const _default: React.ForwardRefExoticComponent<Pick<AccessibilityProps,
|
|
|
290
291
|
* Image props object
|
|
291
292
|
*/
|
|
292
293
|
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
|
+
*/
|
|
293
297
|
sourceTransformer?: ((props: any) => import("../image").ImageSourceType) | undefined;
|
|
294
298
|
assetName?: string | undefined;
|
|
295
299
|
assetGroup?: string | undefined;
|
|
296
300
|
tintColor?: string | undefined;
|
|
297
|
-
supportRTL?: boolean | undefined;
|
|
301
|
+
supportRTL?: boolean | undefined; /**
|
|
302
|
+
* Background color for Avatar
|
|
303
|
+
*/
|
|
298
304
|
cover?: boolean | undefined;
|
|
299
305
|
aspectRatio?: number | undefined;
|
|
300
|
-
overlayType?: string | undefined;
|
|
306
|
+
overlayType?: string | undefined; /**
|
|
307
|
+
* Image props object
|
|
308
|
+
*/
|
|
301
309
|
overlayIntensity?: import("../overlay").OverlayIntensityType | undefined;
|
|
302
310
|
overlayColor?: string | undefined;
|
|
303
311
|
customOverlayContent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
304
312
|
errorSource?: import("../image").ImageSourceType;
|
|
305
|
-
imageId?: string | undefined;
|
|
306
|
-
* Listener-callback for when an image's (uri) loading
|
|
307
|
-
* fails (equiv. to Image.onError()).
|
|
308
|
-
*/
|
|
313
|
+
imageId?: string | undefined;
|
|
309
314
|
useBackgroundContainer?: boolean | undefined;
|
|
310
315
|
width?: string | number | undefined;
|
|
311
316
|
height?: string | number | undefined;
|
|
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
|
-
*/
|
|
317
|
+
source: import("../image").ImageSourceType;
|
|
316
318
|
} & AnimatedImageProps> | undefined;
|
|
317
319
|
/**
|
|
318
320
|
* Image style object used to pass additional style props
|
|
@@ -16,6 +16,7 @@ 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";
|
|
19
20
|
export let BadgePosition = /*#__PURE__*/function (BadgePosition) {
|
|
20
21
|
BadgePosition["TOP_RIGHT"] = "TOP_RIGHT";
|
|
21
22
|
BadgePosition["TOP_LEFT"] = "TOP_LEFT";
|
|
@@ -149,7 +150,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
149
150
|
const renderImage = () => {
|
|
150
151
|
if (source !== undefined) {
|
|
151
152
|
// Looks like reanimated does not support SVG
|
|
152
|
-
const ImageContainer = animate && !isSvg(source) ? AnimatedImage : Image;
|
|
153
|
+
const ImageContainer = animate && !isSvg(source) && !Constants.isWeb ? AnimatedImage : Image;
|
|
153
154
|
return <ImageContainer style={_imageStyle} source={source} onLoadStart={onImageLoadStart} onLoadEnd={onImageLoadEnd} onError={onImageLoadError} testID={`${testID}.image`} width={size} height={size} containerStyle={_baseContainerStyle} {...imageProps} />;
|
|
154
155
|
}
|
|
155
156
|
};
|
|
@@ -10,6 +10,8 @@ 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;
|
|
13
15
|
/**
|
|
14
16
|
* @description: Round colored badge, typically used to show a number
|
|
15
17
|
* @extends: View
|
|
@@ -37,7 +39,14 @@ class Badge extends PureComponent {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
get size() {
|
|
40
|
-
|
|
42
|
+
const {
|
|
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;
|
|
41
50
|
}
|
|
42
51
|
isSmallBadge() {
|
|
43
52
|
return this.size <= 16;
|
|
@@ -15,7 +15,6 @@ 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";
|
|
19
18
|
const keyExtractor = (_item, index) => index.toString();
|
|
20
19
|
const PickerItemsList = props => {
|
|
21
20
|
const {
|
|
@@ -36,8 +35,7 @@ const PickerItemsList = props => {
|
|
|
36
35
|
testID,
|
|
37
36
|
showLoader,
|
|
38
37
|
customLoaderElement,
|
|
39
|
-
renderCustomTopElement
|
|
40
|
-
selectionStatus
|
|
38
|
+
renderCustomTopElement
|
|
41
39
|
} = props;
|
|
42
40
|
const context = useContext(PickerContext);
|
|
43
41
|
const [wheelPickerValue, setWheelPickerValue] = useState(context.value ?? items?.[0]?.value);
|
|
@@ -132,18 +130,10 @@ const PickerItemsList = props => {
|
|
|
132
130
|
<ActivityIndicator />
|
|
133
131
|
</View>;
|
|
134
132
|
};
|
|
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]);
|
|
142
133
|
const renderContent = () => {
|
|
143
134
|
return useWheelPicker ? renderWheel() : <>
|
|
144
135
|
{renderSearchInput()}
|
|
145
136
|
{renderCustomTopElement?.(context.value)}
|
|
146
|
-
{mode === PickerModes.MULTI && renderSelectionStatus}
|
|
147
137
|
{renderList()}
|
|
148
138
|
</>;
|
|
149
139
|
};
|
|
@@ -9,7 +9,5 @@ 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;
|
|
14
12
|
};
|
|
15
13
|
export default usePickerSelection;
|
|
@@ -43,16 +43,11 @@ 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
|
-
}, []);
|
|
49
46
|
return {
|
|
50
47
|
multiDraftValue,
|
|
51
48
|
onDoneSelecting,
|
|
52
49
|
toggleItemSelection,
|
|
53
|
-
cancelSelect
|
|
54
|
-
setMultiFinalValue,
|
|
55
|
-
toggleAllItemsSelection
|
|
50
|
+
cancelSelect
|
|
56
51
|
};
|
|
57
52
|
};
|
|
58
53
|
export default usePickerSelection;
|
|
@@ -1,16 +1,15 @@
|
|
|
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
|
|
4
|
+
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } 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;
|
|
11
10
|
};
|
|
12
11
|
declare const Picker: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>>;
|
|
13
|
-
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods
|
|
12
|
+
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods };
|
|
14
13
|
export { Picker };
|
|
15
14
|
declare const _default: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>> & PickerStatics;
|
|
16
15
|
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
|
|
21
|
+
import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from "./types";
|
|
22
22
|
const DEFAULT_DIALOG_PROPS = {
|
|
23
23
|
bottom: true,
|
|
24
24
|
width: '100%'
|
|
@@ -58,7 +58,6 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
58
58
|
showLoader,
|
|
59
59
|
customLoaderElement,
|
|
60
60
|
renderCustomTopElement,
|
|
61
|
-
selectionStatus,
|
|
62
61
|
...others
|
|
63
62
|
} = themeProps;
|
|
64
63
|
const {
|
|
@@ -102,8 +101,7 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
102
101
|
multiDraftValue,
|
|
103
102
|
onDoneSelecting,
|
|
104
103
|
toggleItemSelection,
|
|
105
|
-
cancelSelect
|
|
106
|
-
toggleAllItemsSelection
|
|
104
|
+
cancelSelect
|
|
107
105
|
} = usePickerSelection({
|
|
108
106
|
migrate,
|
|
109
107
|
value,
|
|
@@ -156,10 +154,9 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
156
154
|
getItemLabel,
|
|
157
155
|
onSelectedLayout: onSelectedItemLayout,
|
|
158
156
|
renderItem,
|
|
159
|
-
selectionLimit
|
|
160
|
-
toggleAllItemsSelection
|
|
157
|
+
selectionLimit
|
|
161
158
|
};
|
|
162
|
-
}, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting
|
|
159
|
+
}, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting]);
|
|
163
160
|
const renderPickerItem = useCallback((item, index) => {
|
|
164
161
|
return <PickerItem key={`${index}-${item.value}`} {...item} />;
|
|
165
162
|
}, []);
|
|
@@ -204,7 +201,7 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
204
201
|
...topBarProps,
|
|
205
202
|
onCancel: cancelSelect,
|
|
206
203
|
onDone: mode === PickerModes.MULTI ? () => onDoneSelecting(multiDraftValue) : undefined
|
|
207
|
-
}} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement}
|
|
204
|
+
}} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement}>
|
|
208
205
|
{filteredItems}
|
|
209
206
|
</PickerItemsList>;
|
|
210
207
|
}, [testID, mode, useDialog, selectedItemPosition, topBarProps, cancelSelect, onDoneSelecting, multiDraftValue, showSearch, searchStyle, searchPlaceholder, _onSearchChange, renderCustomSearch, renderHeader, listProps, filteredItems, useSafeArea, useWheelPicker, items, showLoader]);
|
|
@@ -224,8 +221,6 @@ Picker.modes = PickerModes;
|
|
|
224
221
|
Picker.fieldTypes = PickerFieldTypes;
|
|
225
222
|
// @ts-expect-error
|
|
226
223
|
Picker.extractPickerItems = extractPickerItems;
|
|
227
|
-
|
|
228
|
-
Picker.selectAllType = PickerSelectAllType;
|
|
229
|
-
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectAllType };
|
|
224
|
+
export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods };
|
|
230
225
|
export { Picker }; // For tests
|
|
231
226
|
export default Picker;
|
|
@@ -4,8 +4,6 @@ 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';
|
|
9
7
|
export declare enum PickerModes {
|
|
10
8
|
SINGLE = "SINGLE",
|
|
11
9
|
MULTI = "MULTI"
|
|
@@ -15,11 +13,6 @@ export declare enum PickerFieldTypes {
|
|
|
15
13
|
filter = "filter",
|
|
16
14
|
settings = "settings"
|
|
17
15
|
}
|
|
18
|
-
export declare enum PickerSelectAllType {
|
|
19
|
-
none = "none",
|
|
20
|
-
button = "button",
|
|
21
|
-
checkbox = "checkbox"
|
|
22
|
-
}
|
|
23
16
|
export type PickerSingleValue = string | number;
|
|
24
17
|
export type PickerMultiValue = PickerSingleValue[];
|
|
25
18
|
export type PickerValue = PickerSingleValue | PickerMultiValue | undefined;
|
|
@@ -154,41 +147,6 @@ type PickerExpandableOverlayProps = {
|
|
|
154
147
|
*/
|
|
155
148
|
enableModalBlur?: boolean;
|
|
156
149
|
};
|
|
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
|
-
};
|
|
192
150
|
export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & PickerPropsDeprecation & PickerExpandableOverlayProps & PickerListProps & {
|
|
193
151
|
/**
|
|
194
152
|
* Use dialog instead of modal picker
|
|
@@ -235,10 +193,6 @@ export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & Picke
|
|
|
235
193
|
* Render custom top element
|
|
236
194
|
*/
|
|
237
195
|
renderCustomTopElement?: (value?: PickerValue) => React.ReactElement;
|
|
238
|
-
/**
|
|
239
|
-
*
|
|
240
|
-
*/
|
|
241
|
-
selectionStatus?: PickerSelectionStatusProps;
|
|
242
196
|
/**
|
|
243
197
|
* Add onPress callback for when pressing the picker
|
|
244
198
|
*/
|
|
@@ -332,9 +286,8 @@ export interface PickerContextProps extends Pick<PickerProps, 'migrate' | 'value
|
|
|
332
286
|
isMultiMode: boolean;
|
|
333
287
|
onSelectedLayout: (event: any) => any;
|
|
334
288
|
selectionLimit: PickerProps['selectionLimit'];
|
|
335
|
-
toggleAllItemsSelection?: (itemsToToggle: PickerMultiValue, select: boolean) => void;
|
|
336
289
|
}
|
|
337
|
-
export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | '
|
|
290
|
+
export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'children' | 'useWheelPicker' | 'useDialog' | 'mode' | 'testID'> & {
|
|
338
291
|
items?: {
|
|
339
292
|
value: any;
|
|
340
293
|
label: any;
|
|
@@ -10,12 +10,6 @@ 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
|
-
}({});
|
|
19
13
|
|
|
20
14
|
// TODO: Remove type
|
|
21
15
|
// 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
|
|
70
|
+
export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } 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,7 +166,6 @@ var _exportNames = {
|
|
|
166
166
|
RenderCustomModalProps: true,
|
|
167
167
|
PickerItemsListProps: true,
|
|
168
168
|
PickerMethods: true,
|
|
169
|
-
PickerSelectAllType: true,
|
|
170
169
|
PieChart: true,
|
|
171
170
|
PieChartSegmentProps: true,
|
|
172
171
|
ProgressBar: true,
|
|
@@ -1111,12 +1110,6 @@ Object.defineProperty(exports, "PickerSearchStyle", {
|
|
|
1111
1110
|
return _picker().PickerSearchStyle;
|
|
1112
1111
|
}
|
|
1113
1112
|
});
|
|
1114
|
-
Object.defineProperty(exports, "PickerSelectAllType", {
|
|
1115
|
-
enumerable: true,
|
|
1116
|
-
get: function () {
|
|
1117
|
-
return _picker().PickerSelectAllType;
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
1113
|
Object.defineProperty(exports, "PickerValue", {
|
|
1121
1114
|
enumerable: true,
|
|
1122
1115
|
get: function () {
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
}
|