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.
Files changed (202) hide show
  1. package/babel.config.js +0 -12
  2. package/index.js +0 -1
  3. package/lib/android/build.gradle +5 -5
  4. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +2 -0
  5. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +23 -31
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +30 -0
  7. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +34 -0
  8. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  9. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +33 -0
  10. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +53 -0
  11. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +54 -0
  12. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +28 -0
  13. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +36 -0
  14. package/lib/components/{HighlighterOverlayView/index.d.ts → HighlighterOverlayView.d.ts} +1 -1
  15. package/lib/components/HighlighterOverlayView.js +40 -0
  16. package/lib/components/{HighlighterOverlayView/index.web.d.ts → HighlighterOverlayView.web.d.ts} +1 -1
  17. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.android.d.ts +2 -5
  18. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +28 -0
  19. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  20. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  21. package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.d.ts +0 -3
  22. package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.js +1 -1
  23. package/lib/components/Keyboard/{KeyboardAccessoryView/index.d.ts → KeyboardInput/KeyboardAccessoryView.d.ts} +1 -11
  24. package/lib/components/Keyboard/{KeyboardAccessoryView/index.js → KeyboardInput/KeyboardAccessoryView.js} +5 -31
  25. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.d.ts → KeyboardInput/KeyboardRegistry.d.ts} +1 -1
  26. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.js → KeyboardInput/KeyboardRegistry.js} +1 -1
  27. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/__tests__/KeyboardRegistry.spec.js +1 -1
  28. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/keyboardAccessoryView.api.json +5 -5
  29. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/keyboardRegistry.api.json +9 -9
  30. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +11 -0
  31. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +17 -0
  32. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager → KeyboardInput/utils}/__tests__/EventEmitterManager.spec.js +1 -1
  33. package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.d.ts → KeyboardTracking/KeyboardAwareInsetsView.d.ts} +1 -1
  34. package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.js → KeyboardTracking/KeyboardAwareInsetsView.js} +1 -1
  35. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +4 -1
  36. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.js +8 -5
  37. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.d.ts +2 -2
  38. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/keyboardTrackingView.api.json +20 -11
  39. package/lib/components/Keyboard/index.d.ts +6 -6
  40. package/lib/components/Keyboard/index.js +6 -6
  41. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +7 -21
  42. package/lib/components/SafeArea/SafeAreaInsetsManager.js +31 -95
  43. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  44. package/lib/components/SafeArea/SafeAreaSpacerView.js +9 -63
  45. package/lib/components/index.d.ts +1 -1
  46. package/lib/components/index.js +1 -1
  47. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +8 -52
  48. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +7 -1
  49. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  50. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +41 -109
  51. package/lib/package.json +1 -1
  52. package/lib/react-native.config.js +3 -1
  53. package/metro.config.js +2 -2
  54. package/package.json +25 -25
  55. package/panningViews.d.ts +2 -0
  56. package/panningViews.js +1 -0
  57. package/react-native.config.js +3 -1
  58. package/scripts/release/prReleaseNotesCommon.js +15 -4
  59. package/sharedTransition.d.ts +2 -0
  60. package/sharedTransition.js +1 -0
  61. package/src/commons/Constants.js +5 -2
  62. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +1 -5
  63. package/src/components/actionSheet/index.d.ts +12 -2
  64. package/src/components/actionSheet/index.js +42 -3
  65. package/src/components/badge/index.d.ts +47 -107
  66. package/src/components/button/button.api.json +1 -1
  67. package/src/components/button/index.d.ts +23 -53
  68. package/src/components/button/types.d.ts +1 -0
  69. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  70. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  71. package/src/components/dateTimePicker/index.d.ts +5 -186
  72. package/src/components/dateTimePicker/index.js +4 -3
  73. package/src/components/dialog/DialogDismissibleView.d.ts +34 -0
  74. package/src/components/dialog/DialogDismissibleView.js +184 -0
  75. package/src/components/dialog/OverlayFadingBackground.d.ts +14 -0
  76. package/src/components/dialog/OverlayFadingBackground.js +45 -0
  77. package/src/components/dialog/dialog.api.json +37 -31
  78. package/src/components/dialog/index.d.ts +105 -13
  79. package/src/components/dialog/index.js +212 -204
  80. package/src/components/drawer/Swipeable.js +2 -1
  81. package/src/components/drawer/index.js +25 -31
  82. package/src/components/fadedScrollView/index.js +2 -7
  83. package/src/components/featureHighlight/index.d.ts +1 -1
  84. package/src/components/index.js +19 -0
  85. package/src/components/marquee/types.js +1 -4
  86. package/src/components/modal/index.d.ts +0 -5
  87. package/src/components/modal/index.js +10 -14
  88. package/src/components/modal/modal.api.json +0 -5
  89. package/src/components/panningViews/asPanViewConsumer.d.ts +3 -0
  90. package/src/components/panningViews/asPanViewConsumer.js +16 -0
  91. package/src/components/panningViews/panDismissibleView.d.ts +51 -0
  92. package/src/components/panningViews/panDismissibleView.js +350 -0
  93. package/src/components/panningViews/panGestureView.d.ts +23 -0
  94. package/src/components/panningViews/panGestureView.js +156 -0
  95. package/src/components/panningViews/panListenerView.d.ts +66 -0
  96. package/src/components/panningViews/panListenerView.js +155 -0
  97. package/src/components/panningViews/panResponderView.d.ts +19 -0
  98. package/src/components/panningViews/panResponderView.js +79 -0
  99. package/src/components/panningViews/panningContext.d.ts +3 -0
  100. package/src/components/panningViews/panningContext.js +4 -0
  101. package/src/components/panningViews/panningProvider.d.ts +73 -0
  102. package/src/components/panningViews/panningProvider.js +101 -0
  103. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  104. package/src/components/picker/Picker.driver.new.js +3 -3
  105. package/src/components/picker/PickerItem.js +20 -6
  106. package/src/components/picker/PickerPresenter.d.ts +1 -0
  107. package/src/components/picker/PickerPresenter.js +23 -1
  108. package/src/components/picker/api/picker.api.json +1 -0
  109. package/src/components/picker/api/pickerItem.api.json +5 -0
  110. package/src/components/picker/helpers/useFieldType.d.ts +23 -53
  111. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  112. package/src/components/picker/helpers/usePickerLabel.js +3 -2
  113. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  114. package/src/components/picker/helpers/usePickerMigrationWarnings.js +12 -0
  115. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  116. package/src/components/picker/helpers/usePickerSearch.js +8 -4
  117. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  118. package/src/components/picker/helpers/usePickerSelection.js +10 -2
  119. package/src/components/picker/index.js +22 -4
  120. package/src/components/picker/types.d.ts +24 -1
  121. package/src/components/segmentedControl/index.js +3 -3
  122. package/src/components/sharedTransition/ShareTransitionContext.js +3 -0
  123. package/src/components/sharedTransition/SharedArea.js +153 -0
  124. package/src/components/sharedTransition/SourceElement.js +44 -0
  125. package/src/components/sharedTransition/TargetElement.js +38 -0
  126. package/src/components/sharedTransition/index.js +9 -0
  127. package/src/components/slider/GradientSlider.d.ts +1 -1
  128. package/src/components/sortableGridList/SortableItem.js +4 -13
  129. package/src/components/sortableList/SortableListItem.js +4 -13
  130. package/src/components/stackAggregator/index.js +11 -16
  131. package/src/components/text/Text.driver.new.d.ts +2 -2
  132. package/src/components/text/Text.driver.new.js +2 -2
  133. package/src/components/textField/Input.js +1 -0
  134. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  135. package/src/components/textField/TextField.driver.new.js +2 -2
  136. package/src/components/textField/presets/outline.d.ts +46 -106
  137. package/src/components/textField/presets/underline.d.ts +46 -106
  138. package/src/components/textField/types.js +0 -1
  139. package/src/components/textField/usePreset.d.ts +44 -72
  140. package/src/components/timeline/types.js +0 -3
  141. package/src/incubator/dialog/dialog.api.json +54 -0
  142. package/src/{components → incubator}/dialog/dialogHeader.api.json +2 -2
  143. package/src/incubator/dialog/index.d.ts +15 -0
  144. package/src/incubator/dialog/index.js +218 -0
  145. package/src/{components → incubator}/dialog/types.d.ts +19 -0
  146. package/src/{components → incubator}/dialog/types.js +3 -1
  147. package/src/{components → incubator}/dialog/useDialogContent.d.ts +1 -1
  148. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  149. package/src/incubator/expandableOverlay/index.d.ts +3 -42
  150. package/src/incubator/expandableOverlay/index.js +4 -1
  151. package/src/{hooks/useHiddenLocation/index.d.ts → incubator/hooks/useHiddenLocation.d.ts} +1 -1
  152. package/src/{hooks/useHiddenLocation/index.web.d.ts → incubator/hooks/useHiddenLocation.web.d.ts} +1 -1
  153. package/src/incubator/index.d.ts +2 -0
  154. package/src/incubator/index.js +2 -0
  155. package/src/{components → incubator}/panView/index.d.ts +3 -3
  156. package/src/{components → incubator}/panView/index.js +4 -4
  157. package/src/{components → incubator}/panView/usePanGesture.d.ts +1 -1
  158. package/src/incubator/toast/index.js +1 -1
  159. package/src/index.d.ts +10 -3
  160. package/src/index.js +162 -42
  161. package/src/testkit/index.d.ts +1 -1
  162. package/src/testkit/index.js +1 -1
  163. package/src/testkit/new/Component.driver.d.ts +1 -4
  164. package/src/testkit/new/Component.driver.js +3 -3
  165. package/lib/components/HighlighterOverlayView/index.js +0 -49
  166. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +0 -51
  167. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +0 -26
  168. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +0 -91
  169. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +0 -274
  170. package/lib/components/SafeArea/index.d.ts +0 -10
  171. package/lib/components/SafeArea/index.js +0 -11
  172. package/panView.d.ts +0 -2
  173. package/panView.js +0 -1
  174. /package/lib/components/{HighlighterOverlayView/index.web.js → HighlighterOverlayView.web.js} +0 -0
  175. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.d.ts +0 -0
  176. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.js +0 -0
  177. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.d.ts +0 -0
  178. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.js +0 -0
  179. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  180. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  181. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  182. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  183. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.d.ts +0 -0
  184. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.js +0 -0
  185. /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts → KeyboardInput/utils/EventEmitterManager.d.ts} +0 -0
  186. /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js → KeyboardInput/utils/EventEmitterManager.js} +0 -0
  187. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  188. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  189. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.js +0 -0
  190. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.d.ts +0 -0
  191. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.js +0 -0
  192. /package/lib/components/Keyboard/{KeyboardAwareInsetsView → KeyboardTracking}/keyboardAwareInsetsView.api.json +0 -0
  193. /package/src/{components → incubator}/dialog/Dialog.driver.new.d.ts +0 -0
  194. /package/src/{components → incubator}/dialog/Dialog.driver.new.js +0 -0
  195. /package/src/{components → incubator}/dialog/DialogHeader.d.ts +0 -0
  196. /package/src/{components → incubator}/dialog/DialogHeader.js +0 -0
  197. /package/src/{components → incubator}/dialog/useDialogContent.js +0 -0
  198. /package/src/{hooks/useHiddenLocation/index.js → incubator/hooks/useHiddenLocation.js} +0 -0
  199. /package/src/{hooks/useHiddenLocation/index.web.js → incubator/hooks/useHiddenLocation.web.js} +0 -0
  200. /package/src/{components → incubator}/panView/panningUtil.d.ts +0 -0
  201. /package/src/{components → incubator}/panView/panningUtil.js +0 -0
  202. /package/src/{components → incubator}/panView/usePanGesture.js +0 -0
@@ -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
- //Bottom Up
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
- 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>;
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,3 @@
1
+ import React from 'react';
2
+ declare function asPanViewConsumer<PROPS>(WrappedComponent: React.ComponentType<any>): React.ComponentClass<PROPS>;
3
+ export default asPanViewConsumer;
@@ -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;