@arco-design/mobile-react 2.30.8 → 2.30.10
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 +25 -0
- package/README.en-US.md +70 -2
- package/README.md +69 -2
- package/cjs/_helpers/render.d.ts +6 -1
- package/cjs/_helpers/render.js +24 -2
- package/cjs/carousel/index.js +3 -0
- package/cjs/image/style/index.less +2 -4
- package/cjs/image-preview/methods.js +2 -7
- package/cjs/masking/methods.js +12 -6
- package/cjs/picker/index.js +3 -2
- package/cjs/picker/type.d.ts +1 -1
- package/cjs/picker-view/components/cascader.d.ts +1 -0
- package/cjs/picker-view/components/cascader.js +8 -1
- package/cjs/picker-view/components/picker-cell.d.ts +1 -0
- package/cjs/picker-view/components/picker-cell.js +6 -1
- package/cjs/picker-view/index.d.ts +6 -1
- package/cjs/picker-view/index.js +25 -13
- package/cjs/skeleton/type.d.ts +1 -1
- package/cjs/skeleton/type.js +1 -6
- package/cjs/tabs/tab-cell.js +54 -29
- package/cjs/tabs/type.d.ts +5 -0
- package/dist/index.js +137 -58
- package/dist/index.min.js +3 -3
- package/esm/_helpers/render.d.ts +6 -1
- package/esm/_helpers/render.js +21 -1
- package/esm/carousel/index.js +3 -0
- package/esm/image/style/index.less +2 -4
- package/esm/image-preview/methods.js +2 -7
- package/esm/masking/methods.js +13 -7
- package/esm/picker/index.js +3 -2
- package/esm/picker/type.d.ts +1 -1
- package/esm/picker-view/components/cascader.d.ts +1 -0
- package/esm/picker-view/components/cascader.js +8 -1
- package/esm/picker-view/components/picker-cell.d.ts +1 -0
- package/esm/picker-view/components/picker-cell.js +6 -1
- package/esm/picker-view/index.d.ts +6 -1
- package/esm/picker-view/index.js +26 -13
- package/esm/skeleton/type.d.ts +1 -1
- package/esm/skeleton/type.js +1 -2
- package/esm/tabs/tab-cell.js +55 -29
- package/esm/tabs/type.d.ts +5 -0
- package/package.json +3 -3
- package/umd/_helpers/render.d.ts +6 -1
- package/umd/_helpers/render.js +23 -2
- package/umd/carousel/index.js +3 -0
- package/umd/image/style/index.less +2 -4
- package/umd/image-preview/methods.js +2 -7
- package/umd/masking/methods.js +12 -6
- package/umd/picker/index.js +3 -2
- package/umd/picker/type.d.ts +1 -1
- package/umd/picker-view/components/cascader.d.ts +1 -0
- package/umd/picker-view/components/cascader.js +8 -1
- package/umd/picker-view/components/picker-cell.d.ts +1 -0
- package/umd/picker-view/components/picker-cell.js +6 -1
- package/umd/picker-view/index.d.ts +6 -1
- package/umd/picker-view/index.js +25 -13
- package/umd/skeleton/type.d.ts +1 -1
- package/umd/skeleton/type.js +4 -6
- package/umd/tabs/tab-cell.js +54 -29
- package/umd/tabs/type.d.ts +5 -0
package/esm/_helpers/render.d.ts
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
import { FunctionComponent } from 'react';
|
2
2
|
import { RootType } from './react-dom';
|
3
3
|
import { GlobalContextParams } from '../context-provider';
|
4
|
+
export declare const renderRootCache: Record<string, RootType | undefined>;
|
4
5
|
export declare class ReactDOMRender {
|
5
6
|
root: RootType | undefined;
|
6
7
|
app: FunctionComponent;
|
7
8
|
container: Element | DocumentFragment;
|
8
9
|
context: GlobalContextParams | undefined;
|
9
|
-
|
10
|
+
rootCacheId: string | undefined;
|
11
|
+
constructor(app: FunctionComponent, container: Element | DocumentFragment, context?: GlobalContextParams, rootCacheId?: string, // root id in cache
|
12
|
+
root?: RootType);
|
10
13
|
render: (props: any) => void;
|
14
|
+
setRootCache: () => void;
|
15
|
+
clearRootCache: () => void;
|
11
16
|
unmount: () => void;
|
12
17
|
}
|
package/esm/_helpers/render.js
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import { render as copyRender } from './react-dom';
|
4
|
-
export var
|
4
|
+
export var renderRootCache = {};
|
5
|
+
export var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
|
6
|
+
root // use root in cache
|
7
|
+
) {
|
5
8
|
var _this = this;
|
6
9
|
|
7
10
|
this.root = void 0;
|
8
11
|
this.app = void 0;
|
9
12
|
this.container = void 0;
|
10
13
|
this.context = void 0;
|
14
|
+
this.rootCacheId = void 0;
|
11
15
|
|
12
16
|
this.render = function (props) {
|
13
17
|
var CustomApp = _this.app;
|
@@ -23,14 +27,30 @@ export var ReactDOMRender = function ReactDOMRender(app, container, context) {
|
|
23
27
|
}
|
24
28
|
};
|
25
29
|
|
30
|
+
this.setRootCache = function () {
|
31
|
+
if (_this.rootCacheId) {
|
32
|
+
renderRootCache[_this.rootCacheId] = _this.root;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
this.clearRootCache = function () {
|
37
|
+
if (_this.rootCacheId) {
|
38
|
+
delete renderRootCache[_this.rootCacheId];
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
26
42
|
this.unmount = function () {
|
27
43
|
var _this$root;
|
28
44
|
|
29
45
|
(_this$root = _this.root) == null ? void 0 : _this$root._unmount();
|
30
46
|
_this.root = undefined;
|
47
|
+
|
48
|
+
_this.clearRootCache();
|
31
49
|
};
|
32
50
|
|
33
51
|
this.app = app;
|
34
52
|
this.container = container;
|
35
53
|
this.context = context;
|
54
|
+
this.rootCacheId = rootCacheId;
|
55
|
+
this.root = root;
|
36
56
|
};
|
package/esm/carousel/index.js
CHANGED
@@ -640,6 +640,9 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
640
640
|
|
641
641
|
function getFakeChild() {
|
642
642
|
if (noLoop) {
|
643
|
+
// 循环状态从有到无时,重置 transforms
|
644
|
+
// @en reset transforms when loop status changes to false
|
645
|
+
setTransforms([]);
|
643
646
|
return;
|
644
647
|
}
|
645
648
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
@import
|
1
|
+
@import '../../../style/mixin.less';
|
2
2
|
|
3
3
|
.@{prefix}-image {
|
4
4
|
display: inline-block;
|
5
5
|
position: relative;
|
6
6
|
|
7
7
|
&.preview {
|
8
|
-
transition: all .3s ease-in-out;
|
8
|
+
transition: all 0.3s ease-in-out;
|
9
9
|
|
10
10
|
.image-container,
|
11
11
|
.image-loading-container .image-loading,
|
@@ -109,7 +109,6 @@
|
|
109
109
|
}
|
110
110
|
|
111
111
|
.image-error-container {
|
112
|
-
|
113
112
|
.image-retry-load {
|
114
113
|
position: absolute;
|
115
114
|
top: 0;
|
@@ -127,7 +126,6 @@
|
|
127
126
|
}
|
128
127
|
|
129
128
|
.image-loading-container {
|
130
|
-
|
131
129
|
.image-loading {
|
132
130
|
position: absolute;
|
133
131
|
top: 0;
|
@@ -3,9 +3,7 @@ import { appendElementById, removeElement } from '@arco-design/mobile-utils';
|
|
3
3
|
import { ReactDOMRender } from '../_helpers/render';
|
4
4
|
export function open(Component) {
|
5
5
|
return function (config, context) {
|
6
|
-
var baseProps = _extends({
|
7
|
-
unmountOnExit: true
|
8
|
-
}, config || {}, {
|
6
|
+
var baseProps = _extends({}, config || {}, {
|
9
7
|
close: function close() {}
|
10
8
|
}); // 不同的key用不同的容器挂载
|
11
9
|
// @en Different keys are mounted in different containers
|
@@ -42,10 +40,7 @@ export function open(Component) {
|
|
42
40
|
|
43
41
|
dynamicProps.onClose = function () {
|
44
42
|
baseProps.onClose && baseProps.onClose();
|
45
|
-
|
46
|
-
if (baseProps.unmountOnExit) {
|
47
|
-
removeElement(div);
|
48
|
-
}
|
43
|
+
removeElement(div);
|
49
44
|
};
|
50
45
|
|
51
46
|
dynamicProps.openIndex = -1;
|
package/esm/masking/methods.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import { appendElementById, removeElement, nextTick } from '@arco-design/mobile-utils';
|
3
|
-
import { ReactDOMRender } from '../_helpers/render';
|
3
|
+
import { ReactDOMRender, renderRootCache } from '../_helpers/render';
|
4
4
|
export function getOpenMethod(Component, containerId, normalize) {
|
5
5
|
if (normalize === void 0) {
|
6
6
|
normalize = function normalize(config) {
|
@@ -18,14 +18,14 @@ export function getOpenMethod(Component, containerId, normalize) {
|
|
18
18
|
|
19
19
|
|
20
20
|
var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
|
21
|
-
|
22
|
-
var
|
23
|
-
div = _appendElementById.child;
|
24
|
-
|
21
|
+
var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
|
22
|
+
var div = existedDiv || appendElementById(id, baseProps.getContainer).child;
|
25
23
|
var leaving = false;
|
26
24
|
|
27
|
-
var _ReactDOMRender = new ReactDOMRender(Component, div, context),
|
28
|
-
render = _ReactDOMRender.render
|
25
|
+
var _ReactDOMRender = new ReactDOMRender(Component, div, context, id, existedDiv ? renderRootCache[id] : undefined),
|
26
|
+
render = _ReactDOMRender.render,
|
27
|
+
unmount = _ReactDOMRender.unmount,
|
28
|
+
setRootCache = _ReactDOMRender.setRootCache;
|
29
29
|
|
30
30
|
var dynamicProps = _extends({}, baseProps, {
|
31
31
|
getContainer: function getContainer() {
|
@@ -50,11 +50,17 @@ export function getOpenMethod(Component, containerId, normalize) {
|
|
50
50
|
baseProps.onClose && baseProps.onClose(scene);
|
51
51
|
|
52
52
|
if (baseProps.unmountOnExit) {
|
53
|
+
unmount();
|
53
54
|
removeElement(div);
|
54
55
|
}
|
55
56
|
};
|
56
57
|
|
57
58
|
render(dynamicProps);
|
59
|
+
|
60
|
+
if (!baseProps.unmountOnExit) {
|
61
|
+
setRootCache();
|
62
|
+
}
|
63
|
+
|
58
64
|
nextTick(function () {
|
59
65
|
if (leaving) return;
|
60
66
|
dynamicProps.visible = true;
|
package/esm/picker/index.js
CHANGED
@@ -95,12 +95,13 @@ var Picker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
95
95
|
|
96
96
|
(_pickerViewRef$curren6 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren6.scrollToCurrentIndex();
|
97
97
|
nextTick(function () {
|
98
|
-
var _pickerViewRef$curren7;
|
98
|
+
var _pickerViewRef$curren7, _pickerViewRef$curren8;
|
99
99
|
|
100
100
|
var val = ((_pickerViewRef$curren7 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren7.getAllColumnValues()) || scrollValueRef.current || [];
|
101
|
+
var selectedData = ((_pickerViewRef$curren8 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren8.getAllColumnData()) || [];
|
101
102
|
|
102
103
|
if (onOk) {
|
103
|
-
onOk(val);
|
104
|
+
onOk(val, selectedData);
|
104
105
|
}
|
105
106
|
|
106
107
|
if (onChange) {
|
package/esm/picker/type.d.ts
CHANGED
@@ -81,7 +81,7 @@ export interface PickerProps extends Omit<PopupProps, 'visible' | 'close' | 'chi
|
|
81
81
|
* 点击选中时执行的回调
|
82
82
|
* @en Callback when clicking on Ok
|
83
83
|
*/
|
84
|
-
onOk?: (value: ValueType[]) => void;
|
84
|
+
onOk?: (value: ValueType[], data: PickerData[]) => void;
|
85
85
|
/**
|
86
86
|
* 点击取消时执行的回调
|
87
87
|
* @en Callback when clicking to cancel
|
@@ -19,6 +19,7 @@ export interface CascaderRef {
|
|
19
19
|
getCellMovingStatus: () => PickerCellMovingStatus[];
|
20
20
|
scrollToCurrentIndex: () => void;
|
21
21
|
getAllCellsValue: () => ValueType[];
|
22
|
+
getAllCellsData: () => PickerData[];
|
22
23
|
}
|
23
24
|
declare const Cascader: React.ForwardRefExoticComponent<CascaderProps & React.RefAttributes<CascaderRef>>;
|
24
25
|
export default Cascader;
|
@@ -22,7 +22,8 @@ var Cascader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
22
22
|
return {
|
23
23
|
getCellMovingStatus: getCellMovingStatus,
|
24
24
|
scrollToCurrentIndex: scrollToCurrentIndex,
|
25
|
-
getAllCellsValue: getAllCellsValue
|
25
|
+
getAllCellsValue: getAllCellsValue,
|
26
|
+
getAllCellsData: getAllCellsData
|
26
27
|
};
|
27
28
|
});
|
28
29
|
|
@@ -44,6 +45,12 @@ var Cascader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
44
45
|
});
|
45
46
|
}
|
46
47
|
|
48
|
+
function getAllCellsData() {
|
49
|
+
return pickerCellsRef.current.map(function (cell) {
|
50
|
+
return cell.getCurrentCellData();
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
47
54
|
function _onValueChange(value, index, newData) {
|
48
55
|
var children = arrayTreeFilter(data, function (item, level) {
|
49
56
|
return level <= index && item.value === value[level];
|
@@ -22,6 +22,7 @@ export interface PickerCellRef {
|
|
22
22
|
movingStatus: PickerCellMovingStatus;
|
23
23
|
scrollToCurrentIndex: () => void;
|
24
24
|
getCurrentCellValue: () => ValueType;
|
25
|
+
getCurrentCellData: () => PickerData;
|
25
26
|
}
|
26
27
|
declare const PickerCell: React.ForwardRefExoticComponent<PickerCellProps & React.RefAttributes<PickerCellRef>>;
|
27
28
|
export default PickerCell;
|
@@ -289,6 +289,10 @@ var PickerCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
289
289
|
return (_data$currentIndex = data[currentIndex]) == null ? void 0 : _data$currentIndex.value;
|
290
290
|
}
|
291
291
|
|
292
|
+
function getCurrentCellData() {
|
293
|
+
return data[currentIndex];
|
294
|
+
}
|
295
|
+
|
292
296
|
function _clearTimer() {
|
293
297
|
timeRef.current && clearTimeout(timeRef.current);
|
294
298
|
timeRef.current = null;
|
@@ -354,7 +358,8 @@ var PickerCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
354
358
|
return {
|
355
359
|
movingStatus: movingStatusRef.current,
|
356
360
|
scrollToCurrentIndex: scrollToCurrentIndex,
|
357
|
-
getCurrentCellValue: getCurrentCellValue
|
361
|
+
getCurrentCellValue: getCurrentCellValue,
|
362
|
+
getCurrentCellData: getCurrentCellData
|
358
363
|
};
|
359
364
|
});
|
360
365
|
return !hideEmptyCols || data && data.length ? /*#__PURE__*/React.createElement("div", {
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import MultiPicker from '../picker-view/components/multi-picker';
|
3
3
|
import PickerCell from '../picker-view/components/picker-cell';
|
4
4
|
import Cascader from '../picker-view/components/cascader';
|
5
|
-
import { PickerViewProps, ValueType, PickerCellMovingStatus } from './type';
|
5
|
+
import { PickerViewProps, ValueType, PickerData, PickerCellMovingStatus } from './type';
|
6
6
|
export * from './type';
|
7
7
|
export { MultiPicker, PickerCell, Cascader };
|
8
8
|
export interface PickerViewRef {
|
@@ -41,6 +41,11 @@ export interface PickerViewRef {
|
|
41
41
|
* @en Jump directly to the current most recent line (will break scrolling when called)
|
42
42
|
*/
|
43
43
|
scrollToCurrentIndex: () => void;
|
44
|
+
/**
|
45
|
+
* 获取所有列的 data
|
46
|
+
* @en Get all column data
|
47
|
+
*/
|
48
|
+
getAllColumnData: () => PickerData[];
|
44
49
|
}
|
45
50
|
declare const _default: React.ForwardRefExoticComponent<PickerViewProps & React.RefAttributes<PickerViewRef>> & {
|
46
51
|
displayName?: string | undefined;
|
package/esm/picker-view/index.js
CHANGED
@@ -8,6 +8,15 @@ import Cascader from '../picker-view/components/cascader';
|
|
8
8
|
import { useMountedState } from '../_helpers';
|
9
9
|
export * from './type';
|
10
10
|
export { MultiPicker, PickerCell, Cascader };
|
11
|
+
|
12
|
+
var isArray = function isArray(dt) {
|
13
|
+
return dt ? Array.isArray(dt[0]) : false;
|
14
|
+
};
|
15
|
+
|
16
|
+
var isStrOrNum = function isStrOrNum(dt) {
|
17
|
+
return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
|
18
|
+
};
|
19
|
+
|
11
20
|
var PickerView = /*#__PURE__*/forwardRef(function (props, ref) {
|
12
21
|
var _props$className = props.className,
|
13
22
|
className = _props$className === void 0 ? '' : _props$className,
|
@@ -57,14 +66,6 @@ var PickerView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
66
|
var innerData = useMemo(function () {
|
58
67
|
var newData;
|
59
68
|
|
60
|
-
var isArray = function isArray(dt) {
|
61
|
-
return dt ? Array.isArray(dt[0]) : false;
|
62
|
-
};
|
63
|
-
|
64
|
-
var isStrOrNum = function isStrOrNum(dt) {
|
65
|
-
return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
|
66
|
-
};
|
67
|
-
|
68
69
|
if (isArray(data)) {
|
69
70
|
if (isStrOrNum(data)) {
|
70
71
|
newData = data.map(function (item) {
|
@@ -98,6 +99,17 @@ var PickerView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
98
99
|
});
|
99
100
|
};
|
100
101
|
|
102
|
+
var getAllColumnData = function getAllColumnData() {
|
103
|
+
var _cascaderRef$current2;
|
104
|
+
|
105
|
+
var curValues = cascade ? ((_cascaderRef$current2 = cascaderRef.current) == null ? void 0 : _cascaderRef$current2.getAllCellsData()) || [] : pickerCellsRef.current.map(function (cell) {
|
106
|
+
return cell.getCurrentCellData();
|
107
|
+
});
|
108
|
+
return curValues.filter(function (v) {
|
109
|
+
return v !== undefined;
|
110
|
+
});
|
111
|
+
};
|
112
|
+
|
101
113
|
function getColumnValue(index) {
|
102
114
|
if (index === void 0) {
|
103
115
|
index = 0;
|
@@ -107,18 +119,18 @@ var PickerView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
107
119
|
}
|
108
120
|
|
109
121
|
function getCellMovingStatus() {
|
110
|
-
var _cascaderRef$
|
122
|
+
var _cascaderRef$current3;
|
111
123
|
|
112
|
-
return cascade ? ((_cascaderRef$
|
124
|
+
return cascade ? ((_cascaderRef$current3 = cascaderRef.current) == null ? void 0 : _cascaderRef$current3.getCellMovingStatus()) || [] : pickerCellsRef.current.map(function (cell) {
|
113
125
|
return cell.movingStatus;
|
114
126
|
});
|
115
127
|
}
|
116
128
|
|
117
129
|
function scrollToCurrentIndex() {
|
118
130
|
if (cascade) {
|
119
|
-
var _cascaderRef$
|
131
|
+
var _cascaderRef$current4;
|
120
132
|
|
121
|
-
(_cascaderRef$
|
133
|
+
(_cascaderRef$current4 = cascaderRef.current) == null ? void 0 : _cascaderRef$current4.scrollToCurrentIndex();
|
122
134
|
return;
|
123
135
|
}
|
124
136
|
|
@@ -135,7 +147,8 @@ var PickerView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
135
147
|
getColumnValue: getColumnValue,
|
136
148
|
updateLayout: updateLayout,
|
137
149
|
resetValue: resetValue,
|
138
|
-
scrollToCurrentIndex: scrollToCurrentIndex
|
150
|
+
scrollToCurrentIndex: scrollToCurrentIndex,
|
151
|
+
getAllColumnData: getAllColumnData
|
139
152
|
};
|
140
153
|
});
|
141
154
|
|
package/esm/skeleton/type.d.ts
CHANGED
package/esm/skeleton/type.js
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
export { BaseProps, SimpleBaseProps };
|
1
|
+
export {};
|
package/esm/tabs/tab-cell.js
CHANGED
@@ -73,14 +73,18 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
73
73
|
return tabs.length < overflowThreshold ? tabBarArrange : 'start';
|
74
74
|
}),
|
75
75
|
originArrange = _useState3[0],
|
76
|
-
setOriginArrange = _useState3[1];
|
76
|
+
setOriginArrange = _useState3[1];
|
77
77
|
|
78
|
+
var _useState4 = useState(false),
|
79
|
+
forceUpdate = _useState4[0],
|
80
|
+
setForceUpdate = _useState4[1]; // 默认tab小于overflowThreshold个时不开启加载前隐藏,大于overflowThreshold个时开启
|
78
81
|
|
79
|
-
|
82
|
+
|
83
|
+
var _useState5 = useState(function () {
|
80
84
|
return hideTabBarBeforeMounted === void 0 ? tabs.length < overflowThreshold || activeIndex === 0 : !hideTabBarBeforeMounted;
|
81
85
|
}),
|
82
|
-
showTab =
|
83
|
-
setShowTab =
|
86
|
+
showTab = _useState5[0],
|
87
|
+
setShowTab = _useState5[1];
|
84
88
|
|
85
89
|
var isVertical = tabDirection === 'vertical';
|
86
90
|
var isLine = (type || '').indexOf('line') !== -1;
|
@@ -95,6 +99,15 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
95
99
|
var hasDivider = tabBarHasDivider === void 0 ? isLine : tabBarHasDivider;
|
96
100
|
var wrapSize = isVertical ? wrapWidth : wrapHeight;
|
97
101
|
var system = useSystem();
|
102
|
+
|
103
|
+
var updateScrollPosition = function updateScrollPosition() {
|
104
|
+
if (wrapSize && tabBarScrollChance !== 'none') {
|
105
|
+
setTimeout(function () {
|
106
|
+
scrollToCenter();
|
107
|
+
}, tabBarScrollChance === 'after-jump' ? Math.max(transitionDuration || 0, duration || 0) : 0);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
98
111
|
useEffect(function () {
|
99
112
|
nextTick(function () {
|
100
113
|
setCellOverflow(); // dom出来之后originArrange置空,交由tabBarArrange控制
|
@@ -114,31 +127,16 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
114
127
|
(_underlineRef$current = underlineRef.current) == null ? void 0 : _underlineRef$current.resetUnderlineStyle();
|
115
128
|
});
|
116
129
|
}, [activeIndex, tabs, getCellPadding('left'), getCellPadding('right'), tabBarGutter, tabDirection]);
|
117
|
-
useImperativeHandle(ref, function () {
|
118
|
-
return {
|
119
|
-
dom: domRef.current,
|
120
|
-
scrollTo: scrollTo,
|
121
|
-
scrollToCenter: scrollToCenter,
|
122
|
-
hasOverflow: hasOverflow,
|
123
|
-
setCaterpillarAnimate: function setCaterpillarAnimate(ratio) {
|
124
|
-
var _underlineRef$current2;
|
125
|
-
|
126
|
-
return (_underlineRef$current2 = underlineRef.current) == null ? void 0 : _underlineRef$current2.setCaterpillarAnimate(ratio);
|
127
|
-
},
|
128
|
-
resetUnderlineStyle: function resetUnderlineStyle() {
|
129
|
-
var _underlineRef$current3;
|
130
|
-
|
131
|
-
return (_underlineRef$current3 = underlineRef.current) == null ? void 0 : _underlineRef$current3.resetUnderlineStyle();
|
132
|
-
}
|
133
|
-
};
|
134
|
-
}, [scrollToCenter, scrollTo, hasOverflow]);
|
135
130
|
useEffect(function () {
|
136
|
-
|
137
|
-
setTimeout(function () {
|
138
|
-
scrollToCenter();
|
139
|
-
}, tabBarScrollChance === 'after-jump' ? Math.max(transitionDuration || 0, duration || 0) : 0);
|
140
|
-
}
|
131
|
+
updateScrollPosition();
|
141
132
|
}, [activeIndex, wrapSize]);
|
133
|
+
useEffect(function () {
|
134
|
+
var _underlineRef$current2;
|
135
|
+
|
136
|
+
setCellOverflow();
|
137
|
+
(_underlineRef$current2 = underlineRef.current) == null ? void 0 : _underlineRef$current2.resetUnderlineStyle();
|
138
|
+
updateScrollPosition();
|
139
|
+
}, [forceUpdate]);
|
142
140
|
useEffect(function () {
|
143
141
|
tabBarScrollChance !== 'none' && scrollToCenter(true); // TabCell左右可滚动时,防止触发父级touchmove事件导致滚不动
|
144
142
|
// @en When the TabCell can be scrolled left and right, prevent the parent touchmove event from being triggered which result in inability to scroll
|
@@ -279,7 +277,7 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
279
277
|
return typeof tab === 'string' ? tab : tab.title;
|
280
278
|
}
|
281
279
|
|
282
|
-
function renderTabUnderline() {
|
280
|
+
var renderTabUnderline = function renderTabUnderline() {
|
283
281
|
if (!showUnderline || !isLine) {
|
284
282
|
return null;
|
285
283
|
}
|
@@ -310,7 +308,7 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
310
308
|
getTabCenterLeft: getTabCenterLeft,
|
311
309
|
getTabRect: getTabRect
|
312
310
|
}, lineProps));
|
313
|
-
}
|
311
|
+
};
|
314
312
|
|
315
313
|
var cellInner = /*#__PURE__*/React.createElement(React.Fragment, null, tabs.map(function (tab, index) {
|
316
314
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -352,6 +350,34 @@ var TabCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
352
350
|
height: '100%'
|
353
351
|
}
|
354
352
|
}) : null);
|
353
|
+
|
354
|
+
var _updateLayout = function updateLayout() {
|
355
|
+
setForceUpdate(function (val) {
|
356
|
+
return !val;
|
357
|
+
});
|
358
|
+
};
|
359
|
+
|
360
|
+
useImperativeHandle(ref, function () {
|
361
|
+
return {
|
362
|
+
dom: domRef.current,
|
363
|
+
scrollTo: scrollTo,
|
364
|
+
scrollToCenter: scrollToCenter,
|
365
|
+
hasOverflow: hasOverflow,
|
366
|
+
setCaterpillarAnimate: function setCaterpillarAnimate(ratio) {
|
367
|
+
var _underlineRef$current3;
|
368
|
+
|
369
|
+
return (_underlineRef$current3 = underlineRef.current) == null ? void 0 : _underlineRef$current3.setCaterpillarAnimate(ratio);
|
370
|
+
},
|
371
|
+
resetUnderlineStyle: function resetUnderlineStyle() {
|
372
|
+
var _underlineRef$current4;
|
373
|
+
|
374
|
+
return (_underlineRef$current4 = underlineRef.current) == null ? void 0 : _underlineRef$current4.resetUnderlineStyle();
|
375
|
+
},
|
376
|
+
updateLayout: function updateLayout() {
|
377
|
+
return _updateLayout();
|
378
|
+
}
|
379
|
+
};
|
380
|
+
}, [scrollToCenter, scrollTo, hasOverflow]);
|
355
381
|
return /*#__PURE__*/React.createElement("div", {
|
356
382
|
className: cls(prefix + "-container-wrap", tabDirection, "type-" + type, tabBarClass, system),
|
357
383
|
style: tabBarStyle
|
package/esm/tabs/type.d.ts
CHANGED
@@ -565,6 +565,11 @@ export interface TabCellRef {
|
|
565
565
|
* @en Recalculate underline style
|
566
566
|
*/
|
567
567
|
resetUnderlineStyle: () => void;
|
568
|
+
/**
|
569
|
+
* 强制更新 tab-cell
|
570
|
+
* @en Force update tab-cell
|
571
|
+
*/
|
572
|
+
updateLayout: () => void;
|
568
573
|
}
|
569
574
|
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'> {
|
570
575
|
prefixCls?: string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arco-design/mobile-react",
|
3
|
-
"version": "2.30.
|
3
|
+
"version": "2.30.10",
|
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.17.
|
18
|
+
"@arco-design/mobile-utils": "2.17.10",
|
19
19
|
"@arco-design/transformable": "^1.0.0",
|
20
20
|
"lodash.throttle": "^4.1.1",
|
21
21
|
"resize-observer-polyfill": "^1.5.1"
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "70e0f287b7e294b0d2d8e1516e4ff614f212f7dd"
|
53
53
|
}
|
package/umd/_helpers/render.d.ts
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
import { FunctionComponent } from 'react';
|
2
2
|
import { RootType } from './react-dom';
|
3
3
|
import { GlobalContextParams } from '../context-provider';
|
4
|
+
export declare const renderRootCache: Record<string, RootType | undefined>;
|
4
5
|
export declare class ReactDOMRender {
|
5
6
|
root: RootType | undefined;
|
6
7
|
app: FunctionComponent;
|
7
8
|
container: Element | DocumentFragment;
|
8
9
|
context: GlobalContextParams | undefined;
|
9
|
-
|
10
|
+
rootCacheId: string | undefined;
|
11
|
+
constructor(app: FunctionComponent, container: Element | DocumentFragment, context?: GlobalContextParams, rootCacheId?: string, // root id in cache
|
12
|
+
root?: RootType);
|
10
13
|
render: (props: any) => void;
|
14
|
+
setRootCache: () => void;
|
15
|
+
clearRootCache: () => void;
|
11
16
|
unmount: () => void;
|
12
17
|
}
|
package/umd/_helpers/render.js
CHANGED
@@ -16,17 +16,22 @@
|
|
16
16
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
17
17
|
|
18
18
|
_exports.__esModule = true;
|
19
|
-
_exports.ReactDOMRender = void 0;
|
19
|
+
_exports.renderRootCache = _exports.ReactDOMRender = void 0;
|
20
20
|
_extends2 = _interopRequireDefault(_extends2);
|
21
21
|
_react = _interopRequireDefault(_react);
|
22
|
+
var renderRootCache = {};
|
23
|
+
_exports.renderRootCache = renderRootCache;
|
22
24
|
|
23
|
-
var ReactDOMRender = function ReactDOMRender(app, container, context
|
25
|
+
var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
|
26
|
+
root // use root in cache
|
27
|
+
) {
|
24
28
|
var _this = this;
|
25
29
|
|
26
30
|
this.root = void 0;
|
27
31
|
this.app = void 0;
|
28
32
|
this.container = void 0;
|
29
33
|
this.context = void 0;
|
34
|
+
this.rootCacheId = void 0;
|
30
35
|
|
31
36
|
this.render = function (props) {
|
32
37
|
var CustomApp = _this.app;
|
@@ -41,16 +46,32 @@
|
|
41
46
|
}
|
42
47
|
};
|
43
48
|
|
49
|
+
this.setRootCache = function () {
|
50
|
+
if (_this.rootCacheId) {
|
51
|
+
renderRootCache[_this.rootCacheId] = _this.root;
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
this.clearRootCache = function () {
|
56
|
+
if (_this.rootCacheId) {
|
57
|
+
delete renderRootCache[_this.rootCacheId];
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
44
61
|
this.unmount = function () {
|
45
62
|
var _this$root;
|
46
63
|
|
47
64
|
(_this$root = _this.root) == null ? void 0 : _this$root._unmount();
|
48
65
|
_this.root = undefined;
|
66
|
+
|
67
|
+
_this.clearRootCache();
|
49
68
|
};
|
50
69
|
|
51
70
|
this.app = app;
|
52
71
|
this.container = container;
|
53
72
|
this.context = context;
|
73
|
+
this.rootCacheId = rootCacheId;
|
74
|
+
this.root = root;
|
54
75
|
};
|
55
76
|
|
56
77
|
_exports.ReactDOMRender = ReactDOMRender;
|