@douyinfe/semi-ui 2.49.0-beta.0 → 2.49.1

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.
@@ -17286,6 +17286,8 @@ __webpack_require__.d(__webpack_exports__, {
17286
17286
  "BackTop": () => (/* reexport */ BackTop),
17287
17287
  "Badge": () => (/* reexport */ Badge),
17288
17288
  "Banner": () => (/* reexport */ Banner),
17289
+ "BaseComponent": () => (/* reexport */ BaseComponent),
17290
+ "BaseFoundation": () => (/* reexport */ foundation),
17289
17291
  "Breadcrumb": () => (/* reexport */ breadcrumb_0),
17290
17292
  "Button": () => (/* reexport */ button_0),
17291
17293
  "ButtonGroup": () => (/* reexport */ ButtonGroup),
@@ -17375,45 +17377,12 @@ __webpack_require__.d(__webpack_exports__, {
17375
17377
 
17376
17378
  // EXTERNAL MODULE: ./_base/base.scss
17377
17379
  var base = __webpack_require__("q7sR");
17378
- // EXTERNAL MODULE: ../../node_modules/lodash/throttle.js
17379
- var throttle = __webpack_require__("Bcqe");
17380
- var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle);
17381
- // EXTERNAL MODULE: ../../node_modules/lodash/debounce.js
17382
- var debounce = __webpack_require__("RNvQ");
17383
- var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
17384
17380
  // EXTERNAL MODULE: ../../node_modules/lodash/noop.js
17385
17381
  var noop = __webpack_require__("nnm9");
17386
17382
  var noop_default = /*#__PURE__*/__webpack_require__.n(noop);
17387
- // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
17388
- var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__("neV8");
17389
- var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
17390
- // EXTERNAL MODULE: ../../node_modules/classnames/index.js
17391
- var classnames = __webpack_require__("O94r");
17392
- var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
17393
- // EXTERNAL MODULE: ../../node_modules/prop-types/index.js
17394
- var prop_types = __webpack_require__("aWzz");
17395
- var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
17396
- ;// CONCATENATED MODULE: ../semi-foundation/base/env.ts
17397
- const BASE_CLASS_PREFIX = 'semi';
17398
- ;// CONCATENATED MODULE: ../semi-foundation/anchor/constants.ts
17399
-
17400
- const cssClasses = {
17401
- PREFIX: `${BASE_CLASS_PREFIX}-anchor`
17402
- };
17403
- const constants_strings = {
17404
- SIZE: ['small', 'default'],
17405
- SLIDE_COLOR: ['primary', 'tertiary', 'muted'],
17406
- MAX_WIDTH: '200px',
17407
- MAX_HEIGHT: '750px',
17408
- POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver']
17409
- };
17410
-
17411
17383
  // EXTERNAL MODULE: ../../node_modules/lodash/get.js
17412
17384
  var get = __webpack_require__("2srY");
17413
17385
  var get_default = /*#__PURE__*/__webpack_require__.n(get);
17414
- // EXTERNAL MODULE: ../../node_modules/lodash/isArray.js
17415
- var isArray = __webpack_require__("wxYD");
17416
- var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray);
17417
17386
  ;// CONCATENATED MODULE: ../semi-foundation/utils/log.ts
17418
17387
 
17419
17388
  const log = function (text) {
@@ -17540,6 +17509,115 @@ class BaseFoundation {
17540
17509
  }
17541
17510
  }
17542
17511
  /* harmony default export */ const foundation = (BaseFoundation);
17512
+ // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
17513
+ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__("neV8");
17514
+ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
17515
+ ;// CONCATENATED MODULE: ../semi-foundation/utils/getDataAttr.ts
17516
+ function getDataAttr(props) {
17517
+ return Object.keys(props).reduce((prev, key) => {
17518
+ if (key.substr(0, 5) === 'data-') {
17519
+ prev[key] = props[key];
17520
+ }
17521
+ return prev;
17522
+ }, {});
17523
+ }
17524
+ ;// CONCATENATED MODULE: ./_base/baseComponent.tsx
17525
+ /**
17526
+ * The Semi Foundation / Adapter architecture split was inspired by Material Component For Web. (https://github.com/material-components/material-components-web)
17527
+ * We re-implemented our own code based on the principle and added more functions we need according to actual needs.
17528
+ */
17529
+
17530
+
17531
+
17532
+ const {
17533
+ hasOwnProperty: baseComponent_hasOwnProperty
17534
+ } = Object.prototype;
17535
+ // eslint-disable-next-line
17536
+ class BaseComponent extends external_root_React_commonjs2_react_commonjs_react_amd_react_.Component {
17537
+ constructor(props) {
17538
+ super(props);
17539
+ // eslint-disable-next-line
17540
+ this.isControlled = key => Boolean(key && this.props && typeof this.props === 'object' && baseComponent_hasOwnProperty.call(this.props, key));
17541
+ this.cache = {};
17542
+ this.foundation = null;
17543
+ }
17544
+ componentDidMount() {
17545
+ this.foundation && typeof this.foundation.init === 'function' && this.foundation.init();
17546
+ }
17547
+ componentWillUnmount() {
17548
+ this.foundation && typeof this.foundation.destroy === 'function' && this.foundation.destroy();
17549
+ this.cache = {};
17550
+ }
17551
+ get adapter() {
17552
+ return {
17553
+ getContext: key => {
17554
+ if (this.context && key) {
17555
+ return this.context[key];
17556
+ }
17557
+ },
17558
+ getContexts: () => this.context,
17559
+ getProp: key => this.props[key],
17560
+ // return all props
17561
+ getProps: () => this.props,
17562
+ getState: key => this.state[key],
17563
+ getStates: () => this.state,
17564
+ setState: (states, cb) => this.setState(Object.assign({}, states), cb),
17565
+ getCache: key => key && this.cache[key],
17566
+ getCaches: () => this.cache,
17567
+ setCache: (key, value) => key && (this.cache[key] = value),
17568
+ stopPropagation: e => {
17569
+ try {
17570
+ e.stopPropagation();
17571
+ e.nativeEvent && e.nativeEvent.stopImmediatePropagation();
17572
+ } catch (error) {}
17573
+ },
17574
+ persistEvent: e => {
17575
+ e && e.persist && typeof e.persist === 'function' ? e.persist() : null;
17576
+ }
17577
+ };
17578
+ }
17579
+ log(text) {
17580
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17581
+ rest[_key - 1] = arguments[_key];
17582
+ }
17583
+ return utils_log(text, ...rest);
17584
+ }
17585
+ getDataAttr(props) {
17586
+ return getDataAttr(props);
17587
+ }
17588
+ }
17589
+ BaseComponent.propTypes = {};
17590
+ BaseComponent.defaultProps = {};
17591
+ // EXTERNAL MODULE: ../../node_modules/lodash/throttle.js
17592
+ var throttle = __webpack_require__("Bcqe");
17593
+ var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle);
17594
+ // EXTERNAL MODULE: ../../node_modules/lodash/debounce.js
17595
+ var debounce = __webpack_require__("RNvQ");
17596
+ var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
17597
+ // EXTERNAL MODULE: ../../node_modules/classnames/index.js
17598
+ var classnames = __webpack_require__("O94r");
17599
+ var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
17600
+ // EXTERNAL MODULE: ../../node_modules/prop-types/index.js
17601
+ var prop_types = __webpack_require__("aWzz");
17602
+ var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
17603
+ ;// CONCATENATED MODULE: ../semi-foundation/base/env.ts
17604
+ const BASE_CLASS_PREFIX = 'semi';
17605
+ ;// CONCATENATED MODULE: ../semi-foundation/anchor/constants.ts
17606
+
17607
+ const cssClasses = {
17608
+ PREFIX: `${BASE_CLASS_PREFIX}-anchor`
17609
+ };
17610
+ const constants_strings = {
17611
+ SIZE: ['small', 'default'],
17612
+ SLIDE_COLOR: ['primary', 'tertiary', 'muted'],
17613
+ MAX_WIDTH: '200px',
17614
+ MAX_HEIGHT: '750px',
17615
+ POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver']
17616
+ };
17617
+
17618
+ // EXTERNAL MODULE: ../../node_modules/lodash/isArray.js
17619
+ var isArray = __webpack_require__("wxYD");
17620
+ var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray);
17543
17621
  ;// CONCATENATED MODULE: ../../node_modules/compute-scroll-into-view/dist/index.mjs
17544
17622
  function t(t){return"object"==typeof t&&null!=t&&1===t.nodeType}function e(t,e){return(!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function n(t,n){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return e(r.overflowY,n)||e(r.overflowX,n)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return!!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return!1}function r(t,e,n,r,i,o,l,d){return o<t&&l>e||o>t&&l<e?0:o<=t&&d<=n||l>=e&&d>=n?o-t-r:l>e&&d<n||o<t&&d>n?l-e+i:0}var i=function(e,i){var o=window,l=i.scrollMode,d=i.block,f=i.inline,h=i.boundary,u=i.skipOverflowHiddenElements,s="function"==typeof h?h:function(t){return t!==h};if(!t(e))throw new TypeError("Invalid target");for(var a,c,g=document.scrollingElement||document.documentElement,p=[],m=e;t(m)&&s(m);){if((m=null==(c=(a=m).parentElement)?a.getRootNode().host||null:c)===g){p.push(m);break}null!=m&&m===document.body&&n(m)&&!n(document.documentElement)||null!=m&&n(m,u)&&p.push(m)}for(var w=o.visualViewport?o.visualViewport.width:innerWidth,v=o.visualViewport?o.visualViewport.height:innerHeight,W=window.scrollX||pageXOffset,H=window.scrollY||pageYOffset,b=e.getBoundingClientRect(),y=b.height,E=b.width,M=b.top,V=b.right,x=b.bottom,I=b.left,C="start"===d||"nearest"===d?M:"end"===d?x:M+y/2,R="center"===f?I+E/2:"end"===f?V:I,T=[],k=0;k<p.length;k++){var B=p[k],D=B.getBoundingClientRect(),O=D.height,X=D.width,Y=D.top,L=D.right,S=D.bottom,j=D.left;if("if-needed"===l&&M>=0&&I>=0&&x<=v&&V<=w&&M>=Y&&x<=S&&I>=j&&V<=L)return T;var N=getComputedStyle(B),q=parseInt(N.borderLeftWidth,10),z=parseInt(N.borderTopWidth,10),A=parseInt(N.borderRightWidth,10),F=parseInt(N.borderBottomWidth,10),G=0,J=0,K="offsetWidth"in B?B.offsetWidth-B.clientWidth-q-A:0,P="offsetHeight"in B?B.offsetHeight-B.clientHeight-z-F:0,Q="offsetWidth"in B?0===B.offsetWidth?0:X/B.offsetWidth:0,U="offsetHeight"in B?0===B.offsetHeight?0:O/B.offsetHeight:0;if(g===B)G="start"===d?C:"end"===d?C-v:"nearest"===d?r(H,H+v,v,z,F,H+C,H+C+y,y):C-v/2,J="start"===f?R:"center"===f?R-w/2:"end"===f?R-w:r(W,W+w,w,q,A,W+R,W+R+E,E),G=Math.max(0,G+H),J=Math.max(0,J+W);else{G="start"===d?C-Y-z:"end"===d?C-S+F+P:"nearest"===d?r(Y,S,O,z,F+P,C,C+y,y):C-(Y+O/2)+P/2,J="start"===f?R-j-q:"center"===f?R-(j+X/2)+K/2:"end"===f?R-L+A+K:r(j,L,X,q,A+K,R,R+E,E);var Z=B.scrollLeft,$=B.scrollTop;C+=$-(G=Math.max(0,Math.min($+G/U,B.scrollHeight-O/U+P))),R+=Z-(J=Math.max(0,Math.min(Z+J/Q,B.scrollWidth-X/Q+K)))}T.push({el:B,top:G,left:J})}return T};
17545
17623
  //# sourceMappingURL=index.mjs.map
@@ -17793,82 +17871,6 @@ class AnchorFoundation extends foundation {
17793
17871
  };
17794
17872
  }
17795
17873
  }
17796
- ;// CONCATENATED MODULE: ../semi-foundation/utils/getDataAttr.ts
17797
- function getDataAttr(props) {
17798
- return Object.keys(props).reduce((prev, key) => {
17799
- if (key.substr(0, 5) === 'data-') {
17800
- prev[key] = props[key];
17801
- }
17802
- return prev;
17803
- }, {});
17804
- }
17805
- ;// CONCATENATED MODULE: ./_base/baseComponent.tsx
17806
- /**
17807
- * The Semi Foundation / Adapter architecture split was inspired by Material Component For Web. (https://github.com/material-components/material-components-web)
17808
- * We re-implemented our own code based on the principle and added more functions we need according to actual needs.
17809
- */
17810
-
17811
-
17812
-
17813
- const {
17814
- hasOwnProperty: baseComponent_hasOwnProperty
17815
- } = Object.prototype;
17816
- // eslint-disable-next-line
17817
- class BaseComponent extends external_root_React_commonjs2_react_commonjs_react_amd_react_.Component {
17818
- constructor(props) {
17819
- super(props);
17820
- // eslint-disable-next-line
17821
- this.isControlled = key => Boolean(key && this.props && typeof this.props === 'object' && baseComponent_hasOwnProperty.call(this.props, key));
17822
- this.cache = {};
17823
- this.foundation = null;
17824
- }
17825
- componentDidMount() {
17826
- this.foundation && typeof this.foundation.init === 'function' && this.foundation.init();
17827
- }
17828
- componentWillUnmount() {
17829
- this.foundation && typeof this.foundation.destroy === 'function' && this.foundation.destroy();
17830
- this.cache = {};
17831
- }
17832
- get adapter() {
17833
- return {
17834
- getContext: key => {
17835
- if (this.context && key) {
17836
- return this.context[key];
17837
- }
17838
- },
17839
- getContexts: () => this.context,
17840
- getProp: key => this.props[key],
17841
- // return all props
17842
- getProps: () => this.props,
17843
- getState: key => this.state[key],
17844
- getStates: () => this.state,
17845
- setState: (states, cb) => this.setState(Object.assign({}, states), cb),
17846
- getCache: key => key && this.cache[key],
17847
- getCaches: () => this.cache,
17848
- setCache: (key, value) => key && (this.cache[key] = value),
17849
- stopPropagation: e => {
17850
- try {
17851
- e.stopPropagation();
17852
- e.nativeEvent && e.nativeEvent.stopImmediatePropagation();
17853
- } catch (error) {}
17854
- },
17855
- persistEvent: e => {
17856
- e && e.persist && typeof e.persist === 'function' ? e.persist() : null;
17857
- }
17858
- };
17859
- }
17860
- log(text) {
17861
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17862
- rest[_key - 1] = arguments[_key];
17863
- }
17864
- return utils_log(text, ...rest);
17865
- }
17866
- getDataAttr(props) {
17867
- return getDataAttr(props);
17868
- }
17869
- }
17870
- BaseComponent.propTypes = {};
17871
- BaseComponent.defaultProps = {};
17872
17874
  // EXTERNAL MODULE: ../../node_modules/lodash/isObject.js
17873
17875
  var isObject = __webpack_require__("tQYX");
17874
17876
  var isObject_default = /*#__PURE__*/__webpack_require__.n(isObject);
@@ -69381,6 +69383,7 @@ class SelectFoundation extends foundation {
69381
69383
  this.close(e);
69382
69384
  this._notifyBlur(e);
69383
69385
  this._adapter.updateFocusState(false);
69386
+ this._adapter.unregisterClickOutsideHandler();
69384
69387
  });
69385
69388
  }
69386
69389
  toggle2SearchInput(isShow) {
@@ -69398,7 +69401,6 @@ class SelectFoundation extends foundation {
69398
69401
  this._adapter.setIsFocusInContainer(false);
69399
69402
  // this.unBindKeyBoardEvent();
69400
69403
  // this._notifyBlur(e);
69401
- this._adapter.unregisterClickOutsideHandler();
69402
69404
  // this._adapter.updateFocusState(false);
69403
69405
  const isFilterable = this._isFilterable();
69404
69406
  if (isFilterable) {
@@ -98950,14 +98952,14 @@ const PreviewContext = /*#__PURE__*/(0,external_root_React_commonjs2_react_commo
98950
98952
 
98951
98953
 
98952
98954
  const previewHeader_prefixCls = `${image_constants_cssClasses.PREFIX}-preview-header`;
98953
- const previewHeader_Header = _ref => {
98955
+ const previewHeader_Header = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)((_ref, ref) => {
98954
98956
  let {
98955
98957
  onClose,
98956
98958
  titleStyle,
98957
98959
  className,
98958
98960
  renderHeader
98959
98961
  } = _ref;
98960
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(PreviewContext.Consumer, null, _ref2 => {
98962
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(PreviewContext.Consumer, null, _ref2 => {
98961
98963
  let {
98962
98964
  currentIndex,
98963
98965
  titles
@@ -98966,17 +98968,18 @@ const previewHeader_Header = _ref => {
98966
98968
  if (titles && typeof currentIndex === "number") {
98967
98969
  title = titles[currentIndex];
98968
98970
  }
98969
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98971
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98972
+ ref: ref,
98970
98973
  className: classnames_default()(previewHeader_prefixCls, className)
98971
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98974
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98972
98975
  className: `${previewHeader_prefixCls}-title`,
98973
98976
  style: titleStyle
98974
- }, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98977
+ }, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98975
98978
  className: `${previewHeader_prefixCls}-close`,
98976
98979
  onMouseUp: onClose
98977
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(IconClose, null)));
98980
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconClose, null)));
98978
98981
  });
98979
- };
98982
+ });
98980
98983
  /* harmony default export */ const previewHeader = (previewHeader_Header);
98981
98984
  ;// CONCATENATED MODULE: ../semi-icons/lib/es/icons/IconMinus.js
98982
98985
 
@@ -99132,7 +99135,6 @@ class PreviewFooterFoundation extends foundation {
99132
99135
  } else {
99133
99136
  onZoomOut(Number((value / 100).toFixed(2)));
99134
99137
  }
99135
- this._adapter.setStartMouseOffset(value);
99136
99138
  };
99137
99139
  this.handleRatioClick = () => {
99138
99140
  const {
@@ -99165,14 +99167,9 @@ class PreviewFooterFoundation extends foundation {
99165
99167
 
99166
99168
  const previewFooter_prefixCls = image_constants_cssClasses.PREFIX;
99167
99169
  const footerPrefixCls = `${image_constants_cssClasses.PREFIX}-preview-footer`;
99168
- let mouseActiveTime = 0;
99169
99170
  class previewFooter_Footer extends BaseComponent {
99170
99171
  get adapter() {
99171
- return Object.assign(Object.assign({}, super.adapter), {
99172
- setStartMouseOffset: time => {
99173
- mouseActiveTime = time;
99174
- }
99175
- });
99172
+ return Object.assign({}, super.adapter);
99176
99173
  }
99177
99174
  constructor(props) {
99178
99175
  super(props);
@@ -99412,13 +99409,15 @@ class previewFooter_Footer extends BaseComponent {
99412
99409
  render() {
99413
99410
  const {
99414
99411
  className,
99415
- renderPreviewMenu
99412
+ renderPreviewMenu,
99413
+ forwardRef
99416
99414
  } = this.props;
99417
99415
  const menuCls = classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
99418
99416
  [`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
99419
99417
  });
99420
99418
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
99421
- className: menuCls
99419
+ className: menuCls,
99420
+ ref: forwardRef
99422
99421
  }, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
99423
99422
  }
99424
99423
  }
@@ -99457,9 +99456,6 @@ previewFooter_Footer.defaultProps = {
99457
99456
  };
99458
99457
  ;// CONCATENATED MODULE: ../semi-foundation/image/previewImageFoundation.ts
99459
99458
 
99460
-
99461
-
99462
-
99463
99459
  const DefaultDOMRect = {
99464
99460
  bottom: 0,
99465
99461
  height: 0,
@@ -99474,6 +99470,12 @@ const DefaultDOMRect = {
99474
99470
  class PreviewImageFoundation extends foundation {
99475
99471
  constructor(adapter) {
99476
99472
  super(Object.assign({}, adapter));
99473
+ this.startMouseOffset = {
99474
+ x: 0,
99475
+ y: 0
99476
+ };
99477
+ this.originImageWidth = null;
99478
+ this.originImageHeight = null;
99477
99479
  this._isImageVertical = () => this.getProp("rotation") % 180 !== 0;
99478
99480
  this._getImageBounds = () => {
99479
99481
  const imageDOM = this._adapter.getImage();
@@ -99503,32 +99505,18 @@ class PreviewImageFoundation extends foundation {
99503
99505
  this._adapter.setLoading(loading);
99504
99506
  };
99505
99507
  this.handleWindowResize = () => {
99506
- const {
99507
- ratio,
99508
- setRatio
99509
- } = this.getProps();
99510
- const {
99511
- originImageWidth,
99512
- originImageHeight
99513
- } = this._adapter.getOriginImageSize();
99514
- if (originImageWidth && originImageHeight) {
99515
- if (ratio !== "adaptation") {
99516
- setRatio("adaptation");
99517
- } else {
99518
- this.handleResizeImage();
99519
- }
99508
+ if (this.originImageWidth && this.originImageHeight) {
99509
+ this.handleResizeImage();
99520
99510
  }
99521
99511
  };
99522
99512
  this.handleLoad = e => {
99523
99513
  if (e.target) {
99524
99514
  const {
99525
- width: w,
99526
- height: h
99515
+ naturalWidth: w,
99516
+ naturalHeight: h
99527
99517
  } = e.target;
99528
- this._adapter.setOriginImageSize({
99529
- originImageWidth: w,
99530
- originImageHeight: h
99531
- });
99518
+ this.originImageHeight = h;
99519
+ this.originImageWidth = w;
99532
99520
  this.setState({
99533
99521
  loading: false
99534
99522
  });
@@ -99553,13 +99541,14 @@ class PreviewImageFoundation extends foundation {
99553
99541
  this.handleResizeImage = () => {
99554
99542
  const horizontal = !this._isImageVertical();
99555
99543
  const {
99556
- originImageWidth,
99557
- originImageHeight
99558
- } = this._adapter.getOriginImageSize();
99559
- const imgWidth = horizontal ? originImageWidth : originImageHeight;
99560
- const imgHeight = horizontal ? originImageHeight : originImageWidth;
99544
+ currZoom
99545
+ } = this.getStates();
99546
+ const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
99547
+ const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
99561
99548
  const {
99562
- onZoom
99549
+ onZoom,
99550
+ setRatio,
99551
+ ratio
99563
99552
  } = this.getProps();
99564
99553
  const containerDOM = this._adapter.getContainer();
99565
99554
  if (containerDOM) {
@@ -99569,8 +99558,44 @@ class PreviewImageFoundation extends foundation {
99569
99558
  } = this._getContainerBounds();
99570
99559
  const reservedWidth = containerWidth - 80;
99571
99560
  const reservedHeight = containerHeight - 80;
99572
- const _zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
99573
- onZoom(_zoom);
99561
+ let _zoom = 1;
99562
+ if (imgWidth > reservedWidth || imgHeight > reservedHeight) {
99563
+ _zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
99564
+ }
99565
+ if (currZoom === _zoom) {
99566
+ this.calculatePreviewImage(_zoom, null);
99567
+ } else {
99568
+ onZoom(_zoom);
99569
+ }
99570
+ }
99571
+ };
99572
+ this.handleRatioChange = () => {
99573
+ if (this.originImageWidth && this.originImageHeight) {
99574
+ const {
99575
+ currZoom
99576
+ } = this.getStates();
99577
+ const {
99578
+ ratio,
99579
+ onZoom
99580
+ } = this.getProps();
99581
+ let _zoom;
99582
+ if (ratio === 'adaptation') {
99583
+ const horizontal = !this._isImageVertical();
99584
+ const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
99585
+ const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
99586
+ const {
99587
+ width: containerWidth,
99588
+ height: containerHeight
99589
+ } = this._getContainerBounds();
99590
+ const reservedWidth = containerWidth - 80;
99591
+ const reservedHeight = containerHeight - 80;
99592
+ _zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
99593
+ } else {
99594
+ _zoom = 1;
99595
+ }
99596
+ if (currZoom !== _zoom) {
99597
+ onZoom(_zoom);
99598
+ }
99574
99599
  }
99575
99600
  };
99576
99601
  this.handleRightClickImage = e => {
@@ -99585,38 +99610,6 @@ class PreviewImageFoundation extends foundation {
99585
99610
  return true;
99586
99611
  }
99587
99612
  };
99588
- // e: WheelEvent<HTMLImageElement>
99589
- this.handleWheel = e => {
99590
- this.onWheel(e);
99591
- handlePrevent(e);
99592
- };
99593
- // e: WheelEvent<HTMLImageElement>
99594
- this.onWheel = throttle_default()(e => {
99595
- const {
99596
- onZoom,
99597
- zoomStep,
99598
- maxZoom,
99599
- minZoom
99600
- } = this.getProps();
99601
- const {
99602
- currZoom
99603
- } = this.getStates();
99604
- let _zoom;
99605
- if (e.deltaY < 0) {
99606
- /* zoom in */
99607
- if (currZoom + zoomStep <= maxZoom) {
99608
- _zoom = Number((currZoom + zoomStep).toFixed(2));
99609
- }
99610
- } else if (e.deltaY > 0) {
99611
- /* zoom out */
99612
- if (currZoom - zoomStep >= minZoom) {
99613
- _zoom = Number((currZoom - zoomStep).toFixed(2));
99614
- }
99615
- }
99616
- if (!isUndefined_default()(_zoom)) {
99617
- onZoom(_zoom);
99618
- }
99619
- }, 50);
99620
99613
  this.calcCanDragDirection = () => {
99621
99614
  const {
99622
99615
  width,
@@ -99640,12 +99633,8 @@ class PreviewImageFoundation extends foundation {
99640
99633
  canDragHorizontal
99641
99634
  };
99642
99635
  };
99643
- this.handleZoomChange = (newZoom, e) => {
99636
+ this.calculatePreviewImage = (newZoom, e) => {
99644
99637
  const imageDOM = this._adapter.getImage();
99645
- const {
99646
- originImageWidth,
99647
- originImageHeight
99648
- } = this._adapter.getOriginImageSize();
99649
99638
  const {
99650
99639
  canDragVertical,
99651
99640
  canDragHorizontal
@@ -99655,8 +99644,8 @@ class PreviewImageFoundation extends foundation {
99655
99644
  width: containerWidth,
99656
99645
  height: containerHeight
99657
99646
  } = this._getContainerBounds();
99658
- const newWidth = Math.floor(originImageWidth * newZoom);
99659
- const newHeight = Math.floor(originImageHeight * newZoom);
99647
+ const newWidth = Math.floor(this.originImageWidth * newZoom);
99648
+ const newHeight = Math.floor(this.originImageHeight * newZoom);
99660
99649
  // debugger;
99661
99650
  let _offset;
99662
99651
  const horizontal = !this._isImageVertical();
@@ -99715,13 +99704,13 @@ class PreviewImageFoundation extends foundation {
99715
99704
  width,
99716
99705
  height
99717
99706
  } = this.getStates();
99718
- const startMouseMove = this._adapter.getMouseMove();
99719
- const startMouseOffset = this._adapter.getMouseOffset();
99720
99707
  const {
99721
99708
  canDragVertical,
99722
99709
  canDragHorizontal
99723
99710
  } = this.calcCanDragDirection();
99724
- if (startMouseMove && (canDragVertical || canDragHorizontal)) {
99711
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
99712
+ const mouseLeftPress = e.buttons === 1;
99713
+ if (mouseLeftPress && (canDragVertical || canDragHorizontal)) {
99725
99714
  const {
99726
99715
  clientX,
99727
99716
  clientY
@@ -99734,8 +99723,8 @@ class PreviewImageFoundation extends foundation {
99734
99723
  left: extremeLeft,
99735
99724
  top: extremeTop
99736
99725
  } = this.calcExtremeBounds();
99737
- let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
99738
- let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
99726
+ let newX = canDragHorizontal ? clientX - containerLeft - this.startMouseOffset.x : offset.x;
99727
+ let newY = canDragVertical ? clientY - containerTop - this.startMouseOffset.y : offset.y;
99739
99728
  if (canDragHorizontal) {
99740
99729
  newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
99741
99730
  }
@@ -99754,11 +99743,7 @@ class PreviewImageFoundation extends foundation {
99754
99743
  }
99755
99744
  };
99756
99745
  this.handleImageMouseDown = e => {
99757
- this._adapter.setStartMouseOffset(this._getOffset(e));
99758
- this._adapter.setStartMouseMove(true);
99759
- };
99760
- this.handleImageMouseUp = () => {
99761
- this._adapter.setStartMouseMove(false);
99746
+ this.startMouseOffset = this._getOffset(e);
99762
99747
  };
99763
99748
  }
99764
99749
  }
@@ -99771,38 +99756,14 @@ class PreviewImageFoundation extends foundation {
99771
99756
 
99772
99757
  const previewImage_prefixCls = image_constants_cssClasses.PREFIX;
99773
99758
  const preViewImgPrefixCls = `${previewImage_prefixCls}-preview-image`;
99774
- let originImageWidth = null;
99775
- let originImageHeight = null;
99776
- let startMouseMove = false;
99777
- // startMouseOffset:The offset of the mouse relative to the left and top of the picture
99778
- let startMouseOffset = {
99779
- x: 0,
99780
- y: 0
99781
- };
99782
99759
  class PreviewImage extends BaseComponent {
99783
99760
  get adapter() {
99784
99761
  return Object.assign(Object.assign({}, super.adapter), {
99785
- getOriginImageSize: () => ({
99786
- originImageWidth,
99787
- originImageHeight
99788
- }),
99789
- setOriginImageSize: size => {
99790
- originImageWidth = size.originImageWidth;
99791
- originImageHeight = size.originImageHeight;
99792
- },
99793
99762
  getContainer: () => {
99794
99763
  return this.containerRef.current;
99795
99764
  },
99796
99765
  getImage: () => {
99797
- return this.imageRef;
99798
- },
99799
- getMouseMove: () => startMouseMove,
99800
- setStartMouseMove: move => {
99801
- startMouseMove = move;
99802
- },
99803
- getMouseOffset: () => startMouseOffset,
99804
- setStartMouseOffset: offset => {
99805
- startMouseOffset = offset;
99766
+ return this.imageRef.current;
99806
99767
  },
99807
99768
  setLoading: loading => {
99808
99769
  this.setState({
@@ -99810,7 +99771,7 @@ class PreviewImage extends BaseComponent {
99810
99771
  });
99811
99772
  },
99812
99773
  setImageCursor: canDrag => {
99813
- this.imageRef.style.cursor = canDrag ? "grab" : "default";
99774
+ this.imageRef.current.style.cursor = canDrag ? "grab" : "default";
99814
99775
  }
99815
99776
  });
99816
99777
  }
@@ -99819,52 +99780,22 @@ class PreviewImage extends BaseComponent {
99819
99780
  this.onWindowResize = () => {
99820
99781
  this.foundation.handleWindowResize();
99821
99782
  };
99822
- this.handleZoomChange = (newZoom, e) => {
99823
- this.foundation.handleZoomChange(newZoom, e);
99824
- };
99825
99783
  // Determine the response method of right click according to the disableDownload parameter in props
99826
99784
  this.handleRightClickImage = e => {
99827
99785
  this.foundation.handleRightClickImage(e);
99828
99786
  };
99829
- this.handleWheel = e => {
99830
- this.foundation.handleWheel(e);
99831
- };
99832
99787
  this.handleLoad = e => {
99833
99788
  this.foundation.handleLoad(e);
99834
99789
  };
99835
99790
  this.handleError = e => {
99836
99791
  this.foundation.handleError(e);
99837
99792
  };
99838
- this.resizeImage = () => {
99839
- this.foundation.handleResizeImage();
99840
- };
99841
99793
  this.handleMoveImage = e => {
99842
99794
  this.foundation.handleMoveImage(e);
99843
99795
  };
99844
- // 为什么通过ref注册wheel而不是使用onWheel事件?
99845
- // 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
99846
- // 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
99847
- // Why register wheel via ref instead of using onWheel event?
99848
- // Because for wheel events, the browser changes the passive default of addEventListener to true. This way, the event listener cannot cancel the event, nor prevent the page from rendering when the user scrolls.
99849
- // Here we need to keep the page still and only zoom in on the image, so here we need to set the passive change to false.
99850
- // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
99851
- this.registryImageRef = ref => {
99852
- if (this.imageRef) {
99853
- this.imageRef.removeEventListener("wheel", this.handleWheel);
99854
- }
99855
- if (ref) {
99856
- ref.addEventListener("wheel", this.handleWheel, {
99857
- passive: false
99858
- });
99859
- }
99860
- this.imageRef = ref;
99861
- };
99862
99796
  this.onImageMouseDown = e => {
99863
99797
  this.foundation.handleImageMouseDown(e);
99864
99798
  };
99865
- this.onImageMouseUp = () => {
99866
- this.foundation.handleImageMouseUp();
99867
- };
99868
99799
  this.state = {
99869
99800
  width: 0,
99870
99801
  height: 0,
@@ -99878,7 +99809,7 @@ class PreviewImage extends BaseComponent {
99878
99809
  left: 0
99879
99810
  };
99880
99811
  this.containerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
99881
- this.imageRef = null;
99812
+ this.imageRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
99882
99813
  this.foundation = new PreviewImageFoundation(this.adapter);
99883
99814
  }
99884
99815
  componentDidMount() {
@@ -99889,27 +99820,22 @@ class PreviewImage extends BaseComponent {
99889
99820
  }
99890
99821
  componentDidUpdate(prevProps, prevStates) {
99891
99822
  // If src changes, start a new loading
99892
- if (this.props.src && this.props.src !== prevProps.src) {
99823
+ const zoomChange = "zoom" in this.props && this.props.zoom !== this.state.currZoom;
99824
+ const srcChange = this.props.src && this.props.src !== prevProps.src;
99825
+ if (srcChange) {
99893
99826
  this.foundation.setLoading(true);
99894
99827
  }
99895
99828
  // If the incoming zoom changes, other content changes are determined based on the new zoom value
99896
- if ("zoom" in this.props && this.props.zoom !== prevStates.currZoom) {
99897
- this.handleZoomChange(this.props.zoom, null);
99898
- }
99899
- // When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
99900
- // else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
99901
- if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
99902
- if (originImageWidth && originImageHeight) {
99903
- if (this.props.ratio === "adaptation") {
99904
- this.resizeImage();
99905
- } else {
99906
- this.props.onZoom(1);
99907
- }
99908
- }
99829
+ if (zoomChange) {
99830
+ this.foundation.calculatePreviewImage(this.props.zoom, null);
99909
99831
  }
99910
- // When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
99911
- if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
99912
- this.onWindowResize();
99832
+ if (!zoomChange && !srcChange && prevProps) {
99833
+ if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
99834
+ this.foundation.handleRatioChange();
99835
+ }
99836
+ if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
99837
+ this.onWindowResize();
99838
+ }
99913
99839
  }
99914
99840
  }
99915
99841
  render() {
@@ -99931,21 +99857,20 @@ class PreviewImage extends BaseComponent {
99931
99857
  transform: `rotate(${-rotation}deg)`,
99932
99858
  top,
99933
99859
  left,
99934
- width: loading ? "auto" : `${width}px`,
99935
- height: loading ? "auto" : `${height}px`
99860
+ width,
99861
+ height
99936
99862
  };
99937
99863
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
99938
99864
  className: `${preViewImgPrefixCls}`,
99939
99865
  ref: this.containerRef
99940
99866
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("img", {
99941
- ref: this.registryImageRef,
99867
+ ref: this.imageRef,
99942
99868
  src: src,
99943
99869
  alt: "previewImag",
99944
99870
  className: `${preViewImgPrefixCls}-img`,
99945
99871
  key: src,
99946
99872
  onMouseMove: this.handleMoveImage,
99947
99873
  onMouseDown: this.onImageMouseDown,
99948
- onMouseUp: this.onImageMouseUp,
99949
99874
  onContextMenu: this.handleRightClickImage,
99950
99875
  onDragStart: e => e.preventDefault(),
99951
99876
  onLoad: this.handleLoad,
@@ -99962,9 +99887,9 @@ PreviewImage.propTypes = {
99962
99887
  src: (prop_types_default()).string,
99963
99888
  rotation: (prop_types_default()).number,
99964
99889
  style: (prop_types_default()).object,
99965
- maxZoom: (prop_types_default()).number,
99966
- minZoom: (prop_types_default()).number,
99967
- zoomStep: (prop_types_default()).number,
99890
+ // maxZoom: PropTypes.number,
99891
+ // minZoom: PropTypes.number,
99892
+ // zoomStep: PropTypes.number,
99968
99893
  zoom: (prop_types_default()).number,
99969
99894
  ratio: (prop_types_default()).string,
99970
99895
  disableDownload: (prop_types_default()).bool,
@@ -99975,9 +99900,9 @@ PreviewImage.propTypes = {
99975
99900
  onError: (prop_types_default()).func
99976
99901
  };
99977
99902
  PreviewImage.defaultProps = {
99978
- maxZoom: 5,
99979
- minZoom: 0.1,
99980
- zoomStep: 0.1,
99903
+ // maxZoom: 5,
99904
+ // minZoom: 0.1,
99905
+ // zoomStep: 0.1,
99981
99906
  zoom: undefined
99982
99907
  };
99983
99908
  ;// CONCATENATED MODULE: ../semi-foundation/image/utils.ts
@@ -100072,40 +99997,91 @@ const getPreloadImagArr = (imgSrc, currentIndex, preLoadGap, infinite) => {
100072
99997
 
100073
99998
 
100074
99999
 
100000
+
100001
+
100002
+
100075
100003
  const NOT_CLOSE_TARGETS = ["icon", "footer"];
100076
- const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
100004
+ const STOP_CLOSE_TARGET = (/* unused pure expression or super */ null && (["icon", "footer", "header"]));
100077
100005
  class PreviewInnerFoundation extends foundation {
100078
100006
  constructor(adapter) {
100079
100007
  super(Object.assign({}, adapter));
100008
+ this._timer = null;
100009
+ this._startMouseDown = {
100010
+ x: 0,
100011
+ y: 0
100012
+ };
100080
100013
  this.handleViewVisibleChange = () => {
100081
- const nowTime = new Date().getTime();
100082
- const mouseActiveTime = this._adapter.getMouseActiveTime();
100083
- const stopTiming = this._adapter.getStopTiming();
100084
- const {
100085
- viewerVisibleDelay
100086
- } = this.getProps();
100087
100014
  const {
100088
100015
  viewerVisible
100089
100016
  } = this.getStates();
100090
- if (nowTime - mouseActiveTime > viewerVisibleDelay && !stopTiming) {
100091
- viewerVisible && this.setState({
100017
+ if (viewerVisible) {
100018
+ this.setState({
100092
100019
  viewerVisible: false
100093
100020
  });
100021
+ this.clearTimer();
100022
+ }
100023
+ };
100024
+ this.handleMouseMove = e => {
100025
+ this._persistEvent(e);
100026
+ this.mouseMoveHandler(e);
100027
+ };
100028
+ this.mouseMoveHandler = throttle_default()(e => {
100029
+ const {
100030
+ viewerVisible
100031
+ } = this.getStates();
100032
+ const isValidTarget = this._adapter.isValidTarget(e);
100033
+ if (isValidTarget) {
100034
+ if (!viewerVisible) {
100035
+ this.setState({
100036
+ viewerVisible: true
100037
+ });
100038
+ }
100039
+ this.updateTimer();
100040
+ } else {
100041
+ this.clearTimer();
100094
100042
  }
100043
+ }, 50);
100044
+ this.updateTimer = () => {
100045
+ const {
100046
+ viewerVisibleDelay
100047
+ } = this.getProps();
100048
+ this.clearTimer();
100049
+ this._timer = setTimeout(this.handleViewVisibleChange, viewerVisibleDelay);
100095
100050
  };
100096
- this.handleMouseMoveEvent = (e, event) => {
100097
- const isTarget = isTargetEmit(e, STOP_CLOSE_TARGET);
100098
- if (isTarget && event === "over") {
100099
- this._adapter.setStopTiming(true);
100100
- } else if (isTarget && event === "out") {
100101
- this._adapter.setStopTiming(false);
100051
+ this.clearTimer = () => {
100052
+ if (this._timer) {
100053
+ clearTimeout(this._timer);
100054
+ this._timer = null;
100102
100055
  }
100103
100056
  };
100104
- this.handleMouseMove = e => {
100105
- this._adapter.setMouseActiveTime(new Date().getTime());
100106
- this.setState({
100107
- viewerVisible: true
100108
- });
100057
+ this.handleWheel = e => {
100058
+ this.onWheel(e);
100059
+ handlePrevent(e);
100060
+ };
100061
+ this.onWheel = e => {
100062
+ const {
100063
+ zoomStep,
100064
+ maxZoom,
100065
+ minZoom
100066
+ } = this.getProps();
100067
+ const {
100068
+ zoom: currZoom
100069
+ } = this.getStates();
100070
+ let _zoom;
100071
+ if (e.deltaY < 0) {
100072
+ /* zoom in */
100073
+ if (currZoom + zoomStep <= maxZoom) {
100074
+ _zoom = Number((currZoom + zoomStep).toFixed(2));
100075
+ }
100076
+ } else if (e.deltaY > 0) {
100077
+ /* zoom out */
100078
+ if (currZoom - zoomStep >= minZoom) {
100079
+ _zoom = Number((currZoom - zoomStep).toFixed(2));
100080
+ }
100081
+ }
100082
+ if (!isUndefined_default()(_zoom)) {
100083
+ this.handleZoomImage(_zoom);
100084
+ }
100109
100085
  };
100110
100086
  this.handleMouseUp = e => {
100111
100087
  const {
@@ -100119,7 +100095,7 @@ class PreviewInnerFoundation extends foundation {
100119
100095
  const {
100120
100096
  x,
100121
100097
  y
100122
- } = this._adapter.getStartMouseDown();
100098
+ } = this._startMouseDown;
100123
100099
  // 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
100124
100100
  // Error-tolerant processing of mouse movement, when the movement distance in the x and y directions is less than or equal to 5px in mouseUp, the preview can be closed
100125
100101
  // 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
@@ -100136,7 +100112,10 @@ class PreviewInnerFoundation extends foundation {
100136
100112
  clientX,
100137
100113
  clientY
100138
100114
  } = e;
100139
- this._adapter.setStartMouseDown(clientX, clientY);
100115
+ this._startMouseDown = {
100116
+ x: clientX,
100117
+ y: clientY
100118
+ };
100140
100119
  };
100141
100120
  this.handleKeyDown = e => {
100142
100121
  const {
@@ -100209,10 +100188,12 @@ class PreviewInnerFoundation extends foundation {
100209
100188
  const {
100210
100189
  zoom
100211
100190
  } = this.getStates();
100212
- this._adapter.notifyZoom(newZoom, newZoom > zoom);
100213
- this.setState({
100214
- zoom: newZoom
100215
- });
100191
+ if (zoom !== newZoom) {
100192
+ this._adapter.notifyZoom(newZoom, newZoom > zoom);
100193
+ this.setState({
100194
+ zoom: newZoom
100195
+ });
100196
+ }
100216
100197
  };
100217
100198
  // 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
100218
100199
  // 如: 1,2,3,4,5,6,7,8张图片, 点击第 4 张图片,preLoadGap 为 2
@@ -100330,10 +100311,12 @@ class PreviewInnerFoundation extends foundation {
100330
100311
  beforeShow() {
100331
100312
  this._adapter.registerKeyDownListener();
100332
100313
  this._adapter.disabledBodyScroll();
100314
+ this.updateTimer();
100333
100315
  }
100334
100316
  afterHide() {
100335
100317
  this._adapter.unregisterKeyDownListener();
100336
100318
  this._adapter.enabledBodyScroll();
100319
+ this.clearTimer();
100337
100320
  }
100338
100321
  }
100339
100322
  ;// CONCATENATED MODULE: ./image/previewInner.tsx
@@ -100353,14 +100336,6 @@ class PreviewInnerFoundation extends foundation {
100353
100336
 
100354
100337
 
100355
100338
  const previewInner_prefixCls = image_constants_cssClasses.PREFIX;
100356
- let startMouseDown = {
100357
- x: 0,
100358
- y: 0
100359
- };
100360
- let previewInner_mouseActiveTime = null;
100361
- let stopTiming = false;
100362
- let timer = null;
100363
- // let bodyOverflowValue = document.body.style.overflow;
100364
100339
  class PreviewInner extends BaseComponent {
100365
100340
  get adapter() {
100366
100341
  return Object.assign(Object.assign({}, super.adapter), {
@@ -100444,30 +100419,22 @@ class PreviewInner extends BaseComponent {
100444
100419
  unregisterKeyDownListener: () => {
100445
100420
  window && window.removeEventListener("keydown", this.handleKeyDown);
100446
100421
  },
100447
- getMouseActiveTime: () => {
100448
- return previewInner_mouseActiveTime;
100449
- },
100450
- getStopTiming: () => {
100451
- return stopTiming;
100452
- },
100453
- setStopTiming: value => {
100454
- stopTiming = value;
100455
- },
100456
- getStartMouseDown: () => {
100457
- return startMouseDown;
100458
- },
100459
- setStartMouseDown: (x, y) => {
100460
- startMouseDown = {
100461
- x,
100462
- y
100463
- };
100464
- },
100465
- setMouseActiveTime: time => {
100466
- previewInner_mouseActiveTime = time;
100467
- },
100468
100422
  getSetDownloadFunc: () => {
100469
100423
  var _a, _b;
100470
100424
  return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.setDownloadName) !== null && _b !== void 0 ? _b : this.props.setDownloadName;
100425
+ },
100426
+ isValidTarget: e => {
100427
+ const headerDom = this.headerRef && this.headerRef.current;
100428
+ const footerDom = this.footerRef && this.footerRef.current;
100429
+ const leftIconDom = this.leftIconRef && this.leftIconRef.current;
100430
+ const rightIconDom = this.rightIconRef && this.rightIconRef.current;
100431
+ const target = e.target;
100432
+ if (headerDom && headerDom.contains(target) || footerDom && footerDom.contains(target) || leftIconDom && leftIconDom.contains(target) || rightIconDom && rightIconDom.contains(target)) {
100433
+ // Move in the operation area, return false
100434
+ return false;
100435
+ }
100436
+ // Move in the preview area except the operation area, return true
100437
+ return true;
100471
100438
  }
100472
100439
  });
100473
100440
  }
@@ -100500,9 +100467,6 @@ class PreviewInner extends BaseComponent {
100500
100467
  this.handleMouseMove = e => {
100501
100468
  this.foundation.handleMouseMove(e);
100502
100469
  };
100503
- this.handleMouseEvent = (e, event) => {
100504
- this.foundation.handleMouseMoveEvent(e, event);
100505
- };
100506
100470
  this.handleKeyDown = e => {
100507
100471
  this.foundation.handleKeyDown(e);
100508
100472
  };
@@ -100515,6 +100479,31 @@ class PreviewInner extends BaseComponent {
100515
100479
  this.handleMouseDown = e => {
100516
100480
  this.foundation.handleMouseDown(e);
100517
100481
  };
100482
+ this.handleWheel = e => {
100483
+ this.foundation.handleWheel(e);
100484
+ };
100485
+ // 为什么通过 addEventListener 注册 wheel 事件而不是使用 onWheel 事件?
100486
+ // 因为 Passive Event Listeners(https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners)
100487
+ // Passive Event Listeners 是一种优化技术,用于提高滚动性能。在默认情况下,浏览器会假设事件的监听器不会调用
100488
+ // preventDefault() 方法来阻止事件的默认行为,从而允许进行一些优化操作,例如滚动平滑。
100489
+ // 对于 Image 而言,如果使用触控板,双指朝不同方向分开放大图片,则需要 preventDefault 防止页面整体放大。
100490
+ // Why register wheel event through addEventListener instead of using onWheel event?
100491
+ // Because of Passive Event Listeners(an optimization technique used to improve scrolling performance. By default,
100492
+ // the browser will assume that event listeners will not call preventDefault() method to prevent the default behavior of the event,
100493
+ // allowing some optimization operations such as scroll smoothing.)
100494
+ // For Image, if we use the trackpad and spread your fingers in different directions to enlarge the image, we need to preventDefault
100495
+ // to prevent the page from being enlarged as a whole.
100496
+ this.registryImageWrapRef = ref => {
100497
+ if (this.imageWrapRef) {
100498
+ this.imageWrapRef.removeEventListener("wheel", this.handleWheel);
100499
+ }
100500
+ if (ref) {
100501
+ ref.addEventListener("wheel", this.handleWheel, {
100502
+ passive: false
100503
+ });
100504
+ }
100505
+ this.imageWrapRef = ref;
100506
+ };
100518
100507
  this.state = {
100519
100508
  imgSrc: [],
100520
100509
  imgLoadStatus: new Map(),
@@ -100531,6 +100520,11 @@ class PreviewInner extends BaseComponent {
100531
100520
  this.bodyOverflow = '';
100532
100521
  this.originBodyWidth = '100%';
100533
100522
  this.scrollBarWidth = 0;
100523
+ this.imageWrapRef = null;
100524
+ this.headerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
100525
+ this.footerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
100526
+ this.leftIconRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
100527
+ this.rightIconRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
100534
100528
  }
100535
100529
  static getDerivedStateFromProps(props, state) {
100536
100530
  const willUpdateStates = {};
@@ -100546,6 +100540,9 @@ class PreviewInner extends BaseComponent {
100546
100540
  willUpdateStates.visible = props.visible;
100547
100541
  if (props.visible) {
100548
100542
  willUpdateStates.preloadAfterVisibleChange = true;
100543
+ willUpdateStates.viewerVisible = true;
100544
+ willUpdateStates.rotation = 0;
100545
+ willUpdateStates.ratio = 'adaptation';
100549
100546
  }
100550
100547
  }
100551
100548
  if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
@@ -100564,10 +100561,8 @@ class PreviewInner extends BaseComponent {
100564
100561
  }
100565
100562
  }
100566
100563
  componentDidUpdate(prevProps, prevState) {
100567
- if (prevState.visible !== this.props.visible && this.props.visible) {
100568
- previewInner_mouseActiveTime = new Date().getTime();
100569
- timer && clearInterval(timer);
100570
- timer = setInterval(this.viewVisibleChange, 1000);
100564
+ if (prevProps.src !== this.props.src) {
100565
+ this.foundation.updateTimer();
100571
100566
  }
100572
100567
  // hide => show
100573
100568
  if (!prevProps.visible && this.props.visible) {
@@ -100579,7 +100574,7 @@ class PreviewInner extends BaseComponent {
100579
100574
  }
100580
100575
  }
100581
100576
  componentWillUnmount() {
100582
- timer && clearInterval(timer);
100577
+ this.foundation.clearTimer();
100583
100578
  }
100584
100579
  isInGroup() {
100585
100580
  return Boolean(this.context && this.context.isGroup);
@@ -100644,10 +100639,10 @@ class PreviewInner extends BaseComponent {
100644
100639
  style: style,
100645
100640
  onMouseDown: this.handleMouseDown,
100646
100641
  onMouseUp: this.handleMouseUp,
100647
- onMouseMove: this.handleMouseMove,
100648
- onMouseOver: e => this.handleMouseEvent(e.nativeEvent, "over"),
100649
- onMouseOut: e => this.handleMouseEvent(e.nativeEvent, "out")
100642
+ ref: this.registryImageWrapRef,
100643
+ onMouseMove: this.handleMouseMove
100650
100644
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewHeader, {
100645
+ ref: this.headerRef,
100651
100646
  className: classnames_default()(hideViewerCls),
100652
100647
  onClose: this.handlePreviewClose,
100653
100648
  renderHeader: renderHeader
@@ -100658,7 +100653,6 @@ class PreviewInner extends BaseComponent {
100658
100653
  setRatio: this.handleAdjustRatio,
100659
100654
  zoom: zoom,
100660
100655
  ratio: ratio,
100661
- zoomStep: zoomStep,
100662
100656
  rotation: rotation,
100663
100657
  crossOrigin: crossOrigin,
100664
100658
  onError: this.onImageError,
@@ -100667,6 +100661,7 @@ class PreviewInner extends BaseComponent {
100667
100661
  /*#__PURE__*/
100668
100662
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
100669
100663
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
100664
+ ref: this.leftIconRef,
100670
100665
  className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-prev`, hideViewerCls),
100671
100666
  onClick: () => this.handleSwitchImage("prev")
100672
100667
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowLeft, {
@@ -100675,11 +100670,13 @@ class PreviewInner extends BaseComponent {
100675
100670
  /*#__PURE__*/
100676
100671
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
100677
100672
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
100673
+ ref: this.rightIconRef,
100678
100674
  className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-next`, hideViewerCls),
100679
100675
  onClick: () => this.handleSwitchImage("next")
100680
100676
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowRight, {
100681
100677
  size: "large"
100682
100678
  })), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewFooter_Footer, {
100679
+ forwardRef: this.footerRef,
100683
100680
  className: hideViewerCls,
100684
100681
  totalNum: total,
100685
100682
  curPage: currentIndex + 1,
@@ -100737,6 +100734,8 @@ PreviewInner.propTypes = {
100737
100734
  disableDownload: (prop_types_default()).bool,
100738
100735
  viewerVisibleDelay: (prop_types_default()).number,
100739
100736
  zIndex: (prop_types_default()).number,
100737
+ maxZoom: (prop_types_default()).number,
100738
+ minZoom: (prop_types_default()).number,
100740
100739
  renderHeader: (prop_types_default()).func,
100741
100740
  renderPreviewMenu: (prop_types_default()).func,
100742
100741
  getPopupContainer: (prop_types_default()).func,
@@ -100761,7 +100760,9 @@ PreviewInner.defaultProps = {
100761
100760
  preLoadGap: 2,
100762
100761
  zIndex: 1000,
100763
100762
  maskClosable: true,
100764
- viewerVisibleDelay: 10000
100763
+ viewerVisibleDelay: 10000,
100764
+ maxZoom: 5,
100765
+ minZoom: 0.1
100765
100766
  };
100766
100767
  ;// CONCATENATED MODULE: ../semi-foundation/image/imageFoundation.ts
100767
100768
 
@@ -101405,6 +101406,8 @@ Preview.defaultProps = {
101405
101406
 
101406
101407
 
101407
101408
 
101409
+
101410
+
101408
101411
 
101409
101412
 
101410
101413