@douyinfe/semi-ui 2.47.0 → 2.48.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.
@@ -27299,8 +27299,27 @@ class AvatarFoundation extends foundation {
27299
27299
  this.handleBlur = () => {
27300
27300
  this._adapter.setFocusVisible(false);
27301
27301
  };
27302
+ this.changeScale = () => {
27303
+ const {
27304
+ gap
27305
+ } = this.getProps();
27306
+ const node = this._adapter.getAvatarNode();
27307
+ const stringNode = node === null || node === void 0 ? void 0 : node.firstChild;
27308
+ const [nodeWidth, stringNodeWidth] = [(node === null || node === void 0 ? void 0 : node.offsetWidth) || 0, (stringNode === null || stringNode === void 0 ? void 0 : stringNode.offsetWidth) || 0];
27309
+ if (nodeWidth !== 0 && stringNodeWidth !== 0 && gap * 2 < nodeWidth) {
27310
+ const scale = nodeWidth - gap * 2 > stringNodeWidth ? 1 : (nodeWidth - gap * 2) / stringNodeWidth;
27311
+ this._adapter.setScale(scale);
27312
+ }
27313
+ };
27314
+ }
27315
+ init() {
27316
+ const {
27317
+ children
27318
+ } = this.getProps();
27319
+ if (typeof children === "string") {
27320
+ this.changeScale();
27321
+ }
27302
27322
  }
27303
- init() {}
27304
27323
  destroy() {}
27305
27324
  handleImgLoadError() {
27306
27325
  const {
@@ -27399,8 +27418,12 @@ class Avatar extends BaseComponent {
27399
27418
  })
27400
27419
  };
27401
27420
  const finalProps = clickable ? Object.assign(Object.assign({}, props), a11yFocusProps) : props;
27421
+ const stringStyle = {
27422
+ transform: `scale(${this.state.scale})`
27423
+ };
27402
27424
  content = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
27403
- className: `${avatar_prefixCls}-content`
27425
+ className: `${avatar_prefixCls}-content`,
27426
+ style: stringStyle
27404
27427
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", Object.assign({}, finalProps, {
27405
27428
  "x-semi-prop": "children"
27406
27429
  }), children));
@@ -27410,13 +27433,15 @@ class Avatar extends BaseComponent {
27410
27433
  this.state = {
27411
27434
  isImgExist: true,
27412
27435
  hoverContent: '',
27413
- focusVisible: false
27436
+ focusVisible: false,
27437
+ scale: 1
27414
27438
  };
27415
27439
  this.onEnter = this.onEnter.bind(this);
27416
27440
  this.onLeave = this.onLeave.bind(this);
27417
27441
  this.handleError = this.handleError.bind(this);
27418
27442
  this.handleKeyDown = this.handleKeyDown.bind(this);
27419
27443
  this.getContent = this.getContent.bind(this);
27444
+ this.avatarRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
27420
27445
  }
27421
27446
  get adapter() {
27422
27447
  return Object.assign(Object.assign({}, super.adapter), {
@@ -27453,6 +27478,15 @@ class Avatar extends BaseComponent {
27453
27478
  this.setState({
27454
27479
  focusVisible
27455
27480
  });
27481
+ },
27482
+ setScale: scale => {
27483
+ this.setState({
27484
+ scale
27485
+ });
27486
+ },
27487
+ getAvatarNode: () => {
27488
+ var _a;
27489
+ return (_a = this.avatarRef) === null || _a === void 0 ? void 0 : _a.current;
27456
27490
  }
27457
27491
  });
27458
27492
  }
@@ -27480,6 +27514,9 @@ class Avatar extends BaseComponent {
27480
27514
  });
27481
27515
  };
27482
27516
  }
27517
+ if (typeof this.props.children === "string" && this.props.children !== prevProps.children) {
27518
+ this.foundation.changeScale();
27519
+ }
27483
27520
  }
27484
27521
  componentWillUnmount() {
27485
27522
  this.foundation.destroy();
@@ -27523,9 +27560,10 @@ class Avatar extends BaseComponent {
27523
27560
  src,
27524
27561
  srcSet,
27525
27562
  style,
27526
- alt
27563
+ alt,
27564
+ gap
27527
27565
  } = _a,
27528
- others = avatar_rest(_a, ["shape", "children", "size", "color", "className", "hoverMask", "onClick", "imgAttr", "src", "srcSet", "style", "alt"]);
27566
+ others = avatar_rest(_a, ["shape", "children", "size", "color", "className", "hoverMask", "onClick", "imgAttr", "src", "srcSet", "style", "alt", "gap"]);
27529
27567
  const {
27530
27568
  isImgExist,
27531
27569
  hoverContent,
@@ -27549,7 +27587,8 @@ class Avatar extends BaseComponent {
27549
27587
  onClick: onClick,
27550
27588
  onMouseEnter: this.onEnter,
27551
27589
  onMouseLeave: this.onLeave,
27552
- role: 'listitem'
27590
+ role: 'listitem',
27591
+ ref: this.avatarRef
27553
27592
  }), this.getContent(), hoverRender);
27554
27593
  }
27555
27594
  }
@@ -27557,6 +27596,7 @@ Avatar.defaultProps = {
27557
27596
  size: 'medium',
27558
27597
  color: 'grey',
27559
27598
  shape: 'circle',
27599
+ gap: 3,
27560
27600
  onClick: function_noop,
27561
27601
  onMouseEnter: function_noop,
27562
27602
  onMouseLeave: function_noop
@@ -27569,6 +27609,7 @@ Avatar.propTypes = {
27569
27609
  hoverMask: (prop_types_default()).node,
27570
27610
  className: (prop_types_default()).string,
27571
27611
  style: (prop_types_default()).object,
27612
+ gap: (prop_types_default()).number,
27572
27613
  imgAttr: (prop_types_default()).object,
27573
27614
  src: (prop_types_default()).string,
27574
27615
  srcSet: (prop_types_default()).string,
@@ -76254,6 +76295,7 @@ class Slider extends BaseComponent {
76254
76295
  });
76255
76296
  const handleContents = !range ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Tooltip, {
76256
76297
  content: tipChildren.min,
76298
+ showArrow: this.props.showArrow,
76257
76299
  position: "top",
76258
76300
  trigger: "custom",
76259
76301
  rePosKey: minPercent,
@@ -76452,7 +76494,7 @@ class Slider extends BaseComponent {
76452
76494
  [`${slider_prefixCls}-dot-active`]: this.foundation.isMarkActive(Number(mark)) === 'active'
76453
76495
  });
76454
76496
  const markPercent = (Number(mark) - min) / (max - min);
76455
- return activeResult ?
76497
+ const dotDOM =
76456
76498
  /*#__PURE__*/
76457
76499
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
76458
76500
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
@@ -76462,11 +76504,17 @@ class Slider extends BaseComponent {
76462
76504
  style: {
76463
76505
  [stylePos]: `calc(${markPercent * 100}% - 2px)`
76464
76506
  }
76465
- }) : null;
76507
+ });
76508
+ return activeResult ? this.props.tooltipOnMark ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Tooltip, {
76509
+ content: marks[mark]
76510
+ }, dotDOM) : dotDOM : null;
76466
76511
  })) : null;
76467
76512
  return labelContent;
76468
76513
  };
76469
76514
  this.renderLabel = () => {
76515
+ if (!this.props.showMarkLabel) {
76516
+ return null;
76517
+ }
76470
76518
  const {
76471
76519
  min,
76472
76520
  max,
@@ -76795,6 +76843,7 @@ Slider.propTypes = {
76795
76843
  // allowClear: PropTypes.bool,
76796
76844
  defaultValue: prop_types_default().oneOfType([(prop_types_default()).number, (prop_types_default()).array]),
76797
76845
  disabled: (prop_types_default()).bool,
76846
+ showMarkLabel: (prop_types_default()).bool,
76798
76847
  included: (prop_types_default()).bool,
76799
76848
  marks: (prop_types_default()).object,
76800
76849
  max: (prop_types_default()).number,
@@ -76807,7 +76856,9 @@ Slider.propTypes = {
76807
76856
  onAfterChange: (prop_types_default()).func,
76808
76857
  onChange: (prop_types_default()).func,
76809
76858
  onMouseUp: (prop_types_default()).func,
76859
+ tooltipOnMark: (prop_types_default()).bool,
76810
76860
  tooltipVisible: (prop_types_default()).bool,
76861
+ showArrow: (prop_types_default()).bool,
76811
76862
  style: (prop_types_default()).object,
76812
76863
  className: (prop_types_default()).string,
76813
76864
  showBoundary: (prop_types_default()).bool,
@@ -76818,10 +76869,13 @@ Slider.propTypes = {
76818
76869
  Slider.defaultProps = {
76819
76870
  // allowClear: false,
76820
76871
  disabled: false,
76872
+ showMarkLabel: true,
76873
+ tooltipOnMark: false,
76821
76874
  included: true,
76822
76875
  max: 100,
76823
76876
  min: 0,
76824
76877
  range: false,
76878
+ showArrow: true,
76825
76879
  step: 1,
76826
76880
  tipFormatter: value => value,
76827
76881
  vertical: false,
@@ -80504,9 +80558,6 @@ class HeadTable extends (external_root_React_commonjs2_react_commonjs_react_amd_
80504
80558
  bodyHasScrollBar,
80505
80559
  sticky
80506
80560
  } = this.props;
80507
- if (!showHeader) {
80508
- return null;
80509
- }
80510
80561
  const Table = get_default()(components, 'header.outer', 'table');
80511
80562
  const x = get_default()(scroll, 'x');
80512
80563
  const headStyle = {};
@@ -80527,7 +80578,8 @@ class HeadTable extends (external_root_React_commonjs2_react_commonjs_react_amd_
80527
80578
  onDidUpdate: onDidUpdate
80528
80579
  }));
80529
80580
  const headTableCls = classnames_default()(`${prefixCls}-header`, {
80530
- [`${prefixCls}-header-sticky`]: sticky
80581
+ [`${prefixCls}-header-sticky`]: sticky,
80582
+ [`${prefixCls}-header-hidden`]: !showHeader
80531
80583
  });
80532
80584
  const stickyTop = get_default()(sticky, 'top', 0);
80533
80585
  if (typeof stickyTop === 'number') {