@arco-design/mobile-react 2.30.2 → 2.30.3
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 +12 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/form/type.d.ts +2 -2
- package/cjs/image-preview/index.d.ts +6 -0
- package/cjs/image-preview/index.js +48 -14
- package/cjs/image-preview/style/css/index.css +2 -1
- package/cjs/image-preview/style/index.less +2 -1
- package/cjs/popover/style/css/index.css +9 -2
- package/cjs/popover/style/css/menu.css +4 -0
- package/cjs/popover/style/index.less +1 -2
- package/cjs/popover/style/menu.less +1 -1
- package/cjs/slider/hooks/useSliderEvents.js +14 -8
- package/cjs/slider/hooks/useSliderStyle.js +13 -7
- package/cjs/slider/index.js +4 -2
- package/cjs/slider/marks.js +4 -2
- package/cjs/slider/style/css/index.css +28 -0
- package/cjs/slider/style/index.less +13 -4
- package/dist/index.js +97 -52
- package/dist/index.min.js +4 -4
- package/dist/style.css +36 -3
- package/dist/style.min.css +1 -1
- package/esm/form/type.d.ts +2 -2
- package/esm/image-preview/index.d.ts +6 -0
- package/esm/image-preview/index.js +48 -14
- package/esm/image-preview/style/css/index.css +2 -1
- package/esm/image-preview/style/index.less +2 -1
- package/esm/popover/style/css/index.css +9 -2
- package/esm/popover/style/css/menu.css +4 -0
- package/esm/popover/style/index.less +1 -2
- package/esm/popover/style/menu.less +1 -1
- package/esm/slider/hooks/useSliderEvents.js +13 -8
- package/esm/slider/hooks/useSliderStyle.js +12 -7
- package/esm/slider/index.js +4 -2
- package/esm/slider/marks.js +4 -2
- package/esm/slider/style/css/index.css +28 -0
- package/esm/slider/style/index.less +13 -4
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +1 -1
- package/tokens/app/arcodesign/default/index.d.ts +1 -1
- package/tokens/app/arcodesign/default/index.js +1 -1
- package/tokens/app/arcodesign/default/index.json +7 -7
- package/tokens/app/arcodesign/default/index.less +1 -1
- package/umd/form/type.d.ts +2 -2
- package/umd/image-preview/index.d.ts +6 -0
- package/umd/image-preview/index.js +48 -14
- package/umd/image-preview/style/css/index.css +2 -1
- package/umd/image-preview/style/index.less +2 -1
- package/umd/popover/style/css/index.css +9 -2
- package/umd/popover/style/css/menu.css +4 -0
- package/umd/popover/style/index.less +1 -2
- package/umd/popover/style/menu.less +1 -1
- package/umd/slider/hooks/useSliderEvents.js +16 -12
- package/umd/slider/hooks/useSliderStyle.js +15 -11
- package/umd/slider/index.js +4 -2
- package/umd/slider/marks.js +4 -2
- package/umd/slider/style/css/index.css +28 -0
- package/umd/slider/style/index.less +13 -4
package/dist/index.js
CHANGED
@@ -20873,7 +20873,7 @@
|
|
20873
20873
|
transformersRef.current = []; // 移除过渡图片
|
20874
20874
|
// @en Remove transition image
|
20875
20875
|
|
20876
|
-
removeChild(
|
20876
|
+
removeChild(transImageRef.current);
|
20877
20877
|
setTransImageInfo(null);
|
20878
20878
|
setPlaceholders({});
|
20879
20879
|
var mounted_1 = isInitialMount.current;
|
@@ -20915,8 +20915,10 @@
|
|
20915
20915
|
}, [getMaxScale]);
|
20916
20916
|
|
20917
20917
|
function removeChild(child) {
|
20918
|
+
var _a, _b, _c;
|
20919
|
+
|
20918
20920
|
try {
|
20919
|
-
child &&
|
20921
|
+
child && ((_c = (_b = (_a = domRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.carousel-item')) === null || _b === void 0 ? void 0 : _b[innerIndexRef.current]) === null || _c === void 0 ? void 0 : _c.removeChild(child));
|
20920
20922
|
} catch (e) {}
|
20921
20923
|
} // 监听滑动到上下边缘后还在往外滑动的操作,则关闭弹窗
|
20922
20924
|
// @en Monitor the operation of sliding out after sliding to the upper and lower edges, then close the popup
|
@@ -21336,7 +21338,41 @@
|
|
21336
21338
|
}
|
21337
21339
|
}
|
21338
21340
|
|
21339
|
-
var handleClick = useSingleAndDoubleClick(handleImageClick, handleImageDoubleClick);
|
21341
|
+
var handleClick = useSingleAndDoubleClick(handleImageClick, handleImageDoubleClick); // 当使用 getThumbBounds 时,关闭图片预览有缩小效果
|
21342
|
+
// @en When using getThumbBounds, closing the image preview has a shrinking effect
|
21343
|
+
|
21344
|
+
function animateBeforeClose() {
|
21345
|
+
var _a;
|
21346
|
+
|
21347
|
+
var index = innerIndexRef.current;
|
21348
|
+
var imageDom = (_a = imagesRef.current[index]) === null || _a === void 0 ? void 0 : _a.image;
|
21349
|
+
var thumbBounds = getThumbBounds === null || getThumbBounds === void 0 ? void 0 : getThumbBounds(index);
|
21350
|
+
|
21351
|
+
if (!imageDom || !thumbBounds || !thumbBounds.width || !thumbBounds.height) {
|
21352
|
+
return;
|
21353
|
+
} // 小图超过一半在视野外时,不展示缩小效果
|
21354
|
+
// @en When more than half of the thumbnail is outside the field of view, the zoom effect will not be displayed
|
21355
|
+
|
21356
|
+
|
21357
|
+
if (thumbBounds.top < -1 * thumbBounds.height / 2 || thumbBounds.top > windowHeight - thumbBounds.height / 2 || thumbBounds.left < -1 * thumbBounds.width / 2 || thumbBounds.left > windowWidth - thumbBounds.width / 2) {
|
21358
|
+
return;
|
21359
|
+
}
|
21360
|
+
|
21361
|
+
var imageDomRect = imageDom.getBoundingClientRect();
|
21362
|
+
|
21363
|
+
if (!imageDomRect.width || !imageDomRect.height) {
|
21364
|
+
return;
|
21365
|
+
}
|
21366
|
+
|
21367
|
+
imageDom.classList.add('closing-animation');
|
21368
|
+
setImageBounds(imageDom, imageDomRect, imageDomRect);
|
21369
|
+
imageDom.style.objectPosition = images[index].thumbPosition || 'top center';
|
21370
|
+
nextTick(function () {
|
21371
|
+
imageDom.style.transitionDuration = displayDuration + "ms";
|
21372
|
+
imageDom.style.webkitTransitionDuration = displayDuration + "ms";
|
21373
|
+
setImageBounds(imageDom, thumbBounds, imageDomRect);
|
21374
|
+
});
|
21375
|
+
}
|
21340
21376
|
|
21341
21377
|
function goClose(e) {
|
21342
21378
|
if (closingRef.current) {
|
@@ -21344,6 +21380,7 @@
|
|
21344
21380
|
}
|
21345
21381
|
|
21346
21382
|
closingRef.current = true;
|
21383
|
+
animateBeforeClose();
|
21347
21384
|
close(e);
|
21348
21385
|
}
|
21349
21386
|
/**
|
@@ -21366,7 +21403,7 @@
|
|
21366
21403
|
|
21367
21404
|
|
21368
21405
|
function setDisplayAnimation(index) {
|
21369
|
-
var _a;
|
21406
|
+
var _a, _b, _c, _d;
|
21370
21407
|
|
21371
21408
|
var firstLoaded = (_a = imagesStatusRef.current[index]) === null || _a === void 0 ? void 0 : _a.firstLoaded;
|
21372
21409
|
var fallbackSrc = replaceFallbackWhenLoaded && firstLoaded ? images[index].src : images[index].fallbackSrc; // 用户设置了getThumbBounds和images的fallbackSrc属性才有放大过渡效果
|
@@ -21397,7 +21434,7 @@
|
|
21397
21434
|
transImage.style.opacity = '0';
|
21398
21435
|
transImage.style.transitionDuration = displayDuration + "ms";
|
21399
21436
|
transImage.style.webkitTransitionDuration = displayDuration + "ms";
|
21400
|
-
|
21437
|
+
(_d = (_c = (_b = domRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.carousel-item')) === null || _c === void 0 ? void 0 : _c[index]) === null || _d === void 0 ? void 0 : _d.prepend(transImage); // 拿到放大之后的位置rect,没拿到就取消小图放大效果
|
21401
21438
|
// @en Get the zoomed-in position rect, and cancel the zoom-in effect if not getting it
|
21402
21439
|
|
21403
21440
|
getNewImageBounds(index, fallbackSrc, transImage, function (rect) {
|
@@ -21419,9 +21456,10 @@
|
|
21419
21456
|
return __assign$2(__assign$2({}, holders), (_a = {}, _a[index] = true, _a));
|
21420
21457
|
});
|
21421
21458
|
}, Math.max(0, displayDuration - 80));
|
21459
|
+
var transitionEndDelay = images[index].transitionEndDelay || 30;
|
21422
21460
|
setTimeout(function () {
|
21423
21461
|
resetAnimation(index);
|
21424
|
-
}, displayDuration +
|
21462
|
+
}, displayDuration + transitionEndDelay);
|
21425
21463
|
});
|
21426
21464
|
});
|
21427
21465
|
}
|
@@ -21580,18 +21618,14 @@
|
|
21580
21618
|
}) : null;
|
21581
21619
|
}
|
21582
21620
|
|
21583
|
-
function renderLoadingArea(
|
21584
|
-
|
21585
|
-
// @en The loadingArea is extracted and placed on the upper layer of the transition image
|
21586
|
-
return index === openIndex ? /*#__PURE__*/React__default["default"].createElement(Portal, {
|
21587
|
-
getContainer: getContainer
|
21588
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
21621
|
+
function renderLoadingArea() {
|
21622
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
21589
21623
|
className: "image-preview-loading-area"
|
21590
21624
|
}, loadingArea || /*#__PURE__*/React__default["default"].createElement(Loading, {
|
21591
21625
|
type: "circle",
|
21592
21626
|
className: "loading-icon",
|
21593
21627
|
radius: 7
|
21594
|
-
}))
|
21628
|
+
}));
|
21595
21629
|
}
|
21596
21630
|
|
21597
21631
|
return /*#__PURE__*/React__default["default"].createElement(ContextLayout, null, function (_a) {
|
@@ -21639,7 +21673,7 @@
|
|
21639
21673
|
imagesRef.current[index] = r;
|
21640
21674
|
},
|
21641
21675
|
showLoading: showLoading,
|
21642
|
-
loadingArea: renderLoadingArea(
|
21676
|
+
loadingArea: renderLoadingArea(),
|
21643
21677
|
errorArea: errorArea,
|
21644
21678
|
showError: showError,
|
21645
21679
|
retryTime: retryTime,
|
@@ -27722,6 +27756,7 @@
|
|
27722
27756
|
var getLinePosition = _a.getLinePosition,
|
27723
27757
|
commonIsTouching = _a.commonIsTouching,
|
27724
27758
|
valueGroup = _a.valueGroup;
|
27759
|
+
var useRtl = React.useContext(GlobalContext).useRtl;
|
27725
27760
|
|
27726
27761
|
var _b = React.useContext(SliderContext),
|
27727
27762
|
size = _b.size,
|
@@ -27760,7 +27795,8 @@
|
|
27760
27795
|
length = (larger - min) / (max - min) * length - start;
|
27761
27796
|
}
|
27762
27797
|
|
27763
|
-
|
27798
|
+
var leftStyle = useRtl ? 'right' : 'left';
|
27799
|
+
return _a = {}, _a[isHorizontal ? leftStyle : 'bottom'] = start + "px", _a[isHorizontal ? 'width' : 'height'] = Math.abs(length) + "px", _a;
|
27764
27800
|
}, [valueGroup, getLinePosition, min, max, isHorizontal]);
|
27765
27801
|
return {
|
27766
27802
|
heightStyle: heightStyle,
|
@@ -27783,6 +27819,7 @@
|
|
27783
27819
|
valueGroup = _a.valueGroup,
|
27784
27820
|
setValueGroup = _a.setValueGroup,
|
27785
27821
|
setCommonIsTouching = _a.setCommonIsTouching;
|
27822
|
+
var useRtl = React.useContext(GlobalContext).useRtl;
|
27786
27823
|
|
27787
27824
|
var _b = React.useContext(SliderContext),
|
27788
27825
|
disabled = _b.disabled,
|
@@ -27816,7 +27853,8 @@
|
|
27816
27853
|
length = _a.length,
|
27817
27854
|
start = _a.start;
|
27818
27855
|
if (length === 0) return 0;
|
27819
|
-
var
|
27856
|
+
var rtlRatio = useRtl ? -1 : 1;
|
27857
|
+
var newWidth = isHorizontal ? (touchPosition - start) * rtlRatio : length - touchPosition + start;
|
27820
27858
|
|
27821
27859
|
if (newWidth < 0) {
|
27822
27860
|
newWidth = 0;
|
@@ -28048,20 +28086,24 @@
|
|
28048
28086
|
className = _b === void 0 ? '' : _b,
|
28049
28087
|
_c = _a.style,
|
28050
28088
|
style = _c === void 0 ? {} : _c;
|
28051
|
-
var _d = React.useContext(GlobalContext).prefixCls,
|
28052
|
-
prefixCls = _d === void 0 ? '' : _d;
|
28053
28089
|
|
28054
|
-
var
|
28055
|
-
|
28056
|
-
|
28057
|
-
|
28058
|
-
|
28090
|
+
var _d = React.useContext(GlobalContext),
|
28091
|
+
_e = _d.prefixCls,
|
28092
|
+
prefixCls = _e === void 0 ? '' : _e,
|
28093
|
+
useRtl = _d.useRtl;
|
28094
|
+
|
28095
|
+
var _f = React.useContext(SliderContext),
|
28096
|
+
type = _f.type,
|
28097
|
+
showMarks = _f.showMarks,
|
28098
|
+
max = _f.max,
|
28099
|
+
min = _f.min;
|
28059
28100
|
|
28060
28101
|
var isHorizontal = /^horizontal/g.test(type);
|
28061
28102
|
var genMarkStyle = React.useCallback(function (value) {
|
28062
28103
|
var _a;
|
28063
28104
|
|
28064
|
-
|
28105
|
+
var leftStyle = useRtl ? 'right' : 'left';
|
28106
|
+
return _a = {}, _a[isHorizontal ? leftStyle : 'bottom'] = (value - min) / (max - min) * 100 + "%", _a;
|
28065
28107
|
}, [isHorizontal, min, max]);
|
28066
28108
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
28067
28109
|
className: prefixCls + "-slider-marks"
|
@@ -28082,26 +28124,28 @@
|
|
28082
28124
|
}
|
28083
28125
|
|
28084
28126
|
var Slider = /*#__PURE__*/React.forwardRef(function (_, ref) {
|
28085
|
-
var _a = React.useContext(GlobalContext)
|
28086
|
-
|
28127
|
+
var _a = React.useContext(GlobalContext),
|
28128
|
+
_b = _a.prefixCls,
|
28129
|
+
prefixCls = _b === void 0 ? '' : _b,
|
28130
|
+
useRtl = _a.useRtl;
|
28087
28131
|
|
28088
|
-
var
|
28089
|
-
className =
|
28090
|
-
style =
|
28091
|
-
disabled =
|
28092
|
-
min =
|
28093
|
-
max =
|
28094
|
-
type =
|
28095
|
-
showTooltip =
|
28096
|
-
showMarks =
|
28132
|
+
var _c = React.useContext(SliderContext),
|
28133
|
+
className = _c.className,
|
28134
|
+
style = _c.style,
|
28135
|
+
disabled = _c.disabled,
|
28136
|
+
min = _c.min,
|
28137
|
+
max = _c.max,
|
28138
|
+
type = _c.type,
|
28139
|
+
showTooltip = _c.showTooltip,
|
28140
|
+
showMarks = _c.showMarks;
|
28097
28141
|
|
28098
28142
|
var domRef = React.useRef(null);
|
28099
28143
|
var lineRef = React.useRef(null); // 拖动滑块的 index 为当前的 isTouching
|
28100
28144
|
// @en The index of the slider is the current isTouching
|
28101
28145
|
|
28102
|
-
var
|
28103
|
-
commonIsTouching =
|
28104
|
-
setCommonIsTouching =
|
28146
|
+
var _d = React.useState(-1),
|
28147
|
+
commonIsTouching = _d[0],
|
28148
|
+
setCommonIsTouching = _d[1];
|
28105
28149
|
|
28106
28150
|
var isHorizontal = /^horizontal/g.test(type);
|
28107
28151
|
React.useImperativeHandle(ref, function () {
|
@@ -28110,14 +28154,14 @@
|
|
28110
28154
|
};
|
28111
28155
|
});
|
28112
28156
|
|
28113
|
-
var
|
28157
|
+
var _e = useSliderInit({
|
28114
28158
|
commonIsTouching: commonIsTouching
|
28115
28159
|
}),
|
28116
|
-
firstRender =
|
28117
|
-
valueGroup =
|
28118
|
-
setValueGroup =
|
28119
|
-
runTimeConfig =
|
28120
|
-
isMultiThumb =
|
28160
|
+
firstRender = _e.firstRender,
|
28161
|
+
valueGroup = _e.valueGroup,
|
28162
|
+
setValueGroup = _e.setValueGroup,
|
28163
|
+
runTimeConfig = _e.runTimeConfig,
|
28164
|
+
isMultiThumb = _e.isMultiThumb; // 最长线 div 位置
|
28121
28165
|
|
28122
28166
|
|
28123
28167
|
var getLinePosition = React.useCallback(function () {
|
@@ -28134,20 +28178,21 @@
|
|
28134
28178
|
top = _c.top,
|
28135
28179
|
height = _c.height;
|
28136
28180
|
|
28181
|
+
var leftValue = useRtl ? left + width : left;
|
28137
28182
|
return {
|
28138
28183
|
length: isHorizontal ? width : height,
|
28139
|
-
start: isHorizontal ?
|
28184
|
+
start: isHorizontal ? leftValue : top
|
28140
28185
|
};
|
28141
28186
|
}, [isHorizontal, firstRender]);
|
28142
28187
|
|
28143
|
-
var
|
28188
|
+
var _f = useSliderStyle({
|
28144
28189
|
getLinePosition: getLinePosition,
|
28145
28190
|
commonIsTouching: commonIsTouching,
|
28146
28191
|
valueGroup: valueGroup
|
28147
28192
|
}),
|
28148
|
-
heightStyle =
|
28149
|
-
transitionClass =
|
28150
|
-
activeLineStyle =
|
28193
|
+
heightStyle = _f.heightStyle,
|
28194
|
+
transitionClass = _f.transitionClass,
|
28195
|
+
activeLineStyle = _f.activeLineStyle;
|
28151
28196
|
|
28152
28197
|
useSliderEvents({
|
28153
28198
|
lineRef: lineRef,
|
@@ -28157,11 +28202,11 @@
|
|
28157
28202
|
setCommonIsTouching: setCommonIsTouching
|
28158
28203
|
});
|
28159
28204
|
|
28160
|
-
var
|
28205
|
+
var _g = useSliderIcon({
|
28161
28206
|
valueGroup: valueGroup
|
28162
28207
|
}),
|
28163
|
-
renderPrefixLabel =
|
28164
|
-
renderSuffixLabel =
|
28208
|
+
renderPrefixLabel = _g.renderPrefixLabel,
|
28209
|
+
renderSuffixLabel = _g.renderSuffixLabel;
|
28165
28210
|
/**
|
28166
28211
|
* 为了减少 dom 元素计算,只改变激活 line 的样式,让对应的 thumb 附着在两边,所以需要实时调整 className
|
28167
28212
|
* @en In order to reduce the calculation of dom elements, only the style of the active line is changed, so that the corresponding thumb is attached to both sides, so the className needs to be adjusted in real time
|