@douyinfe/semi-ui 2.51.3 → 2.51.4

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
@@ -36994,10 +37005,12 @@ function util_traverseDataNodes(treeNodes, callback) {
36994
37005
  // Process node if is not root
36995
37006
  if (node) {
36996
37007
  const key = parent ? `${parent.key}${constants_VALUE_SPLIT}${node.value}` : node.value;
37008
+ const pos = parent ? util_getPosition(parent.pos, ind) : `${ind}`;
36997
37009
  item = {
36998
37010
  data: Object.assign({}, node),
36999
37011
  ind,
37000
37012
  key,
37013
+ pos,
37001
37014
  level: parent ? parent.level + 1 : 0,
37002
37015
  parentKey: parent ? parent.key : null,
37003
37016
  path: parent ? [...parent.path, key] : [key],
@@ -37030,6 +37043,17 @@ function getKeyByValuePath(valuePath) {
37030
37043
  function getValuePathByKey(key) {
37031
37044
  return key.split(VALUE_SPLIT);
37032
37045
  }
37046
+ function getKeyByPos(pos, treeData) {
37047
+ const posArr = pos.split('-').map(item => Number(item));
37048
+ let resultData = treeData;
37049
+ let valuePath = [];
37050
+ posArr.forEach((item, index) => {
37051
+ var _a;
37052
+ resultData = index === 0 ? resultData[item] : (_a = resultData === null || resultData === void 0 ? void 0 : resultData.children) === null || _a === void 0 ? void 0 : _a[item];
37053
+ valuePath.push(resultData === null || resultData === void 0 ? void 0 : resultData.value);
37054
+ });
37055
+ return getKeyByValuePath(valuePath);
37056
+ }
37033
37057
  function util_convertDataToEntities(dataNodes) {
37034
37058
  const keyEntities = {};
37035
37059
  util_traverseDataNodes(dataNodes, data => {
@@ -37084,6 +37108,28 @@ class CascaderFoundation extends foundation {
37084
37108
  isSearching: false
37085
37109
  });
37086
37110
  };
37111
+ this.handleTagRemoveByKey = key => {
37112
+ var _a, _b;
37113
+ const {
37114
+ keyEntities
37115
+ } = this.getStates();
37116
+ const {
37117
+ disabled
37118
+ } = this.getProps();
37119
+ if (disabled) {
37120
+ /* istanbul ignore next */
37121
+ return;
37122
+ }
37123
+ const removedItem = (_a = keyEntities[key]) !== null && _a !== void 0 ? _a : {};
37124
+ !((_b = removedItem === null || removedItem === void 0 ? void 0 : removedItem.data) === null || _b === void 0 ? void 0 : _b.disable) && this._handleMultipleSelect(removedItem);
37125
+ };
37126
+ this.handleTagRemoveInTrigger = pos => {
37127
+ const {
37128
+ treeData
37129
+ } = this.getStates();
37130
+ const key = getKeyByPos(pos, treeData);
37131
+ this.handleTagRemoveByKey(key);
37132
+ };
37087
37133
  }
37088
37134
  init() {
37089
37135
  const isOpen = this.getProp('open') || this.getProp('defaultOpen');
@@ -37917,20 +37963,6 @@ class CascaderFoundation extends foundation {
37917
37963
  activeNode: data
37918
37964
  });
37919
37965
  }
37920
- handleTagRemove(e, tagValuePath) {
37921
- const {
37922
- keyEntities
37923
- } = this.getStates();
37924
- const {
37925
- disabled
37926
- } = this.getProps();
37927
- if (disabled) {
37928
- /* istanbul ignore next */
37929
- return;
37930
- }
37931
- const removedItem = Object.values(keyEntities).filter(item => isEqual_default()(item.valuePath, tagValuePath))[0];
37932
- !isEmpty_default()(removedItem) && !removedItem.data.disabled && this._handleMultipleSelect(removedItem);
37933
- }
37934
37966
  }
37935
37967
  // EXTERNAL MODULE: ../semi-foundation/cascader/cascader.scss
37936
37968
  var cascader = __webpack_require__("B2DP");
@@ -47589,14 +47621,13 @@ class Cascader extends BaseComponent {
47589
47621
  this.handleInputChange = value => {
47590
47622
  this.foundation.handleInputChange(value);
47591
47623
  };
47592
- this.handleTagRemove = (e, tagValuePath) => {
47593
- this.foundation.handleTagRemove(e, tagValuePath);
47624
+ this.handleTagRemoveInTrigger = pos => {
47625
+ this.foundation.handleTagRemoveInTrigger(pos);
47594
47626
  };
47595
- this.handleRemoveByKey = key => {
47596
- const {
47597
- keyEntities
47598
- } = this.state;
47599
- this.handleTagRemove(null, keyEntities[key].valuePath);
47627
+ this.handleTagClose = (tagChildren, e, tagKey) => {
47628
+ // When value has not changed, prevent clicking tag closeBtn to close tag
47629
+ e.preventDefault();
47630
+ this.foundation.handleTagRemoveByKey(tagKey);
47600
47631
  };
47601
47632
  this.renderTagItem = (nodeKey, idx) => {
47602
47633
  const {
@@ -47624,18 +47655,18 @@ class Cascader extends BaseComponent {
47624
47655
  size: size === 'default' ? 'large' : size,
47625
47656
  key: `tag-${nodeKey}-${idx}`,
47626
47657
  color: "white",
47658
+ tagKey: nodeKey,
47627
47659
  className: tagCls,
47628
47660
  closable: true,
47629
- onClose: (tagChildren, e) => {
47630
- // When value has not changed, prevent clicking tag closeBtn to close tag
47631
- e.preventDefault();
47632
- this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
47633
- }
47661
+ onClose: this.handleTagClose
47634
47662
  }, keyEntities[nodeKey].data[displayProp]);
47635
47663
  }
47636
47664
  }
47637
47665
  return null;
47638
47666
  };
47667
+ this.onRemoveInTagInput = v => {
47668
+ this.foundation.handleTagRemoveByKey(v);
47669
+ };
47639
47670
  this.handleItemClick = (e, item) => {
47640
47671
  this.foundation.handleItemClick(e, item);
47641
47672
  };
@@ -47835,6 +47866,7 @@ class Cascader extends BaseComponent {
47835
47866
  }, labelNode);
47836
47867
  };
47837
47868
  this.renderCustomTrigger = () => {
47869
+ var _a;
47838
47870
  const {
47839
47871
  disabled,
47840
47872
  triggerRender,
@@ -47845,17 +47877,26 @@ class Cascader extends BaseComponent {
47845
47877
  inputValue,
47846
47878
  inputPlaceHolder,
47847
47879
  resolvedCheckedKeys,
47848
- checkedKeys
47880
+ checkedKeys,
47881
+ keyEntities
47849
47882
  } = this.state;
47850
47883
  let realValue;
47851
47884
  if (multiple) {
47852
47885
  if (this.mergeType === cascader_constants_strings.NONE_MERGE_TYPE) {
47853
- realValue = checkedKeys;
47886
+ realValue = new Set();
47887
+ checkedKeys.forEach(key => {
47888
+ var _a;
47889
+ realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
47890
+ });
47854
47891
  } else {
47855
- realValue = resolvedCheckedKeys;
47892
+ realValue = new Set();
47893
+ resolvedCheckedKeys.forEach(key => {
47894
+ var _a;
47895
+ realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
47896
+ });
47856
47897
  }
47857
47898
  } else {
47858
- realValue = [...selectedKeys][0];
47899
+ realValue = (_a = keyEntities[[...selectedKeys][0]]) === null || _a === void 0 ? void 0 : _a.pos;
47859
47900
  }
47860
47901
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
47861
47902
  value: realValue,
@@ -47868,7 +47909,7 @@ class Cascader extends BaseComponent {
47868
47909
  componentName: 'Cascader',
47869
47910
  componentProps: Object.assign({}, this.props),
47870
47911
  onSearch: this.handleInputChange,
47871
- onRemove: this.handleRemoveByKey
47912
+ onRemove: this.handleTagRemoveInTrigger
47872
47913
  });
47873
47914
  };
47874
47915
  this.handleMouseOver = () => {
@@ -48352,11 +48393,11 @@ class Cascader extends BaseComponent {
48352
48393
  showRestTagsPopover: showRestTagsPopover,
48353
48394
  restTagsPopoverProps: restTagsPopoverProps,
48354
48395
  maxTagCount: maxTagCount,
48355
- renderTagItem: (value, index) => this.renderTagItem(value, index),
48396
+ renderTagItem: this.renderTagItem,
48356
48397
  inputValue: inputValue,
48357
48398
  onInputChange: this.handleInputChange,
48358
48399
  // TODO Modify logic, not modify type
48359
- onRemove: v => this.handleTagRemove(null, v),
48400
+ onRemove: this.onRemoveInTagInput,
48360
48401
  placeholder: placeholder,
48361
48402
  expandRestTagsOnClick: false
48362
48403
  });
@@ -53187,6 +53228,7 @@ function isValidTimeZone(timeZone) {
53187
53228
 
53188
53229
 
53189
53230
 
53231
+
53190
53232
  /**
53191
53233
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
53192
53234
  * task 1. Accept the selected date change, update the date value, and update the input box value according to the date = > Notify the change
@@ -53290,6 +53332,8 @@ class DatePickerFoundation extends foundation {
53290
53332
  parsedV = zonedTimeToUtc(parsedV, prevTimeZone);
53291
53333
  }
53292
53334
  result.push(isValidTimeZone(timeZone) ? utcToZonedTime(parsedV, timeZone) : parsedV);
53335
+ } else {
53336
+ warning(true, `[Semi DatePicker] value cannot be parsed, value: ${String(v)}`);
53293
53337
  }
53294
53338
  }
53295
53339
  }
@@ -58919,16 +58963,6 @@ class YearAndMonth extends BaseComponent {
58919
58963
  currentYear,
58920
58964
  currentMonth
58921
58965
  } = props;
58922
- const currentLeftYear = currentYear.left || now.getFullYear();
58923
- const currentLeftMonth = currentMonth.left || now.getMonth() + 1;
58924
- currentYear = {
58925
- left: currentLeftYear,
58926
- right: currentLeftYear
58927
- };
58928
- currentMonth = {
58929
- left: currentLeftMonth,
58930
- right: currentMonth.right || currentLeftMonth + 1
58931
- };
58932
58966
  this.state = {
58933
58967
  years: _utils_getYears(props.startYear, props.endYear).map(year => ({
58934
58968
  value: year,
@@ -58938,8 +58972,14 @@ class YearAndMonth extends BaseComponent {
58938
58972
  value: idx + 1,
58939
58973
  month: idx + 1
58940
58974
  })),
58941
- currentYear,
58942
- currentMonth
58975
+ currentYear: {
58976
+ left: currentYear.left || now.getFullYear(),
58977
+ right: currentYear.right || now.getFullYear()
58978
+ },
58979
+ currentMonth: {
58980
+ left: currentMonth.left || now.getMonth() + 1,
58981
+ right: currentMonth.right || now.getMonth() + 2
58982
+ }
58943
58983
  };
58944
58984
  this.yearRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
58945
58985
  this.monthRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
@@ -58976,11 +59016,19 @@ class YearAndMonth extends BaseComponent {
58976
59016
  }
58977
59017
  static getDerivedStateFromProps(props, state) {
58978
59018
  const willUpdateStates = {};
58979
- if (!isEqual_default()(props.currentYear, state.currentYear) && props.currentYear.left !== 0) {
58980
- willUpdateStates.currentYear = props.currentYear;
59019
+ if (!isEqual_default()(props.currentYear, state.currentYear)) {
59020
+ const nowYear = new Date().getFullYear();
59021
+ willUpdateStates.currentYear = {
59022
+ left: props.currentYear.left || nowYear,
59023
+ right: props.currentYear.right || nowYear
59024
+ };
58981
59025
  }
58982
- if (!isEqual_default()(props.currentMonth, state.currentMonth) && props.currentMonth.left !== 0) {
58983
- willUpdateStates.currentMonth = props.currentMonth;
59026
+ if (!isEqual_default()(props.currentMonth, state.currentMonth)) {
59027
+ const nowMonth = new Date().getMonth();
59028
+ willUpdateStates.currentMonth = {
59029
+ left: props.currentMonth.left || nowMonth + 1,
59030
+ right: props.currentMonth.right || nowMonth + 2
59031
+ };
58984
59032
  }
58985
59033
  return willUpdateStates;
58986
59034
  }
@@ -60399,7 +60447,7 @@ class DatePicker extends BaseComponent {
60399
60447
  return /range/i.test(type) && !isFunction_default()(triggerRender);
60400
60448
  }
60401
60449
  componentDidUpdate(prevProps) {
60402
- if (prevProps.value !== this.props.value) {
60450
+ if (!isEqual_default()(prevProps.value, this.props.value)) {
60403
60451
  this.foundation.initFromProps(Object.assign({}, this.props));
60404
60452
  } else if (this.props.timeZone !== prevProps.timeZone) {
60405
60453
  this.foundation.initFromProps({
@@ -62146,6 +62194,7 @@ const destroyFns = [];
62146
62194
  class Modal extends BaseComponent {
62147
62195
  constructor(props) {
62148
62196
  super(props);
62197
+ this.bodyOverflow = null;
62149
62198
  this.handleCancel = e => {
62150
62199
  this.foundation.handleCancel(e);
62151
62200
  };
@@ -62285,7 +62334,6 @@ class Modal extends BaseComponent {
62285
62334
  };
62286
62335
  this.foundation = new ModalFoundation(this.adapter);
62287
62336
  this.modalRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
62288
- this.bodyOverflow = '';
62289
62337
  this.scrollBarWidth = 0;
62290
62338
  this.originBodyWidth = '100%';
62291
62339
  }
@@ -62306,7 +62354,7 @@ class Modal extends BaseComponent {
62306
62354
  const {
62307
62355
  getPopupContainer
62308
62356
  } = this.props;
62309
- if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
62357
+ if (!getPopupContainer && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
62310
62358
  document.body.style.overflow = this.bodyOverflow;
62311
62359
  document.body.style.width = this.originBodyWidth;
62312
62360
  }
@@ -70580,7 +70628,8 @@ class option_Option extends external_root_React_commonjs2_react_commonjs_react_a
70580
70628
  value,
70581
70629
  label,
70582
70630
  children
70583
- }, rest), e)
70631
+ }, rest), e),
70632
+ className
70584
70633
  }, rest));
70585
70634
  }
70586
70635
  const config = {
@@ -84252,7 +84301,7 @@ const ResizableTable = function () {
84252
84301
  width: table_constants_numbers.DEFAULT_WIDTH_COLUMN_EXPAND
84253
84302
  });
84254
84303
  }
84255
- if (props.rowSelection && !find_default()(rawColumns, item => item.key === table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION)) {
84304
+ if (props.rowSelection && !get_default()(props.rowSelection, 'hidden') && !find_default()(rawColumns, item => item.key === table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION)) {
84256
84305
  newColumns.unshift({
84257
84306
  width: get_default()(props, 'rowSelection.width', table_constants_numbers.DEFAULT_WIDTH_COLUMN_SELECTION),
84258
84307
  key: table_constants_strings.DEFAULT_KEY_COLUMN_SELECTION