@douyinfe/semi-ui 2.39.3 → 2.40.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.
@@ -19823,10 +19823,35 @@ var portal = __webpack_require__("P1SV");
19823
19823
 
19824
19824
  const defaultGetContainer = () => document.body;
19825
19825
  class Portal extends external_root_React_commonjs2_react_commonjs_react_amd_react_.PureComponent {
19826
- constructor(props) {
19826
+ constructor(props, context) {
19827
19827
  var _this;
19828
19828
  super(props);
19829
19829
  _this = this;
19830
+ this.initContainer = function (context) {
19831
+ let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19832
+ var _a, _b;
19833
+ let container = undefined;
19834
+ if (!_this.el) {
19835
+ _this.el = document.createElement('div');
19836
+ }
19837
+ if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
19838
+ try {
19839
+ _this.el = document.createElement('div');
19840
+ const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
19841
+ const portalContainer = getContainer();
19842
+ portalContainer.appendChild(_this.el);
19843
+ _this.addStyle(_this.props.style);
19844
+ _this.addClass(_this.props.prefixCls, context, _this.props.className);
19845
+ container = portalContainer;
19846
+ return container;
19847
+ } catch (e) {
19848
+ if (!catchError) {
19849
+ throw e;
19850
+ }
19851
+ }
19852
+ }
19853
+ return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
19854
+ };
19830
19855
  this.addStyle = function () {
19831
19856
  let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19832
19857
  if (_this.el) {
@@ -19836,11 +19861,12 @@ class Portal extends external_root_React_commonjs2_react_commonjs_react_amd_reac
19836
19861
  }
19837
19862
  };
19838
19863
  this.addClass = function (prefixCls) {
19864
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
19839
19865
  const {
19840
19866
  direction
19841
- } = _this.context;
19842
- for (var _len = arguments.length, classNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
19843
- classNames[_key - 1] = arguments[_key];
19867
+ } = context;
19868
+ for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
19869
+ classNames[_key - 2] = arguments[_key];
19844
19870
  }
19845
19871
  const cls = classnames_default()(prefixCls, ...classNames, {
19846
19872
  [`${prefixCls}-rtl`]: direction === 'rtl'
@@ -19849,32 +19875,13 @@ class Portal extends external_root_React_commonjs2_react_commonjs_react_amd_reac
19849
19875
  _this.el.className = cls;
19850
19876
  }
19851
19877
  };
19852
- try {
19853
- this.el = document.createElement('div');
19854
- } catch (e) {}
19855
19878
  this.state = {
19856
- container: undefined
19879
+ container: this.initContainer(context, true)
19857
19880
  };
19858
19881
  }
19859
19882
  componentDidMount() {
19860
- if (!this.el) {
19861
- this.el = document.createElement('div');
19862
- }
19863
- const {
19864
- state,
19865
- props,
19866
- context
19867
- } = this;
19868
- const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
19869
- const container = getContainer();
19870
- if (container !== state.container) {
19871
- // const computedStyle = window.getComputedStyle(container);
19872
- // if (computedStyle.position !== 'relative') {
19873
- // container.style.position = 'relative';
19874
- // }
19875
- container.appendChild(this.el);
19876
- this.addStyle(props.style);
19877
- this.addClass(props.prefixCls, props.className);
19883
+ const container = this.initContainer(this.context);
19884
+ if (container !== this.state.container) {
19878
19885
  this.setState({
19879
19886
  container
19880
19887
  });
@@ -82508,6 +82515,8 @@ const parseToDate = function (input) {
82508
82515
  });
82509
82516
  // console.log(curDate, formatToken);
82510
82517
  return curDate;
82518
+ } else if (typeof input === 'undefined') {
82519
+ return undefined;
82511
82520
  }
82512
82521
  return new Date();
82513
82522
  };
@@ -82770,13 +82779,13 @@ class TimePickerFoundation extends foundation {
82770
82779
  if (this.isValidTimeZone(timeZone)) {
82771
82780
  dates = dates.map(date => utcToZonedTime(this.isValidTimeZone(__prevTimeZone) ? zonedTimeToUtc(date, __prevTimeZone) : date, timeZone));
82772
82781
  }
82773
- const inputValue = this.formatValue(dates);
82774
- this.setState({
82775
- value: dates,
82776
- invalid,
82777
- inputValue
82778
- });
82779
82782
  }
82783
+ const inputValue = this.formatValue(dates);
82784
+ this.setState({
82785
+ value: dates,
82786
+ invalid,
82787
+ inputValue
82788
+ });
82780
82789
  }
82781
82790
  handleFocus(e) {
82782
82791
  if (!this.getState('open')) {
@@ -90013,10 +90022,7 @@ class Upload extends BaseComponent {
90013
90022
  * manual upload by user
90014
90023
  */
90015
90024
  this.upload = () => {
90016
- const {
90017
- fileList
90018
- } = this.state;
90019
- this.foundation.startUpload(fileList);
90025
+ this.foundation.manualUpload();
90020
90026
  };
90021
90027
  /**
90022
90028
  * ref method
@@ -93400,7 +93406,7 @@ class FormFoundation extends foundation {
93400
93406
  });
93401
93407
  });
93402
93408
  }
93403
- submit() {
93409
+ submit(e) {
93404
93410
  const {
93405
93411
  values
93406
93412
  } = this.data;
@@ -93408,11 +93414,11 @@ class FormFoundation extends foundation {
93408
93414
  this.validate().then(resolveValues => {
93409
93415
  // if valid do submit
93410
93416
  const _values = this._adapter.cloneDeep(resolveValues);
93411
- this._adapter.notifySubmit(_values);
93417
+ this._adapter.notifySubmit(_values, e);
93412
93418
  }).catch(errors => {
93413
93419
  const _errors = this._adapter.cloneDeep(errors);
93414
93420
  const _values = this._adapter.cloneDeep(values);
93415
- this._adapter.notifySubmitFail(_errors, _values);
93421
+ this._adapter.notifySubmitFail(_errors, _values, e);
93416
93422
  });
93417
93423
  }
93418
93424
  /**
@@ -94943,11 +94949,11 @@ class Form extends BaseComponent {
94943
94949
  get adapter() {
94944
94950
  return Object.assign(Object.assign({}, super.adapter), {
94945
94951
  cloneDeep: cloneDeep,
94946
- notifySubmit: values => {
94947
- this.props.onSubmit(values);
94952
+ notifySubmit: (values, e) => {
94953
+ this.props.onSubmit(values, e);
94948
94954
  },
94949
- notifySubmitFail: (errors, values) => {
94950
- this.props.onSubmitFail(errors, values);
94955
+ notifySubmitFail: (errors, values, e) => {
94956
+ this.props.onSubmitFail(errors, values, e);
94951
94957
  },
94952
94958
  forceUpdate: callback => {
94953
94959
  this.forceUpdate(callback);
@@ -95018,7 +95024,7 @@ class Form extends BaseComponent {
95018
95024
  }
95019
95025
  submit(e) {
95020
95026
  e.preventDefault();
95021
- this.foundation.submit();
95027
+ this.foundation.submit(e);
95022
95028
  }
95023
95029
  reset(e) {
95024
95030
  e.preventDefault();
@@ -95582,18 +95588,20 @@ class previewFooter_Footer extends BaseComponent {
95582
95588
  disabledZoomOut: zoom === min,
95583
95589
  onRatioClick: this.handleRatioClick,
95584
95590
  onZoomIn: this.handlePlusClick,
95585
- onZoomOut: this.handleMinusClick
95591
+ onZoomOut: this.handleMinusClick,
95592
+ menuItems: this.getMenu()
95586
95593
  };
95587
95594
  return renderPreviewMenu(props);
95588
95595
  };
95589
95596
  // According to showTooltip in props, decide whether to use Tooltip to pack a layer
95590
95597
  // 根据 props 中的 showTooltip 决定是否使用 Tooltip 包一层
95591
- this.getFinalIconElement = (element, content) => {
95598
+ this.getFinalIconElement = (element, content, key) => {
95592
95599
  const {
95593
95600
  showTooltip
95594
95601
  } = this.props;
95595
95602
  return showTooltip ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Tooltip, {
95596
- content: content
95603
+ content: content,
95604
+ key: `tooltip-${key}`
95597
95605
  }, element) : element;
95598
95606
  };
95599
95607
  this.getLocalTextByKey = key => /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(LocaleConsumer, {
@@ -95606,12 +95614,13 @@ class previewFooter_Footer extends BaseComponent {
95606
95614
  prevTip
95607
95615
  } = this.props;
95608
95616
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconChevronLeft, {
95617
+ key: "chevron-left",
95609
95618
  size: "large",
95610
95619
  className: disabledPrev ? `${footerPrefixCls}-disabled` : "",
95611
95620
  onClick: !disabledPrev ? onPrev : undefined
95612
95621
  });
95613
95622
  const content = prevTip !== null && prevTip !== void 0 ? prevTip : this.getLocalTextByKey("prevTip");
95614
- return this.getFinalIconElement(icon, content);
95623
+ return this.getFinalIconElement(icon, content, 'chevron-left');
95615
95624
  };
95616
95625
  this.getIconChevronRight = () => {
95617
95626
  const {
@@ -95620,12 +95629,13 @@ class previewFooter_Footer extends BaseComponent {
95620
95629
  nextTip
95621
95630
  } = this.props;
95622
95631
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconChevronRight, {
95632
+ key: "chevron-right",
95623
95633
  size: "large",
95624
95634
  className: disabledNext ? `${footerPrefixCls}-disabled` : "",
95625
95635
  onClick: !disabledNext ? onNext : undefined
95626
95636
  });
95627
95637
  const content = nextTip !== null && nextTip !== void 0 ? nextTip : this.getLocalTextByKey("nextTip");
95628
- return this.getFinalIconElement(icon, content);
95638
+ return this.getFinalIconElement(icon, content, 'chevron-right');
95629
95639
  };
95630
95640
  this.getIconMinus = () => {
95631
95641
  const {
@@ -95635,12 +95645,13 @@ class previewFooter_Footer extends BaseComponent {
95635
95645
  } = this.props;
95636
95646
  const disabledZoomOut = zoom === min;
95637
95647
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconMinus, {
95648
+ key: "minus",
95638
95649
  size: "large",
95639
95650
  onClick: !disabledZoomOut ? this.handleMinusClick : undefined,
95640
95651
  className: disabledZoomOut ? `${footerPrefixCls}-disabled` : ""
95641
95652
  });
95642
95653
  const content = zoomOutTip !== null && zoomOutTip !== void 0 ? zoomOutTip : this.getLocalTextByKey("zoomOutTip");
95643
- return this.getFinalIconElement(icon, content);
95654
+ return this.getFinalIconElement(icon, content, 'minus');
95644
95655
  };
95645
95656
  this.getIconPlus = () => {
95646
95657
  const {
@@ -95650,12 +95661,13 @@ class previewFooter_Footer extends BaseComponent {
95650
95661
  } = this.props;
95651
95662
  const disabledZoomIn = zoom === max;
95652
95663
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconPlus, {
95664
+ key: "plus",
95653
95665
  size: "large",
95654
95666
  onClick: !disabledZoomIn ? this.handlePlusClick : undefined,
95655
95667
  className: disabledZoomIn ? `${footerPrefixCls}-disabled` : ""
95656
95668
  });
95657
95669
  const content = zoomInTip !== null && zoomInTip !== void 0 ? zoomInTip : this.getLocalTextByKey("zoomInTip");
95658
- return this.getFinalIconElement(icon, content);
95670
+ return this.getFinalIconElement(icon, content, 'plus');
95659
95671
  };
95660
95672
  this.getIconRatio = () => {
95661
95673
  const {
@@ -95664,6 +95676,7 @@ class previewFooter_Footer extends BaseComponent {
95664
95676
  adaptiveTip
95665
95677
  } = this.props;
95666
95678
  const props = {
95679
+ key: "ratio",
95667
95680
  size: "large",
95668
95681
  className: classnames_default()(`${footerPrefixCls}-gap`),
95669
95682
  onClick: this.handleRatioClick
@@ -95675,18 +95688,19 @@ class previewFooter_Footer extends BaseComponent {
95675
95688
  } else {
95676
95689
  content = adaptiveTip !== null && adaptiveTip !== void 0 ? adaptiveTip : this.getLocalTextByKey("adaptiveTip");
95677
95690
  }
95678
- return this.getFinalIconElement(icon, content);
95691
+ return this.getFinalIconElement(icon, content, 'ratio');
95679
95692
  };
95680
95693
  this.getIconRotate = () => {
95681
95694
  const {
95682
95695
  rotateTip
95683
95696
  } = this.props;
95684
95697
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconRotate, {
95698
+ key: "rotate",
95685
95699
  size: "large",
95686
95700
  onClick: this.handleRotateLeft
95687
95701
  });
95688
95702
  const content = rotateTip !== null && rotateTip !== void 0 ? rotateTip : this.getLocalTextByKey("rotateTip");
95689
- return this.getFinalIconElement(icon, content);
95703
+ return this.getFinalIconElement(icon, content, 'rotate');
95690
95704
  };
95691
95705
  this.getIconDownload = () => {
95692
95706
  const {
@@ -95695,6 +95709,7 @@ class previewFooter_Footer extends BaseComponent {
95695
95709
  disableDownload
95696
95710
  } = this.props;
95697
95711
  const icon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconDownload, {
95712
+ key: 'download',
95698
95713
  size: "large",
95699
95714
  onClick: !disableDownload ? onDownload : undefined,
95700
95715
  className: classnames_default()(`${footerPrefixCls}-gap`, {
@@ -95702,44 +95717,63 @@ class previewFooter_Footer extends BaseComponent {
95702
95717
  })
95703
95718
  });
95704
95719
  const content = downloadTip !== null && downloadTip !== void 0 ? downloadTip : this.getLocalTextByKey("downloadTip");
95705
- return this.getFinalIconElement(icon, content);
95720
+ return this.getFinalIconElement(icon, content, 'download');
95721
+ };
95722
+ this.getNumberInfo = () => {
95723
+ const {
95724
+ curPage,
95725
+ totalNum
95726
+ } = this.props;
95727
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
95728
+ className: `${footerPrefixCls}-page`,
95729
+ key: 'info'
95730
+ }, curPage, "/", totalNum);
95731
+ };
95732
+ this.getSlider = () => {
95733
+ const {
95734
+ zoom,
95735
+ min,
95736
+ max,
95737
+ step,
95738
+ showTooltip
95739
+ } = this.props;
95740
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Slider, {
95741
+ key: 'slider',
95742
+ value: zoom,
95743
+ min: min,
95744
+ max: max,
95745
+ step: step,
95746
+ tipFormatter: v => `${v}%`,
95747
+ tooltipVisible: showTooltip ? undefined : false,
95748
+ onChange: this.handleSlideChange
95749
+ });
95750
+ };
95751
+ this.getMenu = () => [this.getIconChevronLeft(), this.getNumberInfo(), this.getIconChevronRight(), this.getIconMinus(), this.getSlider(), this.getIconPlus(), this.getIconRatio(), this.getIconRotate(), this.getIconDownload()];
95752
+ this.getFooterMenu = () => {
95753
+ const menuItems = this.getMenu();
95754
+ menuItems.splice(3, 0, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(divider_0, {
95755
+ layout: "vertical",
95756
+ key: "divider-first"
95757
+ }));
95758
+ menuItems.splice(8, 0, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(divider_0, {
95759
+ layout: "vertical",
95760
+ key: "divider-second"
95761
+ }));
95762
+ return menuItems;
95706
95763
  };
95707
95764
  this.foundation = new PreviewFooterFoundation(this.adapter);
95708
95765
  }
95709
95766
  render() {
95710
95767
  const {
95711
- min,
95712
- max,
95713
- step,
95714
- curPage,
95715
- totalNum,
95716
- zoom,
95717
- showTooltip,
95718
95768
  className,
95719
95769
  renderPreviewMenu
95720
95770
  } = this.props;
95721
- if (renderPreviewMenu) {
95722
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
95723
- className: `${footerPrefixCls}-wrapper`
95724
- }, this.customRenderViewMenu());
95725
- }
95771
+ const menuCls = classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
95772
+ [`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
95773
+ });
95726
95774
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
95727
- className: classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className)
95728
- }, this.getIconChevronLeft(), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
95729
- className: `${footerPrefixCls}-page`
95730
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", null, curPage), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", null, "/"), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", null, totalNum)), this.getIconChevronRight(), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(divider_0, {
95731
- layout: "vertical"
95732
- }), this.getIconMinus(), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Slider, {
95733
- value: zoom,
95734
- min: min,
95735
- max: max,
95736
- step: step,
95737
- tipFormatter: v => `${v}%`,
95738
- tooltipVisible: showTooltip ? undefined : false,
95739
- onChange: this.handleSlideChange
95740
- }), this.getIconPlus(), this.getIconRatio(), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(divider_0, {
95741
- layout: "vertical"
95742
- }), this.getIconRotate(), this.getIconDownload());
95775
+ className: menuCls
95776
+ }, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
95743
95777
  }
95744
95778
  }
95745
95779
  previewFooter_Footer.propTypes = {
@@ -96499,8 +96533,9 @@ class PreviewInnerFoundation extends foundation {
96499
96533
  currentIndex,
96500
96534
  imgSrc
96501
96535
  } = this.getStates();
96536
+ const setDownloadName = this._adapter.getSetDownloadFunc();
96502
96537
  const downloadSrc = imgSrc[currentIndex];
96503
- const downloadName = downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
96538
+ const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
96504
96539
  downloadImage(downloadSrc, downloadName);
96505
96540
  this._adapter.notifyDownload(downloadSrc, currentIndex);
96506
96541
  };
@@ -96782,6 +96817,10 @@ class PreviewInner extends BaseComponent {
96782
96817
  },
96783
96818
  setMouseActiveTime: time => {
96784
96819
  previewInner_mouseActiveTime = time;
96820
+ },
96821
+ getSetDownloadFunc: () => {
96822
+ var _a, _b;
96823
+ return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.setDownloadName) !== null && _b !== void 0 ? _b : this.props.setDownloadName;
96785
96824
  }
96786
96825
  });
96787
96826
  }
@@ -97316,9 +97355,10 @@ class image_Image extends BaseComponent {
97316
97355
  preview,
97317
97356
  fallback,
97318
97357
  placeholder,
97319
- imageID
97358
+ imageID,
97359
+ setDownloadName
97320
97360
  } = _b,
97321
- restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID"]);
97361
+ restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
97322
97362
  const outerStyle = Object.assign({
97323
97363
  width,
97324
97364
  height
@@ -97351,7 +97391,8 @@ class image_Image extends BaseComponent {
97351
97391
  src: previewSrc,
97352
97392
  visible: previewVisible,
97353
97393
  onVisibleChange: this.handlePreviewVisibleChange,
97354
- crossOrigin: !isUndefined_default()(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin
97394
+ crossOrigin: !isUndefined_default()(crossOrigin) ? crossOrigin : previewProps === null || previewProps === void 0 ? void 0 : previewProps.crossOrigin,
97395
+ setDownloadName: setDownloadName
97355
97396
  })));
97356
97397
  }
97357
97398
  }
@@ -97557,9 +97598,10 @@ class Preview extends BaseComponent {
97557
97598
  src,
97558
97599
  className,
97559
97600
  style,
97560
- lazyLoad
97601
+ lazyLoad,
97602
+ setDownloadName
97561
97603
  } = _a,
97562
- restProps = preview_rest(_a, ["src", "className", "style", "lazyLoad"]);
97604
+ restProps = preview_rest(_a, ["src", "className", "style", "lazyLoad", "setDownloadName"]);
97563
97605
  const {
97564
97606
  currentIndex,
97565
97607
  visible
@@ -97581,7 +97623,8 @@ class Preview extends BaseComponent {
97581
97623
  lazyLoad,
97582
97624
  previewObserver: this.previewObserver,
97583
97625
  setCurrentIndex: this.handleCurrentIndexChange,
97584
- handleVisibleChange: this.handleVisibleChange
97626
+ handleVisibleChange: this.handleVisibleChange,
97627
+ setDownloadName: setDownloadName
97585
97628
  }
97586
97629
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
97587
97630
  id: this.previewGroupId,