@douyinfe/semi-ui 2.5.1 → 2.7.0-beta.0

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 (111) hide show
  1. package/button/__test__/button.test.js +7 -0
  2. package/button/buttonGroup.tsx +5 -2
  3. package/calendar/monthCalendar.tsx +14 -13
  4. package/cascader/__test__/cascader.test.js +159 -81
  5. package/cascader/_story/cascader.stories.js +36 -23
  6. package/cascader/index.tsx +47 -8
  7. package/cascader/item.tsx +25 -5
  8. package/datePicker/_story/v2/InsetInput.jsx +104 -0
  9. package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
  10. package/datePicker/_story/v2/index.js +2 -0
  11. package/datePicker/dateInput.tsx +102 -13
  12. package/datePicker/datePicker.tsx +95 -16
  13. package/datePicker/index.tsx +15 -0
  14. package/datePicker/insetInput.tsx +76 -0
  15. package/datePicker/month.tsx +14 -7
  16. package/datePicker/monthsGrid.tsx +31 -12
  17. package/datePicker/navigation.tsx +8 -4
  18. package/datePicker/quickControl.tsx +1 -0
  19. package/datePicker/yearAndMonth.tsx +1 -1
  20. package/dist/css/semi.css +120 -8
  21. package/dist/css/semi.min.css +1 -1
  22. package/dist/umd/semi-ui.js +1100 -193
  23. package/dist/umd/semi-ui.js.map +1 -1
  24. package/dist/umd/semi-ui.min.js +1 -1
  25. package/dist/umd/semi-ui.min.js.map +1 -1
  26. package/form/hoc/withField.tsx +1 -1
  27. package/input/_story/input.stories.js +13 -0
  28. package/lib/cjs/_base/base.css +5 -5
  29. package/lib/cjs/button/buttonGroup.d.ts +1 -0
  30. package/lib/cjs/button/buttonGroup.js +6 -2
  31. package/lib/cjs/calendar/monthCalendar.js +21 -5
  32. package/lib/cjs/cascader/index.d.ts +10 -2
  33. package/lib/cjs/cascader/index.js +52 -10
  34. package/lib/cjs/cascader/item.d.ts +6 -2
  35. package/lib/cjs/cascader/item.js +33 -4
  36. package/lib/cjs/datePicker/dateInput.d.ts +9 -4
  37. package/lib/cjs/datePicker/dateInput.js +107 -13
  38. package/lib/cjs/datePicker/datePicker.d.ts +7 -2
  39. package/lib/cjs/datePicker/datePicker.js +138 -30
  40. package/lib/cjs/datePicker/index.js +24 -2
  41. package/lib/cjs/datePicker/insetInput.d.ts +21 -0
  42. package/lib/cjs/datePicker/insetInput.js +80 -0
  43. package/lib/cjs/datePicker/month.d.ts +1 -0
  44. package/lib/cjs/datePicker/month.js +18 -2
  45. package/lib/cjs/datePicker/monthsGrid.js +35 -11
  46. package/lib/cjs/datePicker/navigation.js +8 -0
  47. package/lib/cjs/datePicker/quickControl.js +1 -0
  48. package/lib/cjs/datePicker/yearAndMonth.js +1 -0
  49. package/lib/cjs/form/hoc/withField.js +1 -1
  50. package/lib/cjs/navigation/Item.d.ts +2 -2
  51. package/lib/cjs/navigation/Item.js +8 -6
  52. package/lib/cjs/navigation/SubNav.js +2 -2
  53. package/lib/cjs/scrollList/scrollItem.d.ts +2 -1
  54. package/lib/cjs/scrollList/scrollItem.js +13 -3
  55. package/lib/cjs/table/Body/index.d.ts +2 -0
  56. package/lib/cjs/table/Body/index.js +13 -4
  57. package/lib/cjs/tree/index.js +5 -3
  58. package/lib/cjs/tree/interface.d.ts +1 -0
  59. package/lib/cjs/tree/nodeList.js +2 -1
  60. package/lib/cjs/treeSelect/index.js +7 -3
  61. package/lib/es/_base/base.css +5 -5
  62. package/lib/es/button/buttonGroup.d.ts +1 -0
  63. package/lib/es/button/buttonGroup.js +5 -2
  64. package/lib/es/calendar/monthCalendar.js +22 -5
  65. package/lib/es/cascader/index.d.ts +10 -2
  66. package/lib/es/cascader/index.js +49 -7
  67. package/lib/es/cascader/item.d.ts +6 -2
  68. package/lib/es/cascader/item.js +31 -4
  69. package/lib/es/datePicker/dateInput.d.ts +9 -4
  70. package/lib/es/datePicker/dateInput.js +106 -13
  71. package/lib/es/datePicker/datePicker.d.ts +7 -2
  72. package/lib/es/datePicker/datePicker.js +139 -30
  73. package/lib/es/datePicker/index.js +20 -0
  74. package/lib/es/datePicker/insetInput.d.ts +21 -0
  75. package/lib/es/datePicker/insetInput.js +65 -0
  76. package/lib/es/datePicker/month.d.ts +1 -0
  77. package/lib/es/datePicker/month.js +18 -2
  78. package/lib/es/datePicker/monthsGrid.js +35 -11
  79. package/lib/es/datePicker/navigation.js +8 -0
  80. package/lib/es/datePicker/quickControl.js +2 -0
  81. package/lib/es/datePicker/yearAndMonth.js +1 -0
  82. package/lib/es/form/hoc/withField.js +1 -1
  83. package/lib/es/navigation/Item.d.ts +2 -2
  84. package/lib/es/navigation/Item.js +8 -6
  85. package/lib/es/navigation/SubNav.js +2 -2
  86. package/lib/es/scrollList/scrollItem.d.ts +2 -1
  87. package/lib/es/scrollList/scrollItem.js +13 -3
  88. package/lib/es/table/Body/index.d.ts +2 -0
  89. package/lib/es/table/Body/index.js +13 -4
  90. package/lib/es/tree/index.js +5 -3
  91. package/lib/es/tree/interface.d.ts +1 -0
  92. package/lib/es/tree/nodeList.js +2 -1
  93. package/lib/es/treeSelect/index.js +7 -3
  94. package/navigation/Item.tsx +15 -12
  95. package/navigation/SubNav.tsx +4 -4
  96. package/package.json +9 -9
  97. package/scrollList/_story/ScrollList/index.js +3 -0
  98. package/scrollList/_story/WheelList/index.js +3 -0
  99. package/scrollList/scrollItem.tsx +30 -9
  100. package/table/Body/index.tsx +15 -4
  101. package/table/__test__/table.test.js +18 -0
  102. package/table/_story/v2/FixedExpandedRow/index.jsx +95 -0
  103. package/table/_story/v2/index.js +2 -1
  104. package/tree/__test__/tree.test.js +87 -2
  105. package/tree/_story/tree.stories.js +65 -5
  106. package/tree/index.tsx +4 -2
  107. package/tree/interface.ts +1 -0
  108. package/tree/nodeList.tsx +2 -2
  109. package/treeSelect/__test__/treeSelect.test.js +28 -0
  110. package/treeSelect/_story/treeSelect.stories.js +55 -2
  111. package/treeSelect/index.tsx +11 -3
@@ -33,6 +33,7 @@ export default class Month extends BaseComponent<MonthProps, MonthState> {
33
33
  endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
34
34
  rangeInputFocus: PropTypes.Requireable<string | boolean>;
35
35
  focusRecordsRef: PropTypes.Requireable<object>;
36
+ multiple: PropTypes.Requireable<boolean>;
36
37
  };
37
38
  static defaultProps: {
38
39
  month: Date;
@@ -6,6 +6,8 @@ import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
6
6
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
7
  import _Set from "@babel/runtime-corejs3/core-js-stable/set";
8
8
 
9
+ /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions */
10
+
9
11
  /* eslint-disable max-len */
10
12
  import React from 'react';
11
13
  import classNames from 'classnames';
@@ -328,8 +330,10 @@ export default class Month extends BaseComponent {
328
330
  const weekdaysText = _mapInstanceProperty(weekdays).call(weekdays, key => locale.weeks[key]);
329
331
 
330
332
  return /*#__PURE__*/React.createElement("div", {
333
+ role: "row",
331
334
  className: weekdayCls
332
335
  }, _mapInstanceProperty(weekdaysText).call(weekdaysText, (E, i) => /*#__PURE__*/React.createElement("div", {
336
+ role: "columnheader",
333
337
  key: E + i,
334
338
  className: weekdayItemCls
335
339
  }, E)));
@@ -364,6 +368,7 @@ export default class Month extends BaseComponent {
364
368
  renderWeek(week, weekIndex) {
365
369
  const weekCls = cssClasses.WEEK;
366
370
  return /*#__PURE__*/React.createElement("div", {
371
+ role: "row",
367
372
  className: weekCls,
368
373
  key: weekIndex
369
374
  }, _mapInstanceProperty(week).call(week, (day, dayIndex) => this.renderDay(day, dayIndex)));
@@ -384,6 +389,8 @@ export default class Month extends BaseComponent {
384
389
 
385
390
  if (!fullDate) {
386
391
  return /*#__PURE__*/React.createElement("div", {
392
+ role: "gridcell",
393
+ tabIndex: -1,
387
394
  key: dayNumber + dayIndex,
388
395
  className: cssClasses.DAY
389
396
  }, /*#__PURE__*/React.createElement("span", null));
@@ -421,6 +428,11 @@ export default class Month extends BaseComponent {
421
428
  const customRender = _isFunction(renderFullDate);
422
429
 
423
430
  return /*#__PURE__*/React.createElement("div", {
431
+ role: "gridcell",
432
+ tabIndex: dayStatus.isDisabled ? -1 : 0,
433
+ "aria-disabled": dayStatus.isDisabled,
434
+ "aria-selected": dayStatus.isSelected,
435
+ "aria-label": fullDate,
424
436
  className: !customRender ? dayCls : cssClasses.DAY,
425
437
  title: fullDate,
426
438
  key: dayNumber + dayIndex,
@@ -434,13 +446,16 @@ export default class Month extends BaseComponent {
434
446
 
435
447
  render() {
436
448
  const {
437
- forwardRef
449
+ forwardRef,
450
+ multiple
438
451
  } = this.props;
439
452
  const weekday = this.renderDayOfWeek();
440
453
  const weeks = this.renderWeeks();
441
454
  const monthCls = classNames(cssClasses.MONTH);
442
455
  const ref = forwardRef || this.monthRef;
443
456
  return /*#__PURE__*/React.createElement("div", {
457
+ role: "grid",
458
+ "aria-multiselectable": multiple,
444
459
  ref: ref,
445
460
  className: monthCls
446
461
  }, weekday, weeks);
@@ -466,7 +481,8 @@ Month.propTypes = {
466
481
  startDateOffset: PropTypes.func,
467
482
  endDateOffset: PropTypes.func,
468
483
  rangeInputFocus: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
469
- focusRecordsRef: PropTypes.object
484
+ focusRecordsRef: PropTypes.object,
485
+ multiple: PropTypes.bool
470
486
  };
471
487
  Month.defaultProps = {
472
488
  month: new Date(),
@@ -7,6 +7,10 @@ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"
7
7
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
8
8
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
9
9
 
10
+ /* eslint-disable jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events */
11
+
12
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
13
+
10
14
  /* eslint-disable react/no-did-update-set-state */
11
15
 
12
16
  /* eslint-disable max-len */
@@ -282,6 +286,9 @@ export default class MonthsGrid extends BaseComponent {
282
286
  monthRight,
283
287
  currentPanelHeight
284
288
  } = this.state;
289
+ const {
290
+ insetInput
291
+ } = this.props;
285
292
  const panelDetail = panelType === strings.PANEL_TYPE_RIGHT ? monthRight : monthLeft;
286
293
  const {
287
294
  isTimePickerOpen,
@@ -304,7 +311,7 @@ export default class MonthsGrid extends BaseComponent {
304
311
  style.minWidth = wrap.getBoundingClientRect().width;
305
312
  }
306
313
 
307
- if (this.leftIsYearOrTime() && this.rightIsYearOrTime()) {
314
+ if (this.leftIsYearOrTime() && this.rightIsYearOrTime() && !insetInput) {
308
315
  /**
309
316
  * left和right同时为tpk时,panel会有一个minHeight
310
317
  * 如果缓存的currentPanelHeight为0,则需要计算滚动列表的高度
@@ -314,7 +321,7 @@ export default class MonthsGrid extends BaseComponent {
314
321
  * When left and right are tpk at the same time, the panel will have a minHeight
315
322
  * If the cached currentPanelHeight is 0, you need to calculate the height of the scrolling list
316
323
  * If there is a cached value, use currentPanelHeight (if this height is less than the actual value, it will affect the number of cycles in the ScrollList to render the list)
317
- * See packages/semi-foundation/scrollList/itemF oundation.js initWheelList function
324
+ * See packages/semi-foundation/scrollList/itemFoundation.js initWheelList function
318
325
  */
319
326
  style.minHeight = currentPanelHeight ? currentPanelHeight : this.calcScrollListHeight();
320
327
  }
@@ -322,10 +329,14 @@ export default class MonthsGrid extends BaseComponent {
322
329
  monthCls = classnames(monthCls, "".concat(prefixCls, "-yam-showing"));
323
330
  }
324
331
 
332
+ const _isDatePanelOpen = !(isYearPickerOpen || isTimePickerOpen);
333
+
334
+ const xOpenType = _isDatePanelOpen ? 'date' : isYearPickerOpen ? 'year' : 'time';
325
335
  return /*#__PURE__*/React.createElement("div", {
326
336
  className: monthCls,
327
337
  key: panelType,
328
- style: style
338
+ style: style,
339
+ "x-open-type": xOpenType
329
340
  }, yearAndMonthLayer, timePickerLayer, this.foundation.isRangeType() ? panelContent : isYearPickerOpen || isTimePickerOpen ? null : panelContent, this.renderSwitch(panelType));
330
341
  }
331
342
 
@@ -362,7 +373,8 @@ export default class MonthsGrid extends BaseComponent {
362
373
  endDateOffset,
363
374
  density,
364
375
  rangeInputFocus,
365
- syncSwitchMonth
376
+ syncSwitchMonth,
377
+ multiple
366
378
  } = this.props;
367
379
  let monthText = ''; // i18n monthText
368
380
 
@@ -428,7 +440,8 @@ export default class MonthsGrid extends BaseComponent {
428
440
  onWeeksRowNumChange: weeksRowNum => this.handleWeeksRowNumChange(weeksRowNum, panelType),
429
441
  startDateOffset: startDateOffset,
430
442
  endDateOffset: endDateOffset,
431
- focusRecordsRef: this.props.focusRecordsRef
443
+ focusRecordsRef: this.props.focusRecordsRef,
444
+ multiple: multiple
432
445
  }));
433
446
  }
434
447
 
@@ -534,10 +547,11 @@ export default class MonthsGrid extends BaseComponent {
534
547
  locale,
535
548
  disabledTimePicker,
536
549
  density,
537
- dateFnsLocale
538
- } = this.props; // Type: date, dateRange, year, month, no rendering required
550
+ dateFnsLocale,
551
+ insetInput
552
+ } = this.props; // Type: date, dateRange, year, month, inset input no rendering required
539
553
 
540
- if (!_includesInstanceProperty(type).call(type, 'Time')) {
554
+ if (!_includesInstanceProperty(type).call(type, 'Time') || insetInput) {
541
555
  return null;
542
556
  } // switch year/month & time
543
557
 
@@ -584,14 +598,22 @@ export default class MonthsGrid extends BaseComponent {
584
598
  className: switchCls,
585
599
  ref: current => this.adapter.setCache("switch-".concat(panelType), current)
586
600
  }, /*#__PURE__*/React.createElement("div", {
601
+ role: "button",
602
+ "aria-label": "Switch to date panel",
587
603
  className: dateCls,
588
604
  onClick: e => this.foundation.showDatePanel(panelType)
589
- }, showSwithIcon && /*#__PURE__*/React.createElement(IconCalendar, null), /*#__PURE__*/React.createElement("span", {
605
+ }, showSwithIcon && /*#__PURE__*/React.createElement(IconCalendar, {
606
+ "aria-hidden": true
607
+ }), /*#__PURE__*/React.createElement("span", {
590
608
  className: textCls
591
609
  }, dateText || monthText)), /*#__PURE__*/React.createElement("div", {
610
+ role: "button",
611
+ "aria-label": "Switch to time panel",
592
612
  className: timeCls,
593
613
  onClick: e => this.foundation.showTimePicker(panelType, true)
594
- }, showSwithIcon && /*#__PURE__*/React.createElement(IconClock, null), /*#__PURE__*/React.createElement("span", {
614
+ }, showSwithIcon && /*#__PURE__*/React.createElement(IconClock, {
615
+ "aria-hidden": true
616
+ }), /*#__PURE__*/React.createElement("span", {
595
617
  className: textCls
596
618
  }, timeText)));
597
619
  }
@@ -602,7 +624,8 @@ export default class MonthsGrid extends BaseComponent {
602
624
  monthRight
603
625
  } = this.state;
604
626
  const {
605
- type
627
+ type,
628
+ insetInput
606
629
  } = this.props;
607
630
  const monthGridCls = classnames({
608
631
  ["".concat(prefixCls, "-month-grid")]: true
@@ -624,6 +647,7 @@ export default class MonthsGrid extends BaseComponent {
624
647
  className: monthGridCls,
625
648
  "x-type": type,
626
649
  "x-panel-yearandmonth-open-type": yearOpenType,
650
+ "x-insetInput": insetInput ? "true" : "false",
627
651
  ref: current => this.cacheRefCurrent('monthGrid', current)
628
652
  }, content);
629
653
  }
@@ -54,7 +54,9 @@ export default class Navigation extends PureComponent {
54
54
  ref: ref
55
55
  }, /*#__PURE__*/React.createElement(IconButton, {
56
56
  key: "double-chevron-left",
57
+ "aria-label": "Previous year",
57
58
  icon: /*#__PURE__*/React.createElement(IconDoubleChevronLeft, {
59
+ "aria-hidden": true,
58
60
  size: iconBtnSize
59
61
  }),
60
62
  size: buttonSize,
@@ -64,7 +66,9 @@ export default class Navigation extends PureComponent {
64
66
  style: leftButtonStyle
65
67
  }), /*#__PURE__*/React.createElement(IconButton, {
66
68
  key: "chevron-left",
69
+ "aria-label": "Previous month",
67
70
  icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
71
+ "aria-hidden": true,
68
72
  size: iconBtnSize
69
73
  }),
70
74
  size: buttonSize,
@@ -80,7 +84,9 @@ export default class Navigation extends PureComponent {
80
84
  size: buttonSize
81
85
  }, /*#__PURE__*/React.createElement("span", null, monthText))), /*#__PURE__*/React.createElement(IconButton, {
82
86
  key: "chevron-right",
87
+ "aria-label": "Next month",
83
88
  icon: /*#__PURE__*/React.createElement(IconChevronRight, {
89
+ "aria-hidden": true,
84
90
  size: iconBtnSize
85
91
  }),
86
92
  size: buttonSize,
@@ -90,7 +96,9 @@ export default class Navigation extends PureComponent {
90
96
  style: rightButtonStyle
91
97
  }), /*#__PURE__*/React.createElement(IconButton, {
92
98
  key: "double-chevron-right",
99
+ "aria-label": "Next year",
93
100
  icon: /*#__PURE__*/React.createElement(IconDoubleChevronRight, {
101
+ "aria-hidden": true,
94
102
  size: iconBtnSize
95
103
  }),
96
104
  size: buttonSize,
@@ -1,5 +1,7 @@
1
1
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
2
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
+
4
+ /* eslint-disable jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events */
3
5
  import React, { PureComponent } from 'react';
4
6
  import classNames from 'classnames';
5
7
  import PropTypes from 'prop-types';
@@ -222,6 +222,7 @@ class YearAndMonth extends BaseComponent {
222
222
  }, /*#__PURE__*/React.createElement(IconButton, {
223
223
  noHorizontalPadding: false,
224
224
  icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
225
+ "aria-hidden": true,
225
226
  size: iconSize
226
227
  }),
227
228
  size: buttonSize,
@@ -498,7 +498,7 @@ function withField(Component, opts) {
498
498
  text: label || field,
499
499
  id: labelId,
500
500
  required: required,
501
- name: name || field,
501
+ name: a11yId || name || field,
502
502
  width: mergeLabelWidth,
503
503
  align: mergeLabelAlign
504
504
  }, needSpread));
@@ -1,7 +1,7 @@
1
1
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import ItemFoundation, { ItemProps, SelectedItemProps, ItemAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
4
+ import ItemFoundation, { ItemAdapter, ItemProps, SelectedItemProps } from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
5
5
  export interface NavItemProps extends ItemProps, BaseProps {
6
6
  children?: React.ReactNode;
7
7
  disabled?: boolean;
@@ -63,7 +63,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
63
63
  constructor(props: NavItemProps);
64
64
  _invokeContextFunc(funcName: string, ...args: any[]): any;
65
65
  get adapter(): ItemAdapter<NavItemProps, NavItemState>;
66
- renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean): JSX.Element;
66
+ renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean, key?: number | string): JSX.Element;
67
67
  setItemRef: (ref: HTMLLIElement) => void;
68
68
  wrapTooltip: (node: React.ReactNode) => JSX.Element;
69
69
  handleClick: (e: React.MouseEvent) => void;
@@ -1,5 +1,5 @@
1
- import _noop from "lodash/noop";
2
1
  import _times from "lodash/times";
2
+ import _noop from "lodash/noop";
3
3
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
4
4
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
@@ -14,7 +14,7 @@ import cls from 'classnames';
14
14
  import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
15
15
  import { cloneDeep, isSemiIcon } from '../_utils';
16
16
  import ItemFoundation from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
17
- import { strings, cssClasses } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
17
+ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
18
18
  import Tooltip from '../tooltip';
19
19
  import NavContext from './nav-context';
20
20
  import Dropdown from '../dropdown';
@@ -118,6 +118,7 @@ export default class NavItem extends BaseComponent {
118
118
  var _context3;
119
119
 
120
120
  let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
121
+ let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
121
122
 
122
123
  if (this.props.isSubNav) {
123
124
  return null;
@@ -138,7 +139,8 @@ export default class NavItem extends BaseComponent {
138
139
  ["".concat(clsPrefix, "-icon-info")]: !isToggleIcon
139
140
  });
140
141
  return /*#__PURE__*/React.createElement("i", {
141
- className: className
142
+ className: className,
143
+ key: key
142
144
  }, isSemiIcon(icon) ? /*#__PURE__*/React.cloneElement(icon, {
143
145
  size: icon.props.size || iconSize
144
146
  }) : icon);
@@ -178,12 +180,12 @@ export default class NavItem extends BaseComponent {
178
180
 
179
181
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
180
182
  const iconAmount = icon && !indent ? level : level - 1;
181
- placeholderIcons = _times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
183
+ placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, index));
182
184
  }
183
185
 
184
- itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT) : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
186
+ itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, 'key-position-left') : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
185
187
  className: "".concat(cssClasses.PREFIX, "-item-text")
186
- }, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true));
188
+ }, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'));
187
189
  }
188
190
 
189
191
  if (typeof link === 'string') {
@@ -203,7 +203,7 @@ export default class SubNav extends BaseComponent {
203
203
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
204
204
  /* Different icons' amount means different indents.*/
205
205
  const iconAmount = icon && !indent ? level : level - 1;
206
- placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, undefined, index));
206
+ placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, false, index));
207
207
  }
208
208
 
209
209
  const titleDiv = /*#__PURE__*/React.createElement("div", {
@@ -215,7 +215,7 @@ export default class SubNav extends BaseComponent {
215
215
  onKeyPress: this.handleKeyPress
216
216
  }, /*#__PURE__*/React.createElement("div", {
217
217
  className: "".concat(prefixCls, "-item-inner")
218
- }, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== strings.MODE_HORIZONTAL ? this.renderIcon(icon, strings.ICON_POS_LEFT, undefined, undefined, 'key-inSubNav-position-left') : null, /*#__PURE__*/React.createElement("span", {
218
+ }, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== strings.MODE_HORIZONTAL ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left') : null, /*#__PURE__*/React.createElement("span", {
219
219
  className: "".concat(prefixCls, "-item-text")
220
220
  }, text), this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
221
221
  return titleDiv;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { AriaAttributes } from 'react';
2
2
  import BaseComponent from '../_base/baseComponent';
3
3
  import PropTypes from 'prop-types';
4
4
  import { Item, ScrollItemAdapter } from '@douyinfe/semi-foundation/lib/es/scrollList/itemFoundation';
@@ -18,6 +18,7 @@ export interface ScrollItemProps<T extends Item> {
18
18
  motion?: Motion;
19
19
  style?: React.CSSProperties;
20
20
  type?: string | number;
21
+ 'aria-label'?: AriaAttributes['aria-label'];
21
22
  }
22
23
  export interface ScrollItemState {
23
24
  prependCount: number;
@@ -274,13 +274,14 @@ export default class ScrollItem extends BaseComponent {
274
274
  transform: itemTrans
275
275
  } = item;
276
276
  const transform = typeof itemTrans === 'function' ? itemTrans : commonTrans;
277
+ const selected = selectedIndex === index;
277
278
  const cls = classnames({
278
- ["".concat(cssClasses.PREFIX, "-item-sel")]: selectedIndex === index && mode !== wheelMode,
279
+ ["".concat(cssClasses.PREFIX, "-item-sel")]: selected && mode !== wheelMode,
279
280
  ["".concat(cssClasses.PREFIX, "-item-disabled")]: Boolean(item.disabled)
280
281
  });
281
282
  let text = '';
282
283
 
283
- if (selectedIndex === index) {
284
+ if (selected) {
284
285
  if (typeof transform === 'function') {
285
286
  text = transform(item.value, item.text);
286
287
  } else {
@@ -304,7 +305,10 @@ export default class ScrollItem extends BaseComponent {
304
305
  React.createElement("li", _Object$assign({
305
306
  key: prefixKey + index
306
307
  }, events, {
307
- className: cls
308
+ className: cls,
309
+ role: "option",
310
+ "aria-selected": selected,
311
+ "aria-disabled": item.disabled
308
312
  }), text)
309
313
  );
310
314
  });
@@ -323,6 +327,9 @@ export default class ScrollItem extends BaseComponent {
323
327
  className: wrapperCls,
324
328
  ref: this._cacheWrapperNode
325
329
  }, /*#__PURE__*/React.createElement("ul", {
330
+ role: "listbox",
331
+ "aria-multiselectable": false,
332
+ "aria-label": this.props['aria-label'],
326
333
  ref: this._cacheListNode
327
334
  }, inner));
328
335
  };
@@ -380,6 +387,9 @@ export default class ScrollItem extends BaseComponent {
380
387
  ref: this._cacheWrapperNode,
381
388
  onScroll: this.scrollToSelectItem
382
389
  }, /*#__PURE__*/React.createElement("ul", {
390
+ role: "listbox",
391
+ "aria-label": this.props['aria-label'],
392
+ "aria-multiselectable": false,
383
393
  ref: this._cacheListNode,
384
394
  onClick: this.clickToSelectItem
385
395
  }, prependList, inner, appendList)));
@@ -43,6 +43,8 @@ export interface BodyState {
43
43
  }
44
44
  export interface BodyContext {
45
45
  getVirtualizedListRef: GetVirtualizedListRef;
46
+ flattenedColumns: ColumnProps[];
47
+ getCellWidths: (flattenedColumns: ColumnProps[]) => number[];
46
48
  }
47
49
  declare const _default: React.ForwardRefExoticComponent<Omit<BodyProps, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
48
50
  export default _default;
@@ -389,8 +389,13 @@ class Body extends BaseComponent {
389
389
  const {
390
390
  flattenedColumns,
391
391
  getCellWidths
392
- } = _this.context;
393
- const cellWidths = getCellWidths(flattenedColumns);
392
+ } = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
393
+
394
+ if (flattenedColumns !== _this.flattenedColumns) {
395
+ _this.flattenedColumns = flattenedColumns;
396
+ _this.cellWidths = getCellWidths(flattenedColumns);
397
+ }
398
+
394
399
  return /*#__PURE__*/React.createElement(ExpandedRow, {
395
400
  style: style,
396
401
  components: components,
@@ -402,7 +407,7 @@ class Body extends BaseComponent {
402
407
  index: index,
403
408
  virtualized: virtualized,
404
409
  key: genExpandedRowKey(key),
405
- cellWidths: cellWidths
410
+ cellWidths: _this.cellWidths
406
411
  });
407
412
  };
408
413
  /**
@@ -580,7 +585,9 @@ class Body extends BaseComponent {
580
585
  };
581
586
  this.listRef = /*#__PURE__*/React.createRef();
582
587
  const {
583
- getVirtualizedListRef
588
+ getVirtualizedListRef,
589
+ flattenedColumns,
590
+ getCellWidths
584
591
  } = context;
585
592
 
586
593
  if (getVirtualizedListRef) {
@@ -592,6 +599,8 @@ class Body extends BaseComponent {
592
599
  }
593
600
 
594
601
  this.foundation = new BodyFoundation(this.adapter);
602
+ this.flattenedColumns = flattenedColumns;
603
+ this.cellWidths = getCellWidths(flattenedColumns);
595
604
  this.observer = null;
596
605
  }
597
606
 
@@ -216,7 +216,8 @@ class Tree extends BaseComponent {
216
216
  const isSeaching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
217
217
  const newState = {
218
218
  prevProps: props
219
- }; // Accept a props field as a parameter to determine whether to update the field
219
+ };
220
+ const isExpandControlled = ('expandedKeys' in props); // Accept a props field as a parameter to determine whether to update the field
220
221
 
221
222
  const needUpdate = name => {
222
223
  const firstInProps = !prevProps && name in props;
@@ -260,7 +261,8 @@ class Tree extends BaseComponent {
260
261
  }
261
262
  }
262
263
 
263
- const expandAllWhenDataChange = (needUpdate('treeDataSimpleJson') || needUpdate('treeData')) && props.expandAll;
264
+ const dataUpdated = needUpdate('treeDataSimpleJson') || needUpdate('treeData');
265
+ const expandAllWhenDataChange = dataUpdated && props.expandAll;
264
266
 
265
267
  if (!isSeaching) {
266
268
  // Update expandedKeys
@@ -286,7 +288,7 @@ class Tree extends BaseComponent {
286
288
  newState.expandedKeys = calcExpandedKeys(props.defaultExpandedKeys, keyEntities);
287
289
  } else if (!prevProps && props.defaultValue) {
288
290
  newState.expandedKeys = calcExpandedKeysForValues(props.defaultValue, keyEntities, props.multiple, valueEntities);
289
- } else if (!prevProps && props.value) {
291
+ } else if ((!prevProps || !isExpandControlled && dataUpdated) && props.value) {
290
292
  newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
291
293
  }
292
294
 
@@ -109,6 +109,7 @@ export interface NodeListProps {
109
109
  motionKeys: Set<string>;
110
110
  motionType: string;
111
111
  flattenList: FlattenNode[] | undefined;
112
+ searchTargetIsDeep?: boolean;
112
113
  renderTreeNode: (treeNode: FlattenNode, ind?: number, style?: React.CSSProperties) => ReactNode;
113
114
  }
114
115
  export declare type TransitionNodes<T> = Array<T | Array<T>>;
@@ -83,12 +83,13 @@ export default class NodeList extends PureComponent {
83
83
  const {
84
84
  flattenNodes,
85
85
  motionType,
86
+ searchTargetIsDeep,
86
87
  renderTreeNode
87
88
  } = this.props;
88
89
  const {
89
90
  transitionNodes
90
91
  } = this.state;
91
- const mapData = transitionNodes.length ? transitionNodes : flattenNodes;
92
+ const mapData = transitionNodes.length && !searchTargetIsDeep ? transitionNodes : flattenNodes;
92
93
 
93
94
  const options = _mapInstanceProperty(mapData).call(mapData, treeNode => {
94
95
  const isMotionNode = _Array$isArray(treeNode);
@@ -741,7 +741,8 @@ class TreeSelect extends BaseComponent {
741
741
  const {
742
742
  flattenNodes,
743
743
  motionKeys,
744
- motionType
744
+ motionType,
745
+ filteredKeys
745
746
  } = this.state;
746
747
  const {
747
748
  direction
@@ -750,6 +751,7 @@ class TreeSelect extends BaseComponent {
750
751
  virtualize,
751
752
  motionExpand
752
753
  } = this.props;
754
+ const isExpandControlled = ('expandedKeys' in this.props);
753
755
 
754
756
  if (!virtualize || _isEmpty(virtualize)) {
755
757
  return /*#__PURE__*/React.createElement(NodeList, {
@@ -757,6 +759,8 @@ class TreeSelect extends BaseComponent {
757
759
  flattenList: this._flattenNodes,
758
760
  motionKeys: motionExpand ? motionKeys : new _Set([]),
759
761
  motionType: motionType,
762
+ // When motionKeys is empty, but filteredKeys is not empty (that is, the search hits), this situation should be distinguished from ordinary motionKeys
763
+ searchTargetIsDeep: isExpandControlled && motionExpand && _isEmpty(motionKeys) && !_isEmpty(filteredKeys),
760
764
  onMotionEnd: this.onMotionEnd,
761
765
  renderTreeNode: this.renderTreeNode
762
766
  });
@@ -1076,8 +1080,8 @@ class TreeSelect extends BaseComponent {
1076
1080
  notifySelect: (selectKey, bool, node) => {
1077
1081
  this.props.onSelect && this.props.onSelect(selectKey, bool, node);
1078
1082
  },
1079
- notifySearch: input => {
1080
- this.props.onSearch && this.props.onSearch(input);
1083
+ notifySearch: (input, filteredExpandedKeys) => {
1084
+ this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
1081
1085
  },
1082
1086
  cacheFlattenNodes: bool => {
1083
1087
  this._flattenNodes = bool ? cloneDeep(this.state.flattenNodes) : null;