@douyinfe/semi-ui 2.57.0-beta.0 → 2.58.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.
@@ -18204,6 +18204,14 @@ class foundation_Tooltip extends foundation {
18204
18204
  this.setDisplayNone = (displayNone, cb) => {
18205
18205
  this._adapter.setDisplayNone(displayNone, cb);
18206
18206
  };
18207
+ this.updateStateIfCursorOnTrigger = trigger => {
18208
+ var _a, _b;
18209
+ if ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.matches) === null || _a === void 0 ? void 0 : _a.call(trigger, ":hover")) {
18210
+ const eventNames = this._adapter.getEventName();
18211
+ const triggerEventSet = this.getState("triggerEventSet");
18212
+ (_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
18213
+ }
18214
+ };
18207
18215
  this.onResize = () => {
18208
18216
  // this.log('resize');
18209
18217
  // rePosition when window resize
@@ -20631,6 +20639,15 @@ class Tooltip extends BaseComponent {
20631
20639
  this.mounted = true;
20632
20640
  this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || tooltip_defaultGetContainer;
20633
20641
  this.foundation.init();
20642
+ runAfterTicks(() => {
20643
+ let triggerEle = this.triggerEl.current;
20644
+ if (triggerEle) {
20645
+ if (!(triggerEle instanceof HTMLElement)) {
20646
+ triggerEle = (0,external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_.findDOMNode)(triggerEle);
20647
+ }
20648
+ }
20649
+ this.foundation.updateStateIfCursorOnTrigger(triggerEle);
20650
+ }, 1);
20634
20651
  }
20635
20652
  componentWillUnmount() {
20636
20653
  this.mounted = false;
@@ -25073,9 +25090,6 @@ class InputFoundation extends foundation {
25073
25090
  constructor(adapter) {
25074
25091
  super(Object.assign(Object.assign({}, InputFoundation.inputDefaultAdapter), adapter));
25075
25092
  }
25076
- init() {
25077
- this._setInitValue();
25078
- }
25079
25093
  destroy() {
25080
25094
  if (this._timer) {
25081
25095
  clearTimeout(this._timer);
@@ -25083,19 +25097,6 @@ class InputFoundation extends foundation {
25083
25097
  }
25084
25098
  }
25085
25099
  setDisable() {}
25086
- _setInitValue() {
25087
- const {
25088
- defaultValue,
25089
- value
25090
- } = this.getProps();
25091
- let v = defaultValue;
25092
- if (this._isControlledComponent()) {
25093
- v = value;
25094
- }
25095
- this._adapter.setValue(v);
25096
- // this.checkAllowClear(v);
25097
- }
25098
-
25099
25100
  setValue(value) {
25100
25101
  this._adapter.setValue(value);
25101
25102
  }
@@ -25480,9 +25481,10 @@ class Input extends BaseComponent {
25480
25481
  this.handlePreventMouseDown = e => {
25481
25482
  this.foundation.handlePreventMouseDown(e);
25482
25483
  };
25484
+ const initValue = 'value' in props ? props.value : props.defaultValue;
25483
25485
  this.state = {
25484
- value: '',
25485
- cachedValue: null,
25486
+ value: initValue,
25487
+ cachedValue: props.value,
25486
25488
  disabled: false,
25487
25489
  props: {},
25488
25490
  isFocus: false,
@@ -25555,7 +25557,6 @@ class Input extends BaseComponent {
25555
25557
  componentDidMount() {
25556
25558
  // autofocus is changed from the original support of input to the support of manually calling the focus method,
25557
25559
  // so that preventScroll can still take effect under the setting of autofocus
25558
- this.foundation.init();
25559
25560
  const {
25560
25561
  disabled,
25561
25562
  autoFocus,
@@ -46908,9 +46909,12 @@ class TagInput extends BaseComponent {
46908
46909
  className,
46909
46910
  disabled,
46910
46911
  placeholder,
46911
- validateStatus
46912
+ validateStatus,
46913
+ prefix,
46914
+ insetLabel,
46915
+ suffix
46912
46916
  } = _a,
46913
- rest = tagInput_rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus"]);
46917
+ rest = tagInput_rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus", "prefix", "insetLabel", "suffix"]);
46914
46918
  const {
46915
46919
  focusing,
46916
46920
  hovering,
@@ -46925,7 +46929,9 @@ class TagInput extends BaseComponent {
46925
46929
  [`${tagInput_prefixCls}-error`]: validateStatus === 'error',
46926
46930
  [`${tagInput_prefixCls}-warning`]: validateStatus === 'warning',
46927
46931
  [`${tagInput_prefixCls}-small`]: size === 'small',
46928
- [`${tagInput_prefixCls}-large`]: size === 'large'
46932
+ [`${tagInput_prefixCls}-large`]: size === 'large',
46933
+ [`${tagInput_prefixCls}-with-prefix`]: !!prefix || !!insetLabel,
46934
+ [`${tagInput_prefixCls}-with-suffix`]: !!suffix
46929
46935
  });
46930
46936
  const inputCls = classnames_default()(`${tagInput_prefixCls}-wrapper-input`, `${tagInput_prefixCls}-wrapper-input-${size}`);
46931
46937
  const wrapperCls = classnames_default()(`${tagInput_prefixCls}-wrapper`);
@@ -64302,21 +64308,7 @@ class TextAreaFoundation extends foundation {
64302
64308
  }
64303
64309
  };
64304
64310
  }
64305
- init() {
64306
- this.setInitValue();
64307
- }
64308
64311
  destroy() {}
64309
- setInitValue() {
64310
- const {
64311
- defaultValue,
64312
- value
64313
- } = this.getProps();
64314
- let v = defaultValue;
64315
- if (this._isControlledComponent()) {
64316
- v = value;
64317
- }
64318
- this._adapter.setValue(v);
64319
- }
64320
64312
  handleValueChange(v) {
64321
64313
  this._adapter.setValue(v);
64322
64314
  }
@@ -64544,12 +64536,14 @@ class TextArea extends BaseComponent {
64544
64536
  forwardRef.current = node;
64545
64537
  }
64546
64538
  };
64539
+ const initValue = 'value' in props ? props.value : props.defaultValue;
64547
64540
  this.state = {
64548
- value: '',
64541
+ value: initValue,
64549
64542
  isFocus: false,
64550
64543
  isHover: false,
64551
64544
  height: 0,
64552
- minLength: props.minLength
64545
+ minLength: props.minLength,
64546
+ cachedValue: props.value
64553
64547
  };
64554
64548
  this.focusing = false;
64555
64549
  this.foundation = new TextAreaFoundation(this.adapter);
@@ -66549,7 +66543,7 @@ class Item_NavItem extends BaseComponent {
66549
66543
  onMouseEnter: onMouseEnter,
66550
66544
  onMouseLeave: onMouseLeave,
66551
66545
  onKeyPress: this.handleKeyPress
66552
- }), itemChildren);
66546
+ }, this.getDataAttr(this.props)), itemChildren);
66553
66547
  }
66554
66548
  // Display Tooltip when disabled and SubNav
66555
66549
  if (isCollapsed && !isInSubNav && !isSubNav || isCollapsed && isSubNav && disabled) {
@@ -81660,9 +81654,6 @@ class TableRow extends BaseComponent {
81660
81654
  }
81661
81655
  constructor(props) {
81662
81656
  super(props);
81663
- this._cacheNode = node => {
81664
- this.ref.current = node;
81665
- };
81666
81657
  // Pass true to render the tree-shaped expand button
81667
81658
  this.renderExpandIcon = record => {
81668
81659
  const {
@@ -81691,7 +81682,6 @@ class TableRow extends BaseComponent {
81691
81682
  customRowProps.onClick(e);
81692
81683
  }
81693
81684
  };
81694
- this.ref = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.createRef)();
81695
81685
  this.foundation = new TableRowFoundation(this.adapter);
81696
81686
  }
81697
81687
  componentDidMount() {
@@ -81832,7 +81822,8 @@ class TableRow extends BaseComponent {
81832
81822
  expandableRow,
81833
81823
  level,
81834
81824
  expandedRow,
81835
- isSection
81825
+ isSection,
81826
+ rowKey
81836
81827
  } = this.props;
81837
81828
  const BodyRow = components.body.row;
81838
81829
  const _a = onRow(record, index) || {},
@@ -81843,7 +81834,7 @@ class TableRow extends BaseComponent {
81843
81834
  rowProps = BaseRow_rest(_a, ["className", "style"]);
81844
81835
  this.adapter.setCache('customRowProps', Object.assign({}, rowProps));
81845
81836
  const baseRowStyle = Object.assign(Object.assign({}, style), customStyle);
81846
- const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? replaceClassName : classnames_default()(className, `${prefixCls}-row`, {
81837
+ const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? classnames_default()(replaceClassName, customClassName) : classnames_default()(className, `${prefixCls}-row`, {
81847
81838
  [`${prefixCls}-row-selected`]: selected,
81848
81839
  [`${prefixCls}-row-expanded`]: expanded,
81849
81840
  [`${prefixCls}-row-hovered`]: hovered,
@@ -81871,7 +81862,7 @@ class TableRow extends BaseComponent {
81871
81862
  }, ariaProps, rowProps, {
81872
81863
  style: baseRowStyle,
81873
81864
  className: rowCls,
81874
- ref: this._cacheNode,
81865
+ "data-row-key": rowKey,
81875
81866
  onMouseEnter: this.handleMouseEnter,
81876
81867
  onMouseLeave: this.handleMouseLeave,
81877
81868
  onClick: this.handleClick
@@ -91164,15 +91155,17 @@ class TreeSelect extends BaseComponent {
91164
91155
  leafOnly,
91165
91156
  searchPosition,
91166
91157
  triggerRender,
91167
- borderless
91158
+ borderless,
91159
+ checkRelation
91168
91160
  } = _a,
91169
- rest = treeSelect_rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
91161
+ rest = treeSelect_rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
91170
91162
  const {
91171
91163
  inputValue,
91172
91164
  selectedKeys,
91173
91165
  checkedKeys,
91174
91166
  keyEntities,
91175
- isFocus
91167
+ isFocus,
91168
+ realCheckedKeys
91176
91169
  } = this.state;
91177
91170
  const filterable = Boolean(filterTreeNode);
91178
91171
  const useCustomTrigger = typeof triggerRender === 'function';
@@ -91200,31 +91193,45 @@ class TreeSelect extends BaseComponent {
91200
91193
  [`${treeSelect_prefixcls}-with-suffix`]: suffix,
91201
91194
  [`${treeSelect_prefixcls}-with-suffix`]: suffix
91202
91195
  }, className);
91203
- const triggerRenderKeys = multiple ? normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true) : selectedKeys;
91204
- const inner = useCustomTrigger ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
91205
- inputValue: inputValue,
91206
- value: triggerRenderKeys.map(key => get_default()(keyEntities, [key, 'data'])),
91207
- disabled: disabled,
91208
- placeholder: placeholder,
91209
- onClear: this.handleClear,
91210
- componentName: 'TreeSelect',
91211
- triggerRender: triggerRender,
91212
- componentProps: Object.assign({}, this.props),
91213
- onSearch: this.search,
91214
- onRemove: this.removeTag
91215
- }) : [/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91216
- key: 'prefix'
91217
- }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91218
- key: 'selection'
91219
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
91220
- className: `${treeSelect_prefixcls}-selection`
91221
- }, this.renderSelectContent())), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91222
- key: 'suffix'
91223
- }, suffix ? this.renderSuffix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91224
- key: 'clearBtn'
91225
- }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91226
- key: 'arrow'
91227
- }, this.renderArrow())];
91196
+ let inner;
91197
+ if (useCustomTrigger) {
91198
+ let triggerRenderKeys = [];
91199
+ if (multiple) {
91200
+ if (checkRelation === 'related') {
91201
+ triggerRenderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true);
91202
+ } else if (checkRelation === 'unRelated') {
91203
+ triggerRenderKeys = [...realCheckedKeys];
91204
+ }
91205
+ } else {
91206
+ triggerRenderKeys = selectedKeys;
91207
+ }
91208
+ inner = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
91209
+ inputValue: inputValue,
91210
+ value: triggerRenderKeys.map(key => get_default()(keyEntities, [key, 'data'])),
91211
+ disabled: disabled,
91212
+ placeholder: placeholder,
91213
+ onClear: this.handleClear,
91214
+ componentName: 'TreeSelect',
91215
+ triggerRender: triggerRender,
91216
+ componentProps: Object.assign({}, this.props),
91217
+ onSearch: this.search,
91218
+ onRemove: this.removeTag
91219
+ });
91220
+ } else {
91221
+ inner = [/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91222
+ key: 'prefix'
91223
+ }, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91224
+ key: 'selection'
91225
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
91226
+ className: `${treeSelect_prefixcls}-selection`
91227
+ }, this.renderSelectContent())), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91228
+ key: 'suffix'
91229
+ }, suffix ? this.renderSuffix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91230
+ key: 'clearBtn'
91231
+ }, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
91232
+ key: 'arrow'
91233
+ }, this.renderArrow())];
91234
+ }
91228
91235
  const tabIndex = disabled ? null : 0;
91229
91236
  /**
91230
91237
  * Reasons for disabling the a11y eslint rule:
@@ -91688,7 +91695,6 @@ class TreeSelect extends BaseComponent {
91688
91695
  };
91689
91696
  }
91690
91697
  static getDerivedStateFromProps(props, prevState) {
91691
- var _a;
91692
91698
  const {
91693
91699
  prevProps,
91694
91700
  rePosKey
@@ -91751,16 +91757,6 @@ class TreeSelect extends BaseComponent {
91751
91757
  newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
91752
91758
  } else if (!prevProps && props.value) {
91753
91759
  newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
91754
- } else if (!isExpandControlled && needUpdateTreeData && props.value) {
91755
- // 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
91756
- // 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
91757
- // 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
91758
- // When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
91759
- // If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
91760
- // So there is no need to recalculate expandedKeys at this time, because the expanded item has been added to expandedKeys when the expand button is clicked
91761
- if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
91762
- newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
91763
- }
91764
91760
  }
91765
91761
  if (!newState.expandedKeys) {
91766
91762
  delete newState.expandedKeys;
@@ -98371,6 +98367,7 @@ function withField(Component, opts) {
98371
98367
  const [touched, setTouched] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)();
98372
98368
  const [cursor, setCursor, getCursor] = useStateWithGetter(0);
98373
98369
  const [status, setStatus] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(validateStatus); // use props.validateStatus to init
98370
+ const isUnmounted = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
98374
98371
  const rulesRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(rules);
98375
98372
  const validateRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(validate);
98376
98373
  const validatePromise = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -98381,6 +98378,9 @@ function withField(Component, opts) {
98381
98378
  updater.updateStateTouched(field, isTouched, callOpts);
98382
98379
  };
98383
98380
  const updateError = (errors, callOpts) => {
98381
+ if (isUnmounted.current) {
98382
+ return;
98383
+ }
98384
98384
  if (errors === getError()) {
98385
98385
  // When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
98386
98386
  // When errors is an array, deepEqual is not used, and it is always treated as a need to update
@@ -98425,7 +98425,7 @@ function withField(Component, opts) {
98425
98425
  validator.validate(model, {
98426
98426
  first: mergeStopValidateWithError
98427
98427
  }, (errors, fields) => {}).then(res => {
98428
- if (validatePromise.current !== rootPromise) {
98428
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
98429
98429
  return;
98430
98430
  }
98431
98431
  // validation passed
@@ -98433,7 +98433,7 @@ function withField(Component, opts) {
98433
98433
  updateError(undefined, callOpts);
98434
98434
  resolve({});
98435
98435
  }).catch(err => {
98436
- if (validatePromise.current !== rootPromise) {
98436
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
98437
98437
  return;
98438
98438
  }
98439
98439
  let {
@@ -98479,7 +98479,7 @@ function withField(Component, opts) {
98479
98479
  } else if (isPromise(maybePromisedErrors)) {
98480
98480
  maybePromisedErrors.then(result => {
98481
98481
  // If the async validate is outdated (a newer validate occurs), the result should be discarded
98482
- if (validatePromise.current !== rootPromise) {
98482
+ if (isUnmounted.current || validatePromise.current !== rootPromise) {
98483
98483
  return;
98484
98484
  }
98485
98485
  if (utils_isValid(result)) {
@@ -98607,11 +98607,14 @@ function withField(Component, opts) {
98607
98607
  rulesRef.current = rules;
98608
98608
  validateRef.current = validate;
98609
98609
  }, [rules, validate]);
98610
- // exec validate once when trigger inlcude 'mount'
98611
98610
  useIsomorphicEffect(() => {
98611
+ // exec validate once when trigger include 'mount'
98612
98612
  if (validateOnMount) {
98613
98613
  fieldValidate(value);
98614
98614
  }
98615
+ return () => {
98616
+ isUnmounted.current = true;
98617
+ };
98615
98618
  // eslint-disable-next-line react-hooks/exhaustive-deps
98616
98619
  }, []);
98617
98620
  // register when mounted,unregister when unmounted
@@ -101541,9 +101544,11 @@ class image_Image extends BaseComponent {
101541
101544
  fallback,
101542
101545
  placeholder,
101543
101546
  imageID,
101544
- setDownloadName
101547
+ setDownloadName,
101548
+ imgCls,
101549
+ imgStyle
101545
101550
  } = _b,
101546
- restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
101551
+ restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
101547
101552
  const outerStyle = Object.assign({
101548
101553
  width,
101549
101554
  height
@@ -101566,9 +101571,11 @@ class image_Image extends BaseComponent {
101566
101571
  src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
101567
101572
  "data-src": src,
101568
101573
  alt: alt,
101574
+ style: imgStyle,
101569
101575
  className: classnames_default()(`${image_prefixCls}-img`, {
101570
101576
  [`${image_prefixCls}-img-preview`]: showPreviewCursor,
101571
- [`${image_prefixCls}-img-error`]: loadStatus === "error"
101577
+ [`${image_prefixCls}-img-error`]: loadStatus === "error",
101578
+ [imgCls]: Boolean(imgCls)
101572
101579
  }),
101573
101580
  width: width,
101574
101581
  height: height,