react-native-ui-lib 7.46.3-snapshot.7341 → 7.46.3-snapshot.7342
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 +0 -12
- package/index.js +0 -1
- package/lib/android/build.gradle +5 -5
- package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +2 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +23 -31
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +30 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +34 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +33 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +53 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +54 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +28 -0
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +36 -0
- package/lib/components/{HighlighterOverlayView/index.d.ts → HighlighterOverlayView.d.ts} +1 -1
- package/lib/components/HighlighterOverlayView.js +40 -0
- package/lib/components/{HighlighterOverlayView/index.web.d.ts → HighlighterOverlayView.web.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.android.d.ts +2 -5
- package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +28 -0
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.d.ts +0 -3
- package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.js +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/index.d.ts → KeyboardInput/KeyboardAccessoryView.d.ts} +1 -11
- package/lib/components/Keyboard/{KeyboardAccessoryView/index.js → KeyboardInput/KeyboardAccessoryView.js} +5 -31
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.d.ts → KeyboardInput/KeyboardRegistry.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.js → KeyboardInput/KeyboardRegistry.js} +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/keyboardAccessoryView.api.json +5 -5
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/keyboardRegistry.api.json +9 -9
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +11 -0
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +17 -0
- package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager → KeyboardInput/utils}/__tests__/EventEmitterManager.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.d.ts → KeyboardTracking/KeyboardAwareInsetsView.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.js → KeyboardTracking/KeyboardAwareInsetsView.js} +1 -1
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +4 -1
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.js +8 -5
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.d.ts +2 -2
- package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/keyboardTrackingView.api.json +20 -11
- package/lib/components/Keyboard/index.d.ts +6 -6
- package/lib/components/Keyboard/index.js +6 -6
- package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +7 -21
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +31 -95
- package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/lib/components/SafeArea/SafeAreaSpacerView.js +9 -63
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +8 -52
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +7 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
- package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +41 -109
- package/lib/package.json +1 -1
- package/lib/react-native.config.js +3 -1
- package/metro.config.js +2 -2
- package/package.json +25 -25
- package/panningViews.d.ts +2 -0
- package/panningViews.js +1 -0
- package/react-native.config.js +3 -1
- package/scripts/release/prReleaseNotesCommon.js +15 -4
- package/sharedTransition.d.ts +2 -0
- package/sharedTransition.js +1 -0
- package/src/commons/Constants.js +5 -2
- package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +1 -5
- package/src/components/actionSheet/index.d.ts +12 -2
- package/src/components/actionSheet/index.js +42 -3
- package/src/components/badge/index.d.ts +47 -107
- package/src/components/button/button.api.json +1 -1
- package/src/components/button/index.d.ts +23 -53
- package/src/components/button/types.d.ts +1 -0
- package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
- package/src/components/colorPicker/ColorPickerDialog.js +1 -1
- package/src/components/dateTimePicker/index.d.ts +5 -186
- package/src/components/dateTimePicker/index.js +4 -3
- package/src/components/dialog/DialogDismissibleView.d.ts +34 -0
- package/src/components/dialog/DialogDismissibleView.js +184 -0
- package/src/components/dialog/OverlayFadingBackground.d.ts +14 -0
- package/src/components/dialog/OverlayFadingBackground.js +45 -0
- package/src/components/dialog/dialog.api.json +37 -31
- package/src/components/dialog/index.d.ts +105 -13
- package/src/components/dialog/index.js +212 -204
- package/src/components/drawer/Swipeable.js +2 -1
- package/src/components/drawer/index.js +25 -31
- package/src/components/fadedScrollView/index.js +2 -7
- package/src/components/featureHighlight/index.d.ts +1 -1
- package/src/components/index.js +19 -0
- package/src/components/marquee/types.js +1 -4
- package/src/components/modal/index.d.ts +0 -5
- package/src/components/modal/index.js +10 -14
- package/src/components/modal/modal.api.json +0 -5
- package/src/components/panningViews/asPanViewConsumer.d.ts +3 -0
- package/src/components/panningViews/asPanViewConsumer.js +16 -0
- package/src/components/panningViews/panDismissibleView.d.ts +51 -0
- package/src/components/panningViews/panDismissibleView.js +350 -0
- package/src/components/panningViews/panGestureView.d.ts +23 -0
- package/src/components/panningViews/panGestureView.js +156 -0
- package/src/components/panningViews/panListenerView.d.ts +66 -0
- package/src/components/panningViews/panListenerView.js +155 -0
- package/src/components/panningViews/panResponderView.d.ts +19 -0
- package/src/components/panningViews/panResponderView.js +79 -0
- package/src/components/panningViews/panningContext.d.ts +3 -0
- package/src/components/panningViews/panningContext.js +4 -0
- package/src/components/panningViews/panningProvider.d.ts +73 -0
- package/src/components/panningViews/panningProvider.js +101 -0
- 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 +20 -6
- package/src/components/picker/PickerPresenter.d.ts +1 -0
- package/src/components/picker/PickerPresenter.js +23 -1
- package/src/components/picker/api/picker.api.json +1 -0
- package/src/components/picker/api/pickerItem.api.json +5 -0
- package/src/components/picker/helpers/useFieldType.d.ts +23 -53
- package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
- package/src/components/picker/helpers/usePickerLabel.js +3 -2
- package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
- package/src/components/picker/helpers/usePickerMigrationWarnings.js +12 -0
- package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSearch.js +8 -4
- package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSelection.js +10 -2
- package/src/components/picker/index.js +22 -4
- package/src/components/picker/types.d.ts +24 -1
- package/src/components/segmentedControl/index.js +3 -3
- package/src/components/sharedTransition/ShareTransitionContext.js +3 -0
- package/src/components/sharedTransition/SharedArea.js +153 -0
- package/src/components/sharedTransition/SourceElement.js +44 -0
- package/src/components/sharedTransition/TargetElement.js +38 -0
- package/src/components/sharedTransition/index.js +9 -0
- package/src/components/slider/GradientSlider.d.ts +1 -1
- package/src/components/sortableGridList/SortableItem.js +4 -13
- package/src/components/sortableList/SortableListItem.js +4 -13
- package/src/components/stackAggregator/index.js +11 -16
- 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 +1 -0
- 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 +46 -106
- package/src/components/textField/presets/underline.d.ts +46 -106
- package/src/components/textField/types.js +0 -1
- package/src/components/textField/usePreset.d.ts +44 -72
- package/src/components/timeline/types.js +0 -3
- package/src/incubator/dialog/dialog.api.json +54 -0
- package/src/{components → incubator}/dialog/dialogHeader.api.json +2 -2
- package/src/incubator/dialog/index.d.ts +15 -0
- package/src/incubator/dialog/index.js +218 -0
- package/src/{components → incubator}/dialog/types.d.ts +19 -0
- package/src/{components → incubator}/dialog/types.js +3 -1
- package/src/{components → incubator}/dialog/useDialogContent.d.ts +1 -1
- package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
- package/src/incubator/expandableOverlay/index.d.ts +3 -42
- package/src/incubator/expandableOverlay/index.js +4 -1
- package/src/{hooks/useHiddenLocation/index.d.ts → incubator/hooks/useHiddenLocation.d.ts} +1 -1
- package/src/{hooks/useHiddenLocation/index.web.d.ts → incubator/hooks/useHiddenLocation.web.d.ts} +1 -1
- package/src/incubator/index.d.ts +2 -0
- package/src/incubator/index.js +2 -0
- package/src/{components → incubator}/panView/index.d.ts +3 -3
- package/src/{components → incubator}/panView/index.js +4 -4
- package/src/{components → incubator}/panView/usePanGesture.d.ts +1 -1
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +10 -3
- package/src/index.js +162 -42
- package/src/testkit/index.d.ts +1 -1
- package/src/testkit/index.js +1 -1
- package/src/testkit/new/Component.driver.d.ts +1 -4
- package/src/testkit/new/Component.driver.js +3 -3
- package/lib/components/HighlighterOverlayView/index.js +0 -49
- package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +0 -51
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +0 -26
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +0 -91
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +0 -274
- package/lib/components/SafeArea/index.d.ts +0 -10
- package/lib/components/SafeArea/index.js +0 -11
- package/panView.d.ts +0 -2
- package/panView.js +0 -1
- /package/lib/components/{HighlighterOverlayView/index.web.js → HighlighterOverlayView.web.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts → KeyboardInput/utils/EventEmitterManager.d.ts} +0 -0
- /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js → KeyboardInput/utils/EventEmitterManager.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardAwareInsetsView → KeyboardTracking}/keyboardAwareInsetsView.api.json +0 -0
- /package/src/{components → incubator}/dialog/Dialog.driver.new.d.ts +0 -0
- /package/src/{components → incubator}/dialog/Dialog.driver.new.js +0 -0
- /package/src/{components → incubator}/dialog/DialogHeader.d.ts +0 -0
- /package/src/{components → incubator}/dialog/DialogHeader.js +0 -0
- /package/src/{components → incubator}/dialog/useDialogContent.js +0 -0
- /package/src/{hooks/useHiddenLocation/index.js → incubator/hooks/useHiddenLocation.js} +0 -0
- /package/src/{hooks/useHiddenLocation/index.web.js → incubator/hooks/useHiddenLocation.web.js} +0 -0
- /package/src/{components → incubator}/panView/panningUtil.d.ts +0 -0
- /package/src/{components → incubator}/panView/panningUtil.js +0 -0
- /package/src/{components → incubator}/panView/usePanGesture.js +0 -0
package/src/components/index.js
CHANGED
|
@@ -110,6 +110,21 @@ export default {
|
|
|
110
110
|
get PageControl() {
|
|
111
111
|
return require('./pageControl').default;
|
|
112
112
|
},
|
|
113
|
+
get PanningProvider() {
|
|
114
|
+
return require('./panningViews/panningProvider').default;
|
|
115
|
+
},
|
|
116
|
+
get PanGestureView() {
|
|
117
|
+
return require('./panningViews/panGestureView').default;
|
|
118
|
+
},
|
|
119
|
+
get PanListenerView() {
|
|
120
|
+
return require('./panningViews/panListenerView').default;
|
|
121
|
+
},
|
|
122
|
+
get PanDismissibleView() {
|
|
123
|
+
return require('./panningViews/panDismissibleView').default;
|
|
124
|
+
},
|
|
125
|
+
get PanResponderView() {
|
|
126
|
+
return require('./panningViews/panResponderView').default;
|
|
127
|
+
},
|
|
113
128
|
get Picker() {
|
|
114
129
|
return require('./picker').default;
|
|
115
130
|
},
|
|
@@ -143,6 +158,10 @@ export default {
|
|
|
143
158
|
get RadioGroup() {
|
|
144
159
|
return require('./radioButton').RadioGroup;
|
|
145
160
|
},
|
|
161
|
+
|
|
162
|
+
get SharedTransition() {
|
|
163
|
+
return require('./sharedTransition').default;
|
|
164
|
+
},
|
|
146
165
|
get StackAggregator() {
|
|
147
166
|
return require('./stackAggregator').default;
|
|
148
167
|
},
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export let MarqueeDirections = /*#__PURE__*/function (MarqueeDirections) {
|
|
2
2
|
MarqueeDirections["RIGHT"] = "RIGHT";
|
|
3
|
-
//LTR
|
|
4
3
|
MarqueeDirections["LEFT"] = "LEFT";
|
|
5
|
-
//RTL
|
|
6
4
|
MarqueeDirections["UP"] = "UP";
|
|
7
|
-
|
|
8
|
-
MarqueeDirections["DOWN"] = "DOWN"; //Up To Bottom
|
|
5
|
+
MarqueeDirections["DOWN"] = "DOWN";
|
|
9
6
|
return MarqueeDirections;
|
|
10
7
|
}({});
|
|
@@ -40,11 +40,6 @@ export interface ModalProps extends RNModalProps {
|
|
|
40
40
|
* Send additional props to the KeyboardAvoidingView (iOS only)
|
|
41
41
|
*/
|
|
42
42
|
keyboardAvoidingViewProps?: KeyboardAvoidingViewProps;
|
|
43
|
-
/**
|
|
44
|
-
* Fix RNModal's interaction with react-native-reanimated (Android only, default: true)
|
|
45
|
-
* See this https://github.com/software-mansion/react-native-reanimated/issues/6659#issuecomment-2704931585
|
|
46
|
-
*/
|
|
47
|
-
fixReanimatedInteraction?: boolean;
|
|
48
43
|
}
|
|
49
44
|
/**
|
|
50
45
|
* @description: Component that present content on top of the invoking screen
|
|
@@ -55,7 +55,6 @@ class Modal extends Component {
|
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
57
57
|
const {
|
|
58
|
-
fixReanimatedInteraction = true,
|
|
59
58
|
blurView,
|
|
60
59
|
enableModalBlur,
|
|
61
60
|
visible,
|
|
@@ -77,19 +76,16 @@ class Modal extends Component {
|
|
|
77
76
|
style: [styles.fill, keyboardAvoidingViewProps?.style]
|
|
78
77
|
} : {};
|
|
79
78
|
const Container = blurView ? blurView : defaultContainer;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</GestureContainer>
|
|
91
|
-
</RNModal>
|
|
92
|
-
</HackContainer>;
|
|
79
|
+
return <RNModal visible={Boolean(visible)} {...others}>
|
|
80
|
+
<GestureContainer {...gestureContainerProps}>
|
|
81
|
+
<KeyboardAvoidingContainer {...keyboardAvoidingContainerProps}>
|
|
82
|
+
<Container style={styles.fill} blurType="light">
|
|
83
|
+
{this.renderTouchableOverlay()}
|
|
84
|
+
{this.props.children}
|
|
85
|
+
</Container>
|
|
86
|
+
</KeyboardAvoidingContainer>
|
|
87
|
+
</GestureContainer>
|
|
88
|
+
</RNModal>;
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
const styles = StyleSheet.create({
|
|
@@ -38,11 +38,6 @@
|
|
|
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)"
|
|
46
41
|
}
|
|
47
42
|
],
|
|
48
43
|
"snippet": [
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PanningContext from "./panningContext";
|
|
3
|
+
function asPanViewConsumer(WrappedComponent) {
|
|
4
|
+
class PanViewConsumer extends Component {
|
|
5
|
+
saveRef = r => {
|
|
6
|
+
this.contentRef = r;
|
|
7
|
+
};
|
|
8
|
+
render() {
|
|
9
|
+
return <PanningContext.Consumer>
|
|
10
|
+
{context => <WrappedComponent ref={this.saveRef} context={context} {...this.props} />}
|
|
11
|
+
</PanningContext.Consumer>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return PanViewConsumer;
|
|
15
|
+
}
|
|
16
|
+
export default asPanViewConsumer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { PanningDirections, PanAmountsProps } from './panningProvider';
|
|
4
|
+
export interface DismissibleAnimationProps {
|
|
5
|
+
/**
|
|
6
|
+
* The return animation speed (default is 20)
|
|
7
|
+
*/
|
|
8
|
+
speed?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The return animation bounciness (default is 6)
|
|
11
|
+
*/
|
|
12
|
+
bounciness?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The dismiss animation duration (default is 280)
|
|
15
|
+
*/
|
|
16
|
+
duration?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PanDismissibleViewProps {
|
|
19
|
+
/**
|
|
20
|
+
* Additional styling
|
|
21
|
+
*/
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
/**
|
|
24
|
+
* The directions of the allowed pan (default allows all directions)
|
|
25
|
+
* Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###)
|
|
26
|
+
*/
|
|
27
|
+
directions?: PanningDirections[];
|
|
28
|
+
/**
|
|
29
|
+
* onDismiss callback
|
|
30
|
+
*/
|
|
31
|
+
onDismiss?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Some animation options to choose from, defaults are set for:
|
|
34
|
+
* speed - the animation speed (default is 20)
|
|
35
|
+
* bounciness - the animation bounciness (default is 6)
|
|
36
|
+
* duration - the dismiss animation duration (default is 280)
|
|
37
|
+
*/
|
|
38
|
+
animationOptions?: DismissibleAnimationProps;
|
|
39
|
+
/**
|
|
40
|
+
* Override the default threshold (height/2 and width/2) with different values.
|
|
41
|
+
*/
|
|
42
|
+
threshold?: PanAmountsProps;
|
|
43
|
+
/**
|
|
44
|
+
* Allow diagonal dismiss, this is false by default,
|
|
45
|
+
* since it looks better and most cases.
|
|
46
|
+
*/
|
|
47
|
+
allowDiagonalDismiss?: boolean;
|
|
48
|
+
children?: React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
declare const _default: React.ComponentClass<PanDismissibleViewProps, any>;
|
|
51
|
+
export default _default;
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import _isUndefined from "lodash/isUndefined";
|
|
2
|
+
import _get from "lodash/get";
|
|
3
|
+
import _noop from "lodash/noop";
|
|
4
|
+
import React, { PureComponent } from 'react';
|
|
5
|
+
import { Animated } from 'react-native';
|
|
6
|
+
import { Constants } from "../../commons/new";
|
|
7
|
+
import asPanViewConsumer from "./asPanViewConsumer";
|
|
8
|
+
import PanningProvider from "./panningProvider";
|
|
9
|
+
const DEFAULT_DIRECTIONS = [PanningProvider.Directions.UP, PanningProvider.Directions.DOWN, PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT];
|
|
10
|
+
const DEFAULT_SPEED = 20;
|
|
11
|
+
const DEFAULT_BOUNCINESS = 6;
|
|
12
|
+
const DEFAULT_DISMISS_ANIMATION_DURATION = 280;
|
|
13
|
+
const DEFAULT_ANIMATION_OPTIONS = {
|
|
14
|
+
speed: DEFAULT_SPEED,
|
|
15
|
+
bounciness: DEFAULT_BOUNCINESS,
|
|
16
|
+
duration: DEFAULT_DISMISS_ANIMATION_DURATION
|
|
17
|
+
};
|
|
18
|
+
const MAXIMUM_DRAGS_AFTER_SWIPE = 2;
|
|
19
|
+
/**
|
|
20
|
+
* @description: PanDismissibleView component created to making listening to swipe and drag events easier,
|
|
21
|
+
* @notes: Has to be used as a child of a PanningProvider that also has a PanListenerView.
|
|
22
|
+
* The PanListenerView is the one that sends the drag\swipe events.
|
|
23
|
+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanDismissibleView/PanDismissibleView.gif?raw=true
|
|
24
|
+
*/
|
|
25
|
+
class PanDismissibleView extends PureComponent {
|
|
26
|
+
static displayName = 'IGNORE';
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
directions: DEFAULT_DIRECTIONS,
|
|
29
|
+
animationOptions: DEFAULT_ANIMATION_OPTIONS,
|
|
30
|
+
onDismiss: _noop,
|
|
31
|
+
allowDiagonalDismiss: false
|
|
32
|
+
};
|
|
33
|
+
shouldDismissAfterReset = false;
|
|
34
|
+
ref = React.createRef();
|
|
35
|
+
animTranslateX = new Animated.Value(0);
|
|
36
|
+
animTranslateY = new Animated.Value(0);
|
|
37
|
+
left = 0;
|
|
38
|
+
top = 0;
|
|
39
|
+
width = 0;
|
|
40
|
+
height = 0;
|
|
41
|
+
thresholdX = 0;
|
|
42
|
+
thresholdY = 0;
|
|
43
|
+
swipe = {};
|
|
44
|
+
counter = 0;
|
|
45
|
+
constructor(props) {
|
|
46
|
+
super(props);
|
|
47
|
+
this.state = {
|
|
48
|
+
isAnimating: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
componentDidUpdate(prevProps) {
|
|
52
|
+
const {
|
|
53
|
+
isAnimating
|
|
54
|
+
} = this.state;
|
|
55
|
+
const {
|
|
56
|
+
isPanning,
|
|
57
|
+
dragDeltas,
|
|
58
|
+
swipeDirections
|
|
59
|
+
} = this.props.context;
|
|
60
|
+
const {
|
|
61
|
+
isPanning: prevIsPanning,
|
|
62
|
+
dragDeltas: prevDragDeltas,
|
|
63
|
+
swipeDirections: prevSwipeDirections
|
|
64
|
+
} = prevProps.context;
|
|
65
|
+
if (isPanning !== prevIsPanning) {
|
|
66
|
+
if (isPanning && !isAnimating) {
|
|
67
|
+
// do not start a new pan if we're still animating
|
|
68
|
+
this.onPanStart();
|
|
69
|
+
} else {
|
|
70
|
+
this.onPanEnd();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (isPanning && (dragDeltas.x || dragDeltas.y) && (dragDeltas.x !== prevDragDeltas.x || dragDeltas.y !== prevDragDeltas.y)) {
|
|
74
|
+
this.onDrag(dragDeltas);
|
|
75
|
+
}
|
|
76
|
+
if (isPanning && (swipeDirections.x || swipeDirections.y) && (swipeDirections.x !== prevSwipeDirections.x || swipeDirections.y !== prevSwipeDirections.y)) {
|
|
77
|
+
this.onSwipe(swipeDirections);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
onLayout = event => {
|
|
81
|
+
if (this.height === 0) {
|
|
82
|
+
const layout = event.nativeEvent.layout;
|
|
83
|
+
const {
|
|
84
|
+
threshold
|
|
85
|
+
} = this.props;
|
|
86
|
+
this.height = layout.height;
|
|
87
|
+
this.thresholdY = _get(threshold, 'y', layout.height / 2);
|
|
88
|
+
this.width = layout.width;
|
|
89
|
+
this.thresholdX = _get(threshold, 'x', layout.width / 2);
|
|
90
|
+
this.initPositions();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
initPositions = (extraDataForSetState, runAfterSetState) => {
|
|
94
|
+
this.setNativeProps(0, 0);
|
|
95
|
+
this.animTranslateX = new Animated.Value(0);
|
|
96
|
+
this.animTranslateY = new Animated.Value(0);
|
|
97
|
+
this.setState({
|
|
98
|
+
...extraDataForSetState
|
|
99
|
+
}, runAfterSetState);
|
|
100
|
+
};
|
|
101
|
+
onPanStart = () => {
|
|
102
|
+
this.swipe = {};
|
|
103
|
+
this.counter = 0;
|
|
104
|
+
};
|
|
105
|
+
onDrag = deltas => {
|
|
106
|
+
const left = deltas.x ? Math.round(deltas.x) : 0;
|
|
107
|
+
const top = deltas.y ? Math.round(deltas.y) : 0;
|
|
108
|
+
this.setNativeProps(left, top);
|
|
109
|
+
if (this.swipe.x || this.swipe.y) {
|
|
110
|
+
if (this.counter < MAXIMUM_DRAGS_AFTER_SWIPE) {
|
|
111
|
+
this.counter += 1;
|
|
112
|
+
} else {
|
|
113
|
+
this.swipe = {};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
setNativeProps = (left, top) => {
|
|
118
|
+
if (this.ref.current) {
|
|
119
|
+
this.ref.current?.setNativeProps?.({
|
|
120
|
+
style: {
|
|
121
|
+
left,
|
|
122
|
+
top
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
this.left = left;
|
|
126
|
+
this.top = top;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
onSwipe = swipeDirections => {
|
|
130
|
+
this.swipe = swipeDirections;
|
|
131
|
+
};
|
|
132
|
+
onPanEnd = () => {
|
|
133
|
+
const {
|
|
134
|
+
directions = DEFAULT_DIRECTIONS
|
|
135
|
+
} = this.props;
|
|
136
|
+
if (this.swipe.x || this.swipe.y) {
|
|
137
|
+
const {
|
|
138
|
+
isRight,
|
|
139
|
+
isDown
|
|
140
|
+
} = this.getDismissAnimationDirection();
|
|
141
|
+
this._animateDismiss(isRight, isDown);
|
|
142
|
+
} else {
|
|
143
|
+
const endValue = {
|
|
144
|
+
x: Math.round(this.left),
|
|
145
|
+
y: Math.round(this.top)
|
|
146
|
+
};
|
|
147
|
+
if (directions.includes(PanningProvider.Directions.LEFT) && endValue.x <= -this.thresholdX || directions.includes(PanningProvider.Directions.RIGHT) && endValue.x >= this.thresholdX || directions.includes(PanningProvider.Directions.UP) && endValue.y <= -this.thresholdY || directions.includes(PanningProvider.Directions.DOWN) && endValue.y >= this.thresholdY) {
|
|
148
|
+
const {
|
|
149
|
+
isRight,
|
|
150
|
+
isDown
|
|
151
|
+
} = this.getDismissAnimationDirection();
|
|
152
|
+
this._animateDismiss(isRight, isDown);
|
|
153
|
+
} else {
|
|
154
|
+
this.resetPosition();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
resetPosition = () => {
|
|
159
|
+
const {
|
|
160
|
+
animationOptions
|
|
161
|
+
} = this.props;
|
|
162
|
+
const {
|
|
163
|
+
speed,
|
|
164
|
+
bounciness
|
|
165
|
+
} = animationOptions || DEFAULT_ANIMATION_OPTIONS;
|
|
166
|
+
const toX = -this.left;
|
|
167
|
+
const toY = -this.top;
|
|
168
|
+
const animations = [];
|
|
169
|
+
if (!_isUndefined(toX)) {
|
|
170
|
+
animations.push(Animated.spring(this.animTranslateX, {
|
|
171
|
+
toValue: Math.round(toX),
|
|
172
|
+
useNativeDriver: true,
|
|
173
|
+
speed,
|
|
174
|
+
bounciness
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
if (!_isUndefined(toY)) {
|
|
178
|
+
animations.push(Animated.spring(this.animTranslateY, {
|
|
179
|
+
toValue: Math.round(toY),
|
|
180
|
+
useNativeDriver: true,
|
|
181
|
+
speed,
|
|
182
|
+
bounciness
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
this.setState({
|
|
186
|
+
isAnimating: true
|
|
187
|
+
}, () => {
|
|
188
|
+
Animated.parallel(animations).start(this.onResetPositionFinished);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
onResetPositionFinished = () => {
|
|
192
|
+
const runAfterSetState = this.shouldDismissAfterReset ? this.animateDismiss : undefined;
|
|
193
|
+
this.shouldDismissAfterReset = false;
|
|
194
|
+
this.initPositions({
|
|
195
|
+
isAnimating: false
|
|
196
|
+
}, runAfterSetState);
|
|
197
|
+
};
|
|
198
|
+
getDismissAnimationDirection = () => {
|
|
199
|
+
const {
|
|
200
|
+
allowDiagonalDismiss
|
|
201
|
+
} = this.props;
|
|
202
|
+
const {
|
|
203
|
+
swipeDirections,
|
|
204
|
+
swipeVelocities,
|
|
205
|
+
dragDirections,
|
|
206
|
+
dragDeltas
|
|
207
|
+
} = this.props.context;
|
|
208
|
+
const hasHorizontalSwipe = !_isUndefined(swipeDirections.x);
|
|
209
|
+
const hasVerticalSwipe = !_isUndefined(swipeDirections.y);
|
|
210
|
+
let isRight;
|
|
211
|
+
let isDown;
|
|
212
|
+
if (hasHorizontalSwipe || hasVerticalSwipe) {
|
|
213
|
+
if (!allowDiagonalDismiss && hasHorizontalSwipe && hasVerticalSwipe) {
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
if (Math.abs(swipeVelocities.y) > Math.abs(swipeVelocities.x)) {
|
|
216
|
+
isDown = swipeDirections.y === PanningProvider.Directions.DOWN;
|
|
217
|
+
} else {
|
|
218
|
+
isRight = swipeDirections.x === PanningProvider.Directions.RIGHT;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
isRight,
|
|
222
|
+
isDown
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
if (hasHorizontalSwipe) {
|
|
226
|
+
isRight = swipeDirections.x === PanningProvider.Directions.RIGHT;
|
|
227
|
+
}
|
|
228
|
+
if (hasVerticalSwipe) {
|
|
229
|
+
isDown = swipeDirections.y === PanningProvider.Directions.DOWN;
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
// got here from a drag beyond threshold
|
|
233
|
+
const hasHorizontalDrag = !_isUndefined(dragDirections.x);
|
|
234
|
+
const hasVerticalDrag = !_isUndefined(dragDirections.y);
|
|
235
|
+
if (!allowDiagonalDismiss && hasHorizontalDrag && hasVerticalDrag) {
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
if (Math.abs(dragDeltas.y) > Math.abs(dragDeltas.x)) {
|
|
238
|
+
isDown = dragDirections.y === PanningProvider.Directions.DOWN;
|
|
239
|
+
} else {
|
|
240
|
+
isRight = dragDirections.x === PanningProvider.Directions.RIGHT;
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
isRight,
|
|
244
|
+
isDown
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (hasHorizontalDrag) {
|
|
248
|
+
isRight = dragDirections.x === PanningProvider.Directions.RIGHT;
|
|
249
|
+
}
|
|
250
|
+
if (hasVerticalDrag) {
|
|
251
|
+
isDown = dragDirections.y === PanningProvider.Directions.DOWN;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
isRight,
|
|
256
|
+
isDown
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// Send undefined to not animate in the horizontal\vertical direction
|
|
261
|
+
// isRight === true --> animate to the right
|
|
262
|
+
// isRight === false --> animate to the left
|
|
263
|
+
// isDown === true --> animate to the bottom
|
|
264
|
+
// isDown === false --> animate to the top
|
|
265
|
+
animateDismiss = () => {
|
|
266
|
+
const {
|
|
267
|
+
isAnimating
|
|
268
|
+
} = this.state;
|
|
269
|
+
if (isAnimating) {
|
|
270
|
+
this.shouldDismissAfterReset = true;
|
|
271
|
+
} else {
|
|
272
|
+
const {
|
|
273
|
+
directions = []
|
|
274
|
+
} = this.props;
|
|
275
|
+
const hasUp = directions.includes(PanningProvider.Directions.UP);
|
|
276
|
+
const hasRight = directions.includes(PanningProvider.Directions.RIGHT);
|
|
277
|
+
const hasLeft = directions.includes(PanningProvider.Directions.LEFT);
|
|
278
|
+
const hasDown = !hasUp && !hasLeft && !hasRight; // default
|
|
279
|
+
const verticalDismiss = hasDown ? true : hasUp ? false : undefined;
|
|
280
|
+
const horizontalDismiss = hasRight ? true : hasLeft ? false : undefined;
|
|
281
|
+
this._animateDismiss(horizontalDismiss, verticalDismiss);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
_animateDismiss = (isRight, isDown) => {
|
|
285
|
+
const {
|
|
286
|
+
animationOptions
|
|
287
|
+
} = this.props;
|
|
288
|
+
const {
|
|
289
|
+
duration
|
|
290
|
+
} = animationOptions || DEFAULT_ANIMATION_OPTIONS;
|
|
291
|
+
const animations = [];
|
|
292
|
+
let toX;
|
|
293
|
+
let toY;
|
|
294
|
+
if (!_isUndefined(isRight)) {
|
|
295
|
+
const maxSize = Constants.screenWidth + this.width;
|
|
296
|
+
toX = isRight ? maxSize : -maxSize;
|
|
297
|
+
}
|
|
298
|
+
if (!_isUndefined(isDown)) {
|
|
299
|
+
const maxSize = Constants.screenHeight + this.height;
|
|
300
|
+
toY = isDown ? maxSize : -maxSize;
|
|
301
|
+
}
|
|
302
|
+
if (!_isUndefined(toX)) {
|
|
303
|
+
animations.push(Animated.timing(this.animTranslateX, {
|
|
304
|
+
toValue: Math.round(toX),
|
|
305
|
+
useNativeDriver: true,
|
|
306
|
+
duration
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
if (!_isUndefined(toY)) {
|
|
310
|
+
animations.push(Animated.timing(this.animTranslateY, {
|
|
311
|
+
toValue: Math.round(toY),
|
|
312
|
+
useNativeDriver: true,
|
|
313
|
+
duration
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
this.setState({
|
|
317
|
+
isAnimating: true
|
|
318
|
+
}, () => {
|
|
319
|
+
Animated.parallel(animations).start(this.onDismissAnimationFinished);
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
onDismissAnimationFinished = ({
|
|
323
|
+
finished
|
|
324
|
+
}) => {
|
|
325
|
+
if (finished) {
|
|
326
|
+
this.props.onDismiss?.();
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
render() {
|
|
330
|
+
const {
|
|
331
|
+
style
|
|
332
|
+
} = this.props;
|
|
333
|
+
const {
|
|
334
|
+
isAnimating
|
|
335
|
+
} = this.state;
|
|
336
|
+
const transform = isAnimating ? [{
|
|
337
|
+
translateX: this.animTranslateX
|
|
338
|
+
}, {
|
|
339
|
+
translateY: this.animTranslateY
|
|
340
|
+
}] : [];
|
|
341
|
+
return <Animated.View
|
|
342
|
+
// @ts-ignore
|
|
343
|
+
ref={this.ref} style={[style, {
|
|
344
|
+
transform
|
|
345
|
+
}]} onLayout={this.onLayout}>
|
|
346
|
+
{this.props.children}
|
|
347
|
+
</Animated.View>;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
export default asPanViewConsumer(PanDismissibleView);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export declare enum GestureDirections {
|
|
4
|
+
UP = "up",
|
|
5
|
+
DOWN = "down"
|
|
6
|
+
}
|
|
7
|
+
export interface PanGestureViewProps {
|
|
8
|
+
/**
|
|
9
|
+
* Additional styling
|
|
10
|
+
*/
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
/**
|
|
13
|
+
* onDismiss callback
|
|
14
|
+
*/
|
|
15
|
+
onDismiss?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* The direction of the allowed pan (default is down)
|
|
18
|
+
*/
|
|
19
|
+
direction?: GestureDirections | `${GestureDirections}`;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.ForwardRefExoticComponent<PanGestureViewProps & React.RefAttributes<any>>;
|
|
23
|
+
export default _default;
|