@douyinfe/semi-ui 2.5.0-beta.0 → 2.5.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.
@@ -434,6 +434,10 @@ class DatePicker extends _baseComponent.default {
434
434
 
435
435
  if (prevProps.open !== this.props.open) {
436
436
  this.foundation.initPanelOpenStatus();
437
+
438
+ if (!this.props.open) {
439
+ this.foundation.clearRangeInputFocus();
440
+ }
437
441
  }
438
442
  }
439
443
 
@@ -243,8 +243,8 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
243
243
  renderOption(option: OptionProps, optionIndex: number, style?: React.CSSProperties): any;
244
244
  renderCreateOption(option: OptionProps, isFocused: boolean, optionIndex: number, style: React.CSSProperties): JSX.Element;
245
245
  onOptionHover(optionIndex: number): void;
246
- renderWithGroup(visibileOptions: OptionProps[]): JSX.Element[];
247
- renderVirtualizeList(visibileOptions: OptionProps[]): JSX.Element;
246
+ renderWithGroup(visibleOptions: OptionProps[]): JSX.Element[];
247
+ renderVirtualizeList(visibleOptions: OptionProps[]): JSX.Element;
248
248
  renderOptions(children?: React.ReactNode): JSX.Element;
249
249
  renderSingleSelection(selections: Map<OptionProps['label'], any>, filterable: boolean): JSX.Element;
250
250
  renderMultipleSelection(selections: Map<OptionProps['label'], any>, filterable: boolean): JSX.Element;
@@ -56,7 +56,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
56
56
 
57
57
  var _propTypes = _interopRequireDefault(require("prop-types"));
58
58
 
59
- var _context15 = _interopRequireDefault(require("../configProvider/context"));
59
+ var _context16 = _interopRequireDefault(require("../configProvider/context"));
60
60
 
61
61
  var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/select/foundation"));
62
62
 
@@ -347,11 +347,19 @@ class Select extends _baseComponent.default {
347
347
  el.focus();
348
348
  } catch (error) {}
349
349
  },
350
- updateScrollTop: () => {
351
- var _context9, _context10;
350
+ updateScrollTop: index => {
351
+ var _context10, _context11;
352
352
 
353
353
  // eslint-disable-next-line max-len
354
- let destNode = document.querySelector((0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "#".concat(prefixcls, "-")).call(_context10, this.selectOptionListID, " .")).call(_context9, prefixcls, "-option-selected"));
354
+ let optionClassName = ".".concat(prefixcls, "-option-selected");
355
+
356
+ if (index !== undefined) {
357
+ var _context9;
358
+
359
+ optionClassName = (0, _concat.default)(_context9 = ".".concat(prefixcls, "-option:nth-child(")).call(_context9, index, ")");
360
+ }
361
+
362
+ let destNode = document.querySelector((0, _concat.default)(_context10 = (0, _concat.default)(_context11 = "#".concat(prefixcls, "-")).call(_context11, this.selectOptionListID, " ")).call(_context10, optionClassName));
355
363
 
356
364
  if ((0, _isArray.default)(destNode)) {
357
365
  // eslint-disable-next-line prefer-destructuring
@@ -379,10 +387,10 @@ class Select extends _baseComponent.default {
379
387
  }
380
388
 
381
389
  componentDidUpdate(prevProps, prevState) {
382
- var _context11, _context12;
390
+ var _context12, _context13;
383
391
 
384
- const prevChildrenKeys = (0, _map2.default)(_context11 = _react.default.Children.toArray(prevProps.children)).call(_context11, child => child.key);
385
- const nowChildrenKeys = (0, _map2.default)(_context12 = _react.default.Children.toArray(this.props.children)).call(_context12, child => child.key);
392
+ const prevChildrenKeys = (0, _map2.default)(_context12 = _react.default.Children.toArray(prevProps.children)).call(_context12, child => child.key);
393
+ const nowChildrenKeys = (0, _map2.default)(_context13 = _react.default.Children.toArray(this.props.children)).call(_context13, child => child.key);
386
394
  let isOptionsChanged = false;
387
395
 
388
396
  if (!(0, _isEqual2.default)(prevChildrenKeys, nowChildrenKeys) || !(0, _isEqual2.default)(prevProps.optionList, this.props.optionList)) {
@@ -572,33 +580,29 @@ class Select extends _baseComponent.default {
572
580
  this.foundation.handleOptionMouseEnter(optionIndex);
573
581
  }
574
582
 
575
- renderWithGroup(visibileOptions) {
583
+ renderWithGroup(visibleOptions) {
576
584
  const content = [];
577
585
  const groupStatus = new _map.default();
578
- (0, _forEach.default)(visibileOptions).call(visibileOptions, (option, optionIndex) => {
586
+ (0, _forEach.default)(visibleOptions).call(visibleOptions, (option, optionIndex) => {
579
587
  const parentGroup = option._parentGroup;
580
588
  const optionContent = this.renderOption(option, optionIndex);
581
589
 
582
- if (parentGroup && groupStatus.has(parentGroup.label)) {
583
- // group content already insert
584
- content.push(optionContent);
585
- } else if (parentGroup) {
590
+ if (parentGroup && !groupStatus.has(parentGroup.label)) {
591
+ // when use with OptionGroup and group content not already insert
586
592
  const groupContent = /*#__PURE__*/_react.default.createElement(_optionGroup.default, (0, _assign.default)({}, parentGroup, {
587
593
  key: parentGroup.label
588
594
  }));
589
595
 
590
596
  groupStatus.set(parentGroup.label, true);
591
597
  content.push(groupContent);
592
- content.push(optionContent);
593
- } else {
594
- // when not use with OptionGroup
595
- content.push(optionContent);
596
598
  }
599
+
600
+ content.push(optionContent);
597
601
  });
598
602
  return content;
599
603
  }
600
604
 
601
- renderVirtualizeList(visibileOptions) {
605
+ renderVirtualizeList(visibleOptions) {
602
606
  const {
603
607
  virtualize
604
608
  } = this.props;
@@ -613,10 +617,10 @@ class Select extends _baseComponent.default {
613
617
  return /*#__PURE__*/_react.default.createElement(_reactWindow.FixedSizeList, {
614
618
  ref: this.virtualizeListRef,
615
619
  height: height || _constants.numbers.LIST_HEIGHT,
616
- itemCount: visibileOptions.length,
620
+ itemCount: visibleOptions.length,
617
621
  itemSize: itemSize,
618
622
  itemData: {
619
- visibileOptions,
623
+ visibleOptions,
620
624
  renderOption: this.renderOption
621
625
  },
622
626
  width: width || '100%',
@@ -627,7 +631,7 @@ class Select extends _baseComponent.default {
627
631
  }
628
632
 
629
633
  renderOptions(children) {
630
- var _context13;
634
+ var _context14;
631
635
 
632
636
  const {
633
637
  dropdownMinWidth,
@@ -647,11 +651,11 @@ class Select extends _baseComponent.default {
647
651
  multiple
648
652
  } = this.props; // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
649
653
 
650
- const visibileOptions = (0, _filter.default)(options).call(options, item => item._show);
651
- let listContent = this.renderWithGroup(visibileOptions);
654
+ const visibleOptions = (0, _filter.default)(options).call(options, item => item._show);
655
+ let listContent = this.renderWithGroup(visibleOptions);
652
656
 
653
657
  if (virtualize) {
654
- listContent = this.renderVirtualizeList(visibileOptions);
658
+ listContent = this.renderVirtualizeList(visibleOptions);
655
659
  }
656
660
 
657
661
  const style = (0, _assign.default)({
@@ -663,7 +667,7 @@ class Select extends _baseComponent.default {
663
667
  });
664
668
  const isEmpty = !options.length || !(0, _some.default)(options).call(options, item => item._show);
665
669
  return /*#__PURE__*/_react.default.createElement("div", {
666
- id: (0, _concat.default)(_context13 = "".concat(prefixcls, "-")).call(_context13, this.selectOptionListID),
670
+ id: (0, _concat.default)(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
667
671
  className: dropdownClassName,
668
672
  style: style
669
673
  }, outerTopSlot, /*#__PURE__*/_react.default.createElement("div", {
@@ -891,7 +895,7 @@ class Select extends _baseComponent.default {
891
895
  }
892
896
 
893
897
  renderSelection() {
894
- var _context14;
898
+ var _context15;
895
899
 
896
900
  const {
897
901
  disabled,
@@ -975,7 +979,7 @@ class Select extends _baseComponent.default {
975
979
  role: "combobox",
976
980
  "aria-disabled": disabled,
977
981
  "aria-expanded": isOpen,
978
- "aria-controls": (0, _concat.default)(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
982
+ "aria-controls": (0, _concat.default)(_context15 = "".concat(prefixcls, "-")).call(_context15, this.selectOptionListID),
979
983
  "aria-haspopup": "listbox",
980
984
  "aria-label": "select value",
981
985
  "aria-invalid": this.props['aria-invalid'],
@@ -1042,7 +1046,7 @@ class Select extends _baseComponent.default {
1042
1046
 
1043
1047
  }
1044
1048
 
1045
- Select.contextType = _context15.default;
1049
+ Select.contextType = _context16.default;
1046
1050
  Select.Option = _option.default;
1047
1051
  Select.OptGroup = _optionGroup.default;
1048
1052
  Select.propTypes = {
@@ -15,9 +15,9 @@ const VirtualRow = _ref => {
15
15
  style
16
16
  } = _ref;
17
17
  const {
18
- visibileOptions
18
+ visibleOptions
19
19
  } = data;
20
- const option = visibileOptions[index];
20
+ const option = visibleOptions[index];
21
21
  return data.renderOption(option, index, style);
22
22
  };
23
23
 
@@ -484,11 +484,15 @@ class Tooltip extends _baseComponent.default {
484
484
  }
485
485
  };
486
486
 
487
- document.addEventListener('click', this.clickOutsideHandler, false);
487
+ document.addEventListener('mousedown', this.clickOutsideHandler, {
488
+ capture: true
489
+ });
488
490
  },
489
491
  unregisterClickOutsideHandler: () => {
490
492
  if (this.clickOutsideHandler) {
491
- document.removeEventListener('click', this.clickOutsideHandler, false);
493
+ document.removeEventListener('mousedown', this.clickOutsideHandler, {
494
+ capture: true
495
+ });
492
496
  this.clickOutsideHandler = null;
493
497
  }
494
498
  },
@@ -401,6 +401,10 @@ export default class DatePicker extends BaseComponent {
401
401
 
402
402
  if (prevProps.open !== this.props.open) {
403
403
  this.foundation.initPanelOpenStatus();
404
+
405
+ if (!this.props.open) {
406
+ this.foundation.clearRangeInputFocus();
407
+ }
404
408
  }
405
409
  }
406
410
 
@@ -243,8 +243,8 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
243
243
  renderOption(option: OptionProps, optionIndex: number, style?: React.CSSProperties): any;
244
244
  renderCreateOption(option: OptionProps, isFocused: boolean, optionIndex: number, style: React.CSSProperties): JSX.Element;
245
245
  onOptionHover(optionIndex: number): void;
246
- renderWithGroup(visibileOptions: OptionProps[]): JSX.Element[];
247
- renderVirtualizeList(visibileOptions: OptionProps[]): JSX.Element;
246
+ renderWithGroup(visibleOptions: OptionProps[]): JSX.Element[];
247
+ renderVirtualizeList(visibleOptions: OptionProps[]): JSX.Element;
248
248
  renderOptions(children?: React.ReactNode): JSX.Element;
249
249
  renderSingleSelection(selections: Map<OptionProps['label'], any>, filterable: boolean): JSX.Element;
250
250
  renderMultipleSelection(selections: Map<OptionProps['label'], any>, filterable: boolean): JSX.Element;
@@ -285,11 +285,19 @@ class Select extends BaseComponent {
285
285
  el.focus();
286
286
  } catch (error) {}
287
287
  },
288
- updateScrollTop: () => {
289
- var _context9, _context10;
288
+ updateScrollTop: index => {
289
+ var _context10, _context11;
290
290
 
291
291
  // eslint-disable-next-line max-len
292
- let destNode = document.querySelector(_concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "#".concat(prefixcls, "-")).call(_context10, this.selectOptionListID, " .")).call(_context9, prefixcls, "-option-selected"));
292
+ let optionClassName = ".".concat(prefixcls, "-option-selected");
293
+
294
+ if (index !== undefined) {
295
+ var _context9;
296
+
297
+ optionClassName = _concatInstanceProperty(_context9 = ".".concat(prefixcls, "-option:nth-child(")).call(_context9, index, ")");
298
+ }
299
+
300
+ let destNode = document.querySelector(_concatInstanceProperty(_context10 = _concatInstanceProperty(_context11 = "#".concat(prefixcls, "-")).call(_context11, this.selectOptionListID, " ")).call(_context10, optionClassName));
293
301
 
294
302
  if (_Array$isArray(destNode)) {
295
303
  // eslint-disable-next-line prefer-destructuring
@@ -317,11 +325,11 @@ class Select extends BaseComponent {
317
325
  }
318
326
 
319
327
  componentDidUpdate(prevProps, prevState) {
320
- var _context11, _context12;
328
+ var _context12, _context13;
321
329
 
322
- const prevChildrenKeys = _mapInstanceProperty(_context11 = React.Children.toArray(prevProps.children)).call(_context11, child => child.key);
330
+ const prevChildrenKeys = _mapInstanceProperty(_context12 = React.Children.toArray(prevProps.children)).call(_context12, child => child.key);
323
331
 
324
- const nowChildrenKeys = _mapInstanceProperty(_context12 = React.Children.toArray(this.props.children)).call(_context12, child => child.key);
332
+ const nowChildrenKeys = _mapInstanceProperty(_context13 = React.Children.toArray(this.props.children)).call(_context13, child => child.key);
325
333
 
326
334
  let isOptionsChanged = false;
327
335
 
@@ -515,34 +523,30 @@ class Select extends BaseComponent {
515
523
  this.foundation.handleOptionMouseEnter(optionIndex);
516
524
  }
517
525
 
518
- renderWithGroup(visibileOptions) {
526
+ renderWithGroup(visibleOptions) {
519
527
  const content = [];
520
528
  const groupStatus = new _Map();
521
529
 
522
- _forEachInstanceProperty(visibileOptions).call(visibileOptions, (option, optionIndex) => {
530
+ _forEachInstanceProperty(visibleOptions).call(visibleOptions, (option, optionIndex) => {
523
531
  const parentGroup = option._parentGroup;
524
532
  const optionContent = this.renderOption(option, optionIndex);
525
533
 
526
- if (parentGroup && groupStatus.has(parentGroup.label)) {
527
- // group content already insert
528
- content.push(optionContent);
529
- } else if (parentGroup) {
534
+ if (parentGroup && !groupStatus.has(parentGroup.label)) {
535
+ // when use with OptionGroup and group content not already insert
530
536
  const groupContent = /*#__PURE__*/React.createElement(OptionGroup, _Object$assign({}, parentGroup, {
531
537
  key: parentGroup.label
532
538
  }));
533
539
  groupStatus.set(parentGroup.label, true);
534
540
  content.push(groupContent);
535
- content.push(optionContent);
536
- } else {
537
- // when not use with OptionGroup
538
- content.push(optionContent);
539
541
  }
542
+
543
+ content.push(optionContent);
540
544
  });
541
545
 
542
546
  return content;
543
547
  }
544
548
 
545
- renderVirtualizeList(visibileOptions) {
549
+ renderVirtualizeList(visibleOptions) {
546
550
  const {
547
551
  virtualize
548
552
  } = this.props;
@@ -557,10 +561,10 @@ class Select extends BaseComponent {
557
561
  return /*#__PURE__*/React.createElement(List, {
558
562
  ref: this.virtualizeListRef,
559
563
  height: height || numbers.LIST_HEIGHT,
560
- itemCount: visibileOptions.length,
564
+ itemCount: visibleOptions.length,
561
565
  itemSize: itemSize,
562
566
  itemData: {
563
- visibileOptions,
567
+ visibleOptions,
564
568
  renderOption: this.renderOption
565
569
  },
566
570
  width: width || '100%',
@@ -571,7 +575,7 @@ class Select extends BaseComponent {
571
575
  }
572
576
 
573
577
  renderOptions(children) {
574
- var _context13;
578
+ var _context14;
575
579
 
576
580
  const {
577
581
  dropdownMinWidth,
@@ -591,12 +595,12 @@ class Select extends BaseComponent {
591
595
  multiple
592
596
  } = this.props; // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
593
597
 
594
- const visibileOptions = _filterInstanceProperty(options).call(options, item => item._show);
598
+ const visibleOptions = _filterInstanceProperty(options).call(options, item => item._show);
595
599
 
596
- let listContent = this.renderWithGroup(visibileOptions);
600
+ let listContent = this.renderWithGroup(visibleOptions);
597
601
 
598
602
  if (virtualize) {
599
- listContent = this.renderVirtualizeList(visibileOptions);
603
+ listContent = this.renderVirtualizeList(visibleOptions);
600
604
  }
601
605
 
602
606
  const style = _Object$assign({
@@ -609,7 +613,7 @@ class Select extends BaseComponent {
609
613
  });
610
614
  const isEmpty = !options.length || !_someInstanceProperty(options).call(options, item => item._show);
611
615
  return /*#__PURE__*/React.createElement("div", {
612
- id: _concatInstanceProperty(_context13 = "".concat(prefixcls, "-")).call(_context13, this.selectOptionListID),
616
+ id: _concatInstanceProperty(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
613
617
  className: dropdownClassName,
614
618
  style: style
615
619
  }, outerTopSlot, /*#__PURE__*/React.createElement("div", {
@@ -840,7 +844,7 @@ class Select extends BaseComponent {
840
844
  }
841
845
 
842
846
  renderSelection() {
843
- var _context14;
847
+ var _context15;
844
848
 
845
849
  const {
846
850
  disabled,
@@ -924,7 +928,7 @@ class Select extends BaseComponent {
924
928
  role: "combobox",
925
929
  "aria-disabled": disabled,
926
930
  "aria-expanded": isOpen,
927
- "aria-controls": _concatInstanceProperty(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
931
+ "aria-controls": _concatInstanceProperty(_context15 = "".concat(prefixcls, "-")).call(_context15, this.selectOptionListID),
928
932
  "aria-haspopup": "listbox",
929
933
  "aria-label": "select value",
930
934
  "aria-invalid": this.props['aria-invalid'],
@@ -5,9 +5,9 @@ const VirtualRow = _ref => {
5
5
  style
6
6
  } = _ref;
7
7
  const {
8
- visibileOptions
8
+ visibleOptions
9
9
  } = data;
10
- const option = visibileOptions[index];
10
+ const option = visibleOptions[index];
11
11
  return data.renderOption(option, index, style);
12
12
  };
13
13
 
@@ -443,11 +443,15 @@ export default class Tooltip extends BaseComponent {
443
443
  }
444
444
  };
445
445
 
446
- document.addEventListener('click', this.clickOutsideHandler, false);
446
+ document.addEventListener('mousedown', this.clickOutsideHandler, {
447
+ capture: true
448
+ });
447
449
  },
448
450
  unregisterClickOutsideHandler: () => {
449
451
  if (this.clickOutsideHandler) {
450
- document.removeEventListener('click', this.clickOutsideHandler, false);
452
+ document.removeEventListener('mousedown', this.clickOutsideHandler, {
453
+ capture: true
454
+ });
451
455
  this.clickOutsideHandler = null;
452
456
  }
453
457
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.5.0-beta.0",
3
+ "version": "2.5.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.5.0-beta.0",
18
- "@douyinfe/semi-animation-react": "2.5.0-beta.0",
19
- "@douyinfe/semi-foundation": "2.5.0-beta.0",
20
- "@douyinfe/semi-icons": "2.5.0-beta.0",
21
- "@douyinfe/semi-illustrations": "2.5.0-beta.0",
22
- "@douyinfe/semi-theme-default": "2.5.0-beta.0",
17
+ "@douyinfe/semi-animation": "2.5.0",
18
+ "@douyinfe/semi-animation-react": "2.5.0",
19
+ "@douyinfe/semi-foundation": "2.5.0",
20
+ "@douyinfe/semi-icons": "2.5.0",
21
+ "@douyinfe/semi-illustrations": "2.5.0",
22
+ "@douyinfe/semi-theme-default": "2.5.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": "d71dddacba0c96004c19103f2e0d3cb59ac52857",
72
+ "gitHead": "856255d8b5ad895a5fee47c5920aa1835836aff0",
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.5.0-beta.0",
78
+ "@douyinfe/semi-scss-compile": "2.5.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
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 };
@@ -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
 
@@ -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;