react-native-ui-lib 7.46.1 → 7.46.2-snapshot.7314
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/babel.config.js +12 -0
- package/index.js +1 -0
- package/lib/android/build.gradle +5 -5
- package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
- package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
- package/lib/components/HighlighterOverlayView/index.js +49 -0
- package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
- package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
- package/lib/components/Keyboard/index.d.ts +6 -6
- package/lib/components/Keyboard/index.js +6 -6
- package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
- package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
- package/lib/components/SafeArea/index.d.ts +10 -0
- package/lib/components/SafeArea/index.js +11 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +52 -8
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
- package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +109 -41
- package/lib/package.json +1 -1
- package/lib/react-native.config.js +1 -3
- package/metro.config.js +2 -2
- package/package.json +24 -24
- package/panView.d.ts +2 -0
- package/panView.js +1 -0
- package/react-native.config.js +1 -3
- package/src/commons/Constants.js +2 -5
- package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
- package/src/components/actionSheet/index.d.ts +2 -12
- package/src/components/actionSheet/index.js +3 -42
- package/src/components/badge/index.d.ts +107 -47
- package/src/components/button/button.api.json +1 -1
- package/src/components/button/index.d.ts +53 -23
- package/src/components/button/types.d.ts +0 -1
- package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
- package/src/components/colorPicker/ColorPickerDialog.js +1 -1
- package/src/components/dateTimePicker/index.d.ts +186 -5
- package/src/components/dateTimePicker/index.js +3 -4
- package/src/components/dialog/dialog.api.json +31 -37
- package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
- package/src/components/dialog/index.d.ts +13 -105
- package/src/components/dialog/index.js +204 -212
- package/src/{incubator → components}/dialog/types.d.ts +0 -19
- package/src/{incubator → components}/dialog/types.js +1 -3
- package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
- package/src/components/drawer/Swipeable.js +1 -2
- package/src/components/drawer/index.js +31 -25
- package/src/components/fadedScrollView/index.js +7 -2
- package/src/components/featureHighlight/index.d.ts +1 -1
- package/src/components/index.js +0 -19
- package/src/components/modal/index.d.ts +5 -0
- package/src/components/modal/index.js +14 -10
- package/src/components/modal/modal.api.json +5 -0
- package/src/{incubator → components}/panView/index.d.ts +3 -3
- package/src/{incubator → components}/panView/index.js +4 -4
- package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
- package/src/components/picker/Picker.driver.new.d.ts +2 -2
- package/src/components/picker/Picker.driver.new.js +3 -3
- package/src/components/picker/PickerItem.js +6 -20
- package/src/components/picker/PickerPresenter.d.ts +0 -1
- package/src/components/picker/PickerPresenter.js +1 -23
- package/src/components/picker/api/picker.api.json +0 -1
- package/src/components/picker/api/pickerItem.api.json +0 -5
- package/src/components/picker/helpers/useFieldType.d.ts +53 -23
- package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
- package/src/components/picker/helpers/usePickerLabel.js +2 -3
- package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
- package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
- package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSearch.js +4 -8
- package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSelection.js +2 -10
- package/src/components/picker/index.js +4 -22
- package/src/components/picker/types.d.ts +1 -24
- package/src/components/segmentedControl/index.js +3 -3
- package/src/components/slider/GradientSlider.d.ts +1 -1
- package/src/components/sortableGridList/SortableItem.js +13 -4
- package/src/components/sortableList/SortableListItem.js +13 -4
- package/src/components/stackAggregator/index.js +16 -11
- package/src/components/text/Text.driver.new.d.ts +2 -2
- package/src/components/text/Text.driver.new.js +2 -2
- package/src/components/textField/Input.js +0 -1
- package/src/components/textField/TextField.driver.new.d.ts +2 -2
- package/src/components/textField/TextField.driver.new.js +2 -2
- package/src/components/textField/presets/outline.d.ts +106 -46
- package/src/components/textField/presets/underline.d.ts +106 -46
- package/src/components/textField/usePreset.d.ts +72 -44
- package/src/hooks/index.d.ts +1 -0
- package/src/hooks/index.js +1 -0
- package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
- package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
- package/src/hooks/useKeyboardHeight/index.d.ts +5 -0
- package/src/hooks/useKeyboardHeight/index.js +23 -0
- package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
- package/src/incubator/expandableOverlay/index.d.ts +42 -3
- package/src/incubator/expandableOverlay/index.js +1 -4
- package/src/incubator/gradient/BorderGradient.d.ts +4 -0
- package/src/incubator/gradient/BorderGradient.js +45 -0
- package/src/incubator/gradient/CircleGradient.d.ts +4 -0
- package/src/incubator/gradient/CircleGradient.js +35 -0
- package/src/incubator/gradient/RectangleGradient.d.ts +4 -0
- package/src/incubator/gradient/RectangleGradient.js +32 -0
- package/src/incubator/gradient/index.d.ts +5 -0
- package/src/incubator/gradient/index.js +31 -0
- package/src/incubator/gradient/types.d.ts +26 -0
- package/src/incubator/gradient/types.js +1 -0
- package/src/incubator/gradient/useAngleTransform.d.ts +27 -0
- package/src/incubator/gradient/useAngleTransform.js +72 -0
- package/src/incubator/index.d.ts +1 -2
- package/src/incubator/index.js +2 -3
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +3 -10
- package/src/index.js +41 -160
- package/src/optionalDependencies/LinearGradientPackage.d.ts +1 -1
- package/src/style/borderRadiuses.d.ts +2 -0
- package/src/style/borderRadiuses.js +1 -0
- package/src/testkit/index.d.ts +1 -1
- package/src/testkit/index.js +1 -1
- package/src/testkit/new/Component.driver.d.ts +4 -1
- package/src/testkit/new/Component.driver.js +3 -3
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
- package/lib/components/HighlighterOverlayView.js +0 -40
- package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
- package/panningViews.d.ts +0 -2
- package/panningViews.js +0 -1
- package/sharedTransition.d.ts +0 -2
- package/sharedTransition.js +0 -1
- package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
- package/src/components/dialog/DialogDismissibleView.js +0 -184
- package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
- package/src/components/dialog/OverlayFadingBackground.js +0 -45
- package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
- package/src/components/panningViews/asPanViewConsumer.js +0 -16
- package/src/components/panningViews/panDismissibleView.d.ts +0 -51
- package/src/components/panningViews/panDismissibleView.js +0 -350
- package/src/components/panningViews/panGestureView.d.ts +0 -23
- package/src/components/panningViews/panGestureView.js +0 -156
- package/src/components/panningViews/panListenerView.d.ts +0 -66
- package/src/components/panningViews/panListenerView.js +0 -155
- package/src/components/panningViews/panResponderView.d.ts +0 -19
- package/src/components/panningViews/panResponderView.js +0 -79
- package/src/components/panningViews/panningContext.d.ts +0 -3
- package/src/components/panningViews/panningContext.js +0 -4
- package/src/components/panningViews/panningProvider.d.ts +0 -73
- package/src/components/panningViews/panningProvider.js +0 -101
- package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
- package/src/components/sharedTransition/SharedArea.js +0 -153
- package/src/components/sharedTransition/SourceElement.js +0 -44
- package/src/components/sharedTransition/TargetElement.js +0 -38
- package/src/components/sharedTransition/index.js +0 -9
- package/src/incubator/dialog/dialog.api.json +0 -54
- package/src/incubator/dialog/index.d.ts +0 -15
- package/src/incubator/dialog/index.js +0 -218
- /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
- /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
- /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
- /package/src/{incubator → components}/panView/panningUtil.js +0 -0
- /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
- /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
- /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/index.web.js} +0 -0
|
@@ -55,6 +55,7 @@ class Modal extends Component {
|
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
57
57
|
const {
|
|
58
|
+
fixReanimatedInteraction = true,
|
|
58
59
|
blurView,
|
|
59
60
|
enableModalBlur,
|
|
60
61
|
visible,
|
|
@@ -76,16 +77,19 @@ class Modal extends Component {
|
|
|
76
77
|
style: [styles.fill, keyboardAvoidingViewProps?.style]
|
|
77
78
|
} : {};
|
|
78
79
|
const Container = blurView ? blurView : defaultContainer;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const HackContainer = fixReanimatedInteraction && Constants.isAndroid ? View : React.Fragment;
|
|
81
|
+
return <HackContainer>
|
|
82
|
+
<RNModal visible={Boolean(visible)} {...others}>
|
|
83
|
+
<GestureContainer {...gestureContainerProps}>
|
|
84
|
+
<KeyboardAvoidingContainer {...keyboardAvoidingContainerProps}>
|
|
85
|
+
<Container style={styles.fill} blurType="light">
|
|
86
|
+
{this.renderTouchableOverlay()}
|
|
87
|
+
{this.props.children}
|
|
88
|
+
</Container>
|
|
89
|
+
</KeyboardAvoidingContainer>
|
|
90
|
+
</GestureContainer>
|
|
91
|
+
</RNModal>
|
|
92
|
+
</HackContainer>;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
const styles = StyleSheet.create({
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"name": "keyboardAvoidingViewProps",
|
|
39
39
|
"type": "object",
|
|
40
40
|
"description": "Send additional props to the KeyboardAvoidingView (iOS only)"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "fixReanimatedInteraction",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"description": "Fix RNModal's interaction with react-native-reanimated (Android only, default: true)"
|
|
41
46
|
}
|
|
42
47
|
],
|
|
43
48
|
"snippet": [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
import { ViewProps } from '
|
|
3
|
+
import { ViewProps } from '../view';
|
|
4
4
|
import { PanningDirections, PanningDirectionsEnum } from './panningUtil';
|
|
5
|
-
import { PanGestureProps, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold
|
|
6
|
-
export { PanningDirections, PanningDirectionsEnum, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold
|
|
5
|
+
import { PanGestureProps, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold } from './usePanGesture';
|
|
6
|
+
export { PanningDirections, PanningDirectionsEnum, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold };
|
|
7
7
|
export interface PanViewProps extends Omit<PanGestureProps, 'hiddenLocation'>, ViewProps {
|
|
8
8
|
/**
|
|
9
9
|
* Add a style to the container
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { useAnimatedStyle } from 'react-native-reanimated';
|
|
3
3
|
import { GestureDetector, gestureHandlerRootHOC } from 'react-native-gesture-handler';
|
|
4
4
|
import { asBaseComponent } from "../../commons/new";
|
|
5
|
-
import View from "
|
|
6
|
-
import useHiddenLocation from "
|
|
5
|
+
import View from "../view";
|
|
6
|
+
import useHiddenLocation from "../../hooks/useHiddenLocation";
|
|
7
7
|
import { PanningDirections, PanningDirectionsEnum } from "./panningUtil";
|
|
8
|
-
import usePanGesture, { PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold, DEFAULT_DIRECTIONS
|
|
9
|
-
export { PanningDirections, PanningDirectionsEnum, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold
|
|
8
|
+
import usePanGesture, { PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold, DEFAULT_DIRECTIONS } from "./usePanGesture";
|
|
9
|
+
export { PanningDirections, PanningDirectionsEnum, PanViewDirections, PanViewDirectionsEnum, PanViewDismissThreshold };
|
|
10
10
|
const PanView = props => {
|
|
11
11
|
const {
|
|
12
12
|
directions = DEFAULT_DIRECTIONS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PanningDirections, PanningDirectionsEnum, PanningDismissThreshold } from './panningUtil';
|
|
2
|
-
import type { HiddenLocation } from '
|
|
2
|
+
import type { HiddenLocation } from '../../hooks/useHiddenLocation';
|
|
3
3
|
export type PanViewDirections = PanningDirections;
|
|
4
4
|
export declare const PanViewDirectionsEnum: typeof PanningDirectionsEnum;
|
|
5
5
|
export type PanViewDismissThreshold = PanningDismissThreshold;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentProps } from '../../testkit/new/Component.driver';
|
|
2
|
-
export declare const PickerDriver: (props: ComponentProps, useDialog: boolean) => {
|
|
1
|
+
import { ComponentDriverOptions, ComponentProps } from '../../testkit/new/Component.driver';
|
|
2
|
+
export declare const PickerDriver: (props: ComponentProps, useDialog: boolean, options?: ComponentDriverOptions) => {
|
|
3
3
|
exists: () => boolean;
|
|
4
4
|
getValue: () => string | undefined;
|
|
5
5
|
open: () => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TextFieldDriver } from "../textField/TextField.driver.new";
|
|
2
2
|
import { ModalDriver } from "../modal/Modal.driver.new";
|
|
3
|
-
import { DialogDriver } from "
|
|
3
|
+
import { DialogDriver } from "../dialog/Dialog.driver.new";
|
|
4
4
|
import { ButtonDriver } from "../button/Button.driver.new";
|
|
5
5
|
import { ExpandableOverlayDriver } from "../../incubator/expandableOverlay/ExpandableOverlay.driver";
|
|
6
|
-
export const PickerDriver = (props, useDialog) => {
|
|
6
|
+
export const PickerDriver = (props, useDialog, options) => {
|
|
7
7
|
const expandableOverlayDriver = ExpandableOverlayDriver({
|
|
8
8
|
renderTree: props.renderTree,
|
|
9
9
|
testID: props.testID
|
|
@@ -11,7 +11,7 @@ export const PickerDriver = (props, useDialog) => {
|
|
|
11
11
|
const textFieldDriver = TextFieldDriver({
|
|
12
12
|
renderTree: props.renderTree,
|
|
13
13
|
testID: `${props.testID}.input`
|
|
14
|
-
});
|
|
14
|
+
}, options);
|
|
15
15
|
const modalDriver = ModalDriver({
|
|
16
16
|
renderTree: props.renderTree,
|
|
17
17
|
testID: `${props.testID}.overlay`
|
|
@@ -11,7 +11,7 @@ import View from "../view";
|
|
|
11
11
|
import TouchableOpacity from "../touchableOpacity";
|
|
12
12
|
import Image from "../image";
|
|
13
13
|
import Text from "../text";
|
|
14
|
-
import {
|
|
14
|
+
import { isItemSelected } from "./PickerPresenter";
|
|
15
15
|
import PickerContext from "./PickerContext";
|
|
16
16
|
/**
|
|
17
17
|
* @description: Picker.Item, for configuring the Picker's selectable options
|
|
@@ -29,14 +29,8 @@ const PickerItem = props => {
|
|
|
29
29
|
testID
|
|
30
30
|
} = props;
|
|
31
31
|
const context = useContext(PickerContext);
|
|
32
|
-
const {
|
|
33
|
-
migrate
|
|
34
|
-
} = context;
|
|
35
32
|
const customRenderItem = props.renderItem || context.renderItem;
|
|
36
|
-
|
|
37
|
-
const itemValue = !migrate && typeof value === 'object' ? value?.value : value;
|
|
38
|
-
const isSelected = isItemSelected(itemValue, context.value);
|
|
39
|
-
const itemLabel = getItemLabel(label, value, props.getItemLabel || context.getItemLabel);
|
|
33
|
+
const isSelected = isItemSelected(value, context.value);
|
|
40
34
|
const selectedCounter = context.selectionLimit && _isArray(context.value) && context.value?.length;
|
|
41
35
|
const accessibilityProps = {
|
|
42
36
|
accessibilityState: isSelected ? {
|
|
@@ -67,23 +61,15 @@ const PickerItem = props => {
|
|
|
67
61
|
if (onPress && (await onPress(context.isMultiMode ? !isSelected : undefined, props)) === false) {
|
|
68
62
|
return;
|
|
69
63
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
// @ts-expect-error TODO: fix after removing migrate prop completely
|
|
74
|
-
context.onPress(typeof value === 'object' || context.isMultiMode ? value : {
|
|
75
|
-
value,
|
|
76
|
-
label: itemLabel
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}, [migrate, value, context.onPress, onPress]);
|
|
64
|
+
context.onPress(value);
|
|
65
|
+
}, [value, context.onPress, onPress]);
|
|
80
66
|
const onSelectedLayout = useCallback((...args) => {
|
|
81
67
|
_invoke(context, 'onSelectedLayout', ...args);
|
|
82
68
|
}, []);
|
|
83
69
|
const _renderItem = () => {
|
|
84
70
|
return <View style={styles.container} flex row spread centerV>
|
|
85
71
|
<Text numberOfLines={1} style={itemLabelStyle}>
|
|
86
|
-
{
|
|
72
|
+
{label}
|
|
87
73
|
</Text>
|
|
88
74
|
{selectedIndicator}
|
|
89
75
|
</View>;
|
|
@@ -93,7 +79,7 @@ const PickerItem = props => {
|
|
|
93
79
|
...props,
|
|
94
80
|
isSelected,
|
|
95
81
|
isItemDisabled
|
|
96
|
-
},
|
|
82
|
+
}, label) : _renderItem()}
|
|
97
83
|
</TouchableOpacity>;
|
|
98
84
|
};
|
|
99
85
|
const styles = StyleSheet.create({
|
|
@@ -4,5 +4,4 @@ export declare function extractPickerItems(props: PickerProps): {
|
|
|
4
4
|
label: any;
|
|
5
5
|
}[];
|
|
6
6
|
export declare function isItemSelected(childValue: PickerSingleValue, selectedValue?: PickerValue): boolean;
|
|
7
|
-
export declare function getItemLabel(label: string, value: PickerValue, getItemLabel?: PickerProps['getItemLabel']): string | undefined;
|
|
8
7
|
export declare function shouldFilterOut(searchValue: string, itemLabel?: string): boolean;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _lowerCase from "lodash/lowerCase";
|
|
2
2
|
import _includes from "lodash/includes";
|
|
3
|
-
import _get from "lodash/get";
|
|
4
|
-
import _isObject from "lodash/isObject";
|
|
5
3
|
import _find from "lodash/find";
|
|
6
4
|
import React from 'react';
|
|
7
5
|
export function extractPickerItems(props) {
|
|
@@ -20,33 +18,13 @@ export function isItemSelected(childValue, selectedValue) {
|
|
|
20
18
|
let isSelected = false;
|
|
21
19
|
if (Array.isArray(selectedValue)) {
|
|
22
20
|
isSelected = _find(selectedValue, v => {
|
|
23
|
-
|
|
24
|
-
return v === childValue || typeof v === 'object' && v?.value === childValue;
|
|
21
|
+
return v === childValue;
|
|
25
22
|
}) !== undefined;
|
|
26
23
|
} else {
|
|
27
24
|
isSelected = childValue === selectedValue;
|
|
28
25
|
}
|
|
29
26
|
return isSelected;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
// export function getItemValue(props) {
|
|
33
|
-
// if (_.isArray(props.value)) {
|
|
34
|
-
// return props.getItemValue ? _.map(props.value, item => props.getItemValue(item)) : _.map(props.value, 'value');
|
|
35
|
-
// } else if (!_.isObject(props.value)) {
|
|
36
|
-
// return props.value;
|
|
37
|
-
// }
|
|
38
|
-
// return _.invoke(props, 'getItemValue', props.value) || _.get(props.value, 'value');
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
export function getItemLabel(label, value, getItemLabel) {
|
|
42
|
-
if (_isObject(value)) {
|
|
43
|
-
if (getItemLabel) {
|
|
44
|
-
return getItemLabel(value);
|
|
45
|
-
}
|
|
46
|
-
return _get(value, 'label');
|
|
47
|
-
}
|
|
48
|
-
return label;
|
|
49
|
-
}
|
|
50
28
|
export function shouldFilterOut(searchValue, itemLabel) {
|
|
51
29
|
return !_includes(_lowerCase(itemLabel), _lowerCase(searchValue));
|
|
52
30
|
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Picker/CustomPicker.gif?raw=true"
|
|
12
12
|
],
|
|
13
13
|
"props": [
|
|
14
|
-
{"name": "migrate", "type": "boolean", "description": "Temporary prop required for migration to Picker's new API"},
|
|
15
14
|
{"name": "value", "type": "string | number", "description": "Picker current value"},
|
|
16
15
|
{
|
|
17
16
|
"name": "onChange",
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
{"name": "value", "type": "string | number", "description": "Item's value"},
|
|
14
14
|
{"name": "label", "type": "string", "description": "Item's label"},
|
|
15
15
|
{"name": "labelStyle", "type": "ViewStyle", "description": "Item's label style"},
|
|
16
|
-
{
|
|
17
|
-
"name": "getItemLabel",
|
|
18
|
-
"type": "(value: string | number) => string",
|
|
19
|
-
"description": "Custom function for the item label"
|
|
20
|
-
},
|
|
21
16
|
{"name": "isSelected", "type": "boolean", "description": "Is the item selected"},
|
|
22
17
|
{"name": "selectedIcon", "type": "string", "description": "Pass to change the selected icon"},
|
|
23
18
|
{"name": "selectedIconColor", "type": "ImageSource", "description": "Pass to change the selected icon color"},
|
|
@@ -13,7 +13,7 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
13
13
|
fontFamily?: string | undefined;
|
|
14
14
|
fontSize?: number | undefined;
|
|
15
15
|
fontStyle?: "normal" | "italic" | undefined;
|
|
16
|
-
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | undefined;
|
|
16
|
+
fontWeight?: "black" | 900 | 600 | "light" | 100 | "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | 200 | 300 | 400 | 500 | 700 | 800 | "ultralight" | "thin" | "medium" | "regular" | "semibold" | "condensedBold" | "condensed" | "heavy" | undefined;
|
|
17
17
|
letterSpacing?: number | undefined;
|
|
18
18
|
lineHeight?: number | undefined;
|
|
19
19
|
textAlign?: "auto" | "left" | "right" | "center" | "justify" | undefined;
|
|
@@ -36,31 +36,41 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
36
36
|
borderBlockEndColor?: import("react-native/types").ColorValue | undefined;
|
|
37
37
|
borderBlockStartColor?: import("react-native/types").ColorValue | undefined;
|
|
38
38
|
borderBottomColor?: import("react-native/types").ColorValue | undefined;
|
|
39
|
-
borderBottomEndRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
40
|
-
borderBottomLeftRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
41
|
-
borderBottomRightRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
42
|
-
borderBottomStartRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
39
|
+
borderBottomEndRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
40
|
+
borderBottomLeftRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
41
|
+
borderBottomRightRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
42
|
+
borderBottomStartRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
43
43
|
borderColor?: import("react-native/types").ColorValue | undefined;
|
|
44
44
|
borderCurve?: "circular" | "continuous" | undefined;
|
|
45
45
|
borderEndColor?: import("react-native/types").ColorValue | undefined;
|
|
46
|
-
borderEndEndRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
47
|
-
borderEndStartRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
46
|
+
borderEndEndRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
47
|
+
borderEndStartRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
48
48
|
borderLeftColor?: import("react-native/types").ColorValue | undefined;
|
|
49
|
-
borderRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
49
|
+
borderRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
50
50
|
borderRightColor?: import("react-native/types").ColorValue | undefined;
|
|
51
51
|
borderStartColor?: import("react-native/types").ColorValue | undefined;
|
|
52
|
-
borderStartEndRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
53
|
-
borderStartStartRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
52
|
+
borderStartEndRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
53
|
+
borderStartStartRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
54
54
|
borderStyle?: "solid" | "dotted" | "dashed" | undefined;
|
|
55
55
|
borderTopColor?: import("react-native/types").ColorValue | undefined;
|
|
56
|
-
borderTopEndRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
57
|
-
borderTopLeftRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
58
|
-
borderTopRightRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
59
|
-
borderTopStartRadius?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
56
|
+
borderTopEndRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
57
|
+
borderTopLeftRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
58
|
+
borderTopRightRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
59
|
+
borderTopStartRadius?: string | import("react-native/types").AnimatableNumericValue | undefined;
|
|
60
|
+
outlineColor?: import("react-native/types").ColorValue | undefined;
|
|
61
|
+
outlineOffset?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
62
|
+
outlineStyle?: "solid" | "dotted" | "dashed" | undefined;
|
|
63
|
+
outlineWidth?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
60
64
|
opacity?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
61
65
|
elevation?: number | undefined;
|
|
62
66
|
pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
|
|
63
|
-
|
|
67
|
+
isolation?: "auto" | "isolate" | undefined;
|
|
68
|
+
cursor?: import("react-native/types").CursorValue | undefined;
|
|
69
|
+
boxShadow?: string | readonly import("react-native/types").BoxShadowValue[] | undefined;
|
|
70
|
+
filter?: string | readonly import("react-native/types").FilterFunction[] | undefined;
|
|
71
|
+
mixBlendMode?: import("react-native/types").BlendMode | undefined;
|
|
72
|
+
experimental_backgroundImage?: string | readonly import("react-native/types").GradientValue[] | undefined;
|
|
73
|
+
alignContent?: "center" | "flex-start" | "flex-end" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
|
|
64
74
|
alignItems?: import("react-native/types").FlexAlignType | undefined;
|
|
65
75
|
alignSelf?: "auto" | import("react-native/types").FlexAlignType | undefined;
|
|
66
76
|
aspectRatio?: string | number | undefined;
|
|
@@ -72,14 +82,15 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
72
82
|
borderTopWidth?: number | undefined;
|
|
73
83
|
borderWidth?: number | undefined;
|
|
74
84
|
bottom?: import("react-native/types").DimensionValue | undefined;
|
|
75
|
-
|
|
85
|
+
boxSizing?: "border-box" | "content-box" | undefined;
|
|
86
|
+
display?: "none" | "flex" | "contents" | undefined;
|
|
76
87
|
end?: import("react-native/types").DimensionValue | undefined;
|
|
77
88
|
flex?: number | undefined;
|
|
78
89
|
flexBasis?: import("react-native/types").DimensionValue | undefined;
|
|
79
90
|
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" | undefined;
|
|
80
|
-
rowGap?: number | undefined;
|
|
81
|
-
gap?: number | undefined;
|
|
82
|
-
columnGap?: number | undefined;
|
|
91
|
+
rowGap?: string | number | undefined;
|
|
92
|
+
gap?: string | number | undefined;
|
|
93
|
+
columnGap?: string | number | undefined;
|
|
83
94
|
flexGrow?: number | undefined;
|
|
84
95
|
flexShrink?: number | undefined;
|
|
85
96
|
flexWrap?: "wrap" | "nowrap" | "wrap-reverse" | undefined;
|
|
@@ -109,13 +120,32 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
109
120
|
paddingStart?: import("react-native/types").DimensionValue | undefined;
|
|
110
121
|
paddingTop?: import("react-native/types").DimensionValue | undefined;
|
|
111
122
|
paddingVertical?: import("react-native/types").DimensionValue | undefined;
|
|
112
|
-
position?: "absolute" | "relative" | undefined;
|
|
123
|
+
position?: "absolute" | "relative" | "static" | undefined;
|
|
113
124
|
right?: import("react-native/types").DimensionValue | undefined;
|
|
114
125
|
start?: import("react-native/types").DimensionValue | undefined;
|
|
115
126
|
top?: import("react-native/types").DimensionValue | undefined;
|
|
116
127
|
width?: import("react-native/types").DimensionValue | undefined;
|
|
117
128
|
zIndex?: number | undefined;
|
|
118
129
|
direction?: "ltr" | "rtl" | "inherit" | undefined;
|
|
130
|
+
inset?: import("react-native/types").DimensionValue | undefined;
|
|
131
|
+
insetBlock?: import("react-native/types").DimensionValue | undefined;
|
|
132
|
+
insetBlockEnd?: import("react-native/types").DimensionValue | undefined;
|
|
133
|
+
insetBlockStart?: import("react-native/types").DimensionValue | undefined;
|
|
134
|
+
insetInline?: import("react-native/types").DimensionValue | undefined;
|
|
135
|
+
insetInlineEnd?: import("react-native/types").DimensionValue | undefined;
|
|
136
|
+
insetInlineStart?: import("react-native/types").DimensionValue | undefined;
|
|
137
|
+
marginBlock?: import("react-native/types").DimensionValue | undefined;
|
|
138
|
+
marginBlockEnd?: import("react-native/types").DimensionValue | undefined;
|
|
139
|
+
marginBlockStart?: import("react-native/types").DimensionValue | undefined;
|
|
140
|
+
marginInline?: import("react-native/types").DimensionValue | undefined;
|
|
141
|
+
marginInlineEnd?: import("react-native/types").DimensionValue | undefined;
|
|
142
|
+
marginInlineStart?: import("react-native/types").DimensionValue | undefined;
|
|
143
|
+
paddingBlock?: import("react-native/types").DimensionValue | undefined;
|
|
144
|
+
paddingBlockEnd?: import("react-native/types").DimensionValue | undefined;
|
|
145
|
+
paddingBlockStart?: import("react-native/types").DimensionValue | undefined;
|
|
146
|
+
paddingInline?: import("react-native/types").DimensionValue | undefined;
|
|
147
|
+
paddingInlineEnd?: import("react-native/types").DimensionValue | undefined;
|
|
148
|
+
paddingInlineStart?: import("react-native/types").DimensionValue | undefined;
|
|
119
149
|
shadowColor?: import("react-native/types").ColorValue | undefined;
|
|
120
150
|
shadowOffset?: Readonly<{
|
|
121
151
|
width: number;
|
|
@@ -123,7 +153,7 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
123
153
|
}> | undefined;
|
|
124
154
|
shadowOpacity?: import("react-native/types").AnimatableNumericValue | undefined;
|
|
125
155
|
shadowRadius?: number | undefined;
|
|
126
|
-
transform?: string | (({
|
|
156
|
+
transform?: string | readonly (({
|
|
127
157
|
perspective: import("react-native/types").AnimatableNumericValue;
|
|
128
158
|
} & {
|
|
129
159
|
rotate?: undefined;
|
|
@@ -244,7 +274,7 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
244
274
|
skewY?: undefined;
|
|
245
275
|
matrix?: undefined;
|
|
246
276
|
}) | ({
|
|
247
|
-
translateX: import("react-native/types").AnimatableNumericValue
|
|
277
|
+
translateX: import("react-native/types").AnimatableNumericValue | `${number}%`;
|
|
248
278
|
} & {
|
|
249
279
|
perspective?: undefined;
|
|
250
280
|
rotate?: undefined;
|
|
@@ -259,7 +289,7 @@ declare const useFieldType: (props: UseFieldTypeProps) => {
|
|
|
259
289
|
skewY?: undefined;
|
|
260
290
|
matrix?: undefined;
|
|
261
291
|
}) | ({
|
|
262
|
-
translateY: import("react-native/types").AnimatableNumericValue
|
|
292
|
+
translateY: import("react-native/types").AnimatableNumericValue | `${number}%`;
|
|
263
293
|
} & {
|
|
264
294
|
perspective?: undefined;
|
|
265
295
|
rotate?: undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PickerProps, PickerValue } from '../types';
|
|
2
|
-
interface UsePickerLabelProps extends Pick<PickerProps, 'value' | 'getLabel' | '
|
|
2
|
+
interface UsePickerLabelProps extends Pick<PickerProps, 'value' | 'getLabel' | 'placeholder' | 'accessibilityLabel' | 'accessibilityHint'> {
|
|
3
3
|
items: {
|
|
4
4
|
value: string | number;
|
|
5
5
|
label: string;
|
|
@@ -14,15 +14,14 @@ const usePickerLabel = props => {
|
|
|
14
14
|
value,
|
|
15
15
|
items,
|
|
16
16
|
getLabel,
|
|
17
|
-
getItemLabel,
|
|
18
17
|
placeholder,
|
|
19
18
|
accessibilityLabel,
|
|
20
19
|
accessibilityHint
|
|
21
20
|
} = props;
|
|
22
21
|
const getLabelsFromArray = useCallback(value => {
|
|
23
22
|
const itemsByValue = _keyBy(items, 'value');
|
|
24
|
-
return _flow(arr => _map(arr, item => _isPlainObject(item) ?
|
|
25
|
-
}, [
|
|
23
|
+
return _flow(arr => _map(arr, item => _isPlainObject(item) ? item?.label : itemsByValue[item]?.label), arr => _join(arr, ', '))(value);
|
|
24
|
+
}, [items]);
|
|
26
25
|
const _getLabel = useCallback(value => {
|
|
27
26
|
if (_isFunction(getLabel) && !_isUndefined(getLabel(value))) {
|
|
28
27
|
return getLabel(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PickerProps } from '../types';
|
|
2
|
-
type UsePickerMigrationWarnings = Pick<PickerProps, 'children' | '
|
|
2
|
+
type UsePickerMigrationWarnings = Pick<PickerProps, 'children' | 'onShow'>;
|
|
3
3
|
declare const usePickerMigrationWarnings: (props: UsePickerMigrationWarnings) => void;
|
|
4
4
|
export default usePickerMigrationWarnings;
|
|
@@ -6,24 +6,12 @@ import { LogService } from "../../../services";
|
|
|
6
6
|
const usePickerMigrationWarnings = props => {
|
|
7
7
|
const {
|
|
8
8
|
children,
|
|
9
|
-
migrate,
|
|
10
|
-
getItemLabel,
|
|
11
|
-
getItemValue,
|
|
12
9
|
onShow
|
|
13
10
|
} = props;
|
|
14
11
|
useEffect(() => {
|
|
15
12
|
if (children) {
|
|
16
13
|
LogService.warn(`UILib Picker will stop supporting the 'children' prop in the next major version, please pass 'items' prop instead`);
|
|
17
14
|
}
|
|
18
|
-
if (migrate) {
|
|
19
|
-
LogService.warn(`UILib Picker will stop supporting the 'migrate' prop in the next major version, please stop using it. The picker uses the new implementation by default.`);
|
|
20
|
-
}
|
|
21
|
-
if (getItemLabel) {
|
|
22
|
-
LogService.warn(`UILib Picker will stop supporting the 'getItemLabel' prop in the next major version, please pass the 'getItemLabel' prop to the specific item instead`);
|
|
23
|
-
}
|
|
24
|
-
if (getItemValue) {
|
|
25
|
-
LogService.warn(`UILib Picker will stop supporting the 'getItemValue' prop in the next major version, please stop using it. The value will be extract from 'items' prop instead`);
|
|
26
|
-
}
|
|
27
15
|
if (onShow) {
|
|
28
16
|
LogService.warn(`UILib Picker will stop supporting the 'onShow' prop in the next major version, please pass the 'onShow' prop from the 'pickerModalProps' instead`);
|
|
29
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PickerProps } from '../types';
|
|
3
|
-
type UsePickerSearchProps = Pick<PickerProps, 'showSearch' | 'onSearchChange' | 'children' | '
|
|
3
|
+
type UsePickerSearchProps = Pick<PickerProps, 'showSearch' | 'onSearchChange' | 'children' | 'items'>;
|
|
4
4
|
declare const usePickerSearch: (props: UsePickerSearchProps) => {
|
|
5
5
|
setSearchValue: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
6
6
|
onSearchChange: (searchValue: string) => void;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _filter from "lodash/filter";
|
|
2
2
|
import _isEmpty from "lodash/isEmpty";
|
|
3
3
|
import { useCallback, useState, useMemo } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { shouldFilterOut } from "../PickerPresenter";
|
|
5
5
|
const usePickerSearch = props => {
|
|
6
6
|
const {
|
|
7
7
|
showSearch,
|
|
8
8
|
onSearchChange,
|
|
9
9
|
children,
|
|
10
|
-
getItemLabel,
|
|
11
10
|
items
|
|
12
11
|
} = props;
|
|
13
12
|
const [searchValue, setSearchValue] = useState('');
|
|
@@ -15,16 +14,13 @@ const usePickerSearch = props => {
|
|
|
15
14
|
if (showSearch && !_isEmpty(searchValue)) {
|
|
16
15
|
return _filter(items, item => {
|
|
17
16
|
const {
|
|
18
|
-
label
|
|
19
|
-
value,
|
|
20
|
-
getItemLabel: childGetItemLabel
|
|
17
|
+
label
|
|
21
18
|
} = item.props || item;
|
|
22
|
-
|
|
23
|
-
return !shouldFilterOut(searchValue, itemLabel);
|
|
19
|
+
return !shouldFilterOut(searchValue, label);
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
return items;
|
|
27
|
-
}, [showSearch, searchValue
|
|
23
|
+
}, [showSearch, searchValue]);
|
|
28
24
|
const filteredItems = useMemo(() => {
|
|
29
25
|
return filterItems(children || items);
|
|
30
26
|
}, [filterItems, items, children]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { PickerProps, PickerValue, PickerSingleValue, PickerMultiValue } from '../types';
|
|
3
|
-
interface UsePickerSelectionProps extends Pick<PickerProps, '
|
|
3
|
+
interface UsePickerSelectionProps extends Pick<PickerProps, 'value' | 'onChange' | 'topBarProps' | 'mode' | 'items'> {
|
|
4
4
|
pickerExpandableRef: RefObject<any>;
|
|
5
5
|
setSearchValue: (searchValue: string) => void;
|
|
6
6
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import _xor from "lodash/xor";
|
|
2
|
-
import _xorBy from "lodash/xorBy";
|
|
3
2
|
import { useCallback, useState, useEffect, useMemo } from 'react';
|
|
4
3
|
import { PickerModes } from "../types";
|
|
5
4
|
const usePickerSelection = props => {
|
|
6
5
|
const {
|
|
7
|
-
migrate,
|
|
8
6
|
value,
|
|
9
7
|
onChange,
|
|
10
8
|
topBarProps,
|
|
11
9
|
pickerExpandableRef,
|
|
12
|
-
getItemValue,
|
|
13
10
|
setSearchValue,
|
|
14
11
|
mode,
|
|
15
12
|
items
|
|
@@ -29,15 +26,10 @@ const usePickerSelection = props => {
|
|
|
29
26
|
onChange?.(item);
|
|
30
27
|
}, [onChange]);
|
|
31
28
|
const toggleItemSelection = useCallback(item => {
|
|
32
|
-
let newValue;
|
|
33
29
|
const itemAsArray = [item];
|
|
34
|
-
|
|
35
|
-
newValue = _xorBy(multiDraftValue, itemAsArray, getItemValue || 'value');
|
|
36
|
-
} else {
|
|
37
|
-
newValue = _xor(multiDraftValue, itemAsArray);
|
|
38
|
-
}
|
|
30
|
+
const newValue = _xor(multiDraftValue, itemAsArray);
|
|
39
31
|
setMultiDraftValue(newValue);
|
|
40
|
-
}, [multiDraftValue
|
|
32
|
+
}, [multiDraftValue]);
|
|
41
33
|
const cancelSelect = useCallback(() => {
|
|
42
34
|
setSearchValue('');
|
|
43
35
|
setMultiDraftValue(multiFinalValue);
|