@douyinfe/semi-ui 2.49.1 → 2.50.0-alpha.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.
Files changed (79) hide show
  1. package/dist/css/semi.css +1 -1
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +385 -376
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/anchor/index.d.ts +1 -1
  8. package/lib/cjs/autoComplete/index.d.ts +1 -1
  9. package/lib/cjs/button/Button.d.ts +1 -1
  10. package/lib/cjs/button/index.d.ts +1 -1
  11. package/lib/cjs/carousel/index.d.ts +1 -1
  12. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  13. package/lib/cjs/dropdown/index.d.ts +1 -1
  14. package/lib/cjs/form/baseForm.d.ts +1 -1
  15. package/lib/cjs/form/field.d.ts +1 -1
  16. package/lib/cjs/image/interface.d.ts +3 -3
  17. package/lib/cjs/image/previewFooter.js +8 -5
  18. package/lib/cjs/image/previewHeader.d.ts +2 -2
  19. package/lib/cjs/image/previewHeader.js +8 -9
  20. package/lib/cjs/image/previewImage.d.ts +12 -1
  21. package/lib/cjs/image/previewImage.js +83 -23
  22. package/lib/cjs/image/previewInner.d.ts +2 -11
  23. package/lib/cjs/image/previewInner.js +42 -60
  24. package/lib/cjs/index.d.ts +0 -2
  25. package/lib/cjs/index.js +0 -14
  26. package/lib/cjs/modal/confirm.d.ts +11 -11
  27. package/lib/cjs/popover/index.d.ts +1 -1
  28. package/lib/cjs/select/index.d.ts +1 -1
  29. package/lib/cjs/table/ColumnSorter.d.ts +3 -1
  30. package/lib/cjs/table/ColumnSorter.js +26 -15
  31. package/lib/cjs/table/Table.d.ts +1 -1
  32. package/lib/cjs/table/Table.js +1 -0
  33. package/lib/cjs/table/interface.d.ts +4 -0
  34. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  35. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  36. package/lib/cjs/timePicker/index.d.ts +2 -2
  37. package/lib/cjs/tooltip/index.d.ts +1 -1
  38. package/lib/cjs/typography/base.d.ts +1 -1
  39. package/lib/cjs/typography/numeral.d.ts +1 -1
  40. package/lib/cjs/typography/paragraph.d.ts +1 -1
  41. package/lib/cjs/typography/text.d.ts +1 -1
  42. package/lib/cjs/typography/title.d.ts +1 -1
  43. package/lib/es/anchor/index.d.ts +1 -1
  44. package/lib/es/autoComplete/index.d.ts +1 -1
  45. package/lib/es/button/Button.d.ts +1 -1
  46. package/lib/es/button/index.d.ts +1 -1
  47. package/lib/es/carousel/index.d.ts +1 -1
  48. package/lib/es/datePicker/datePicker.d.ts +1 -1
  49. package/lib/es/dropdown/index.d.ts +1 -1
  50. package/lib/es/form/baseForm.d.ts +1 -1
  51. package/lib/es/form/field.d.ts +1 -1
  52. package/lib/es/image/interface.d.ts +3 -3
  53. package/lib/es/image/previewFooter.js +8 -5
  54. package/lib/es/image/previewHeader.d.ts +2 -2
  55. package/lib/es/image/previewHeader.js +3 -4
  56. package/lib/es/image/previewImage.d.ts +12 -1
  57. package/lib/es/image/previewImage.js +83 -23
  58. package/lib/es/image/previewInner.d.ts +2 -11
  59. package/lib/es/image/previewInner.js +42 -60
  60. package/lib/es/index.d.ts +0 -2
  61. package/lib/es/index.js +0 -2
  62. package/lib/es/modal/confirm.d.ts +11 -11
  63. package/lib/es/popover/index.d.ts +1 -1
  64. package/lib/es/select/index.d.ts +1 -1
  65. package/lib/es/table/ColumnSorter.d.ts +3 -1
  66. package/lib/es/table/ColumnSorter.js +26 -15
  67. package/lib/es/table/Table.d.ts +1 -1
  68. package/lib/es/table/Table.js +1 -0
  69. package/lib/es/table/interface.d.ts +4 -0
  70. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  71. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  72. package/lib/es/timePicker/index.d.ts +2 -2
  73. package/lib/es/tooltip/index.d.ts +1 -1
  74. package/lib/es/typography/base.d.ts +1 -1
  75. package/lib/es/typography/numeral.d.ts +1 -1
  76. package/lib/es/typography/paragraph.d.ts +1 -1
  77. package/lib/es/typography/text.d.ts +1 -1
  78. package/lib/es/typography/title.d.ts +1 -1
  79. package/package.json +8 -8
@@ -17286,8 +17286,6 @@ __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),
17291
17289
  "Breadcrumb": () => (/* reexport */ breadcrumb_0),
17292
17290
  "Button": () => (/* reexport */ button_0),
17293
17291
  "ButtonGroup": () => (/* reexport */ ButtonGroup),
@@ -17377,12 +17375,45 @@ __webpack_require__.d(__webpack_exports__, {
17377
17375
 
17378
17376
  // EXTERNAL MODULE: ./_base/base.scss
17379
17377
  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);
17380
17384
  // EXTERNAL MODULE: ../../node_modules/lodash/noop.js
17381
17385
  var noop = __webpack_require__("nnm9");
17382
17386
  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
+
17383
17411
  // EXTERNAL MODULE: ../../node_modules/lodash/get.js
17384
17412
  var get = __webpack_require__("2srY");
17385
17413
  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);
17386
17417
  ;// CONCATENATED MODULE: ../semi-foundation/utils/log.ts
17387
17418
 
17388
17419
  const log = function (text) {
@@ -17509,115 +17540,6 @@ class BaseFoundation {
17509
17540
  }
17510
17541
  }
17511
17542
  /* 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);
17621
17543
  ;// CONCATENATED MODULE: ../../node_modules/compute-scroll-into-view/dist/index.mjs
17622
17544
  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};
17623
17545
  //# sourceMappingURL=index.mjs.map
@@ -17871,6 +17793,82 @@ class AnchorFoundation extends foundation {
17871
17793
  };
17872
17794
  }
17873
17795
  }
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 = {};
17874
17872
  // EXTERNAL MODULE: ../../node_modules/lodash/isObject.js
17875
17873
  var isObject = __webpack_require__("tQYX");
17876
17874
  var isObject_default = /*#__PURE__*/__webpack_require__.n(isObject);
@@ -69383,7 +69381,6 @@ class SelectFoundation extends foundation {
69383
69381
  this.close(e);
69384
69382
  this._notifyBlur(e);
69385
69383
  this._adapter.updateFocusState(false);
69386
- this._adapter.unregisterClickOutsideHandler();
69387
69384
  });
69388
69385
  }
69389
69386
  toggle2SearchInput(isShow) {
@@ -69401,6 +69398,7 @@ class SelectFoundation extends foundation {
69401
69398
  this._adapter.setIsFocusInContainer(false);
69402
69399
  // this.unBindKeyBoardEvent();
69403
69400
  // this._notifyBlur(e);
69401
+ this._adapter.unregisterClickOutsideHandler();
69404
69402
  // this._adapter.updateFocusState(false);
69405
69403
  const isFilterable = this._isFilterable();
69406
69404
  if (isFilterable) {
@@ -79988,7 +79986,8 @@ class ColumnSorter extends external_root_React_commonjs2_react_commonjs_react_am
79988
79986
  onClick,
79989
79987
  sortOrder,
79990
79988
  style,
79991
- title
79989
+ title,
79990
+ sortIcon
79992
79991
  } = this.props;
79993
79992
  const iconBtnSize = 'default';
79994
79993
  const upCls = classnames_default()(`${prefixCls}-column-sorter-up`, {
@@ -80005,25 +80004,34 @@ class ColumnSorter extends external_root_React_commonjs2_react_commonjs_react_am
80005
80004
  'aria-label': `Current sort order is ${sortOrder ? `${sortOrder}ing` : 'none'}`,
80006
80005
  'aria-roledescription': 'Sort data with this column'
80007
80006
  };
80007
+ const renderSortIcon = () => {
80008
+ if (typeof sortIcon === 'function') {
80009
+ return sortIcon({
80010
+ sortOrder
80011
+ });
80012
+ } else {
80013
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
80014
+ style: style,
80015
+ className: `${prefixCls}-column-sorter`
80016
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
80017
+ className: `${upCls}`
80018
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretup, {
80019
+ size: iconBtnSize
80020
+ })), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
80021
+ className: `${downCls}`
80022
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretdown, {
80023
+ size: iconBtnSize
80024
+ })));
80025
+ }
80026
+ };
80008
80027
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({
80009
- role: 'button'
80028
+ role: "button"
80010
80029
  }, ariaProps, {
80011
80030
  tabIndex: -1,
80012
80031
  className: `${prefixCls}-column-sorter-wrapper`,
80013
80032
  onClick: onClick,
80014
80033
  onKeyPress: e => utils_isEnterPress(e) && onClick(e)
80015
- }), title, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
80016
- style: style,
80017
- className: `${prefixCls}-column-sorter`
80018
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
80019
- className: `${upCls}`
80020
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretup, {
80021
- size: iconBtnSize
80022
- })), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
80023
- className: `${downCls}`
80024
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretdown, {
80025
- size: iconBtnSize
80026
- }))));
80034
+ }), title, renderSortIcon());
80027
80035
  }
80028
80036
  }
80029
80037
  ColumnSorter.propTypes = {
@@ -80031,7 +80039,8 @@ ColumnSorter.propTypes = {
80031
80039
  style: (prop_types_default()).object,
80032
80040
  onClick: (prop_types_default()).func,
80033
80041
  prefixCls: (prop_types_default()).string,
80034
- sortOrder: prop_types_default().oneOfType([(prop_types_default()).string, (prop_types_default()).bool])
80042
+ sortOrder: prop_types_default().oneOfType([(prop_types_default()).string, (prop_types_default()).bool]),
80043
+ sortIcon: (prop_types_default()).func
80035
80044
  };
80036
80045
  ColumnSorter.defaultProps = {
80037
80046
  prefixCls: table_constants_cssClasses.PREFIX,
@@ -83319,6 +83328,7 @@ class Table extends BaseComponent {
83319
83328
  const sorter = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(ColumnSorter, {
83320
83329
  key: table_constants_strings.DEFAULT_KEY_COLUMN_SORTER,
83321
83330
  sortOrder: sortOrder,
83331
+ sortIcon: column.sortIcon,
83322
83332
  onClick: e => _this2.foundation.handleSort(column, e),
83323
83333
  title: TitleNode
83324
83334
  });
@@ -98952,14 +98962,14 @@ const PreviewContext = /*#__PURE__*/(0,external_root_React_commonjs2_react_commo
98952
98962
 
98953
98963
 
98954
98964
  const previewHeader_prefixCls = `${image_constants_cssClasses.PREFIX}-preview-header`;
98955
- const previewHeader_Header = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)((_ref, ref) => {
98965
+ const previewHeader_Header = _ref => {
98956
98966
  let {
98957
98967
  onClose,
98958
98968
  titleStyle,
98959
98969
  className,
98960
98970
  renderHeader
98961
98971
  } = _ref;
98962
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(PreviewContext.Consumer, null, _ref2 => {
98972
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(PreviewContext.Consumer, null, _ref2 => {
98963
98973
  let {
98964
98974
  currentIndex,
98965
98975
  titles
@@ -98968,18 +98978,17 @@ const previewHeader_Header = /*#__PURE__*/(0,external_root_React_commonjs2_react
98968
98978
  if (titles && typeof currentIndex === "number") {
98969
98979
  title = titles[currentIndex];
98970
98980
  }
98971
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98972
- ref: ref,
98981
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98973
98982
  className: classnames_default()(previewHeader_prefixCls, className)
98974
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98983
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98975
98984
  className: `${previewHeader_prefixCls}-title`,
98976
98985
  style: titleStyle
98977
- }, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
98986
+ }, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
98978
98987
  className: `${previewHeader_prefixCls}-close`,
98979
98988
  onMouseUp: onClose
98980
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconClose, null)));
98989
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(IconClose, null)));
98981
98990
  });
98982
- });
98991
+ };
98983
98992
  /* harmony default export */ const previewHeader = (previewHeader_Header);
98984
98993
  ;// CONCATENATED MODULE: ../semi-icons/lib/es/icons/IconMinus.js
98985
98994
 
@@ -99135,6 +99144,7 @@ class PreviewFooterFoundation extends foundation {
99135
99144
  } else {
99136
99145
  onZoomOut(Number((value / 100).toFixed(2)));
99137
99146
  }
99147
+ this._adapter.setStartMouseOffset(value);
99138
99148
  };
99139
99149
  this.handleRatioClick = () => {
99140
99150
  const {
@@ -99167,9 +99177,14 @@ class PreviewFooterFoundation extends foundation {
99167
99177
 
99168
99178
  const previewFooter_prefixCls = image_constants_cssClasses.PREFIX;
99169
99179
  const footerPrefixCls = `${image_constants_cssClasses.PREFIX}-preview-footer`;
99180
+ let mouseActiveTime = 0;
99170
99181
  class previewFooter_Footer extends BaseComponent {
99171
99182
  get adapter() {
99172
- return Object.assign({}, super.adapter);
99183
+ return Object.assign(Object.assign({}, super.adapter), {
99184
+ setStartMouseOffset: time => {
99185
+ mouseActiveTime = time;
99186
+ }
99187
+ });
99173
99188
  }
99174
99189
  constructor(props) {
99175
99190
  super(props);
@@ -99409,15 +99424,13 @@ class previewFooter_Footer extends BaseComponent {
99409
99424
  render() {
99410
99425
  const {
99411
99426
  className,
99412
- renderPreviewMenu,
99413
- forwardRef
99427
+ renderPreviewMenu
99414
99428
  } = this.props;
99415
99429
  const menuCls = classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
99416
99430
  [`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
99417
99431
  });
99418
99432
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
99419
- className: menuCls,
99420
- ref: forwardRef
99433
+ className: menuCls
99421
99434
  }, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
99422
99435
  }
99423
99436
  }
@@ -99456,6 +99469,9 @@ previewFooter_Footer.defaultProps = {
99456
99469
  };
99457
99470
  ;// CONCATENATED MODULE: ../semi-foundation/image/previewImageFoundation.ts
99458
99471
 
99472
+
99473
+
99474
+
99459
99475
  const DefaultDOMRect = {
99460
99476
  bottom: 0,
99461
99477
  height: 0,
@@ -99470,12 +99486,6 @@ const DefaultDOMRect = {
99470
99486
  class PreviewImageFoundation extends foundation {
99471
99487
  constructor(adapter) {
99472
99488
  super(Object.assign({}, adapter));
99473
- this.startMouseOffset = {
99474
- x: 0,
99475
- y: 0
99476
- };
99477
- this.originImageWidth = null;
99478
- this.originImageHeight = null;
99479
99489
  this._isImageVertical = () => this.getProp("rotation") % 180 !== 0;
99480
99490
  this._getImageBounds = () => {
99481
99491
  const imageDOM = this._adapter.getImage();
@@ -99505,18 +99515,32 @@ class PreviewImageFoundation extends foundation {
99505
99515
  this._adapter.setLoading(loading);
99506
99516
  };
99507
99517
  this.handleWindowResize = () => {
99508
- if (this.originImageWidth && this.originImageHeight) {
99509
- this.handleResizeImage();
99518
+ const {
99519
+ ratio,
99520
+ setRatio
99521
+ } = this.getProps();
99522
+ const {
99523
+ originImageWidth,
99524
+ originImageHeight
99525
+ } = this._adapter.getOriginImageSize();
99526
+ if (originImageWidth && originImageHeight) {
99527
+ if (ratio !== "adaptation") {
99528
+ setRatio("adaptation");
99529
+ } else {
99530
+ this.handleResizeImage();
99531
+ }
99510
99532
  }
99511
99533
  };
99512
99534
  this.handleLoad = e => {
99513
99535
  if (e.target) {
99514
99536
  const {
99515
- naturalWidth: w,
99516
- naturalHeight: h
99537
+ width: w,
99538
+ height: h
99517
99539
  } = e.target;
99518
- this.originImageHeight = h;
99519
- this.originImageWidth = w;
99540
+ this._adapter.setOriginImageSize({
99541
+ originImageWidth: w,
99542
+ originImageHeight: h
99543
+ });
99520
99544
  this.setState({
99521
99545
  loading: false
99522
99546
  });
@@ -99541,14 +99565,13 @@ class PreviewImageFoundation extends foundation {
99541
99565
  this.handleResizeImage = () => {
99542
99566
  const horizontal = !this._isImageVertical();
99543
99567
  const {
99544
- currZoom
99545
- } = this.getStates();
99546
- const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
99547
- const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
99568
+ originImageWidth,
99569
+ originImageHeight
99570
+ } = this._adapter.getOriginImageSize();
99571
+ const imgWidth = horizontal ? originImageWidth : originImageHeight;
99572
+ const imgHeight = horizontal ? originImageHeight : originImageWidth;
99548
99573
  const {
99549
- onZoom,
99550
- setRatio,
99551
- ratio
99574
+ onZoom
99552
99575
  } = this.getProps();
99553
99576
  const containerDOM = this._adapter.getContainer();
99554
99577
  if (containerDOM) {
@@ -99558,44 +99581,8 @@ class PreviewImageFoundation extends foundation {
99558
99581
  } = this._getContainerBounds();
99559
99582
  const reservedWidth = containerWidth - 80;
99560
99583
  const reservedHeight = containerHeight - 80;
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
- }
99584
+ const _zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
99585
+ onZoom(_zoom);
99599
99586
  }
99600
99587
  };
99601
99588
  this.handleRightClickImage = e => {
@@ -99610,6 +99597,38 @@ class PreviewImageFoundation extends foundation {
99610
99597
  return true;
99611
99598
  }
99612
99599
  };
99600
+ // e: WheelEvent<HTMLImageElement>
99601
+ this.handleWheel = e => {
99602
+ this.onWheel(e);
99603
+ handlePrevent(e);
99604
+ };
99605
+ // e: WheelEvent<HTMLImageElement>
99606
+ this.onWheel = throttle_default()(e => {
99607
+ const {
99608
+ onZoom,
99609
+ zoomStep,
99610
+ maxZoom,
99611
+ minZoom
99612
+ } = this.getProps();
99613
+ const {
99614
+ currZoom
99615
+ } = this.getStates();
99616
+ let _zoom;
99617
+ if (e.deltaY < 0) {
99618
+ /* zoom in */
99619
+ if (currZoom + zoomStep <= maxZoom) {
99620
+ _zoom = Number((currZoom + zoomStep).toFixed(2));
99621
+ }
99622
+ } else if (e.deltaY > 0) {
99623
+ /* zoom out */
99624
+ if (currZoom - zoomStep >= minZoom) {
99625
+ _zoom = Number((currZoom - zoomStep).toFixed(2));
99626
+ }
99627
+ }
99628
+ if (!isUndefined_default()(_zoom)) {
99629
+ onZoom(_zoom);
99630
+ }
99631
+ }, 50);
99613
99632
  this.calcCanDragDirection = () => {
99614
99633
  const {
99615
99634
  width,
@@ -99633,8 +99652,12 @@ class PreviewImageFoundation extends foundation {
99633
99652
  canDragHorizontal
99634
99653
  };
99635
99654
  };
99636
- this.calculatePreviewImage = (newZoom, e) => {
99655
+ this.handleZoomChange = (newZoom, e) => {
99637
99656
  const imageDOM = this._adapter.getImage();
99657
+ const {
99658
+ originImageWidth,
99659
+ originImageHeight
99660
+ } = this._adapter.getOriginImageSize();
99638
99661
  const {
99639
99662
  canDragVertical,
99640
99663
  canDragHorizontal
@@ -99644,8 +99667,8 @@ class PreviewImageFoundation extends foundation {
99644
99667
  width: containerWidth,
99645
99668
  height: containerHeight
99646
99669
  } = this._getContainerBounds();
99647
- const newWidth = Math.floor(this.originImageWidth * newZoom);
99648
- const newHeight = Math.floor(this.originImageHeight * newZoom);
99670
+ const newWidth = Math.floor(originImageWidth * newZoom);
99671
+ const newHeight = Math.floor(originImageHeight * newZoom);
99649
99672
  // debugger;
99650
99673
  let _offset;
99651
99674
  const horizontal = !this._isImageVertical();
@@ -99704,13 +99727,13 @@ class PreviewImageFoundation extends foundation {
99704
99727
  width,
99705
99728
  height
99706
99729
  } = this.getStates();
99730
+ const startMouseMove = this._adapter.getMouseMove();
99731
+ const startMouseOffset = this._adapter.getMouseOffset();
99707
99732
  const {
99708
99733
  canDragVertical,
99709
99734
  canDragHorizontal
99710
99735
  } = this.calcCanDragDirection();
99711
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
99712
- const mouseLeftPress = e.buttons === 1;
99713
- if (mouseLeftPress && (canDragVertical || canDragHorizontal)) {
99736
+ if (startMouseMove && (canDragVertical || canDragHorizontal)) {
99714
99737
  const {
99715
99738
  clientX,
99716
99739
  clientY
@@ -99723,8 +99746,8 @@ class PreviewImageFoundation extends foundation {
99723
99746
  left: extremeLeft,
99724
99747
  top: extremeTop
99725
99748
  } = this.calcExtremeBounds();
99726
- let newX = canDragHorizontal ? clientX - containerLeft - this.startMouseOffset.x : offset.x;
99727
- let newY = canDragVertical ? clientY - containerTop - this.startMouseOffset.y : offset.y;
99749
+ let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
99750
+ let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
99728
99751
  if (canDragHorizontal) {
99729
99752
  newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
99730
99753
  }
@@ -99743,7 +99766,11 @@ class PreviewImageFoundation extends foundation {
99743
99766
  }
99744
99767
  };
99745
99768
  this.handleImageMouseDown = e => {
99746
- this.startMouseOffset = this._getOffset(e);
99769
+ this._adapter.setStartMouseOffset(this._getOffset(e));
99770
+ this._adapter.setStartMouseMove(true);
99771
+ };
99772
+ this.handleImageMouseUp = () => {
99773
+ this._adapter.setStartMouseMove(false);
99747
99774
  };
99748
99775
  }
99749
99776
  }
@@ -99756,14 +99783,38 @@ class PreviewImageFoundation extends foundation {
99756
99783
 
99757
99784
  const previewImage_prefixCls = image_constants_cssClasses.PREFIX;
99758
99785
  const preViewImgPrefixCls = `${previewImage_prefixCls}-preview-image`;
99786
+ let originImageWidth = null;
99787
+ let originImageHeight = null;
99788
+ let startMouseMove = false;
99789
+ // startMouseOffset:The offset of the mouse relative to the left and top of the picture
99790
+ let startMouseOffset = {
99791
+ x: 0,
99792
+ y: 0
99793
+ };
99759
99794
  class PreviewImage extends BaseComponent {
99760
99795
  get adapter() {
99761
99796
  return Object.assign(Object.assign({}, super.adapter), {
99797
+ getOriginImageSize: () => ({
99798
+ originImageWidth,
99799
+ originImageHeight
99800
+ }),
99801
+ setOriginImageSize: size => {
99802
+ originImageWidth = size.originImageWidth;
99803
+ originImageHeight = size.originImageHeight;
99804
+ },
99762
99805
  getContainer: () => {
99763
99806
  return this.containerRef.current;
99764
99807
  },
99765
99808
  getImage: () => {
99766
- return this.imageRef.current;
99809
+ return this.imageRef;
99810
+ },
99811
+ getMouseMove: () => startMouseMove,
99812
+ setStartMouseMove: move => {
99813
+ startMouseMove = move;
99814
+ },
99815
+ getMouseOffset: () => startMouseOffset,
99816
+ setStartMouseOffset: offset => {
99817
+ startMouseOffset = offset;
99767
99818
  },
99768
99819
  setLoading: loading => {
99769
99820
  this.setState({
@@ -99771,7 +99822,7 @@ class PreviewImage extends BaseComponent {
99771
99822
  });
99772
99823
  },
99773
99824
  setImageCursor: canDrag => {
99774
- this.imageRef.current.style.cursor = canDrag ? "grab" : "default";
99825
+ this.imageRef.style.cursor = canDrag ? "grab" : "default";
99775
99826
  }
99776
99827
  });
99777
99828
  }
@@ -99780,22 +99831,52 @@ class PreviewImage extends BaseComponent {
99780
99831
  this.onWindowResize = () => {
99781
99832
  this.foundation.handleWindowResize();
99782
99833
  };
99834
+ this.handleZoomChange = (newZoom, e) => {
99835
+ this.foundation.handleZoomChange(newZoom, e);
99836
+ };
99783
99837
  // Determine the response method of right click according to the disableDownload parameter in props
99784
99838
  this.handleRightClickImage = e => {
99785
99839
  this.foundation.handleRightClickImage(e);
99786
99840
  };
99841
+ this.handleWheel = e => {
99842
+ this.foundation.handleWheel(e);
99843
+ };
99787
99844
  this.handleLoad = e => {
99788
99845
  this.foundation.handleLoad(e);
99789
99846
  };
99790
99847
  this.handleError = e => {
99791
99848
  this.foundation.handleError(e);
99792
99849
  };
99850
+ this.resizeImage = () => {
99851
+ this.foundation.handleResizeImage();
99852
+ };
99793
99853
  this.handleMoveImage = e => {
99794
99854
  this.foundation.handleMoveImage(e);
99795
99855
  };
99856
+ // 为什么通过ref注册wheel而不是使用onWheel事件?
99857
+ // 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
99858
+ // 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
99859
+ // Why register wheel via ref instead of using onWheel event?
99860
+ // 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.
99861
+ // 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.
99862
+ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
99863
+ this.registryImageRef = ref => {
99864
+ if (this.imageRef) {
99865
+ this.imageRef.removeEventListener("wheel", this.handleWheel);
99866
+ }
99867
+ if (ref) {
99868
+ ref.addEventListener("wheel", this.handleWheel, {
99869
+ passive: false
99870
+ });
99871
+ }
99872
+ this.imageRef = ref;
99873
+ };
99796
99874
  this.onImageMouseDown = e => {
99797
99875
  this.foundation.handleImageMouseDown(e);
99798
99876
  };
99877
+ this.onImageMouseUp = () => {
99878
+ this.foundation.handleImageMouseUp();
99879
+ };
99799
99880
  this.state = {
99800
99881
  width: 0,
99801
99882
  height: 0,
@@ -99809,7 +99890,7 @@ class PreviewImage extends BaseComponent {
99809
99890
  left: 0
99810
99891
  };
99811
99892
  this.containerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
99812
- this.imageRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
99893
+ this.imageRef = null;
99813
99894
  this.foundation = new PreviewImageFoundation(this.adapter);
99814
99895
  }
99815
99896
  componentDidMount() {
@@ -99820,23 +99901,28 @@ class PreviewImage extends BaseComponent {
99820
99901
  }
99821
99902
  componentDidUpdate(prevProps, prevStates) {
99822
99903
  // If src changes, start a new loading
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) {
99904
+ if (this.props.src && this.props.src !== prevProps.src) {
99826
99905
  this.foundation.setLoading(true);
99827
99906
  }
99828
99907
  // If the incoming zoom changes, other content changes are determined based on the new zoom value
99829
- if (zoomChange) {
99830
- this.foundation.calculatePreviewImage(this.props.zoom, null);
99831
- }
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();
99908
+ if ("zoom" in this.props && this.props.zoom !== prevStates.currZoom) {
99909
+ this.handleZoomChange(this.props.zoom, null);
99910
+ }
99911
+ // When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
99912
+ // else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
99913
+ if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
99914
+ if (originImageWidth && originImageHeight) {
99915
+ if (this.props.ratio === "adaptation") {
99916
+ this.resizeImage();
99917
+ } else {
99918
+ this.props.onZoom(1);
99919
+ }
99838
99920
  }
99839
99921
  }
99922
+ // When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
99923
+ if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
99924
+ this.onWindowResize();
99925
+ }
99840
99926
  }
99841
99927
  render() {
99842
99928
  const {
@@ -99857,20 +99943,21 @@ class PreviewImage extends BaseComponent {
99857
99943
  transform: `rotate(${-rotation}deg)`,
99858
99944
  top,
99859
99945
  left,
99860
- width,
99861
- height
99946
+ width: loading ? "auto" : `${width}px`,
99947
+ height: loading ? "auto" : `${height}px`
99862
99948
  };
99863
99949
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
99864
99950
  className: `${preViewImgPrefixCls}`,
99865
99951
  ref: this.containerRef
99866
99952
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("img", {
99867
- ref: this.imageRef,
99953
+ ref: this.registryImageRef,
99868
99954
  src: src,
99869
99955
  alt: "previewImag",
99870
99956
  className: `${preViewImgPrefixCls}-img`,
99871
99957
  key: src,
99872
99958
  onMouseMove: this.handleMoveImage,
99873
99959
  onMouseDown: this.onImageMouseDown,
99960
+ onMouseUp: this.onImageMouseUp,
99874
99961
  onContextMenu: this.handleRightClickImage,
99875
99962
  onDragStart: e => e.preventDefault(),
99876
99963
  onLoad: this.handleLoad,
@@ -99887,9 +99974,9 @@ PreviewImage.propTypes = {
99887
99974
  src: (prop_types_default()).string,
99888
99975
  rotation: (prop_types_default()).number,
99889
99976
  style: (prop_types_default()).object,
99890
- // maxZoom: PropTypes.number,
99891
- // minZoom: PropTypes.number,
99892
- // zoomStep: PropTypes.number,
99977
+ maxZoom: (prop_types_default()).number,
99978
+ minZoom: (prop_types_default()).number,
99979
+ zoomStep: (prop_types_default()).number,
99893
99980
  zoom: (prop_types_default()).number,
99894
99981
  ratio: (prop_types_default()).string,
99895
99982
  disableDownload: (prop_types_default()).bool,
@@ -99900,9 +99987,9 @@ PreviewImage.propTypes = {
99900
99987
  onError: (prop_types_default()).func
99901
99988
  };
99902
99989
  PreviewImage.defaultProps = {
99903
- // maxZoom: 5,
99904
- // minZoom: 0.1,
99905
- // zoomStep: 0.1,
99990
+ maxZoom: 5,
99991
+ minZoom: 0.1,
99992
+ zoomStep: 0.1,
99906
99993
  zoom: undefined
99907
99994
  };
99908
99995
  ;// CONCATENATED MODULE: ../semi-foundation/image/utils.ts
@@ -99997,91 +100084,40 @@ const getPreloadImagArr = (imgSrc, currentIndex, preLoadGap, infinite) => {
99997
100084
 
99998
100085
 
99999
100086
 
100000
-
100001
-
100002
-
100003
100087
  const NOT_CLOSE_TARGETS = ["icon", "footer"];
100004
- const STOP_CLOSE_TARGET = (/* unused pure expression or super */ null && (["icon", "footer", "header"]));
100088
+ const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
100005
100089
  class PreviewInnerFoundation extends foundation {
100006
100090
  constructor(adapter) {
100007
100091
  super(Object.assign({}, adapter));
100008
- this._timer = null;
100009
- this._startMouseDown = {
100010
- x: 0,
100011
- y: 0
100012
- };
100013
100092
  this.handleViewVisibleChange = () => {
100093
+ const nowTime = new Date().getTime();
100094
+ const mouseActiveTime = this._adapter.getMouseActiveTime();
100095
+ const stopTiming = this._adapter.getStopTiming();
100096
+ const {
100097
+ viewerVisibleDelay
100098
+ } = this.getProps();
100014
100099
  const {
100015
100100
  viewerVisible
100016
100101
  } = this.getStates();
100017
- if (viewerVisible) {
100018
- this.setState({
100102
+ if (nowTime - mouseActiveTime > viewerVisibleDelay && !stopTiming) {
100103
+ viewerVisible && this.setState({
100019
100104
  viewerVisible: false
100020
100105
  });
100021
- this.clearTimer();
100022
100106
  }
100023
100107
  };
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();
100042
- }
100043
- }, 50);
100044
- this.updateTimer = () => {
100045
- const {
100046
- viewerVisibleDelay
100047
- } = this.getProps();
100048
- this.clearTimer();
100049
- this._timer = setTimeout(this.handleViewVisibleChange, viewerVisibleDelay);
100050
- };
100051
- this.clearTimer = () => {
100052
- if (this._timer) {
100053
- clearTimeout(this._timer);
100054
- this._timer = null;
100108
+ this.handleMouseMoveEvent = (e, event) => {
100109
+ const isTarget = isTargetEmit(e, STOP_CLOSE_TARGET);
100110
+ if (isTarget && event === "over") {
100111
+ this._adapter.setStopTiming(true);
100112
+ } else if (isTarget && event === "out") {
100113
+ this._adapter.setStopTiming(false);
100055
100114
  }
100056
100115
  };
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
- }
100116
+ this.handleMouseMove = e => {
100117
+ this._adapter.setMouseActiveTime(new Date().getTime());
100118
+ this.setState({
100119
+ viewerVisible: true
100120
+ });
100085
100121
  };
100086
100122
  this.handleMouseUp = e => {
100087
100123
  const {
@@ -100095,7 +100131,7 @@ class PreviewInnerFoundation extends foundation {
100095
100131
  const {
100096
100132
  x,
100097
100133
  y
100098
- } = this._startMouseDown;
100134
+ } = this._adapter.getStartMouseDown();
100099
100135
  // 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
100100
100136
  // 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
100101
100137
  // 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
@@ -100112,10 +100148,7 @@ class PreviewInnerFoundation extends foundation {
100112
100148
  clientX,
100113
100149
  clientY
100114
100150
  } = e;
100115
- this._startMouseDown = {
100116
- x: clientX,
100117
- y: clientY
100118
- };
100151
+ this._adapter.setStartMouseDown(clientX, clientY);
100119
100152
  };
100120
100153
  this.handleKeyDown = e => {
100121
100154
  const {
@@ -100188,12 +100221,10 @@ class PreviewInnerFoundation extends foundation {
100188
100221
  const {
100189
100222
  zoom
100190
100223
  } = this.getStates();
100191
- if (zoom !== newZoom) {
100192
- this._adapter.notifyZoom(newZoom, newZoom > zoom);
100193
- this.setState({
100194
- zoom: newZoom
100195
- });
100196
- }
100224
+ this._adapter.notifyZoom(newZoom, newZoom > zoom);
100225
+ this.setState({
100226
+ zoom: newZoom
100227
+ });
100197
100228
  };
100198
100229
  // 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
100199
100230
  // 如: 1,2,3,4,5,6,7,8张图片, 点击第 4 张图片,preLoadGap 为 2
@@ -100311,12 +100342,10 @@ class PreviewInnerFoundation extends foundation {
100311
100342
  beforeShow() {
100312
100343
  this._adapter.registerKeyDownListener();
100313
100344
  this._adapter.disabledBodyScroll();
100314
- this.updateTimer();
100315
100345
  }
100316
100346
  afterHide() {
100317
100347
  this._adapter.unregisterKeyDownListener();
100318
100348
  this._adapter.enabledBodyScroll();
100319
- this.clearTimer();
100320
100349
  }
100321
100350
  }
100322
100351
  ;// CONCATENATED MODULE: ./image/previewInner.tsx
@@ -100336,6 +100365,14 @@ class PreviewInnerFoundation extends foundation {
100336
100365
 
100337
100366
 
100338
100367
  const previewInner_prefixCls = image_constants_cssClasses.PREFIX;
100368
+ let startMouseDown = {
100369
+ x: 0,
100370
+ y: 0
100371
+ };
100372
+ let previewInner_mouseActiveTime = null;
100373
+ let stopTiming = false;
100374
+ let timer = null;
100375
+ // let bodyOverflowValue = document.body.style.overflow;
100339
100376
  class PreviewInner extends BaseComponent {
100340
100377
  get adapter() {
100341
100378
  return Object.assign(Object.assign({}, super.adapter), {
@@ -100419,22 +100456,30 @@ class PreviewInner extends BaseComponent {
100419
100456
  unregisterKeyDownListener: () => {
100420
100457
  window && window.removeEventListener("keydown", this.handleKeyDown);
100421
100458
  },
100459
+ getMouseActiveTime: () => {
100460
+ return previewInner_mouseActiveTime;
100461
+ },
100462
+ getStopTiming: () => {
100463
+ return stopTiming;
100464
+ },
100465
+ setStopTiming: value => {
100466
+ stopTiming = value;
100467
+ },
100468
+ getStartMouseDown: () => {
100469
+ return startMouseDown;
100470
+ },
100471
+ setStartMouseDown: (x, y) => {
100472
+ startMouseDown = {
100473
+ x,
100474
+ y
100475
+ };
100476
+ },
100477
+ setMouseActiveTime: time => {
100478
+ previewInner_mouseActiveTime = time;
100479
+ },
100422
100480
  getSetDownloadFunc: () => {
100423
100481
  var _a, _b;
100424
100482
  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;
100438
100483
  }
100439
100484
  });
100440
100485
  }
@@ -100467,6 +100512,9 @@ class PreviewInner extends BaseComponent {
100467
100512
  this.handleMouseMove = e => {
100468
100513
  this.foundation.handleMouseMove(e);
100469
100514
  };
100515
+ this.handleMouseEvent = (e, event) => {
100516
+ this.foundation.handleMouseMoveEvent(e, event);
100517
+ };
100470
100518
  this.handleKeyDown = e => {
100471
100519
  this.foundation.handleKeyDown(e);
100472
100520
  };
@@ -100479,31 +100527,6 @@ class PreviewInner extends BaseComponent {
100479
100527
  this.handleMouseDown = e => {
100480
100528
  this.foundation.handleMouseDown(e);
100481
100529
  };
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
- };
100507
100530
  this.state = {
100508
100531
  imgSrc: [],
100509
100532
  imgLoadStatus: new Map(),
@@ -100520,11 +100543,6 @@ class PreviewInner extends BaseComponent {
100520
100543
  this.bodyOverflow = '';
100521
100544
  this.originBodyWidth = '100%';
100522
100545
  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();
100528
100546
  }
100529
100547
  static getDerivedStateFromProps(props, state) {
100530
100548
  const willUpdateStates = {};
@@ -100540,9 +100558,6 @@ class PreviewInner extends BaseComponent {
100540
100558
  willUpdateStates.visible = props.visible;
100541
100559
  if (props.visible) {
100542
100560
  willUpdateStates.preloadAfterVisibleChange = true;
100543
- willUpdateStates.viewerVisible = true;
100544
- willUpdateStates.rotation = 0;
100545
- willUpdateStates.ratio = 'adaptation';
100546
100561
  }
100547
100562
  }
100548
100563
  if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
@@ -100561,8 +100576,10 @@ class PreviewInner extends BaseComponent {
100561
100576
  }
100562
100577
  }
100563
100578
  componentDidUpdate(prevProps, prevState) {
100564
- if (prevProps.src !== this.props.src) {
100565
- this.foundation.updateTimer();
100579
+ if (prevState.visible !== this.props.visible && this.props.visible) {
100580
+ previewInner_mouseActiveTime = new Date().getTime();
100581
+ timer && clearInterval(timer);
100582
+ timer = setInterval(this.viewVisibleChange, 1000);
100566
100583
  }
100567
100584
  // hide => show
100568
100585
  if (!prevProps.visible && this.props.visible) {
@@ -100574,7 +100591,7 @@ class PreviewInner extends BaseComponent {
100574
100591
  }
100575
100592
  }
100576
100593
  componentWillUnmount() {
100577
- this.foundation.clearTimer();
100594
+ timer && clearInterval(timer);
100578
100595
  }
100579
100596
  isInGroup() {
100580
100597
  return Boolean(this.context && this.context.isGroup);
@@ -100639,10 +100656,10 @@ class PreviewInner extends BaseComponent {
100639
100656
  style: style,
100640
100657
  onMouseDown: this.handleMouseDown,
100641
100658
  onMouseUp: this.handleMouseUp,
100642
- ref: this.registryImageWrapRef,
100643
- onMouseMove: this.handleMouseMove
100659
+ onMouseMove: this.handleMouseMove,
100660
+ onMouseOver: e => this.handleMouseEvent(e.nativeEvent, "over"),
100661
+ onMouseOut: e => this.handleMouseEvent(e.nativeEvent, "out")
100644
100662
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewHeader, {
100645
- ref: this.headerRef,
100646
100663
  className: classnames_default()(hideViewerCls),
100647
100664
  onClose: this.handlePreviewClose,
100648
100665
  renderHeader: renderHeader
@@ -100653,6 +100670,7 @@ class PreviewInner extends BaseComponent {
100653
100670
  setRatio: this.handleAdjustRatio,
100654
100671
  zoom: zoom,
100655
100672
  ratio: ratio,
100673
+ zoomStep: zoomStep,
100656
100674
  rotation: rotation,
100657
100675
  crossOrigin: crossOrigin,
100658
100676
  onError: this.onImageError,
@@ -100661,7 +100679,6 @@ class PreviewInner extends BaseComponent {
100661
100679
  /*#__PURE__*/
100662
100680
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
100663
100681
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
100664
- ref: this.leftIconRef,
100665
100682
  className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-prev`, hideViewerCls),
100666
100683
  onClick: () => this.handleSwitchImage("prev")
100667
100684
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowLeft, {
@@ -100670,13 +100687,11 @@ class PreviewInner extends BaseComponent {
100670
100687
  /*#__PURE__*/
100671
100688
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
100672
100689
  external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
100673
- ref: this.rightIconRef,
100674
100690
  className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-next`, hideViewerCls),
100675
100691
  onClick: () => this.handleSwitchImage("next")
100676
100692
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowRight, {
100677
100693
  size: "large"
100678
100694
  })), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewFooter_Footer, {
100679
- forwardRef: this.footerRef,
100680
100695
  className: hideViewerCls,
100681
100696
  totalNum: total,
100682
100697
  curPage: currentIndex + 1,
@@ -100734,8 +100749,6 @@ PreviewInner.propTypes = {
100734
100749
  disableDownload: (prop_types_default()).bool,
100735
100750
  viewerVisibleDelay: (prop_types_default()).number,
100736
100751
  zIndex: (prop_types_default()).number,
100737
- maxZoom: (prop_types_default()).number,
100738
- minZoom: (prop_types_default()).number,
100739
100752
  renderHeader: (prop_types_default()).func,
100740
100753
  renderPreviewMenu: (prop_types_default()).func,
100741
100754
  getPopupContainer: (prop_types_default()).func,
@@ -100760,9 +100773,7 @@ PreviewInner.defaultProps = {
100760
100773
  preLoadGap: 2,
100761
100774
  zIndex: 1000,
100762
100775
  maskClosable: true,
100763
- viewerVisibleDelay: 10000,
100764
- maxZoom: 5,
100765
- minZoom: 0.1
100776
+ viewerVisibleDelay: 10000
100766
100777
  };
100767
100778
  ;// CONCATENATED MODULE: ../semi-foundation/image/imageFoundation.ts
100768
100779
 
@@ -101406,8 +101417,6 @@ Preview.defaultProps = {
101406
101417
 
101407
101418
 
101408
101419
 
101409
-
101410
-
101411
101420
 
101412
101421
 
101413
101422