@autobest-ui/components 2.3.0 → 2.4.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 (140) 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 +1 -1
  22. package/esm/input-number/ControlArrow.js +0 -2
  23. package/esm/input-number/constants.js +2 -2
  24. package/esm/input-number/index.js +26 -106
  25. package/esm/lazy-image/index.js +10 -55
  26. package/esm/link-list/index.js +11 -35
  27. package/esm/loading/index.js +15 -42
  28. package/esm/loading-container/index.js +3 -6
  29. package/esm/loading-icon/index.js +0 -2
  30. package/esm/mask/index.js +6 -9
  31. package/esm/message/index.d.ts +17 -6
  32. package/esm/message/index.js +68 -96
  33. package/esm/message/renderMessage.d.ts +17 -0
  34. package/esm/message/renderMessage.js +137 -0
  35. package/esm/message/style/index.css +1 -1
  36. package/esm/modal/Title.js +5 -12
  37. package/esm/modal/getPopupLocation.js +5 -7
  38. package/esm/modal/index.js +44 -125
  39. package/esm/move/index.js +32 -132
  40. package/esm/move/range.js +6 -12
  41. package/esm/move/utils.js +3 -10
  42. package/esm/popover/index.js +9 -28
  43. package/esm/portal/index.js +1 -22
  44. package/esm/script/index.js +19 -59
  45. package/esm/select/index.js +28 -106
  46. package/esm/show-more/index.js +40 -103
  47. package/esm/skeleton/Item.js +1 -3
  48. package/esm/skeleton/index.js +5 -11
  49. package/esm/style.css +1 -1
  50. package/esm/table/body/BodyRow.js +11 -28
  51. package/esm/table/body/CheckIcon.js +10 -18
  52. package/esm/table/body/index.js +8 -12
  53. package/esm/table/header/CheckIcon.js +3 -11
  54. package/esm/table/header/HeaderCell.js +12 -33
  55. package/esm/table/header/HeaderRow.js +6 -17
  56. package/esm/table/index.js +30 -100
  57. package/esm/tabs/index.js +35 -118
  58. package/esm/tooltip/index.js +0 -4
  59. package/esm/trigger/align.js +6 -6
  60. package/esm/trigger/bottomAlign.js +33 -45
  61. package/esm/trigger/constants.js +0 -1
  62. package/esm/trigger/getPopupLocation.js +48 -68
  63. package/esm/trigger/index.js +52 -187
  64. package/esm/trigger/leftAlign.js +33 -47
  65. package/esm/trigger/ref.js +2 -7
  66. package/esm/trigger/rightAlign.js +33 -45
  67. package/esm/trigger/topAlign.js +33 -45
  68. package/esm/trigger/utils.js +28 -45
  69. package/lib/accordion/Item.js +6 -27
  70. package/lib/accordion/index.js +8 -41
  71. package/lib/affix/PortalAffix.js +7 -17
  72. package/lib/affix/index.js +30 -75
  73. package/lib/carousel/index.js +45 -146
  74. package/lib/checkbox/index.js +12 -41
  75. package/lib/collapse/index.js +11 -53
  76. package/lib/confirm/index.d.ts +8 -0
  77. package/lib/confirm/index.js +23 -38
  78. package/lib/date-picker/DateEnum.js +0 -3
  79. package/lib/date-picker/calendar/Day.js +62 -87
  80. package/lib/date-picker/calendar/MonthYear.js +20 -62
  81. package/lib/date-picker/calendar/grid/index.js +7 -16
  82. package/lib/date-picker/calendar/index.js +4 -37
  83. package/lib/date-picker/index.js +9 -58
  84. package/lib/date-picker/utils.js +6 -26
  85. package/lib/drawer/Child.js +10 -25
  86. package/lib/drawer/index.js +22 -78
  87. package/lib/ellipsis/index.js +9 -23
  88. package/lib/guide/index.js +25 -71
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +0 -29
  91. package/lib/input-number/ControlArrow.js +0 -4
  92. package/lib/input-number/constants.js +2 -2
  93. package/lib/input-number/index.js +26 -114
  94. package/lib/lazy-image/index.js +10 -58
  95. package/lib/link-list/index.js +11 -40
  96. package/lib/loading/index.js +13 -48
  97. package/lib/loading-bar/index.js +0 -5
  98. package/lib/loading-container/index.js +3 -11
  99. package/lib/loading-icon/index.js +0 -7
  100. package/lib/mask/index.js +6 -17
  101. package/lib/message/index.d.ts +17 -6
  102. package/lib/message/index.js +67 -104
  103. package/lib/message/renderMessage.d.ts +17 -0
  104. package/lib/message/renderMessage.js +144 -0
  105. package/lib/message/style/index.css +1 -1
  106. package/lib/modal/Affix.js +0 -4
  107. package/lib/modal/Title.js +5 -15
  108. package/lib/modal/getPopupLocation.js +5 -9
  109. package/lib/modal/index.js +44 -135
  110. package/lib/move/index.js +32 -144
  111. package/lib/move/range.js +6 -14
  112. package/lib/move/utils.js +3 -12
  113. package/lib/popover/index.js +9 -33
  114. package/lib/portal/index.js +1 -25
  115. package/lib/script/index.js +19 -61
  116. package/lib/select/index.js +28 -113
  117. package/lib/show-more/index.js +40 -110
  118. package/lib/skeleton/Item.js +1 -8
  119. package/lib/skeleton/index.js +5 -16
  120. package/lib/style.css +1 -1
  121. package/lib/table/body/BodyRow.js +11 -33
  122. package/lib/table/body/CheckIcon.js +10 -22
  123. package/lib/table/body/index.js +8 -17
  124. package/lib/table/header/CheckIcon.js +3 -15
  125. package/lib/table/header/HeaderCell.js +12 -37
  126. package/lib/table/header/HeaderRow.js +6 -22
  127. package/lib/table/index.js +30 -107
  128. package/lib/tabs/index.js +35 -122
  129. package/lib/tooltip/index.js +0 -9
  130. package/lib/trigger/align.js +0 -4
  131. package/lib/trigger/bottomAlign.js +33 -48
  132. package/lib/trigger/constants.js +0 -2
  133. package/lib/trigger/getPopupLocation.js +48 -74
  134. package/lib/trigger/index.js +52 -198
  135. package/lib/trigger/leftAlign.js +33 -50
  136. package/lib/trigger/ref.js +2 -12
  137. package/lib/trigger/rightAlign.js +33 -48
  138. package/lib/trigger/topAlign.js +33 -48
  139. package/lib/trigger/utils.js +28 -53
  140. package/package.json +7 -3
@@ -9,54 +9,39 @@ var __extends = this && this.__extends || function () {
9
9
  if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
10
10
  }
11
11
  };
12
-
13
12
  return _extendStatics(d, b);
14
13
  };
15
-
16
14
  return function (d, b) {
17
15
  if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
18
-
19
16
  _extendStatics(d, b);
20
-
21
17
  function __() {
22
18
  this.constructor = d;
23
19
  }
24
-
25
20
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26
21
  };
27
22
  }();
28
-
29
23
  var __assign = this && this.__assign || function () {
30
24
  __assign = Object.assign || function (t) {
31
25
  for (var s, i = 1, n = arguments.length; i < n; i++) {
32
26
  s = arguments[i];
33
-
34
27
  for (var p in s) {
35
28
  if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
36
29
  }
37
30
  }
38
-
39
31
  return t;
40
32
  };
41
-
42
33
  return __assign.apply(this, arguments);
43
34
  };
44
-
45
35
  import React from 'react';
46
36
  import classNames from 'classnames';
47
37
  import { addEventListener, getScrollBarSize, isEmptyArray, throttleWithRAF } from '@autobest-ui/utils';
48
38
  import LoadingContainer from '../loading-container';
49
39
  import HeaderRow from './header/HeaderRow';
50
40
  import Body from './body';
51
-
52
- var Table =
53
- /** @class */
54
- function (_super) {
41
+ var Table = /** @class */function (_super) {
55
42
  __extends(Table, _super);
56
-
57
43
  function Table(props) {
58
44
  var _this = _super.call(this, props) || this;
59
-
60
45
  _this.prefixCls = 'ab-table';
61
46
  _this.headerRef = /*#__PURE__*/React.createRef();
62
47
  _this.bodyRef = /*#__PURE__*/React.createRef();
@@ -71,7 +56,6 @@ function (_super) {
71
56
  /**
72
57
  * 清空选项
73
58
  */
74
-
75
59
  _this.clearSelection = function () {
76
60
  _this.setState(function (prevState) {
77
61
  return {
@@ -83,51 +67,40 @@ function (_super) {
83
67
  };
84
68
  });
85
69
  };
86
-
87
70
  _this.headerScroll = throttleWithRAF(function () {
88
71
  _this.headerRef.current.scrollLeft = _this.bodyRef.current.scrollLeft;
89
72
  });
90
-
91
73
  _this.addListener = function () {
92
74
  var fixedHeader = _this.props.fixedHeader;
93
75
  var bodyRef = _this.bodyRef.current;
94
-
95
76
  if (fixedHeader && _this.headerRef.current && bodyRef) {
96
77
  _this.scrollHandler = addEventListener(bodyRef, 'scroll', _this.headerScroll);
97
78
  _this.resizeObserver = new ResizeObserver(function (entries) {
98
79
  for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
99
80
  var entry = entries_1[_i];
100
81
  var ele = entry.target;
101
-
102
82
  if (entry.contentBoxSize) {
103
83
  var headerRef = _this.headerRef.current;
104
-
105
84
  if (!headerRef) {
106
85
  return;
107
86
  }
108
-
109
87
  if (ele.scrollHeight > ele.clientHeight) {
110
88
  if (_this.scrollBarThAdded) {
111
89
  return;
112
90
  }
113
-
114
- var scrollBarTh = document.createElement('th'); // 显示滚动条的情况下,需要在thead追加一个与滚动条等宽的th
115
-
91
+ var scrollBarTh = document.createElement('th');
92
+ // 显示滚动条的情况下,需要在thead追加一个与滚动条等宽的th
116
93
  scrollBarTh.setAttribute('style', "width: ".concat(getScrollBarSize(), "px; padding: 0"));
117
94
  var tHeader = headerRef.querySelector('thead > tr');
118
-
119
95
  if (tHeader) {
120
96
  tHeader.appendChild(scrollBarTh);
121
97
  _this.scrollBarThAdded = true;
122
98
  }
123
-
124
99
  return;
125
100
  }
126
-
127
101
  if (_this.scrollBarThAdded) {
128
102
  // 删除thead追加了的与滚动条等宽的th
129
103
  var scrollBarTh = headerRef.querySelector('thead > tr > th:last-child');
130
-
131
104
  if (scrollBarTh) {
132
105
  scrollBarTh.parentNode.removeChild(scrollBarTh);
133
106
  }
@@ -135,16 +108,13 @@ function (_super) {
135
108
  }
136
109
  }
137
110
  });
138
-
139
111
  _this.resizeObserver.observe(bodyRef);
140
112
  }
141
113
  };
142
-
143
114
  _this.getSelectedRows = function (selectedKeys) {
144
115
  if (isEmptyArray(selectedKeys)) {
145
116
  return [];
146
117
  }
147
-
148
118
  var getRowKey = _this.getRowKey;
149
119
  var dataSource = _this.props.dataSource;
150
120
  return selectedKeys.map(function (key) {
@@ -156,21 +126,16 @@ function (_super) {
156
126
  /**
157
127
  * 点击表头的checkbox,全选或全不选
158
128
  */
159
-
160
-
161
129
  _this.onSelectAll = function (checked) {
162
130
  var getRowKey = _this.getRowKey;
163
131
  var _a = _this.props,
164
- dataSource = _a.dataSource,
165
- rowSelection = _a.rowSelection;
166
-
132
+ dataSource = _a.dataSource,
133
+ rowSelection = _a.rowSelection;
167
134
  if (checked) {
168
135
  var newSelectedRowKeys_1 = dataSource.map(getRowKey);
169
-
170
136
  if (rowSelection.onSelectAll) {
171
137
  rowSelection.onSelectAll(true);
172
138
  }
173
-
174
139
  _this.setState(function (prevState) {
175
140
  return {
176
141
  rowSelection: __assign(__assign({}, prevState.rowSelection), {
@@ -179,18 +144,14 @@ function (_super) {
179
144
  selectedRowKeys: newSelectedRowKeys_1
180
145
  };
181
146
  });
182
-
183
147
  if (rowSelection.onSelectedRowChange) {
184
148
  rowSelection.onSelectedRowChange(newSelectedRowKeys_1, dataSource);
185
149
  }
186
-
187
150
  return;
188
151
  }
189
-
190
152
  if (rowSelection.onSelectAll) {
191
153
  rowSelection.onSelectAll(false);
192
154
  }
193
-
194
155
  _this.setState(function (prevState) {
195
156
  return {
196
157
  rowSelection: __assign(__assign({}, prevState.rowSelection), {
@@ -199,7 +160,6 @@ function (_super) {
199
160
  selectedRowKeys: []
200
161
  };
201
162
  });
202
-
203
163
  if (rowSelection.onSelectedRowChange) {
204
164
  rowSelection.onSelectedRowChange([], []);
205
165
  }
@@ -210,20 +170,17 @@ function (_super) {
210
170
  * @param rowData
211
171
  * @param rowIndex
212
172
  */
213
-
214
-
215
173
  _this.onSelect = function (visible, rowData, rowIndex) {
216
174
  var getRowKey = _this.getRowKey;
217
175
  var _a = _this.props,
218
- dataSource = _a.dataSource,
219
- rowSelection = _a.rowSelection;
176
+ dataSource = _a.dataSource,
177
+ rowSelection = _a.rowSelection;
220
178
  var _b = _this.state,
221
- selectedRowKeys = _b.selectedRowKeys,
222
- selectedRows = _b.selectedRows;
179
+ selectedRowKeys = _b.selectedRowKeys,
180
+ selectedRows = _b.selectedRows;
223
181
  var newRowKey = getRowKey(rowData, rowIndex);
224
182
  var newSelectedRowKeys = [];
225
183
  var newSelectedRows = [];
226
-
227
184
  if (visible) {
228
185
  if (!selectedRowKeys.includes(newRowKey)) {
229
186
  newSelectedRowKeys = selectedRowKeys.concat(newRowKey);
@@ -234,16 +191,13 @@ function (_super) {
234
191
  if (currentValue === newRowKey) {
235
192
  return previousValue;
236
193
  }
237
-
238
194
  var data = dataSource.find(function (item, index) {
239
195
  return getRowKey(item, index) === currentValue;
240
196
  });
241
-
242
197
  if (data) {
243
198
  previousValue.selectedRowKeys.push(currentValue);
244
199
  previousValue.selectedRows.push(data);
245
200
  }
246
-
247
201
  return previousValue;
248
202
  }, {
249
203
  selectedRowKeys: [],
@@ -252,11 +206,9 @@ function (_super) {
252
206
  newSelectedRows = result.selectedRows;
253
207
  newSelectedRowKeys = result.selectedRowKeys;
254
208
  }
255
-
256
209
  if (rowSelection.onSelect) {
257
210
  rowSelection.onSelect(visible, rowData, selectedRows);
258
211
  }
259
-
260
212
  if (!visible && _this.state.rowSelection.selectAllChecked) {
261
213
  _this.setState(function (prevState) {
262
214
  return {
@@ -266,35 +218,28 @@ function (_super) {
266
218
  };
267
219
  });
268
220
  }
269
-
270
221
  _this.setState({
271
222
  selectedRowKeys: newSelectedRowKeys,
272
223
  selectedRows: newSelectedRows
273
224
  });
274
-
275
225
  if (rowSelection.onSelectedRowChange) {
276
226
  rowSelection.onSelectedRowChange(newSelectedRowKeys, newSelectedRows);
277
227
  }
278
228
  };
279
-
280
229
  _this.getDisabled = function (rowData) {
281
230
  var rowSelection = _this.props.rowSelection;
282
-
283
231
  if ('getDisabled' in rowSelection) {
284
232
  var _a = _this.state,
285
- selectedRowKeys = _a.selectedRowKeys,
286
- selectedRows = _a.selectedRows;
233
+ selectedRowKeys = _a.selectedRowKeys,
234
+ selectedRows = _a.selectedRows;
287
235
  return rowSelection.getDisabled(rowData, selectedRowKeys, selectedRows);
288
236
  }
289
-
290
237
  return false;
291
238
  };
292
-
293
239
  _this.getRowSelection = function () {
294
240
  if (!('rowSelection' in _this.props) || !_this.props.rowSelection) {
295
241
  return null;
296
242
  }
297
-
298
243
  var propsRowSelection = _this.props.rowSelection;
299
244
  return __assign(__assign(__assign({}, _this.defaultRowSelection), propsRowSelection), {
300
245
  onSelect: _this.onSelect,
@@ -305,17 +250,14 @@ function (_super) {
305
250
  /**
306
251
  * 用colgroup设置每一列的宽度
307
252
  */
308
-
309
-
310
253
  _this.renderColgroup = function () {
311
254
  var _a = _this.props,
312
- columns = _a.columns,
313
- rowSelection = _a.rowSelection;
255
+ columns = _a.columns,
256
+ rowSelection = _a.rowSelection;
314
257
  return /*#__PURE__*/React.createElement("colgroup", null, rowSelection ? /*#__PURE__*/React.createElement("col", {
315
258
  className: "".concat(_this.prefixCls, "-checkbox-col")
316
259
  }) : null, columns.map(function (item) {
317
260
  var width = item.width;
318
-
319
261
  if (width) {
320
262
  return /*#__PURE__*/React.createElement("col", {
321
263
  key: item.key,
@@ -325,21 +267,19 @@ function (_super) {
325
267
  }
326
268
  });
327
269
  }
328
-
329
270
  return /*#__PURE__*/React.createElement("col", {
330
271
  key: item.key
331
272
  });
332
273
  }));
333
274
  };
334
-
335
275
  _this.renderHeader = function () {
336
276
  var cls = _this.prefixCls;
337
277
  var _a = _this.props,
338
- columns = _a.columns,
339
- sortName = _a.sortName,
340
- isSortedDescending = _a.isSortedDescending,
341
- sortIcon = _a.sortIcon,
342
- onSortChange = _a.onSortChange;
278
+ columns = _a.columns,
279
+ sortName = _a.sortName,
280
+ isSortedDescending = _a.isSortedDescending,
281
+ sortIcon = _a.sortIcon,
282
+ onSortChange = _a.onSortChange;
343
283
  var rowSelection = _this.state.rowSelection;
344
284
  return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement(HeaderRow, {
345
285
  prefixCls: cls,
@@ -351,19 +291,18 @@ function (_super) {
351
291
  rowSelection: rowSelection
352
292
  }));
353
293
  };
354
-
355
294
  _this.renderBody = function () {
356
295
  var cls = _this.prefixCls;
357
296
  var getRowKey = _this.getRowKey;
358
297
  var _a = _this.props,
359
- columns = _a.columns,
360
- dataSource = _a.dataSource,
361
- expandable = _a.expandable,
362
- onRowClick = _a.onRowClick,
363
- rowClassName = _a.rowClassName;
298
+ columns = _a.columns,
299
+ dataSource = _a.dataSource,
300
+ expandable = _a.expandable,
301
+ onRowClick = _a.onRowClick,
302
+ rowClassName = _a.rowClassName;
364
303
  var _b = _this.state,
365
- rowSelection = _b.rowSelection,
366
- selectedRowKeys = _b.selectedRowKeys;
304
+ rowSelection = _b.rowSelection,
305
+ selectedRowKeys = _b.selectedRowKeys;
367
306
  return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement(Body, {
368
307
  prefixCls: cls,
369
308
  getRowKey: getRowKey,
@@ -376,9 +315,8 @@ function (_super) {
376
315
  getRowClassName: rowClassName
377
316
  }));
378
317
  };
379
-
380
318
  var rowSelection = props.rowSelection,
381
- rowKey = props.rowKey;
319
+ rowKey = props.rowKey;
382
320
  _this.getRowKey = typeof rowKey === 'string' ? function (data) {
383
321
  return data[rowKey];
384
322
  } : rowKey;
@@ -390,30 +328,25 @@ function (_super) {
390
328
  };
391
329
  return _this;
392
330
  }
393
-
394
331
  Table.prototype.componentDidMount = function () {
395
332
  this.addListener();
396
333
  };
397
-
398
334
  Table.prototype.componentWillUnmount = function () {
399
335
  if (this.scrollHandler) {
400
336
  this.scrollHandler.remove();
401
337
  this.scrollHandler = null;
402
338
  }
403
-
404
339
  if (this.resizeObserver && this.bodyRef.current) {
405
340
  this.resizeObserver.unobserve(this.bodyRef.current);
406
341
  }
407
342
  };
408
-
409
343
  Table.prototype.render = function () {
410
344
  var cls = this.prefixCls;
411
345
  var _a = this.props,
412
- className = _a.className,
413
- fixedHeader = _a.fixedHeader,
414
- maxHeight = _a.maxHeight,
415
- loading = _a.loading;
416
-
346
+ className = _a.className,
347
+ fixedHeader = _a.fixedHeader,
348
+ maxHeight = _a.maxHeight,
349
+ loading = _a.loading;
417
350
  if (fixedHeader) {
418
351
  return /*#__PURE__*/React.createElement(LoadingContainer, {
419
352
  loading: loading,
@@ -433,7 +366,6 @@ function (_super) {
433
366
  className: "".concat(cls, "-table")
434
367
  }, this.renderColgroup(), this.renderBody())));
435
368
  }
436
-
437
369
  return /*#__PURE__*/React.createElement(LoadingContainer, {
438
370
  loading: loading,
439
371
  className: classNames(className, cls)
@@ -441,7 +373,6 @@ function (_super) {
441
373
  className: "".concat(cls, "-table")
442
374
  }, this.renderColgroup(), this.renderHeader(), this.renderBody()));
443
375
  };
444
-
445
376
  Table.defaultProps = {
446
377
  fixedHeader: false,
447
378
  loading: false,
@@ -452,5 +383,4 @@ function (_super) {
452
383
  };
453
384
  return Table;
454
385
  }(React.Component);
455
-
456
386
  export default Table;