@douyinfe/semi-ui 2.4.1 → 2.6.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 (138) hide show
  1. package/calendar/monthCalendar.tsx +14 -13
  2. package/cascader/__test__/cascader.test.js +24 -0
  3. package/cascader/_story/cascader.stories.js +73 -0
  4. package/cascader/index.tsx +26 -5
  5. package/cascader/item.tsx +25 -5
  6. package/datePicker/_story/v2/FixInputRangeFocus.jsx +25 -0
  7. package/datePicker/_story/v2/index.js +2 -1
  8. package/datePicker/dateInput.tsx +8 -5
  9. package/datePicker/datePicker.tsx +9 -1
  10. package/datePicker/month.tsx +14 -7
  11. package/datePicker/monthsGrid.tsx +17 -5
  12. package/datePicker/navigation.tsx +8 -4
  13. package/datePicker/quickControl.tsx +1 -0
  14. package/datePicker/yearAndMonth.tsx +1 -1
  15. package/dist/css/semi.css +71 -35
  16. package/dist/css/semi.min.css +1 -1
  17. package/dist/umd/semi-ui.js +696 -263
  18. package/dist/umd/semi-ui.js.map +1 -1
  19. package/dist/umd/semi-ui.min.js +1 -1
  20. package/dist/umd/semi-ui.min.js.map +1 -1
  21. package/form/__test__/formApi.test.js +182 -0
  22. package/form/_story/FormApi/arrayDemo.jsx +4 -7
  23. package/form/_story/Layout/slotDemo.jsx +2 -2
  24. package/form/_story/demo.jsx +18 -1
  25. package/form/_story/form.stories.js +6 -6
  26. package/form/baseForm.tsx +2 -2
  27. package/form/hoc/withField.tsx +1 -1
  28. package/lib/cjs/_base/base.css +5 -5
  29. package/lib/cjs/autoComplete/index.d.ts +1 -1
  30. package/lib/cjs/calendar/monthCalendar.js +21 -5
  31. package/lib/cjs/cascader/index.d.ts +9 -2
  32. package/lib/cjs/cascader/index.js +20 -1
  33. package/lib/cjs/cascader/item.d.ts +6 -2
  34. package/lib/cjs/cascader/item.js +33 -4
  35. package/lib/cjs/datePicker/dateInput.d.ts +0 -2
  36. package/lib/cjs/datePicker/dateInput.js +17 -6
  37. package/lib/cjs/datePicker/datePicker.js +19 -12
  38. package/lib/cjs/datePicker/month.d.ts +1 -0
  39. package/lib/cjs/datePicker/month.js +18 -2
  40. package/lib/cjs/datePicker/monthsGrid.js +16 -4
  41. package/lib/cjs/datePicker/navigation.js +8 -0
  42. package/lib/cjs/datePicker/quickControl.js +1 -0
  43. package/lib/cjs/datePicker/yearAndMonth.js +1 -0
  44. package/lib/cjs/dropdown/index.d.ts +1 -1
  45. package/lib/cjs/form/baseForm.d.ts +1 -1
  46. package/lib/cjs/form/baseForm.js +2 -2
  47. package/lib/cjs/form/field.d.ts +1 -1
  48. package/lib/cjs/form/hoc/withField.js +1 -1
  49. package/lib/cjs/scrollList/scrollItem.d.ts +2 -1
  50. package/lib/cjs/scrollList/scrollItem.js +13 -3
  51. package/lib/cjs/select/index.d.ts +3 -3
  52. package/lib/cjs/select/index.js +32 -28
  53. package/lib/cjs/select/option.js +2 -2
  54. package/lib/cjs/select/virtualRow.js +2 -2
  55. package/lib/cjs/table/Table.d.ts +1 -1
  56. package/lib/cjs/table/Table.js +8 -2
  57. package/lib/cjs/table/interface.d.ts +1 -0
  58. package/lib/cjs/tabs/interface.d.ts +1 -1
  59. package/lib/cjs/tooltip/index.d.ts +1 -1
  60. package/lib/cjs/tooltip/index.js +6 -2
  61. package/lib/cjs/tree/index.d.ts +2 -0
  62. package/lib/cjs/tree/index.js +15 -8
  63. package/lib/cjs/treeSelect/index.d.ts +2 -0
  64. package/lib/cjs/treeSelect/index.js +64 -27
  65. package/lib/cjs/upload/fileCard.js +31 -22
  66. package/lib/cjs/upload/index.d.ts +6 -0
  67. package/lib/cjs/upload/index.js +15 -8
  68. package/lib/cjs/upload/interface.d.ts +8 -6
  69. package/lib/es/_base/base.css +5 -5
  70. package/lib/es/autoComplete/index.d.ts +1 -1
  71. package/lib/es/calendar/monthCalendar.js +22 -5
  72. package/lib/es/cascader/index.d.ts +9 -2
  73. package/lib/es/cascader/index.js +19 -1
  74. package/lib/es/cascader/item.d.ts +6 -2
  75. package/lib/es/cascader/item.js +31 -4
  76. package/lib/es/datePicker/dateInput.d.ts +0 -2
  77. package/lib/es/datePicker/dateInput.js +17 -6
  78. package/lib/es/datePicker/datePicker.js +19 -12
  79. package/lib/es/datePicker/month.d.ts +1 -0
  80. package/lib/es/datePicker/month.js +18 -2
  81. package/lib/es/datePicker/monthsGrid.js +16 -4
  82. package/lib/es/datePicker/navigation.js +8 -0
  83. package/lib/es/datePicker/quickControl.js +2 -0
  84. package/lib/es/datePicker/yearAndMonth.js +1 -0
  85. package/lib/es/dropdown/index.d.ts +1 -1
  86. package/lib/es/form/baseForm.d.ts +1 -1
  87. package/lib/es/form/baseForm.js +2 -2
  88. package/lib/es/form/field.d.ts +1 -1
  89. package/lib/es/form/hoc/withField.js +1 -1
  90. package/lib/es/scrollList/scrollItem.d.ts +2 -1
  91. package/lib/es/scrollList/scrollItem.js +13 -3
  92. package/lib/es/select/index.d.ts +3 -3
  93. package/lib/es/select/index.js +30 -26
  94. package/lib/es/select/option.js +2 -2
  95. package/lib/es/select/virtualRow.js +2 -2
  96. package/lib/es/table/Table.d.ts +1 -1
  97. package/lib/es/table/Table.js +10 -2
  98. package/lib/es/table/interface.d.ts +1 -0
  99. package/lib/es/tabs/interface.d.ts +1 -1
  100. package/lib/es/tooltip/index.d.ts +1 -1
  101. package/lib/es/tooltip/index.js +6 -2
  102. package/lib/es/tree/index.d.ts +2 -0
  103. package/lib/es/tree/index.js +15 -8
  104. package/lib/es/treeSelect/index.d.ts +2 -0
  105. package/lib/es/treeSelect/index.js +64 -27
  106. package/lib/es/upload/fileCard.js +31 -24
  107. package/lib/es/upload/index.d.ts +6 -0
  108. package/lib/es/upload/index.js +14 -8
  109. package/lib/es/upload/interface.d.ts +8 -6
  110. package/package.json +9 -9
  111. package/scrollList/_story/ScrollList/index.js +3 -0
  112. package/scrollList/_story/WheelList/index.js +3 -0
  113. package/scrollList/scrollItem.tsx +30 -9
  114. package/select/index.tsx +18 -19
  115. package/select/option.tsx +2 -2
  116. package/select/virtualRow.tsx +2 -2
  117. package/table/Table.tsx +7 -2
  118. package/table/_story/Perf/Virtualized/index.jsx +6 -0
  119. package/table/_story/table.stories.js +1 -2
  120. package/table/_story/v2/FixedHeaderMerge/index.jsx +98 -0
  121. package/table/_story/v2/FixedResizable/index.jsx +114 -0
  122. package/table/_story/v2/defaultFilteredValue.tsx +114 -0
  123. package/table/_story/v2/index.js +5 -0
  124. package/table/interface.ts +1 -0
  125. package/tabs/interface.ts +1 -1
  126. package/tooltip/__test__/tooltip.test.js +48 -4
  127. package/tooltip/_story/tooltip.stories.js +83 -1
  128. package/tooltip/index.tsx +4 -4
  129. package/tree/__test__/treeMultiple.test.js +94 -0
  130. package/tree/_story/tree.stories.js +169 -0
  131. package/tree/index.tsx +12 -5
  132. package/treeSelect/__test__/treeMultiple.test.js +94 -0
  133. package/treeSelect/_story/treeSelect.stories.js +242 -0
  134. package/treeSelect/index.tsx +72 -40
  135. package/upload/_story/upload.stories.js +22 -6
  136. package/upload/fileCard.tsx +23 -23
  137. package/upload/index.tsx +15 -6
  138. package/upload/interface.ts +7 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.4.1",
3
+ "version": "2.6.0-beta.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.4.1",
18
- "@douyinfe/semi-animation-react": "2.4.1",
19
- "@douyinfe/semi-foundation": "2.4.1",
20
- "@douyinfe/semi-icons": "2.4.1",
21
- "@douyinfe/semi-illustrations": "2.4.1",
22
- "@douyinfe/semi-theme-default": "2.4.1",
17
+ "@douyinfe/semi-animation": "2.6.0-beta.0",
18
+ "@douyinfe/semi-animation-react": "2.6.0-beta.0",
19
+ "@douyinfe/semi-foundation": "2.6.0-beta.0",
20
+ "@douyinfe/semi-icons": "2.6.0-beta.0",
21
+ "@douyinfe/semi-illustrations": "2.6.0-beta.0",
22
+ "@douyinfe/semi-theme-default": "2.6.0-beta.0",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "c69c466ecd14aeeda847473e97dad2ec313f09fa",
72
+ "gitHead": "49d107f759f3610a471c34bb9568ad9408aa2cb0",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.4.1",
78
+ "@douyinfe/semi-scss-compile": "2.6.0-beta.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
@@ -43,6 +43,7 @@ class ScrollListDemo extends React.Component {
43
43
  type={1}
44
44
  selectedIndex={this.state.selectIndex1}
45
45
  onSelect={this.onSelect}
46
+ aria-label="1"
46
47
  />
47
48
  <ScrollItem
48
49
  mode="normal"
@@ -50,6 +51,7 @@ class ScrollListDemo extends React.Component {
50
51
  type={2}
51
52
  selectedIndex={this.state.selectIndex2}
52
53
  onSelect={this.onSelect}
54
+ aria-label="2"
53
55
  />
54
56
  <ScrollItem
55
57
  mode="normal"
@@ -57,6 +59,7 @@ class ScrollListDemo extends React.Component {
57
59
  type={3}
58
60
  selectedIndex={this.state.selectIndex3}
59
61
  onSelect={this.onSelect}
62
+ aria-label="3"
60
63
  />
61
64
  </ScrollList>
62
65
  );
@@ -92,6 +92,7 @@ class ScrollListDemo extends React.Component {
92
92
  type={1}
93
93
  selectedIndex={this.state.selectIndex1}
94
94
  onSelect={this.onSelectAP}
95
+ aria-label="时段"
95
96
  />
96
97
  <ScrollItem
97
98
  {...commonProps}
@@ -99,6 +100,7 @@ class ScrollListDemo extends React.Component {
99
100
  type={2}
100
101
  selectedIndex={this.state.selectIndex2}
101
102
  onSelect={this.onSelectHour}
103
+ aria-label="小时"
102
104
  />
103
105
  <ScrollItem
104
106
  {...commonProps}
@@ -106,6 +108,7 @@ class ScrollListDemo extends React.Component {
106
108
  type={3}
107
109
  selectedIndex={this.state.selectIndex3}
108
110
  onSelect={this.onSelectMinute}
111
+ aria-label="分钟"
109
112
  />
110
113
  </ScrollList>
111
114
  </div>
@@ -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 classnames from 'classnames';
@@ -28,6 +28,7 @@ export interface ScrollItemProps<T extends Item> {
28
28
  motion?: Motion;
29
29
  style?: React.CSSProperties;
30
30
  type?: string | number; // used to identify the scrollItem, used internally by the semi component, and does not need to be exposed to the user
31
+ 'aria-label'?: AriaAttributes['aria-label'];
31
32
  }
32
33
 
33
34
  export interface ScrollItemState {
@@ -413,15 +414,15 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
413
414
  const { transform: itemTrans } = item;
414
415
 
415
416
  const transform = typeof itemTrans === 'function' ? itemTrans : commonTrans;
416
-
417
+ const selected = selectedIndex === index;
417
418
  const cls = classnames({
418
- [`${cssClasses.PREFIX}-item-sel`]: selectedIndex === index && mode !== wheelMode,
419
+ [`${cssClasses.PREFIX}-item-sel`]: selected && mode !== wheelMode,
419
420
  [`${cssClasses.PREFIX}-item-disabled`]: Boolean(item.disabled),
420
421
  });
421
422
 
422
423
  let text = '';
423
424
 
424
- if (selectedIndex === index) {
425
+ if (selected) {
425
426
  if (typeof transform === 'function') {
426
427
  text = transform(item.value, item.text);
427
428
  } else {
@@ -441,7 +442,14 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
441
442
 
442
443
  return (
443
444
  // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
444
- <li key={prefixKey + index} {...events} className={cls}>
445
+ <li
446
+ key={prefixKey + index}
447
+ {...events}
448
+ className={cls}
449
+ role="option"
450
+ aria-selected={selected}
451
+ aria-disabled={item.disabled}
452
+ >
445
453
  {text}
446
454
  </li>
447
455
  );
@@ -457,7 +465,14 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
457
465
 
458
466
  return (
459
467
  <div style={style} className={wrapperCls} ref={this._cacheWrapperNode}>
460
- <ul ref={this._cacheListNode}>{inner}</ul>
468
+ <ul
469
+ role="listbox"
470
+ aria-multiselectable={false}
471
+ aria-label={this.props['aria-label']}
472
+ ref={this._cacheListNode}
473
+ >
474
+ {inner}
475
+ </ul>
461
476
  </div>
462
477
  );
463
478
  };
@@ -470,13 +485,13 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
470
485
  const { prependCount, appendCount } = this.state;
471
486
 
472
487
  const prependList = times(prependCount).reduce((arr, num) => {
473
- const items = this.renderItemList(`pre_${ num }_`);
488
+ const items = this.renderItemList(`pre_${num}_`);
474
489
  arr.unshift(...items);
475
490
 
476
491
  return arr;
477
492
  }, []);
478
493
  const appendList = times(appendCount).reduce((arr, num) => {
479
- const items = this.renderItemList(`app_${ num }_`);
494
+ const items = this.renderItemList(`app_${num}_`);
480
495
  arr.push(...items);
481
496
  return arr;
482
497
  }, []);
@@ -500,7 +515,13 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
500
515
  <div className={selectorCls} ref={this._cacheSelectorNode} />
501
516
  <div className={postShadeCls} />
502
517
  <div className={listWrapperCls} ref={this._cacheWrapperNode} onScroll={this.scrollToSelectItem}>
503
- <ul ref={this._cacheListNode} onClick={this.clickToSelectItem}>
518
+ <ul
519
+ role="listbox"
520
+ aria-label={this.props['aria-label']}
521
+ aria-multiselectable={false}
522
+ ref={this._cacheListNode}
523
+ onClick={this.clickToSelectItem}
524
+ >
504
525
  {prependList}
505
526
  {inner}
506
527
  {appendList}
package/select/index.tsx CHANGED
@@ -530,9 +530,13 @@ class Select extends BaseComponent<SelectProps, SelectState> {
530
530
 
531
531
  }
532
532
  },
533
- updateScrollTop: () => {
533
+ updateScrollTop: (index?: number) => {
534
534
  // eslint-disable-next-line max-len
535
- let destNode = document.querySelector(`#${prefixcls}-${this.selectOptionListID} .${prefixcls}-option-selected`) as HTMLDivElement;
535
+ let optionClassName = `.${prefixcls}-option-selected`;
536
+ if (index !== undefined) {
537
+ optionClassName = `.${prefixcls}-option:nth-child(${index})`;
538
+ }
539
+ let destNode = document.querySelector(`#${prefixcls}-${this.selectOptionListID} ${optionClassName}`) as HTMLDivElement;
536
540
  if (Array.isArray(destNode)) {
537
541
  // eslint-disable-next-line prefer-destructuring
538
542
  destNode = destNode[0];
@@ -754,31 +758,26 @@ class Select extends BaseComponent<SelectProps, SelectState> {
754
758
  this.foundation.handleOptionMouseEnter(optionIndex);
755
759
  }
756
760
 
757
- renderWithGroup(visibileOptions: OptionProps[]) {
761
+ renderWithGroup(visibleOptions: OptionProps[]) {
758
762
  const content: JSX.Element[] = [];
759
763
  const groupStatus = new Map();
760
764
 
761
- visibileOptions.forEach((option, optionIndex) => {
765
+ visibleOptions.forEach((option, optionIndex) => {
762
766
  const parentGroup = option._parentGroup;
763
767
  const optionContent = this.renderOption(option, optionIndex);
764
- if (parentGroup && groupStatus.has(parentGroup.label)) {
765
- // group content already insert
766
- content.push(optionContent);
767
- } else if (parentGroup) {
768
+ if (parentGroup && !groupStatus.has(parentGroup.label)) {
769
+ // when use with OptionGroup and group content not already insert
768
770
  const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
769
771
  groupStatus.set(parentGroup.label, true);
770
772
  content.push(groupContent);
771
- content.push(optionContent);
772
- } else {
773
- // when not use with OptionGroup
774
- content.push(optionContent);
775
- }
773
+ }
774
+ content.push(optionContent);
776
775
  });
777
776
 
778
777
  return content;
779
778
  }
780
779
 
781
- renderVirtualizeList(visibileOptions: OptionProps[]) {
780
+ renderVirtualizeList(visibleOptions: OptionProps[]) {
782
781
  const { virtualize } = this.props;
783
782
  const { direction } = this.context;
784
783
  const { height, width, itemSize } = virtualize;
@@ -787,9 +786,9 @@ class Select extends BaseComponent<SelectProps, SelectState> {
787
786
  <List
788
787
  ref={this.virtualizeListRef}
789
788
  height={height || numbers.LIST_HEIGHT}
790
- itemCount={visibileOptions.length}
789
+ itemCount={visibleOptions.length}
791
790
  itemSize={itemSize}
792
- itemData={{ visibileOptions, renderOption: this.renderOption }}
791
+ itemData={{ visibleOptions, renderOption: this.renderOption }}
793
792
  width={width || '100%'}
794
793
  style={{ direction }}
795
794
  >
@@ -814,11 +813,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
814
813
  } = this.props;
815
814
 
816
815
  // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
817
- const visibileOptions = options.filter(item => item._show);
816
+ const visibleOptions = options.filter(item => item._show);
818
817
 
819
- let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(visibileOptions);
818
+ let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(visibleOptions);
820
819
  if (virtualize) {
821
- listContent = this.renderVirtualizeList(visibileOptions);
820
+ listContent = this.renderVirtualizeList(visibleOptions);
822
821
  }
823
822
 
824
823
  const style = { minWidth: dropdownMinWidth, ...dropdownStyle };
package/select/option.tsx CHANGED
@@ -57,8 +57,8 @@ class Option extends PureComponent<OptionProps> {
57
57
 
58
58
  onClick({ value, label, children, ...rest }: Partial<OptionProps>, event: React.MouseEvent) {
59
59
  const { props } = this;
60
- const isDisbled = props.disabled;
61
- if (!isDisbled) {
60
+ const isDisabled = props.disabled;
61
+ if (!isDisabled) {
62
62
  props.onSelect({ ...rest, value, label: label || children }, event);
63
63
  }
64
64
  }
@@ -5,8 +5,8 @@ export interface VirtualRowProps{
5
5
  style?: React.CSSProperties;
6
6
  }
7
7
  const VirtualRow = ({ index, data, style }: VirtualRowProps) => {
8
- const { visibileOptions } = data;
9
- const option = visibileOptions[index];
8
+ const { visibleOptions } = data;
9
+ const option = visibleOptions[index];
10
10
  return data.renderOption(option, index, style);
11
11
  };
12
12
 
package/table/Table.tsx CHANGED
@@ -424,11 +424,12 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
424
424
  willUpdateStates.cachedColumns = props.columns;
425
425
  willUpdateStates.cachedChildren = null;
426
426
  } else if (props.children && props.children !== state.cachedChildren) {
427
- const newFlattenColumns = flattenColumns(getColumns(props.children));
427
+ const newNestedColumns = getColumns(props.children);
428
+ const newFlattenColumns = flattenColumns(newNestedColumns);
428
429
  const columns = mergeColumns(state.queries, newFlattenColumns, null, false);
429
430
  willUpdateStates.flattenColumns = newFlattenColumns;
430
431
  willUpdateStates.queries = [...columns];
431
- willUpdateStates.cachedColumns = [...columns];
432
+ willUpdateStates.cachedColumns = [...newNestedColumns];
432
433
  willUpdateStates.cachedChildren = props.children;
433
434
  }
434
435
 
@@ -943,11 +944,15 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
943
944
  titleArr.push(sorter);
944
945
  }
945
946
 
947
+ const stateFilteredValue = get(curQuery, 'filteredValue');
948
+ const defaultFilteredValue = get(curQuery, 'defaultFilteredValue');
949
+ const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
946
950
  if ((Array.isArray(column.filters) && column.filters.length) || isValidElement(column.filterDropdown)) {
947
951
  const filter = (
948
952
  <ColumnFilter
949
953
  key={strings.DEFAULT_KEY_COLUMN_FILTER}
950
954
  {...curQuery}
955
+ filteredValue={filteredValue}
951
956
  onFilterDropdownVisibleChange={(visible: boolean) => this.foundation.toggleShowFilter(dataIndex, visible)}
952
957
  onSelect={(data: OnSelectData) => this.foundation.handleFilterSelect(dataIndex, data)}
953
958
  />
@@ -9,29 +9,35 @@ class PerfVirtualized extends React.Component {
9
9
  {
10
10
  title: 'A',
11
11
  dataIndex: 'key',
12
+ key: 'a',
12
13
  width: 150,
13
14
  },
14
15
  {
15
16
  title: 'B',
16
17
  dataIndex: 'key',
18
+ key: 'b',
17
19
  },
18
20
  {
19
21
  title: 'C',
20
22
  dataIndex: 'key',
23
+ key: 'c',
21
24
  },
22
25
  {
23
26
  title: 'D',
24
27
  dataIndex: 'key',
28
+ key: 'd',
25
29
  },
26
30
  {
27
31
  title: 'E',
28
32
  dataIndex: 'key',
29
33
  width: 200,
34
+ key: 'e',
30
35
  },
31
36
  {
32
37
  title: 'F',
33
38
  dataIndex: 'key',
34
39
  width: 100,
40
+ key: 'f'
35
41
  },
36
42
  ];
37
43
 
@@ -76,8 +76,7 @@ export { default as ScrollBar } from './ScrollBar';
76
76
  export { default as TableSpan } from './TableSpan';
77
77
  export { default as FixRenderReturnProps } from './FixRenderReturnProps';
78
78
  export { default as WarnColumnWithoutDataIndex } from './WarnColumnWithoutDataIndex';
79
- export { default as FixedColumnsChange } from './v2/FixedColumnsChange';
80
- export { default as FixedZIndex } from './v2/FixedZIndex';
79
+ export * from './v2';
81
80
 
82
81
  // empty table
83
82
 
@@ -0,0 +1,98 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Table, Button } from '@douyinfe/semi-ui';
3
+
4
+ Demo.storyName = "fixed jsx column nested bug";
5
+
6
+
7
+ /**
8
+ * fixed https://github.com/DouyinFE/semi-design/issues/619
9
+ *
10
+ * Test with Cypress
11
+ */
12
+ export default function Demo() {
13
+ const columns = [
14
+ {
15
+ title: 'Base Information',
16
+ fixed: 'left',
17
+ children: [
18
+ {
19
+ title: 'Name',
20
+ dataIndex: 'name',
21
+ width: 200,
22
+ },
23
+ {
24
+ title: 'Age',
25
+ dataIndex: 'age',
26
+ width: 100,
27
+ },
28
+ ],
29
+ },
30
+ {
31
+ title: 'Company Information',
32
+ children: [
33
+ {
34
+ title: 'Company Name',
35
+ dataIndex: 'company.name',
36
+ },
37
+ {
38
+ title: 'Company Address',
39
+ dataIndex: 'company.address',
40
+ },
41
+ ],
42
+ }
43
+ ];
44
+
45
+ const data = useMemo(() => {
46
+ const data = [];
47
+ for (let i = 0; i < 100; i++) {
48
+ let age = (i * 1000) % 149;
49
+ let name = `Edward King ${i}`;
50
+ data.push({
51
+ key: '' + i,
52
+ company: {
53
+ name: 'ByteDance',
54
+ address: 'No. 48, Zhichun Road',
55
+ },
56
+ name,
57
+ age,
58
+ address: `No ${i + 1}, Zhongguancun Street`,
59
+ description: `My name is ${name}, I am ${age} years old, living in No ${i + 1}, Zhongguancun Street`,
60
+ });
61
+ }
62
+ return data;
63
+ }, []);
64
+
65
+ const [flag, setFlag] = React.useState(true);
66
+
67
+ return (
68
+ <>
69
+ <Button data-cy="button" onClick={()=> setFlag(!flag)}>reRender</Button>
70
+ <Table dataSource={data} pagination={true} size="small">
71
+ {columns.map((item, titleIndex) =>
72
+ (
73
+ <Table.Column
74
+ key={titleIndex}
75
+ title={item.title}
76
+ >
77
+ {item.children.map(
78
+ (childItem, columnIndex) =>
79
+ (
80
+ <Table.Column
81
+ title={childItem.title}
82
+ dataIndex={childItem.dataIndex}
83
+ key={titleIndex.toString() + columnIndex.toString()}
84
+ />
85
+ )
86
+ )}
87
+ </Table.Column>
88
+ )
89
+ )}
90
+ <Table.Column
91
+ title=""
92
+ key="lastColumn"
93
+ render={() => 123}
94
+ />
95
+ </Table>
96
+ </>
97
+ );
98
+ }
@@ -0,0 +1,114 @@
1
+ import React, { useState } from 'react';
2
+ import { Table, Avatar, Button, Space } from '@douyinfe/semi-ui';
3
+ import { IconMore } from '@douyinfe/semi-icons';
4
+
5
+ const columns = [
6
+ {
7
+ title: '标题',
8
+ dataIndex: 'name',
9
+ width: 300,
10
+ key: 'name',
11
+ render: (text, record, index) => {
12
+ return (
13
+ <div>
14
+ <Avatar size="small" shape="square" src={record.nameIconSrc} style={{ marginRight: 12 }}></Avatar>
15
+ {text}
16
+ </div>
17
+ );
18
+ },
19
+ },
20
+ {
21
+ title: '大小',
22
+ dataIndex: 'size',
23
+ key: 'size',
24
+ width: 200,
25
+ },
26
+ {
27
+ title: '所有者',
28
+ dataIndex: 'owner',
29
+ key: 'owner',
30
+ width: 200,
31
+ render: (text, record, index) => {
32
+ return (
33
+ <div>
34
+ <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
35
+ {typeof text === 'string' && text.slice(0, 1)}
36
+ </Avatar>
37
+ {text}
38
+ </div>
39
+ );
40
+ },
41
+ },
42
+ {
43
+ title: '更新日期',
44
+ dataIndex: 'updateTime',
45
+ key: 'updateTime',
46
+ width: 200,
47
+ },
48
+ {
49
+ title: '',
50
+ dataIndex: 'operate',
51
+ key: 'operate',
52
+ render: () => {
53
+ return <IconMore />;
54
+ },
55
+ },
56
+ ];
57
+
58
+ /**
59
+ * fix https://github.com/DouyinFE/semi-design/issues/650
60
+ */
61
+ App.storyName = 'fixed resizable column width bug';
62
+ App.parameters = { chromatic: { disableSnapshot: true } };
63
+ function App() {
64
+ const [cols, setCols] = useState(columns);
65
+
66
+ const onClickHandle = () => {
67
+ const localCols = [...cols].filter((i, index) => index !== 1);
68
+ setCols(localCols);
69
+ };
70
+
71
+ const data = [
72
+ {
73
+ key: '1',
74
+ name: 'Semi Design 设计稿.fig',
75
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png',
76
+ size: '2M',
77
+ owner: '姜鹏志',
78
+ updateTime: '2020-02-02 05:13',
79
+ avatarBg: 'grey',
80
+ },
81
+ {
82
+ key: '2',
83
+ name: 'Semi Design 分享演示文稿',
84
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
85
+ size: '2M',
86
+ owner: '郝宣',
87
+ updateTime: '2020-01-17 05:31',
88
+ avatarBg: 'red',
89
+ },
90
+ {
91
+ key: '3',
92
+ name: '设计文档',
93
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
94
+ size: '34KB',
95
+ owner: 'Zoey Edwards',
96
+ updateTime: '2020-01-26 11:01',
97
+ avatarBg: 'light-blue',
98
+ },
99
+ ];
100
+
101
+ return (
102
+ <>
103
+ <Space>
104
+ <Button onClick={onClickHandle}>减少一列</Button>
105
+ <Button theme="solid" onClick={() => setCols(columns)}>
106
+ reset
107
+ </Button>
108
+ </Space>
109
+ <Table columns={cols} dataSource={data} pagination={false} resizable />
110
+ </>
111
+ );
112
+ }
113
+
114
+ export default App;