@arco-design/mobile-react 2.21.3 → 2.22.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 (63) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/_helpers/index.d.ts +1 -0
  5. package/cjs/_helpers/index.js +9 -0
  6. package/cjs/_helpers/react-dom.d.ts +13 -0
  7. package/cjs/_helpers/react-dom.js +65 -0
  8. package/cjs/_helpers/render.d.ts +10 -0
  9. package/cjs/_helpers/render.js +40 -0
  10. package/cjs/action-sheet/index.d.ts +1 -1
  11. package/cjs/image-picker/index.js +0 -1
  12. package/cjs/image-preview/index.d.ts +2 -10
  13. package/cjs/image-preview/methods.js +4 -11
  14. package/cjs/masking/index.d.ts +10 -0
  15. package/cjs/masking/methods.js +4 -11
  16. package/cjs/notify/methods.js +6 -9
  17. package/cjs/popover/hooks/useEvent.js +6 -6
  18. package/cjs/swipe-action/index.js +21 -3
  19. package/cjs/tabs/index.js +5 -2
  20. package/cjs/tabs/tab-cell.js +4 -3
  21. package/cjs/tabs/type.d.ts +11 -0
  22. package/cjs/toast/methods.js +9 -12
  23. package/dist/index.js +167 -72
  24. package/dist/index.min.js +3 -3
  25. package/esm/_helpers/index.d.ts +1 -0
  26. package/esm/_helpers/index.js +1 -0
  27. package/esm/_helpers/react-dom.d.ts +13 -0
  28. package/esm/_helpers/react-dom.js +57 -0
  29. package/esm/_helpers/render.d.ts +10 -0
  30. package/esm/_helpers/render.js +29 -0
  31. package/esm/action-sheet/index.d.ts +1 -1
  32. package/esm/image-picker/index.js +0 -1
  33. package/esm/image-preview/index.d.ts +2 -10
  34. package/esm/image-preview/methods.js +3 -9
  35. package/esm/masking/index.d.ts +10 -0
  36. package/esm/masking/methods.js +3 -9
  37. package/esm/notify/methods.js +6 -7
  38. package/esm/popover/hooks/useEvent.js +6 -6
  39. package/esm/swipe-action/index.js +21 -3
  40. package/esm/tabs/index.js +5 -2
  41. package/esm/tabs/tab-cell.js +4 -3
  42. package/esm/tabs/type.d.ts +11 -0
  43. package/esm/toast/methods.js +8 -9
  44. package/package.json +3 -3
  45. package/umd/_helpers/index.d.ts +1 -0
  46. package/umd/_helpers/index.js +10 -4
  47. package/umd/_helpers/react-dom.d.ts +13 -0
  48. package/umd/_helpers/react-dom.js +78 -0
  49. package/umd/_helpers/render.d.ts +10 -0
  50. package/umd/_helpers/render.js +51 -0
  51. package/umd/action-sheet/index.d.ts +1 -1
  52. package/umd/image-picker/index.js +0 -1
  53. package/umd/image-preview/index.d.ts +2 -10
  54. package/umd/image-preview/methods.js +6 -13
  55. package/umd/masking/index.d.ts +10 -0
  56. package/umd/masking/methods.js +6 -13
  57. package/umd/notify/methods.js +9 -12
  58. package/umd/popover/hooks/useEvent.js +6 -6
  59. package/umd/swipe-action/index.js +21 -3
  60. package/umd/tabs/index.js +5 -2
  61. package/umd/tabs/tab-cell.js +4 -3
  62. package/umd/tabs/type.d.ts +11 -0
  63. package/umd/toast/methods.js +11 -14
@@ -5,6 +5,7 @@
5
5
  import { CSSProperties } from 'react';
6
6
  export * from './hooks';
7
7
  export * from './type';
8
+ export * from './react-dom';
8
9
  export declare function getStyleWithVendor(style: CSSProperties): CSSProperties;
9
10
  /**
10
11
  * 计算默认值,仅未定义时使用默认值
@@ -6,6 +6,7 @@ import _extends from "@babel/runtime/helpers/extends";
6
6
  */
7
7
  export * from './hooks';
8
8
  export * from './type';
9
+ export * from './react-dom';
9
10
  export function getStyleWithVendor(style) {
10
11
  var allowReg = /(transform|transition|animation)/i;
11
12
  var newStyle = Object.keys(style).reduce(function (acc, key) {
@@ -0,0 +1,13 @@
1
+ import { ReactElement } from 'react';
2
+ export interface RootType {
3
+ render: (container: ReactElement) => void;
4
+ _unmount: () => void;
5
+ }
6
+ export interface RootTypeReact extends RootType {
7
+ unmount?: () => void;
8
+ }
9
+ export declare type CreateRootFnType = (container: Element | DocumentFragment) => RootTypeReact;
10
+ export declare const render: (app: ReactElement, container: Element | DocumentFragment) => {
11
+ render: (container: ReactElement) => void;
12
+ _unmount: () => void;
13
+ };
@@ -0,0 +1,57 @@
1
+ var _CopyReactDOM$version;
2
+
3
+ import ReactDOM from 'react-dom';
4
+
5
+ function isObject(obj) {
6
+ return Object.prototype.toString.call(obj) === '[object Object]';
7
+ }
8
+
9
+ var __SECRET_INTERNALS__ = '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED';
10
+ var CopyReactDOM = ReactDOM;
11
+ var copyRender;
12
+ var isReact18 = Number((_CopyReactDOM$version = CopyReactDOM.version) == null ? void 0 : _CopyReactDOM$version.split('.')[0]) > 17;
13
+
14
+ var updateUsingClientEntryPoint = function updateUsingClientEntryPoint(skipWarning) {
15
+ // https://github.com/facebook/react/blob/17806594cc28284fe195f918e8d77de3516848ec/packages/react-dom/npm/client.js#L10
16
+ // Avoid console warning
17
+ if (isObject(CopyReactDOM[__SECRET_INTERNALS__])) {
18
+ CopyReactDOM[__SECRET_INTERNALS__].usingClientEntryPoint = skipWarning;
19
+ }
20
+ };
21
+
22
+ var createRoot;
23
+
24
+ try {
25
+ createRoot = CopyReactDOM.createRoot;
26
+ } catch (_) {}
27
+
28
+ if (isReact18 && createRoot) {
29
+ copyRender = function copyRender(app, container) {
30
+ updateUsingClientEntryPoint(true);
31
+ var root = createRoot(container);
32
+ updateUsingClientEntryPoint(false);
33
+ root.render(app);
34
+
35
+ root._unmount = function () {
36
+ setTimeout(function () {
37
+ root == null ? void 0 : root.unmount == null ? void 0 : root.unmount();
38
+ });
39
+ };
40
+
41
+ return root;
42
+ };
43
+ } else {
44
+ copyRender = function copyRender(app, container) {
45
+ CopyReactDOM.render(app, container);
46
+ return {
47
+ render: function render(comment) {
48
+ CopyReactDOM.render(comment, container);
49
+ },
50
+ _unmount: function _unmount() {
51
+ CopyReactDOM.unmountComponentAtNode(container);
52
+ }
53
+ };
54
+ };
55
+ }
56
+
57
+ export var render = copyRender;
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { RootType } from './react-dom';
3
+ export declare class ReactDOMRender {
4
+ root: RootType | undefined;
5
+ app: FunctionComponent;
6
+ container: Element | DocumentFragment;
7
+ constructor(app: FunctionComponent, container: Element | DocumentFragment);
8
+ render: (props: any) => void;
9
+ unmount: () => void;
10
+ }
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { render as copyRender } from './react-dom';
3
+ export var ReactDOMRender = function ReactDOMRender(app, container) {
4
+ var _this = this;
5
+
6
+ this.root = void 0;
7
+ this.app = void 0;
8
+ this.container = void 0;
9
+
10
+ this.render = function (props) {
11
+ var CustomApp = _this.app;
12
+
13
+ if (_this.root) {
14
+ _this.root.render( /*#__PURE__*/React.createElement(CustomApp, props));
15
+ } else {
16
+ _this.root = copyRender( /*#__PURE__*/React.createElement(CustomApp, props), _this.container);
17
+ }
18
+ };
19
+
20
+ this.unmount = function () {
21
+ var _this$root;
22
+
23
+ (_this$root = _this.root) == null ? void 0 : _this$root._unmount();
24
+ _this.root = undefined;
25
+ };
26
+
27
+ this.app = app;
28
+ this.container = container;
29
+ };
@@ -26,7 +26,7 @@ export interface ActionSheetItemOptions {
26
26
  * 点击选项事件,返回值为 true 时可以阻止动作面板关闭
27
27
  * @en Click option event, actionSheet will be prevent from closing when returning true
28
28
  */
29
- onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => (void | boolean) | Promise<void | boolean>;
29
+ onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => (void | boolean) | Promise<void | boolean>;
30
30
  }
31
31
  export interface ActionSheetProps extends Omit<PopupProps, 'children' | 'getScrollContainer' | 'orientationDirection' | 'direction'> {
32
32
  /**
@@ -166,7 +166,6 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
166
166
  var timeOutEvent;
167
167
 
168
168
  var handleTouchStart = function handleTouchStart(e, image, index) {
169
- e.preventDefault();
170
169
  timeOutEvent = setTimeout(function () {
171
170
  timeOutEvent = 0;
172
171
  onLongPress == null ? void 0 : onLongPress(e, image, index);
@@ -254,11 +254,7 @@ export declare function methodsGenerator<P extends ImagePreviewProps>(Comp: Reac
254
254
  */
255
255
  open: (config: Pick<P, Exclude<keyof P, "close">>) => {
256
256
  close: () => void;
257
- update: (newConfig: Pick<P, Exclude<keyof P, "close">>) => void; /**
258
- * 是否可循环滑动
259
- * @en Whether it can be swiped circularly
260
- * @default false
261
- */
257
+ update: (newConfig: Pick<P, Exclude<keyof P, "close">>) => void;
262
258
  };
263
259
  };
264
260
  declare const _default: React.ForwardRefExoticComponent<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>> & {
@@ -270,11 +266,7 @@ declare const _default: React.ForwardRefExoticComponent<ImagePreviewProps & Reac
270
266
  */
271
267
  open: (config: Pick<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>, "style" | "ref" | "key" | "getContainer" | "className" | "onClose" | "onTouchMove" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "onChange" | "onTouchEnd" | "onTouchStart" | "animateDurationSlide" | "loop" | "swipeable" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "lazyloadCount" | "onAfterChange" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => {
272
268
  close: () => void;
273
- update: (newConfig: Pick<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>, "style" | "ref" | "key" | "getContainer" | "className" | "onClose" | "onTouchMove" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "onChange" | "onTouchEnd" | "onTouchStart" | "animateDurationSlide" | "loop" | "swipeable" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "lazyloadCount" | "onAfterChange" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => void; /**
274
- * 是否可循环滑动
275
- * @en Whether it can be swiped circularly
276
- * @default false
277
- */
269
+ update: (newConfig: Pick<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>, "style" | "ref" | "key" | "getContainer" | "className" | "onClose" | "onTouchMove" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "onChange" | "onTouchEnd" | "onTouchStart" | "animateDurationSlide" | "loop" | "swipeable" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "lazyloadCount" | "onAfterChange" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => void;
278
270
  };
279
271
  };
280
272
  /**
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import ReactDOM from 'react-dom';
4
2
  import { appendElementById, removeElement } from '@arco-design/mobile-utils';
3
+ import { ReactDOMRender } from '../_helpers/render';
5
4
  export function open(Component) {
6
5
  return function (config) {
7
6
  var baseProps = _extends({
@@ -21,13 +20,8 @@ export function open(Component) {
21
20
 
22
21
  var leaving = false;
23
22
 
24
- function render(props) {
25
- ReactDOM.render( /*#__PURE__*/React.createElement(Component, _extends({}, props, {
26
- getContainer: function getContainer() {
27
- return div;
28
- }
29
- })), div);
30
- }
23
+ var _ReactDOMRender = new ReactDOMRender(Component, div),
24
+ render = _ReactDOMRender.render;
31
25
 
32
26
  function update(newConfig) {
33
27
  dynamicProps = _extends({}, dynamicProps, newConfig || {});
@@ -192,6 +192,11 @@ export declare function methodsGenerator<P extends OpenBaseProps>(Comp: React.Fu
192
192
  open: (config: Pick<P, Exclude<keyof P, "visible" | "close">> & {
193
193
  key?: string | undefined;
194
194
  }) => {
195
+ /**
196
+ * 点击蒙层是否关闭菜单
197
+ * @en Whether to click the mask to close the menu
198
+ * @default true
199
+ */
195
200
  close: () => void;
196
201
  update: (newConfig: Pick<P, Exclude<keyof P, "visible" | "close">> & {
197
202
  key?: string | undefined;
@@ -208,6 +213,11 @@ declare const _default: React.ForwardRefExoticComponent<MaskingProps & React.Ref
208
213
  open: (config: Pick<MaskingProps & React.RefAttributes<MaskingRef>, "ref" | "children" | "key" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "className" | "onClose" | "contentAtCenter" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onTouchMove" | "onPreventTouchMove" | "getScrollContainer"> & {
209
214
  key?: string | undefined;
210
215
  }) => {
216
+ /**
217
+ * 点击蒙层是否关闭菜单
218
+ * @en Whether to click the mask to close the menu
219
+ * @default true
220
+ */
211
221
  close: () => void;
212
222
  update: (newConfig: Pick<MaskingProps & React.RefAttributes<MaskingRef>, "ref" | "children" | "key" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "className" | "onClose" | "contentAtCenter" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onTouchMove" | "onPreventTouchMove" | "getScrollContainer"> & {
213
223
  key?: string | undefined;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import ReactDOM from 'react-dom';
4
2
  import { appendElementById, removeElement, nextTick } from '@arco-design/mobile-utils';
3
+ import { ReactDOMRender } from '../_helpers/render';
5
4
  export function getOpenMethod(Component, containerId, normalize) {
6
5
  if (normalize === void 0) {
7
6
  normalize = function normalize(config) {
@@ -27,13 +26,8 @@ export function getOpenMethod(Component, containerId, normalize) {
27
26
 
28
27
  var leaving = false;
29
28
 
30
- function render(props) {
31
- ReactDOM.render( /*#__PURE__*/React.createElement(Component, _extends({}, props, {
32
- getContainer: function getContainer() {
33
- return div;
34
- }
35
- })), div);
36
- }
29
+ var _ReactDOMRender = new ReactDOMRender(Component, div),
30
+ render = _ReactDOMRender.render;
37
31
 
38
32
  function update(newConfig) {
39
33
  dynamicProps = _extends({}, dynamicProps, normalize(newConfig));
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import { nextTick } from '@arco-design/mobile-utils';
3
- import React from 'react';
4
- import ReactDOM from 'react-dom';
3
+ import { ReactDOMRender } from '../_helpers/render';
5
4
  export function notify(Component, type) {
6
5
  return function (originConfig) {
7
6
  var config = typeof originConfig === 'string' ? {
@@ -22,16 +21,16 @@ export function notify(Component, type) {
22
21
  document.body.appendChild(div);
23
22
  }
24
23
 
25
- function render(props) {
26
- ReactDOM.render( /*#__PURE__*/React.createElement(Component, props), div);
27
- }
24
+ var _ReactDOMRender = new ReactDOMRender(Component, div),
25
+ render = _ReactDOMRender.render,
26
+ unmount = _ReactDOMRender.unmount;
28
27
 
29
28
  function destroy() {
30
29
  var onClose = config.onClose;
31
30
  onClose && onClose();
32
- var unmountResult = ReactDOM.unmountComponentAtNode(div);
31
+ unmount();
33
32
 
34
- if (unmountResult && div.parentNode) {
33
+ if (div.parentNode) {
35
34
  div.parentNode.removeChild(div);
36
35
  }
37
36
  }
@@ -40,6 +40,7 @@ export var useEvent = function useEvent(props, wrapperRef, popoverInnerRef, visi
40
40
  onVisibleChange(false);
41
41
  window.clearTimeout(closeTimer.current);
42
42
  closeTimer.current = 0;
43
+ mayRemoveEventListenerOnBody();
43
44
  };
44
45
 
45
46
  var throttleHandleVerticalScroll = useMemo(function () {
@@ -59,7 +60,7 @@ export var useEvent = function useEvent(props, wrapperRef, popoverInnerRef, visi
59
60
  };
60
61
  }, [throttleHandleVerticalScroll, getVerticalScrollContainer, autoVerticalDirection, visibleRef]);
61
62
  var mayRemoveEventListenerOnBody = useCallback(function () {
62
- document.body.removeEventListener('click', handleClickBody);
63
+ document.body.removeEventListener('click', handleClickBody, true);
63
64
  document.body.removeEventListener('touchstart', handleTouchBody);
64
65
  var el = getVerticalScrollContainer();
65
66
 
@@ -74,7 +75,6 @@ export var useEvent = function useEvent(props, wrapperRef, popoverInnerRef, visi
74
75
  // 仅处理子元素和气泡元素外的点击事件
75
76
  // @en Only handle click events outside of children elements and bubble elements
76
77
  if (!isContains(wrapperRef.current, e.target) && !isContains(((_popoverInnerRef$curr = popoverInnerRef.current) == null ? void 0 : _popoverInnerRef$curr.dom) || null, e.target)) {
77
- // TODO: 这里仅阻止了react事件,react 18 将不再在document上挂事件,这里的stop会失效
78
78
  if (preventBodyClick) {
79
79
  e.stopPropagation();
80
80
  e.preventDefault();
@@ -100,13 +100,13 @@ export var useEvent = function useEvent(props, wrapperRef, popoverInnerRef, visi
100
100
  var handle = function handle(e) {
101
101
  e.stopPropagation();
102
102
  e.preventDefault();
103
- document.body.removeEventListener('click', handle);
103
+ document.body.removeEventListener('click', handle, true);
104
104
  clearTimeout(preventRecentClickTimer);
105
105
  };
106
106
 
107
- document.body.addEventListener('click', handle);
107
+ document.body.addEventListener('click', handle, true);
108
108
  preventRecentClickTimer = window.setTimeout(function () {
109
- document.body.removeEventListener('click', handle);
109
+ document.body.removeEventListener('click', handle, true);
110
110
  }, 500);
111
111
  };
112
112
 
@@ -149,7 +149,7 @@ export var useEvent = function useEvent(props, wrapperRef, popoverInnerRef, visi
149
149
  var el = getVerticalScrollContainer();
150
150
  el && el.addEventListener('scroll', handleScrollBody);
151
151
  } else if (clickOtherToClose) {
152
- document.body.addEventListener('click', handleClickBody);
152
+ document.body.addEventListener('click', handleClickBody, true);
153
153
  }
154
154
  };
155
155
  /**
@@ -51,6 +51,7 @@ var SwipeAction = /*#__PURE__*/forwardRef(function (props, ref) {
51
51
 
52
52
  var dampRateRef = useLatestRef(dampRate);
53
53
  var forbidClick = useRef(false);
54
+ var scrollingRef = useRef(null);
54
55
 
55
56
  var _useRefState = useRefState(false),
56
57
  moving = _useRefState[0],
@@ -67,6 +68,7 @@ var SwipeAction = /*#__PURE__*/forwardRef(function (props, ref) {
67
68
 
68
69
  var startRef = useRef(0);
69
70
  var startX = useRef(0);
71
+ var startY = useRef(0);
70
72
  var slideX = useRef(0);
71
73
  var isLayer = openStyleType === 'layer';
72
74
  var transitionStyle = useMemo(function () {
@@ -77,6 +79,7 @@ var SwipeAction = /*#__PURE__*/forwardRef(function (props, ref) {
77
79
 
78
80
  function resetMoveData() {
79
81
  startX.current = 0;
82
+ startY.current = 0;
80
83
  slideX.current = 0;
81
84
  }
82
85
 
@@ -88,19 +91,34 @@ var SwipeAction = /*#__PURE__*/forwardRef(function (props, ref) {
88
91
  function touchstart(e) {
89
92
  startRef.current = offsetRef.current;
90
93
  resetMoveData();
94
+ scrollingRef.current = null;
91
95
  startX.current = e.touches[0].pageX;
96
+ startY.current = e.touches[0].pageY;
92
97
  }
93
98
 
94
99
  function touchmove(e) {
95
- e.preventDefault();
96
- slideX.current = e.touches[0].pageX - startX.current;
100
+ var x = e.changedTouches[0].pageX - startX.current;
101
+ var y = e.changedTouches[0].pageY - startY.current;
102
+
103
+ if (scrollingRef.current === null) {
104
+ scrollingRef.current = Math.abs(x) < Math.abs(y);
105
+ }
106
+
107
+ if (scrollingRef.current) {
108
+ setMoving(false);
109
+ setOffset(0);
110
+ return;
111
+ }
112
+
113
+ e.cancelable && e.preventDefault();
114
+ slideX.current = x;
97
115
  forbidClick.current = true;
98
116
  setMoving(true);
99
117
  setOffset(getMenuCurrentWidth(slideX.current + startRef.current, -rightMenuWidthRef.current, leftMenuWidthRef.current));
100
118
  }
101
119
 
102
120
  function touchend() {
103
- if (movingRef.current) {
121
+ if (movingRef.current && !scrollingRef.current) {
104
122
  var currentMenu = offsetRef.current > 0 ? 'left' : 'right';
105
123
  changeMenu(currentMenu);
106
124
  setMoving(false);
package/esm/tabs/index.js CHANGED
@@ -117,7 +117,9 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
117
117
  _props$translateZ = props.translateZ,
118
118
  translateZ = _props$translateZ === void 0 ? true : _props$translateZ,
119
119
  fullScreen = props.fullScreen,
120
- autoHeight = props.autoHeight;
120
+ autoHeight = props.autoHeight,
121
+ _props$tabBarStopProp = props.tabBarStopPropagation,
122
+ tabBarStopPropagation = _props$tabBarStopProp === void 0 ? true : _props$tabBarStopProp;
121
123
  var domRef = useRef(null);
122
124
  var cellRef = useRef(null);
123
125
  var paneRef = useRef(null);
@@ -472,7 +474,8 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
472
474
  renderTabBarItem: renderTabBarItem,
473
475
  renderTabBarInner: renderTabBarInner,
474
476
  tabBarStyle: tabBarStyle,
475
- tabBarClass: tabBarClass
477
+ tabBarClass: tabBarClass,
478
+ tabBarStopPropagation: tabBarStopPropagation
476
479
  }, commonProps);
477
480
 
478
481
  var CellComp = /*#__PURE__*/React.createElement(TabCell, cellProps);
@@ -48,7 +48,8 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
48
48
  renderTabBarInner = props.renderTabBarInner,
49
49
  tabBarStyle = props.tabBarStyle,
50
50
  tabBarClass = props.tabBarClass,
51
- translateZ = props.translateZ;
51
+ translateZ = props.translateZ,
52
+ tabBarStopPropagation = props.tabBarStopPropagation;
52
53
  var prefix = prefixCls + "-tab-cell";
53
54
  var domRef = useRef(null);
54
55
  var underlineRef = useRef(null);
@@ -140,13 +141,13 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
140
141
  return e.stopPropagation();
141
142
  };
142
143
 
143
- if (isVertical && hasOverflow && domRef.current) {
144
+ if (isVertical && hasOverflow && domRef.current && tabBarStopPropagation) {
144
145
  domRef.current.addEventListener('touchstart', stopFunc);
145
146
  domRef.current.addEventListener('touchmove', stopFunc);
146
147
  }
147
148
 
148
149
  return function () {
149
- if (isVertical && hasOverflow && domRef.current) {
150
+ if (isVertical && hasOverflow && domRef.current && tabBarStopPropagation) {
150
151
  domRef.current.removeEventListener('touchstart', stopFunc);
151
152
  domRef.current.removeEventListener('touchmove', stopFunc);
152
153
  }
@@ -421,6 +421,12 @@ export interface TabsProps {
421
421
  * @en Tabbar underline inner style, applied to tab-cell-underline-inner
422
422
  */
423
423
  underlineInnerStyle?: React.CSSProperties;
424
+ /**
425
+ * 当前 TabBar 的触摸事件是否需要 stopPropagation
426
+ * @en Does the touch event of the current TabBar require stopPropagation
427
+ * @default true
428
+ */
429
+ tabBarStopPropagation?: boolean;
424
430
  }
425
431
  export interface TabsRef {
426
432
  /**
@@ -510,6 +516,11 @@ export interface TabCellProps extends Pick<TabsProps, 'tabs' | 'type' | 'onTabCl
510
516
  * @en The distance the underline has been swiped
511
517
  */
512
518
  jumpingDis: number;
519
+ /**
520
+ * 当前 TabBar 的触摸事件是否需要 stopPropagation
521
+ * @en Does the touch event of the current TabBar require stopPropagation
522
+ */
523
+ tabBarStopPropagation: boolean;
513
524
  }
514
525
  export interface TabCellRef {
515
526
  /**
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import ReactDOM from 'react-dom';
4
2
  import { nextTick } from '@arco-design/mobile-utils';
3
+ import { ReactDOMRender } from '../_helpers/render';
5
4
  export function toast(Component, type) {
6
5
  return function (originConfig) {
7
6
  var config = typeof originConfig === 'string' ? {
@@ -17,16 +16,16 @@ export function toast(Component, type) {
17
16
  var div = document.createElement('div');
18
17
  document.body.appendChild(div);
19
18
 
20
- function render(props) {
21
- ReactDOM.render( /*#__PURE__*/React.createElement(Component, props), div);
22
- }
19
+ var _ReactDOMRender = new ReactDOMRender(Component, div),
20
+ render = _ReactDOMRender.render,
21
+ unmount = _ReactDOMRender.unmount;
23
22
 
24
- function destory() {
23
+ function destroy() {
25
24
  var onClose = config.onClose;
26
25
  onClose && onClose();
27
- var unmountResult = ReactDOM.unmountComponentAtNode(div);
26
+ unmount();
28
27
 
29
- if (unmountResult && div.parentNode) {
28
+ if (div.parentNode) {
30
29
  div.parentNode.removeChild(div);
31
30
  }
32
31
  }
@@ -36,7 +35,7 @@ export function toast(Component, type) {
36
35
  getContainer: function getContainer() {
37
36
  return div;
38
37
  },
39
- onClose: destory,
38
+ onClose: destroy,
40
39
  visible: false
41
40
  });
42
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.21.3",
3
+ "version": "2.22.0",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -15,7 +15,7 @@
15
15
  "author": "taoyiyue@bytedance.com",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@arco-design/mobile-utils": "^2.12.3",
18
+ "@arco-design/mobile-utils": "^2.12.4",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "es6-promise": "^4.2.8",
21
21
  "lodash.throttle": "^4.1.1",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "12927a2cee1ac841f4e96754c72e6cd95633e68a"
39
+ "gitHead": "00c2641c2230e9115db0af84f0b16545b6c8b8e3"
40
40
  }
@@ -5,6 +5,7 @@
5
5
  import { CSSProperties } from 'react';
6
6
  export * from './hooks';
7
7
  export * from './type';
8
+ export * from './react-dom';
8
9
  export declare function getStyleWithVendor(style: CSSProperties): CSSProperties;
9
10
  /**
10
11
  * 计算默认值,仅未定义时使用默认值
@@ -1,16 +1,16 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/helpers/extends", "./hooks", "./type"], factory);
3
+ define(["exports", "@babel/runtime/helpers/extends", "./hooks", "./type", "./react-dom"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/helpers/extends"), require("./hooks"), require("./type"));
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("./hooks"), require("./type"), require("./react-dom"));
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(mod.exports, global._extends, global.hooks, global.type);
10
+ factory(mod.exports, global._extends, global.hooks, global.type, global.reactDom);
11
11
  global.index = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends3, _hooks, _type) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends3, _hooks, _type, _reactDom) {
14
14
  "use strict";
15
15
 
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -35,6 +35,12 @@
35
35
  if (key in _exports && _exports[key] === _type[key]) return;
36
36
  _exports[key] = _type[key];
37
37
  });
38
+ Object.keys(_reactDom).forEach(function (key) {
39
+ if (key === "default" || key === "__esModule") return;
40
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
41
+ if (key in _exports && _exports[key] === _reactDom[key]) return;
42
+ _exports[key] = _reactDom[key];
43
+ });
38
44
 
39
45
  /**
40
46
  * @type utils
@@ -0,0 +1,13 @@
1
+ import { ReactElement } from 'react';
2
+ export interface RootType {
3
+ render: (container: ReactElement) => void;
4
+ _unmount: () => void;
5
+ }
6
+ export interface RootTypeReact extends RootType {
7
+ unmount?: () => void;
8
+ }
9
+ export declare type CreateRootFnType = (container: Element | DocumentFragment) => RootTypeReact;
10
+ export declare const render: (app: ReactElement, container: Element | DocumentFragment) => {
11
+ render: (container: ReactElement) => void;
12
+ _unmount: () => void;
13
+ };