@douyinfe/semi-ui 2.58.0-beta.0 → 2.58.1

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 (73) hide show
  1. package/dist/css/semi.css +108 -29
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +105 -31
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/_base/base.css +2 -2
  8. package/lib/cjs/button/Button.d.ts +1 -1
  9. package/lib/cjs/button/Button.js +1 -0
  10. package/lib/cjs/locale/interface.d.ts +3 -0
  11. package/lib/cjs/locale/source/ar.js +3 -0
  12. package/lib/cjs/locale/source/de.js +3 -0
  13. package/lib/cjs/locale/source/en_GB.js +3 -0
  14. package/lib/cjs/locale/source/en_US.js +3 -0
  15. package/lib/cjs/locale/source/es.js +3 -0
  16. package/lib/cjs/locale/source/fr.js +3 -0
  17. package/lib/cjs/locale/source/id_ID.js +3 -0
  18. package/lib/cjs/locale/source/it.js +3 -0
  19. package/lib/cjs/locale/source/ja_JP.js +3 -0
  20. package/lib/cjs/locale/source/ko_KR.js +3 -0
  21. package/lib/cjs/locale/source/ms_MY.js +3 -0
  22. package/lib/cjs/locale/source/nl_NL.js +3 -0
  23. package/lib/cjs/locale/source/pl_PL.js +3 -0
  24. package/lib/cjs/locale/source/pt_BR.js +3 -0
  25. package/lib/cjs/locale/source/ro.js +3 -0
  26. package/lib/cjs/locale/source/ru_RU.js +3 -0
  27. package/lib/cjs/locale/source/sv_SE.js +3 -0
  28. package/lib/cjs/locale/source/th_TH.js +3 -0
  29. package/lib/cjs/locale/source/tr_TR.js +3 -0
  30. package/lib/cjs/locale/source/vi_VN.js +3 -0
  31. package/lib/cjs/locale/source/zh_CN.js +3 -0
  32. package/lib/cjs/locale/source/zh_TW.js +3 -0
  33. package/lib/cjs/slider/index.js +13 -8
  34. package/lib/cjs/tabs/TabBar.d.ts +7 -0
  35. package/lib/cjs/tabs/TabBar.js +78 -18
  36. package/lib/cjs/tabs/TabItem.js +3 -1
  37. package/lib/cjs/tabs/index.d.ts +1 -0
  38. package/lib/cjs/tabs/index.js +7 -4
  39. package/lib/cjs/tabs/interface.d.ts +7 -0
  40. package/lib/es/_base/base.css +2 -2
  41. package/lib/es/button/Button.d.ts +1 -1
  42. package/lib/es/button/Button.js +1 -0
  43. package/lib/es/locale/interface.d.ts +3 -0
  44. package/lib/es/locale/source/ar.js +3 -0
  45. package/lib/es/locale/source/de.js +3 -0
  46. package/lib/es/locale/source/en_GB.js +3 -0
  47. package/lib/es/locale/source/en_US.js +3 -0
  48. package/lib/es/locale/source/es.js +3 -0
  49. package/lib/es/locale/source/fr.js +3 -0
  50. package/lib/es/locale/source/id_ID.js +3 -0
  51. package/lib/es/locale/source/it.js +3 -0
  52. package/lib/es/locale/source/ja_JP.js +3 -0
  53. package/lib/es/locale/source/ko_KR.js +3 -0
  54. package/lib/es/locale/source/ms_MY.js +3 -0
  55. package/lib/es/locale/source/nl_NL.js +3 -0
  56. package/lib/es/locale/source/pl_PL.js +3 -0
  57. package/lib/es/locale/source/pt_BR.js +3 -0
  58. package/lib/es/locale/source/ro.js +3 -0
  59. package/lib/es/locale/source/ru_RU.js +3 -0
  60. package/lib/es/locale/source/sv_SE.js +3 -0
  61. package/lib/es/locale/source/th_TH.js +3 -0
  62. package/lib/es/locale/source/tr_TR.js +3 -0
  63. package/lib/es/locale/source/vi_VN.js +3 -0
  64. package/lib/es/locale/source/zh_CN.js +3 -0
  65. package/lib/es/locale/source/zh_TW.js +3 -0
  66. package/lib/es/slider/index.js +13 -8
  67. package/lib/es/tabs/TabBar.d.ts +7 -0
  68. package/lib/es/tabs/TabBar.js +79 -19
  69. package/lib/es/tabs/TabItem.js +3 -1
  70. package/lib/es/tabs/index.d.ts +1 -0
  71. package/lib/es/tabs/index.js +7 -4
  72. package/lib/es/tabs/interface.d.ts +7 -0
  73. package/package.json +8 -8
@@ -51,6 +51,7 @@ export default class Button extends PureComponent {
51
51
  [`${prefixCls}-block`]: block,
52
52
  [`${prefixCls}-circle`]: circle,
53
53
  [`${prefixCls}-borderless`]: theme === 'borderless',
54
+ [`${prefixCls}-outline`]: theme === "outline",
54
55
  [`${prefixCls}-${type}-disabled`]: disabled && type
55
56
  }, className),
56
57
  type: htmlType,
@@ -12,6 +12,9 @@ export interface Locale {
12
12
  confirm: string;
13
13
  cancel: string;
14
14
  };
15
+ Tabs: {
16
+ more: string;
17
+ };
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: string;
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'تؤكد',
13
13
  cancel: 'إلغاء'
14
14
  },
15
+ Tabs: {
16
+ more: "أكثر"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'حدد الوقت',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Bestätigen',
13
13
  cancel: 'Abbrechen'
14
14
  },
15
+ Tabs: {
16
+ more: "Mehr"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Zeit auswählen',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Confirm',
13
13
  cancel: 'Cancel'
14
14
  },
15
+ Tabs: {
16
+ more: "More"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Select time',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Confirm',
13
13
  cancel: 'Cancel'
14
14
  },
15
+ Tabs: {
16
+ more: "More"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Select time',
@@ -16,6 +16,9 @@ const locale = {
16
16
  confirm: 'Aceptar',
17
17
  cancel: 'Cancelar'
18
18
  },
19
+ Tabs: {
20
+ more: "Más"
21
+ },
19
22
  TimePicker: {
20
23
  placeholder: {
21
24
  time: 'Seleccionar hora',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Confirmer',
13
13
  cancel: 'Annuler'
14
14
  },
15
+ Tabs: {
16
+ more: "Plus"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Sélectionner temps',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Konfirmasi',
13
13
  cancel: 'Batalkan'
14
14
  },
15
+ Tabs: {
16
+ more: "Lagi"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Pilih waktu',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Conferma',
13
13
  cancel: 'Cancella'
14
14
  },
15
+ Tabs: {
16
+ more: "Di più"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Seleziona ora',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: '確認する',
13
13
  cancel: 'キャンセル'
14
14
  },
15
+ Tabs: {
16
+ more: "もっと"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: '時間を選択してください',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: '확인',
13
13
  cancel: '취소'
14
14
  },
15
+ Tabs: {
16
+ more: "더"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: '시간 선택',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Sahkan',
13
13
  cancel: 'Batal'
14
14
  },
15
+ Tabs: {
16
+ more: "Lagi"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Pilih masa',
@@ -17,6 +17,9 @@ const local = {
17
17
  confirm: 'Bevestigen',
18
18
  cancel: 'Annuleren'
19
19
  },
20
+ Tabs: {
21
+ more: "Meer"
22
+ },
20
23
  TimePicker: {
21
24
  placeholder: {
22
25
  time: 'Tijd selecteren',
@@ -17,6 +17,9 @@ const local = {
17
17
  confirm: 'Potwierdź',
18
18
  cancel: 'Anuluj'
19
19
  },
20
+ Tabs: {
21
+ more: "Więcej"
22
+ },
20
23
  TimePicker: {
21
24
  placeholder: {
22
25
  time: 'Wybierz czas',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'OK',
13
13
  cancel: 'Cancelar'
14
14
  },
15
+ Tabs: {
16
+ more: "Mais"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Por favor escolha a hora',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Confirmă',
13
13
  cancel: 'Anulează'
14
14
  },
15
+ Tabs: {
16
+ more: "Mai mult"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Selectează timpul',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'подтвердить',
13
13
  cancel: 'отмена'
14
14
  },
15
+ Tabs: {
16
+ more: "Более"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Выбрать время',
@@ -16,6 +16,9 @@ const local = {
16
16
  confirm: 'Bekräfta',
17
17
  cancel: 'Avbryt'
18
18
  },
19
+ Tabs: {
20
+ more: "Mer"
21
+ },
19
22
  TimePicker: {
20
23
  placeholder: {
21
24
  time: 'Välj tid',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'ตกลง',
13
13
  cancel: 'ยกเลิก'
14
14
  },
15
+ Tabs: {
16
+ more: "มากกว่า"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'โปรดเลือกเวลา',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Tamam',
13
13
  cancel: 'İptal'
14
14
  },
15
+ Tabs: {
16
+ more: "Daha"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Lütfen bir zaman seçin',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: 'Xác nhận',
13
13
  cancel: 'Huỷ bỏ'
14
14
  },
15
+ Tabs: {
16
+ more: "Hơn"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: 'Chọn thời gian',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: '确定',
13
13
  cancel: '取消'
14
14
  },
15
+ Tabs: {
16
+ more: "更多"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: '请选择时间',
@@ -12,6 +12,9 @@ const local = {
12
12
  confirm: '確定',
13
13
  cancel: '取消'
14
14
  },
15
+ Tabs: {
16
+ more: "更多"
17
+ },
15
18
  TimePicker: {
16
19
  placeholder: {
17
20
  time: '請選擇時間',
@@ -266,11 +266,11 @@ export default class Slider extends BaseComponent {
266
266
  const minPercent = percentInfo.min;
267
267
  const maxPercent = percentInfo.max;
268
268
  let trackStyle = !vertical ? {
269
- width: range ? `${(maxPercent - minPercent) * 100}%` : `${minPercent * 100}%`,
270
- left: range ? `${minPercent * 100}%` : 0
269
+ width: range ? `${Math.abs(maxPercent - minPercent) * 100}%` : `${minPercent * 100}%`,
270
+ left: range ? `${Math.min(minPercent, maxPercent) * 100}%` : 0
271
271
  } : {
272
- height: range ? `${(maxPercent - minPercent) * 100}%` : `${minPercent * 100}%`,
273
- top: range ? `${minPercent * 100}%` : 0
272
+ height: range ? `${Math.abs(maxPercent - minPercent) * 100}%` : `${minPercent * 100}%`,
273
+ top: range ? `${Math.min(minPercent, maxPercent) * 100}%` : 0
274
274
  };
275
275
  trackStyle = included ? trackStyle : {};
276
276
  return (
@@ -385,11 +385,13 @@ export default class Slider extends BaseComponent {
385
385
  var _this = this;
386
386
  return Object.assign(Object.assign({}, super.adapter), {
387
387
  getSliderLengths: () => {
388
+ var _a;
388
389
  if (this.sliderEl && this.sliderEl.current) {
389
390
  const rect = this.sliderEl.current.getBoundingClientRect();
391
+ const offsetParentRect = (_a = this.sliderEl.current.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
390
392
  const offset = {
391
- x: this.sliderEl.current.offsetLeft,
392
- y: this.sliderEl.current.offsetTop
393
+ x: offsetParentRect ? rect.left - offsetParentRect.left : this.sliderEl.current.offsetLeft,
394
+ y: offsetParentRect ? rect.top - offsetParentRect.top : this.sliderEl.current.offsetTop
393
395
  };
394
396
  return {
395
397
  sliderX: offset.x,
@@ -446,7 +448,9 @@ export default class Slider extends BaseComponent {
446
448
  let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _noop;
447
449
  this.setState(stateObj, callback);
448
450
  },
449
- notifyChange: cbValue => this.props.onChange(cbValue),
451
+ notifyChange: cbValue => {
452
+ this.props.onChange(Array.isArray(cbValue) ? [...cbValue].sort() : cbValue);
453
+ },
450
454
  setDragging: value => {
451
455
  this.dragging = value;
452
456
  },
@@ -599,7 +603,8 @@ export default class Slider extends BaseComponent {
599
603
  [`${prefixCls}`]: !vertical,
600
604
  [cssClasses.VERTICAL]: vertical
601
605
  });
602
- const ariaLabel = range ? `Range: ${this._getAriaValueText(currentValue[0], 0)} to ${this._getAriaValueText(currentValue[1], 1)}` : undefined;
606
+ const fixedCurrentValue = Array.isArray(currentValue) ? [...currentValue].sort() : currentValue;
607
+ const ariaLabel = range ? `Range: ${this._getAriaValueText(fixedCurrentValue[0], 0)} to ${this._getAriaValueText(fixedCurrentValue[1], 1)}` : undefined;
603
608
  const slider = /*#__PURE__*/React.createElement("div", Object.assign({
604
609
  className: wrapperClass,
605
610
  style: style,
@@ -1,5 +1,6 @@
1
1
  import React, { MouseEvent, ReactNode } from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { DropdownProps } from '../dropdown';
3
4
  import { TabBarProps, PlainTab } from './interface';
4
5
  export interface TabBarState {
5
6
  endInd: number;
@@ -25,19 +26,25 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
25
26
  type: PropTypes.Requireable<string>;
26
27
  closable: PropTypes.Requireable<boolean>;
27
28
  deleteTabItem: PropTypes.Requireable<(...args: any[]) => any>;
29
+ more: PropTypes.Requireable<NonNullable<number | object>>;
28
30
  };
29
31
  constructor(props: TabBarProps);
30
32
  componentDidMount(): void;
33
+ componentDidUpdate(prevProps: any): void;
31
34
  renderIcon(icon: ReactNode): ReactNode;
32
35
  renderExtra(): ReactNode;
33
36
  handleItemClick: (itemKey: string, e: MouseEvent<Element>) => void;
34
37
  handleKeyDown: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
35
38
  renderTabItem: (panel: PlainTab) => ReactNode;
39
+ scrollTabItemIntoViewByKey: (key: string, logicalPosition?: ScrollLogicalPosition) => void;
40
+ scrollActiveTabItemIntoView: (logicalPosition?: ScrollLogicalPosition) => void;
36
41
  renderTabComponents: (list: Array<PlainTab>) => Array<ReactNode>;
37
42
  handleArrowClick: (items: Array<OverflowItem>, pos: 'start' | 'end') => void;
38
43
  renderCollapse: (items: Array<OverflowItem>, icon: ReactNode, pos: 'start' | 'end') => ReactNode;
39
44
  renderOverflow: (items: any[]) => Array<ReactNode>;
40
45
  renderCollapsedTab: () => ReactNode;
46
+ renderWithMoreTrigger: () => ReactNode;
47
+ renderMoreDropdown: (panels: PlainTab[], dropDownProps: DropdownProps, trigger: ReactNode) => ReactNode;
41
48
  render(): ReactNode;
42
49
  private _isActive;
43
50
  private _getItemKey;
@@ -16,23 +16,17 @@ import getDataAttr from '@douyinfe/semi-foundation/lib/es/utils/getDataAttr';
16
16
  import OverflowList from '../overflowList';
17
17
  import Dropdown from '../dropdown';
18
18
  import Button from '../button';
19
- import { IconChevronRight, IconChevronLeft } from '@douyinfe/semi-icons';
19
+ import { IconChevronRight, IconChevronLeft, IconChevronDown } from '@douyinfe/semi-icons';
20
20
  import { getUuidv4 } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
21
21
  import TabItem from './TabItem';
22
+ import LocaleConsumer from "../locale/localeConsumer";
22
23
  class TabBar extends React.Component {
23
24
  constructor(props) {
25
+ var _this;
24
26
  super(props);
27
+ _this = this;
25
28
  this.handleItemClick = (itemKey, e) => {
26
29
  this.props.onTabClick(itemKey, e);
27
- if (this.props.collapsible) {
28
- const key = this._getItemKey(itemKey);
29
- const tabItem = document.querySelector(`[data-uuid="${this.state.uuid}"] .${cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
30
- tabItem.scrollIntoView({
31
- behavior: 'smooth',
32
- block: 'nearest',
33
- inline: 'nearest'
34
- });
35
- }
36
30
  };
37
31
  this.handleKeyDown = (event, itemKey, closable) => {
38
32
  this.props.handleKeyDown(event, itemKey, closable);
@@ -57,6 +51,19 @@ class TabBar extends React.Component {
57
51
  onClick: this.handleItemClick
58
52
  }));
59
53
  };
54
+ this.scrollTabItemIntoViewByKey = function (key) {
55
+ let logicalPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'nearest';
56
+ const tabItem = document.querySelector(`[data-uuid="${_this.state.uuid}"] .${cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
57
+ tabItem === null || tabItem === void 0 ? void 0 : tabItem.scrollIntoView({
58
+ behavior: 'smooth',
59
+ block: logicalPosition,
60
+ inline: logicalPosition
61
+ });
62
+ };
63
+ this.scrollActiveTabItemIntoView = logicalPosition => {
64
+ const key = this._getItemKey(this.props.activeKey);
65
+ this.scrollTabItemIntoViewByKey(key, logicalPosition);
66
+ };
60
67
  this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
61
68
  this.handleArrowClick = (items, pos) => {
62
69
  const lastItem = pos === 'start' ? items.pop() : items.shift();
@@ -64,12 +71,7 @@ class TabBar extends React.Component {
64
71
  return;
65
72
  }
66
73
  const key = this._getItemKey(lastItem.itemKey);
67
- const tabItem = document.querySelector(`[data-uuid="${this.state.uuid}"] .${cssClasses.TABS_TAB}[data-scrollkey="${key}"]`);
68
- tabItem.scrollIntoView({
69
- behavior: 'smooth',
70
- block: 'nearest',
71
- inline: 'nearest'
72
- });
74
+ this.scrollTabItemIntoViewByKey(key);
73
75
  };
74
76
  this.renderCollapse = (items, icon, pos) => {
75
77
  if (_isEmpty(items)) {
@@ -156,6 +158,55 @@ class TabBar extends React.Component {
156
158
  visibleItemRenderer: this.renderTabItem
157
159
  });
158
160
  };
161
+ this.renderWithMoreTrigger = () => {
162
+ const {
163
+ list,
164
+ more
165
+ } = this.props;
166
+ let tabElements = [];
167
+ let moreTrigger = /*#__PURE__*/React.createElement("div", {
168
+ className: cls({
169
+ [`${cssClasses.TABS_BAR}-more-trigger`]: true,
170
+ [`${cssClasses.TABS_BAR}-more-trigger-${this.props.type}`]: true
171
+ })
172
+ }, /*#__PURE__*/React.createElement(LocaleConsumer, {
173
+ componentName: "Tabs"
174
+ }, (locale, localeCode) => /*#__PURE__*/React.createElement("div", {
175
+ className: `${cssClasses.TABS_BAR}-more-trigger-content`
176
+ }, /*#__PURE__*/React.createElement("div", null, locale.more), /*#__PURE__*/React.createElement(IconChevronDown, {
177
+ className: `${cssClasses.TABS_BAR}-more-trigger-content-icon`
178
+ }))));
179
+ let keepCount;
180
+ if (typeof more === "number") {
181
+ keepCount = list.length - Math.min(more, list.length);
182
+ tabElements = list.slice(0, keepCount).map(panel => this.renderTabItem(panel));
183
+ } else if (typeof more === 'object') {
184
+ keepCount = list.length - Math.min(more.count, list.length);
185
+ tabElements = list.slice(0, keepCount).map(panel => this.renderTabItem(panel));
186
+ if (more.render) {
187
+ moreTrigger = more.render();
188
+ }
189
+ } else if (more !== undefined) {
190
+ throw new Error("[Semi Tabs]: invalid tab props format: more");
191
+ }
192
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, this.renderMoreDropdown(list.slice(keepCount), more === null || more === void 0 ? void 0 : more['dropdownProps'], moreTrigger));
193
+ };
194
+ this.renderMoreDropdown = (panels, dropDownProps, trigger) => {
195
+ return /*#__PURE__*/React.createElement(Dropdown, Object.assign({
196
+ trigger: 'hover',
197
+ showTick: true,
198
+ position: 'bottomLeft',
199
+ className: `${cssClasses.TABS_BAR}-more-dropdown-${this.props.type}`,
200
+ clickToHide: true,
201
+ menu: panels.map(panel => ({
202
+ node: 'item',
203
+ name: panel.tab,
204
+ icon: panel.icon,
205
+ onClick: e => this.props.onTabClick(panel.itemKey, e),
206
+ active: this.props.activeKey === panel.itemKey
207
+ }))
208
+ }, dropDownProps), trigger);
209
+ };
159
210
  this._isActive = key => key === this.props.activeKey;
160
211
  this._getItemKey = key => `${key}-bar`;
161
212
  this.state = {
@@ -170,6 +221,13 @@ class TabBar extends React.Component {
170
221
  uuid: getUuidv4()
171
222
  });
172
223
  }
224
+ componentDidUpdate(prevProps) {
225
+ if (prevProps.activeKey !== this.props.activeKey) {
226
+ if (this.props.collapsible) {
227
+ this.scrollActiveTabItemIntoView();
228
+ }
229
+ }
230
+ }
173
231
  renderIcon(icon) {
174
232
  return /*#__PURE__*/React.createElement("span", null, icon);
175
233
  }
@@ -205,9 +263,10 @@ class TabBar extends React.Component {
205
263
  className,
206
264
  list,
207
265
  tabPosition,
266
+ more,
208
267
  collapsible
209
268
  } = _a,
210
- restProps = __rest(_a, ["type", "style", "className", "list", "tabPosition", "collapsible"]);
269
+ restProps = __rest(_a, ["type", "style", "className", "list", "tabPosition", "more", "collapsible"]);
211
270
  const classNames = cls(className, {
212
271
  [cssClasses.TABS_BAR]: true,
213
272
  [cssClasses.TABS_BAR_LINE]: type === 'line',
@@ -217,7 +276,7 @@ class TabBar extends React.Component {
217
276
  [`${cssClasses.TABS_BAR}-collapse`]: collapsible
218
277
  });
219
278
  const extra = this.renderExtra();
220
- const contents = collapsible ? this.renderCollapsedTab() : this.renderTabComponents(list);
279
+ const contents = collapsible ? this.renderCollapsedTab() : more ? this.renderWithMoreTrigger() : this.renderTabComponents(list);
221
280
  return /*#__PURE__*/React.createElement("div", Object.assign({
222
281
  role: "tablist",
223
282
  "aria-orientation": tabPosition === "left" ? "vertical" : "horizontal",
@@ -240,6 +299,7 @@ TabBar.propTypes = {
240
299
  tabPosition: PropTypes.oneOf(strings.POSITION_MAP),
241
300
  type: PropTypes.oneOf(strings.TYPE_MAP),
242
301
  closable: PropTypes.bool,
243
- deleteTabItem: PropTypes.func
302
+ deleteTabItem: PropTypes.func,
303
+ more: PropTypes.oneOfType([PropTypes.number, PropTypes.object])
244
304
  };
245
305
  export default TabBar;
@@ -34,7 +34,9 @@ const TabItem = (props, ref) => {
34
34
  onClick: e => deleteTabItem(itemKey, e)
35
35
  }) : null;
36
36
  }, [type, closable, deleteTabItem, itemKey]);
37
- const renderIcon = useCallback(icon => /*#__PURE__*/React.createElement("span", null, icon), []);
37
+ const renderIcon = useCallback(icon => /*#__PURE__*/React.createElement("span", {
38
+ className: `${cssClasses.TABS_BAR}-icon`
39
+ }, icon), []);
38
40
  const handleKeyDownInItem = useCallback(event => {
39
41
  handleKeyDown && handleKeyDown(event, itemKey, closable);
40
42
  }, [handleKeyDown, itemKey, closable]);
@@ -37,6 +37,7 @@ declare class Tabs extends BaseComponent<TabsProps, TabsState> {
37
37
  type: PropTypes.Requireable<string>;
38
38
  onTabClose: PropTypes.Requireable<(...args: any[]) => any>;
39
39
  preventScroll: PropTypes.Requireable<boolean>;
40
+ more: PropTypes.Requireable<NonNullable<number | object>>;
40
41
  };
41
42
  static __SemiComponentName__: string;
42
43
  static defaultProps: TabsProps;
@@ -222,9 +222,10 @@ class Tabs extends BaseComponent {
222
222
  tabBarStyle,
223
223
  tabPaneMotion,
224
224
  tabPosition,
225
- type
225
+ type,
226
+ more
226
227
  } = _a,
227
- restProps = __rest(_a, ["children", "className", "collapsible", "contentStyle", "keepDOM", "lazyRender", "renderTabBar", "size", "style", "tabBarClassName", "tabBarExtraContent", "tabBarStyle", "tabPaneMotion", "tabPosition", "type"]);
228
+ restProps = __rest(_a, ["children", "className", "collapsible", "contentStyle", "keepDOM", "lazyRender", "renderTabBar", "size", "style", "tabBarClassName", "tabBarExtraContent", "tabBarStyle", "tabPaneMotion", "tabPosition", "type", "more"]);
228
229
  const {
229
230
  panes,
230
231
  activeKey
@@ -249,7 +250,8 @@ class Tabs extends BaseComponent {
249
250
  tabPosition,
250
251
  type,
251
252
  deleteTabItem: this.deleteTabItem,
252
- handleKeyDown: this.foundation.handleKeyDown
253
+ handleKeyDown: this.foundation.handleKeyDown,
254
+ more
253
255
  };
254
256
  const tabBar = renderTabBar ? renderTabBar(tabBarProps, TabBar) : /*#__PURE__*/React.createElement(TabBar, Object.assign({}, tabBarProps));
255
257
  const content = keepDOM ? children : this.getActiveItem();
@@ -296,7 +298,8 @@ Tabs.propTypes = {
296
298
  tabPosition: PropTypes.oneOf(strings.POSITION_MAP),
297
299
  type: PropTypes.oneOf(strings.TYPE_MAP),
298
300
  onTabClose: PropTypes.func,
299
- preventScroll: PropTypes.bool
301
+ preventScroll: PropTypes.bool,
302
+ more: PropTypes.oneOfType([PropTypes.number, PropTypes.object])
300
303
  };
301
304
  Tabs.__SemiComponentName__ = "Tabs";
302
305
  Tabs.defaultProps = getDefaultPropsFromGlobalConfig(Tabs.__SemiComponentName__, {
@@ -1,6 +1,7 @@
1
1
  import React, { CSSProperties, MouseEvent, ReactNode } from 'react';
2
2
  import { Motion } from '../_base/base';
3
3
  import TabBar from './TabBar';
4
+ import { DropdownProps } from "../dropdown";
4
5
  export type TabType = 'line' | 'card' | 'button';
5
6
  export type TabSize = 'small' | 'medium' | 'large';
6
7
  export type TabPosition = 'top' | 'left';
@@ -34,6 +35,11 @@ export interface TabsProps {
34
35
  type?: TabType;
35
36
  onTabClose?: (tabKey: string) => void;
36
37
  preventScroll?: boolean;
38
+ more?: number | {
39
+ count: number;
40
+ render?: () => ReactNode;
41
+ dropdownProps?: DropdownProps;
42
+ };
37
43
  }
38
44
  export interface TabBarProps {
39
45
  activeKey?: string;
@@ -51,6 +57,7 @@ export interface TabBarProps {
51
57
  closable?: boolean;
52
58
  deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
53
59
  handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
60
+ more?: TabsProps['more'];
54
61
  }
55
62
  export interface TabPaneProps {
56
63
  className?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.58.0-beta.0",
3
+ "version": "2.58.1",
4
4
  "description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -20,12 +20,12 @@
20
20
  "@dnd-kit/core": "^6.0.8",
21
21
  "@dnd-kit/sortable": "^7.0.2",
22
22
  "@dnd-kit/utilities": "^3.2.1",
23
- "@douyinfe/semi-animation": "2.58.0-beta.0",
24
- "@douyinfe/semi-animation-react": "2.58.0-beta.0",
25
- "@douyinfe/semi-foundation": "2.58.0-beta.0",
26
- "@douyinfe/semi-icons": "2.58.0-beta.0",
27
- "@douyinfe/semi-illustrations": "2.58.0-beta.0",
28
- "@douyinfe/semi-theme-default": "2.58.0-beta.0",
23
+ "@douyinfe/semi-animation": "2.58.1",
24
+ "@douyinfe/semi-animation-react": "2.58.1",
25
+ "@douyinfe/semi-foundation": "2.58.1",
26
+ "@douyinfe/semi-icons": "2.58.1",
27
+ "@douyinfe/semi-illustrations": "2.58.1",
28
+ "@douyinfe/semi-theme-default": "2.58.1",
29
29
  "async-validator": "^3.5.0",
30
30
  "classnames": "^2.2.6",
31
31
  "copy-text-to-clipboard": "^2.1.1",
@@ -75,7 +75,7 @@
75
75
  ],
76
76
  "author": "",
77
77
  "license": "MIT",
78
- "gitHead": "bd0c5bf8924d1e971746ba88f83c2c8857d307f7",
78
+ "gitHead": "1e48bf7b71e78f49b188ff82c5ab61884a6ec0ab",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",