@arco-design/mobile-react 2.29.5 → 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.
- package/CHANGELOG.md +13 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/image/index.d.ts +7 -7
- package/cjs/image/index.js +81 -61
- package/cjs/image-preview/index.js +6 -2
- package/cjs/image-preview/methods.d.ts +1 -0
- package/cjs/image-preview/methods.js +7 -2
- package/cjs/masking/methods.js +7 -2
- package/cjs/popup-swiper/index.d.ts +2 -8
- package/cjs/tabs/index.js +4 -1
- package/dist/index.js +123 -88
- package/dist/index.min.js +2 -2
- package/esm/image/index.d.ts +7 -7
- package/esm/image/index.js +81 -61
- package/esm/image-preview/index.js +6 -2
- package/esm/image-preview/methods.d.ts +1 -0
- package/esm/image-preview/methods.js +7 -3
- package/esm/masking/methods.js +7 -3
- package/esm/popup-swiper/index.d.ts +2 -8
- package/esm/tabs/index.js +4 -1
- package/package.json +3 -3
- package/umd/image/index.d.ts +7 -7
- package/umd/image/index.js +81 -61
- package/umd/image-preview/index.js +6 -2
- package/umd/image-preview/methods.d.ts +1 -0
- package/umd/image-preview/methods.js +7 -2
- package/umd/masking/methods.js +7 -2
- package/umd/popup-swiper/index.d.ts +2 -8
- package/umd/tabs/index.js +4 -1
package/dist/index.js
CHANGED
@@ -5311,7 +5311,10 @@
|
|
5311
5311
|
// 利用受控手动更改index时,给cell line加上动画
|
5312
5312
|
// @en Animate the cell line when changeing the index
|
5313
5313
|
setCellTrans(true);
|
5314
|
-
|
5314
|
+
|
5315
|
+
if (!changeFromRef.current) {
|
5316
|
+
changeFromRef.current = 'manual';
|
5317
|
+
}
|
5315
5318
|
}, [activeTab]);
|
5316
5319
|
useUpdateEffect(function () {
|
5317
5320
|
onDistanceChange && onDistanceChange(distance, wrapWidth, activeIndex);
|
@@ -7306,9 +7309,7 @@
|
|
7306
7309
|
}, normalize(config)), {
|
7307
7310
|
visible: false,
|
7308
7311
|
close: function close() {}
|
7309
|
-
});
|
7310
|
-
|
7311
|
-
var dynamicProps = __assign$2({}, baseProps); // 不同的key用不同的容器挂载
|
7312
|
+
}); // 不同的key用不同的容器挂载
|
7312
7313
|
|
7313
7314
|
|
7314
7315
|
var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
|
@@ -7316,6 +7317,12 @@
|
|
7316
7317
|
var leaving = false;
|
7317
7318
|
var render = new ReactDOMRender(Component, div, context).render;
|
7318
7319
|
|
7320
|
+
var dynamicProps = __assign$2(__assign$2({}, baseProps), {
|
7321
|
+
getContainer: function getContainer() {
|
7322
|
+
return div;
|
7323
|
+
}
|
7324
|
+
});
|
7325
|
+
|
7319
7326
|
function update(newConfig) {
|
7320
7327
|
dynamicProps = __assign$2(__assign$2({}, dynamicProps), normalize(newConfig));
|
7321
7328
|
render(dynamicProps);
|
@@ -7736,69 +7743,69 @@
|
|
7736
7743
|
*/
|
7737
7744
|
|
7738
7745
|
var BaseImage = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
7739
|
-
var system = useSystem();
|
7740
|
-
|
7741
|
-
var _a = useWindowSize(),
|
7742
|
-
windowWidth = _a.windowWidth,
|
7743
|
-
windowHeight = _a.windowHeight;
|
7744
|
-
|
7745
|
-
var _b = useMountedState('init'),
|
7746
|
-
imageStatus = _b[0],
|
7747
|
-
setImageStatus = _b[1];
|
7748
|
-
|
7749
|
-
var _c = useMountedState(''),
|
7750
|
-
wrapClass = _c[0],
|
7751
|
-
setWrapClass = _c[1];
|
7752
|
-
|
7753
|
-
var _d = useMountedState(false),
|
7754
|
-
staticRetrying = _d[0],
|
7755
|
-
setStaticRetrying = _d[1];
|
7756
|
-
|
7757
|
-
var imageRef = React.useRef(null);
|
7758
|
-
var imageDomRef = React.useRef(null);
|
7759
|
-
var wrapRef = React.useRef(null);
|
7760
|
-
var retryCountRef = React.useRef(0);
|
7761
|
-
var loadingImageRef = React.useRef(null);
|
7762
|
-
var hasLoadedRef = React.useRef(false);
|
7763
7746
|
var style = props.style,
|
7764
7747
|
className = props.className,
|
7765
7748
|
status = props.status,
|
7766
7749
|
src = props.src,
|
7767
7750
|
width = props.width,
|
7768
7751
|
height = props.height,
|
7769
|
-
|
7770
|
-
alt =
|
7771
|
-
|
7772
|
-
fit =
|
7773
|
-
|
7774
|
-
position =
|
7752
|
+
_a = props.alt,
|
7753
|
+
alt = _a === void 0 ? '' : _a,
|
7754
|
+
_b = props.fit,
|
7755
|
+
fit = _b === void 0 ? 'cover' : _b,
|
7756
|
+
_c = props.position,
|
7757
|
+
position = _c === void 0 ? 'center' : _c,
|
7775
7758
|
radius = props.radius,
|
7776
7759
|
bordered = props.bordered,
|
7777
7760
|
loadingArea = props.loadingArea,
|
7778
7761
|
errorArea = props.errorArea,
|
7779
7762
|
showLoading = props.showLoading,
|
7780
7763
|
showError = props.showError,
|
7781
|
-
|
7782
|
-
animateDuration =
|
7783
|
-
|
7784
|
-
retryTime =
|
7764
|
+
_d = props.animateDuration,
|
7765
|
+
animateDuration = _d === void 0 ? 200 : _d,
|
7766
|
+
_e = props.retryTime,
|
7767
|
+
retryTime = _e === void 0 ? 0 : _e,
|
7785
7768
|
forceHttps = props.forceHttps,
|
7786
|
-
|
7787
|
-
boxWidth =
|
7788
|
-
|
7789
|
-
boxHeight =
|
7769
|
+
_f = props.boxWidth,
|
7770
|
+
boxWidth = _f === void 0 ? 0 : _f,
|
7771
|
+
_g = props.boxHeight,
|
7772
|
+
boxHeight = _g === void 0 ? 0 : _g,
|
7790
7773
|
topOverlap = props.topOverlap,
|
7791
7774
|
bottomOverlap = props.bottomOverlap,
|
7792
|
-
|
7793
|
-
showImage =
|
7775
|
+
_h = props.showImage,
|
7776
|
+
showImage = _h === void 0 ? true : _h,
|
7794
7777
|
staticLabel = props.staticLabel,
|
7795
|
-
|
7796
|
-
nativeProps =
|
7778
|
+
_j = props.nativeProps,
|
7779
|
+
nativeProps = _j === void 0 ? {} : _j,
|
7797
7780
|
onChange = props.onChange,
|
7798
7781
|
onClick = props.onClick,
|
7799
|
-
|
7782
|
+
onLoad = props.onLoad,
|
7800
7783
|
onError = props.onError,
|
7801
7784
|
onAutoRetry = props.onAutoRetry;
|
7785
|
+
var system = useSystem();
|
7786
|
+
|
7787
|
+
var _k = useWindowSize(),
|
7788
|
+
windowWidth = _k.windowWidth,
|
7789
|
+
windowHeight = _k.windowHeight;
|
7790
|
+
|
7791
|
+
var _l = useMountedState(staticLabel && showLoading ? 'loading' : 'init'),
|
7792
|
+
imageStatus = _l[0],
|
7793
|
+
setImageStatus = _l[1];
|
7794
|
+
|
7795
|
+
var _m = useMountedState(''),
|
7796
|
+
wrapClass = _m[0],
|
7797
|
+
setWrapClass = _m[1];
|
7798
|
+
|
7799
|
+
var _o = useMountedState(false),
|
7800
|
+
staticRetrying = _o[0],
|
7801
|
+
setStaticRetrying = _o[1];
|
7802
|
+
|
7803
|
+
var imageRef = React.useRef(null);
|
7804
|
+
var imageDomRef = React.useRef(null);
|
7805
|
+
var wrapRef = React.useRef(null);
|
7806
|
+
var retryCountRef = React.useRef(0);
|
7807
|
+
var loadingImageRef = React.useRef(null);
|
7808
|
+
var hasLoadedRef = React.useRef(false);
|
7802
7809
|
var isPreview = Boolean(fit.indexOf('preview') >= 0);
|
7803
7810
|
var actualBoxWidth = boxWidth || windowWidth;
|
7804
7811
|
var actualBoxHeight = boxHeight || windowHeight;
|
@@ -7834,6 +7841,21 @@
|
|
7834
7841
|
retryCountRef.current = 0;
|
7835
7842
|
loadImage();
|
7836
7843
|
}, [attrs, width, height, showImage, staticLabel]);
|
7844
|
+
React.useEffect(function () {
|
7845
|
+
var _a; // 当使用img标签时,onLoad可能加载完成前已经执行完,此时手动触发一次
|
7846
|
+
// @en When using the img tag, onLoad may have been executed before loading is complete, and it needs to be triggered manually
|
7847
|
+
|
7848
|
+
|
7849
|
+
if (staticLabel && !hasLoadedRef.current && ((_a = imageDomRef.current) === null || _a === void 0 ? void 0 : _a.complete)) {
|
7850
|
+
// 图片有宽高认为正常加载,否则认为加载错误
|
7851
|
+
// @en If the image has width and height, it is considered to be loaded normally, otherwise it is considered to be a loading error
|
7852
|
+
if (imageDomRef.current.naturalWidth || imageDomRef.current.naturalHeight) {
|
7853
|
+
handleImageLoaded(null, imageDomRef.current);
|
7854
|
+
} else {
|
7855
|
+
handleStaticImageError(null);
|
7856
|
+
}
|
7857
|
+
}
|
7858
|
+
}, [staticLabel]);
|
7837
7859
|
|
7838
7860
|
function changeStatus(newStatus) {
|
7839
7861
|
setImageStatus(newStatus);
|
@@ -7854,6 +7876,43 @@
|
|
7854
7876
|
}
|
7855
7877
|
}
|
7856
7878
|
|
7879
|
+
function handleImageLoaded(evt, image) {
|
7880
|
+
hasLoadedRef.current = true;
|
7881
|
+
changeStatus('loaded');
|
7882
|
+
var _a = image.width,
|
7883
|
+
imageWidth = _a === void 0 ? 0 : _a,
|
7884
|
+
_b = image.height,
|
7885
|
+
imageHeight = _b === void 0 ? 0 : _b;
|
7886
|
+
var extraClass = '';
|
7887
|
+
|
7888
|
+
if (isPreview) {
|
7889
|
+
var scale = imageWidth / imageHeight;
|
7890
|
+
var windowScale = actualBoxWidth / actualBoxHeight;
|
7891
|
+
|
7892
|
+
if (fit === 'preview-y') {
|
7893
|
+
if (scale < windowScale) {
|
7894
|
+
image.style.width = actualBoxWidth + "px";
|
7895
|
+
image.style.height = actualBoxWidth / scale + "px";
|
7896
|
+
extraClass = 'preview-overflow-y';
|
7897
|
+
} else {
|
7898
|
+
extraClass = 'preview-fit-contain-y';
|
7899
|
+
}
|
7900
|
+
} else if (fit === 'preview-x') {
|
7901
|
+
if (scale > windowScale) {
|
7902
|
+
image.style.width = actualBoxHeight * scale + "px";
|
7903
|
+
image.style.height = actualBoxHeight + "px";
|
7904
|
+
extraClass = 'preview-overflow-x';
|
7905
|
+
} else {
|
7906
|
+
extraClass = 'preview-fit-contain-x';
|
7907
|
+
}
|
7908
|
+
}
|
7909
|
+
}
|
7910
|
+
|
7911
|
+
extraClass && image.classList.add(extraClass);
|
7912
|
+
setWrapClass(extraClass ? extraClass + "-container" : '');
|
7913
|
+
onLoad && onLoad(evt, image);
|
7914
|
+
}
|
7915
|
+
|
7857
7916
|
function loadImage(isFromRetry) {
|
7858
7917
|
// 如果在加载图片前发现上一个图片还没加载完,则抛弃上一个图片的加载
|
7859
7918
|
// @en Abort last image before starting loading new image
|
@@ -7879,41 +7938,8 @@
|
|
7879
7938
|
image.onload = function (evt) {
|
7880
7939
|
loadingImageRef.current = null;
|
7881
7940
|
imageDomRef.current = image;
|
7882
|
-
|
7883
|
-
changeStatus('loaded');
|
7884
|
-
var _a = image.width,
|
7885
|
-
imageWidth = _a === void 0 ? 0 : _a,
|
7886
|
-
_b = image.height,
|
7887
|
-
imageHeight = _b === void 0 ? 0 : _b;
|
7888
|
-
var extraClass = '';
|
7889
|
-
|
7890
|
-
if (isPreview) {
|
7891
|
-
var scale = imageWidth / imageHeight;
|
7892
|
-
var windowScale = actualBoxWidth / actualBoxHeight;
|
7893
|
-
|
7894
|
-
if (fit === 'preview-y') {
|
7895
|
-
if (scale < windowScale) {
|
7896
|
-
image.style.width = actualBoxWidth + "px";
|
7897
|
-
image.style.height = actualBoxWidth / scale + "px";
|
7898
|
-
extraClass = 'preview-overflow-y';
|
7899
|
-
} else {
|
7900
|
-
extraClass = 'preview-fit-contain-y';
|
7901
|
-
}
|
7902
|
-
} else if (fit === 'preview-x') {
|
7903
|
-
if (scale > windowScale) {
|
7904
|
-
image.style.width = actualBoxHeight * scale + "px";
|
7905
|
-
image.style.height = actualBoxHeight + "px";
|
7906
|
-
extraClass = 'preview-overflow-x';
|
7907
|
-
} else {
|
7908
|
-
extraClass = 'preview-fit-contain-x';
|
7909
|
-
}
|
7910
|
-
}
|
7911
|
-
}
|
7912
|
-
|
7913
|
-
extraClass && image.classList.add(extraClass);
|
7914
|
-
setWrapClass(extraClass ? extraClass + "-container" : '');
|
7941
|
+
handleImageLoaded(evt, image);
|
7915
7942
|
replaceChild(image);
|
7916
|
-
_onLoad && _onLoad(evt, image);
|
7917
7943
|
};
|
7918
7944
|
|
7919
7945
|
image.onerror = function (evt) {
|
@@ -7939,9 +7965,10 @@
|
|
7939
7965
|
}
|
7940
7966
|
|
7941
7967
|
function handleStaticImageError(e) {
|
7942
|
-
var evt = e.nativeEvent;
|
7968
|
+
var evt = e ? e.nativeEvent : null;
|
7943
7969
|
|
7944
7970
|
if (retryCountRef.current >= retryTime) {
|
7971
|
+
changeStatus('error');
|
7945
7972
|
onError && onError(evt);
|
7946
7973
|
} else {
|
7947
7974
|
retryCountRef.current += 1;
|
@@ -8006,7 +8033,7 @@
|
|
8006
8033
|
}, staticLabel && showImage && !staticRetrying ? /*#__PURE__*/React__default["default"].createElement("img", __assign$2({}, nativeProps, attrs, {
|
8007
8034
|
ref: imageDomRef,
|
8008
8035
|
onLoad: function onLoad(e) {
|
8009
|
-
return
|
8036
|
+
return handleImageLoaded(e.nativeEvent, imageDomRef.current);
|
8010
8037
|
},
|
8011
8038
|
onError: handleStaticImageError
|
8012
8039
|
})) : null), showLoading && validStatus === 'loading' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
@@ -19596,9 +19623,7 @@
|
|
19596
19623
|
unmountOnExit: true
|
19597
19624
|
}, config || {}), {
|
19598
19625
|
close: function close() {}
|
19599
|
-
});
|
19600
|
-
|
19601
|
-
var dynamicProps = __assign$2({}, baseProps); // 不同的key用不同的容器挂载
|
19626
|
+
}); // 不同的key用不同的容器挂载
|
19602
19627
|
// @en Different keys are mounted in different containers
|
19603
19628
|
|
19604
19629
|
|
@@ -19607,6 +19632,12 @@
|
|
19607
19632
|
var leaving = false;
|
19608
19633
|
var render = new ReactDOMRender(Component, div, context).render;
|
19609
19634
|
|
19635
|
+
var dynamicProps = __assign$2(__assign$2({}, baseProps), {
|
19636
|
+
getContainer: function getContainer() {
|
19637
|
+
return div;
|
19638
|
+
}
|
19639
|
+
});
|
19640
|
+
|
19610
19641
|
function update(newConfig) {
|
19611
19642
|
dynamicProps = __assign$2(__assign$2({}, dynamicProps), newConfig || {});
|
19612
19643
|
render(dynamicProps);
|
@@ -20444,7 +20475,9 @@
|
|
20444
20475
|
return renderIndicator(currentIndex, total, lastIndex);
|
20445
20476
|
}
|
20446
20477
|
|
20447
|
-
return openLoaded ? /*#__PURE__*/React__default["default"].createElement(Portal,
|
20478
|
+
return openLoaded ? /*#__PURE__*/React__default["default"].createElement(Portal, {
|
20479
|
+
getContainer: getContainer
|
20480
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
20448
20481
|
className: "image-preview-indicator"
|
20449
20482
|
}, currentIndex + 1, "/", total)) : null;
|
20450
20483
|
} // ios在重设style时图片会消失一下造成闪动,因此在底下垫一张图
|
@@ -20482,7 +20515,9 @@
|
|
20482
20515
|
function renderLoadingArea(index) {
|
20483
20516
|
// loadingArea提出来,放到过渡图上层
|
20484
20517
|
// @en The loadingArea is extracted and placed on the upper layer of the transition image
|
20485
|
-
return index === openIndex ? /*#__PURE__*/React__default["default"].createElement(Portal,
|
20518
|
+
return index === openIndex ? /*#__PURE__*/React__default["default"].createElement(Portal, {
|
20519
|
+
getContainer: getContainer
|
20520
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
20486
20521
|
className: "image-preview-loading-area"
|
20487
20522
|
}, loadingArea || /*#__PURE__*/React__default["default"].createElement(Loading, {
|
20488
20523
|
type: "circle",
|