@arco-design/mobile-react 2.21.2 → 2.21.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/ellipsis/components/js-ellipsis.js +7 -1
  5. package/cjs/image-picker/style/css/index.d.ts +1 -0
  6. package/cjs/image-picker/style/css/index.js +2 -0
  7. package/cjs/image-picker/style/index.d.ts +1 -0
  8. package/cjs/image-picker/style/index.js +2 -0
  9. package/cjs/tabs/index.d.ts +3 -463
  10. package/cjs/tabs/index.js +10 -0
  11. package/cjs/tabs/tab-cell-underline.d.ts +4 -0
  12. package/cjs/tabs/tab-cell-underline.js +234 -0
  13. package/cjs/tabs/tab-cell.d.ts +1 -85
  14. package/cjs/tabs/tab-cell.js +53 -198
  15. package/cjs/tabs/tab-pane.d.ts +2 -38
  16. package/cjs/tabs/type.d.ts +590 -0
  17. package/cjs/tabs/type.js +3 -0
  18. package/dist/index.js +272 -199
  19. package/dist/index.min.js +3 -3
  20. package/esm/ellipsis/components/js-ellipsis.js +7 -1
  21. package/esm/image-picker/style/css/index.d.ts +1 -0
  22. package/esm/image-picker/style/css/index.js +1 -0
  23. package/esm/image-picker/style/index.d.ts +1 -0
  24. package/esm/image-picker/style/index.js +1 -0
  25. package/esm/tabs/index.d.ts +3 -463
  26. package/esm/tabs/index.js +2 -1
  27. package/esm/tabs/tab-cell-underline.d.ts +4 -0
  28. package/esm/tabs/tab-cell-underline.js +218 -0
  29. package/esm/tabs/tab-cell.d.ts +1 -85
  30. package/esm/tabs/tab-cell.js +55 -201
  31. package/esm/tabs/tab-pane.d.ts +2 -38
  32. package/esm/tabs/type.d.ts +590 -0
  33. package/esm/tabs/type.js +1 -0
  34. package/package.json +3 -3
  35. package/umd/ellipsis/components/js-ellipsis.js +7 -1
  36. package/umd/image-picker/style/css/index.d.ts +1 -0
  37. package/umd/image-picker/style/css/index.js +4 -4
  38. package/umd/image-picker/style/index.d.ts +1 -0
  39. package/umd/image-picker/style/index.js +4 -4
  40. package/umd/tabs/index.d.ts +3 -463
  41. package/umd/tabs/index.js +11 -4
  42. package/umd/tabs/tab-cell-underline.d.ts +4 -0
  43. package/umd/tabs/tab-cell-underline.js +242 -0
  44. package/umd/tabs/tab-cell.d.ts +1 -85
  45. package/umd/tabs/tab-cell.js +56 -202
  46. package/umd/tabs/tab-pane.d.ts +2 -38
  47. package/umd/tabs/type.d.ts +590 -0
  48. package/umd/tabs/type.js +17 -0
@@ -0,0 +1,242 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../_helpers"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../_helpers"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global._extends, global.react, global.mobileUtils, global._helpers);
11
+ global.tabCellUnderline = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _helpers) {
14
+ "use strict";
15
+
16
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
+
18
+ _exports.__esModule = true;
19
+ _exports.default = void 0;
20
+ _extends2 = _interopRequireDefault(_extends2);
21
+ _react = _interopRequireWildcard(_react);
22
+
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+
25
+ 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; }
26
+
27
+ var TabCellUnderline = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
28
+ var prefix = props.prefix,
29
+ useCaterpillar = props.useCaterpillar,
30
+ distance = props.distance,
31
+ tabDirection = props.tabDirection,
32
+ underlineInnerStyle = props.underlineInnerStyle,
33
+ duration = props.duration,
34
+ cellTrans = props.cellTrans,
35
+ showLine = props.showLine,
36
+ activeIndex = props.activeIndex,
37
+ wrapWidth = props.wrapWidth,
38
+ wrapHeight = props.wrapHeight,
39
+ jumpingDis = props.jumpingDis,
40
+ translateZ = props.translateZ,
41
+ caterpillarMaxScale = props.caterpillarMaxScale,
42
+ caterpillarProperty = props.caterpillarProperty,
43
+ underlineSize = props.underlineSize,
44
+ underlineThick = props.underlineThick,
45
+ renderUnderline = props.renderUnderline,
46
+ getTabCenterLeft = props.getTabCenterLeft;
47
+
48
+ var _useState = (0, _react.useState)({}),
49
+ underlineStyle = _useState[0],
50
+ setUnderlineStyle = _useState[1];
51
+
52
+ var _useRefState = (0, _helpers.useRefState)(false),
53
+ caterpillar = _useRefState[0],
54
+ caterpillarRef = _useRefState[1],
55
+ setCaterpillar = _useRefState[2];
56
+
57
+ var _useState2 = (0, _react.useState)(0),
58
+ caterpillarDelay = _useState2[0],
59
+ setCaterpillarDelay = _useState2[1];
60
+
61
+ var lineRef = (0, _react.useRef)(null);
62
+ var timeRef = (0, _react.useRef)(0);
63
+ var system = (0, _helpers.useSystem)();
64
+ var isVertical = tabDirection === 'vertical';
65
+ var maxScaleWithDefault = caterpillarMaxScale || 2;
66
+ var translateZStr = translateZ ? ' translateZ(0)' : '';
67
+ (0, _react.useImperativeHandle)(ref, function () {
68
+ return {
69
+ setCaterpillarAnimate: setCaterpillarAnimate,
70
+ resetUnderlineStyle: resetUnderlineStyle
71
+ };
72
+ }, [setCaterpillarAnimate, resetUnderlineStyle]);
73
+ var animationKey = (0, _react.useMemo)(function () {
74
+ if (!useCaterpillar) {
75
+ return '';
76
+ }
77
+
78
+ if (caterpillarProperty === 'size') {
79
+ return "tabsCaterpillar" + (isVertical ? 'W' : 'H') + maxScaleWithDefault;
80
+ }
81
+
82
+ if (caterpillarMaxScale) {
83
+ return "tabsCaterpillar" + (isVertical ? 'X' : 'Y') + caterpillarMaxScale;
84
+ }
85
+
86
+ return '';
87
+ }, [useCaterpillar, isVertical, caterpillarMaxScale, caterpillarProperty]);
88
+ (0, _react.useEffect)(function () {
89
+ if (!animationKey) {
90
+ return;
91
+ }
92
+
93
+ var dir = isVertical ? 'X' : 'Y';
94
+
95
+ if (caterpillarProperty === 'size') {
96
+ var attr = isVertical ? 'width' : 'height';
97
+ (0, _mobileUtils.addCssKeyframes)(animationKey, "{\n 0% {\n " + attr + ": 100%;\n }\n 50% {\n " + attr + ": " + 100 * maxScaleWithDefault + "%;\n }\n 100% {\n " + attr + ": 100%;\n }\n }");
98
+ return;
99
+ }
100
+
101
+ (0, _mobileUtils.addCssKeyframes)(animationKey, "{\n 0% {\n transform: scale" + dir + "(1)" + translateZStr + ";\n -webkit-transform: scale" + dir + "(1)" + translateZStr + ";\n }\n 50% {\n transform: scale" + dir + "(" + caterpillarMaxScale + ")" + translateZStr + ";\n -webkit-transform: scale" + dir + "(" + caterpillarMaxScale + ")" + translateZStr + ";\n }\n 100% {\n transform: scale" + dir + "(1)" + translateZStr + ";\n -webkit-transform: scale" + dir + "(1)" + translateZStr + ";\n }\n }");
102
+ return function () {
103
+ (0, _mobileUtils.removeCssStyleDom)(animationKey);
104
+ };
105
+ }, [animationKey]);
106
+ (0, _react.useEffect)(function () {
107
+ if (jumpingDis && useCaterpillar && system !== 'ios') {
108
+ var movedRatio = wrapWidth ? jumpingDis / wrapWidth : 0;
109
+ setCaterpillarAnimate(movedRatio);
110
+ }
111
+ }, [jumpingDis]);
112
+ (0, _react.useEffect)(function () {
113
+ resetUnderlineStyle();
114
+ }, [useCaterpillar, caterpillar, cellTrans, duration, tabDirection, wrapWidth, wrapHeight, distance, animationKey, caterpillarDelay]);
115
+
116
+ function getLineLeft(index) {
117
+ var _lineRef$current, _lineRef$current2;
118
+
119
+ var offsetSize = isVertical ? (_lineRef$current = lineRef.current) == null ? void 0 : _lineRef$current.offsetWidth : (_lineRef$current2 = lineRef.current) == null ? void 0 : _lineRef$current2.offsetHeight;
120
+ var lineWidth = offsetSize || 0;
121
+ return getTabCenterLeft(index) - lineWidth / 2;
122
+ }
123
+
124
+ function getDescIndex() {
125
+ if (distance > 0) {
126
+ return activeIndex - 1;
127
+ }
128
+
129
+ if (distance < 0) {
130
+ return activeIndex + 1;
131
+ }
132
+
133
+ return activeIndex;
134
+ }
135
+
136
+ function getLineScale(ratio) {
137
+ var absRatio = Math.abs(ratio);
138
+ return absRatio > 0.5 ? (1 - absRatio) * 2 * (maxScaleWithDefault - 1) + 1 : absRatio * 2 * (maxScaleWithDefault - 1) + 1;
139
+ }
140
+
141
+ function getLineStyle() {
142
+ var _ref;
143
+
144
+ if (!lineRef.current) {
145
+ return {};
146
+ }
147
+
148
+ var currentLeft = getLineLeft(activeIndex);
149
+ var descIndex = getDescIndex();
150
+ var descLeft = getLineLeft(descIndex);
151
+ var moveRatio = wrapWidth ? distance / wrapWidth : 0;
152
+ var leftOffset = moveRatio * (currentLeft - descLeft);
153
+ var direc = isVertical ? 'X' : 'Y';
154
+ var transStyle = useCaterpillar && !jumpingDis ? caterpillarProperty === 'size' ? (_ref = {}, _ref[isVertical ? 'width' : 'height'] = 100 * getLineScale(moveRatio) + "%", _ref.willChange = 'width', _ref) : {
155
+ transform: "scale" + direc + "(" + getLineScale(moveRatio) + ")"
156
+ } : {};
157
+ var outerSize = isVertical ? {
158
+ width: underlineSize,
159
+ height: underlineThick
160
+ } : {
161
+ height: underlineSize,
162
+ width: underlineThick
163
+ };
164
+ return {
165
+ outer: (0, _extends2.default)({
166
+ transform: "translate" + direc + "(" + (distance > 0 ? currentLeft - leftOffset : currentLeft + leftOffset) + "px)" + translateZStr
167
+ }, outerSize),
168
+ inner: (0, _extends2.default)({}, transStyle)
169
+ };
170
+ }
171
+
172
+ function getUnderlineStyle() {
173
+ var transStyle = {};
174
+
175
+ if (useCaterpillar) {
176
+ transStyle.animationDuration = duration + "ms";
177
+ }
178
+
179
+ if (caterpillarRef.current && animationKey) {
180
+ transStyle.animationName = animationKey;
181
+ }
182
+
183
+ if (caterpillarDelay) {
184
+ transStyle.animationDelay = "-" + caterpillarDelay + "ms";
185
+ }
186
+
187
+ var lineStyle = getLineStyle();
188
+ return {
189
+ outer: (0, _helpers.getStyleWithVendor)((0, _extends2.default)({
190
+ transitionDuration: cellTrans ? duration + "ms" : '0ms'
191
+ }, lineStyle.outer || {})),
192
+ inner: (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, transStyle, lineStyle.inner || {}))
193
+ };
194
+ }
195
+
196
+ function resetUnderlineStyle() {
197
+ setUnderlineStyle(getUnderlineStyle());
198
+ }
199
+
200
+ function setCaterpillarAnimate(movedRatio) {
201
+ if (movedRatio === void 0) {
202
+ movedRatio = 0;
203
+ }
204
+
205
+ if (!duration) {
206
+ return;
207
+ }
208
+
209
+ var movedTime = (duration || 0) * Math.abs(movedRatio);
210
+ setCaterpillarDelay(movedTime);
211
+ (0, _mobileUtils.nextTick)(function () {
212
+ setCaterpillar(true);
213
+ });
214
+
215
+ if (timeRef.current) {
216
+ clearTimeout(timeRef.current);
217
+ }
218
+
219
+ timeRef.current = window.setTimeout(function () {
220
+ setCaterpillar(false);
221
+ setCaterpillarDelay(0);
222
+ }, (duration || 0) - movedTime + 20);
223
+ }
224
+
225
+ return renderUnderline ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderUnderline(underlineStyle, showLine, lineRef)) : /*#__PURE__*/_react.default.createElement("div", {
226
+ className: (0, _mobileUtils.cls)(prefix + "-underline", {
227
+ show: showLine
228
+ }),
229
+ ref: lineRef,
230
+ style: underlineStyle.outer
231
+ }, /*#__PURE__*/_react.default.createElement("div", {
232
+ className: (0, _mobileUtils.cls)(prefix + "-underline-inner", {
233
+ caterpillar: caterpillar,
234
+ 'custom-animate': animationKey,
235
+ 'caterpillar-moving': caterpillar || useCaterpillar && distance
236
+ }, tabDirection),
237
+ style: (0, _extends2.default)({}, underlineStyle.inner || {}, underlineInnerStyle || {})
238
+ }));
239
+ });
240
+ var _default = TabCellUnderline;
241
+ _exports.default = _default;
242
+ });
@@ -1,88 +1,4 @@
1
1
  import React from 'react';
2
- import { TabsProps } from '.';
3
- export interface TabCellProps extends Pick<TabsProps, 'tabs' | 'type' | 'onTabClick' | 'tabBarPosition' | 'tabBarArrange' | 'tabBarScroll' | 'tabBarFixed' | 'renderUnderline' | 'duration' | 'transitionDuration' | 'useCaterpillar' | 'tabBarExtra' | 'onTabBarOverflowChange' | 'tabBarGutter' | 'tabBarPadding' | 'underlineSize' | 'underlineThick' | 'underlineInnerStyle' | 'caterpillarMaxScale' | 'caterpillarProperty' | 'onTabBarScroll' | 'hideTabBarBeforeMounted' | 'tabBarScrollBezier' | 'tabBarScrollDuration' | 'tabBarScrollChance' | 'tabBarHasDivider' | 'tabBarStyle' | 'tabBarClass' | 'mode' | 'overflowThreshold' | 'showUnderline' | 'disabled' | 'renderTabBarItem' | 'renderTabBarInner' | 'translateZ'> {
4
- /**
5
- * 类前缀
6
- * @en prefix classname
7
- */
8
- prefixCls?: string;
9
- /**
10
- * 当前选中 Tab
11
- * @en Currently selected Tab
12
- */
13
- activeIndex: number;
14
- /**
15
- * 当前选中 Tab ref
16
- * @en Currently selected Tab ref
17
- */
18
- activeIndexRef: React.MutableRefObject<number>;
19
- /**
20
- * Tab 布局方向,横向 or 竖向
21
- * @en Tab layout direction, horizontal or vertical
22
- */
23
- tabDirection: 'horizontal' | 'vertical';
24
- /**
25
- * 修改选中 Tab
26
- * @en Modify selected Tab
27
- */
28
- changeIndex: (newIndex: number, from?: string) => void;
29
- /**
30
- * 外层容器宽度
31
- * @en Wrapper container width
32
- */
33
- wrapWidth: number;
34
- /**
35
- * 外层容器高度
36
- * @en Wrapper container height
37
- */
38
- wrapHeight: number;
39
- /**
40
- * TabBar是否启用过渡效果
41
- * @en Whether the TabBar enables transition effects
42
- */
43
- cellTrans: boolean;
44
- /**
45
- * 手指滑动距离
46
- * @en Finger sliding distance
47
- */
48
- distance: number;
49
- /**
50
- * 下划线已滑动的距离
51
- * @en The distance the underline has been swiped
52
- */
53
- jumpingDis: number;
54
- }
55
- export interface TabCellRef {
56
- /**
57
- * 外层元素 DOM
58
- * @en Outer element DOM
59
- */
60
- dom: HTMLDivElement | null;
61
- /**
62
- * 当前 TabBar 宽度是否已溢出
63
- * @en Whether the current TabBar width has overflowed
64
- */
65
- hasOverflow: boolean;
66
- /**
67
- * 滚动 bar 到指定位置,tabs 上下布局时是以 x 轴滚动,左右布局时以 y 轴滚动
68
- * @en Scroll the bar to the specified position, the tabs are scrolled on the x-axis when the tabs are laid out up and down, and the y-axis is scrolled when the tabs are laid out left and right
69
- */
70
- scrollTo: (position: number, rightNow?: boolean) => void;
71
- /**
72
- * 滚动 bar 使当前选中item到屏幕中间
73
- * @en Scroll the bar to bring the currently selected item to the middle of the screen
74
- */
75
- scrollToCenter: (rightNow?: boolean) => void;
76
- /**
77
- * 触发毛毛虫动画
78
- * @en Trigger caterpillar animation
79
- */
80
- setCaterpillarAnimate: (ratio?: number) => void;
81
- /**
82
- * 重新计算下划线样式
83
- * @en Recalculate underline style
84
- */
85
- resetUnderlineStyle: () => void;
86
- }
2
+ import { TabCellProps, TabCellRef } from './type';
87
3
  declare const TabCell: React.ForwardRefExoticComponent<TabCellProps & React.RefAttributes<TabCellRef>>;
88
4
  export default TabCell;
@@ -1,16 +1,16 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../_helpers"], factory);
3
+ define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../_helpers", "./tab-cell-underline"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../_helpers"));
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../_helpers"), require("./tab-cell-underline"));
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(mod.exports, global._extends, global.react, global.mobileUtils, global._helpers);
10
+ factory(mod.exports, global._extends, global.react, global.mobileUtils, global._helpers, global.tabCellUnderline);
11
11
  global.tabCell = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _helpers) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _helpers, _tabCellUnderline) {
14
14
  "use strict";
15
15
 
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -19,6 +19,7 @@
19
19
  _exports.default = void 0;
20
20
  _extends2 = _interopRequireDefault(_extends2);
21
21
  _react = _interopRequireWildcard(_react);
22
+ _tabCellUnderline = _interopRequireDefault(_tabCellUnderline);
22
23
 
23
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
25
 
@@ -72,43 +73,29 @@
72
73
  translateZ = props.translateZ;
73
74
  var prefix = prefixCls + "-tab-cell";
74
75
  var domRef = (0, _react.useRef)(null);
75
- var lineRef = (0, _react.useRef)(null);
76
- var timeRef = (0, _react.useRef)(0);
76
+ var underlineRef = (0, _react.useRef)(null);
77
77
  var allCellRectRef = (0, _react.useRef)([]);
78
78
 
79
- var _useState = (0, _react.useState)({}),
80
- underlineStyle = _useState[0],
81
- setUnderlineStyle = _useState[1];
79
+ var _useState = (0, _react.useState)(false),
80
+ showLine = _useState[0],
81
+ setShowLine = _useState[1];
82
82
 
83
- var _useRefState = (0, _helpers.useRefState)(false),
84
- caterpillar = _useRefState[0],
85
- caterpillarRef = _useRefState[1],
86
- setCaterpillar = _useRefState[2];
83
+ var _useState2 = (0, _react.useState)(false),
84
+ hasOverflow = _useState2[0],
85
+ setHasOverflow = _useState2[1];
87
86
 
88
- var _useState2 = (0, _react.useState)(0),
89
- caterpillarDelay = _useState2[0],
90
- setCaterpillarDelay = _useState2[1];
91
-
92
- var _useState3 = (0, _react.useState)(false),
93
- hasOverflow = _useState3[0],
94
- setHasOverflow = _useState3[1];
95
-
96
- var _useState4 = (0, _react.useState)(function () {
87
+ var _useState3 = (0, _react.useState)(function () {
97
88
  return tabs.length < overflowThreshold ? tabBarArrange : 'start';
98
89
  }),
99
- originArrange = _useState4[0],
100
- setOriginArrange = _useState4[1]; // 默认tab小于overflowThreshold个时不开启加载前隐藏,大于overflowThreshold个时开启
90
+ originArrange = _useState3[0],
91
+ setOriginArrange = _useState3[1]; // 默认tab小于overflowThreshold个时不开启加载前隐藏,大于overflowThreshold个时开启
101
92
 
102
93
 
103
- var _useState5 = (0, _react.useState)(function () {
94
+ var _useState4 = (0, _react.useState)(function () {
104
95
  return hideTabBarBeforeMounted === void 0 ? tabs.length < overflowThreshold || activeIndex === 0 : !hideTabBarBeforeMounted;
105
96
  }),
106
- showTab = _useState5[0],
107
- setShowTab = _useState5[1];
108
-
109
- var _useState6 = (0, _react.useState)(false),
110
- showLine = _useState6[0],
111
- setShowLine = _useState6[1];
97
+ showTab = _useState4[0],
98
+ setShowTab = _useState4[1];
112
99
 
113
100
  var isVertical = tabDirection === 'vertical';
114
101
  var isLine = (type || '').indexOf('line') !== -1;
@@ -122,42 +109,7 @@
122
109
  var cellGutter = isCard ? void 0 : tabBarGutter;
123
110
  var hasDivider = tabBarHasDivider === void 0 ? isLine : tabBarHasDivider;
124
111
  var wrapSize = isVertical ? wrapWidth : wrapHeight;
125
- var translateZStr = translateZ ? ' translateZ(0)' : '';
126
112
  var system = (0, _helpers.useSystem)();
127
- var maxScaleWithDefault = caterpillarMaxScale || 2;
128
- var animationKey = (0, _react.useMemo)(function () {
129
- if (!showUnderline || !useCaterpillar) {
130
- return '';
131
- }
132
-
133
- if (caterpillarProperty === 'size') {
134
- return "tabsCaterpillar" + (isVertical ? 'W' : 'H') + maxScaleWithDefault;
135
- }
136
-
137
- if (caterpillarMaxScale) {
138
- return "tabsCaterpillar" + (isVertical ? 'X' : 'Y') + caterpillarMaxScale;
139
- }
140
-
141
- return '';
142
- }, [showUnderline, useCaterpillar, isVertical, caterpillarMaxScale, caterpillarProperty]);
143
- (0, _react.useEffect)(function () {
144
- if (!animationKey) {
145
- return;
146
- }
147
-
148
- var dir = isVertical ? 'X' : 'Y';
149
-
150
- if (caterpillarProperty === 'size') {
151
- var attr = isVertical ? 'width' : 'height';
152
- (0, _mobileUtils.addCssKeyframes)(animationKey, "{\n 0% {\n " + attr + ": 100%;\n }\n 50% {\n " + attr + ": " + 100 * maxScaleWithDefault + "%;\n }\n 100% {\n " + attr + ": 100%;\n }\n }");
153
- return;
154
- }
155
-
156
- (0, _mobileUtils.addCssKeyframes)(animationKey, "{\n 0% {\n transform: scale" + dir + "(1)" + translateZStr + ";\n -webkit-transform: scale" + dir + "(1)" + translateZStr + ";\n }\n 50% {\n transform: scale" + dir + "(" + caterpillarMaxScale + ")" + translateZStr + ";\n -webkit-transform: scale" + dir + "(" + caterpillarMaxScale + ")" + translateZStr + ";\n }\n 100% {\n transform: scale" + dir + "(1)" + translateZStr + ";\n -webkit-transform: scale" + dir + "(1)" + translateZStr + ";\n }\n }");
157
- return function () {
158
- (0, _mobileUtils.removeCssStyleDom)(animationKey);
159
- };
160
- }, [animationKey]);
161
113
  (0, _react.useEffect)(function () {
162
114
  (0, _mobileUtils.nextTick)(function () {
163
115
  setCellOverflow(); // dom出来之后originArrange置空,交由tabBarArrange控制
@@ -170,12 +122,11 @@
170
122
  setShowLine(true);
171
123
  });
172
124
  }, [domRef.current, wrapSize, tabs]);
173
- (0, _react.useEffect)(function () {
174
- resetUnderlineStyle();
175
- }, [useCaterpillar, caterpillar, cellTrans, duration, tabDirection, wrapWidth, wrapHeight, distance, animationKey, caterpillarDelay]);
176
125
  (0, _react.useEffect)(function () {
177
126
  (0, _mobileUtils.nextTick)(function () {
178
- resetUnderlineStyle();
127
+ var _underlineRef$current;
128
+
129
+ (_underlineRef$current = underlineRef.current) == null ? void 0 : _underlineRef$current.resetUnderlineStyle();
179
130
  });
180
131
  }, [activeIndex, tabs, getCellPadding('left'), getCellPadding('right'), tabBarGutter, tabDirection]);
181
132
  (0, _react.useImperativeHandle)(ref, function () {
@@ -184,10 +135,18 @@
184
135
  scrollTo: scrollTo,
185
136
  scrollToCenter: scrollToCenter,
186
137
  hasOverflow: hasOverflow,
187
- setCaterpillarAnimate: setCaterpillarAnimate,
188
- resetUnderlineStyle: resetUnderlineStyle
138
+ setCaterpillarAnimate: function setCaterpillarAnimate(ratio) {
139
+ var _underlineRef$current2;
140
+
141
+ return (_underlineRef$current2 = underlineRef.current) == null ? void 0 : _underlineRef$current2.setCaterpillarAnimate(ratio);
142
+ },
143
+ resetUnderlineStyle: function resetUnderlineStyle() {
144
+ var _underlineRef$current3;
145
+
146
+ return (_underlineRef$current3 = underlineRef.current) == null ? void 0 : _underlineRef$current3.resetUnderlineStyle();
147
+ }
189
148
  };
190
- }, [scrollToCenter, scrollTo, hasOverflow, setCaterpillarAnimate, resetUnderlineStyle]);
149
+ }, [scrollToCenter, scrollTo, hasOverflow]);
191
150
  (0, _react.useEffect)(function () {
192
151
  if (wrapSize && tabBarScrollChance !== 'none') {
193
152
  setTimeout(function () {
@@ -215,16 +174,6 @@
215
174
  }
216
175
  };
217
176
  }, [hasOverflow]);
218
- (0, _react.useEffect)(function () {
219
- if (jumpingDis && useCaterpillar && system !== 'ios') {
220
- var movedRatio = wrapWidth ? jumpingDis / wrapWidth : 0;
221
- setCaterpillarAnimate(movedRatio);
222
- }
223
- }, [jumpingDis]);
224
-
225
- function resetUnderlineStyle() {
226
- setUnderlineStyle(getUnderlineStyle());
227
- }
228
177
 
229
178
  function setCellOverflow() {
230
179
  var overflow = false;
@@ -292,69 +241,6 @@
292
241
  }
293
242
  }
294
243
 
295
- function getUnderlineStyle() {
296
- var transStyle = {};
297
-
298
- if (useCaterpillar) {
299
- transStyle.animationDuration = duration + "ms";
300
- }
301
-
302
- if (caterpillarRef.current && animationKey) {
303
- transStyle.animationName = animationKey;
304
- }
305
-
306
- if (caterpillarDelay) {
307
- transStyle.animationDelay = "-" + caterpillarDelay + "ms";
308
- }
309
-
310
- var lineStyle = getLineStyle();
311
- return {
312
- outer: (0, _helpers.getStyleWithVendor)((0, _extends2.default)({
313
- transitionDuration: cellTrans ? duration + "ms" : '0ms'
314
- }, lineStyle.outer || {})),
315
- inner: (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, transStyle, lineStyle.inner || {}))
316
- };
317
- }
318
-
319
- function getLineStyle() {
320
- var _ref;
321
-
322
- if (!lineRef.current || !domRef.current) {
323
- return {};
324
- }
325
-
326
- var currentLeft = getLineLeft(activeIndex);
327
- var descIndex = getDescIndex();
328
- var descLeft = getLineLeft(descIndex);
329
- var moveRatio = wrapWidth ? distance / wrapWidth : 0;
330
- var leftOffset = moveRatio * (currentLeft - descLeft);
331
- var direc = isVertical ? 'X' : 'Y';
332
- var transStyle = useCaterpillar && !jumpingDis ? caterpillarProperty === 'size' ? (_ref = {}, _ref[isVertical ? 'width' : 'height'] = 100 * getLineScale(moveRatio) + "%", _ref.willChange = 'width', _ref) : {
333
- transform: "scale" + direc + "(" + getLineScale(moveRatio) + ")"
334
- } : {};
335
- var outerSize = isVertical ? {
336
- width: underlineSize,
337
- height: underlineThick
338
- } : {
339
- height: underlineSize,
340
- width: underlineThick
341
- };
342
- return {
343
- outer: (0, _extends2.default)({
344
- transform: "translate" + direc + "(" + (distance > 0 ? currentLeft - leftOffset : currentLeft + leftOffset) + "px)" + translateZStr
345
- }, outerSize),
346
- inner: (0, _extends2.default)({}, transStyle)
347
- };
348
- }
349
-
350
- function getLineLeft(index) {
351
- var _lineRef$current, _lineRef$current2;
352
-
353
- var offsetSize = isVertical ? (_lineRef$current = lineRef.current) == null ? void 0 : _lineRef$current.offsetWidth : (_lineRef$current2 = lineRef.current) == null ? void 0 : _lineRef$current2.offsetHeight;
354
- var lineWidth = offsetSize || 0;
355
- return getTabCenterLeft(index) - lineWidth / 2;
356
- }
357
-
358
244
  function getTabCenterLeft(index) {
359
245
  var currentTab = allCellRectRef.current[index] || {};
360
246
  var currentTabWidth = (isVertical ? currentTab.width : currentTab.height) || 0;
@@ -362,48 +248,6 @@
362
248
  return currentTabLeft + currentTabWidth / 2;
363
249
  }
364
250
 
365
- function getLineScale(ratio) {
366
- var absRatio = Math.abs(ratio);
367
- return absRatio > 0.5 ? (1 - absRatio) * 2 * (maxScaleWithDefault - 1) + 1 : absRatio * 2 * (maxScaleWithDefault - 1) + 1;
368
- }
369
-
370
- function getDescIndex() {
371
- if (distance > 0) {
372
- return activeIndex - 1;
373
- }
374
-
375
- if (distance < 0) {
376
- return activeIndex + 1;
377
- }
378
-
379
- return activeIndex;
380
- }
381
-
382
- function setCaterpillarAnimate(movedRatio) {
383
- if (movedRatio === void 0) {
384
- movedRatio = 0;
385
- }
386
-
387
- if (!duration) {
388
- return;
389
- }
390
-
391
- var movedTime = (duration || 0) * Math.abs(movedRatio);
392
- setCaterpillarDelay(movedTime);
393
- (0, _mobileUtils.nextTick)(function () {
394
- setCaterpillar(true);
395
- });
396
-
397
- if (timeRef.current) {
398
- clearTimeout(timeRef.current);
399
- }
400
-
401
- timeRef.current = window.setTimeout(function () {
402
- setCaterpillar(false);
403
- setCaterpillarDelay(0);
404
- }, (duration || 0) - movedTime + 20);
405
- }
406
-
407
251
  function getCellPadding(pType) {
408
252
  if (typeof cellPadding === 'object') {
409
253
  return cellPadding[pType];
@@ -444,20 +288,30 @@
444
288
  return null;
445
289
  }
446
290
 
447
- return renderUnderline ? renderUnderline(underlineStyle, showLine, lineRef) : /*#__PURE__*/_react.default.createElement("div", {
448
- className: (0, _mobileUtils.cls)(prefix + "-underline", {
449
- show: showLine
450
- }),
451
- ref: lineRef,
452
- style: underlineStyle.outer
453
- }, /*#__PURE__*/_react.default.createElement("div", {
454
- className: (0, _mobileUtils.cls)(prefix + "-underline-inner", {
455
- caterpillar: caterpillar,
456
- 'custom-animate': animationKey,
457
- 'caterpillar-moving': caterpillar || useCaterpillar && distance
458
- }, tabDirection),
459
- style: (0, _extends2.default)({}, underlineStyle.inner || {}, underlineInnerStyle || {})
460
- }));
291
+ var lineProps = {
292
+ prefix: prefix,
293
+ showLine: showLine,
294
+ useCaterpillar: useCaterpillar,
295
+ distance: distance,
296
+ tabDirection: tabDirection,
297
+ underlineInnerStyle: underlineInnerStyle,
298
+ cellTrans: cellTrans,
299
+ duration: duration,
300
+ activeIndex: activeIndex,
301
+ wrapWidth: wrapWidth,
302
+ wrapHeight: wrapHeight,
303
+ jumpingDis: jumpingDis,
304
+ caterpillarMaxScale: caterpillarMaxScale,
305
+ caterpillarProperty: caterpillarProperty,
306
+ translateZ: translateZ,
307
+ underlineSize: underlineSize,
308
+ underlineThick: underlineThick,
309
+ renderUnderline: renderUnderline
310
+ };
311
+ return /*#__PURE__*/_react.default.createElement(_tabCellUnderline.default, (0, _extends2.default)({
312
+ ref: underlineRef,
313
+ getTabCenterLeft: getTabCenterLeft
314
+ }, lineProps));
461
315
  }
462
316
 
463
317
  var cellInner = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabs.map(function (tab, index) {