@douyinfe/semi-ui 2.25.2 → 2.26.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.
@@ -24156,6 +24156,10 @@ const getRenderText = function (originEle, rows) {
24156
24156
  let ellipsisPos // eslint-disable-next-line max-params
24157
24157
  = arguments.length > 6 ? arguments[6] : undefined;
24158
24158
 
24159
+ if (content.length === 0) {
24160
+ return '';
24161
+ }
24162
+
24159
24163
  if (!ellipsisContainer) {
24160
24164
  ellipsisContainer = document.createElement('div');
24161
24165
  ellipsisContainer.setAttribute('aria-hidden', 'true');
@@ -38288,6 +38292,9 @@ function findKeysForValues(valueList, valueEntities) {
38288
38292
  valueList.forEach(val => {
38289
38293
  if (val in valueEntities) {
38290
38294
  res.push(valueEntities[val]);
38295
+ } else {
38296
+ // if val not in valueEntities, then value push to keys array
38297
+ val && res.push(val);
38291
38298
  }
38292
38299
  });
38293
38300
  return res;
@@ -38557,15 +38564,22 @@ function normalizedArr(val) {
38557
38564
  } else {
38558
38565
  return val;
38559
38566
  }
38560
- }
38567
+ } // flag is used to determine whether to return when the key does not belong to the keys in keyEntities
38568
+ // export function normalizeKeyList(keyList: any, keyEntities: KeyEntities, leafOnly = false) {
38569
+
38561
38570
  function normalizeKeyList(keyList, keyEntities) {
38562
38571
  let leafOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
38572
+ let flag = arguments.length > 3 ? arguments[3] : undefined;
38563
38573
  const res = [];
38564
38574
  const keyListSet = new Set(keyList);
38565
38575
 
38566
38576
  if (!leafOnly) {
38567
38577
  keyList.forEach(key => {
38568
38578
  if (!keyEntities[key]) {
38579
+ if (flag) {
38580
+ res.push(key);
38581
+ }
38582
+
38569
38583
  return;
38570
38584
  }
38571
38585
 
@@ -38583,6 +38597,11 @@ function normalizeKeyList(keyList, keyEntities) {
38583
38597
  keyList.forEach(key => {
38584
38598
  if (keyEntities[key] && !treeUtil_isValid(keyEntities[key].children)) {
38585
38599
  res.push(key);
38600
+ } // when key is not in keyEntities, if flag is true, key should be push in res
38601
+
38602
+
38603
+ if (!keyEntities[key] && flag) {
38604
+ res.push(key);
38586
38605
  }
38587
38606
  });
38588
38607
  }
@@ -38699,7 +38718,7 @@ function calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedK
38699
38718
  }
38700
38719
  };
38701
38720
 
38702
- calcCurrLevel(nodeItem);
38721
+ nodeItem && calcCurrLevel(nodeItem);
38703
38722
  return {
38704
38723
  checkedKeys,
38705
38724
  halfCheckedKeys
@@ -41403,7 +41422,66 @@ class foundation_TagInputFoundation extends foundation {
41403
41422
  const {
41404
41423
  value
41405
41424
  } = e.target;
41406
- this._checkInputChangeValid(value) && this._onInputChange(value, e);
41425
+ const {
41426
+ entering
41427
+ } = this.getStates();
41428
+
41429
+ if (entering) {
41430
+ // 如果处于输入法输入中,则先不检查输入是否有效,直接更新到inputValue,
41431
+ // 因为对于输入法输入中而言,此时更新到 inputValue 的不是最后的结果,比如对于中文,此时 inputValue 中的内容是拼音
41432
+ // 当输入法输入结束后,将在 handleInputCompositionEnd 中判断输入是否有效,处理结果
41433
+ // If it is composition session, it does not check whether the input is valid, and directly updates to inputValue,
41434
+ // Because for composition input, what is updated to inputValue at this time is not the final result.
41435
+ // For example, for Chinese, the content in inputValue is pinyin at this time
41436
+ // When the composition input is finished, it will be judged whether the input is valid in handleInputCompositionEnd and the result will be processed
41437
+ this._onInputChange(value, e);
41438
+ } else {
41439
+ this._checkInputChangeValid(value) && this._onInputChange(value, e);
41440
+ }
41441
+ };
41442
+
41443
+ this.handleInputCompositionStart = e => {
41444
+ this._adapter.setEntering(true);
41445
+ };
41446
+
41447
+ this.handleInputCompositionEnd = e => {
41448
+ this._adapter.setEntering(false);
41449
+
41450
+ const {
41451
+ value
41452
+ } = e.target;
41453
+ const {
41454
+ maxLength,
41455
+ onInputExceed,
41456
+ separator
41457
+ } = this.getProps();
41458
+ let allowChange = true;
41459
+ const {
41460
+ inputValue
41461
+ } = this.getStates();
41462
+
41463
+ if (isNumber_default()(maxLength)) {
41464
+ const inputArr = utils_getSplitedArray(inputValue, separator);
41465
+ let index = 0;
41466
+
41467
+ for (; index < inputArr.length; index++) {
41468
+ if (inputArr[index].length > maxLength) {
41469
+ allowChange = false;
41470
+ isFunction_default()(onInputExceed) && onInputExceed(value);
41471
+ break;
41472
+ }
41473
+ }
41474
+
41475
+ if (!allowChange) {
41476
+ const newInputArr = inputArr.slice(0, index);
41477
+
41478
+ if (index < inputArr.length) {
41479
+ newInputArr.push(inputArr[index].slice(0, maxLength));
41480
+ }
41481
+
41482
+ this._adapter.setInputValue(newInputArr.join(separator));
41483
+ }
41484
+ }
41407
41485
  };
41408
41486
  /**
41409
41487
  * check whether the input change is legal
@@ -43694,13 +43772,22 @@ class tagInput_TagInput extends baseComponent_BaseComponent {
43694
43772
  this.foundation.handleSortEnd(callbackProps);
43695
43773
  };
43696
43774
 
43775
+ this.handleInputCompositionStart = e => {
43776
+ this.foundation.handleInputCompositionStart(e);
43777
+ };
43778
+
43779
+ this.handleInputCompositionEnd = e => {
43780
+ this.foundation.handleInputCompositionEnd(e);
43781
+ };
43782
+
43697
43783
  this.foundation = new tagInput_foundation(this.adapter);
43698
43784
  this.state = {
43699
43785
  tagsArray: props.defaultValue || [],
43700
43786
  inputValue: '',
43701
43787
  focusing: false,
43702
43788
  hovering: false,
43703
- active: false
43789
+ active: false,
43790
+ entering: false
43704
43791
  };
43705
43792
  this.inputRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createRef();
43706
43793
  this.tagInputRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createRef();
@@ -43776,6 +43863,11 @@ class tagInput_TagInput extends baseComponent_BaseComponent {
43776
43863
  active
43777
43864
  });
43778
43865
  },
43866
+ setEntering: entering => {
43867
+ this.setState({
43868
+ entering
43869
+ });
43870
+ },
43779
43871
  getClickOutsideHandler: () => {
43780
43872
  return this.clickOutsideHandler;
43781
43873
  },
@@ -44065,7 +44157,9 @@ class tagInput_TagInput extends baseComponent_BaseComponent {
44065
44157
  },
44066
44158
  onFocus: e => {
44067
44159
  this.handleInputFocus(e);
44068
- }
44160
+ },
44161
+ onCompositionStart: this.handleInputCompositionStart,
44162
+ onCompositionEnd: this.handleInputCompositionEnd
44069
44163
  })), this.renderClearBtn(), this.renderSuffix())
44070
44164
  );
44071
44165
  }
@@ -80228,11 +80322,12 @@ function warnIfNoDataIndex(column) {
80228
80322
  const {
80229
80323
  filters,
80230
80324
  sorter,
80231
- dataIndex
80325
+ dataIndex,
80326
+ onFilter
80232
80327
  } = column;
80233
80328
  const logger = new utils_Logger('[@douyinfe/semi-ui Table]');
80234
80329
 
80235
- if ((Array.isArray(filters) || isFunction_default()(sorter)) && isNullOrUndefined(dataIndex)) {
80330
+ if ((Array.isArray(filters) || isFunction_default()(onFilter) || isFunction_default()(sorter)) && isNullOrUndefined(dataIndex)) {
80236
80331
  logger.warn("The column with sorter or filter must pass the 'dataIndex' prop");
80237
80332
  }
80238
80333
  }
@@ -80487,9 +80582,10 @@ class foundation_TableFoundation extends foundation {
80487
80582
  const {
80488
80583
  defaultFilteredValue,
80489
80584
  filteredValue,
80490
- filters
80585
+ onFilter
80491
80586
  } = column;
80492
- const hasFilter = Array.isArray(filters) && filters.length;
80587
+
80588
+ const hasFilter = isFunction_default()(onFilter);
80493
80589
 
80494
80590
  if (hasFilter && isUndefined_default()(filteredValue)) {
80495
80591
  if (Array.isArray(defaultFilteredValue) && defaultFilteredValue.length) {
@@ -80607,7 +80703,7 @@ class foundation_TableFoundation extends foundation {
80607
80703
  * When initializing we should use `defaultFilteredValue`, after clicking we should use `filteredValue`
80608
80704
  */
80609
80705
  const currentFilteredValue = query.filteredValue ? query.filteredValue : query.defaultFilteredValue;
80610
- return isFunction_default()(query.onFilter) && Array.isArray(query.filters) && query.filters.length && Array.isArray(currentFilteredValue) && currentFilteredValue.length;
80706
+ return isFunction_default()(query.onFilter) && Array.isArray(currentFilteredValue) && currentFilteredValue.length;
80611
80707
  }));
80612
80708
  const sortedDataSource = this.sortDataSource(filteredDataSource, queries.filter(query => query && isFunction_default()(query.sorter)));
80613
80709
  return sortedDataSource;
@@ -86249,6 +86345,8 @@ class Table_Table extends baseComponent_BaseComponent {
86249
86345
  if (this.props.defaultExpandAllRows && handledProps.groups && handledProps.groups.size || this.props.expandAllRows || this.props.expandAllGroupRows) {
86250
86346
  this.foundation.initExpandedRowKeys(handledProps);
86251
86347
  }
86348
+
86349
+ states.pagination = handledProps.pagination;
86252
86350
  } // Centrally update paging related state
86253
86351
 
86254
86352
 
@@ -92603,6 +92701,46 @@ class foundation_TreeSelectFoundation extends foundation {
92603
92701
  return Boolean(inputValue) && showFilteredOnly;
92604
92702
  }
92605
92703
 
92704
+ findDataForValue(findValue) {
92705
+ const {
92706
+ value,
92707
+ defaultValue
92708
+ } = this.getProps();
92709
+ let valueArr = [];
92710
+
92711
+ if (value) {
92712
+ valueArr = Array.isArray(value) ? value : [value];
92713
+ } else if (defaultValue) {
92714
+ valueArr = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
92715
+ }
92716
+
92717
+ return valueArr.find(item => {
92718
+ return item.value === findValue || item.key === findValue;
92719
+ });
92720
+ }
92721
+
92722
+ constructDataForValue(value) {
92723
+ const {
92724
+ treeNodeLabelProp
92725
+ } = this.getProps();
92726
+ return {
92727
+ key: value,
92728
+ [treeNodeLabelProp]: value
92729
+ };
92730
+ }
92731
+
92732
+ getDataForKeyNotInKeyEntities(value) {
92733
+ const {
92734
+ onChangeWithObject
92735
+ } = this.getProps();
92736
+
92737
+ if (onChangeWithObject) {
92738
+ return this.findDataForValue(value);
92739
+ } else {
92740
+ return this.constructDataForValue(value);
92741
+ }
92742
+ }
92743
+
92606
92744
  getCopyFromState(items) {
92607
92745
  const res = {};
92608
92746
  normalizedArr(items).forEach(key => {
@@ -92729,12 +92867,12 @@ class foundation_TreeSelectFoundation extends foundation {
92729
92867
  let keyList = [];
92730
92868
 
92731
92869
  if (checkRelation === 'related') {
92732
- keyList = normalizeKeyList(key, keyEntities, leafOnly);
92870
+ keyList = normalizeKeyList(key, keyEntities, leafOnly, true);
92733
92871
  } else if (checkRelation === 'unRelated') {
92734
92872
  keyList = key;
92735
92873
  }
92736
92874
 
92737
- const nodes = keyList.map(i => keyEntities[i].data);
92875
+ const nodes = keyList.map(key => keyEntities[key] && keyEntities[key].data.key === key ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
92738
92876
 
92739
92877
  if (this.getProp('onChangeWithObject')) {
92740
92878
  this._adapter.notifyChangeWithObject(nodes, e);
@@ -92908,7 +93046,7 @@ class foundation_TreeSelectFoundation extends foundation {
92908
93046
  disabledKeys,
92909
93047
  realCheckedKeys
92910
93048
  } = this.getStates();
92911
- const item = keyEntities[eventKey].data;
93049
+ const item = keyEntities[eventKey] && keyEntities[eventKey].data.key === eventKey ? keyEntities[eventKey].data : this.getDataForKeyNotInKeyEntities(eventKey);
92912
93050
 
92913
93051
  if (item.disabled || disableStrictly && disabledKeys.has(eventKey)) {
92914
93052
  return;
@@ -93331,7 +93469,13 @@ class foundation_TreeSelectFoundation extends foundation {
93331
93469
  keyEntities
93332
93470
  } = this.getStates();
93333
93471
  const renderSelectedItem = isFunction_default()(propRenderSelectedItem) ? propRenderSelectedItem : item => get_default()(item, treeNodeLabelProp, null);
93334
- const item = selectedKeys.length && keyEntities[selectedKeys[0]] ? keyEntities[selectedKeys[0]].data : undefined;
93472
+ let item;
93473
+
93474
+ if (selectedKeys.length) {
93475
+ const key = selectedKeys[0];
93476
+ item = keyEntities[key] && keyEntities[key].data.key === key ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key);
93477
+ }
93478
+
93335
93479
  const renderText = item && treeNodeLabelProp in item ? renderSelectedItem(item) : null;
93336
93480
  return renderText;
93337
93481
  }
@@ -93398,6 +93542,8 @@ var treeSelect = __webpack_require__("uw59");
93398
93542
 
93399
93543
 
93400
93544
 
93545
+
93546
+
93401
93547
 
93402
93548
 
93403
93549
 
@@ -93470,6 +93616,10 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93470
93616
  this.handleClick = e => {
93471
93617
  this.foundation.handleClick(e);
93472
93618
  };
93619
+
93620
+ this.getDataForKeyNotInKeyEntities = key => {
93621
+ return this.foundation.getDataForKeyNotInKeyEntities(key);
93622
+ };
93473
93623
  /* istanbul ignore next */
93474
93624
 
93475
93625
 
@@ -93540,15 +93690,15 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93540
93690
  let renderKeys = [];
93541
93691
 
93542
93692
  if (checkRelation === 'related') {
93543
- renderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly);
93693
+ renderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true);
93544
93694
  } else if (checkRelation === 'unRelated' && Object.keys(keyEntities).length > 0) {
93545
93695
  renderKeys = [...realCheckedKeys];
93546
93696
  }
93547
93697
 
93548
93698
  const tagList = []; // eslint-disable-next-line @typescript-eslint/no-shadow
93549
93699
 
93550
- renderKeys.forEach(key => {
93551
- const item = keyEntities[key].data;
93700
+ renderKeys.forEach((key, index) => {
93701
+ const item = keyEntities[key] && keyEntities[key].data.key === key ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key);
93552
93702
 
93553
93703
  const onClose = (tagContent, e) => {
93554
93704
  if (e && typeof e.preventDefault === 'function') {
@@ -93562,12 +93712,12 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93562
93712
  const {
93563
93713
  content,
93564
93714
  isRenderInTag
93565
- } = treeNodeLabelProp in item && item ? renderSelectedItem(item, {
93566
- index: key,
93715
+ } = item && treeNodeLabelProp in item ? renderSelectedItem(item, {
93716
+ index,
93567
93717
  onClose
93568
93718
  }) : null;
93569
93719
 
93570
- if (!content) {
93720
+ if (isNull_default()(content) || isUndefined_default()(content)) {
93571
93721
  return;
93572
93722
  }
93573
93723
 
@@ -93577,7 +93727,7 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93577
93727
  color: 'white',
93578
93728
  visible: true,
93579
93729
  onClose,
93580
- key,
93730
+ key: "tag-".concat(key, "-").concat(index),
93581
93731
  size: size === 'small' ? 'small' : 'large'
93582
93732
  };
93583
93733
 
@@ -93790,7 +93940,7 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93790
93940
  ["".concat(treeSelect_prefixcls, "-with-suffix")]: suffix,
93791
93941
  ["".concat(treeSelect_prefixcls, "-with-suffix")]: suffix
93792
93942
  }, className);
93793
- const triggerRenderKeys = multiple ? normalizeKeyList([...checkedKeys], keyEntities, leafOnly) : selectedKeys;
93943
+ const triggerRenderKeys = multiple ? normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true) : selectedKeys;
93794
93944
  const inner = useCustomTrigger ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement(trigger_0, {
93795
93945
  inputValue: inputValue,
93796
93946
  // eslint-disable-next-line @typescript-eslint/no-shadow
@@ -93854,8 +94004,8 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93854
94004
  renderSelectedItem: propRenderSelectedItem,
93855
94005
  treeNodeLabelProp
93856
94006
  } = this.props;
93857
- const keyList = normalizeKeyList([key], keyEntities, leafOnly);
93858
- const nodes = keyList.map(i => keyEntities[i].data);
94007
+ const keyList = normalizeKeyList([key], keyEntities, leafOnly, true);
94008
+ const nodes = keyList.map(i => keyEntities[key] && keyEntities[key].data.key === key ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
93859
94009
  const value = getValueOrKey(nodes);
93860
94010
  const tagCls = classnames_default()("".concat(treeSelect_prefixcls, "-selection-tag"), {
93861
94011
  ["".concat(treeSelect_prefixcls, "-selection-tag-disabled")]: disabled
@@ -93888,7 +94038,7 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93888
94038
  const {
93889
94039
  content,
93890
94040
  isRenderInTag
93891
- } = treeNodeLabelProp in item && item ? renderSelectedItem(item, {
94041
+ } = item && treeNodeLabelProp in item ? renderSelectedItem(item, {
93892
94042
  index: idx,
93893
94043
  onClose
93894
94044
  }) : null;
@@ -93926,7 +94076,7 @@ class treeSelect_TreeSelect extends baseComponent_BaseComponent {
93926
94076
  let keyList = [];
93927
94077
 
93928
94078
  if (checkRelation === 'related') {
93929
- keyList = normalizeKeyList(checkedKeys, keyEntities, leafOnly);
94079
+ keyList = normalizeKeyList(checkedKeys, keyEntities, leafOnly, true);
93930
94080
  } else if (checkRelation === 'unRelated') {
93931
94081
  keyList = [...realCheckedKeys];
93932
94082
  } // auto focus search input divide into two parts
@@ -94651,7 +94801,7 @@ treeSelect_TreeSelect.propTypes = {
94651
94801
  arrowIcon: prop_types_default.a.node,
94652
94802
  clearIcon: prop_types_default.a.node,
94653
94803
  defaultOpen: prop_types_default.a.bool,
94654
- defaultValue: prop_types_default.a.oneOfType([prop_types_default.a.string, prop_types_default.a.array]),
94804
+ defaultValue: prop_types_default.a.oneOfType([prop_types_default.a.string, prop_types_default.a.array, prop_types_default.a.object]),
94655
94805
  defaultExpandAll: prop_types_default.a.bool,
94656
94806
  defaultExpandedKeys: prop_types_default.a.array,
94657
94807
  expandAll: prop_types_default.a.bool,