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,226 +1,219 @@
1
- import _isEmpty from "lodash/isEmpty";
2
- import React, { Component } from 'react';
1
+ import React, { useMemo, useCallback, useImperativeHandle, forwardRef, useEffect, useState } from 'react';
3
2
  import { StyleSheet } from 'react-native';
4
- import { Colors } from "../../style";
3
+ import hoistStatics from 'hoist-non-react-statics';
4
+ import { Extrapolation, interpolate, runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
5
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
6
+ import { Spacings, Colors, BorderRadiuses } from "../../style";
7
+ import { useDidUpdate } from "../../hooks";
8
+ import { asBaseComponent, Constants } from "../../commons/new";
9
+ import View from "../../components/view";
10
+ import Modal from "../../components/modal";
5
11
  import { extractAlignmentsValues } from "../../commons/modifiers";
6
- import { Constants, asBaseComponent } from "../../commons/new";
7
- import Modal from "../modal";
8
- import View from "../view";
9
- import PanListenerView from "../panningViews/panListenerView";
10
- import DialogDismissibleView from "./DialogDismissibleView";
11
- import OverlayFadingBackground from "./OverlayFadingBackground";
12
- import PanningProvider, { PanningDirections, PanningDirectionsEnum } from "../panningViews/panningProvider";
13
- export { PanningDirections as DialogDirections, PanningDirectionsEnum as DialogDirectionsEnum };
12
+ import useHiddenLocation from "../../hooks/useHiddenLocation";
13
+ import DialogHeader from "./DialogHeader";
14
+ import useDialogContent from "./useDialogContent";
15
+ import { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps } from "./types";
16
+ export { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps };
17
+ const THRESHOLD_VELOCITY = 750;
18
+ const Dialog = (props, ref) => {
19
+ const {
20
+ visible = false,
21
+ headerProps,
22
+ showCloseButton,
23
+ closeButtonProps,
24
+ containerStyle: propsContainerStyle,
25
+ containerProps: propsContainerProps,
26
+ width,
27
+ height,
28
+ onDismiss,
29
+ direction = DialogDirectionsEnum.DOWN,
30
+ ignoreBackgroundPress,
31
+ modalProps = {},
32
+ useSafeArea,
33
+ disableAnimation = false,
34
+ testID,
35
+ children
36
+ } = props;
37
+ const {
38
+ overlayBackgroundColor = Colors.rgba(Colors.grey10, 0.65),
39
+ ...otherModalProps
40
+ } = modalProps;
41
+ const visibility = useSharedValue(0); // value between 0 (closed) and 1 (open)
42
+ const initialTranslation = useSharedValue(0);
43
+ const [modalVisibility, setModalVisibility] = useState(visible); // unfortunately this is needed when changing visibility by the user (clicking on an option etc)
14
44
 
15
- // TODO: KNOWN ISSUES
16
- // 1. iOS pressing on the background while enter animation is happening will not call onDismiss
17
- // Touch events are not registered?
18
- // 2. SafeArea is transparent
19
- // 3. Check why we need the state change in DialogDismissibleView -> onLayout -> animateTo
45
+ const {
46
+ setRef,
47
+ onLayout,
48
+ hiddenLocation: _hiddenLocation
49
+ } = useHiddenLocation();
50
+ const hiddenLocation = _hiddenLocation[direction];
51
+ const wasMeasured = _hiddenLocation.wasMeasured;
52
+ const isVertical = useMemo(() => {
53
+ 'worklet';
20
54
 
21
- const DEFAULT_OVERLAY_BACKGROUND_COLOR = Colors.rgba(Colors.$backgroundInverted, 0.3);
55
+ return direction === DialogDirectionsEnum.DOWN || direction === DialogDirectionsEnum.UP;
56
+ }, [direction]);
57
+ const getTranslationInterpolation = useCallback(value => {
58
+ 'worklet';
22
59
 
23
- /**
24
- * @description: Dialog component for displaying custom content inside a popup dialog
25
- * @notes: Use alignment modifiers to control the dialog position
26
- * (top, bottom, centerV, centerH, etc... by default the dialog is aligned to center)
27
- * @modifiers: alignment
28
- * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/DialogScreen.js
29
- * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Dialog/Dialog.gif?raw=true
30
- */
31
- class Dialog extends Component {
32
- static displayName = 'Dialog';
33
- static directions = PanningDirectionsEnum;
34
- static defaultProps = {
35
- overlayBackgroundColor: DEFAULT_OVERLAY_BACKGROUND_COLOR
36
- };
37
- constructor(props) {
38
- super(props);
39
- this.state = {
40
- alignments: extractAlignmentsValues(props),
41
- modalVisibility: props.visible,
42
- dialogVisibility: props.visible
43
- };
44
- this.styles = createStyles(this.props);
45
- this.setAlignment();
46
- }
47
- UNSAFE_componentWillReceiveProps(nextProps) {
48
- const {
49
- visible: nexVisible
50
- } = nextProps;
51
- const {
52
- visible
53
- } = this.props;
54
- if (nexVisible && !visible) {
55
- this.setState({
56
- modalVisibility: true,
57
- dialogVisibility: true
58
- });
59
- } else if (visible && !nexVisible) {
60
- this.hideDialogView();
61
- }
62
- }
63
- setAlignment() {
64
- const {
65
- alignments
66
- } = this.state;
67
- if (_isEmpty(alignments)) {
68
- this.styles.alignments = this.styles.centerContent;
69
- } else {
70
- this.styles.alignments = alignments;
71
- }
72
- }
60
+ return interpolate(value, [0, 1], [hiddenLocation, 0], Extrapolation.CLAMP);
61
+ }, [hiddenLocation]);
62
+ const getTranslationReverseInterpolation = useCallback(value => {
63
+ 'worklet';
64
+
65
+ return interpolate(value, [hiddenLocation, 0], [0, 1]);
66
+ }, [hiddenLocation]);
67
+ const _onDismiss = useCallback(() => {
68
+ 'worklet';
69
+
70
+ runOnJS(setModalVisibility)(false);
71
+ }, []);
72
+ const close = useCallback(() => {
73
+ 'worklet';
74
+
75
+ visibility.value = withTiming(0, undefined, _onDismiss);
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
77
+ }, [_onDismiss]);
78
+ const open = useCallback(() => {
79
+ 'worklet';
73
80
 
74
- // TODO: revert adding this workaround once RN fixes https://github.com/facebook/react-native/issues/29455
75
- onFadeDone = () => {
76
- if (!this.state.modalVisibility) {
77
- setTimeout(() => {
78
- // unfortunately this is needed if a modal needs to open on iOS
79
- this.props.onDialogDismissed?.(this.props);
80
- }, 100);
81
+ visibility.value = withSpring(1);
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ }, []);
84
+ useEffect(() => {
85
+ if (visible) {
86
+ setModalVisibility(true);
87
+ } else if (wasMeasured && modalVisibility) {
88
+ // Close when sending visible = false
89
+ close();
81
90
  }
82
- };
83
- _onDismiss = () => {
84
- this.setState({
85
- modalVisibility: false,
86
- fadeOut: false
87
- }, () => {
88
- const props = this.props;
89
- if (props.visible) {
90
- props.onDismiss?.(props);
91
- }
92
- // Parity with iOS Modal's onDismiss
93
- if (Constants.isAndroid) {
94
- props.onDialogDismissed?.(props);
91
+ // eslint-disable-next-line react-hooks/exhaustive-deps
92
+ }, [visible, wasMeasured]);
93
+ useDidUpdate(() => {
94
+ if (wasMeasured) {
95
+ if (modalVisibility) {
96
+ open();
97
+ } else if (Constants.isAndroid) {
98
+ onDismiss?.();
95
99
  }
96
- });
97
- };
98
- onDismiss = () => {
99
- const fadeOut = Constants.isIOS && this.props.visible;
100
- if (fadeOut) {
101
- this.setState({
102
- fadeOut
103
- }, this._onDismiss);
104
- } else {
105
- this._onDismiss();
106
100
  }
107
- };
108
- hideDialogView = () => {
109
- this.setState({
110
- dialogVisibility: false
111
- });
112
- };
113
- renderPannableHeader = directions => {
114
- const {
115
- renderPannableHeader,
116
- pannableHeaderProps
117
- } = this.props;
118
- if (renderPannableHeader) {
119
- return <PanListenerView directions={directions}>{renderPannableHeader(pannableHeaderProps)}</PanListenerView>;
120
- }
121
- };
122
- getContainerType = () => {
123
- const {
124
- panDirection,
125
- renderPannableHeader
126
- } = this.props;
127
- if (!panDirection || renderPannableHeader) {
128
- return View;
101
+ // eslint-disable-next-line react-hooks/exhaustive-deps
102
+ }, [modalVisibility, wasMeasured]);
103
+ const alignmentStyle = useMemo(() => {
104
+ return {
105
+ flex: 1,
106
+ alignItems: 'center',
107
+ ...extractAlignmentsValues(props)
108
+ };
109
+ // eslint-disable-next-line react-hooks/exhaustive-deps
110
+ }, []);
111
+ const {
112
+ renderDialogContent,
113
+ containerProps,
114
+ containerStyle
115
+ } = useDialogContent({
116
+ showCloseButton,
117
+ close,
118
+ closeButtonProps,
119
+ containerStyle: propsContainerStyle,
120
+ containerProps: propsContainerProps,
121
+ headerProps,
122
+ children
123
+ });
124
+ const animatedStyle = useAnimatedStyle(() => {
125
+ if (isVertical) {
126
+ return {
127
+ transform: [{
128
+ translateY: getTranslationInterpolation(visibility.value)
129
+ }]
130
+ };
131
+ } else {
132
+ return {
133
+ transform: [{
134
+ translateX: getTranslationInterpolation(visibility.value)
135
+ }]
136
+ };
129
137
  }
130
- return PanListenerView;
131
- };
132
- renderDialogView = () => {
133
- const {
134
- children,
135
- panDirection = PanningProvider.Directions.DOWN,
136
- containerStyle,
137
- testID
138
- } = this.props;
139
- const {
140
- dialogVisibility
141
- } = this.state;
142
- const Container = this.getContainerType();
143
- return <View testID={testID} style={[this.styles.dialogViewSize]} pointerEvents="box-none">
144
- <PanningProvider>
145
- <DialogDismissibleView direction={panDirection} visible={dialogVisibility} onDismiss={this.onDismiss} containerStyle={this.styles.flexType} style={this.styles.flexType}>
146
- <Container directions={[panDirection]} style={[this.styles.overflow, !Constants.isWeb && this.styles.flexType, containerStyle]}>
147
- {this.renderPannableHeader([panDirection])}
148
- {children}
149
- </Container>
150
- </DialogDismissibleView>
151
- </PanningProvider>
152
- </View>;
153
- };
138
+ });
139
+ const style = useMemo(() => {
140
+ return [styles.defaultDialogStyle, {
141
+ backgroundColor: Colors.$backgroundDefault
142
+ }, containerStyle, disableAnimation ? undefined : animatedStyle, width ? {
143
+ width
144
+ } : undefined, height ? {
145
+ height
146
+ } : undefined];
147
+ // eslint-disable-next-line react-hooks/exhaustive-deps
148
+ }, [containerStyle, width, height]);
149
+ const shouldClose = event => {
150
+ 'worklet';
154
151
 
155
- // TODO: renderOverlay {_.invoke(this.props, 'renderOverlay')}
156
- renderDialogContainer = () => {
157
- const {
158
- modalVisibility,
159
- dialogVisibility,
160
- fadeOut
161
- } = this.state;
162
- const {
163
- useSafeArea,
164
- bottom,
165
- overlayBackgroundColor,
166
- testID
167
- } = this.props;
168
- const addBottomSafeArea = Constants.isIphoneX && useSafeArea && bottom;
169
- const bottomInsets = Constants.getSafeAreaInsets().bottom - 8; // TODO: should this be here or in the input style?
170
- const onFadeDone = Constants.isIOS ? this.onFadeDone : undefined;
171
- return <View useSafeArea={useSafeArea} style={[this.styles.centerHorizontal, this.styles.alignments, this.styles.container]} pointerEvents="box-none">
172
- <OverlayFadingBackground testID={`${testID}.overlayFadingBackground`} modalVisibility={modalVisibility} dialogVisibility={dialogVisibility} overlayBackgroundColor={overlayBackgroundColor} onFadeDone={onFadeDone} fadeOut={fadeOut} />
173
- {this.renderDialogView()}
174
- {addBottomSafeArea && <View style={{
175
- marginTop: bottomInsets
176
- }} />}
177
- </View>;
178
- };
179
- render = () => {
180
- const {
181
- modalVisibility
182
- } = this.state;
183
- const {
184
- testID,
185
- supportedOrientations,
186
- accessibilityLabel,
187
- ignoreBackgroundPress,
188
- modalProps
189
- } = this.props;
190
- const onBackgroundPress = !ignoreBackgroundPress ? this.hideDialogView : undefined;
191
- return <Modal testID={`${testID}.modal`} transparent visible={modalVisibility} animationType={'none'} onBackgroundPress={onBackgroundPress} onRequestClose={onBackgroundPress} supportedOrientations={supportedOrientations} accessibilityLabel={accessibilityLabel} {...modalProps}>
192
- {this.renderDialogContainer()}
193
- </Modal>;
194
- };
195
- }
196
- function createStyles(props) {
197
- const {
198
- width = '90%',
199
- height
200
- } = props;
201
- const flexType = height ? {
202
- flex: 1
203
- } : {
204
- flex: 0
152
+ const wasPannedOverThreshold = Math.abs(getTranslationInterpolation(visibility.value)) >= Math.abs(hiddenLocation / 3);
153
+ let velocity;
154
+ switch (direction) {
155
+ case DialogDirectionsEnum.DOWN:
156
+ default:
157
+ velocity = event.velocityY;
158
+ break;
159
+ case DialogDirectionsEnum.UP:
160
+ velocity = -event.velocityY;
161
+ break;
162
+ case DialogDirectionsEnum.LEFT:
163
+ velocity = -event.velocityX;
164
+ break;
165
+ case DialogDirectionsEnum.RIGHT:
166
+ velocity = event.velocityX;
167
+ break;
168
+ }
169
+ const wasFlung = velocity >= THRESHOLD_VELOCITY;
170
+ return wasPannedOverThreshold || wasFlung;
205
171
  };
206
- return StyleSheet.create({
207
- dialogViewSize: {
208
- width,
209
- height: height ?? undefined
210
- },
211
- flexType,
212
- container: {
213
- flex: 1
214
- },
215
- centerHorizontal: {
216
- alignItems: 'center'
217
- },
218
- centerContent: {
219
- justifyContent: 'center'
220
- },
221
- overflow: {
222
- overflow: 'hidden'
172
+ const panGesture = Gesture.Pan().onStart(event => {
173
+ initialTranslation.value = getTranslationReverseInterpolation(isVertical ? event.translationY : event.translationX) - visibility.value;
174
+ }).onUpdate(event => {
175
+ visibility.value = getTranslationReverseInterpolation(isVertical ? event.translationY : event.translationX) - initialTranslation.value;
176
+ }).onEnd(event => {
177
+ if (shouldClose(event)) {
178
+ close();
179
+ } else {
180
+ open();
223
181
  }
224
182
  });
225
- }
226
- export default asBaseComponent(Dialog);
183
+ useImperativeHandle(ref, () => ({
184
+ dismiss: close
185
+ }));
186
+ const renderDialog = () => <GestureDetector gesture={panGesture}>
187
+ <View {...containerProps} reanimated={!Constants.accessibility.isReduceMotionEnabled} style={style} onLayout={onLayout} ref={setRef} testID={testID}>
188
+ {renderDialogContent()}
189
+ </View>
190
+ </GestureDetector>;
191
+ const overlayStyle = useAnimatedStyle(() => {
192
+ return {
193
+ opacity: visibility.value,
194
+ backgroundColor: overlayBackgroundColor
195
+ };
196
+ }, [overlayBackgroundColor]);
197
+ const renderOverlayView = () => <View testID={`${testID}.overlayFadingBackground`} absF reanimated style={overlayStyle} pointerEvents="none" />;
198
+ return <Modal transparent animationType={'none'} {...otherModalProps} testID={`${testID}.modal`} useGestureHandlerRootView visible={modalVisibility} onBackgroundPress={ignoreBackgroundPress ? undefined : close} onRequestClose={ignoreBackgroundPress ? undefined : close} onDismiss={onDismiss}>
199
+ {renderOverlayView()}
200
+ <View useSafeArea={useSafeArea} pointerEvents={'box-none'} style={alignmentStyle}>
201
+ {renderDialog()}
202
+ </View>
203
+ </Modal>;
204
+ };
205
+ Dialog.displayName = 'Dialog';
206
+ Dialog.directions = DialogDirectionsEnum;
207
+ Dialog.Header = DialogHeader;
208
+ const _Dialog = forwardRef(Dialog);
209
+ hoistStatics(_Dialog, Dialog);
210
+ export default asBaseComponent(_Dialog);
211
+ const styles = StyleSheet.create({
212
+ defaultDialogStyle: {
213
+ marginBottom: Spacings.s5,
214
+ maxHeight: '60%',
215
+ width: 250,
216
+ borderRadius: BorderRadiuses.br20,
217
+ overflow: 'hidden'
218
+ }
219
+ });
@@ -1,7 +1,6 @@
1
1
  import { PropsWithChildren, ReactElement } from 'react';
2
2
  import { type DimensionValue, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
3
3
  import { AlignmentModifiers } from '../../commons/modifiers';
4
- import { DialogProps as DialogPropsOld } from '../../components/dialog';
5
4
  import { ButtonProps } from '../../components/button';
6
5
  import { ModalProps } from '../../components/modal';
7
6
  import { PanningDirections, PanningDirectionsEnum } from '../panView';
@@ -119,6 +118,13 @@ export interface _DialogProps extends AlignmentModifiers, Pick<ViewProps, 'useSa
119
118
  * Additional props for the modal.
120
119
  */
121
120
  modalProps?: ModalProps;
121
+ /**
122
+ * Disable animation (default is false)
123
+ * In some cases you might want to disable the animation (probably for Android only), this is when the dialog is scrollable and has touchable items in the scrollable area.
124
+ * This is a temporary solution for a reanimated + RN77\8 bug.
125
+ * See https://github.com/software-mansion/react-native-reanimated/issues/6659 and https://github.com/facebook/react-native/issues/49694
126
+ */
127
+ disableAnimation?: boolean;
122
128
  /**
123
129
  * Used to locate this view in end-to-end tests
124
130
  * The container has the unchanged id.
@@ -130,21 +136,3 @@ export interface _DialogProps extends AlignmentModifiers, Pick<ViewProps, 'useSa
130
136
  testID?: string;
131
137
  }
132
138
  export type DialogProps = PropsWithChildren<_DialogProps>;
133
- export interface _DialogPropsOld {
134
- /**
135
- * The props to pass to the dialog expandable container
136
- */
137
- dialogProps?: DialogPropsOld;
138
- migrateDialog?: false;
139
- }
140
- export interface _DialogPropsNew {
141
- /**
142
- * The props to pass to the dialog expandable container
143
- */
144
- dialogProps?: DialogProps;
145
- /**
146
- * Migrate the Dialog to DialogNew (make sure you use only new props in dialogProps)
147
- */
148
- migrateDialog: true;
149
- }
150
- export type DialogMigrationProps = _DialogPropsOld | _DialogPropsNew;
@@ -1,5 +1,3 @@
1
1
  import { PanningDirectionsEnum } from "../panView";
2
2
  const DialogDirectionsEnum = PanningDirectionsEnum;
3
- export { DialogDirectionsEnum };
4
-
5
- // For migration purposes
3
+ export { DialogDirectionsEnum };
@@ -5,7 +5,7 @@ interface InternalDialogCloseButtonProps extends PropsWithChildren<DialogCloseBu
5
5
  }
6
6
  declare const useDialogContent: (props: InternalDialogCloseButtonProps) => {
7
7
  renderDialogContent: () => React.JSX.Element;
8
- containerStyle: false | import("react-native").ViewStyle | import("react-native").RegisteredStyle<import("react-native").ViewStyle> | import("react-native").RecursiveArray<import("react-native").ViewStyle | import("react-native").Falsy | import("react-native").RegisteredStyle<import("react-native").ViewStyle>> | (import("react-native").StyleProp<import("react-native").ViewStyle> | {
8
+ containerStyle: false | "" | import("react-native").ViewStyle | import("react-native").RegisteredStyle<import("react-native").ViewStyle> | import("react-native").RecursiveArray<import("react-native").ViewStyle | import("react-native").Falsy | import("react-native").RegisteredStyle<import("react-native").ViewStyle>> | (import("react-native").StyleProp<import("react-native").ViewStyle> | {
9
9
  backgroundColor: string;
10
10
  })[] | null | undefined;
11
11
  containerProps: Omit<import("../../components/view").ViewProps, "style" | "testID" | "ref" | "onLayout" | "animated" | "reanimated"> | undefined;
@@ -26,8 +26,7 @@ class Swipeable extends Component {
26
26
  static defaultProps = {
27
27
  friction: 1,
28
28
  overshootFriction: 1,
29
- useNativeAnimations: false,
30
- // issue in iPhone5
29
+ useNativeAnimations: true,
31
30
  fullLeftThreshold: 0.45,
32
31
  fullRightThreshold: 0.45
33
32
  };
@@ -220,30 +220,33 @@ class Drawer extends PureComponent {
220
220
  outputRange,
221
221
  extrapolate: 'clamp'
222
222
  });
223
- return <RectButton key={index} testID={item.testID} style={[styles.action, item.style, {
224
- backgroundColor: item.background || DEFAULT_BG,
225
- width: item.width,
226
- minWidth: itemsMinWidth
227
- }]} onPress={() => this.onActionPress(item)}>
228
- {item.customElement}
229
- {!item.customElement && item.icon && <Animated.Image source={item.icon} style={[styles.actionIcon, {
230
- width: itemsIconSize,
231
- height: itemsIconSize,
232
- tintColor: item.iconColor || itemsTintColor,
233
- opacity,
234
- transform: [{
235
- scale
236
- }]
237
- }]} />}
238
- {!item.customElement && item.text && <Animated.Text style={[styles.actionText, {
239
- color: item.textColor || itemsTintColor,
240
- opacity,
241
- transform: [{
242
- scale
243
- }]
244
- }, itemsTextStyle]} accessibilityElementsHidden importantForAccessibility="no-hide-descendants" accessible={false}>
245
- {item.text}
246
- </Animated.Text>}
223
+ return <RectButton key={index} testID={item.testID} onPress={() => this.onActionPress(item)}>
224
+ <View style={[styles.action, item.style, {
225
+ backgroundColor: item.background || DEFAULT_BG,
226
+ height: '100%',
227
+ width: item.width,
228
+ minWidth: itemsMinWidth
229
+ }]}>
230
+ {item.customElement}
231
+ {!item.customElement && item.icon && <Animated.Image source={item.icon} style={[styles.actionIcon, {
232
+ width: itemsIconSize,
233
+ height: itemsIconSize,
234
+ tintColor: item.iconColor || itemsTintColor,
235
+ opacity,
236
+ transform: [{
237
+ scale
238
+ }]
239
+ }]} />}
240
+ {!item.customElement && item.text && <Animated.Text style={[styles.actionText, {
241
+ color: item.textColor || itemsTintColor,
242
+ opacity,
243
+ transform: [{
244
+ scale
245
+ }]
246
+ }, itemsTextStyle]} accessibilityElementsHidden importantForAccessibility="no-hide-descendants" accessible={false}>
247
+ {item.text}
248
+ </Animated.Text>}
249
+ </View>
247
250
  </RectButton>;
248
251
  };
249
252
  render() {
@@ -255,7 +258,7 @@ class Drawer extends PureComponent {
255
258
  onToggleSwipeLeft,
256
259
  ...others
257
260
  } = this.props;
258
- return <GestureHandlerRootView>
261
+ return <GestureHandlerRootView style={styles.container}>
259
262
  <Swipeable {...others} ref={this._swipeableRow} friction={1} containerStyle={style} animationOptions={this.animationOptions} renderLeftActions={this.leftRender} renderRightActions={this.rightRender} rightActionsContainerStyle={this.getRightActionsContainerStyle(rightItems, leftItem)} leftActionsContainerStyle={this.getLeftActionsContainerStyle(leftItem, rightItems)} onSwipeableWillOpen={this.onSwipeableWillOpen} onSwipeableWillClose={this.onSwipeableWillClose} onToggleSwipeLeft={onToggleSwipeLeft && this.onToggleSwipeLeft}>
260
263
  <View accessible accessibilityActions={this.getAccessibilityActions()} onAccessibilityAction={this.onAccessibilityAction} {...extractAccessibilityProps(this.props)}>
261
264
  {children}
@@ -266,6 +269,9 @@ class Drawer extends PureComponent {
266
269
  }
267
270
  export default asBaseComponent(Drawer);
268
271
  const styles = StyleSheet.create({
272
+ container: {
273
+ flex: 0
274
+ },
269
275
  leftAction: {
270
276
  flex: 1,
271
277
  justifyContent: 'center',
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useRef, useImperativeHandle } from 'react';
2
- import { ScrollView as RNScrollView } from 'react-native';
2
+ import { ScrollView as RNScrollView, StyleSheet } from 'react-native';
3
3
  import { ScrollView as GestureScrollView, GestureHandlerRootView } from 'react-native-gesture-handler';
4
4
  import Fader from "../fader";
5
5
  import useScrollEnabler from "../../hooks/useScrollEnabler";
@@ -60,7 +60,7 @@ const FadedScrollView = props => {
60
60
  isScrollEnabled
61
61
  }));
62
62
  if (children) {
63
- return <GestureHandlerRootView>
63
+ return <GestureHandlerRootView style={styles.container}>
64
64
  <ScrollView scrollEventThrottle={16} decelerationRate={'fast'} {...others} horizontal={horizontal} scrollEnabled={scrollEnabled} onContentSizeChange={_onContentSizeChange} onLayout={_onLayout} onScroll={onScroll}
65
65
  // @ts-expect-error
66
66
  ref={scrollViewRef}>
@@ -72,5 +72,10 @@ const FadedScrollView = props => {
72
72
  }
73
73
  return null;
74
74
  };
75
+ const styles = StyleSheet.create({
76
+ container: {
77
+ flex: 0
78
+ }
79
+ });
75
80
  FadedScrollView.displayName = 'IGNORE';
76
81
  export default forwardRef(FadedScrollView);
@@ -100,7 +100,7 @@ export type FeatureHighlightProps = {
100
100
  interface State {
101
101
  fadeAnim: Animated.Value;
102
102
  contentTopPosition?: number;
103
- node?: number | null;
103
+ node?: number;
104
104
  getTarget?: () => any;
105
105
  }
106
106
  /**
@@ -3,20 +3,12 @@ import { HintPositions, HintProps } from './types';
3
3
  declare const Hint: {
4
4
  (props: HintProps): string | number | true | React.JSX.Element | Iterable<React.ReactNode> | null;
5
5
  displayName: string;
6
- defaultProps: {
7
- position: HintPositions;
8
- useModal: boolean;
9
- };
10
6
  positions: typeof HintPositions;
11
7
  };
12
8
  export { HintProps, Hint };
13
9
  declare const _default: React.ForwardRefExoticComponent<HintProps & React.RefAttributes<any>> & {
14
10
  (props: HintProps): string | number | true | React.JSX.Element | Iterable<React.ReactNode> | null;
15
11
  displayName: string;
16
- defaultProps: {
17
- position: HintPositions;
18
- useModal: boolean;
19
- };
20
12
  positions: typeof HintPositions;
21
13
  };
22
14
  export default _default;