react-native-ui-lib 7.46.3-snapshot.7342 → 7.46.3-snapshot.7356

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 (207) hide show
  1. package/babel.config.js +12 -0
  2. package/index.js +1 -0
  3. package/lib/android/build.gradle +5 -5
  4. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
  5. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  7. package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
  8. package/lib/components/HighlighterOverlayView/index.js +49 -0
  9. package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
  10. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
  11. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
  12. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  13. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  14. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
  15. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
  16. package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
  17. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
  18. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
  19. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
  20. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
  21. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
  22. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
  23. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
  24. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
  25. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
  26. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
  27. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
  28. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
  29. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
  30. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
  31. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
  32. package/lib/components/Keyboard/index.d.ts +6 -6
  33. package/lib/components/Keyboard/index.js +6 -6
  34. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
  35. package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
  36. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  37. package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
  38. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
  39. package/lib/components/SafeArea/index.d.ts +10 -0
  40. package/lib/components/SafeArea/index.js +11 -0
  41. package/lib/components/index.d.ts +1 -1
  42. package/lib/components/index.js +1 -1
  43. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +52 -8
  44. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
  45. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  46. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +109 -41
  47. package/lib/package.json +3 -3
  48. package/lib/react-native.config.js +1 -3
  49. package/metro.config.js +2 -2
  50. package/package.json +29 -29
  51. package/panView.d.ts +2 -0
  52. package/panView.js +1 -0
  53. package/react-native.config.js +1 -3
  54. package/src/commons/Constants.js +2 -5
  55. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
  56. package/src/components/actionSheet/index.d.ts +2 -12
  57. package/src/components/actionSheet/index.js +3 -42
  58. package/src/components/animatedImage/index.js +16 -6
  59. package/src/components/badge/index.d.ts +107 -47
  60. package/src/components/button/button.api.json +1 -1
  61. package/src/components/button/index.d.ts +53 -23
  62. package/src/components/button/types.d.ts +0 -1
  63. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  64. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  65. package/src/components/dateTimePicker/index.d.ts +186 -5
  66. package/src/components/dateTimePicker/index.js +3 -4
  67. package/src/components/dialog/dialog.api.json +31 -37
  68. package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
  69. package/src/components/dialog/index.d.ts +13 -105
  70. package/src/components/dialog/index.js +204 -212
  71. package/src/{incubator → components}/dialog/types.d.ts +0 -19
  72. package/src/{incubator → components}/dialog/types.js +1 -3
  73. package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
  74. package/src/components/drawer/Swipeable.js +1 -2
  75. package/src/components/drawer/index.js +31 -25
  76. package/src/components/fadedScrollView/index.js +7 -2
  77. package/src/components/featureHighlight/index.d.ts +1 -1
  78. package/src/components/index.js +0 -19
  79. package/src/components/marquee/types.js +4 -1
  80. package/src/components/modal/index.d.ts +5 -0
  81. package/src/components/modal/index.js +14 -10
  82. package/src/components/modal/modal.api.json +5 -0
  83. package/src/{incubator → components}/panView/index.d.ts +3 -3
  84. package/src/{incubator → components}/panView/index.js +4 -4
  85. package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
  86. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  87. package/src/components/picker/Picker.driver.new.js +3 -3
  88. package/src/components/picker/PickerItem.js +6 -20
  89. package/src/components/picker/PickerPresenter.d.ts +0 -1
  90. package/src/components/picker/PickerPresenter.js +1 -23
  91. package/src/components/picker/api/picker.api.json +0 -1
  92. package/src/components/picker/api/pickerItem.api.json +0 -5
  93. package/src/components/picker/helpers/useFieldType.d.ts +53 -23
  94. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  95. package/src/components/picker/helpers/usePickerLabel.js +2 -3
  96. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  97. package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
  98. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  99. package/src/components/picker/helpers/usePickerSearch.js +4 -8
  100. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  101. package/src/components/picker/helpers/usePickerSelection.js +2 -10
  102. package/src/components/picker/index.js +4 -22
  103. package/src/components/picker/types.d.ts +1 -24
  104. package/src/components/segmentedControl/index.js +3 -3
  105. package/src/components/slider/GradientSlider.d.ts +1 -1
  106. package/src/components/sortableGridList/SortableItem.js +13 -4
  107. package/src/components/sortableList/SortableListItem.js +13 -4
  108. package/src/components/stackAggregator/index.js +16 -11
  109. package/src/components/tabController/TabBar.js +1 -2
  110. package/src/components/text/Text.driver.new.d.ts +2 -2
  111. package/src/components/text/Text.driver.new.js +2 -2
  112. package/src/components/textField/Input.js +0 -1
  113. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  114. package/src/components/textField/TextField.driver.new.js +2 -2
  115. package/src/components/textField/presets/outline.d.ts +106 -46
  116. package/src/components/textField/presets/underline.d.ts +106 -46
  117. package/src/components/textField/types.js +1 -0
  118. package/src/components/textField/usePreset.d.ts +72 -44
  119. package/src/components/timeline/types.js +3 -0
  120. package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
  121. package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
  122. package/src/hooks/useScrollToItem/index.d.ts +18 -4
  123. package/src/hooks/useScrollToItem/index.js +56 -17
  124. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  125. package/src/incubator/expandableOverlay/index.d.ts +42 -3
  126. package/src/incubator/expandableOverlay/index.js +1 -4
  127. package/src/incubator/index.d.ts +0 -2
  128. package/src/incubator/index.js +0 -2
  129. package/src/incubator/toast/index.js +1 -1
  130. package/src/index.d.ts +3 -10
  131. package/src/index.js +42 -162
  132. package/src/testkit/index.d.ts +1 -1
  133. package/src/testkit/index.js +1 -1
  134. package/src/testkit/new/Component.driver.d.ts +4 -1
  135. package/src/testkit/new/Component.driver.js +3 -3
  136. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
  137. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
  138. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
  139. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
  140. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
  141. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
  142. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
  143. package/lib/components/HighlighterOverlayView.js +0 -40
  144. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
  145. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
  146. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
  147. package/panningViews.d.ts +0 -2
  148. package/panningViews.js +0 -1
  149. package/sharedTransition.d.ts +0 -2
  150. package/sharedTransition.js +0 -1
  151. package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
  152. package/src/components/dialog/DialogDismissibleView.js +0 -184
  153. package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
  154. package/src/components/dialog/OverlayFadingBackground.js +0 -45
  155. package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
  156. package/src/components/panningViews/asPanViewConsumer.js +0 -16
  157. package/src/components/panningViews/panDismissibleView.d.ts +0 -51
  158. package/src/components/panningViews/panDismissibleView.js +0 -350
  159. package/src/components/panningViews/panGestureView.d.ts +0 -23
  160. package/src/components/panningViews/panGestureView.js +0 -156
  161. package/src/components/panningViews/panListenerView.d.ts +0 -66
  162. package/src/components/panningViews/panListenerView.js +0 -155
  163. package/src/components/panningViews/panResponderView.d.ts +0 -19
  164. package/src/components/panningViews/panResponderView.js +0 -79
  165. package/src/components/panningViews/panningContext.d.ts +0 -3
  166. package/src/components/panningViews/panningContext.js +0 -4
  167. package/src/components/panningViews/panningProvider.d.ts +0 -73
  168. package/src/components/panningViews/panningProvider.js +0 -101
  169. package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
  170. package/src/components/sharedTransition/SharedArea.js +0 -153
  171. package/src/components/sharedTransition/SourceElement.js +0 -44
  172. package/src/components/sharedTransition/TargetElement.js +0 -38
  173. package/src/components/sharedTransition/index.js +0 -9
  174. package/src/components/tabController/useScrollToItem.d.ts +0 -79
  175. package/src/components/tabController/useScrollToItem.js +0 -159
  176. package/src/incubator/dialog/dialog.api.json +0 -54
  177. package/src/incubator/dialog/index.d.ts +0 -15
  178. package/src/incubator/dialog/index.js +0 -218
  179. /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
  180. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
  181. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
  182. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
  183. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
  184. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
  185. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
  186. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  187. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  188. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  189. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  190. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
  191. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
  192. /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
  193. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  194. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  195. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
  196. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
  197. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
  198. /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
  199. /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
  200. /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
  201. /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
  202. /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
  203. /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
  204. /package/src/{incubator → components}/panView/panningUtil.js +0 -0
  205. /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
  206. /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
  207. /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/index.web.js} +0 -0
@@ -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
- };
@@ -1,79 +0,0 @@
1
- import { RefObject } from 'react';
2
- import { LayoutChangeEvent } from 'react-native';
3
- import { ScrollToSupportedViews, ScrollToResultProps } from 'hooks';
4
- export declare enum OffsetType {
5
- CENTER = "CENTER",
6
- DYNAMIC = "DYNAMIC",
7
- LEFT = "LEFT",
8
- RIGHT = "RIGHT"
9
- }
10
- export type ScrollToItemProps<T extends ScrollToSupportedViews> = {
11
- scrollViewRef?: RefObject<T>;
12
- /**
13
- * The number of items
14
- */
15
- itemsCount: number;
16
- /**
17
- * The selected item's index
18
- */
19
- selectedIndex?: number;
20
- /**
21
- * The container width, should update on orientation change
22
- */
23
- containerWidth: number;
24
- /**
25
- * Where would the item be located (default to CENTER)
26
- */
27
- offsetType?: OffsetType | `${OffsetType}`;
28
- /**
29
- * Add a margin to the offset (default to true)
30
- * This gives a better UX
31
- * Not relevant to OffsetType.CENTER
32
- */
33
- addOffsetMargin?: boolean;
34
- /**
35
- * How much space (padding \ margin) is there on the left\right of the items
36
- */
37
- outerSpacing?: number;
38
- /**
39
- * How much space (padding \ margin) is there between each item
40
- */
41
- innerSpacing?: number;
42
- };
43
- export type ScrollToItemResultProps<T extends ScrollToSupportedViews> = Pick<ScrollToResultProps<T>, 'scrollViewRef'> & {
44
- /**
45
- * This should be called by each ot the items' onLayout
46
- */
47
- onItemLayout: (event: LayoutChangeEvent, index: number) => void;
48
- /**
49
- * The items' width as share animated value
50
- */
51
- itemsWidthsAnimated: any;
52
- /**
53
- * The items' offsets as share animated value
54
- */
55
- itemsOffsetsAnimated: any;
56
- /**
57
- * Use in order to focus the item with the specified index (use when the selectedIndex is not changed)
58
- */
59
- focusIndex: (index: number, animated?: boolean) => void;
60
- /**
61
- * Use in order to reset the data.
62
- */
63
- reset: () => void;
64
- /**
65
- * onContentSizeChange callback (should be set to your onContentSizeChange).
66
- * Needed for RTL support on Android.
67
- */
68
- onContentSizeChange: (contentWidth: number, contentHeight: number) => void;
69
- /**
70
- * onLayout callback (should be set to your onLayout).
71
- * Needed for RTL support on Android.
72
- */
73
- onLayout: (event: LayoutChangeEvent) => void;
74
- };
75
- declare const useScrollToItem: {
76
- <T extends ScrollToSupportedViews>(props: ScrollToItemProps<T>): ScrollToItemResultProps<T>;
77
- offsetType: typeof OffsetType;
78
- };
79
- export default useScrollToItem;
@@ -1,159 +0,0 @@
1
- import _isUndefined from "lodash/isUndefined";
2
- import _includes from "lodash/includes";
3
- import _isEmpty from "lodash/isEmpty";
4
- import _times from "lodash/times";
5
- import { useState, useCallback, useEffect, useRef } from 'react';
6
- import { useSharedValue } from 'react-native-reanimated';
7
- import { useScrollTo } from "../../hooks";
8
- import { Constants } from "../../commons/new";
9
- const FIX_RTL = Constants.isRTL;
10
- export let OffsetType = /*#__PURE__*/function (OffsetType) {
11
- OffsetType["CENTER"] = "CENTER";
12
- OffsetType["DYNAMIC"] = "DYNAMIC";
13
- OffsetType["LEFT"] = "LEFT";
14
- OffsetType["RIGHT"] = "RIGHT";
15
- return OffsetType;
16
- }({});
17
-
18
- // TODO: this is what I want, is there a better way to do it?
19
-
20
- const useScrollToItem = props => {
21
- const {
22
- scrollViewRef: propsScrollViewRef,
23
- itemsCount,
24
- selectedIndex,
25
- containerWidth,
26
- offsetType = OffsetType.CENTER,
27
- addOffsetMargin = true,
28
- outerSpacing = 0,
29
- innerSpacing = 0
30
- } = props;
31
- const itemsWidths = useRef(_times(itemsCount, () => null));
32
- const itemsWidthsAnimated = useSharedValue(_times(itemsCount, () => 0));
33
- const itemsOffsetsAnimated = useSharedValue(_times(itemsCount, () => 0));
34
- const currentIndex = useRef(selectedIndex || 0);
35
- const [offsets, setOffsets] = useState({
36
- CENTER: [],
37
- LEFT: [],
38
- RIGHT: []
39
- });
40
- const {
41
- scrollViewRef,
42
- scrollTo,
43
- onContentSizeChange,
44
- onLayout
45
- } = useScrollTo({
46
- scrollViewRef: propsScrollViewRef
47
- });
48
-
49
- // TODO: reset?
50
- // useEffect(() => {
51
- // itemsWidths.current = _.times(itemsCount, () => null);
52
- // }, [itemsCount]);
53
-
54
- // const contentWidth = _.sum(itemsWidths);
55
- // TODO: const scrollEnabled = contentWidth.current > containerWidth;
56
-
57
- const setSnapBreakpoints = useCallback(widths => {
58
- if (_isEmpty(widths)) {
59
- return;
60
- }
61
- const screenCenter = containerWidth / 2;
62
- let index = 0;
63
- const centeredOffsets = [];
64
- let currentCenterOffset = outerSpacing;
65
- const leftOffsets = [];
66
- leftOffsets.push(outerSpacing - innerSpacing);
67
- const rightOffsets = [];
68
- rightOffsets.push(-containerWidth + widths[0] + outerSpacing + innerSpacing);
69
- while (index < itemsCount) {
70
- /* calc center, left and right offsets */
71
- centeredOffsets[index] = currentCenterOffset - screenCenter + widths[index] / 2;
72
- ++index;
73
- currentCenterOffset += widths[index - 1] + innerSpacing;
74
- leftOffsets[index] = leftOffsets[index - 1] + widths[index - 1] + innerSpacing;
75
- rightOffsets[index] = rightOffsets[index - 1] + widths[index] + innerSpacing;
76
- }
77
- if (addOffsetMargin) {
78
- index = 1;
79
- while (index < itemsCount - 1) {
80
- leftOffsets[index] -= widths[index - 1];
81
- rightOffsets[index] += widths[index + 1] + innerSpacing;
82
- ++index;
83
- }
84
- }
85
- setOffsets({
86
- CENTER: centeredOffsets,
87
- LEFT: leftOffsets,
88
- RIGHT: rightOffsets
89
- }); // default for DYNAMIC is CENTER
90
-
91
- // Update shared values
92
- // @ts-expect-error pretty sure this is a bug in reanimated since itemsWidthsAnimated is defined as SharedValue<number[]>
93
- itemsWidthsAnimated.modify(value => {
94
- 'worklet';
95
-
96
- return value.map((_, index) => widths[index]);
97
- });
98
- itemsOffsetsAnimated.modify(value => {
99
- 'worklet';
100
-
101
- value.forEach((_, index) => {
102
- if (index > 0) {
103
- value[index] = value[index - 1] + widths[index - 1];
104
- }
105
- });
106
- return value;
107
- });
108
- }, [itemsCount, outerSpacing, innerSpacing, addOffsetMargin, containerWidth]);
109
- const onItemLayout = useCallback((event, index) => {
110
- const {
111
- width
112
- } = event.nativeEvent.layout;
113
- itemsWidths.current[index] = width;
114
- if (!_includes(itemsWidths.current, null)) {
115
- setSnapBreakpoints(itemsWidths.current);
116
- }
117
- }, [setSnapBreakpoints]);
118
- const focusIndex = useCallback((index, animated = true) => {
119
- if (index >= 0 && offsets.CENTER.length > index) {
120
- const rtlIndex = FIX_RTL ? itemsCount - index - 1 : index;
121
- if (offsetType !== OffsetType.DYNAMIC) {
122
- scrollTo(offsets[offsetType][rtlIndex], animated);
123
- } else {
124
- const movingLeft = index < currentIndex.current;
125
- currentIndex.current = rtlIndex;
126
- scrollTo(movingLeft ? offsets[OffsetType.RIGHT][rtlIndex] : offsets[OffsetType.LEFT][rtlIndex], animated);
127
- }
128
- }
129
- }, [offsets, offsetType, scrollTo]);
130
- useEffect(() => {
131
- if (!_isUndefined(selectedIndex)) {
132
- focusIndex(selectedIndex, false);
133
- }
134
- }, [selectedIndex, focusIndex]);
135
- const reset = useCallback(() => {
136
- for (let i = 0; i < itemsCount; ++i) {
137
- itemsWidths.current[i] = null;
138
- itemsWidthsAnimated.value[i] = 0;
139
- itemsOffsetsAnimated.value[i] = 0;
140
- }
141
- setOffsets({
142
- CENTER: [],
143
- LEFT: [],
144
- RIGHT: []
145
- });
146
- }, [itemsCount]);
147
- return {
148
- scrollViewRef,
149
- onItemLayout,
150
- itemsWidthsAnimated,
151
- itemsOffsetsAnimated,
152
- focusIndex,
153
- reset,
154
- onContentSizeChange,
155
- onLayout
156
- };
157
- };
158
- useScrollToItem.offsetType = OffsetType;
159
- export default useScrollToItem;
@@ -1,54 +0,0 @@
1
- {
2
- "name": "Dialog",
3
- "category": "incubator",
4
- "description": "Component for displaying custom content inside a popup dialog",
5
- "note": "Use alignment modifiers to control the dialog position (top, bottom, centerV, centerH, etc... by default the dialog is aligned to center). \nWhen adding a `FlatList` \\ `ScrollView` to the content be sure to use one from `react-native-gesture-handler` (see [this link](https://github.com/software-mansion/react-native-gesture-handler/issues/1380) for `SectionList`).",
6
- "modifiers": ["alignment"],
7
- "example": "https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/incubatorScreens/IncubatorDialogScreen.tsx",
8
- "props": [
9
- {"name": "visible", "type": "boolean", "description": "The visibility of the dialog"},
10
- {"name": "headerProps", "type": "DialogHeaderProps", "description": "The Dialog's header (title, subtitle etc)"},
11
- {
12
- "name": "containerStyle",
13
- "type": "ViewStyle",
14
- "description": "The Dialog`s container style (it is set to {position: 'absolute'})"
15
- },
16
- {
17
- "name": "containerProps",
18
- "type": "ViewProps",
19
- "description": "Extra props for the container"
20
- },
21
- {
22
- "name": "onDismiss",
23
- "type": "(props?: DialogProps) => void",
24
- "description": "Callback that is called after the dialog's dismiss (after the animation has ended)."
25
- },
26
- {
27
- "name": "direction",
28
- "type": "up | down | left | right",
29
- "description": "The direction from which and to which the dialog is animating \\ panning (default down).",
30
- "default": "down"
31
- },
32
- {
33
- "name": "showClose",
34
- "type": "boolean",
35
- "description": "Show the close button"
36
- },
37
- {"name": "ignoreBackgroundPress", "type": "boolean", "description": "Whether or not to ignore background press."},
38
- {"name": "modalProps", "type": "ModalProps", "description": "Pass props to the dialog modal"},
39
- {
40
- "name": "testID",
41
- "type": "string",
42
- "description": "Used to locate this view in end-to-end tests. \nThe container has the original id. \nSupported inner elements IDs: \n`${TestID}.modal` - the Modal's id. \n`${TestID}.overlayFadingBackground` - the fading background id."
43
- }
44
- ],
45
- "snippet": [
46
- "<Dialog",
47
- " visible={isVisible$1}",
48
- " onDismiss={() => console.log('dismissed')$2}",
49
- " panDirection={PanningProvider.Directions.DOWN$3}",
50
- ">",
51
- " <Text text60>Content</Text>$4",
52
- "</Dialog>"
53
- ]
54
- }
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import DialogHeader from './DialogHeader';
3
- import { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps, DialogMigrationProps } from './types';
4
- export { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps, DialogMigrationProps };
5
- export interface DialogStatics {
6
- directions: typeof DialogDirectionsEnum;
7
- Header: typeof DialogHeader;
8
- }
9
- export interface DialogImperativeMethods {
10
- dismiss: () => void;
11
- }
12
- declare const _default: React.ForwardRefExoticComponent<import("./types")._DialogProps & {
13
- children?: React.ReactNode;
14
- } & React.RefAttributes<any>> & DialogStatics;
15
- export default _default;
@@ -1,218 +0,0 @@
1
- import React, { useMemo, useCallback, useImperativeHandle, forwardRef, useEffect, useState } from 'react';
2
- import { StyleSheet } from 'react-native';
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";
11
- import { extractAlignmentsValues } from "../../commons/modifiers";
12
- import useHiddenLocation from "../hooks/useHiddenLocation";
13
- import DialogHeader from "./DialogHeader";
14
- import useDialogContent from "./useDialogContent";
15
- import { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps, DialogMigrationProps } from "./types";
16
- export { DialogProps, DialogDirections, DialogDirectionsEnum, DialogHeaderProps, DialogMigrationProps };
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
- testID,
34
- children
35
- } = props;
36
- const {
37
- overlayBackgroundColor = Colors.rgba(Colors.grey10, 0.65),
38
- ...otherModalProps
39
- } = modalProps;
40
- const visibility = useSharedValue(0); // value between 0 (closed) and 1 (open)
41
- const initialTranslation = useSharedValue(0);
42
- const [modalVisibility, setModalVisibility] = useState(visible); // unfortunately this is needed when changing visibility by the user (clicking on an option etc)
43
-
44
- const {
45
- setRef,
46
- onLayout,
47
- hiddenLocation: _hiddenLocation
48
- } = useHiddenLocation();
49
- const hiddenLocation = _hiddenLocation[direction];
50
- const wasMeasured = _hiddenLocation.wasMeasured;
51
- const isVertical = useMemo(() => {
52
- 'worklet';
53
-
54
- return direction === DialogDirectionsEnum.DOWN || direction === DialogDirectionsEnum.UP;
55
- }, [direction]);
56
- const getTranslationInterpolation = useCallback(value => {
57
- 'worklet';
58
-
59
- return interpolate(value, [0, 1], [hiddenLocation, 0], Extrapolation.CLAMP);
60
- }, [hiddenLocation]);
61
- const getTranslationReverseInterpolation = useCallback(value => {
62
- 'worklet';
63
-
64
- return interpolate(value, [hiddenLocation, 0], [0, 1]);
65
- }, [hiddenLocation]);
66
- const _onDismiss = useCallback(() => {
67
- 'worklet';
68
-
69
- runOnJS(setModalVisibility)(false);
70
- }, []);
71
- const close = useCallback(() => {
72
- 'worklet';
73
-
74
- visibility.value = withTiming(0, undefined, _onDismiss);
75
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
- }, [_onDismiss]);
77
- const open = useCallback(() => {
78
- 'worklet';
79
-
80
- visibility.value = withSpring(1);
81
- // eslint-disable-next-line react-hooks/exhaustive-deps
82
- }, []);
83
- useEffect(() => {
84
- if (visible) {
85
- setModalVisibility(true);
86
- } else if (wasMeasured && modalVisibility) {
87
- // Close when sending visible = false
88
- close();
89
- }
90
- // eslint-disable-next-line react-hooks/exhaustive-deps
91
- }, [visible, wasMeasured]);
92
- useDidUpdate(() => {
93
- if (wasMeasured) {
94
- if (modalVisibility) {
95
- open();
96
- } else if (Constants.isAndroid) {
97
- onDismiss?.();
98
- }
99
- }
100
- // eslint-disable-next-line react-hooks/exhaustive-deps
101
- }, [modalVisibility, wasMeasured]);
102
- const alignmentStyle = useMemo(() => {
103
- return {
104
- flex: 1,
105
- alignItems: 'center',
106
- ...extractAlignmentsValues(props)
107
- };
108
- // eslint-disable-next-line react-hooks/exhaustive-deps
109
- }, []);
110
- const {
111
- renderDialogContent,
112
- containerProps,
113
- containerStyle
114
- } = useDialogContent({
115
- showCloseButton,
116
- close,
117
- closeButtonProps,
118
- containerStyle: propsContainerStyle,
119
- containerProps: propsContainerProps,
120
- headerProps,
121
- children
122
- });
123
- const animatedStyle = useAnimatedStyle(() => {
124
- if (isVertical) {
125
- return {
126
- transform: [{
127
- translateY: getTranslationInterpolation(visibility.value)
128
- }]
129
- };
130
- } else {
131
- return {
132
- transform: [{
133
- translateX: getTranslationInterpolation(visibility.value)
134
- }]
135
- };
136
- }
137
- });
138
- const style = useMemo(() => {
139
- return [styles.defaultDialogStyle, {
140
- backgroundColor: Colors.$backgroundDefault
141
- }, containerStyle, animatedStyle, width ? {
142
- width
143
- } : undefined, height ? {
144
- height
145
- } : undefined];
146
- // eslint-disable-next-line react-hooks/exhaustive-deps
147
- }, [containerStyle, width, height]);
148
- const shouldClose = event => {
149
- 'worklet';
150
-
151
- const wasPannedOverThreshold = Math.abs(getTranslationInterpolation(visibility.value)) >= Math.abs(hiddenLocation / 3);
152
- let velocity;
153
- switch (direction) {
154
- case DialogDirectionsEnum.DOWN:
155
- default:
156
- velocity = event.velocityY;
157
- break;
158
- case DialogDirectionsEnum.UP:
159
- velocity = -event.velocityY;
160
- break;
161
- case DialogDirectionsEnum.LEFT:
162
- velocity = -event.velocityX;
163
- break;
164
- case DialogDirectionsEnum.RIGHT:
165
- velocity = event.velocityX;
166
- break;
167
- }
168
- const wasFlung = velocity >= THRESHOLD_VELOCITY;
169
- return wasPannedOverThreshold || wasFlung;
170
- };
171
- const panGesture = Gesture.Pan().onStart(event => {
172
- initialTranslation.value = getTranslationReverseInterpolation(isVertical ? event.translationY : event.translationX) - visibility.value;
173
- }).onUpdate(event => {
174
- visibility.value = getTranslationReverseInterpolation(isVertical ? event.translationY : event.translationX) - initialTranslation.value;
175
- }).onEnd(event => {
176
- if (shouldClose(event)) {
177
- close();
178
- } else {
179
- open();
180
- }
181
- });
182
- useImperativeHandle(ref, () => ({
183
- dismiss: close
184
- }));
185
- const renderDialog = () => <GestureDetector gesture={panGesture}>
186
- <View {...containerProps} reanimated={!Constants.accessibility.isReduceMotionEnabled} style={style} onLayout={onLayout} ref={setRef} testID={testID}>
187
- {renderDialogContent()}
188
- </View>
189
- </GestureDetector>;
190
- const overlayStyle = useAnimatedStyle(() => {
191
- return {
192
- opacity: visibility.value,
193
- backgroundColor: overlayBackgroundColor
194
- };
195
- }, [overlayBackgroundColor]);
196
- const renderOverlayView = () => <View testID={`${testID}.overlayFadingBackground`} absF reanimated style={overlayStyle} pointerEvents="none" />;
197
- return <Modal transparent animationType={'none'} {...otherModalProps} testID={`${testID}.modal`} useGestureHandlerRootView visible={modalVisibility} onBackgroundPress={ignoreBackgroundPress ? undefined : close} onRequestClose={ignoreBackgroundPress ? undefined : close} onDismiss={onDismiss}>
198
- {renderOverlayView()}
199
- <View useSafeArea={useSafeArea} pointerEvents={'box-none'} style={alignmentStyle}>
200
- {renderDialog()}
201
- </View>
202
- </Modal>;
203
- };
204
- Dialog.displayName = 'Incubator.Dialog';
205
- Dialog.directions = DialogDirectionsEnum;
206
- Dialog.Header = DialogHeader;
207
- const _Dialog = forwardRef(Dialog);
208
- hoistStatics(_Dialog, Dialog);
209
- export default asBaseComponent(_Dialog);
210
- const styles = StyleSheet.create({
211
- defaultDialogStyle: {
212
- marginBottom: Spacings.s5,
213
- maxHeight: '60%',
214
- width: 250,
215
- borderRadius: BorderRadiuses.br20,
216
- overflow: 'hidden'
217
- }
218
- });