@autobest-ui/components 2.3.0 → 2.5.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 (141) hide show
  1. package/esm/accordion/Item.js +6 -23
  2. package/esm/accordion/index.js +8 -36
  3. package/esm/affix/PortalAffix.js +7 -11
  4. package/esm/affix/index.js +30 -70
  5. package/esm/carousel/index.js +45 -141
  6. package/esm/checkbox/index.js +12 -37
  7. package/esm/collapse/index.js +11 -49
  8. package/esm/confirm/index.d.ts +8 -0
  9. package/esm/confirm/index.js +23 -31
  10. package/esm/date-picker/DateEnum.js +0 -3
  11. package/esm/date-picker/calendar/Day.js +62 -78
  12. package/esm/date-picker/calendar/MonthYear.js +20 -53
  13. package/esm/date-picker/calendar/grid/index.js +7 -12
  14. package/esm/date-picker/calendar/index.js +4 -31
  15. package/esm/date-picker/index.js +11 -51
  16. package/esm/date-picker/utils.js +6 -11
  17. package/esm/drawer/Child.js +10 -20
  18. package/esm/drawer/index.js +22 -71
  19. package/esm/ellipsis/index.js +9 -17
  20. package/esm/guide/index.js +25 -63
  21. package/esm/index.d.ts +2 -2
  22. package/esm/index.js +1 -1
  23. package/esm/input-number/ControlArrow.js +0 -2
  24. package/esm/input-number/constants.js +2 -2
  25. package/esm/input-number/index.js +26 -106
  26. package/esm/lazy-image/index.js +10 -55
  27. package/esm/link-list/index.js +11 -35
  28. package/esm/loading/index.js +15 -42
  29. package/esm/loading-container/index.js +3 -6
  30. package/esm/loading-icon/index.js +0 -2
  31. package/esm/mask/index.js +6 -9
  32. package/esm/message/index.d.ts +44 -7
  33. package/esm/message/index.js +96 -111
  34. package/esm/message/renderMessage.d.ts +17 -0
  35. package/esm/message/renderMessage.js +137 -0
  36. package/esm/message/style/index.css +1 -1
  37. package/esm/modal/Title.js +5 -12
  38. package/esm/modal/getPopupLocation.js +5 -7
  39. package/esm/modal/index.js +44 -125
  40. package/esm/move/index.js +32 -132
  41. package/esm/move/range.js +6 -12
  42. package/esm/move/utils.js +3 -10
  43. package/esm/popover/index.js +9 -28
  44. package/esm/portal/index.js +1 -22
  45. package/esm/script/index.js +19 -59
  46. package/esm/select/index.js +28 -106
  47. package/esm/show-more/index.js +40 -103
  48. package/esm/skeleton/Item.js +1 -3
  49. package/esm/skeleton/index.js +5 -11
  50. package/esm/style.css +1 -1
  51. package/esm/table/body/BodyRow.js +11 -28
  52. package/esm/table/body/CheckIcon.js +10 -18
  53. package/esm/table/body/index.js +8 -12
  54. package/esm/table/header/CheckIcon.js +3 -11
  55. package/esm/table/header/HeaderCell.js +12 -33
  56. package/esm/table/header/HeaderRow.js +6 -17
  57. package/esm/table/index.js +30 -100
  58. package/esm/tabs/index.js +35 -118
  59. package/esm/tooltip/index.js +0 -4
  60. package/esm/trigger/align.js +6 -6
  61. package/esm/trigger/bottomAlign.js +33 -45
  62. package/esm/trigger/constants.js +0 -1
  63. package/esm/trigger/getPopupLocation.js +48 -68
  64. package/esm/trigger/index.js +52 -187
  65. package/esm/trigger/leftAlign.js +33 -47
  66. package/esm/trigger/ref.js +2 -7
  67. package/esm/trigger/rightAlign.js +33 -45
  68. package/esm/trigger/topAlign.js +33 -45
  69. package/esm/trigger/utils.js +28 -45
  70. package/lib/accordion/Item.js +6 -27
  71. package/lib/accordion/index.js +8 -41
  72. package/lib/affix/PortalAffix.js +7 -17
  73. package/lib/affix/index.js +30 -75
  74. package/lib/carousel/index.js +45 -146
  75. package/lib/checkbox/index.js +12 -41
  76. package/lib/collapse/index.js +11 -53
  77. package/lib/confirm/index.d.ts +8 -0
  78. package/lib/confirm/index.js +23 -38
  79. package/lib/date-picker/DateEnum.js +0 -3
  80. package/lib/date-picker/calendar/Day.js +62 -87
  81. package/lib/date-picker/calendar/MonthYear.js +20 -62
  82. package/lib/date-picker/calendar/grid/index.js +7 -16
  83. package/lib/date-picker/calendar/index.js +4 -37
  84. package/lib/date-picker/index.js +9 -58
  85. package/lib/date-picker/utils.js +6 -26
  86. package/lib/drawer/Child.js +10 -25
  87. package/lib/drawer/index.js +22 -78
  88. package/lib/ellipsis/index.js +9 -23
  89. package/lib/guide/index.js +25 -71
  90. package/lib/index.d.ts +2 -2
  91. package/lib/index.js +12 -32
  92. package/lib/input-number/ControlArrow.js +0 -4
  93. package/lib/input-number/constants.js +2 -2
  94. package/lib/input-number/index.js +26 -114
  95. package/lib/lazy-image/index.js +10 -58
  96. package/lib/link-list/index.js +11 -40
  97. package/lib/loading/index.js +13 -48
  98. package/lib/loading-bar/index.js +0 -5
  99. package/lib/loading-container/index.js +3 -11
  100. package/lib/loading-icon/index.js +0 -7
  101. package/lib/mask/index.js +6 -17
  102. package/lib/message/index.d.ts +44 -7
  103. package/lib/message/index.js +97 -120
  104. package/lib/message/renderMessage.d.ts +17 -0
  105. package/lib/message/renderMessage.js +144 -0
  106. package/lib/message/style/index.css +1 -1
  107. package/lib/modal/Affix.js +0 -4
  108. package/lib/modal/Title.js +5 -15
  109. package/lib/modal/getPopupLocation.js +5 -9
  110. package/lib/modal/index.js +44 -135
  111. package/lib/move/index.js +32 -144
  112. package/lib/move/range.js +6 -14
  113. package/lib/move/utils.js +3 -12
  114. package/lib/popover/index.js +9 -33
  115. package/lib/portal/index.js +1 -25
  116. package/lib/script/index.js +19 -61
  117. package/lib/select/index.js +28 -113
  118. package/lib/show-more/index.js +40 -110
  119. package/lib/skeleton/Item.js +1 -8
  120. package/lib/skeleton/index.js +5 -16
  121. package/lib/style.css +1 -1
  122. package/lib/table/body/BodyRow.js +11 -33
  123. package/lib/table/body/CheckIcon.js +10 -22
  124. package/lib/table/body/index.js +8 -17
  125. package/lib/table/header/CheckIcon.js +3 -15
  126. package/lib/table/header/HeaderCell.js +12 -37
  127. package/lib/table/header/HeaderRow.js +6 -22
  128. package/lib/table/index.js +30 -107
  129. package/lib/tabs/index.js +35 -122
  130. package/lib/tooltip/index.js +0 -9
  131. package/lib/trigger/align.js +0 -4
  132. package/lib/trigger/bottomAlign.js +33 -48
  133. package/lib/trigger/constants.js +0 -2
  134. package/lib/trigger/getPopupLocation.js +48 -74
  135. package/lib/trigger/index.js +52 -198
  136. package/lib/trigger/leftAlign.js +33 -50
  137. package/lib/trigger/ref.js +2 -12
  138. package/lib/trigger/rightAlign.js +33 -48
  139. package/lib/trigger/topAlign.js +33 -48
  140. package/lib/trigger/utils.js +28 -53
  141. package/package.json +7 -3
@@ -1,28 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _reactDom = require("react-dom");
13
-
14
10
  var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
11
  var _utils = require("@autobest-ui/utils");
17
-
18
12
  var _reactTransitionGroup = require("react-transition-group");
19
-
20
13
  var _portal = _interopRequireDefault(require("../portal"));
21
-
22
14
  var _ref = require("./ref");
23
-
24
15
  var _getPopupLocation = _interopRequireDefault(require("./getPopupLocation"));
25
-
26
16
  var __extends = void 0 && (void 0).__extends || function () {
27
17
  var _extendStatics = function extendStatics(d, b) {
28
18
  _extendStatics = Object.setPrototypeOf || {
@@ -34,140 +24,106 @@ var __extends = void 0 && (void 0).__extends || function () {
34
24
  if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
35
25
  }
36
26
  };
37
-
38
27
  return _extendStatics(d, b);
39
28
  };
40
-
41
29
  return function (d, b) {
42
30
  if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
43
-
44
31
  _extendStatics(d, b);
45
-
46
32
  function __() {
47
33
  this.constructor = d;
48
34
  }
49
-
50
35
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
51
36
  };
52
37
  }();
53
-
54
38
  var __assign = void 0 && (void 0).__assign || function () {
55
39
  __assign = Object.assign || function (t) {
56
40
  for (var s, i = 1, n = arguments.length; i < n; i++) {
57
41
  s = arguments[i];
58
-
59
42
  for (var p in s) {
60
43
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
61
44
  }
62
45
  }
63
-
64
46
  return t;
65
47
  };
66
-
67
48
  return __assign.apply(this, arguments);
68
49
  };
69
-
70
50
  function noop() {}
71
-
72
- var Trigger =
73
- /** @class */
74
- function (_super) {
51
+ var Trigger = /** @class */function (_super) {
75
52
  __extends(Trigger, _super);
76
-
77
53
  function Trigger(props) {
78
54
  var _this = _super.call(this, props) || this;
79
-
80
55
  _this.prefixCls = 'ab-trigger';
81
56
  _this.popupRef = /*#__PURE__*/_react.default.createRef();
82
57
  _this.maskRef = /*#__PURE__*/_react.default.createRef();
83
58
  _this.triggerRef = /*#__PURE__*/_react.default.createRef();
84
-
85
59
  _this.isClickToHide = function () {
86
60
  return _this.props.trigger.indexOf('click') !== -1;
87
61
  };
88
-
89
62
  _this.clearPopupTimer = function (popupEl) {
90
63
  clearTimeout(_this.popupTimer);
91
-
92
64
  var element = popupEl || _this.getPopupDomNode();
93
-
94
65
  if (element) {
95
66
  element.style.visibility = '';
96
67
  }
97
68
  };
98
-
99
69
  _this.forceAlign = function (popupEl) {
100
70
  var rootEl = _this.getRootDomNode();
101
-
102
71
  popupEl = popupEl || _this.getPopupDomNode();
103
-
104
72
  if (!popupEl || !rootEl) {
105
73
  return;
106
74
  }
107
-
108
75
  _this.clearPopupTimer(popupEl);
109
-
110
76
  var _a = _this.props,
111
- placement = _a.placement,
112
- translateX = _a.translateX,
113
- translateY = _a.translateY,
114
- rootToPopupSpacing = _a.rootToPopupSpacing,
115
- popupLimitSpacing = _a.popupLimitSpacing,
116
- isTransformHorizontalDirection = _a.isTransformHorizontalDirection,
117
- hiddenArrow = _a.hiddenArrow,
118
- onArrowStyleChange = _a.onArrowStyleChange,
119
- maxHeight = _a.maxHeight,
120
- isMinRootWidth = _a.isMinRootWidth,
121
- isMaxRootWidth = _a.isMaxRootWidth,
122
- isInsertNode = _a.isInsertNode;
123
-
77
+ placement = _a.placement,
78
+ translateX = _a.translateX,
79
+ translateY = _a.translateY,
80
+ rootToPopupSpacing = _a.rootToPopupSpacing,
81
+ popupLimitSpacing = _a.popupLimitSpacing,
82
+ isTransformHorizontalDirection = _a.isTransformHorizontalDirection,
83
+ hiddenArrow = _a.hiddenArrow,
84
+ onArrowStyleChange = _a.onArrowStyleChange,
85
+ maxHeight = _a.maxHeight,
86
+ isMinRootWidth = _a.isMinRootWidth,
87
+ isMaxRootWidth = _a.isMaxRootWidth,
88
+ isInsertNode = _a.isInsertNode;
124
89
  if (maxHeight) {
125
90
  popupEl.style.maxHeight = "".concat(maxHeight, "px");
126
91
  popupEl.style.overflowY = 'auto';
127
92
  }
128
-
129
93
  if (isMinRootWidth || isMaxRootWidth) {
130
94
  var rootWidth = (0, _utils.getElementSize)(rootEl).width;
131
-
132
95
  if (isMinRootWidth) {
133
96
  popupEl.style.minWidth = "".concat(rootWidth, "px");
134
97
  }
135
-
136
98
  if (isMaxRootWidth) {
137
99
  popupEl.style.maxWidth = "".concat(rootWidth, "px");
138
100
  popupEl.style.overflowX = 'auto';
139
101
  }
140
- } // 计算Popup元素应该显示的位置
141
-
142
-
102
+ }
103
+ // 计算Popup元素应该显示的位置
143
104
  var _b = (0, _getPopupLocation.default)(placement, rootEl, popupEl, translateX, translateY, rootToPopupSpacing, popupLimitSpacing, isTransformHorizontalDirection, hiddenArrow, isInsertNode),
144
- left = _b.left,
145
- top = _b.top,
146
- arrowStyle = _b.arrowStyle,
147
- transformOrigin = _b.transformOrigin,
148
- popupMaxWidthByCalc = _b.maxWidth,
149
- popupMaxHeightByCalc = _b.maxHeight,
150
- width = _b.width,
151
- height = _b.height;
152
-
105
+ left = _b.left,
106
+ top = _b.top,
107
+ arrowStyle = _b.arrowStyle,
108
+ transformOrigin = _b.transformOrigin,
109
+ popupMaxWidthByCalc = _b.maxWidth,
110
+ popupMaxHeightByCalc = _b.maxHeight,
111
+ width = _b.width,
112
+ height = _b.height;
153
113
  _this.prevPopupSize = {
154
114
  width: width,
155
115
  height: height
156
116
  };
157
-
158
117
  if (!hiddenArrow && onArrowStyleChange && JSON.stringify(arrowStyle) !== JSON.stringify(_this.prevArrowStyle)) {
159
118
  _this.prevArrowStyle = arrowStyle;
160
119
  onArrowStyleChange(arrowStyle);
161
120
  }
162
-
163
121
  popupEl.style.transformOrigin = transformOrigin;
164
122
  popupEl.style.left = "".concat(left, "px");
165
123
  popupEl.style.top = "".concat(top, "px");
166
-
167
124
  if (popupMaxHeightByCalc) {
168
125
  popupEl.style.maxHeight = "".concat(popupMaxWidthByCalc, "px");
169
126
  }
170
-
171
127
  if (popupMaxWidthByCalc) {
172
128
  popupEl.style.maxWidth = "".concat(popupMaxWidthByCalc, "px");
173
129
  popupEl.style.overflowX = 'auto';
@@ -175,89 +131,67 @@ function (_super) {
175
131
  popupEl.style.maxWidth = '';
176
132
  }
177
133
  };
178
-
179
134
  _this.getRootDomNode = function () {
180
135
  var getCurrentDOMNode = _this.props.getCurrentDOMNode;
181
-
182
136
  if (getCurrentDOMNode) {
183
137
  return getCurrentDOMNode(_this.triggerRef.current);
184
138
  }
185
-
186
139
  try {
187
140
  // 支持children是组件的情况, 穿透组件获取HTML元素
188
141
  // eslint-disable-next-line react/no-find-dom-node
189
142
  var domNode = (0, _reactDom.findDOMNode)(_this.triggerRef.current);
190
-
191
143
  if (domNode) {
192
144
  return domNode;
193
145
  }
194
146
  } catch (err) {}
195
-
196
147
  return null;
197
148
  };
198
149
  /**
199
150
  * 全局事件回调
200
151
  * @param event
201
152
  */
202
-
203
-
204
153
  _this.onDocumentClick = function (event) {
205
154
  if (!_this.state.visible) {
206
155
  return;
207
156
  }
208
-
209
157
  var target = event.target;
210
-
211
158
  var root = _this.getRootDomNode();
212
-
213
159
  var popupNode = _this.getPopupDomNode();
214
-
215
160
  if (!root || !target || !popupNode) {
216
161
  return;
217
162
  }
218
-
219
163
  var showMask = _this.props.showMask;
220
-
221
164
  var maskEl = _this.getMaskDomNode();
222
-
223
165
  if (showMask && !maskEl) {
224
166
  return;
225
- } // 排除操作当前元素
226
-
227
-
167
+ }
168
+ // 排除操作当前元素
228
169
  if (!(0, _utils.contains)(root, target) && (!showMask || maskEl === target) && !(0, _utils.contains)(popupNode, target) && !_this.hasPopupMouseDown) {
229
170
  _this.hidePopup();
230
171
  }
231
172
  };
232
-
233
173
  _this.showPopup = function () {
234
174
  _this.triggerPopup(true);
235
175
  };
236
-
237
176
  _this.hidePopup = function (ev) {
238
177
  if (ev) {
239
178
  ev.stopPropagation();
240
179
  ev.nativeEvent.stopImmediatePropagation();
241
180
  }
242
-
243
181
  _this.triggerPopup(false);
244
182
  };
245
-
246
183
  _this.onVisibleChange = function (visible) {
247
184
  var prevVisible = _this.state.visible;
248
185
  clearTimeout(_this.delayTimer);
249
-
250
186
  if (prevVisible !== visible) {
251
187
  if (!_this.isOutsideControl()) {
252
188
  _this.setState({
253
189
  visible: visible
254
190
  });
255
191
  }
256
-
257
192
  var _a = _this.props,
258
- onVisibleChange = _a.onVisibleChange,
259
- name_1 = _a.name;
260
-
193
+ onVisibleChange = _a.onVisibleChange,
194
+ name_1 = _a.name;
261
195
  if (onVisibleChange) {
262
196
  onVisibleChange(visible, name_1);
263
197
  }
@@ -267,21 +201,17 @@ function (_super) {
267
201
  * 设置显示与隐藏
268
202
  * @param nextVisible
269
203
  */
270
-
271
-
272
204
  _this.triggerPopup = function (nextVisible) {
273
205
  if (nextVisible) {
274
- _this.hasPopupMouseDown = true; // 禁止执行全局监听,回调函数中的隐藏功能
275
-
206
+ _this.hasPopupMouseDown = true;
207
+ // 禁止执行全局监听,回调函数中的隐藏功能
276
208
  clearTimeout(_this.mouseDownTimeout);
277
209
  _this.mouseDownTimeout = setTimeout(function () {
278
210
  _this.hasPopupMouseDown = false;
279
211
  }, 0);
280
212
  }
281
-
282
213
  _this.onVisibleChange(nextVisible);
283
214
  };
284
-
285
215
  _this.onPopupMouseDown = function () {
286
216
  _this.hasPopupMouseDown = true;
287
217
  clearTimeout(_this.mouseDownTimeout);
@@ -289,59 +219,45 @@ function (_super) {
289
219
  _this.hasPopupMouseDown = false;
290
220
  }, 0);
291
221
  };
292
-
293
222
  _this.onClick = function (event) {
294
223
  if (event && event.preventDefault) {
295
224
  event.preventDefault();
296
225
  }
297
-
298
226
  var touch = (0, _utils.isTouchScreen)();
299
-
300
227
  if (event.type === 'touchstart' && touch || event.type === 'mousedown' && !touch) {
301
228
  _this.triggerPopup(!_this.state.visible);
302
229
  }
303
230
  };
304
-
305
231
  _this.onMouseEnter = function () {
306
232
  _this.delaySetPopupVisible(true, _this.props.mouseEnterDelay);
307
233
  };
308
-
309
234
  _this.onMouseLeave = function () {
310
235
  _this.delaySetPopupVisible(false, _this.props.mouseLeaveDelay);
311
236
  };
312
-
313
237
  _this.onPopupMouseEnter = function () {
314
238
  clearTimeout(_this.delayTimer);
315
239
  };
316
-
317
240
  _this.onPopupMouseLeave = function () {
318
241
  _this.delaySetPopupVisible(false, _this.props.mouseLeaveDelay);
319
242
  };
320
-
321
243
  _this.onExited = function () {
322
244
  _this.clearPopupTimer();
323
-
324
245
  var onDestroy = _this.props.onDestroy;
325
-
326
246
  if (onDestroy) {
327
247
  onDestroy();
328
248
  }
329
249
  };
330
-
331
250
  _this.isCurrentTrigger = function (eventName, trigger) {
332
251
  return trigger.indexOf(eventName) !== -1;
333
252
  };
334
-
335
253
  _this.isOutsideControl = function () {
336
254
  return 'visible' in _this.props;
337
255
  };
338
-
339
256
  _this.onPreventThrough = function (event) {
340
257
  if (event && event.preventDefault) {
341
258
  event.preventDefault();
342
259
  }
343
260
  };
344
-
345
261
  _this.state = {
346
262
  visible: false,
347
263
  isUserOperated: false,
@@ -349,7 +265,6 @@ function (_super) {
349
265
  };
350
266
  return _this;
351
267
  }
352
-
353
268
  Trigger.getPopupInnerHeight = function (element) {
354
269
  if (element.children && element.children.length) {
355
270
  var height_1 = (0, _utils.getStyleValue)(element, 'padding-top') + (0, _utils.getStyleValue)(element, 'padding-bottom');
@@ -359,53 +274,40 @@ function (_super) {
359
274
  });
360
275
  return height_1;
361
276
  }
362
-
363
277
  return (0, _utils.getElementSize)(element).height;
364
278
  };
365
-
366
279
  Trigger.getDerivedStateFromProps = function (nextProps, preState) {
367
280
  var nextState = {};
368
-
369
281
  if ('visible' in nextProps) {
370
282
  nextState.visible = nextProps.visible;
371
- } // 在触摸屏下, hover 事件转成click
372
-
373
-
283
+ }
284
+ // 在触摸屏下, hover 事件转成click
374
285
  if (nextProps.trigger === 'hover' && (0, _utils.isTouchScreen)()) {
375
286
  nextState.trigger = 'click';
376
287
  }
377
-
378
288
  var isUserOperated = preState.isUserOperated || nextState.visible || preState.visible;
379
-
380
289
  if (isUserOperated !== preState.isUserOperated) {
381
290
  nextState.isUserOperated = isUserOperated;
382
291
  }
383
-
384
292
  if ((0, _utils.isEmptyObject)(nextState)) {
385
293
  return null;
386
294
  }
387
-
388
295
  return nextState;
389
296
  };
390
-
391
297
  Trigger.prototype.componentDidMount = function () {
392
298
  this.componentDidUpdate();
393
299
  };
394
-
395
300
  Trigger.prototype.componentDidUpdate = function () {
396
301
  var _this = this;
397
-
398
302
  var visible = this.state.visible;
399
-
400
303
  if (!visible) {
401
304
  // 其中参数是解决: 当同时多个trigger在同一个组件中,一个更新(一个使用visible)导致多个都发生componentDidUpdate
402
305
  // 应该不让其他trigger 的delay事件销毁
403
306
  this.clearOutsideHandler(true);
404
307
  return;
405
308
  }
406
-
407
- var popupEl = this.getPopupDomNode(); // 加入 resize 监听
408
-
309
+ var popupEl = this.getPopupDomNode();
310
+ // 加入 resize 监听
409
311
  if (this.props.monitorWindowResize && !this.resizeHandler) {
410
312
  var handle = this.props.windowResizeHidden ? (0, _utils.throttleWithRAF)(function () {
411
313
  return _this.triggerPopup(false);
@@ -413,126 +315,99 @@ function (_super) {
413
315
  return _this.forceAlign();
414
316
  });
415
317
  this.resizeHandler = (0, _utils.addEventListener)(window, 'resize', handle);
416
- } // 加入 scroll 监听
417
-
418
-
318
+ }
319
+ // 加入 scroll 监听
419
320
  if (visible && this.props.scrollClosable && !this.scrollHandler) {
420
321
  this.scrollHandler = (0, _utils.addEventListener)(window, 'scroll', function () {
421
322
  if (_this.scrollHandler) {
422
323
  _this.scrollHandler.remove();
423
-
424
324
  _this.scrollHandler = null;
425
325
  }
426
-
427
326
  _this.triggerPopup(false);
428
327
  });
429
- } // 需要监听 `mousedown` or `touchstart`, 而不是click
430
-
431
-
328
+ }
329
+ // 需要监听 `mousedown` or `touchstart`, 而不是click
432
330
  var currentDocument;
433
331
  var touch = (0, _utils.isTouchScreen)();
434
-
435
332
  if (!this.clickOutsideHandler && !touch && this.isClickToHide()) {
436
333
  currentDocument = window.document;
437
334
  this.clickOutsideHandler = (0, _utils.addEventListener)(currentDocument, 'mousedown', this.onDocumentClick);
438
- } // always hide on mobile
439
-
440
-
335
+ }
336
+ // always hide on mobile
441
337
  if (!this.touchOutsideHandler) {
442
338
  currentDocument = currentDocument || window.document;
443
339
  this.touchOutsideHandler = (0, _utils.addEventListener)(currentDocument, 'touchstart', this.onDocumentClick);
444
340
  }
445
-
446
341
  if (popupEl && this.prevPopupSize) {
447
342
  var _a = (0, _utils.getElementSize)(popupEl),
448
- width = _a.width,
449
- height = _a.height;
450
-
343
+ width = _a.width,
344
+ height = _a.height;
451
345
  if (this.prevPopupSize.width !== width || this.prevPopupSize.height !== height) {
452
346
  this.clearPopupTimer(popupEl);
453
347
  popupEl.style.visibility = 'hidden';
454
348
  this.popupTimer = setTimeout(function () {
455
349
  _this.forceAlign(popupEl);
456
-
457
350
  popupEl.style.visibility = '';
458
351
  });
459
352
  }
460
353
  }
461
354
  };
462
-
463
355
  Trigger.prototype.componentWillUnmount = function () {
464
356
  // remove绑定事件
465
357
  this.clearOutsideHandler();
466
358
  };
467
-
468
359
  Trigger.prototype.getPopupDomNode = function () {
469
360
  if (this.popupRef && this.popupRef.current) {
470
361
  return this.popupRef.current;
471
362
  }
472
-
473
363
  return null;
474
364
  };
475
-
476
365
  Trigger.prototype.getMaskDomNode = function () {
477
366
  if (this.maskRef && this.maskRef.current) {
478
367
  return this.maskRef.current;
479
368
  }
480
-
481
369
  return null;
482
370
  };
483
-
484
371
  Trigger.prototype.clearOutsideHandler = function (ignoreDelayTimer) {
485
372
  // clearTimeout(this.mouseDownTimeout);
486
373
  if (!ignoreDelayTimer) {
487
374
  clearTimeout(this.delayTimer);
488
375
  }
489
-
490
376
  this.clearPopupTimer();
491
-
492
377
  if (this.resizeHandler) {
493
378
  this.resizeHandler.remove();
494
379
  this.resizeHandler = null;
495
380
  }
496
-
497
381
  if (this.scrollHandler) {
498
382
  this.scrollHandler.remove();
499
383
  this.scrollHandler = null;
500
384
  }
501
-
502
385
  if (this.clickOutsideHandler) {
503
386
  this.clickOutsideHandler.remove();
504
387
  this.clickOutsideHandler = null;
505
388
  }
506
-
507
389
  if (this.touchOutsideHandler) {
508
390
  this.touchOutsideHandler.remove();
509
391
  this.touchOutsideHandler = null;
510
392
  }
511
393
  };
512
-
513
394
  Trigger.prototype.delaySetPopupVisible = function (visible, delayTime) {
514
395
  var _this = this;
515
-
516
396
  clearTimeout(this.delayTimer);
517
-
518
397
  if (delayTime) {
519
398
  var delay = delayTime * 1000;
520
399
  this.delayTimer = setTimeout(function () {
521
400
  _this.triggerPopup(visible);
522
-
523
401
  clearTimeout(_this.delayTimer);
524
402
  }, delay);
525
403
  } else {
526
404
  this.triggerPopup(visible);
527
405
  }
528
406
  };
529
-
530
407
  Trigger.prototype.renderMask = function () {
531
408
  var _a;
532
-
533
409
  var visible = this.state.visible;
534
410
  var showMask = this.props.showMask;
535
-
536
411
  if (showMask) {
537
412
  var cls = this.prefixCls;
538
413
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -541,32 +416,27 @@ function (_super) {
541
416
  onTouchEnd: this.onPreventThrough
542
417
  });
543
418
  }
544
-
545
419
  return null;
546
420
  };
547
-
548
421
  Trigger.prototype.renderPopupContent = function () {
549
422
  var _a;
550
-
551
423
  var cls = this.prefixCls;
552
424
  var _b = this.props,
553
- popup = _b.popup,
554
- wrapClassName = _b.wrapClassName,
555
- isTransformHorizontalDirection = _b.isTransformHorizontalDirection,
556
- isInsertNode = _b.isInsertNode;
425
+ popup = _b.popup,
426
+ wrapClassName = _b.wrapClassName,
427
+ isTransformHorizontalDirection = _b.isTransformHorizontalDirection,
428
+ isInsertNode = _b.isInsertNode;
557
429
  var _c = this.state,
558
- visible = _c.visible,
559
- isUserOperated = _c.isUserOperated,
560
- trigger = _c.trigger;
561
- var wrapClass = (0, _classnames.default)("".concat(cls, "-wrap"), wrapClassName, (_a = {}, _a["".concat(cls, "-hidden")] = isInsertNode && !isUserOperated && !visible, _a)); // hover 下,对popup增加相应的事件,延迟隐藏,可以在弹框中停留
562
-
430
+ visible = _c.visible,
431
+ isUserOperated = _c.isUserOperated,
432
+ trigger = _c.trigger;
433
+ var wrapClass = (0, _classnames.default)("".concat(cls, "-wrap"), wrapClassName, (_a = {}, _a["".concat(cls, "-hidden")] = isInsertNode && !isUserOperated && !visible, _a));
434
+ // hover 下,对popup增加相应的事件,延迟隐藏,可以在弹框中停留
563
435
  var mouseProps = {};
564
-
565
436
  if (this.isCurrentTrigger('hover', trigger)) {
566
437
  mouseProps.onMouseEnter = this.onPopupMouseEnter;
567
438
  mouseProps.onMouseLeave = this.onPopupMouseLeave;
568
439
  }
569
-
570
440
  mouseProps.onMouseDown = this.onPopupMouseDown;
571
441
  mouseProps.onTouchStart = this.onPopupMouseDown;
572
442
  return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
@@ -584,61 +454,46 @@ function (_super) {
584
454
  /**
585
455
  * 扩充children属性,根据trigger绑定不同事件
586
456
  */
587
-
588
-
589
457
  Trigger.prototype.renderChildComponent = function () {
590
458
  var children = this.props.children;
591
459
  var trigger = this.state.trigger;
592
-
593
460
  var child = _react.default.Children.only(children);
594
-
595
461
  var newChildProps = {
596
462
  key: 'trigger'
597
463
  };
598
-
599
464
  if (this.isCurrentTrigger('hover', trigger) && this.props.trigger === trigger) {
600
465
  newChildProps.onMouseEnter = this.onMouseEnter;
601
466
  newChildProps.onMouseLeave = this.onMouseLeave;
602
467
  }
603
-
604
468
  if (!this.isOutsideControl() || this.props.trigger !== trigger) {
605
469
  if (this.isCurrentTrigger('click', trigger)) {
606
470
  newChildProps.onMouseDown = this.onClick;
607
471
  newChildProps.onTouchStart = this.onClick;
608
472
  }
609
-
610
473
  if (this.isCurrentTrigger('focus', trigger)) {
611
474
  newChildProps.onFocus = this.showPopup;
612
475
  newChildProps.onBlur = this.hidePopup;
613
476
  }
614
477
  }
615
-
616
478
  var cloneProps = __assign({}, newChildProps);
617
-
618
479
  if ((0, _ref.supportRef)(child)) {
619
480
  cloneProps.ref = (0, _ref.composeRef)(this.triggerRef, child.ref);
620
- } // 对当前children元素添加额外属性
621
-
622
-
481
+ }
482
+ // 对当前children元素添加额外属性
623
483
  return /*#__PURE__*/_react.default.cloneElement(child, cloneProps);
624
484
  };
625
-
626
485
  Trigger.prototype.renderPopupComponent = function () {
627
486
  if (this.props.isInsertNode) {
628
487
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderMask(), this.renderPopupContent());
629
488
  }
630
-
631
489
  if (this.state.visible || this.popupRef.current) {
632
490
  return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderMask(), this.renderPopupContent()));
633
491
  }
634
-
635
492
  return null;
636
493
  };
637
-
638
494
  Trigger.prototype.render = function () {
639
495
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.renderChildComponent(), this.renderPopupComponent());
640
496
  };
641
-
642
497
  Trigger.defaultProps = {
643
498
  placement: 'Top',
644
499
  trigger: 'hover',
@@ -662,6 +517,5 @@ function (_super) {
662
517
  };
663
518
  return Trigger;
664
519
  }(_react.default.Component);
665
-
666
520
  var _default = Trigger;
667
521
  exports.default = _default;