@arco-design/mobile-react 2.29.4 → 2.29.6

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 (86) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/action-sheet/index.d.ts +2 -2
  5. package/cjs/dialog/index.d.ts +2 -2
  6. package/cjs/image/index.d.ts +7 -7
  7. package/cjs/image/index.js +81 -61
  8. package/cjs/image-picker/index.js +14 -6
  9. package/cjs/image-preview/index.d.ts +2 -2
  10. package/cjs/image-preview/index.js +11 -5
  11. package/cjs/image-preview/methods.d.ts +1 -0
  12. package/cjs/image-preview/methods.js +7 -2
  13. package/cjs/index.d.ts +5 -5
  14. package/cjs/index.js +16 -16
  15. package/cjs/load-more/index.d.ts +7 -2
  16. package/cjs/load-more/index.js +9 -1
  17. package/cjs/masking/index.d.ts +2 -2
  18. package/cjs/masking/methods.js +7 -2
  19. package/cjs/popup/index.d.ts +2 -2
  20. package/cjs/popup-swiper/index.d.ts +4 -10
  21. package/cjs/pull-refresh/android-pull-refresh.js +12 -20
  22. package/cjs/pull-refresh/hooks.js +2 -2
  23. package/cjs/pull-refresh/style/css/index.css +0 -1
  24. package/cjs/pull-refresh/style/index.less +0 -1
  25. package/cjs/style.d.ts +5 -5
  26. package/cjs/style.js +8 -8
  27. package/cjs/tabs/index.js +4 -1
  28. package/cjs/tabs/tab-pane.js +5 -2
  29. package/cjs/toast/index.d.ts +12 -12
  30. package/dist/index.js +2505 -2458
  31. package/dist/index.min.js +4 -4
  32. package/dist/style.css +503 -504
  33. package/dist/style.min.css +1 -1
  34. package/esm/action-sheet/index.d.ts +2 -2
  35. package/esm/dialog/index.d.ts +2 -2
  36. package/esm/image/index.d.ts +7 -7
  37. package/esm/image/index.js +81 -61
  38. package/esm/image-picker/index.js +13 -6
  39. package/esm/image-preview/index.d.ts +2 -2
  40. package/esm/image-preview/index.js +11 -5
  41. package/esm/image-preview/methods.d.ts +1 -0
  42. package/esm/image-preview/methods.js +7 -3
  43. package/esm/index.d.ts +5 -5
  44. package/esm/index.js +5 -5
  45. package/esm/load-more/index.d.ts +7 -2
  46. package/esm/load-more/index.js +9 -1
  47. package/esm/masking/index.d.ts +2 -2
  48. package/esm/masking/methods.js +7 -3
  49. package/esm/popup/index.d.ts +2 -2
  50. package/esm/popup-swiper/index.d.ts +4 -10
  51. package/esm/pull-refresh/android-pull-refresh.js +13 -22
  52. package/esm/pull-refresh/hooks.js +2 -2
  53. package/esm/pull-refresh/style/css/index.css +0 -1
  54. package/esm/pull-refresh/style/index.less +0 -1
  55. package/esm/style.d.ts +5 -5
  56. package/esm/style.js +5 -5
  57. package/esm/tabs/index.js +4 -1
  58. package/esm/tabs/tab-pane.js +6 -3
  59. package/esm/toast/index.d.ts +12 -12
  60. package/package.json +3 -3
  61. package/umd/action-sheet/index.d.ts +2 -2
  62. package/umd/dialog/index.d.ts +2 -2
  63. package/umd/image/index.d.ts +7 -7
  64. package/umd/image/index.js +81 -61
  65. package/umd/image-picker/index.js +16 -10
  66. package/umd/image-preview/index.d.ts +2 -2
  67. package/umd/image-preview/index.js +11 -5
  68. package/umd/image-preview/methods.d.ts +1 -0
  69. package/umd/image-preview/methods.js +7 -2
  70. package/umd/index.d.ts +5 -5
  71. package/umd/index.js +14 -14
  72. package/umd/load-more/index.d.ts +7 -2
  73. package/umd/load-more/index.js +9 -1
  74. package/umd/masking/index.d.ts +2 -2
  75. package/umd/masking/methods.js +7 -2
  76. package/umd/popup/index.d.ts +2 -2
  77. package/umd/popup-swiper/index.d.ts +4 -10
  78. package/umd/pull-refresh/android-pull-refresh.js +15 -24
  79. package/umd/pull-refresh/hooks.js +2 -2
  80. package/umd/pull-refresh/style/css/index.css +0 -1
  81. package/umd/pull-refresh/style/index.less +0 -1
  82. package/umd/style.d.ts +5 -5
  83. package/umd/style.js +2 -2
  84. package/umd/tabs/index.js +4 -1
  85. package/umd/tabs/tab-pane.js +5 -2
  86. package/umd/toast/index.d.ts +12 -12
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.29.6](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.29.5...@arco-design/mobile-react@2.29.6) (2023-10-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `Image` support loading & error area when using "staticLabel" ([#181](https://github.com/arco-design/arco-design-mobile/issues/181)) ([552a37d](https://github.com/arco-design/arco-design-mobile/commit/552a37d5a29cbbbe84107c0ba7cddeb1c685f2be))
12
+ * `Tabs` duplicate scrolling when "activeTab" is controlled in scroll mode ([7632138](https://github.com/arco-design/arco-design-mobile/commit/7632138f8d1164d8be6b55f5a65cc543b3b22684))
13
+ * incorrectly mounted elements when calling masking components using methods ([5740648](https://github.com/arco-design/arco-design-mobile/commit/5740648160fb6ff6d97a40da71c28d16034b4346))
14
+
15
+
16
+
17
+
18
+
19
+ ## [2.29.5](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.29.4...@arco-design/mobile-react@2.29.5) (2023-10-07)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * `ImagePicker` the image will show up again if deleted when uploading ([#182](https://github.com/arco-design/arco-design-mobile/issues/182)) ([f26512a](https://github.com/arco-design/arco-design-mobile/commit/f26512a165e3c8ca082f716a64bdc8e7e86517b7))
25
+ * `ImagePreview` refresh problem when onload of multiple pictures is triggered at the same time ([#173](https://github.com/arco-design/arco-design-mobile/issues/173)) ([c71c526](https://github.com/arco-design/arco-design-mobile/commit/c71c526e81a2851df6653682bfad9b9b84704462))
26
+ * `LoadMore` support "getDataWithEndReachCheck" ([#180](https://github.com/arco-design/arco-design-mobile/issues/180)) ([25baa3c](https://github.com/arco-design/arco-design-mobile/commit/25baa3cae665edb7fa4f316d80886f497c38f7a3))
27
+ * `PullRefresh` optimize transform performance & fix decimal point deviation in ifShouldHandle ([#179](https://github.com/arco-design/arco-design-mobile/issues/179)) ([a826ed2](https://github.com/arco-design/arco-design-mobile/commit/a826ed26096cec3a6487d2bd58345113a5d17dfd))
28
+ * `Tabs` scroll offset in ssr when defaultActiveTab is greater than 0 ([#175](https://github.com/arco-design/arco-design-mobile/issues/175)) ([98aa1d7](https://github.com/arco-design/arco-design-mobile/commit/98aa1d7c5abe8851778f2aa5c2308fe807d5e4d9))
29
+
30
+
31
+
32
+
33
+
6
34
  ## [2.29.4](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.29.3...@arco-design/mobile-react@2.29.4) (2023-09-13)
7
35
 
8
36
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.29.3/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.29.3/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.29.5/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.29.5/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.29.3/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.29.3/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.29.5/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.29.5/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -86,11 +86,11 @@ declare const _default: React.ForwardRefExoticComponent<ActionSheetProps & React
86
86
  * @param {ActionSheetProps} config setting
87
87
  * @returns {{ close: () => void; update: (newConfig: ActionSheetProps) => void; }}
88
88
  */
89
- open: (config: Pick<import("../context-provider").WithGlobalContext<ActionSheetProps & React.RefAttributes<ActionSheetRef>>, "title" | "ref" | "key" | "context" | "translateZ" | "className" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "needBottomOffset" | "items" | "cancelText" | "subTitle"> & {
89
+ open: (config: Pick<import("../context-provider").WithGlobalContext<ActionSheetProps & React.RefAttributes<ActionSheetRef>>, "title" | "ref" | "key" | "context" | "translateZ" | "className" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "initialBodyOverflow" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "preventBodyScroll" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "needBottomOffset" | "items" | "cancelText" | "subTitle"> & {
90
90
  key?: string | undefined;
91
91
  }, context?: import("../context-provider").GlobalContextParams | undefined) => {
92
92
  close: () => void;
93
- update: (newConfig: Pick<import("../context-provider").WithGlobalContext<ActionSheetProps & React.RefAttributes<ActionSheetRef>>, "title" | "ref" | "key" | "context" | "translateZ" | "className" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "needBottomOffset" | "items" | "cancelText" | "subTitle"> & {
93
+ update: (newConfig: Pick<import("../context-provider").WithGlobalContext<ActionSheetProps & React.RefAttributes<ActionSheetRef>>, "title" | "ref" | "key" | "context" | "translateZ" | "className" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "initialBodyOverflow" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "preventBodyScroll" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "needBottomOffset" | "items" | "cancelText" | "subTitle"> & {
94
94
  key?: string | undefined;
95
95
  }) => void;
96
96
  };
@@ -193,11 +193,11 @@ declare const _default: React.ForwardRefExoticComponent<DialogProps & React.RefA
193
193
  * @param {DialogProps} config Configuration
194
194
  * @returns {{ close: () => void; update: (newConfig: DialogProps) => void; }}
195
195
  */
196
- open: (config: Pick<import("../context-provider").WithGlobalContext<DialogProps & React.RefAttributes<DialogRef>>, "platform" | "footer" | "title" | "children" | "ref" | "key" | "context" | "className" | "getScrollContainer" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "footerType" | "renderFooter" | "footerCollapseCount" | "titleAlign" | "contentAlign" | "extra"> & {
196
+ open: (config: Pick<import("../context-provider").WithGlobalContext<DialogProps & React.RefAttributes<DialogRef>>, "platform" | "footer" | "title" | "children" | "ref" | "key" | "context" | "className" | "getScrollContainer" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "initialBodyOverflow" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "footerType" | "renderFooter" | "footerCollapseCount" | "titleAlign" | "contentAlign" | "extra"> & {
197
197
  key?: string | undefined;
198
198
  }, context?: import("../context-provider").GlobalContextParams | undefined) => {
199
199
  close: () => void;
200
- update: (newConfig: Pick<import("../context-provider").WithGlobalContext<DialogProps & React.RefAttributes<DialogRef>>, "platform" | "footer" | "title" | "children" | "ref" | "key" | "context" | "className" | "getScrollContainer" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "initialBodyOverflow" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "footerType" | "renderFooter" | "footerCollapseCount" | "titleAlign" | "contentAlign" | "extra"> & {
200
+ update: (newConfig: Pick<import("../context-provider").WithGlobalContext<DialogProps & React.RefAttributes<DialogRef>>, "platform" | "footer" | "title" | "children" | "ref" | "key" | "context" | "className" | "getScrollContainer" | "onTouchMove" | "getContainer" | "mountOnEnter" | "unmountOnExit" | "onClose" | "initialBodyOverflow" | "maskClass" | "maskStyle" | "contentClass" | "contentStyle" | "maskTransitionType" | "contentTransitionType" | "maskTransitionTimeout" | "contentTransitionTimeout" | "maskClosable" | "animatingClosable" | "orientationDirection" | "preventBodyScroll" | "gestureOutOfControl" | "onOpen" | "onMaskClick" | "onPreventTouchMove" | "footerType" | "renderFooter" | "footerCollapseCount" | "titleAlign" | "contentAlign" | "extra"> & {
201
201
  key?: string | undefined;
202
202
  }) => void;
203
203
  };
@@ -60,22 +60,22 @@ export interface ImageProps {
60
60
  * */
61
61
  bordered?: boolean;
62
62
  /**
63
- * 自定义展示加载中内容,staticLabel=false时有效
63
+ * 自定义展示加载中内容
64
64
  * @en Custom display loading content, valid when staticLabel=false
65
65
  * */
66
66
  loadingArea?: ReactNode;
67
67
  /**
68
- * 自定义展示加载失败内容,staticLabel=false时有效
68
+ * 自定义展示加载失败内容
69
69
  * @en Custom display failed to load content, valid when staticLabel=false
70
70
  * */
71
71
  errorArea?: ReactNode;
72
72
  /**
73
- * 是否展示图片加载中提示,staticLabel=false时有效
73
+ * 是否展示图片加载中提示
74
74
  * @en Whether to display the image loading prompt, valid when staticLabel=false
75
75
  * */
76
76
  showLoading?: boolean;
77
77
  /**
78
- * 是否展示图片加载失败提示,staticLabel=false时有效
78
+ * 是否展示图片加载失败提示
79
79
  * @en Whether to display the image loading failure prompt, valid when staticLabel=false
80
80
  * */
81
81
  showError?: boolean;
@@ -145,17 +145,17 @@ export interface ImageProps {
145
145
  * 图片加载完毕时触发的回调
146
146
  * @en Callback when the image is loaded
147
147
  * */
148
- onLoad?: (e: Event, image: HTMLImageElement) => void;
148
+ onLoad?: (e: Event | null, image: HTMLImageElement) => void;
149
149
  /**
150
150
  * 图片加载失败时触发的回调,如果有自动重试则在重试最终失败后触发
151
151
  * @en Callback when the image fails to load, triggered after the retry finally fails if there is an automatic retry
152
152
  */
153
- onError?: (e: string | Event) => void;
153
+ onError?: (e: string | Event | null) => void;
154
154
  /**
155
155
  * 图片加载失败时自动重试触发的回调
156
156
  * @en Callback triggered by automatic retry when image loading fails
157
157
  */
158
- onAutoRetry?: (e: string | Event) => void;
158
+ onAutoRetry?: (e: string | Event | null) => void;
159
159
  }
160
160
  export interface ImageRef {
161
161
  /**
@@ -30,30 +30,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
30
30
  * @name_en Image
31
31
  */
32
32
  var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
33
- var system = (0, _helpers.useSystem)();
34
-
35
- var _useWindowSize = (0, _helpers.useWindowSize)(),
36
- windowWidth = _useWindowSize.windowWidth,
37
- windowHeight = _useWindowSize.windowHeight;
38
-
39
- var _useMountedState = (0, _helpers.useMountedState)('init'),
40
- imageStatus = _useMountedState[0],
41
- setImageStatus = _useMountedState[1];
42
-
43
- var _useMountedState2 = (0, _helpers.useMountedState)(''),
44
- wrapClass = _useMountedState2[0],
45
- setWrapClass = _useMountedState2[1];
46
-
47
- var _useMountedState3 = (0, _helpers.useMountedState)(false),
48
- staticRetrying = _useMountedState3[0],
49
- setStaticRetrying = _useMountedState3[1];
50
-
51
- var imageRef = (0, _react.useRef)(null);
52
- var imageDomRef = (0, _react.useRef)(null);
53
- var wrapRef = (0, _react.useRef)(null);
54
- var retryCountRef = (0, _react.useRef)(0);
55
- var loadingImageRef = (0, _react.useRef)(null);
56
- var hasLoadedRef = (0, _react.useRef)(false);
57
33
  var style = props.style,
58
34
  className = props.className,
59
35
  status = props.status,
@@ -90,9 +66,33 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
90
66
  nativeProps = _props$nativeProps === void 0 ? {} : _props$nativeProps,
91
67
  onChange = props.onChange,
92
68
  onClick = props.onClick,
93
- _onLoad = props.onLoad,
69
+ onLoad = props.onLoad,
94
70
  onError = props.onError,
95
71
  onAutoRetry = props.onAutoRetry;
72
+ var system = (0, _helpers.useSystem)();
73
+
74
+ var _useWindowSize = (0, _helpers.useWindowSize)(),
75
+ windowWidth = _useWindowSize.windowWidth,
76
+ windowHeight = _useWindowSize.windowHeight;
77
+
78
+ var _useMountedState = (0, _helpers.useMountedState)(staticLabel && showLoading ? 'loading' : 'init'),
79
+ imageStatus = _useMountedState[0],
80
+ setImageStatus = _useMountedState[1];
81
+
82
+ var _useMountedState2 = (0, _helpers.useMountedState)(''),
83
+ wrapClass = _useMountedState2[0],
84
+ setWrapClass = _useMountedState2[1];
85
+
86
+ var _useMountedState3 = (0, _helpers.useMountedState)(false),
87
+ staticRetrying = _useMountedState3[0],
88
+ setStaticRetrying = _useMountedState3[1];
89
+
90
+ var imageRef = (0, _react.useRef)(null);
91
+ var imageDomRef = (0, _react.useRef)(null);
92
+ var wrapRef = (0, _react.useRef)(null);
93
+ var retryCountRef = (0, _react.useRef)(0);
94
+ var loadingImageRef = (0, _react.useRef)(null);
95
+ var hasLoadedRef = (0, _react.useRef)(false);
96
96
  var isPreview = Boolean(fit.indexOf('preview') >= 0);
97
97
  var actualBoxWidth = boxWidth || windowWidth;
98
98
  var actualBoxHeight = boxHeight || windowHeight;
@@ -128,6 +128,21 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
128
128
  retryCountRef.current = 0;
129
129
  loadImage();
130
130
  }, [attrs, width, height, showImage, staticLabel]);
131
+ (0, _react.useEffect)(function () {
132
+ var _imageDomRef$current;
133
+
134
+ // 当使用img标签时,onLoad可能加载完成前已经执行完,此时手动触发一次
135
+ // @en When using the img tag, onLoad may have been executed before loading is complete, and it needs to be triggered manually
136
+ if (staticLabel && !hasLoadedRef.current && (_imageDomRef$current = imageDomRef.current) != null && _imageDomRef$current.complete) {
137
+ // 图片有宽高认为正常加载,否则认为加载错误
138
+ // @en If the image has width and height, it is considered to be loaded normally, otherwise it is considered to be a loading error
139
+ if (imageDomRef.current.naturalWidth || imageDomRef.current.naturalHeight) {
140
+ handleImageLoaded(null, imageDomRef.current);
141
+ } else {
142
+ handleStaticImageError(null);
143
+ }
144
+ }
145
+ }, [staticLabel]);
131
146
 
132
147
  function changeStatus(newStatus) {
133
148
  setImageStatus(newStatus);
@@ -148,6 +163,43 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
148
163
  }
149
164
  }
150
165
 
166
+ function handleImageLoaded(evt, image) {
167
+ hasLoadedRef.current = true;
168
+ changeStatus('loaded');
169
+ var _image$width = image.width,
170
+ imageWidth = _image$width === void 0 ? 0 : _image$width,
171
+ _image$height = image.height,
172
+ imageHeight = _image$height === void 0 ? 0 : _image$height;
173
+ var extraClass = '';
174
+
175
+ if (isPreview) {
176
+ var scale = imageWidth / imageHeight;
177
+ var windowScale = actualBoxWidth / actualBoxHeight;
178
+
179
+ if (fit === 'preview-y') {
180
+ if (scale < windowScale) {
181
+ image.style.width = actualBoxWidth + "px";
182
+ image.style.height = actualBoxWidth / scale + "px";
183
+ extraClass = 'preview-overflow-y';
184
+ } else {
185
+ extraClass = 'preview-fit-contain-y';
186
+ }
187
+ } else if (fit === 'preview-x') {
188
+ if (scale > windowScale) {
189
+ image.style.width = actualBoxHeight * scale + "px";
190
+ image.style.height = actualBoxHeight + "px";
191
+ extraClass = 'preview-overflow-x';
192
+ } else {
193
+ extraClass = 'preview-fit-contain-x';
194
+ }
195
+ }
196
+ }
197
+
198
+ extraClass && image.classList.add(extraClass);
199
+ setWrapClass(extraClass ? extraClass + "-container" : '');
200
+ onLoad && onLoad(evt, image);
201
+ }
202
+
151
203
  function loadImage(isFromRetry) {
152
204
  // 如果在加载图片前发现上一个图片还没加载完,则抛弃上一个图片的加载
153
205
  // @en Abort last image before starting loading new image
@@ -173,41 +225,8 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
173
225
  image.onload = function (evt) {
174
226
  loadingImageRef.current = null;
175
227
  imageDomRef.current = image;
176
- hasLoadedRef.current = true;
177
- changeStatus('loaded');
178
- var _image$width = image.width,
179
- imageWidth = _image$width === void 0 ? 0 : _image$width,
180
- _image$height = image.height,
181
- imageHeight = _image$height === void 0 ? 0 : _image$height;
182
- var extraClass = '';
183
-
184
- if (isPreview) {
185
- var scale = imageWidth / imageHeight;
186
- var windowScale = actualBoxWidth / actualBoxHeight;
187
-
188
- if (fit === 'preview-y') {
189
- if (scale < windowScale) {
190
- image.style.width = actualBoxWidth + "px";
191
- image.style.height = actualBoxWidth / scale + "px";
192
- extraClass = 'preview-overflow-y';
193
- } else {
194
- extraClass = 'preview-fit-contain-y';
195
- }
196
- } else if (fit === 'preview-x') {
197
- if (scale > windowScale) {
198
- image.style.width = actualBoxHeight * scale + "px";
199
- image.style.height = actualBoxHeight + "px";
200
- extraClass = 'preview-overflow-x';
201
- } else {
202
- extraClass = 'preview-fit-contain-x';
203
- }
204
- }
205
- }
206
-
207
- extraClass && image.classList.add(extraClass);
208
- setWrapClass(extraClass ? extraClass + "-container" : '');
228
+ handleImageLoaded(evt, image);
209
229
  replaceChild(image);
210
- _onLoad && _onLoad(evt, image);
211
230
  };
212
231
 
213
232
  image.onerror = function (evt) {
@@ -233,9 +252,10 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
233
252
  }
234
253
 
235
254
  function handleStaticImageError(e) {
236
- var evt = e.nativeEvent;
255
+ var evt = e ? e.nativeEvent : null;
237
256
 
238
257
  if (retryCountRef.current >= retryTime) {
258
+ changeStatus('error');
239
259
  onError && onError(evt);
240
260
  } else {
241
261
  retryCountRef.current += 1;
@@ -300,7 +320,7 @@ var BaseImage = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
300
320
  }, staticLabel && showImage && !staticRetrying ? /*#__PURE__*/_react.default.createElement("img", (0, _extends2.default)({}, nativeProps, attrs, {
301
321
  ref: imageDomRef,
302
322
  onLoad: function onLoad(e) {
303
- return _onLoad && _onLoad(e.nativeEvent, imageDomRef.current);
323
+ return handleImageLoaded(e.nativeEvent, imageDomRef.current);
304
324
  },
305
325
  onError: handleStaticImageError
306
326
  })) : null), showLoading && validStatus === 'loading' ? /*#__PURE__*/_react.default.createElement("div", {
@@ -24,6 +24,8 @@ var _grid = _interopRequireDefault(require("../grid"));
24
24
 
25
25
  var _addIcon = _interopRequireDefault(require("./add-icon"));
26
26
 
27
+ var _helpers = require("../_helpers");
28
+
27
29
  var _type = require("./type");
28
30
 
29
31
  Object.keys(_type).forEach(function (key) {
@@ -81,7 +83,7 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
81
83
  onDeleteClick = props.onDeleteClick;
82
84
  var domRef = (0, _react.useRef)(null);
83
85
  var fileRef = (0, _react.useRef)(null);
84
- var cacheRef = (0, _react.useRef)([]);
86
+ var cacheRef = (0, _helpers.useLatestRef)(images);
85
87
  (0, _react.useImperativeHandle)(ref, function () {
86
88
  return {
87
89
  dom: domRef.current
@@ -148,7 +150,7 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
148
150
  file: files[index]
149
151
  };
150
152
  });
151
- cacheRef.current = [].concat(images, res);
153
+ cacheRef.current = [].concat(cacheRef.current, res);
152
154
  onChange([].concat(cacheRef.current)); // 执行upload
153
155
 
154
156
  if (typeof upload === 'function') {
@@ -161,15 +163,21 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
161
163
  var file = _ref2.file;
162
164
  return file === _file;
163
165
  });
164
- cacheRef.current[index] = (0, _extends2.default)({}, cacheRef.current[index], data, {
165
- status: undefined
166
- });
166
+
167
+ if (index !== -1) {
168
+ cacheRef.current[index] = (0, _extends2.default)({}, cacheRef.current[index], data, {
169
+ status: undefined
170
+ });
171
+ }
167
172
  }).catch(function () {
168
173
  var index = cacheRef.current.findIndex(function (_ref3) {
169
174
  var file = _ref3.file;
170
175
  return file === _file;
171
176
  });
172
- cacheRef.current[index].status = 'error';
177
+
178
+ if (index !== -1) {
179
+ cacheRef.current[index].status = 'error';
180
+ }
173
181
  }).finally(function () {
174
182
  onChange([].concat(cacheRef.current));
175
183
  });
@@ -274,9 +274,9 @@ declare const _default: React.ForwardRefExoticComponent<ImagePreviewProps & Reac
274
274
  * @param {ImagePreviewProps} config configuration
275
275
  * @returns {{ close: () => void; update: (newConfig: ImagePreviewProps) => void; }}
276
276
  */
277
- open: (config: Pick<import("../context-provider").WithGlobalContext<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>>, "style" | "ref" | "key" | "context" | "className" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "loadingArea" | "onClose" | "fit" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">, context?: import("../context-provider").GlobalContextParams | undefined) => {
277
+ open: (config: Pick<import("../context-provider").WithGlobalContext<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>>, "style" | "ref" | "key" | "context" | "className" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "onClose" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">, context?: import("../context-provider").GlobalContextParams | undefined) => {
278
278
  close: () => void;
279
- update: (newConfig: Pick<import("../context-provider").WithGlobalContext<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>>, "style" | "ref" | "key" | "context" | "className" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "loadingArea" | "onClose" | "fit" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => void;
279
+ update: (newConfig: Pick<import("../context-provider").WithGlobalContext<ImagePreviewProps & React.RefAttributes<ImagePreviewRef>>, "style" | "ref" | "key" | "context" | "className" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "onClose" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => void;
280
280
  };
281
281
  };
282
282
  /**
@@ -658,9 +658,11 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
658
658
 
659
659
 
660
660
  function setImagesStatusByIndex(index, data) {
661
- var newStatus = imagesStatusRef.current.slice();
662
- newStatus[index] = (0, _extends5.default)({}, newStatus[index] || {}, data);
663
- setImagesStatus(newStatus);
661
+ setImagesStatus(function (current) {
662
+ var newStatus = current.slice();
663
+ newStatus[index] = (0, _extends5.default)({}, newStatus[index] || {}, data);
664
+ return newStatus;
665
+ });
664
666
  }
665
667
  /**
666
668
  * 缩略图放大过渡动画设置
@@ -847,7 +849,9 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
847
849
  return renderIndicator(currentIndex, total, lastIndex);
848
850
  }
849
851
 
850
- return openLoaded ? /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement("div", {
852
+ return openLoaded ? /*#__PURE__*/_react.default.createElement(_portal.default, {
853
+ getContainer: getContainer
854
+ }, /*#__PURE__*/_react.default.createElement("div", {
851
855
  className: "image-preview-indicator"
852
856
  }, currentIndex + 1, "/", total)) : null;
853
857
  } // ios在重设style时图片会消失一下造成闪动,因此在底下垫一张图
@@ -885,7 +889,9 @@ var ImagePreview = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
885
889
  function renderLoadingArea(index) {
886
890
  // loadingArea提出来,放到过渡图上层
887
891
  // @en The loadingArea is extracted and placed on the upper layer of the transition image
888
- return index === openIndex ? /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement("div", {
892
+ return index === openIndex ? /*#__PURE__*/_react.default.createElement(_portal.default, {
893
+ getContainer: getContainer
894
+ }, /*#__PURE__*/_react.default.createElement("div", {
889
895
  className: "image-preview-loading-area"
890
896
  }, loadingArea || /*#__PURE__*/_react.default.createElement(_loading.default, {
891
897
  type: "circle",
@@ -5,6 +5,7 @@ export interface OpenBaseProps {
5
5
  close: (e: any) => void;
6
6
  openIndex: number;
7
7
  images: any[];
8
+ getContainer?: () => HTMLElement;
8
9
  }
9
10
  export declare function open<P extends OpenBaseProps>(Component: React.FunctionComponent<P>): (config: Pick<P, Exclude<keyof P, "close">>, context?: GlobalContextParams | undefined) => {
10
11
  close: () => void;
@@ -17,8 +17,7 @@ function open(Component) {
17
17
  unmountOnExit: true
18
18
  }, config || {}, {
19
19
  close: function close() {}
20
- });
21
- var dynamicProps = (0, _extends2.default)({}, baseProps); // 不同的key用不同的容器挂载
20
+ }); // 不同的key用不同的容器挂载
22
21
  // @en Different keys are mounted in different containers
23
22
 
24
23
  var id = "_ARCO_IMAGE_PREVIEW_DIV_" + (baseProps.key || '') + "_";
@@ -31,6 +30,12 @@ function open(Component) {
31
30
  var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context),
32
31
  render = _ReactDOMRender.render;
33
32
 
33
+ var dynamicProps = (0, _extends2.default)({}, baseProps, {
34
+ getContainer: function getContainer() {
35
+ return div;
36
+ }
37
+ });
38
+
34
39
  function update(newConfig) {
35
40
  dynamicProps = (0, _extends2.default)({}, dynamicProps, newConfig || {});
36
41
  render(dynamicProps);
package/cjs/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  export { default as Tabs } from './tabs';
2
2
  export { default as Sticky } from './sticky';
3
- export { default as LoadMore } from './load-more';
4
- export { default as Cell } from './cell';
3
+ export { default as Portal } from './portal';
4
+ export { default as Toast } from './toast';
5
5
  export { default as ActionSheet } from './action-sheet';
6
6
  export { default as Avatar } from './avatar';
7
7
  export { default as Badge } from './badge';
8
8
  export { default as Button } from './button';
9
9
  export { default as Carousel } from './carousel';
10
+ export { default as Cell } from './cell';
10
11
  export { default as Checkbox } from './checkbox';
11
12
  export { default as CircleProgress } from './circle-progress';
12
13
  export { default as Collapse } from './collapse';
@@ -26,6 +27,7 @@ export { default as ImagePreview } from './image-preview';
26
27
  export { default as IndexBar } from './index-bar';
27
28
  export { default as Input } from './input';
28
29
  export { default as Keyboard } from './keyboard';
30
+ export { default as LoadMore } from './load-more';
29
31
  export { default as Loading } from './loading';
30
32
  export { default as Masking } from './masking';
31
33
  export { default as NavBar } from './nav-bar';
@@ -37,14 +39,13 @@ export { default as PickerView } from './picker-view';
37
39
  export { default as Popover } from './popover';
38
40
  export { default as Popup } from './popup';
39
41
  export { default as PopupSwiper } from './popup-swiper';
40
- export { default as Portal } from './portal';
41
42
  export { default as Progress } from './progress';
42
43
  export { default as PullRefresh } from './pull-refresh';
43
44
  export { default as Radio } from './radio';
44
45
  export { default as Rate } from './rate';
45
46
  export { default as SearchBar } from './search-bar';
46
- export { default as Skeleton } from './skeleton';
47
47
  export { default as ShowMonitor } from './show-monitor';
48
+ export { default as Skeleton } from './skeleton';
48
49
  export { default as Slider } from './slider';
49
50
  export { default as Stepper } from './stepper';
50
51
  export { default as Steps } from './steps';
@@ -54,5 +55,4 @@ export { default as Switch } from './switch';
54
55
  export { default as TabBar } from './tab-bar';
55
56
  export { default as Tag } from './tag';
56
57
  export { default as Textarea } from './textarea';
57
- export { default as Toast } from './toast';
58
58
  export { default as Transition } from './transition';
package/cjs/index.js CHANGED
@@ -13,13 +13,13 @@ var _sticky = _interopRequireDefault(require("./sticky"));
13
13
 
14
14
  exports.Sticky = _sticky.default;
15
15
 
16
- var _loadMore = _interopRequireDefault(require("./load-more"));
16
+ var _portal = _interopRequireDefault(require("./portal"));
17
17
 
18
- exports.LoadMore = _loadMore.default;
18
+ exports.Portal = _portal.default;
19
19
 
20
- var _cell = _interopRequireDefault(require("./cell"));
20
+ var _toast = _interopRequireDefault(require("./toast"));
21
21
 
22
- exports.Cell = _cell.default;
22
+ exports.Toast = _toast.default;
23
23
 
24
24
  var _actionSheet = _interopRequireDefault(require("./action-sheet"));
25
25
 
@@ -41,6 +41,10 @@ var _carousel = _interopRequireDefault(require("./carousel"));
41
41
 
42
42
  exports.Carousel = _carousel.default;
43
43
 
44
+ var _cell = _interopRequireDefault(require("./cell"));
45
+
46
+ exports.Cell = _cell.default;
47
+
44
48
  var _checkbox = _interopRequireDefault(require("./checkbox"));
45
49
 
46
50
  exports.Checkbox = _checkbox.default;
@@ -117,6 +121,10 @@ var _keyboard = _interopRequireDefault(require("./keyboard"));
117
121
 
118
122
  exports.Keyboard = _keyboard.default;
119
123
 
124
+ var _loadMore = _interopRequireDefault(require("./load-more"));
125
+
126
+ exports.LoadMore = _loadMore.default;
127
+
120
128
  var _loading = _interopRequireDefault(require("./loading"));
121
129
 
122
130
  exports.Loading = _loading.default;
@@ -161,10 +169,6 @@ var _popupSwiper = _interopRequireDefault(require("./popup-swiper"));
161
169
 
162
170
  exports.PopupSwiper = _popupSwiper.default;
163
171
 
164
- var _portal = _interopRequireDefault(require("./portal"));
165
-
166
- exports.Portal = _portal.default;
167
-
168
172
  var _progress = _interopRequireDefault(require("./progress"));
169
173
 
170
174
  exports.Progress = _progress.default;
@@ -185,14 +189,14 @@ var _searchBar = _interopRequireDefault(require("./search-bar"));
185
189
 
186
190
  exports.SearchBar = _searchBar.default;
187
191
 
188
- var _skeleton = _interopRequireDefault(require("./skeleton"));
189
-
190
- exports.Skeleton = _skeleton.default;
191
-
192
192
  var _showMonitor = _interopRequireDefault(require("./show-monitor"));
193
193
 
194
194
  exports.ShowMonitor = _showMonitor.default;
195
195
 
196
+ var _skeleton = _interopRequireDefault(require("./skeleton"));
197
+
198
+ exports.Skeleton = _skeleton.default;
199
+
196
200
  var _slider = _interopRequireDefault(require("./slider"));
197
201
 
198
202
  exports.Slider = _slider.default;
@@ -229,10 +233,6 @@ var _textarea = _interopRequireDefault(require("./textarea"));
229
233
 
230
234
  exports.Textarea = _textarea.default;
231
235
 
232
- var _toast = _interopRequireDefault(require("./toast"));
233
-
234
- exports.Toast = _toast.default;
235
-
236
236
  var _transition = _interopRequireDefault(require("./transition"));
237
237
 
238
238
  exports.Transition = _transition.default;
@@ -108,8 +108,8 @@ export interface LoadMoreProps {
108
108
  */
109
109
  getDataAtFirst?: boolean;
110
110
  /**
111
- * 当 getDataAtFirst === false 且数据不满一屏时是否触发一次请求,trigger=scroll时有效
112
- * @en Whether to trigger a request when getDataAtFirst === false and the data is not full of one screen, valid when trigger=scroll
111
+ * 当 getDataAtFirst 值为 false 且数据不满一屏时是否触发一次请求,trigger=scroll时有效
112
+ * @en Whether to trigger a request when getDataAtFirst equals false and the data is not full of one screen, valid when trigger=scroll
113
113
  * @default false
114
114
  */
115
115
  getDataWhenNoScrollAtFirst?: boolean;
@@ -140,6 +140,11 @@ export interface LoadMoreRef {
140
140
  * @en Change component state manually
141
141
  */
142
142
  changeStatus: (status: LoadMoreStatus, scene?: string) => void;
143
+ /**
144
+ * 判断是否滚动到底部并手动触发数据获取
145
+ * @en Determine whether to scroll to the bottom and manually trigger data acquisition
146
+ */
147
+ getDataWithEndReachCheck: () => void;
143
148
  }
144
149
  /**
145
150
  * 上拉加载组件,支持`scroll`和`click`两种触发加载方式,支持滚动监听。支持受控与不受控两种形式。<br>如果引入组件后发现仅触发了初始的`getData`,请确认是否在`getData`方法内没有调用`callback`移除 loading 状态,且未设置`blockWhenLoading`属性为 false。