@arco-design/mobile-react 2.30.9 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.en-US.md +70 -2
  3. package/README.md +69 -2
  4. package/cjs/carousel/index.js +3 -0
  5. package/cjs/picker/index.js +3 -2
  6. package/cjs/picker/type.d.ts +1 -1
  7. package/cjs/picker-view/components/cascader.d.ts +1 -0
  8. package/cjs/picker-view/components/cascader.js +8 -1
  9. package/cjs/picker-view/components/picker-cell.d.ts +1 -0
  10. package/cjs/picker-view/components/picker-cell.js +6 -1
  11. package/cjs/picker-view/index.d.ts +6 -1
  12. package/cjs/picker-view/index.js +25 -13
  13. package/cjs/tabs/tab-cell.js +54 -29
  14. package/cjs/tabs/type.d.ts +5 -0
  15. package/dist/index.js +102 -48
  16. package/dist/index.min.js +1 -1
  17. package/esm/carousel/index.js +3 -0
  18. package/esm/picker/index.js +3 -2
  19. package/esm/picker/type.d.ts +1 -1
  20. package/esm/picker-view/components/cascader.d.ts +1 -0
  21. package/esm/picker-view/components/cascader.js +8 -1
  22. package/esm/picker-view/components/picker-cell.d.ts +1 -0
  23. package/esm/picker-view/components/picker-cell.js +6 -1
  24. package/esm/picker-view/index.d.ts +6 -1
  25. package/esm/picker-view/index.js +26 -13
  26. package/esm/tabs/tab-cell.js +55 -29
  27. package/esm/tabs/type.d.ts +5 -0
  28. package/package.json +3 -3
  29. package/umd/carousel/index.js +3 -0
  30. package/umd/picker/index.js +3 -2
  31. package/umd/picker/type.d.ts +1 -1
  32. package/umd/picker-view/components/cascader.d.ts +1 -0
  33. package/umd/picker-view/components/cascader.js +8 -1
  34. package/umd/picker-view/components/picker-cell.d.ts +1 -0
  35. package/umd/picker-view/components/picker-cell.js +6 -1
  36. package/umd/picker-view/index.d.ts +6 -1
  37. package/umd/picker-view/index.js +25 -13
  38. package/umd/tabs/tab-cell.js +54 -29
  39. package/umd/tabs/type.d.ts +5 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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.30.10](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.9...@arco-design/mobile-react@2.30.10) (2024-03-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `Carousel` reset transforms when loop status changes ([#243](https://github.com/arco-design/arco-design-mobile/issues/243)) ([3983669](https://github.com/arco-design/arco-design-mobile/commit/398366920556ea4eb91ee87035f62443ad8db1d1))
12
+ * `Picker` onOk method adds new parameters ([#237](https://github.com/arco-design/arco-design-mobile/issues/237)) ([ef2e800](https://github.com/arco-design/arco-design-mobile/commit/ef2e8001c390174a12ca8b815e96c71436420e94))
13
+ * `Tabs` tab-cell support "updateLayout" method ([#234](https://github.com/arco-design/arco-design-mobile/issues/234)) ([1f17383](https://github.com/arco-design/arco-design-mobile/commit/1f17383592be7917a3f8392025ada60c788738f4))
14
+
15
+
16
+
17
+
18
+
6
19
  ## [2.30.9](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.8...@arco-design/mobile-react@2.30.9) (2024-02-27)
7
20
 
8
21
 
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.30.8/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
@@ -134,6 +134,74 @@ import { Button as ArcoButton } from '@arco-design/mobile-react';
134
134
  import { IconAsk, IconBack } from '@arco-design/mobile-react/esm/icon';
135
135
  ```
136
136
 
137
+
138
+ ## Partial import(Vite)
139
+
140
+ It is recommended to use `vite-plugin-importer` to import(**<a href="https://www.npmjs.com/package/vite-plugin-importer" target="_blank">Click here</a>** to know more from this plugin):
141
+
142
+ ```
143
+ npm install vite-plugin-importer -D
144
+ ```
145
+
146
+ ### Import components on demand
147
+
148
+ **vite.config.ts** :
149
+
150
+ ```js
151
+ import usePluginImport from 'vite-plugin-importer'
152
+
153
+ export default defineConfig({
154
+ plugins: [
155
+ usePluginImport({
156
+ libraryName: "@arco-design/mobile-react",
157
+ libraryDirectory: "esm",
158
+ style: (path) => `${path}/style`,
159
+ })
160
+ ]
161
+ })
162
+ ```
163
+
164
+ ### Import icons on demand
165
+
166
+ **vite.config.ts** :
167
+
168
+ ```js
169
+ import usePluginImport from 'vite-plugin-importer'
170
+
171
+ export default defineConfig({
172
+ plugins: [
173
+ usePluginImport({
174
+ libraryName: "@arco-design/mobile-react/esm/icon",
175
+ libraryDirectory: "",
176
+ camel2DashComponentName: false,
177
+ })
178
+ ]
179
+ })
180
+ ```
181
+
182
+ If both component and Icon need to be imported on demand, you just declare all and do not need any change.
183
+
184
+ **vite.config.ts** :
185
+
186
+ ```js
187
+ import usePluginImport from 'vite-plugin-importer'
188
+
189
+ export default defineConfig({
190
+ plugins: [
191
+ usePluginImport({
192
+ libraryName: "@arco-design/mobile-react",
193
+ libraryDirectory: "esm",
194
+ style: (path) => `${path}/style`,
195
+ }),
196
+ usePluginImport({
197
+ libraryName: "@arco-design/mobile-react/esm/icon",
198
+ libraryDirectory: "",
199
+ camel2DashComponentName: false,
200
+ })
201
+ ]
202
+ })
203
+ ```
204
+
137
205
  ## Partial import (manual)
138
206
 
139
207
  If you don't use babel-plugin-import, you need to import js and css files manually. The following example has the same effect as the import statement above:
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.30.8/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.30.9/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -134,6 +134,73 @@ import { Button as ArcoButton } from '@arco-design/mobile-react';
134
134
  import { IconAsk, IconBack } from '@arco-design/mobile-react/esm/icon';
135
135
  ```
136
136
 
137
+ ## 部分引入(Vite)
138
+
139
+ 如果是 Vite 构建工具的话,则推荐使用 `vite-plugin-importer` 引入(该插件具体使用 **<a href="https://www.npmjs.com/package/vite-plugin-importer" target="_blank">戳这里</a>** ):
140
+
141
+ ```
142
+ npm install vite-plugin-importer -D
143
+ ```
144
+
145
+ ### 组件按需引入
146
+
147
+ **vite.config.ts** 中配置:
148
+
149
+ ```js
150
+ import usePluginImport from 'vite-plugin-importer'
151
+
152
+ export default defineConfig({
153
+ plugins: [
154
+ usePluginImport({
155
+ libraryName: "@arco-design/mobile-react",
156
+ libraryDirectory: "esm",
157
+ style: (path) => `${path}/style`,
158
+ })
159
+ ]
160
+ })
161
+ ```
162
+
163
+ ### Icon 按需引入
164
+
165
+ **vite.config.ts** 中配置:
166
+
167
+ ```js
168
+ import usePluginImport from 'vite-plugin-importer'
169
+
170
+ export default defineConfig({
171
+ plugins: [
172
+ usePluginImport({
173
+ libraryName: "@arco-design/mobile-react/esm/icon",
174
+ libraryDirectory: "",
175
+ camel2DashComponentName: false,
176
+ })
177
+ ]
178
+ })
179
+ ```
180
+
181
+ 如果同时存在 组件 和 Icon 的按需引入方式,不需要做改动,可以同时声明
182
+
183
+ **vite.config.ts** 中配置:
184
+
185
+ ```js
186
+ import usePluginImport from 'vite-plugin-importer'
187
+
188
+ export default defineConfig({
189
+ plugins: [
190
+ usePluginImport({
191
+ libraryName: "@arco-design/mobile-react",
192
+ libraryDirectory: "esm",
193
+ style: (path) => `${path}/style`,
194
+ }),
195
+ usePluginImport({
196
+ libraryName: "@arco-design/mobile-react/esm/icon",
197
+ libraryDirectory: "",
198
+ camel2DashComponentName: false,
199
+ })
200
+ ]
201
+ })
202
+ ```
203
+
137
204
  ## 部分引入(手动)
138
205
 
139
206
  如果不使用babel-plugin-import,则需要手动引入js和css文件。下方例子效果等同于上方引入语句:
@@ -655,6 +655,9 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
655
655
 
656
656
  function getFakeChild() {
657
657
  if (noLoop) {
658
+ // 循环状态从有到无时,重置 transforms
659
+ // @en reset transforms when loop status changes to false
660
+ setTransforms([]);
658
661
  return;
659
662
  }
660
663
 
@@ -129,12 +129,13 @@ var Picker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
129
129
 
130
130
  (_pickerViewRef$curren6 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren6.scrollToCurrentIndex();
131
131
  (0, _mobileUtils.nextTick)(function () {
132
- var _pickerViewRef$curren7;
132
+ var _pickerViewRef$curren7, _pickerViewRef$curren8;
133
133
 
134
134
  var val = ((_pickerViewRef$curren7 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren7.getAllColumnValues()) || scrollValueRef.current || [];
135
+ var selectedData = ((_pickerViewRef$curren8 = pickerViewRef.current) == null ? void 0 : _pickerViewRef$curren8.getAllColumnData()) || [];
135
136
 
136
137
  if (onOk) {
137
- onOk(val);
138
+ onOk(val, selectedData);
138
139
  }
139
140
 
140
141
  if (onChange) {
@@ -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;
@@ -37,7 +37,8 @@ var Cascader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
37
37
  return {
38
38
  getCellMovingStatus: getCellMovingStatus,
39
39
  scrollToCurrentIndex: scrollToCurrentIndex,
40
- getAllCellsValue: getAllCellsValue
40
+ getAllCellsValue: getAllCellsValue,
41
+ getAllCellsData: getAllCellsData
41
42
  };
42
43
  });
43
44
 
@@ -59,6 +60,12 @@ var Cascader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
59
60
  });
60
61
  }
61
62
 
63
+ function getAllCellsData() {
64
+ return pickerCellsRef.current.map(function (cell) {
65
+ return cell.getCurrentCellData();
66
+ });
67
+ }
68
+
62
69
  function _onValueChange(value, index, newData) {
63
70
  var children = (0, _mobileUtils.arrayTreeFilter)(data, function (item, level) {
64
71
  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;
@@ -304,6 +304,10 @@ var PickerCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
304
304
  return (_data$currentIndex = data[currentIndex]) == null ? void 0 : _data$currentIndex.value;
305
305
  }
306
306
 
307
+ function getCurrentCellData() {
308
+ return data[currentIndex];
309
+ }
310
+
307
311
  function _clearTimer() {
308
312
  timeRef.current && clearTimeout(timeRef.current);
309
313
  timeRef.current = null;
@@ -369,7 +373,8 @@ var PickerCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
369
373
  return {
370
374
  movingStatus: movingStatusRef.current,
371
375
  scrollToCurrentIndex: scrollToCurrentIndex,
372
- getCurrentCellValue: getCurrentCellValue
376
+ getCurrentCellValue: getCurrentCellValue,
377
+ getCurrentCellData: getCurrentCellData
373
378
  };
374
379
  });
375
380
  return !hideEmptyCols || data && data.length ? /*#__PURE__*/_react.default.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;
@@ -45,6 +45,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
45
45
 
46
46
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
47
 
48
+ var isArray = function isArray(dt) {
49
+ return dt ? Array.isArray(dt[0]) : false;
50
+ };
51
+
52
+ var isStrOrNum = function isStrOrNum(dt) {
53
+ return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
54
+ };
55
+
48
56
  var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
49
57
  var _props$className = props.className,
50
58
  className = _props$className === void 0 ? '' : _props$className,
@@ -94,14 +102,6 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
94
102
  var innerData = (0, _react.useMemo)(function () {
95
103
  var newData;
96
104
 
97
- var isArray = function isArray(dt) {
98
- return dt ? Array.isArray(dt[0]) : false;
99
- };
100
-
101
- var isStrOrNum = function isStrOrNum(dt) {
102
- return typeof dt[0][0] === 'string' || typeof dt[0][0] === 'number';
103
- };
104
-
105
105
  if (isArray(data)) {
106
106
  if (isStrOrNum(data)) {
107
107
  newData = data.map(function (item) {
@@ -135,6 +135,17 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
135
135
  });
136
136
  };
137
137
 
138
+ var getAllColumnData = function getAllColumnData() {
139
+ var _cascaderRef$current2;
140
+
141
+ var curValues = cascade ? ((_cascaderRef$current2 = cascaderRef.current) == null ? void 0 : _cascaderRef$current2.getAllCellsData()) || [] : pickerCellsRef.current.map(function (cell) {
142
+ return cell.getCurrentCellData();
143
+ });
144
+ return curValues.filter(function (v) {
145
+ return v !== undefined;
146
+ });
147
+ };
148
+
138
149
  function getColumnValue(index) {
139
150
  if (index === void 0) {
140
151
  index = 0;
@@ -144,18 +155,18 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
144
155
  }
145
156
 
146
157
  function getCellMovingStatus() {
147
- var _cascaderRef$current2;
158
+ var _cascaderRef$current3;
148
159
 
149
- return cascade ? ((_cascaderRef$current2 = cascaderRef.current) == null ? void 0 : _cascaderRef$current2.getCellMovingStatus()) || [] : pickerCellsRef.current.map(function (cell) {
160
+ return cascade ? ((_cascaderRef$current3 = cascaderRef.current) == null ? void 0 : _cascaderRef$current3.getCellMovingStatus()) || [] : pickerCellsRef.current.map(function (cell) {
150
161
  return cell.movingStatus;
151
162
  });
152
163
  }
153
164
 
154
165
  function scrollToCurrentIndex() {
155
166
  if (cascade) {
156
- var _cascaderRef$current3;
167
+ var _cascaderRef$current4;
157
168
 
158
- (_cascaderRef$current3 = cascaderRef.current) == null ? void 0 : _cascaderRef$current3.scrollToCurrentIndex();
169
+ (_cascaderRef$current4 = cascaderRef.current) == null ? void 0 : _cascaderRef$current4.scrollToCurrentIndex();
159
170
  return;
160
171
  }
161
172
 
@@ -172,7 +183,8 @@ var PickerView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
172
183
  getColumnValue: getColumnValue,
173
184
  updateLayout: updateLayout,
174
185
  resetValue: resetValue,
175
- scrollToCurrentIndex: scrollToCurrentIndex
186
+ scrollToCurrentIndex: scrollToCurrentIndex,
187
+ getAllColumnData: getAllColumnData
176
188
  };
177
189
  });
178
190
 
@@ -90,14 +90,18 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
90
90
  return tabs.length < overflowThreshold ? tabBarArrange : 'start';
91
91
  }),
92
92
  originArrange = _useState3[0],
93
- setOriginArrange = _useState3[1]; // 默认tab小于overflowThreshold个时不开启加载前隐藏,大于overflowThreshold个时开启
93
+ setOriginArrange = _useState3[1];
94
94
 
95
+ var _useState4 = (0, _react.useState)(false),
96
+ forceUpdate = _useState4[0],
97
+ setForceUpdate = _useState4[1]; // 默认tab小于overflowThreshold个时不开启加载前隐藏,大于overflowThreshold个时开启
95
98
 
96
- var _useState4 = (0, _react.useState)(function () {
99
+
100
+ var _useState5 = (0, _react.useState)(function () {
97
101
  return hideTabBarBeforeMounted === void 0 ? tabs.length < overflowThreshold || activeIndex === 0 : !hideTabBarBeforeMounted;
98
102
  }),
99
- showTab = _useState4[0],
100
- setShowTab = _useState4[1];
103
+ showTab = _useState5[0],
104
+ setShowTab = _useState5[1];
101
105
 
102
106
  var isVertical = tabDirection === 'vertical';
103
107
  var isLine = (type || '').indexOf('line') !== -1;
@@ -112,6 +116,15 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
112
116
  var hasDivider = tabBarHasDivider === void 0 ? isLine : tabBarHasDivider;
113
117
  var wrapSize = isVertical ? wrapWidth : wrapHeight;
114
118
  var system = (0, _helpers.useSystem)();
119
+
120
+ var updateScrollPosition = function updateScrollPosition() {
121
+ if (wrapSize && tabBarScrollChance !== 'none') {
122
+ setTimeout(function () {
123
+ scrollToCenter();
124
+ }, tabBarScrollChance === 'after-jump' ? Math.max(transitionDuration || 0, duration || 0) : 0);
125
+ }
126
+ };
127
+
115
128
  (0, _react.useEffect)(function () {
116
129
  (0, _mobileUtils.nextTick)(function () {
117
130
  setCellOverflow(); // dom出来之后originArrange置空,交由tabBarArrange控制
@@ -131,31 +144,16 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
131
144
  (_underlineRef$current = underlineRef.current) == null ? void 0 : _underlineRef$current.resetUnderlineStyle();
132
145
  });
133
146
  }, [activeIndex, tabs, getCellPadding('left'), getCellPadding('right'), tabBarGutter, tabDirection]);
134
- (0, _react.useImperativeHandle)(ref, function () {
135
- return {
136
- dom: domRef.current,
137
- scrollTo: scrollTo,
138
- scrollToCenter: scrollToCenter,
139
- hasOverflow: hasOverflow,
140
- setCaterpillarAnimate: function setCaterpillarAnimate(ratio) {
141
- var _underlineRef$current2;
142
-
143
- return (_underlineRef$current2 = underlineRef.current) == null ? void 0 : _underlineRef$current2.setCaterpillarAnimate(ratio);
144
- },
145
- resetUnderlineStyle: function resetUnderlineStyle() {
146
- var _underlineRef$current3;
147
-
148
- return (_underlineRef$current3 = underlineRef.current) == null ? void 0 : _underlineRef$current3.resetUnderlineStyle();
149
- }
150
- };
151
- }, [scrollToCenter, scrollTo, hasOverflow]);
152
147
  (0, _react.useEffect)(function () {
153
- if (wrapSize && tabBarScrollChance !== 'none') {
154
- setTimeout(function () {
155
- scrollToCenter();
156
- }, tabBarScrollChance === 'after-jump' ? Math.max(transitionDuration || 0, duration || 0) : 0);
157
- }
148
+ updateScrollPosition();
158
149
  }, [activeIndex, wrapSize]);
150
+ (0, _react.useEffect)(function () {
151
+ var _underlineRef$current2;
152
+
153
+ setCellOverflow();
154
+ (_underlineRef$current2 = underlineRef.current) == null ? void 0 : _underlineRef$current2.resetUnderlineStyle();
155
+ updateScrollPosition();
156
+ }, [forceUpdate]);
159
157
  (0, _react.useEffect)(function () {
160
158
  tabBarScrollChance !== 'none' && scrollToCenter(true); // TabCell左右可滚动时,防止触发父级touchmove事件导致滚不动
161
159
  // @en When the TabCell can be scrolled left and right, prevent the parent touchmove event from being triggered which result in inability to scroll
@@ -296,7 +294,7 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
296
294
  return typeof tab === 'string' ? tab : tab.title;
297
295
  }
298
296
 
299
- function renderTabUnderline() {
297
+ var renderTabUnderline = function renderTabUnderline() {
300
298
  if (!showUnderline || !isLine) {
301
299
  return null;
302
300
  }
@@ -327,7 +325,7 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
327
325
  getTabCenterLeft: getTabCenterLeft,
328
326
  getTabRect: getTabRect
329
327
  }, lineProps));
330
- }
328
+ };
331
329
 
332
330
  var cellInner = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabs.map(function (tab, index) {
333
331
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -370,6 +368,33 @@ var TabCell = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
370
368
  }
371
369
  }) : null);
372
370
 
371
+ var _updateLayout = function updateLayout() {
372
+ setForceUpdate(function (val) {
373
+ return !val;
374
+ });
375
+ };
376
+
377
+ (0, _react.useImperativeHandle)(ref, function () {
378
+ return {
379
+ dom: domRef.current,
380
+ scrollTo: scrollTo,
381
+ scrollToCenter: scrollToCenter,
382
+ hasOverflow: hasOverflow,
383
+ setCaterpillarAnimate: function setCaterpillarAnimate(ratio) {
384
+ var _underlineRef$current3;
385
+
386
+ return (_underlineRef$current3 = underlineRef.current) == null ? void 0 : _underlineRef$current3.setCaterpillarAnimate(ratio);
387
+ },
388
+ resetUnderlineStyle: function resetUnderlineStyle() {
389
+ var _underlineRef$current4;
390
+
391
+ return (_underlineRef$current4 = underlineRef.current) == null ? void 0 : _underlineRef$current4.resetUnderlineStyle();
392
+ },
393
+ updateLayout: function updateLayout() {
394
+ return _updateLayout();
395
+ }
396
+ };
397
+ }, [scrollToCenter, scrollTo, hasOverflow]);
373
398
  return /*#__PURE__*/_react.default.createElement("div", {
374
399
  className: (0, _mobileUtils.cls)(prefix + "-container-wrap", tabDirection, "type-" + type, tabBarClass, system),
375
400
  style: tabBarStyle
@@ -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;