@arco-design/mobile-react 2.27.1 → 2.27.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 +26 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/_helpers/index.d.ts +1 -0
- package/cjs/_helpers/index.js +10 -0
- package/cjs/index-bar/type.d.ts +3 -3
- package/cjs/load-more/index.js +4 -1
- package/cjs/nav-bar/index.js +2 -2
- package/cjs/show-monitor/index.js +112 -38
- package/cjs/swipe-load/demo/style/css/mobile.css +3 -0
- package/cjs/swipe-load/demo/style/mobile.less +11 -0
- package/cjs/swipe-load/index.js +86 -32
- package/cjs/swipe-load/style/css/index.css +3 -0
- package/cjs/swipe-load/style/index.less +7 -0
- package/cjs/swipe-load/type.d.ts +29 -0
- package/cjs/tabs/index.js +6 -2
- package/cjs/tabs/style/css/index.css +4 -0
- package/cjs/tabs/style/index.less +5 -0
- package/cjs/tabs/tab-pane.js +49 -12
- package/cjs/tabs/type.d.ts +7 -1
- package/dist/index.js +297 -119
- package/dist/index.min.js +5 -5
- package/dist/style.css +7 -0
- package/dist/style.min.css +1 -1
- package/esm/_helpers/index.d.ts +1 -0
- package/esm/_helpers/index.js +7 -0
- package/esm/index-bar/type.d.ts +3 -3
- package/esm/load-more/index.js +4 -1
- package/esm/nav-bar/index.js +2 -2
- package/esm/show-monitor/index.js +112 -38
- package/esm/swipe-load/demo/style/css/mobile.css +3 -0
- package/esm/swipe-load/demo/style/mobile.less +11 -0
- package/esm/swipe-load/index.js +85 -32
- package/esm/swipe-load/style/css/index.css +3 -0
- package/esm/swipe-load/style/index.less +7 -0
- package/esm/swipe-load/type.d.ts +29 -0
- package/esm/tabs/index.js +6 -2
- package/esm/tabs/style/css/index.css +4 -0
- package/esm/tabs/style/index.less +5 -0
- package/esm/tabs/tab-pane.js +49 -11
- package/esm/tabs/type.d.ts +7 -1
- package/package.json +3 -3
- package/umd/_helpers/index.d.ts +1 -0
- package/umd/_helpers/index.js +10 -0
- package/umd/index-bar/type.d.ts +3 -3
- package/umd/load-more/index.js +4 -1
- package/umd/nav-bar/index.js +2 -2
- package/umd/show-monitor/index.js +112 -38
- package/umd/swipe-load/demo/style/css/mobile.css +3 -0
- package/umd/swipe-load/demo/style/mobile.less +11 -0
- package/umd/swipe-load/index.js +88 -36
- package/umd/swipe-load/style/css/index.css +3 -0
- package/umd/swipe-load/style/index.less +7 -0
- package/umd/swipe-load/type.d.ts +29 -0
- package/umd/tabs/index.js +6 -2
- package/umd/tabs/style/css/index.css +4 -0
- package/umd/tabs/style/index.less +5 -0
- package/umd/tabs/tab-pane.js +49 -12
- package/umd/tabs/type.d.ts +7 -1
@@ -4,14 +4,21 @@
|
|
4
4
|
position: relative;
|
5
5
|
display: inline-flex;
|
6
6
|
width: 100%;
|
7
|
+
|
7
8
|
.@{prefix}-list-area {
|
8
9
|
position: relative;
|
9
10
|
width: 100%;
|
11
|
+
|
12
|
+
&::-webkit-scrollbar {
|
13
|
+
display: none;
|
14
|
+
}
|
10
15
|
}
|
16
|
+
|
11
17
|
.@{prefix}-loading-area {
|
12
18
|
.use-var(background-color, swipe-load-label-background);
|
13
19
|
margin-top: 0;
|
14
20
|
.use-var(border-radius, swipe-load-label-border-radius);
|
21
|
+
|
15
22
|
.@{prefix}-loading-label {
|
16
23
|
.use-var(margin-left, swipe-load-label-text-margin-left);
|
17
24
|
.use-var(width, swipe-load-label-text-width);
|
package/cjs/swipe-load/type.d.ts
CHANGED
@@ -77,6 +77,35 @@ export interface SwipeLoadProps {
|
|
77
77
|
* @default_en "Release to view"
|
78
78
|
*/
|
79
79
|
activeText?: string;
|
80
|
+
/**
|
81
|
+
* 触碰左侧边界时是否需要回弹效果
|
82
|
+
* @en Whether a bounce effect is required when touching the left boundary
|
83
|
+
* @default false
|
84
|
+
*/
|
85
|
+
bounceWhenBumpBoundary?: boolean;
|
86
|
+
/**
|
87
|
+
* 当开启回弹效果时的阻尼系数
|
88
|
+
* @en Damping coefficient when the rebound effect is turned on
|
89
|
+
* @default 3
|
90
|
+
*/
|
91
|
+
bounceDampRate?: number;
|
92
|
+
/**
|
93
|
+
* 当开启回弹效果时的动画毫秒时间
|
94
|
+
* @en Animation in milliseconds when the bounce effect is turned on
|
95
|
+
* @default 300
|
96
|
+
*/
|
97
|
+
bounceAnimateDuration?: number;
|
98
|
+
/**
|
99
|
+
* 回弹效果开启时需要回弹的容器,默认为 getScrollContainer 返回的容器或容器的一个子元素
|
100
|
+
* @en The container that needs to be rebounded when the rebound effect is enabled, the default is the container returned by getScrollContainer or a child element of the container
|
101
|
+
*/
|
102
|
+
getBounceContainer?: () => HTMLElement | null;
|
103
|
+
/**
|
104
|
+
* 当开启回弹效果时自定义手指滑动跟手的距离计算方式,dis表示touchmove的距离
|
105
|
+
* @en When the rebound effect is turned on, customize the calculation method of the distance between the finger sliding and the hand, and dis indicates the distance of touchmove
|
106
|
+
* @default (dis) => Math.min(dis, bounceScrollContainer.offsetWidth) / bounceDampRate
|
107
|
+
*/
|
108
|
+
bounceDistanceProcessor?: (dis: number) => number;
|
80
109
|
/**
|
81
110
|
* 抛出外层touch事件,便于自定义,常用于阻止划动退出,切换tab等手势冲突
|
82
111
|
* @en Throw the outer touchstart event, which is easy to customize. It is often used to prevent gesture conflicts such as swiping to exit, switching tabs, etc.
|
package/cjs/tabs/index.js
CHANGED
@@ -147,7 +147,9 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
147
147
|
fullScreen = props.fullScreen,
|
148
148
|
autoHeight = props.autoHeight,
|
149
149
|
_props$tabBarStopProp = props.tabBarStopPropagation,
|
150
|
-
tabBarStopPropagation = _props$tabBarStopProp === void 0 ? true : _props$tabBarStopProp
|
150
|
+
tabBarStopPropagation = _props$tabBarStopProp === void 0 ? true : _props$tabBarStopProp,
|
151
|
+
_props$swipeEnergySav = props.swipeEnergySaving,
|
152
|
+
swipeEnergySaving = _props$swipeEnergySav === void 0 ? false : _props$swipeEnergySav;
|
151
153
|
var domRef = (0, _react.useRef)(null);
|
152
154
|
var cellRef = (0, _react.useRef)(null);
|
153
155
|
var paneRef = (0, _react.useRef)(null);
|
@@ -246,6 +248,7 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
246
248
|
// 利用受控手动更改index时,给cell line加上动画
|
247
249
|
// @en Animate the cell line when changeing the index
|
248
250
|
setCellTrans(true);
|
251
|
+
changeFromRef.current = 'manual';
|
249
252
|
}, [activeTab]);
|
250
253
|
(0, _helpers.useUpdateEffect)(function () {
|
251
254
|
onDistanceChange && onDistanceChange(distance, wrapWidth, activeIndex);
|
@@ -533,7 +536,8 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
533
536
|
tabPaneClass: tabPaneClass,
|
534
537
|
tabPaneExtra: tabPaneExtra,
|
535
538
|
autoHeight: autoHeight,
|
536
|
-
onScroll: onScroll
|
539
|
+
onScroll: onScroll,
|
540
|
+
swipeEnergySaving: swipeEnergySaving
|
537
541
|
}, commonProps)));
|
538
542
|
});
|
539
543
|
});
|
@@ -473,6 +473,10 @@
|
|
473
473
|
-webkit-transition-timing-function: ease-out;
|
474
474
|
transition-timing-function: ease-out;
|
475
475
|
}
|
476
|
+
.arco-tab-pane-container.mode-swipe-energy-saving {
|
477
|
+
position: relative;
|
478
|
+
overflow: hidden;
|
479
|
+
}
|
476
480
|
.arco-tab-pane-container.full-screen {
|
477
481
|
-webkit-box-flex: 1;
|
478
482
|
-webkit-flex: 1;
|
package/cjs/tabs/tab-pane.js
CHANGED
@@ -50,6 +50,7 @@ var TabPane = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
50
50
|
translateZ = props.translateZ,
|
51
51
|
fullScreen = props.fullScreen,
|
52
52
|
autoHeight = props.autoHeight,
|
53
|
+
swipeEnergySaving = props.swipeEnergySaving,
|
53
54
|
changeIndex = props.changeIndex,
|
54
55
|
onScroll = props.onScroll;
|
55
56
|
var domRef = (0, _react.useRef)(null);
|
@@ -61,12 +62,16 @@ var TabPane = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
61
62
|
shownIndexes = _useState[0],
|
62
63
|
setShownIndexes = _useState[1];
|
63
64
|
|
65
|
+
var _useState2 = (0, _react.useState)(activeIndex),
|
66
|
+
shownActiveIndex = _useState2[0],
|
67
|
+
setShownActiveIndex = _useState2[1];
|
68
|
+
|
64
69
|
var prefix = prefixCls + "-tab-pane";
|
65
70
|
var handleTouchEnd = swipeable ? handlePaneTouchEnd : void 0;
|
66
71
|
|
67
|
-
var
|
68
|
-
currentPaneHeight =
|
69
|
-
setCurrentPaneHeight =
|
72
|
+
var _useState3 = (0, _react.useState)('auto'),
|
73
|
+
currentPaneHeight = _useState3[0],
|
74
|
+
setCurrentPaneHeight = _useState3[1];
|
70
75
|
|
71
76
|
(0, _react.useImperativeHandle)(ref, function () {
|
72
77
|
return {
|
@@ -152,6 +157,8 @@ var TabPane = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
152
157
|
}
|
153
158
|
|
154
159
|
function calcShownIndexes() {
|
160
|
+
setShownActiveIndex(activeIndex);
|
161
|
+
|
155
162
|
if (typeof lazyloadCount === 'number') {
|
156
163
|
setShownIndexes([activeIndex - lazyloadCount, activeIndex + lazyloadCount]);
|
157
164
|
return;
|
@@ -252,11 +259,35 @@ var TabPane = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
252
259
|
var heightStyle = currentPaneHeight && currentPaneHeight !== 'auto' ? {
|
253
260
|
height: currentPaneHeight
|
254
261
|
} : {};
|
255
|
-
return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, sizeStyle, {
|
262
|
+
return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, swipeEnergySaving ? {} : sizeStyle, {
|
256
263
|
transitionDuration: getTransition() + "ms"
|
257
264
|
}, heightStyle, commonStyle));
|
258
265
|
}
|
259
266
|
|
267
|
+
function getEnergySavingPaneStyle(index) {
|
268
|
+
if (mode === 'scroll' || !swipeEnergySaving) {
|
269
|
+
return undefined;
|
270
|
+
}
|
271
|
+
|
272
|
+
if (index !== shownActiveIndex) {
|
273
|
+
return {
|
274
|
+
position: 'absolute',
|
275
|
+
left: '-100%',
|
276
|
+
top: '-100%'
|
277
|
+
};
|
278
|
+
}
|
279
|
+
|
280
|
+
var translateStr = translateZ ? ' translateZ(0)' : '';
|
281
|
+
var sizeStyle = tabDirection === 'vertical' ? {
|
282
|
+
transform: "translateX(" + (distance - wrapWidth * (activeIndex - index)) + "px)" + translateStr
|
283
|
+
} : {
|
284
|
+
transform: "translateY(" + (distance - wrapHeight * (activeIndex - index)) + "px)" + translateStr
|
285
|
+
};
|
286
|
+
return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, sizeStyle, {
|
287
|
+
transitionDuration: getTransition() + "ms"
|
288
|
+
}));
|
289
|
+
}
|
290
|
+
|
260
291
|
function renderContent(pane, index) {
|
261
292
|
var contentProps = {
|
262
293
|
key: index,
|
@@ -266,32 +297,38 @@ var TabPane = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
266
297
|
ref: function ref(r) {
|
267
298
|
return panesRef.current[index] = r;
|
268
299
|
}
|
269
|
-
};
|
300
|
+
};
|
301
|
+
var energySavingStyle = getEnergySavingPaneStyle(index); // 是滚动模式或在加载范围内,直接渲染
|
270
302
|
// @en Render directly when in scroll mode or in loading scope
|
271
303
|
|
272
304
|
if (mode === 'scroll' || index >= shownIndexes[0] && index <= shownIndexes[1]) {
|
273
|
-
return /*#__PURE__*/_react.default.createElement("div", contentProps,
|
274
|
-
|
275
|
-
|
305
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, contentProps, {
|
306
|
+
style: energySavingStyle
|
307
|
+
}), pane);
|
308
|
+
}
|
276
309
|
|
310
|
+
var energySavingHideStyle = (0, _extends2.default)({}, energySavingStyle, hideContentStyle || {}); // 不在加载范围内,视renderHideContent和hideContentStyle情况而定
|
311
|
+
// @en Not in the loading range, depending on renderHideContent and hideContentStyle
|
277
312
|
|
278
313
|
if (renderHideContent) {
|
279
314
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, contentProps, {
|
280
|
-
style:
|
315
|
+
style: energySavingHideStyle
|
281
316
|
}), renderHideContent(index, pane));
|
282
317
|
}
|
283
318
|
|
284
319
|
if (hideContentStyle === null) {
|
285
|
-
return /*#__PURE__*/_react.default.createElement("div", contentProps
|
320
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, contentProps, {
|
321
|
+
style: energySavingStyle
|
322
|
+
}));
|
286
323
|
}
|
287
324
|
|
288
325
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, contentProps, {
|
289
|
-
style:
|
326
|
+
style: energySavingHideStyle
|
290
327
|
}), pane);
|
291
328
|
}
|
292
329
|
|
293
330
|
return /*#__PURE__*/_react.default.createElement("div", {
|
294
|
-
className: (0, _mobileUtils.cls)(prefix + "-container", tabDirection, "mode-" + mode, tabPaneClass, {
|
331
|
+
className: (0, _mobileUtils.cls)(prefix + "-container", tabDirection, swipeEnergySaving ? "mode-" + mode + "-energy-saving" : "mode-" + mode, tabPaneClass, {
|
295
332
|
'full-screen': fullScreen
|
296
333
|
}, (_cls = {}, _cls["mode-scroll-" + (scrollVertical ? 'vertical' : 'horizontal')] = mode === 'scroll', _cls)),
|
297
334
|
style: getPaneStyle(),
|
package/cjs/tabs/type.d.ts
CHANGED
@@ -322,6 +322,12 @@ export interface TabsProps {
|
|
322
322
|
* @default true
|
323
323
|
*/
|
324
324
|
translateZ?: boolean;
|
325
|
+
/**
|
326
|
+
* 是否启用滑动节能模式,开启后TabPane外层容器不会随panes数量撑开并提升为合成层,仅滑动当前选中的pane,其他pane在选中前将被隐藏
|
327
|
+
* @en Whether to enable the energy-saving sliding mode. After opening, the outer container of the TabPane will not expand with the number of panes and be promoted to a composite layer. Only the currently selected pane will be slid, and other panes will be hidden before being selected.
|
328
|
+
* @default false
|
329
|
+
*/
|
330
|
+
swipeEnergySaving?: boolean;
|
325
331
|
/**
|
326
332
|
* 当滑到第一页或最后一页,还想再滑动时触发
|
327
333
|
* @en Triggered when swiping to the first or last page and want to swipe again
|
@@ -560,7 +566,7 @@ export interface TabCellRef {
|
|
560
566
|
*/
|
561
567
|
resetUnderlineStyle: () => void;
|
562
568
|
}
|
563
|
-
export interface TabPaneProps extends Pick<TabsProps, 'duration' | 'transitionDuration' | 'lazyloadCount' | 'hideContentStyle' | 'renderHideContent' | 'mode' | 'tabPaneClass' | 'tabPaneStyle' | 'tabPaneExtra' | 'getScrollContainer' | 'scrollThrottle' | 'scrollOffset' | 'goLastWhenScrollBottom' | 'scrollVertical' | 'translateZ' | 'fullScreen' | 'autoHeight' | 'onScroll'> {
|
569
|
+
export interface TabPaneProps extends Pick<TabsProps, 'duration' | 'transitionDuration' | 'lazyloadCount' | 'hideContentStyle' | 'renderHideContent' | 'mode' | 'tabPaneClass' | 'tabPaneStyle' | 'tabPaneExtra' | 'getScrollContainer' | 'scrollThrottle' | 'scrollOffset' | 'goLastWhenScrollBottom' | 'scrollVertical' | 'translateZ' | 'fullScreen' | 'autoHeight' | 'onScroll' | 'swipeEnergySaving'> {
|
564
570
|
prefixCls?: string;
|
565
571
|
panes: ReactNodeArray;
|
566
572
|
activeIndex: number;
|