@douyinfe/semi-ui 2.52.0-beta.1 → 2.52.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.
@@ -18633,6 +18633,7 @@ class foundation_Tooltip extends foundation {
18633
18633
  return null;
18634
18634
  }
18635
18635
  calcPosStyle(props) {
18636
+ var _a;
18636
18637
  const {
18637
18638
  spacing,
18638
18639
  isOverFlow
@@ -18683,6 +18684,10 @@ class foundation_Tooltip extends foundation {
18683
18684
  const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
18684
18685
  const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
18685
18686
  const isWrapperWidthOverflow = wrapperRect.width > innerWidth;
18687
+ const scaled = Math.abs((wrapperRect === null || wrapperRect === void 0 ? void 0 : wrapperRect.width) - ((_a = this._adapter.getContainer()) === null || _a === void 0 ? void 0 : _a.clientWidth)) > 1;
18688
+ if (scaled) {
18689
+ SPACING = SPACING * wrapperRect.width / this._adapter.getContainer().clientWidth;
18690
+ }
18686
18691
  switch (position) {
18687
18692
  case 'top':
18688
18693
  // left = middleX;
@@ -18799,6 +18804,12 @@ class foundation_Tooltip extends foundation {
18799
18804
  // Calculate container positioning relative to window
18800
18805
  left = left - containerRect.left;
18801
18806
  top = top - containerRect.top;
18807
+ if (scaled) {
18808
+ left /= wrapperRect.width / this._adapter.getContainer().clientWidth;
18809
+ }
18810
+ if (scaled) {
18811
+ top /= wrapperRect.height / this._adapter.getContainer().clientHeight;
18812
+ }
18802
18813
  /**
18803
18814
  * container为body时,如果position不为relative或absolute,这时trigger计算出的top/left会根据html定位(initial containing block)
18804
18815
  * 此时如果body有margin,则计算出的位置相对于body会有问题 fix issue #1368
@@ -36892,14 +36903,13 @@ function calcMotionKeys(oldKeySet, newKeySet, keyEntities) {
36892
36903
  /**
36893
36904
  * @returns whether option includes sugInput.
36894
36905
  * When filterTreeNode is a function,returns the result of filterTreeNode which called with (sugInput, target, option).
36895
- * The filteredPath parameter will only be passed in when the Cascader calls the filter function
36896
36906
  */
36897
- function filter(sugInput, option, filterTreeNode, filterProps, filteredPath) {
36907
+ function filter(sugInput, option, filterTreeNode, filterProps) {
36898
36908
  if (!filterTreeNode) {
36899
36909
  return true;
36900
36910
  }
36901
36911
  let filterFn = filterTreeNode;
36902
- let target = filteredPath !== null && filteredPath !== void 0 ? filteredPath : option;
36912
+ let target = option;
36903
36913
  if (typeof filterTreeNode === 'boolean') {
36904
36914
  filterFn = (targetVal, val) => {
36905
36915
  const input = targetVal.toLowerCase();
@@ -37172,6 +37182,33 @@ function util_normalizedArr(val) {
37172
37182
  return val;
37173
37183
  }
37174
37184
  }
37185
+ /**
37186
+ * @returns whether option includes sugInput.
37187
+ * When filterTreeNode is a function,returns the result of filterTreeNode which called with (sugInput, target, option).
37188
+ */
37189
+ function util_filter(sugInput, option, filterTreeNode, filteredPath) {
37190
+ if (!filterTreeNode) {
37191
+ return true;
37192
+ }
37193
+ let filterFn = filterTreeNode;
37194
+ let target;
37195
+ if (typeof filterTreeNode === 'boolean') {
37196
+ filterFn = (targetVal, val) => {
37197
+ const input = targetVal.toLowerCase();
37198
+ return val.toLowerCase().includes(input);
37199
+ };
37200
+ // 当 filterTreeNode 是 bool 类型时,由 Cascader 内部判断是否符合筛选条件,使用 join('') 修复搜索英文逗号导致所有数据被匹配问题
37201
+ // When the type of of filterTreeNode is bool, Cascader internally determines whether it meets the filtering conditions.
37202
+ // Use join('') to fix the problem that searching for English commas causes all data to be matched.
37203
+ target = filteredPath.join('');
37204
+ } else {
37205
+ // 当 filterTreeNode 为函数类型时,由用户判断是否符合筛选条件,使用 join(), 和原来保持一致
37206
+ // When the type of of filterTreeNode is function, the user determines whether it meets the filtering conditions,
37207
+ // uses join() to be consistent with the previous version.
37208
+ target = filteredPath.join();
37209
+ }
37210
+ return filterFn(sugInput, target, option);
37211
+ }
37175
37212
  /**
37176
37213
  * Traverse all the data by `treeData`.
37177
37214
  */
@@ -37182,10 +37219,12 @@ function util_traverseDataNodes(treeNodes, callback) {
37182
37219
  // Process node if is not root
37183
37220
  if (node) {
37184
37221
  const key = parent ? `${parent.key}${constants_VALUE_SPLIT}${node.value}` : node.value;
37222
+ const pos = parent ? util_getPosition(parent.pos, ind) : `${ind}`;
37185
37223
  item = {
37186
37224
  data: Object.assign({}, node),
37187
37225
  ind,
37188
37226
  key,
37227
+ pos,
37189
37228
  level: parent ? parent.level + 1 : 0,
37190
37229
  parentKey: parent ? parent.key : null,
37191
37230
  path: parent ? [...parent.path, key] : [key],
@@ -37218,6 +37257,17 @@ function getKeyByValuePath(valuePath) {
37218
37257
  function getValuePathByKey(key) {
37219
37258
  return key.split(VALUE_SPLIT);
37220
37259
  }
37260
+ function getKeyByPos(pos, treeData) {
37261
+ const posArr = pos.split('-').map(item => Number(item));
37262
+ let resultData = treeData;
37263
+ let valuePath = [];
37264
+ posArr.forEach((item, index) => {
37265
+ var _a;
37266
+ resultData = index === 0 ? resultData[item] : (_a = resultData === null || resultData === void 0 ? void 0 : resultData.children) === null || _a === void 0 ? void 0 : _a[item];
37267
+ valuePath.push(resultData === null || resultData === void 0 ? void 0 : resultData.value);
37268
+ });
37269
+ return getKeyByValuePath(valuePath);
37270
+ }
37221
37271
  function util_convertDataToEntities(dataNodes) {
37222
37272
  const keyEntities = {};
37223
37273
  util_traverseDataNodes(dataNodes, data => {
@@ -37272,6 +37322,28 @@ class CascaderFoundation extends foundation {
37272
37322
  isSearching: false
37273
37323
  });
37274
37324
  };
37325
+ this.handleTagRemoveByKey = key => {
37326
+ var _a, _b;
37327
+ const {
37328
+ keyEntities
37329
+ } = this.getStates();
37330
+ const {
37331
+ disabled
37332
+ } = this.getProps();
37333
+ if (disabled) {
37334
+ /* istanbul ignore next */
37335
+ return;
37336
+ }
37337
+ const removedItem = (_a = keyEntities[key]) !== null && _a !== void 0 ? _a : {};
37338
+ !((_b = removedItem === null || removedItem === void 0 ? void 0 : removedItem.data) === null || _b === void 0 ? void 0 : _b.disable) && this._handleMultipleSelect(removedItem);
37339
+ };
37340
+ this.handleTagRemoveInTrigger = pos => {
37341
+ const {
37342
+ treeData
37343
+ } = this.getStates();
37344
+ const key = getKeyByPos(pos, treeData);
37345
+ this.handleTagRemoveByKey(key);
37346
+ };
37275
37347
  }
37276
37348
  init() {
37277
37349
  const isOpen = this.getProp('open') || this.getProp('defaultOpen');
@@ -37980,8 +38052,8 @@ class CascaderFoundation extends foundation {
37980
38052
  if (_notExist) {
37981
38053
  return false;
37982
38054
  }
37983
- const filteredPath = this.getItemPropPath(key, treeNodeFilterProp).join();
37984
- return filter(sugInput, data, filterTreeNode, false, filteredPath);
38055
+ const filteredPath = this.getItemPropPath(key, treeNodeFilterProp);
38056
+ return util_filter(sugInput, data, filterTreeNode, filteredPath);
37985
38057
  }).filter(item => filterTreeNode && !filterLeafOnly || this._isLeaf(item)).map(item => item.key);
37986
38058
  }
37987
38059
  this._adapter.updateStates({
@@ -38003,6 +38075,7 @@ class CascaderFoundation extends foundation {
38003
38075
  const isControlled = this._isControlledComponent();
38004
38076
  const newState = {};
38005
38077
  if (multiple) {
38078
+ newState.isSearching = false;
38006
38079
  this._adapter.updateInputValue('');
38007
38080
  this._adapter.notifyOnSearch('');
38008
38081
  newState.checkedKeys = new Set([]);
@@ -38105,20 +38178,6 @@ class CascaderFoundation extends foundation {
38105
38178
  activeNode: data
38106
38179
  });
38107
38180
  }
38108
- handleTagRemove(e, tagValuePath) {
38109
- const {
38110
- keyEntities
38111
- } = this.getStates();
38112
- const {
38113
- disabled
38114
- } = this.getProps();
38115
- if (disabled) {
38116
- /* istanbul ignore next */
38117
- return;
38118
- }
38119
- const removedItem = Object.values(keyEntities).filter(item => isEqual_default()(item.valuePath, tagValuePath))[0];
38120
- !isEmpty_default()(removedItem) && !removedItem.data.disabled && this._handleMultipleSelect(removedItem);
38121
- }
38122
38181
  }
38123
38182
  // EXTERNAL MODULE: ../semi-foundation/cascader/cascader.scss
38124
38183
  var cascader = __webpack_require__("B2DP");
@@ -47777,14 +47836,13 @@ class Cascader extends BaseComponent {
47777
47836
  this.handleInputChange = value => {
47778
47837
  this.foundation.handleInputChange(value);
47779
47838
  };
47780
- this.handleTagRemove = (e, tagValuePath) => {
47781
- this.foundation.handleTagRemove(e, tagValuePath);
47839
+ this.handleTagRemoveInTrigger = pos => {
47840
+ this.foundation.handleTagRemoveInTrigger(pos);
47782
47841
  };
47783
- this.handleRemoveByKey = key => {
47784
- const {
47785
- keyEntities
47786
- } = this.state;
47787
- this.handleTagRemove(null, keyEntities[key].valuePath);
47842
+ this.handleTagClose = (tagChildren, e, tagKey) => {
47843
+ // When value has not changed, prevent clicking tag closeBtn to close tag
47844
+ e.preventDefault();
47845
+ this.foundation.handleTagRemoveByKey(tagKey);
47788
47846
  };
47789
47847
  this.renderTagItem = (nodeKey, idx) => {
47790
47848
  const {
@@ -47812,18 +47870,18 @@ class Cascader extends BaseComponent {
47812
47870
  size: size === 'default' ? 'large' : size,
47813
47871
  key: `tag-${nodeKey}-${idx}`,
47814
47872
  color: "white",
47873
+ tagKey: nodeKey,
47815
47874
  className: tagCls,
47816
47875
  closable: true,
47817
- onClose: (tagChildren, e) => {
47818
- // When value has not changed, prevent clicking tag closeBtn to close tag
47819
- e.preventDefault();
47820
- this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
47821
- }
47876
+ onClose: this.handleTagClose
47822
47877
  }, keyEntities[nodeKey].data[displayProp]);
47823
47878
  }
47824
47879
  }
47825
47880
  return null;
47826
47881
  };
47882
+ this.onRemoveInTagInput = v => {
47883
+ this.foundation.handleTagRemoveByKey(v);
47884
+ };
47827
47885
  this.handleItemClick = (e, item) => {
47828
47886
  this.foundation.handleItemClick(e, item);
47829
47887
  };
@@ -48023,6 +48081,7 @@ class Cascader extends BaseComponent {
48023
48081
  }, labelNode);
48024
48082
  };
48025
48083
  this.renderCustomTrigger = () => {
48084
+ var _a;
48026
48085
  const {
48027
48086
  disabled,
48028
48087
  triggerRender,
@@ -48033,17 +48092,26 @@ class Cascader extends BaseComponent {
48033
48092
  inputValue,
48034
48093
  inputPlaceHolder,
48035
48094
  resolvedCheckedKeys,
48036
- checkedKeys
48095
+ checkedKeys,
48096
+ keyEntities
48037
48097
  } = this.state;
48038
48098
  let realValue;
48039
48099
  if (multiple) {
48040
48100
  if (this.mergeType === cascader_constants_strings.NONE_MERGE_TYPE) {
48041
- realValue = checkedKeys;
48101
+ realValue = new Set();
48102
+ checkedKeys.forEach(key => {
48103
+ var _a;
48104
+ realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
48105
+ });
48042
48106
  } else {
48043
- realValue = resolvedCheckedKeys;
48107
+ realValue = new Set();
48108
+ resolvedCheckedKeys.forEach(key => {
48109
+ var _a;
48110
+ realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
48111
+ });
48044
48112
  }
48045
48113
  } else {
48046
- realValue = [...selectedKeys][0];
48114
+ realValue = (_a = keyEntities[[...selectedKeys][0]]) === null || _a === void 0 ? void 0 : _a.pos;
48047
48115
  }
48048
48116
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
48049
48117
  value: realValue,
@@ -48056,7 +48124,7 @@ class Cascader extends BaseComponent {
48056
48124
  componentName: 'Cascader',
48057
48125
  componentProps: Object.assign({}, this.props),
48058
48126
  onSearch: this.handleInputChange,
48059
- onRemove: this.handleRemoveByKey
48127
+ onRemove: this.handleTagRemoveInTrigger
48060
48128
  });
48061
48129
  };
48062
48130
  this.handleMouseOver = () => {
@@ -48087,11 +48155,12 @@ class Cascader extends BaseComponent {
48087
48155
  selectedKeys,
48088
48156
  isOpen,
48089
48157
  isHovering,
48090
- checkedKeys
48158
+ checkedKeys,
48159
+ inputValue
48091
48160
  } = this.state;
48092
48161
  const hasValue = selectedKeys.size;
48093
48162
  const multipleWithHaveValue = multiple && checkedKeys.size;
48094
- return showClear && (hasValue || multipleWithHaveValue) && !disabled && (isOpen || isHovering);
48163
+ return showClear && (inputValue || hasValue || multipleWithHaveValue) && !disabled && (isOpen || isHovering);
48095
48164
  };
48096
48165
  this.renderClearBtn = () => {
48097
48166
  const clearCls = classnames_default()(`${cascader_prefixcls}-clearbtn`);
@@ -48540,11 +48609,11 @@ class Cascader extends BaseComponent {
48540
48609
  showRestTagsPopover: showRestTagsPopover,
48541
48610
  restTagsPopoverProps: restTagsPopoverProps,
48542
48611
  maxTagCount: maxTagCount,
48543
- renderTagItem: (value, index) => this.renderTagItem(value, index),
48612
+ renderTagItem: this.renderTagItem,
48544
48613
  inputValue: inputValue,
48545
48614
  onInputChange: this.handleInputChange,
48546
48615
  // TODO Modify logic, not modify type
48547
- onRemove: v => this.handleTagRemove(null, v),
48616
+ onRemove: this.onRemoveInTagInput,
48548
48617
  placeholder: placeholder,
48549
48618
  expandRestTagsOnClick: false
48550
48619
  });
@@ -53375,6 +53444,7 @@ function isValidTimeZone(timeZone) {
53375
53444
 
53376
53445
 
53377
53446
 
53447
+
53378
53448
  /**
53379
53449
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
53380
53450
  * task 1. Accept the selected date change, update the date value, and update the input box value according to the date = > Notify the change
@@ -53478,6 +53548,8 @@ class DatePickerFoundation extends foundation {
53478
53548
  parsedV = zonedTimeToUtc(parsedV, prevTimeZone);
53479
53549
  }
53480
53550
  result.push(isValidTimeZone(timeZone) ? utcToZonedTime(parsedV, timeZone) : parsedV);
53551
+ } else {
53552
+ warning(true, `[Semi DatePicker] value cannot be parsed, value: ${String(v)}`);
53481
53553
  }
53482
53554
  }
53483
53555
  }
@@ -59109,16 +59181,6 @@ class YearAndMonth extends BaseComponent {
59109
59181
  currentYear,
59110
59182
  currentMonth
59111
59183
  } = props;
59112
- const currentLeftYear = currentYear.left || now.getFullYear();
59113
- const currentLeftMonth = currentMonth.left || now.getMonth() + 1;
59114
- currentYear = {
59115
- left: currentLeftYear,
59116
- right: currentLeftYear
59117
- };
59118
- currentMonth = {
59119
- left: currentLeftMonth,
59120
- right: currentMonth.right || currentLeftMonth + 1
59121
- };
59122
59184
  this.state = {
59123
59185
  years: _utils_getYears(props.startYear, props.endYear).map(year => ({
59124
59186
  value: year,
@@ -59128,8 +59190,14 @@ class YearAndMonth extends BaseComponent {
59128
59190
  value: idx + 1,
59129
59191
  month: idx + 1
59130
59192
  })),
59131
- currentYear,
59132
- currentMonth
59193
+ currentYear: {
59194
+ left: currentYear.left || now.getFullYear(),
59195
+ right: currentYear.right || now.getFullYear()
59196
+ },
59197
+ currentMonth: {
59198
+ left: currentMonth.left || now.getMonth() + 1,
59199
+ right: currentMonth.right || now.getMonth() + 2
59200
+ }
59133
59201
  };
59134
59202
  this.yearRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
59135
59203
  this.monthRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
@@ -59166,11 +59234,19 @@ class YearAndMonth extends BaseComponent {
59166
59234
  }
59167
59235
  static getDerivedStateFromProps(props, state) {
59168
59236
  const willUpdateStates = {};
59169
- if (!isEqual_default()(props.currentYear, state.currentYear) && props.currentYear.left !== 0) {
59170
- willUpdateStates.currentYear = props.currentYear;
59237
+ if (!isEqual_default()(props.currentYear, state.currentYear)) {
59238
+ const nowYear = new Date().getFullYear();
59239
+ willUpdateStates.currentYear = {
59240
+ left: props.currentYear.left || nowYear,
59241
+ right: props.currentYear.right || nowYear
59242
+ };
59171
59243
  }
59172
- if (!isEqual_default()(props.currentMonth, state.currentMonth) && props.currentMonth.left !== 0) {
59173
- willUpdateStates.currentMonth = props.currentMonth;
59244
+ if (!isEqual_default()(props.currentMonth, state.currentMonth)) {
59245
+ const nowMonth = new Date().getMonth();
59246
+ willUpdateStates.currentMonth = {
59247
+ left: props.currentMonth.left || nowMonth + 1,
59248
+ right: props.currentMonth.right || nowMonth + 2
59249
+ };
59174
59250
  }
59175
59251
  return willUpdateStates;
59176
59252
  }
@@ -60589,7 +60665,7 @@ class DatePicker extends BaseComponent {
60589
60665
  return /range/i.test(type) && !isFunction_default()(triggerRender);
60590
60666
  }
60591
60667
  componentDidUpdate(prevProps) {
60592
- if (prevProps.value !== this.props.value) {
60668
+ if (!isEqual_default()(prevProps.value, this.props.value)) {
60593
60669
  this.foundation.initFromProps(Object.assign({}, this.props));
60594
60670
  } else if (this.props.timeZone !== prevProps.timeZone) {
60595
60671
  this.foundation.initFromProps({
@@ -62336,6 +62412,7 @@ const destroyFns = [];
62336
62412
  class Modal extends BaseComponent {
62337
62413
  constructor(props) {
62338
62414
  super(props);
62415
+ this.bodyOverflow = null;
62339
62416
  this.handleCancel = e => {
62340
62417
  this.foundation.handleCancel(e);
62341
62418
  };
@@ -62482,7 +62559,6 @@ class Modal extends BaseComponent {
62482
62559
  };
62483
62560
  this.foundation = new ModalFoundation(this.adapter);
62484
62561
  this.modalRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
62485
- this.bodyOverflow = '';
62486
62562
  this.scrollBarWidth = 0;
62487
62563
  this.originBodyWidth = '100%';
62488
62564
  }
@@ -62503,7 +62579,7 @@ class Modal extends BaseComponent {
62503
62579
  const {
62504
62580
  getPopupContainer
62505
62581
  } = this.props;
62506
- if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
62582
+ if (!getPopupContainer && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
62507
62583
  document.body.style.overflow = this.bodyOverflow;
62508
62584
  document.body.style.width = this.originBodyWidth;
62509
62585
  }
@@ -70269,6 +70345,8 @@ class SelectFoundation extends foundation {
70269
70345
  if (filter) {
70270
70346
  this.clearInput(e);
70271
70347
  }
70348
+ // after click showClear button, the select need to be focused
70349
+ this.focus();
70272
70350
  this.clearSelected();
70273
70351
  // prevent this click open dropdown
70274
70352
  e.stopPropagation();
@@ -70779,7 +70857,8 @@ class option_Option extends external_root_React_commonjs2_react_commonjs_react_a
70779
70857
  value,
70780
70858
  label,
70781
70859
  children
70782
- }, rest), e)
70860
+ }, rest), e),
70861
+ className
70783
70862
  }, rest));
70784
70863
  }
70785
70864
  const config = {
@@ -84570,7 +84649,7 @@ const ResizableTable = function () {
84570
84649
  width: table_constants_numbers.DEFAULT_WIDTH_COLUMN_EXPAND
84571
84650
  });
84572
84651
  }
84573
- if (props.rowSelection && !find_default()(rawColumns, item => item.key === table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION)) {
84652
+ if (props.rowSelection && !get_default()(props.rowSelection, 'hidden') && !find_default()(rawColumns, item => item.key === table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION)) {
84574
84653
  newColumns.unshift({
84575
84654
  width: get_default()(props, 'rowSelection.width', table_constants_numbers.DEFAULT_WIDTH_COLUMN_SELECTION),
84576
84655
  key: table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION
@@ -100746,6 +100825,9 @@ class PreviewInnerFoundation extends foundation {
100746
100825
  return;
100747
100826
  }
100748
100827
  const preloadImages = getPreloadImagArr(imgSrc, currentIndex, preLoadGap, infinite);
100828
+ if (preloadImages.length === 0) {
100829
+ return;
100830
+ }
100749
100831
  const Img = new Image();
100750
100832
  let index = 0;
100751
100833
  function callback(e) {