@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.
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { DatePicker, Button } from '../../../index';
3
+
4
+ /**
5
+ * fix gitlab #1375
6
+ */
7
+ App.storyName = 'fixed input range focus';
8
+ export default function App() {
9
+ const [visible, setVisible] = React.useState(false);
10
+ return (
11
+ <div>
12
+ {/* <Button onClick={() => { setVisible(false); }}>关闭</Button> */}
13
+ <DatePicker
14
+ type="dateTimeRange"
15
+ bottomSlot={<Button onClick={() => { setVisible(false); }}>关闭</Button>}
16
+ onFocus={() => {
17
+ console.log('focus');
18
+ setVisible(true);
19
+ }}
20
+ open={visible}
21
+ showClear
22
+ />
23
+ </div>
24
+ );
25
+ }
@@ -1,2 +1,3 @@
1
1
  export { default as YearButton } from './YearButton';
2
- export { default as PanelOpen } from './PanelOpen';
2
+ export { default as PanelOpen } from './PanelOpen';
3
+ export { default as FixInputRangeFocus } from './FixInputRangeFocus';
@@ -331,6 +331,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
331
331
 
332
332
  if (prevProps.open !== this.props.open) {
333
333
  this.foundation.initPanelOpenStatus();
334
+ if (!this.props.open) {
335
+ this.foundation.clearRangeInputFocus();
336
+ }
334
337
  }
335
338
  }
336
339
 
@@ -27154,11 +27154,15 @@ class tooltip_Tooltip extends baseComponent_BaseComponent {
27154
27154
  }
27155
27155
  };
27156
27156
 
27157
- document.addEventListener('click', this.clickOutsideHandler, false);
27157
+ document.addEventListener('mousedown', this.clickOutsideHandler, {
27158
+ capture: true
27159
+ });
27158
27160
  },
27159
27161
  unregisterClickOutsideHandler: () => {
27160
27162
  if (this.clickOutsideHandler) {
27161
- document.removeEventListener('click', this.clickOutsideHandler, false);
27163
+ document.removeEventListener('mousedown', this.clickOutsideHandler, {
27164
+ capture: true
27165
+ });
27162
27166
  this.clickOutsideHandler = null;
27163
27167
  }
27164
27168
  },
@@ -52780,6 +52784,24 @@ function getDefaultFormatTokenByType(type) {
52780
52784
  class foundation_DatePickerFoundation extends foundation {
52781
52785
  constructor(adapter) {
52782
52786
  super(assign_default()({}, adapter));
52787
+ /**
52788
+ * clear range input focus when open is controlled
52789
+ * fixed github 1375
52790
+ */
52791
+
52792
+ this.clearRangeInputFocus = () => {
52793
+ const {
52794
+ type
52795
+ } = this._adapter.getProps();
52796
+
52797
+ const {
52798
+ rangeInputFocus
52799
+ } = this._adapter.getStates();
52800
+
52801
+ if (type === 'dateTimeRange' && rangeInputFocus) {
52802
+ this._adapter.setRangeInputFocus(false);
52803
+ }
52804
+ };
52783
52805
 
52784
52806
  this.getMergedMotion = motion => {
52785
52807
  const mergedMotion = typeof motion === 'undefined' || motion ? assign_default()(assign_default()({}, motion), {
@@ -59876,6 +59898,10 @@ class datePicker_DatePicker extends baseComponent_BaseComponent {
59876
59898
 
59877
59899
  if (prevProps.open !== this.props.open) {
59878
59900
  this.foundation.initPanelOpenStatus();
59901
+
59902
+ if (!this.props.open) {
59903
+ this.foundation.clearRangeInputFocus();
59904
+ }
59879
59905
  }
59880
59906
  }
59881
59907
 
@@ -72424,8 +72450,9 @@ class foundation_SelectFoundation extends foundation {
72424
72450
  } // console.log('new:' + index);
72425
72451
 
72426
72452
 
72427
- this._adapter.updateFocusIndex(index); // TODO requires scrollIntoView
72453
+ this._adapter.updateFocusIndex(index);
72428
72454
 
72455
+ this._adapter.updateScrollTop(index);
72429
72456
  }
72430
72457
 
72431
72458
  _handleArrowKeyDown(offset) {
@@ -72987,9 +73014,9 @@ const VirtualRow = _ref => {
72987
73014
  style
72988
73015
  } = _ref;
72989
73016
  const {
72990
- visibileOptions
73017
+ visibleOptions
72991
73018
  } = data;
72992
- const option = visibileOptions[index];
73019
+ const option = visibleOptions[index];
72993
73020
  return data.renderOption(option, index, style);
72994
73021
  };
72995
73022
 
@@ -73327,11 +73354,19 @@ class select_Select extends baseComponent_BaseComponent {
73327
73354
  el.focus();
73328
73355
  } catch (error) {}
73329
73356
  },
73330
- updateScrollTop: () => {
73331
- var _context9, _context10;
73357
+ updateScrollTop: index => {
73358
+ var _context10, _context11;
73332
73359
 
73333
73360
  // eslint-disable-next-line max-len
73334
- let destNode = document.querySelector(concat_default()(_context9 = concat_default()(_context10 = "#".concat(select_prefixcls, "-")).call(_context10, this.selectOptionListID, " .")).call(_context9, select_prefixcls, "-option-selected"));
73361
+ let optionClassName = ".".concat(select_prefixcls, "-option-selected");
73362
+
73363
+ if (index !== undefined) {
73364
+ var _context9;
73365
+
73366
+ optionClassName = concat_default()(_context9 = ".".concat(select_prefixcls, "-option:nth-child(")).call(_context9, index, ")");
73367
+ }
73368
+
73369
+ let destNode = document.querySelector(concat_default()(_context10 = concat_default()(_context11 = "#".concat(select_prefixcls, "-")).call(_context11, this.selectOptionListID, " ")).call(_context10, optionClassName));
73335
73370
 
73336
73371
  if (is_array_default()(destNode)) {
73337
73372
  // eslint-disable-next-line prefer-destructuring
@@ -73359,11 +73394,11 @@ class select_Select extends baseComponent_BaseComponent {
73359
73394
  }
73360
73395
 
73361
73396
  componentDidUpdate(prevProps, prevState) {
73362
- var _context11, _context12;
73397
+ var _context12, _context13;
73363
73398
 
73364
- const prevChildrenKeys = map_default()(_context11 = external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.Children.toArray(prevProps.children)).call(_context11, child => child.key);
73399
+ const prevChildrenKeys = map_default()(_context12 = external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.Children.toArray(prevProps.children)).call(_context12, child => child.key);
73365
73400
 
73366
- const nowChildrenKeys = map_default()(_context12 = external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.Children.toArray(this.props.children)).call(_context12, child => child.key);
73401
+ const nowChildrenKeys = map_default()(_context13 = external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.Children.toArray(this.props.children)).call(_context13, child => child.key);
73367
73402
 
73368
73403
  let isOptionsChanged = false;
73369
73404
 
@@ -73557,34 +73592,30 @@ class select_Select extends baseComponent_BaseComponent {
73557
73592
  this.foundation.handleOptionMouseEnter(optionIndex);
73558
73593
  }
73559
73594
 
73560
- renderWithGroup(visibileOptions) {
73595
+ renderWithGroup(visibleOptions) {
73561
73596
  const content = [];
73562
73597
  const groupStatus = new core_js_stable_map_default.a();
73563
73598
 
73564
- for_each_default()(visibileOptions).call(visibileOptions, (option, optionIndex) => {
73599
+ for_each_default()(visibleOptions).call(visibleOptions, (option, optionIndex) => {
73565
73600
  const parentGroup = option._parentGroup;
73566
73601
  const optionContent = this.renderOption(option, optionIndex);
73567
73602
 
73568
- if (parentGroup && groupStatus.has(parentGroup.label)) {
73569
- // group content already insert
73570
- content.push(optionContent);
73571
- } else if (parentGroup) {
73603
+ if (parentGroup && !groupStatus.has(parentGroup.label)) {
73604
+ // when use with OptionGroup and group content not already insert
73572
73605
  const groupContent = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement(optionGroup, assign_default()({}, parentGroup, {
73573
73606
  key: parentGroup.label
73574
73607
  }));
73575
73608
  groupStatus.set(parentGroup.label, true);
73576
73609
  content.push(groupContent);
73577
- content.push(optionContent);
73578
- } else {
73579
- // when not use with OptionGroup
73580
- content.push(optionContent);
73581
73610
  }
73611
+
73612
+ content.push(optionContent);
73582
73613
  });
73583
73614
 
73584
73615
  return content;
73585
73616
  }
73586
73617
 
73587
- renderVirtualizeList(visibileOptions) {
73618
+ renderVirtualizeList(visibleOptions) {
73588
73619
  const {
73589
73620
  virtualize
73590
73621
  } = this.props;
@@ -73599,10 +73630,10 @@ class select_Select extends baseComponent_BaseComponent {
73599
73630
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement(FixedSizeList, {
73600
73631
  ref: this.virtualizeListRef,
73601
73632
  height: height || select_constants_numbers.LIST_HEIGHT,
73602
- itemCount: visibileOptions.length,
73633
+ itemCount: visibleOptions.length,
73603
73634
  itemSize: itemSize,
73604
73635
  itemData: {
73605
- visibileOptions,
73636
+ visibleOptions,
73606
73637
  renderOption: this.renderOption
73607
73638
  },
73608
73639
  width: width || '100%',
@@ -73613,7 +73644,7 @@ class select_Select extends baseComponent_BaseComponent {
73613
73644
  }
73614
73645
 
73615
73646
  renderOptions(children) {
73616
- var _context13;
73647
+ var _context14;
73617
73648
 
73618
73649
  const {
73619
73650
  dropdownMinWidth,
@@ -73633,12 +73664,12 @@ class select_Select extends baseComponent_BaseComponent {
73633
73664
  multiple
73634
73665
  } = this.props; // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
73635
73666
 
73636
- const visibileOptions = filter_default()(options).call(options, item => item._show);
73667
+ const visibleOptions = filter_default()(options).call(options, item => item._show);
73637
73668
 
73638
- let listContent = this.renderWithGroup(visibileOptions);
73669
+ let listContent = this.renderWithGroup(visibleOptions);
73639
73670
 
73640
73671
  if (virtualize) {
73641
- listContent = this.renderVirtualizeList(visibileOptions);
73672
+ listContent = this.renderVirtualizeList(visibleOptions);
73642
73673
  }
73643
73674
 
73644
73675
  const style = assign_default()({
@@ -73651,7 +73682,7 @@ class select_Select extends baseComponent_BaseComponent {
73651
73682
  });
73652
73683
  const isEmpty = !options.length || !some_default()(options).call(options, item => item._show);
73653
73684
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("div", {
73654
- id: concat_default()(_context13 = "".concat(select_prefixcls, "-")).call(_context13, this.selectOptionListID),
73685
+ id: concat_default()(_context14 = "".concat(select_prefixcls, "-")).call(_context14, this.selectOptionListID),
73655
73686
  className: dropdownClassName,
73656
73687
  style: style
73657
73688
  }, outerTopSlot, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("div", {
@@ -73882,7 +73913,7 @@ class select_Select extends baseComponent_BaseComponent {
73882
73913
  }
73883
73914
 
73884
73915
  renderSelection() {
73885
- var _context14;
73916
+ var _context15;
73886
73917
 
73887
73918
  const {
73888
73919
  disabled,
@@ -73966,7 +73997,7 @@ class select_Select extends baseComponent_BaseComponent {
73966
73997
  role: "combobox",
73967
73998
  "aria-disabled": disabled,
73968
73999
  "aria-expanded": isOpen,
73969
- "aria-controls": concat_default()(_context14 = "".concat(select_prefixcls, "-")).call(_context14, this.selectOptionListID),
74000
+ "aria-controls": concat_default()(_context15 = "".concat(select_prefixcls, "-")).call(_context15, this.selectOptionListID),
73970
74001
  "aria-haspopup": "listbox",
73971
74002
  "aria-label": "select value",
73972
74003
  "aria-invalid": this.props['aria-invalid'],
@@ -80215,7 +80246,10 @@ function assignColumnKeys(columns) {
80215
80246
  if (column.key == null) {
80216
80247
  var _context4;
80217
80248
 
80218
- column.key = concat_default()(_context4 = "".concat(level, "-")).call(_context4, index);
80249
+ // if user give column a dataIndex, use it for backup
80250
+ const _index = column.dataIndex || index;
80251
+
80252
+ column.key = concat_default()(_context4 = "".concat(level, "-")).call(_context4, _index);
80219
80253
  }
80220
80254
 
80221
80255
  if (is_array_default()(column[childrenColumnName]) && column[childrenColumnName].length) {