@douyinfe/semi-ui 2.55.4 → 2.56.0-beta.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.
@@ -20518,7 +20518,10 @@ class Tooltip extends BaseComponent {
20518
20518
  let popupEl = this.containerEl && this.containerEl.current;
20519
20519
  el = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(el);
20520
20520
  popupEl = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(popupEl);
20521
- if (el && !el.contains(e.target) && popupEl && !popupEl.contains(e.target) || this.props.clickTriggerToHide && el && el.contains(e.target)) {
20521
+ const target = e.target;
20522
+ const path = e.composedPath && e.composedPath() || [target];
20523
+ const isClickTriggerToHide = this.props.clickTriggerToHide ? el && el.contains(target) || path.includes(el) : false;
20524
+ if (el && !el.contains(target) && popupEl && !popupEl.contains(target) && !(path.includes(popupEl) || path.includes(el)) || isClickTriggerToHide) {
20522
20525
  this.props.onClickOutSide(e);
20523
20526
  cb();
20524
20527
  }
@@ -26241,7 +26244,8 @@ class AutoComplete extends BaseComponent {
26241
26244
  const triggerDom = this.triggerRef && this.triggerRef.current;
26242
26245
  const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
26243
26246
  const target = e.target;
26244
- if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
26247
+ const path = e.composedPath && e.composedPath() || [target];
26248
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target) && !(path.includes(triggerDom) || path.includes(optionsDom))) {
26245
26249
  cb(e);
26246
26250
  }
26247
26251
  };
@@ -28082,6 +28086,7 @@ function IconChevronUp_SvgComponent(props) {
28082
28086
  const IconChevronUp_IconComponent = convertIcon(IconChevronUp_SvgComponent, 'chevron_up');
28083
28087
  /* harmony default export */ const IconChevronUp = (IconChevronUp_IconComponent);
28084
28088
  ;// CONCATENATED MODULE: ./backtop/index.tsx
28089
+
28085
28090
  var backtop_rest = undefined && undefined.__rest || function (s, e) {
28086
28091
  var t = {};
28087
28092
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -28111,7 +28116,9 @@ class BackTop extends BaseComponent {
28111
28116
  this.foundation = new BackTopFoundation(this.adapter);
28112
28117
  }
28113
28118
  componentDidMount() {
28119
+ var _a;
28114
28120
  this.foundation.init();
28121
+ this.handler = throttle_default()(this.handleClick, (_a = this.props.duration) !== null && _a !== void 0 ? _a : BackTop.defaultProps.duration);
28115
28122
  }
28116
28123
  componentWillUnmount() {
28117
28124
  this.foundation.destroy();
@@ -28169,7 +28176,7 @@ class BackTop extends BaseComponent {
28169
28176
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({}, others, {
28170
28177
  className: preCls,
28171
28178
  style: style,
28172
- onClick: e => this.handleClick(e),
28179
+ onClick: e => this.handler(e),
28173
28180
  "x-semi-prop": "children"
28174
28181
  }), backtopBtn) : null;
28175
28182
  return content;
@@ -34012,7 +34019,9 @@ class monthCalendar extends BaseComponent {
34012
34019
  const clickOutsideHandler = e => {
34013
34020
  const cardInstance = this.cardRef && this.cardRef.get(key);
34014
34021
  const cardDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(cardInstance);
34015
- if (cardDom && !cardDom.contains(e.target)) {
34022
+ const target = e.target;
34023
+ const path = e.composedPath && e.composedPath() || [target];
34024
+ if (cardDom && !cardDom.contains(target) && !path.includes(cardDom)) {
34016
34025
  cb();
34017
34026
  }
34018
34027
  };
@@ -46700,7 +46709,8 @@ class TagInput extends BaseComponent {
46700
46709
  const clickOutsideHandler = e => {
46701
46710
  const tagInputDom = this.tagInputRef && this.tagInputRef.current;
46702
46711
  const target = e.target;
46703
- if (tagInputDom && !tagInputDom.contains(target)) {
46712
+ const path = e.composedPath && e.composedPath() || [target];
46713
+ if (tagInputDom && !tagInputDom.contains(target) && !path.includes(tagInputDom)) {
46704
46714
  cb(e);
46705
46715
  }
46706
46716
  };
@@ -47072,10 +47082,10 @@ class Cascader extends BaseComponent {
47072
47082
  displayRender,
47073
47083
  disableStrictly
47074
47084
  } = this.props;
47075
- const isDsiabled = disabled || keyEntities[nodeKey].data.disabled || disableStrictly && disabledKeys.has(nodeKey);
47076
47085
  if (keyEntities[nodeKey]) {
47086
+ const isDisabled = disabled || keyEntities[nodeKey].data.disabled || disableStrictly && disabledKeys.has(nodeKey);
47077
47087
  const tagCls = classnames_default()(`${cascader_prefixcls}-selection-tag`, {
47078
- [`${cascader_prefixcls}-selection-tag-disabled`]: isDsiabled
47088
+ [`${cascader_prefixcls}-selection-tag-disabled`]: isDisabled
47079
47089
  });
47080
47090
  // custom render tags
47081
47091
  if (isFunction_default()(displayRender)) {
@@ -47575,7 +47585,8 @@ class Cascader extends BaseComponent {
47575
47585
  const triggerDom = this.triggerRef && this.triggerRef.current;
47576
47586
  const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
47577
47587
  const target = e.target;
47578
- if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
47588
+ const path = e.composedPath && e.composedPath() || [target];
47589
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target) && !(path.includes(triggerDom) || path.includes(optionsDom))) {
47579
47590
  cb(e);
47580
47591
  }
47581
47592
  };
@@ -47738,7 +47749,11 @@ class Cascader extends BaseComponent {
47738
47749
  formatItem.length > 0 && formatValuePath.push(formatItem);
47739
47750
  });
47740
47751
  // formatKeys is used to save key of value
47741
- const formatKeys = formatValuePath.map(v => getKeyByValuePath(v));
47752
+ const formatKeys = formatValuePath.reduce((acc, cur) => {
47753
+ const key = getKeyByValuePath(cur);
47754
+ keyEntities[key] && acc.push(key);
47755
+ return acc;
47756
+ }, []);
47742
47757
  return formatKeys;
47743
47758
  };
47744
47759
  const needUpdateTreeData = needUpdate('treeData') || needUpdateData();
@@ -60106,15 +60121,11 @@ class DatePicker extends BaseComponent {
60106
60121
  this.clickOutSideHandler = e => {
60107
60122
  const triggerEl = this.triggerElRef && this.triggerElRef.current;
60108
60123
  const panelEl = this.panelRef && this.panelRef.current;
60109
- const isInTrigger = triggerEl && triggerEl.contains(e.target);
60110
- const isInPanel = panelEl && panelEl.contains(e.target);
60111
- const clickOutSide = !isInTrigger && !isInPanel && this._mounted;
60112
- if (this.adapter.needConfirm()) {
60113
- clickOutSide && this.props.onClickOutSide();
60114
- return;
60115
- } else {
60116
- if (clickOutSide) {
60117
- this.props.onClickOutSide();
60124
+ const target = e.target;
60125
+ const path = e.composedPath && e.composedPath() || [target];
60126
+ if (!(triggerEl && triggerEl.contains(target)) && !(panelEl && panelEl.contains(target)) && !(path.includes(triggerEl) || path.includes(panelEl))) {
60127
+ this.props.onClickOutSide();
60128
+ if (!this.adapter.needConfirm()) {
60118
60129
  this.foundation.closePanel(e);
60119
60130
  }
60120
60131
  }
@@ -70919,9 +70930,9 @@ class Select extends BaseComponent {
70919
70930
  const optionInstance = this.optionsRef && this.optionsRef.current;
70920
70931
  const triggerDom = this.triggerRef && this.triggerRef.current;
70921
70932
  const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
70922
- // let isInPanel = optionsDom && optionsDom.contains(e.target);
70923
- // let isInTrigger = triggerDom && triggerDom.contains(e.target);
70924
- if (optionsDom && !optionsDom.contains(e.target) && triggerDom && !triggerDom.contains(e.target)) {
70933
+ const target = e.target;
70934
+ const path = e.composedPath && e.composedPath() || [target];
70935
+ if (!(optionsDom && optionsDom.contains(target)) && !(triggerDom && triggerDom.contains(target)) && !(path.includes(triggerDom) || path.includes(optionsDom))) {
70925
70936
  cb(e);
70926
70937
  }
70927
70938
  };
@@ -76010,7 +76021,8 @@ class SliderFoundation extends foundation {
76010
76021
  this.onHandleLeave = () => {
76011
76022
  // this._adapter.setEventDefault(e);
76012
76023
  const disabled = this._adapter.getState('disabled');
76013
- if (!disabled && this.getStates()['focusPos'] === "") {
76024
+ const isDrag = this._adapter.getState('isDrag');
76025
+ if (!disabled && !isDrag) {
76014
76026
  this._adapter.onHandleLeave();
76015
76027
  }
76016
76028
  };
@@ -86584,6 +86596,7 @@ class TimePicker extends BaseComponent {
86584
86596
  this.foundation = new timePicker_foundation(this.adapter);
86585
86597
  this.timePickerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
86586
86598
  this.savePanelRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
86599
+ this.useCustomTrigger = typeof this.props.triggerRender === 'function';
86587
86600
  }
86588
86601
  get adapter() {
86589
86602
  var _this2 = this;
@@ -86599,11 +86612,11 @@ class TimePicker extends BaseComponent {
86599
86612
  }
86600
86613
  this.clickOutSideHandler = e => {
86601
86614
  const panel = this.savePanelRef && this.savePanelRef.current;
86602
- const isInPanel = e.target && panel && panel.contains(e.target);
86603
- const isInTimepicker = this.timePickerRef && this.timePickerRef.current && this.timePickerRef.current.contains(e.target);
86604
- if (!isInTimepicker && !isInPanel) {
86605
- const clickedOutside = true;
86606
- this.foundation.handlePanelClose(clickedOutside, e);
86615
+ const trigger = this.timePickerRef && this.timePickerRef.current;
86616
+ const target = e.target;
86617
+ const path = e.composedPath && e.composedPath() || [target];
86618
+ if (!(panel && panel.contains(target)) && !(trigger && trigger.contains(target)) && !(path.includes(trigger) || path.includes(panel))) {
86619
+ this.foundation.handlePanelClose(true, e);
86607
86620
  }
86608
86621
  };
86609
86622
  document.addEventListener('mousedown', this.clickOutSideHandler);
@@ -86767,7 +86780,6 @@ class TimePicker extends BaseComponent {
86767
86780
  rest = TimePicker_rest(_a, ["prefixCls", "placeholder", "disabled", "defaultValue", "dropdownMargin", "className", "popupStyle", "size", "style", "locale", "localeCode", "zIndex", "getPopupContainer", "insetLabel", "insetLabelId", "inputStyle", "showClear", "panelHeader", "panelFooter", "rangeSeparator", "onOpenChange", "onChangeWithDateFirst", "popupClassName", "hideDisabledOptions", "use12Hours", "minuteStep", "hourStep", "secondStep", "scrollItemProps", "triggerRender", "motion", "autoAdjustOverflow", "stopPropagation"]);
86768
86781
  const format = this.foundation.getDefaultFormatIfNeed();
86769
86782
  const position = this.foundation.getPosition();
86770
- const useCustomTrigger = typeof triggerRender === 'function';
86771
86783
  const {
86772
86784
  open,
86773
86785
  inputValue,
@@ -86801,7 +86813,7 @@ class TimePicker extends BaseComponent {
86801
86813
  onBlur: this.handleBlur
86802
86814
  });
86803
86815
  const outerProps = {};
86804
- if (useCustomTrigger) {
86816
+ if (this.useCustomTrigger) {
86805
86817
  outerProps.onClick = this.openPanel;
86806
86818
  }
86807
86819
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({
@@ -86824,7 +86836,7 @@ class TimePicker extends BaseComponent {
86824
86836
  margin: dropdownMargin,
86825
86837
  autoAdjustOverflow: autoAdjustOverflow,
86826
86838
  stopPropagation: stopPropagation
86827
- }, useCustomTrigger ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
86839
+ }, this.useCustomTrigger ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
86828
86840
  triggerRender: triggerRender,
86829
86841
  disabled: disabled,
86830
86842
  value: value,
@@ -87771,6 +87783,45 @@ class TreeFoundation extends foundation {
87771
87783
  const value = pick_default()(data, selectedPath);
87772
87784
  this._adapter.notifyChange(value);
87773
87785
  }
87786
+ constructDataForValue(value) {
87787
+ const {
87788
+ keyMaps
87789
+ } = this.getProps();
87790
+ const keyName = get_default()(keyMaps, 'key', 'key');
87791
+ const labelName = get_default()(keyMaps, 'label', 'label');
87792
+ return {
87793
+ [keyName]: value,
87794
+ [labelName]: value
87795
+ };
87796
+ }
87797
+ findDataForValue(findValue) {
87798
+ const {
87799
+ value,
87800
+ defaultValue,
87801
+ keyMaps
87802
+ } = this.getProps();
87803
+ const realValueName = get_default()(keyMaps, 'value', 'value');
87804
+ const realKeyName = get_default()(keyMaps, 'key', 'key');
87805
+ let valueArr = [];
87806
+ if (value) {
87807
+ valueArr = Array.isArray(value) ? value : [value];
87808
+ } else if (defaultValue) {
87809
+ valueArr = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
87810
+ }
87811
+ return valueArr.find(item => {
87812
+ return item[realValueName] === findValue || item[realKeyName] === findValue;
87813
+ });
87814
+ }
87815
+ getDataForKeyNotInKeyEntities(value) {
87816
+ const {
87817
+ onChangeWithObject
87818
+ } = this.getProps();
87819
+ if (onChangeWithObject) {
87820
+ return this.findDataForValue(value);
87821
+ } else {
87822
+ return this.constructDataForValue(value);
87823
+ }
87824
+ }
87774
87825
  notifyMultipleChange(key, e) {
87775
87826
  const {
87776
87827
  keyEntities
@@ -87783,14 +87834,15 @@ class TreeFoundation extends foundation {
87783
87834
  let value;
87784
87835
  let keyList = [];
87785
87836
  if (checkRelation === 'related') {
87786
- keyList = normalizeKeyList(key, keyEntities, leafOnly);
87837
+ keyList = normalizeKeyList(key, keyEntities, leafOnly, true);
87787
87838
  } else if (checkRelation === 'unRelated') {
87788
87839
  keyList = key;
87789
87840
  }
87841
+ const nodes = keyList.map(key => keyEntities[key] ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
87790
87842
  if (this.getProp('onChangeWithObject')) {
87791
- value = keyList.map(itemKey => keyEntities[itemKey].data);
87843
+ value = nodes;
87792
87844
  } else {
87793
- value = getValueOrKey(keyList.map(itemKey => keyEntities[itemKey].data), keyMaps);
87845
+ value = getValueOrKey(nodes, keyMaps);
87794
87846
  }
87795
87847
  this._adapter.notifyChange(value);
87796
87848
  }
@@ -87949,7 +88001,7 @@ class TreeFoundation extends foundation {
87949
88001
  return this.calcCheckedKeys(eventKey, targetStatus);
87950
88002
  }
87951
88003
  const nonDisabled = descendantKeys.filter(key => !disabledKeys.has(key));
87952
- const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : difference_default()(normalizeKeyList([...checkedKeys], keyEntities, true), nonDisabled);
88004
+ const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : difference_default()(normalizeKeyList([...checkedKeys], keyEntities, true, true), nonDisabled);
87953
88005
  return calcCheckedKeys(newCheckedKeys, keyEntities);
87954
88006
  }
87955
88007
  /*
@@ -88498,6 +88550,7 @@ class TreeNode extends external_root_React_commonjs2_react_commonjs_react_amd_re
88498
88550
  onNodeExpand(e, this.props);
88499
88551
  };
88500
88552
  this.onCheck = e => {
88553
+ var _a, _b;
88501
88554
  if (this.isDisabled()) {
88502
88555
  return;
88503
88556
  }
@@ -88505,7 +88558,7 @@ class TreeNode extends external_root_React_commonjs2_react_commonjs_react_amd_re
88505
88558
  onNodeCheck
88506
88559
  } = this.context;
88507
88560
  e.stopPropagation();
88508
- e.nativeEvent.stopImmediatePropagation();
88561
+ (_b = (_a = e.nativeEvent) === null || _a === void 0 ? void 0 : _a.stopImmediatePropagation) === null || _b === void 0 ? void 0 : _b.call(_a);
88509
88562
  onNodeCheck(e, this.props);
88510
88563
  };
88511
88564
  /**
@@ -91760,7 +91813,8 @@ class TreeSelect extends BaseComponent {
91760
91813
  const triggerDom = this.triggerRef && this.triggerRef.current;
91761
91814
  const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
91762
91815
  const target = e.target;
91763
- if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
91816
+ const path = e.composedPath && e.composedPath() || [target];
91817
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target) && !(path.includes(triggerDom) || path.includes(optionsDom))) {
91764
91818
  cb(e);
91765
91819
  }
91766
91820
  };