react-native-ui-lib 7.46.3 → 8.0.0

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 (214) hide show
  1. package/babel.config.js +12 -0
  2. package/incubator.d.ts +2 -2
  3. package/incubator.js +0 -2
  4. package/index.js +1 -0
  5. package/lib/android/build.gradle +5 -5
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
  7. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
  8. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  9. package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
  10. package/lib/components/HighlighterOverlayView/index.js +49 -0
  11. package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
  12. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
  13. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
  14. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  15. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  16. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
  17. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
  18. package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
  19. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
  20. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
  21. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
  22. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
  23. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
  24. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
  25. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
  26. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
  27. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
  28. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
  29. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
  30. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
  31. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
  32. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
  33. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
  34. package/lib/components/Keyboard/index.d.ts +6 -6
  35. package/lib/components/Keyboard/index.js +6 -6
  36. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
  37. package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
  38. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  39. package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
  40. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
  41. package/lib/components/SafeArea/index.d.ts +10 -0
  42. package/lib/components/SafeArea/index.js +11 -0
  43. package/lib/components/index.d.ts +1 -1
  44. package/lib/components/index.js +1 -1
  45. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +56 -8
  46. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
  47. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  48. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +134 -44
  49. package/lib/package.json +3 -3
  50. package/lib/react-native.config.js +1 -3
  51. package/metro.config.js +2 -2
  52. package/package.json +33 -32
  53. package/panView.d.ts +2 -0
  54. package/panView.js +1 -0
  55. package/scripts/release/prReleaseNotesCommon.js +15 -4
  56. package/src/commons/Constants.js +2 -5
  57. package/src/commons/modifiers.d.ts +1 -0
  58. package/src/commons/modifiers.js +5 -2
  59. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
  60. package/src/components/actionSheet/index.d.ts +2 -12
  61. package/src/components/actionSheet/index.js +3 -42
  62. package/src/components/animatedImage/index.js +12 -2
  63. package/src/components/badge/index.d.ts +107 -47
  64. package/src/components/button/button.api.json +1 -1
  65. package/src/components/button/index.d.ts +53 -23
  66. package/src/components/button/types.d.ts +0 -1
  67. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  68. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  69. package/src/components/dateTimePicker/index.d.ts +186 -5
  70. package/src/components/dateTimePicker/index.js +3 -4
  71. package/src/components/dialog/dialog.api.json +34 -35
  72. package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
  73. package/src/components/dialog/index.d.ts +13 -105
  74. package/src/components/dialog/index.js +205 -212
  75. package/src/{incubator → components}/dialog/types.d.ts +7 -19
  76. package/src/{incubator → components}/dialog/types.js +1 -3
  77. package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
  78. package/src/components/drawer/Swipeable.js +1 -2
  79. package/src/components/drawer/index.js +31 -25
  80. package/src/components/fadedScrollView/index.js +7 -2
  81. package/src/components/featureHighlight/index.d.ts +1 -1
  82. package/src/components/hint/index.d.ts +0 -8
  83. package/src/components/hint/index.js +4 -6
  84. package/src/components/image/index.js +4 -0
  85. package/src/components/index.js +0 -19
  86. package/src/components/marquee/types.js +4 -1
  87. package/src/components/modal/index.d.ts +5 -0
  88. package/src/components/modal/index.js +14 -10
  89. package/src/components/modal/modal.api.json +5 -0
  90. package/src/{incubator → components}/panView/index.d.ts +3 -3
  91. package/src/{incubator → components}/panView/index.js +4 -4
  92. package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
  93. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  94. package/src/components/picker/Picker.driver.new.js +3 -3
  95. package/src/components/picker/PickerItem.js +6 -20
  96. package/src/components/picker/PickerPresenter.d.ts +0 -1
  97. package/src/components/picker/PickerPresenter.js +1 -23
  98. package/src/components/picker/api/picker.api.json +0 -1
  99. package/src/components/picker/api/pickerItem.api.json +0 -5
  100. package/src/components/picker/helpers/useFieldType.d.ts +53 -23
  101. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  102. package/src/components/picker/helpers/usePickerLabel.js +2 -3
  103. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  104. package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
  105. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  106. package/src/components/picker/helpers/usePickerSearch.js +4 -8
  107. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  108. package/src/components/picker/helpers/usePickerSelection.js +2 -10
  109. package/src/components/picker/index.js +4 -22
  110. package/src/components/picker/types.d.ts +1 -24
  111. package/src/components/segmentedControl/index.js +3 -3
  112. package/src/components/slider/GradientSlider.d.ts +1 -1
  113. package/src/components/slider/index.js +1 -1
  114. package/src/components/sortableGridList/SortableItem.js +13 -4
  115. package/src/components/sortableList/SortableListItem.js +13 -4
  116. package/src/components/stackAggregator/index.js +16 -11
  117. package/src/components/tabController/TabPage.js +18 -14
  118. package/src/components/text/Text.driver.new.d.ts +2 -2
  119. package/src/components/text/Text.driver.new.js +2 -2
  120. package/src/components/text/index.js +2 -3
  121. package/src/components/textField/Input.js +0 -1
  122. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  123. package/src/components/textField/TextField.driver.new.js +2 -2
  124. package/src/components/textField/presets/outline.d.ts +106 -46
  125. package/src/components/textField/presets/underline.d.ts +106 -46
  126. package/src/components/textField/types.js +1 -0
  127. package/src/components/textField/usePreset.d.ts +72 -44
  128. package/src/components/timeline/types.js +3 -0
  129. package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
  130. package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
  131. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  132. package/src/incubator/expandableOverlay/index.d.ts +42 -3
  133. package/src/incubator/expandableOverlay/index.js +1 -4
  134. package/src/incubator/index.d.ts +0 -2
  135. package/src/incubator/index.js +0 -2
  136. package/src/incubator/slider/SliderPresenter.js +2 -1
  137. package/src/incubator/toast/index.js +1 -1
  138. package/src/index.d.ts +3 -10
  139. package/src/index.js +42 -162
  140. package/src/testkit/index.d.ts +1 -1
  141. package/src/testkit/index.js +1 -1
  142. package/src/testkit/new/Component.driver.d.ts +4 -1
  143. package/src/testkit/new/Component.driver.js +3 -3
  144. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
  145. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
  146. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
  147. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
  148. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
  149. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
  150. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
  151. package/lib/components/HighlighterOverlayView.js +0 -40
  152. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
  153. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
  154. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
  155. package/panningViews.d.ts +0 -2
  156. package/panningViews.js +0 -1
  157. package/react-native.config.js +0 -22
  158. package/sharedTransition.d.ts +0 -2
  159. package/sharedTransition.js +0 -1
  160. package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
  161. package/src/components/dialog/DialogDismissibleView.js +0 -184
  162. package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
  163. package/src/components/dialog/OverlayFadingBackground.js +0 -45
  164. package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
  165. package/src/components/panningViews/asPanViewConsumer.js +0 -16
  166. package/src/components/panningViews/panDismissibleView.d.ts +0 -51
  167. package/src/components/panningViews/panDismissibleView.js +0 -350
  168. package/src/components/panningViews/panGestureView.d.ts +0 -23
  169. package/src/components/panningViews/panGestureView.js +0 -156
  170. package/src/components/panningViews/panListenerView.d.ts +0 -66
  171. package/src/components/panningViews/panListenerView.js +0 -155
  172. package/src/components/panningViews/panResponderView.d.ts +0 -19
  173. package/src/components/panningViews/panResponderView.js +0 -79
  174. package/src/components/panningViews/panningContext.d.ts +0 -3
  175. package/src/components/panningViews/panningContext.js +0 -4
  176. package/src/components/panningViews/panningProvider.d.ts +0 -73
  177. package/src/components/panningViews/panningProvider.js +0 -101
  178. package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
  179. package/src/components/sharedTransition/SharedArea.js +0 -153
  180. package/src/components/sharedTransition/SourceElement.js +0 -44
  181. package/src/components/sharedTransition/TargetElement.js +0 -38
  182. package/src/components/sharedTransition/index.js +0 -9
  183. package/src/incubator/dialog/dialog.api.json +0 -54
  184. package/src/incubator/dialog/index.d.ts +0 -15
  185. package/src/incubator/dialog/index.js +0 -218
  186. /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
  187. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
  188. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
  189. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
  190. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
  191. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
  192. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
  193. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  194. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  195. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  196. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  197. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
  198. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
  199. /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
  200. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  201. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  202. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
  203. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
  204. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
  205. /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
  206. /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
  207. /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
  208. /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
  209. /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
  210. /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
  211. /package/src/{incubator → components}/panView/panningUtil.js +0 -0
  212. /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
  213. /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
  214. /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/index.web.js} +0 -0
@@ -1,155 +0,0 @@
1
- import _isUndefined from "lodash/isUndefined";
2
- import React, { PureComponent } from 'react';
3
- import { PanResponder } from 'react-native';
4
- import asPanViewConsumer from "./asPanViewConsumer";
5
- import PanningProvider from "./panningProvider";
6
- import View from "../view";
7
- const DEFAULT_DIRECTIONS = [PanningProvider.Directions.UP, PanningProvider.Directions.DOWN, PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT];
8
- const DEFAULT_PAN_SENSITIVITY = 5;
9
- const DEFAULT_SWIPE_VELOCITY = 1.8;
10
-
11
- /**
12
- * @description: PanListenerView component created to making listening to swipe and drag events easier
13
- * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/PanListenerScreen.tsx
14
- * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanListenerView/PanListenerView.gif?raw=true
15
- */
16
- class PanListenerView extends PureComponent {
17
- static displayName = 'IGNORE';
18
- static defaultProps = {
19
- directions: DEFAULT_DIRECTIONS,
20
- panSensitivity: DEFAULT_PAN_SENSITIVITY,
21
- swipeVelocitySensitivity: DEFAULT_SWIPE_VELOCITY
22
- };
23
- constructor(props) {
24
- super(props);
25
- const {
26
- isClickable
27
- } = props;
28
- this.panResponder = PanResponder.create({
29
- onStartShouldSetPanResponder: isClickable ? this.shouldPan : this.yes,
30
- onMoveShouldSetPanResponder: this.shouldPan,
31
- onStartShouldSetPanResponderCapture: this.no,
32
- onMoveShouldSetPanResponderCapture: this.no,
33
- onPanResponderGrant: this.handlePanStart,
34
- onPanResponderMove: this.handlePanMove,
35
- onPanResponderRelease: this.handlePanRelease,
36
- onPanResponderTerminate: this.handlePanTerminate
37
- });
38
- }
39
- yes = () => {
40
- return true;
41
- };
42
- no = () => {
43
- return false;
44
- };
45
- shouldPan = (_e, gestureState) => {
46
- // return true if user is swiping, return false if it's a single click
47
- const {
48
- dy,
49
- dx
50
- } = gestureState;
51
- const {
52
- directions,
53
- panSensitivity = DEFAULT_PAN_SENSITIVITY
54
- } = this.props;
55
- return Boolean(directions && (directions.includes(PanningProvider.Directions.UP) && dy < -panSensitivity || directions.includes(PanningProvider.Directions.DOWN) && dy > panSensitivity || directions.includes(PanningProvider.Directions.LEFT) && dx < -panSensitivity || directions.includes(PanningProvider.Directions.RIGHT) && dx > panSensitivity));
56
- };
57
- handlePanStart = () => {
58
- this.props.onPanStart?.();
59
- this.props.context?.onPanStart?.();
60
- };
61
- getSwipeDirection = ({
62
- vx,
63
- vy
64
- }) => {
65
- const {
66
- swipeVelocitySensitivity = DEFAULT_SWIPE_VELOCITY
67
- } = this.props;
68
- return this.getDirectionsOverSensitivity(vx, vy, swipeVelocitySensitivity);
69
- };
70
- getDragDirection = ({
71
- dx,
72
- dy
73
- }) => {
74
- return this.getDirectionsOverSensitivity(dx, dy, 0);
75
- };
76
- getDirectionsOverSensitivity = (x, y, sensitivity) => {
77
- const {
78
- directions = DEFAULT_DIRECTIONS
79
- } = this.props;
80
- const selectedDirections = {};
81
- const selectedAmounts = {};
82
- if (directions.includes(PanningProvider.Directions.LEFT) && x < -sensitivity) {
83
- selectedDirections.x = PanningProvider.Directions.LEFT;
84
- selectedAmounts.x = x;
85
- } else if (directions.includes(PanningProvider.Directions.RIGHT) && x > sensitivity) {
86
- selectedDirections.x = PanningProvider.Directions.RIGHT;
87
- selectedAmounts.x = x;
88
- }
89
- if (directions.includes(PanningProvider.Directions.UP) && y < -sensitivity) {
90
- selectedDirections.y = PanningProvider.Directions.UP;
91
- selectedAmounts.y = y;
92
- } else if (directions.includes(PanningProvider.Directions.DOWN) && y > sensitivity) {
93
- selectedDirections.y = PanningProvider.Directions.DOWN;
94
- selectedAmounts.y = y;
95
- }
96
- return {
97
- selectedDirections,
98
- selectedAmounts
99
- };
100
- };
101
- panResultHasValue = panResult => {
102
- return Boolean(panResult && (panResult.selectedDirections.x || panResult.selectedDirections.y));
103
- };
104
- handlePanMove = (_e, gestureState) => {
105
- const {
106
- onSwipe,
107
- onDrag,
108
- context
109
- } = this.props;
110
- const hasSwipe = !_isUndefined(onSwipe);
111
- const hasDrag = !_isUndefined(onDrag);
112
- const hasContext = !_isUndefined(context);
113
- let panResult;
114
- if (hasSwipe || hasContext) {
115
- panResult = this.getSwipeDirection(gestureState);
116
- }
117
- if (this.panResultHasValue(panResult)) {
118
- // @ts-ignore
119
- const data = {
120
- directions: panResult.selectedDirections,
121
- velocities: panResult.selectedAmounts
122
- };
123
- this.props.onSwipe?.(data);
124
- context?.onSwipe?.(data);
125
- } else if (hasDrag || hasContext) {
126
- panResult = this.getDragDirection(gestureState);
127
- if (this.panResultHasValue(panResult)) {
128
- const data = {
129
- directions: panResult.selectedDirections,
130
- deltas: panResult.selectedAmounts
131
- };
132
- this.props.onDrag?.(data);
133
- context?.onDrag?.(data);
134
- }
135
- }
136
- };
137
- handlePanRelease = () => {
138
- this.props.onPanRelease?.();
139
- this.props.context?.onPanRelease?.();
140
- };
141
- handlePanTerminate = () => {
142
- this.props.onPanTerminated?.();
143
- this.props.context?.onPanTerminated?.();
144
- };
145
- render() {
146
- const {
147
- children,
148
- ...others
149
- } = this.props;
150
- return <View {...others} {...this.panResponder.panHandlers}>
151
- {children}
152
- </View>;
153
- }
154
- }
155
- export default asPanViewConsumer(PanListenerView);
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { ViewProps } from '../view';
3
- import { PanLocationProps } from './panningProvider';
4
- export interface PanResponderViewProps extends ViewProps {
5
- /**
6
- * Will be called with the current location ({left, top}) when the pan has ended
7
- */
8
- onPanLocationChanged?: (location: PanLocationProps) => void;
9
- /**
10
- * Ignore panning events while this is true
11
- */
12
- ignorePanning?: boolean;
13
- /**
14
- * Allow the view to be animated (send animation via style; default is false)
15
- */
16
- isAnimated?: boolean;
17
- }
18
- declare const _default: React.ComponentClass<PanResponderViewProps, any>;
19
- export default _default;
@@ -1,79 +0,0 @@
1
- import React, { PureComponent } from 'react';
2
- import View from "../view";
3
- import asPanViewConsumer from "./asPanViewConsumer";
4
- /**
5
- * @description: panResponderView component created to making listening to swipe and drag events easier.
6
- * @notes: Has to be used as a child of a PanningProvider that also has a PanListenerView.
7
- * The PanListenerView is the one that sends the drag\swipe events.
8
- * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/PanResponderScreen.tsx
9
- * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/PanResponderView/PanResponderView.gif?raw=true
10
- */
11
- class PanResponderView extends PureComponent {
12
- static displayName = 'IGNORE';
13
- static defaultProps = {
14
- isAnimated: false
15
- };
16
- initialLeft = 0;
17
- initialTop = 0;
18
- ref = React.createRef();
19
- componentDidMount() {
20
- this.setNativeProps(this.initialLeft, this.initialTop);
21
- }
22
- componentDidUpdate(prevProps) {
23
- const {
24
- ignorePanning
25
- } = this.props;
26
- const {
27
- isPanning,
28
- dragDeltas
29
- } = this.props.context;
30
- const {
31
- isPanning: prevIsPanning,
32
- dragDeltas: prevDragDeltas
33
- } = prevProps.context;
34
- if (!ignorePanning && !isPanning && prevIsPanning) {
35
- this.onPanEnd();
36
- }
37
- if (!ignorePanning && isPanning && (dragDeltas.x || dragDeltas.y) && (dragDeltas.x !== prevDragDeltas.x || dragDeltas.y !== prevDragDeltas.y)) {
38
- this.onDrag(dragDeltas);
39
- }
40
- }
41
- onPanEnd() {
42
- const location = {
43
- left: this.left,
44
- top: this.top
45
- };
46
- this.initialLeft = this.left || this.initialLeft;
47
- this.initialTop = this.top || this.initialTop;
48
- this.props.onPanLocationChanged?.(location);
49
- //@ts-expect-error
50
- this.props.context.onPanLocationChanged?.(location);
51
- }
52
- onDrag(deltas) {
53
- const left = this.initialLeft + (deltas.x ? Math.round(deltas.x) : 0);
54
- const top = this.initialTop + (deltas.y ? Math.round(deltas.y) : 0);
55
- this.setNativeProps(left, top);
56
- }
57
- setNativeProps(left, top) {
58
- if (this.ref.current) {
59
- this.ref.current?.setNativeProps?.({
60
- style: {
61
- left,
62
- top
63
- }
64
- });
65
- this.left = left;
66
- this.top = top;
67
- }
68
- }
69
- render() {
70
- const {
71
- isAnimated,
72
- ...others
73
- } = this.props;
74
- return <View animated={isAnimated} ref={this.ref} pointerEvents={'box-none'} {...others}>
75
- {this.props.children}
76
- </View>;
77
- }
78
- }
79
- export default asPanViewConsumer(PanResponderView);
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const PanningContext: React.Context<{}>;
3
- export default PanningContext;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- const PanningContext = React.createContext({});
3
- PanningContext.displayName = 'IGNORE';
4
- export default PanningContext;
@@ -1,73 +0,0 @@
1
- import React, { Component } from 'react';
2
- export declare enum PanningDirectionsEnum {
3
- UP = "up",
4
- DOWN = "down",
5
- LEFT = "left",
6
- RIGHT = "right"
7
- }
8
- export type PanningDirectionsUnion = `${PanningDirectionsEnum}`;
9
- export type PanningDirections = PanningDirectionsEnum | PanningDirectionsUnion;
10
- export interface PanLocationProps {
11
- left?: number;
12
- top?: number;
13
- }
14
- export interface PanDirectionsProps {
15
- x?: PanningDirections;
16
- y?: PanningDirections;
17
- }
18
- export interface PanAmountsProps {
19
- x?: number;
20
- y?: number;
21
- }
22
- interface State {
23
- isPanning: boolean;
24
- wasTerminated: boolean;
25
- dragDirections: PanDirectionsProps;
26
- dragDeltas: PanAmountsProps;
27
- swipeDirections: PanDirectionsProps;
28
- swipeVelocities: PanAmountsProps;
29
- panLocation: PanLocationProps;
30
- }
31
- /**
32
- * @description: Wraps the panResponderView and panListenerView to provide a shared context
33
- */
34
- export default class PanningProvider extends Component<any, State> {
35
- static displayName: string;
36
- static Directions: typeof PanningDirectionsEnum;
37
- constructor(props: any);
38
- getProviderContextValue: () => {
39
- onPanStart: () => void;
40
- onPanRelease: () => void;
41
- onPanTerminated: () => void;
42
- isPanning: boolean;
43
- wasTerminated: boolean;
44
- onDrag: ({ directions, deltas }: {
45
- directions: PanDirectionsProps;
46
- deltas: PanAmountsProps;
47
- }) => void;
48
- dragDirections: PanDirectionsProps;
49
- dragDeltas: PanAmountsProps;
50
- onSwipe: ({ directions, velocities }: {
51
- directions: PanDirectionsProps;
52
- velocities: PanAmountsProps;
53
- }) => void;
54
- swipeDirections: PanDirectionsProps;
55
- swipeVelocities: PanAmountsProps;
56
- onPanLocationChanged: (location: PanLocationProps) => void;
57
- panLocation: PanLocationProps;
58
- };
59
- onPanStart: () => void;
60
- onPanRelease: () => void;
61
- onPanTerminated: () => void;
62
- onDrag: ({ directions, deltas }: {
63
- directions: PanDirectionsProps;
64
- deltas: PanAmountsProps;
65
- }) => void;
66
- onSwipe: ({ directions, velocities }: {
67
- directions: PanDirectionsProps;
68
- velocities: PanAmountsProps;
69
- }) => void;
70
- onPanLocationChanged: (location: PanLocationProps) => void;
71
- render(): React.JSX.Element;
72
- }
73
- export {};
@@ -1,101 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PanningContext from "./panningContext";
3
- export let PanningDirectionsEnum = /*#__PURE__*/function (PanningDirectionsEnum) {
4
- PanningDirectionsEnum["UP"] = "up";
5
- PanningDirectionsEnum["DOWN"] = "down";
6
- PanningDirectionsEnum["LEFT"] = "left";
7
- PanningDirectionsEnum["RIGHT"] = "right";
8
- return PanningDirectionsEnum;
9
- }({});
10
- /**
11
- * @description: Wraps the panResponderView and panListenerView to provide a shared context
12
- */
13
- export default class PanningProvider extends Component {
14
- static displayName = 'IGNORE';
15
- static Directions = PanningDirectionsEnum;
16
- constructor(props) {
17
- super(props);
18
- this.state = {
19
- isPanning: false,
20
- wasTerminated: false,
21
- dragDirections: {},
22
- dragDeltas: {},
23
- swipeDirections: {},
24
- swipeVelocities: {},
25
- panLocation: {}
26
- };
27
- }
28
- getProviderContextValue = () => {
29
- const {
30
- isPanning,
31
- wasTerminated,
32
- dragDirections,
33
- dragDeltas,
34
- swipeDirections,
35
- swipeVelocities,
36
- panLocation
37
- } = this.state;
38
- return {
39
- onPanStart: this.onPanStart,
40
- onPanRelease: this.onPanRelease,
41
- onPanTerminated: this.onPanTerminated,
42
- isPanning,
43
- wasTerminated,
44
- onDrag: this.onDrag,
45
- dragDirections,
46
- dragDeltas,
47
- onSwipe: this.onSwipe,
48
- swipeDirections,
49
- swipeVelocities,
50
- onPanLocationChanged: this.onPanLocationChanged,
51
- panLocation
52
- };
53
- };
54
- onPanStart = () => {
55
- this.setState({
56
- isPanning: true,
57
- wasTerminated: false
58
- });
59
- };
60
- onPanRelease = () => {
61
- this.setState({
62
- isPanning: false
63
- });
64
- };
65
- onPanTerminated = () => {
66
- this.setState({
67
- isPanning: false,
68
- wasTerminated: true
69
- });
70
- };
71
- onDrag = ({
72
- directions,
73
- deltas
74
- }) => {
75
- this.setState({
76
- dragDirections: directions,
77
- dragDeltas: deltas,
78
- swipeDirections: {},
79
- swipeVelocities: {}
80
- });
81
- };
82
- onSwipe = ({
83
- directions,
84
- velocities
85
- }) => {
86
- this.setState({
87
- swipeDirections: directions,
88
- swipeVelocities: velocities,
89
- dragDirections: {},
90
- dragDeltas: {}
91
- });
92
- };
93
- onPanLocationChanged = location => {
94
- this.setState({
95
- panLocation: location
96
- });
97
- };
98
- render() {
99
- return <PanningContext.Provider value={this.getProviderContextValue()}>{this.props.children}</PanningContext.Provider>;
100
- }
101
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
-
3
- export default React.createContext({});
@@ -1,153 +0,0 @@
1
- import React, {Component} from 'react';
2
- import {StyleSheet} from 'react-native';
3
- import Animated, {Easing as _Easing, EasingNode} from 'react-native-reanimated';
4
- import PropTypes from 'prop-types';
5
- import _ from 'lodash';
6
- import TouchableOpacity from '../touchableOpacity';
7
- import {Colors} from '../../style';
8
- import ShareTransitionContext from './ShareTransitionContext';
9
-
10
- const {interpolate: _interpolate, interpolateNode} = Animated;
11
- const Easing = EasingNode || _Easing;
12
- const interpolate = interpolateNode || _interpolate;
13
-
14
- // TODO: 2.17 breaks Android (at list the screen, the image is not shown) - move to incubator?
15
- class SharedArea extends Component {
16
- displayName = 'IGNORE';
17
- static propTypes = {
18
- /**
19
- * render details screen
20
- */
21
- renderDetails: PropTypes.elementType
22
- };
23
-
24
- static defaultProps = {
25
- renderDetails: _.noop
26
- };
27
-
28
- state = {};
29
- transition = new Animated.Value(0);
30
-
31
- getProviderContextValue() {
32
- const {showDetails} = this.state;
33
- return {
34
- setSharedData: this.setSharedData,
35
- setSource: this.setSource,
36
- setTarget: this.setTarget,
37
- showDetails
38
- };
39
- }
40
-
41
- getOverlayStyle() {
42
- return {
43
- ...StyleSheet.absoluteFillObject,
44
- backgroundColor: Colors.white,
45
- opacity: interpolate(this.transition, {inputRange: [0, 1], outputRange: [0, 1]})
46
- };
47
- }
48
-
49
- getDetailsStyle() {
50
- return {
51
- ...StyleSheet.absoluteFillObject,
52
- opacity: interpolate(this.transition, {inputRange: [90, 100], outputRange: [0, 1]})
53
- };
54
- }
55
-
56
- getElementStyle() {
57
- const {sourceLayout, targetLayout} = this.state;
58
- if (sourceLayout && this.transition) {
59
- return {
60
- position: 'absolute',
61
- width: interpolate(this.transition, {
62
- inputRange: [0, 100],
63
- outputRange: [sourceLayout.width, targetLayout.width]
64
- }),
65
- height: interpolate(this.transition, {
66
- inputRange: [0, 100],
67
- outputRange: [sourceLayout.height, targetLayout.height]
68
- }),
69
- top: interpolate(this.transition, {
70
- inputRange: [0, 100],
71
- outputRange: [sourceLayout.y, targetLayout.y]
72
- }),
73
- left: interpolate(this.transition, {
74
- inputRange: [0, 100],
75
- outputRange: [sourceLayout.x, targetLayout.x]
76
- })
77
- };
78
- }
79
- }
80
-
81
- setSharedData = data => {
82
- this.setState({
83
- data
84
- });
85
- };
86
-
87
- setSource = (sourceLayout, element) => {
88
- this.setState({
89
- sourceLayout,
90
- element,
91
- showDetails: true
92
- },
93
- () => {
94
- this.startTransition(true);
95
- });
96
- };
97
-
98
- setTarget = targetLayout => {
99
- this.setState({
100
- targetLayout
101
- });
102
- };
103
-
104
- clearSource = () => {
105
- this.startTransition(false, () => {
106
- this.setState({
107
- showDetails: false,
108
- data: undefined,
109
- sourceLayout: undefined,
110
- element: undefined
111
- });
112
- });
113
- };
114
-
115
- startTransition(show, onAnimationEnd) {
116
- Animated.timing(this.transition, {
117
- toValue: show ? 100 : 0,
118
- duration: 600,
119
- easing: Easing.bezier(0.19, 1, 0.22, 1),
120
- useNativeDriver: false
121
- }).start(onAnimationEnd);
122
- }
123
-
124
- renderDetailsOverlay() {
125
- const {renderDetails} = this.props;
126
- const {data, element} = this.state;
127
-
128
- return (
129
- <Animated.View pointerEvents={data ? 'auto' : 'none'} style={this.getOverlayStyle()}>
130
- <Animated.View pointerEvents="box-none" style={this.getDetailsStyle()}>
131
- {renderDetails(data)}
132
- </Animated.View>
133
-
134
- <Animated.View style={this.getElementStyle()}>
135
- <TouchableOpacity activeOpacity={1} onPress={this.clearSource} /* _style={[style]} */ style={{flex: 1}}>
136
- {element}
137
- </TouchableOpacity>
138
- </Animated.View>
139
- </Animated.View>
140
- );
141
- }
142
-
143
- render() {
144
- return (
145
- <ShareTransitionContext.Provider value={this.getProviderContextValue()}>
146
- {this.props.children}
147
- {this.renderDetailsOverlay()}
148
- </ShareTransitionContext.Provider>
149
- );
150
- }
151
- }
152
-
153
- export default SharedArea;
@@ -1,44 +0,0 @@
1
- import React, {Component} from 'react';
2
- import PropTypes from 'prop-types';
3
- import TouchableOpacity from '../touchableOpacity';
4
-
5
- import ShareTransitionContext from './ShareTransitionContext';
6
-
7
- class SourceElement extends Component {
8
- displayName = 'IGNORE';
9
- static propTypes = {
10
- /**
11
- * Data to share between shared element and placeholder
12
- */
13
- data: PropTypes.object
14
- };
15
-
16
- state = {};
17
-
18
- onPress = () => {
19
- const {data} = this.props;
20
- const {setSharedData, setSource} = this.context;
21
- setSharedData(data);
22
-
23
- this.element.measure((_x, _y, width, height, pageX, pageY) => {
24
- const sourceLayout = {x: pageX, y: pageY, width, height};
25
- setSource(sourceLayout, this.props.children);
26
- });
27
- };
28
-
29
- setRef = ref => {
30
- this.element = ref;
31
- };
32
-
33
- render() {
34
- const {style, children} = this.props;
35
- return (
36
- <TouchableOpacity activeOpacity={0.9} style={style} ref={this.setRef} onPress={this.onPress}>
37
- {children}
38
- </TouchableOpacity>
39
- );
40
- }
41
- }
42
-
43
- SourceElement.contextType = ShareTransitionContext;
44
- export default SourceElement;
@@ -1,38 +0,0 @@
1
- import React, {Component} from 'react';
2
- import TouchableOpacity from '../touchableOpacity';
3
-
4
- import ShareTransitionContext from './ShareTransitionContext';
5
-
6
- class TargetElement extends Component {
7
- displayName = 'IGNORE';
8
- state = {};
9
-
10
- componentDidMount() {
11
- const {setTarget} = this.context;
12
-
13
- if (!this.targetLayout) {
14
- setTimeout(() => {
15
- this.element.measure((_x, _y, width, height, pageX, pageY) => {
16
- this.targetLayout = {x: pageX, y: pageY, width, height};
17
- setTarget(this.targetLayout);
18
- });
19
- });
20
- }
21
- }
22
-
23
- setRef = ref => {
24
- this.element = ref;
25
- };
26
-
27
- render() {
28
- const {style, children} = this.props;
29
- return (
30
- <TouchableOpacity style={[style, {opacity: 0}]} ref={this.setRef}>
31
- {children}
32
- </TouchableOpacity>
33
- );
34
- }
35
- }
36
-
37
- TargetElement.contextType = ShareTransitionContext;
38
- export default TargetElement;
@@ -1,9 +0,0 @@
1
- import Source from './SourceElement';
2
- import Target from './TargetElement';
3
- import Area from './SharedArea';
4
-
5
- export default {
6
- Area,
7
- Source,
8
- Target
9
- };