@plesk/ui-library 3.36.0 → 3.37.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.
- package/cjs/components/Card/helpers.js +0 -1
- package/cjs/components/Carousel/Carousel.js +182 -77
- package/cjs/components/ComboBox/ComboBoxOption.js +2 -1
- package/cjs/components/Drawer/DrawerProgress.js +1 -1
- package/cjs/components/List/List.js +102 -314
- package/cjs/components/List/ListAction.js +0 -1
- package/cjs/components/Panel/Panel.js +61 -98
- package/cjs/components/Select/SelectControl.js +4 -0
- package/cjs/components/Select/SelectOption.js +2 -1
- package/cjs/components/Toaster/Toaster.js +3 -3
- package/cjs/components/Toolbar/ToolbarMenu.js +0 -1
- package/cjs/components/index.js +42 -22
- package/cjs/index.js +1 -1
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +574 -678
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +10 -10
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Card/helpers.js +0 -1
- package/esm/components/Carousel/Carousel.js +183 -78
- package/esm/components/ComboBox/ComboBoxOption.js +2 -1
- package/esm/components/Drawer/DrawerProgress.js +1 -1
- package/esm/components/List/List.js +102 -314
- package/esm/components/List/ListAction.js +0 -1
- package/esm/components/Panel/Panel.js +62 -99
- package/esm/components/Select/SelectControl.js +4 -0
- package/esm/components/Select/SelectOption.js +2 -1
- package/esm/components/Toaster/Toaster.js +3 -3
- package/esm/components/Toolbar/ToolbarMenu.js +0 -1
- package/esm/components/index.js +2 -4
- package/esm/index.js +1 -1
- package/package.json +41 -41
- package/styleguide/build/bundle.c3d05006.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/Action/Action.d.ts +1 -1
- package/types/src/components/Action/index.d.ts +1 -0
- package/types/src/components/Alert/Alert.d.ts +1 -1
- package/types/src/components/Alert/index.d.ts +1 -0
- package/types/src/components/AutoClosable/AutoClosable.d.ts +1 -1
- package/types/src/components/AutoClosable/index.d.ts +1 -0
- package/types/src/components/AuxiliaryActions/AuxiliaryActions.d.ts +1 -1
- package/types/src/components/AuxiliaryActions/index.d.ts +1 -0
- package/types/src/components/Badge/Badge.d.ts +1 -1
- package/types/src/components/Badge/index.d.ts +1 -0
- package/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/types/src/components/Breadcrumbs/index.d.ts +1 -0
- package/types/src/components/Button/ButtonContext.d.ts +1 -0
- package/types/src/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/types/src/components/ButtonGroup/index.d.ts +1 -0
- package/types/src/components/Carousel/Carousel.d.ts +43 -8
- package/types/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/types/src/components/Checkbox/index.d.ts +1 -0
- package/types/src/components/ComboBox/ComboBox.d.ts +1 -1
- package/types/src/components/ComboBox/ComboBoxOption.d.ts +1 -1
- package/types/src/components/ComboBox/index.d.ts +2 -0
- package/types/src/components/ConsoleOutput/ConsoleOutput.d.ts +1 -1
- package/types/src/components/ConsoleOutput/index.d.ts +1 -0
- package/types/src/components/ContentLoader/ContentLoader.d.ts +1 -1
- package/types/src/components/ContentLoader/index.d.ts +1 -0
- package/types/src/components/Cuttable/Cuttable.d.ts +1 -1
- package/types/src/components/Cuttable/index.d.ts +1 -0
- package/types/src/components/DistractionFreeModeContext/DistractionFreeModeContext.d.ts +1 -0
- package/types/src/components/Drawer/DrawerProgress.d.ts +1 -1
- package/types/src/components/Form/DisabledContext.d.ts +1 -0
- package/types/src/components/Form/FormContext.d.ts +1 -0
- package/types/src/components/Form/ScrollableElementFormContext.d.ts +1 -0
- package/types/src/components/List/List.d.ts +637 -0
- package/types/src/components/List/ListAction.d.ts +21 -18
- package/types/src/components/List/ListActionsDivider.d.ts +1 -1
- package/types/src/components/List/ListEmptyView.d.ts +1 -1
- package/types/src/components/List/index.d.ts +12 -0
- package/types/src/components/OnDarkContext/OnDarkContext.d.ts +1 -0
- package/types/src/components/Pagination/Pagination.d.ts +1 -1
- package/types/src/components/Pagination/index.d.ts +1 -0
- package/types/src/components/Panel/Panel.d.ts +4 -21
- package/types/src/components/Panel/index.d.ts +1 -0
- package/types/src/components/Radio/Radio.d.ts +4 -6
- package/types/src/components/Radio/index.d.ts +1 -0
- package/types/src/components/ResponsiveContext/ResponsiveContext.d.ts +1 -0
- package/types/src/components/Section/Section.d.ts +1 -1
- package/types/src/components/Toolbar/RegistryContext.d.ts +1 -0
- package/types/src/components/Translate/Translate.d.ts +4 -3
- package/types/src/components/Translate/index.d.ts +1 -1
- package/types/src/components/VerticalContext/VerticalContext.d.ts +1 -0
- package/types/src/components/index.d.ts +17 -4
- package/styleguide/build/bundle.2c956ff2.js +0 -2
- /package/styleguide/build/{bundle.2c956ff2.js.LICENSE.txt → bundle.c3d05006.js.LICENSE.txt} +0 -0
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react =
|
|
9
|
+
var _react = require("react");
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
var _reactTransitionGroup = require("react-transition-group");
|
|
@@ -29,7 +29,8 @@ var _useFocusVisible = require("use-focus-visible");
|
|
|
29
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
30
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
31
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
32
|
-
|
|
32
|
+
// eslint-disable-next-line func-style
|
|
33
|
+
function getRowKey(row, props) {
|
|
33
34
|
const {
|
|
34
35
|
rowKey
|
|
35
36
|
} = props;
|
|
@@ -37,7 +38,7 @@ const getRowKey = (row, props) => {
|
|
|
37
38
|
return rowKey(row);
|
|
38
39
|
}
|
|
39
40
|
return row[rowKey];
|
|
40
|
-
}
|
|
41
|
+
}
|
|
41
42
|
const Tbody = _ref => {
|
|
42
43
|
let {
|
|
43
44
|
baseClassName,
|
|
@@ -137,7 +138,6 @@ const getHumanTotalRows = _ref2 => {
|
|
|
137
138
|
return null;
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
|
-
|
|
141
141
|
/**
|
|
142
142
|
* `List` component is used for displaying a collection of tabular data.
|
|
143
143
|
* [More details about designing of lists.](#!/Sets%20of%20Objects)
|
|
@@ -149,26 +149,32 @@ class List extends _react.Component {
|
|
|
149
149
|
(0, _defineProperty2.default)(this, "state", {
|
|
150
150
|
sortInPlace: !this.props.pagination,
|
|
151
151
|
vertical: false,
|
|
152
|
-
expandedRows: this.props.expandedRows,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
expandedRows: this.props.expandedRows ?? [],
|
|
153
|
+
ReorderableList: undefined,
|
|
154
|
+
reorderableItemWidths: [],
|
|
155
|
+
prevExpandedRows: this.props.expandedRows ?? [],
|
|
156
|
+
sortColumn: undefined,
|
|
157
|
+
prevSortColumn: undefined,
|
|
158
|
+
sortDirection: undefined,
|
|
159
|
+
prevSortDirection: undefined,
|
|
160
|
+
selection: this.props.selection ?? [],
|
|
161
|
+
prevSelection: this.props.selection ?? [],
|
|
162
|
+
prevData: [],
|
|
163
|
+
prevPagination: undefined
|
|
158
164
|
});
|
|
165
|
+
(0, _defineProperty2.default)(this, "needScroll", false);
|
|
159
166
|
(0, _defineProperty2.default)(this, "anchorRef", /*#__PURE__*/(0, _react.createRef)());
|
|
160
|
-
(0, _defineProperty2.default)(this, "flatData", data => data.reduce((acc,
|
|
161
|
-
|
|
162
|
-
data
|
|
163
|
-
|
|
164
|
-
} = _ref3;
|
|
167
|
+
(0, _defineProperty2.default)(this, "flatData", data => data.reduce((acc, item) => {
|
|
168
|
+
const {
|
|
169
|
+
data
|
|
170
|
+
} = item;
|
|
165
171
|
const {
|
|
166
172
|
virtual
|
|
167
|
-
} = this.getRowProps(
|
|
173
|
+
} = this.getRowProps(item);
|
|
168
174
|
if (virtual) {
|
|
169
175
|
return [...acc, ...(data ? this.flatData(data) : [])];
|
|
170
176
|
}
|
|
171
|
-
return [...acc,
|
|
177
|
+
return [...acc, item, ...(data ? this.flatData(data) : [])];
|
|
172
178
|
}, []));
|
|
173
179
|
(0, _defineProperty2.default)(this, "handleRowSelectionChange", (checked, rowKey) => {
|
|
174
180
|
const {
|
|
@@ -186,13 +192,14 @@ class List extends _react.Component {
|
|
|
186
192
|
});
|
|
187
193
|
(0, _defineProperty2.default)(this, "handleGlobalSelectionChange", headerChecked => {
|
|
188
194
|
const {
|
|
189
|
-
onAllRowsSelectedChange
|
|
195
|
+
onAllRowsSelectedChange,
|
|
196
|
+
data
|
|
190
197
|
} = this.props;
|
|
191
198
|
const {
|
|
192
199
|
selection
|
|
193
200
|
} = this.state;
|
|
194
201
|
const nextSelection = [];
|
|
195
|
-
this.flatData(
|
|
202
|
+
this.flatData(data ?? []).forEach(row => {
|
|
196
203
|
const key = getRowKey(row, this.props);
|
|
197
204
|
if (row.disabled || this.isRowLoading(row)) {
|
|
198
205
|
if (selection.indexOf(key) !== -1) {
|
|
@@ -209,15 +216,17 @@ class List extends _react.Component {
|
|
|
209
216
|
}
|
|
210
217
|
this.setSelection(nextSelection);
|
|
211
218
|
});
|
|
212
|
-
(0, _defineProperty2.default)(this, "handleResize",
|
|
219
|
+
(0, _defineProperty2.default)(this, "handleResize", _ref3 => {
|
|
213
220
|
let {
|
|
214
221
|
bounds
|
|
215
|
-
} =
|
|
216
|
-
this.
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
} = _ref3;
|
|
223
|
+
if (bounds && this.props.vertical) {
|
|
224
|
+
this.setState({
|
|
225
|
+
vertical: typeof this.props.vertical === 'boolean' ? this.props.vertical : bounds.width < this.props.vertical
|
|
226
|
+
});
|
|
227
|
+
}
|
|
219
228
|
});
|
|
220
|
-
(0, _defineProperty2.default)(this, "isRowLoading", row => this.props.loadingRows
|
|
229
|
+
(0, _defineProperty2.default)(this, "isRowLoading", row => this.props.loadingRows?.indexOf(getRowKey(row, this.props)) !== -1);
|
|
221
230
|
(0, _defineProperty2.default)(this, "getRowTitle", row => {
|
|
222
231
|
const {
|
|
223
232
|
columns
|
|
@@ -264,7 +273,7 @@ class List extends _react.Component {
|
|
|
264
273
|
} = this.state;
|
|
265
274
|
const headerExpanded = this.isAnyRowsExpanded(data, expandedRows);
|
|
266
275
|
const nextExpandedRows = [];
|
|
267
|
-
this.flatData(
|
|
276
|
+
this.flatData(data ?? []).forEach(row => {
|
|
268
277
|
const key = getRowKey(row, this.props);
|
|
269
278
|
if (!this.isRowExpandable(row)) {
|
|
270
279
|
if (expandedRows.indexOf(key) !== -1) {
|
|
@@ -287,7 +296,7 @@ class List extends _react.Component {
|
|
|
287
296
|
}
|
|
288
297
|
});
|
|
289
298
|
}
|
|
290
|
-
static getDerivedStateFromProps(
|
|
299
|
+
static getDerivedStateFromProps(_ref4, _ref5) {
|
|
291
300
|
let {
|
|
292
301
|
sortColumn,
|
|
293
302
|
sortDirection,
|
|
@@ -301,7 +310,7 @@ class List extends _react.Component {
|
|
|
301
310
|
rowKey,
|
|
302
311
|
totalRows,
|
|
303
312
|
filtered
|
|
304
|
-
} =
|
|
313
|
+
} = _ref4;
|
|
305
314
|
let {
|
|
306
315
|
prevSortColumn,
|
|
307
316
|
prevSortDirection,
|
|
@@ -310,7 +319,7 @@ class List extends _react.Component {
|
|
|
310
319
|
prevPagination,
|
|
311
320
|
prevExpandedRows,
|
|
312
321
|
...state
|
|
313
|
-
} =
|
|
322
|
+
} = _ref5;
|
|
314
323
|
let nextState = {};
|
|
315
324
|
if (prevSortColumn !== sortColumn || prevSortDirection !== sortDirection) {
|
|
316
325
|
nextState = {
|
|
@@ -321,18 +330,18 @@ class List extends _react.Component {
|
|
|
321
330
|
}
|
|
322
331
|
const additionalExpanded = [];
|
|
323
332
|
if (prevData !== data) {
|
|
324
|
-
const isSingleElementInCurrentExpanded = () => state.expandedRows.includes(getRowKey(data[0], {
|
|
333
|
+
const isSingleElementInCurrentExpanded = () => data && state.expandedRows.includes(getRowKey(data[0], {
|
|
325
334
|
rowKey
|
|
326
335
|
}));
|
|
327
336
|
if (renderRowBody && data?.length === 1 && (!pagination || totalRows === 1) && (!prevData || prevData?.length === 0 || isSingleElementInCurrentExpanded()) && (!filtered || isSingleElementInCurrentExpanded())) {
|
|
328
337
|
const key = getRowKey(data[0], {
|
|
329
338
|
rowKey
|
|
330
339
|
});
|
|
331
|
-
if (notExpandableRows
|
|
340
|
+
if (notExpandableRows?.indexOf(key) === -1) {
|
|
332
341
|
additionalExpanded.push(key);
|
|
333
342
|
}
|
|
334
343
|
}
|
|
335
|
-
const keys = data.map(row => getRowKey(row, {
|
|
344
|
+
const keys = (data ?? []).map(row => getRowKey(row, {
|
|
336
345
|
rowKey
|
|
337
346
|
}));
|
|
338
347
|
const nextSelection = state.selection.filter(key => keys.indexOf(key) !== -1);
|
|
@@ -344,13 +353,13 @@ class List extends _react.Component {
|
|
|
344
353
|
if (prevSelection !== selection) {
|
|
345
354
|
nextState = {
|
|
346
355
|
...nextState,
|
|
347
|
-
selection
|
|
356
|
+
selection: selection ?? []
|
|
348
357
|
};
|
|
349
358
|
}
|
|
350
359
|
if (prevExpandedRows !== expandedRows || additionalExpanded.length) {
|
|
351
360
|
nextState = {
|
|
352
361
|
...nextState,
|
|
353
|
-
expandedRows: [...expandedRows, ...additionalExpanded]
|
|
362
|
+
expandedRows: [...(expandedRows ?? []), ...additionalExpanded]
|
|
354
363
|
};
|
|
355
364
|
}
|
|
356
365
|
if (prevPagination !== pagination) {
|
|
@@ -393,10 +402,11 @@ class List extends _react.Component {
|
|
|
393
402
|
}
|
|
394
403
|
}
|
|
395
404
|
applyReorderableList() {
|
|
396
|
-
Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "react-movable" */'@plesk/react-movable'))).then(
|
|
405
|
+
Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "react-movable" */'@plesk/react-movable'))).then(_ref6 => {
|
|
397
406
|
let {
|
|
398
407
|
List: ReorderableList
|
|
399
|
-
} =
|
|
408
|
+
} = _ref6;
|
|
409
|
+
// @ts-expect-error
|
|
400
410
|
this.setState({
|
|
401
411
|
ReorderableList
|
|
402
412
|
});
|
|
@@ -412,13 +422,16 @@ class List extends _react.Component {
|
|
|
412
422
|
data,
|
|
413
423
|
columns
|
|
414
424
|
} = this.props;
|
|
425
|
+
if (!data) {
|
|
426
|
+
return [];
|
|
427
|
+
}
|
|
415
428
|
if (!sortInPlace) {
|
|
416
429
|
return data;
|
|
417
430
|
}
|
|
418
|
-
const [column] = columns.filter(
|
|
431
|
+
const [column] = columns.filter(_ref7 => {
|
|
419
432
|
let {
|
|
420
433
|
key
|
|
421
|
-
} =
|
|
434
|
+
} = _ref7;
|
|
422
435
|
return key === sortColumn;
|
|
423
436
|
});
|
|
424
437
|
const defaultSort = (a, b) => {
|
|
@@ -430,7 +443,7 @@ class List extends _react.Component {
|
|
|
430
443
|
}
|
|
431
444
|
return 0;
|
|
432
445
|
};
|
|
433
|
-
if (!column) {
|
|
446
|
+
if (!column || !sortColumn) {
|
|
434
447
|
return data;
|
|
435
448
|
}
|
|
436
449
|
return data.sort((a, b) => (column.sort ? column.sort(a, b) : defaultSort(a[sortColumn], b[sortColumn])) * (sortDirection === 'ASC' ? 1 : -1));
|
|
@@ -439,22 +452,22 @@ class List extends _react.Component {
|
|
|
439
452
|
const {
|
|
440
453
|
sortInPlace
|
|
441
454
|
} = this.state;
|
|
442
|
-
|
|
455
|
+
const {
|
|
443
456
|
sortColumn,
|
|
444
457
|
sortDirection
|
|
445
458
|
} = this.state;
|
|
446
|
-
|
|
447
|
-
|
|
459
|
+
const nextSortDirection = sortColumn === columnKey && sortDirection === 'ASC' ? 'DESC' : 'ASC';
|
|
460
|
+
const nextSortColumn = columnKey;
|
|
448
461
|
if (sortInPlace) {
|
|
449
462
|
this.setState({
|
|
450
|
-
sortColumn,
|
|
451
|
-
sortDirection
|
|
463
|
+
sortColumn: nextSortColumn,
|
|
464
|
+
sortDirection: nextSortDirection
|
|
452
465
|
});
|
|
453
466
|
}
|
|
454
467
|
if (this.props.onSortChange) {
|
|
455
468
|
this.props.onSortChange({
|
|
456
|
-
sortColumn,
|
|
457
|
-
sortDirection
|
|
469
|
+
sortColumn: nextSortColumn,
|
|
470
|
+
sortDirection: nextSortDirection
|
|
458
471
|
});
|
|
459
472
|
}
|
|
460
473
|
}
|
|
@@ -479,7 +492,7 @@ class List extends _react.Component {
|
|
|
479
492
|
if (virtual) {
|
|
480
493
|
return false;
|
|
481
494
|
}
|
|
482
|
-
return this.props.notExpandableRows
|
|
495
|
+
return this.props.notExpandableRows?.indexOf(getRowKey(row, this.props)) === -1;
|
|
483
496
|
}
|
|
484
497
|
handleRowExpandingChange(row) {
|
|
485
498
|
let expandedRows;
|
|
@@ -498,7 +511,7 @@ class List extends _react.Component {
|
|
|
498
511
|
});
|
|
499
512
|
(0, _utils.safeInvoke)(this.props.onExpandedRowsChange, expandedRows.slice());
|
|
500
513
|
}
|
|
501
|
-
renderRow(
|
|
514
|
+
renderRow(_ref8) {
|
|
502
515
|
let {
|
|
503
516
|
row,
|
|
504
517
|
index,
|
|
@@ -507,7 +520,7 @@ class List extends _react.Component {
|
|
|
507
520
|
parent,
|
|
508
521
|
isDragged,
|
|
509
522
|
reorderableProps
|
|
510
|
-
} =
|
|
523
|
+
} = _ref8;
|
|
511
524
|
const {
|
|
512
525
|
baseClassName,
|
|
513
526
|
renderRowBody,
|
|
@@ -517,10 +530,10 @@ class List extends _react.Component {
|
|
|
517
530
|
vertical,
|
|
518
531
|
reorderableItemWidths
|
|
519
532
|
} = this.state;
|
|
520
|
-
const hasActions = realColumn.some(
|
|
533
|
+
const hasActions = realColumn.some(_ref9 => {
|
|
521
534
|
let {
|
|
522
535
|
type
|
|
523
|
-
} =
|
|
536
|
+
} = _ref9;
|
|
524
537
|
return type === 'actions';
|
|
525
538
|
});
|
|
526
539
|
const {
|
|
@@ -546,7 +559,7 @@ class List extends _react.Component {
|
|
|
546
559
|
}, className),
|
|
547
560
|
...rowProps,
|
|
548
561
|
onClick: renderRowBody ? this.createRowClickHandler(row) : undefined,
|
|
549
|
-
children: realColumn.map((
|
|
562
|
+
children: realColumn.map((_ref10, index) => {
|
|
550
563
|
let {
|
|
551
564
|
key,
|
|
552
565
|
title,
|
|
@@ -555,7 +568,7 @@ class List extends _react.Component {
|
|
|
555
568
|
cellProps,
|
|
556
569
|
truncate,
|
|
557
570
|
type
|
|
558
|
-
} =
|
|
571
|
+
} = _ref10;
|
|
559
572
|
if (skipCells > 0) {
|
|
560
573
|
skipCells -= 1;
|
|
561
574
|
return null;
|
|
@@ -566,7 +579,7 @@ class List extends _react.Component {
|
|
|
566
579
|
width
|
|
567
580
|
};
|
|
568
581
|
}
|
|
569
|
-
if (isDragged) {
|
|
582
|
+
if (isDragged && reorderableItemWidths) {
|
|
570
583
|
style = {
|
|
571
584
|
width: reorderableItemWidths[index]
|
|
572
585
|
};
|
|
@@ -663,13 +676,13 @@ class List extends _react.Component {
|
|
|
663
676
|
}
|
|
664
677
|
return element;
|
|
665
678
|
}
|
|
666
|
-
renderRowBody(
|
|
679
|
+
renderRowBody(_ref11) {
|
|
667
680
|
let {
|
|
668
681
|
row,
|
|
669
682
|
index,
|
|
670
683
|
realColumn,
|
|
671
684
|
parent
|
|
672
|
-
} =
|
|
685
|
+
} = _ref11;
|
|
673
686
|
const {
|
|
674
687
|
baseClassName,
|
|
675
688
|
renderRowBody
|
|
@@ -680,16 +693,16 @@ class List extends _react.Component {
|
|
|
680
693
|
if (!renderRowBody) {
|
|
681
694
|
return null;
|
|
682
695
|
}
|
|
683
|
-
const reorderable = realColumn.find(
|
|
696
|
+
const reorderable = realColumn.find(_ref12 => {
|
|
684
697
|
let {
|
|
685
698
|
key
|
|
686
|
-
} =
|
|
699
|
+
} = _ref12;
|
|
687
700
|
return key === 'reorderable';
|
|
688
701
|
});
|
|
689
|
-
const expander = realColumn.find(
|
|
702
|
+
const expander = realColumn.find(_ref13 => {
|
|
690
703
|
let {
|
|
691
704
|
key
|
|
692
|
-
} =
|
|
705
|
+
} = _ref13;
|
|
693
706
|
return key === 'expander';
|
|
694
707
|
});
|
|
695
708
|
const isRowExpanded = this.isRowExpanded(row);
|
|
@@ -834,7 +847,7 @@ class List extends _react.Component {
|
|
|
834
847
|
itemsPerPageOptions = _Pagination.ITEMS_PER_PAGE_OPTIONS
|
|
835
848
|
} = pagination.props;
|
|
836
849
|
if (Array.isArray(itemsPerPageOptions)) {
|
|
837
|
-
const numericOptions = itemsPerPageOptions.filter(
|
|
850
|
+
const numericOptions = itemsPerPageOptions.filter(Number);
|
|
838
851
|
if (numericOptions.length) {
|
|
839
852
|
const min = Math.min(...numericOptions);
|
|
840
853
|
if (totalRows <= min) {
|
|
@@ -897,6 +910,9 @@ class List extends _react.Component {
|
|
|
897
910
|
pagination,
|
|
898
911
|
loading
|
|
899
912
|
} = this.props;
|
|
913
|
+
if (!pagination) {
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
900
916
|
const paginationProps = {
|
|
901
917
|
loading
|
|
902
918
|
};
|
|
@@ -959,7 +975,7 @@ class List extends _react.Component {
|
|
|
959
975
|
const {
|
|
960
976
|
vertical
|
|
961
977
|
} = this.state;
|
|
962
|
-
if (
|
|
978
|
+
if (!(data && data.length > 0) && !filtered && emptyViewMode === 'all') {
|
|
963
979
|
return this.renderEmptyView();
|
|
964
980
|
}
|
|
965
981
|
const realColumn = columns.map((column, i) => {
|
|
@@ -1111,14 +1127,14 @@ class List extends _react.Component {
|
|
|
1111
1127
|
}
|
|
1112
1128
|
const hasTitle = !vertical && columns.some(column => column.title);
|
|
1113
1129
|
let content;
|
|
1114
|
-
if (
|
|
1130
|
+
if (!(data && data.length > 0) && (filtered || emptyViewMode === 'items')) {
|
|
1115
1131
|
content = this.renderEmptyView();
|
|
1116
1132
|
} else {
|
|
1117
|
-
const renderList =
|
|
1133
|
+
const renderList = _ref14 => {
|
|
1118
1134
|
let {
|
|
1119
1135
|
children,
|
|
1120
1136
|
props: reorderableProps
|
|
1121
|
-
} =
|
|
1137
|
+
} = _ref14;
|
|
1122
1138
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useFocusVisible.FocusVisibleManager, {
|
|
1123
1139
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("table", {
|
|
1124
1140
|
className: (0, _classnames.default)(`${baseClassName}__table`, {
|
|
@@ -1132,7 +1148,7 @@ class List extends _react.Component {
|
|
|
1132
1148
|
className: (0, _classnames.default)(`${baseClassName}__table-thead`, {
|
|
1133
1149
|
[`${baseClassName}__row--expanded`]: this.isAnyRowsExpanded(data, this.state.expandedRows)
|
|
1134
1150
|
}),
|
|
1135
|
-
children: realColumn.map(
|
|
1151
|
+
children: realColumn.map(_ref15 => {
|
|
1136
1152
|
let {
|
|
1137
1153
|
key,
|
|
1138
1154
|
title,
|
|
@@ -1144,7 +1160,7 @@ class List extends _react.Component {
|
|
|
1144
1160
|
type,
|
|
1145
1161
|
cellProps,
|
|
1146
1162
|
...headerProps
|
|
1147
|
-
} =
|
|
1163
|
+
} = _ref15;
|
|
1148
1164
|
if (sortable) {
|
|
1149
1165
|
title = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
1150
1166
|
className: "th__action",
|
|
@@ -1175,7 +1191,7 @@ class List extends _react.Component {
|
|
|
1175
1191
|
})
|
|
1176
1192
|
});
|
|
1177
1193
|
};
|
|
1178
|
-
const renderItem =
|
|
1194
|
+
const renderItem = _ref16 => {
|
|
1179
1195
|
let {
|
|
1180
1196
|
value: {
|
|
1181
1197
|
row
|
|
@@ -1183,7 +1199,7 @@ class List extends _react.Component {
|
|
|
1183
1199
|
index,
|
|
1184
1200
|
props: reorderableProps,
|
|
1185
1201
|
isDragged
|
|
1186
|
-
} =
|
|
1202
|
+
} = _ref16;
|
|
1187
1203
|
return this.renderRow({
|
|
1188
1204
|
row,
|
|
1189
1205
|
index,
|
|
@@ -1193,27 +1209,27 @@ class List extends _react.Component {
|
|
|
1193
1209
|
isDragged
|
|
1194
1210
|
});
|
|
1195
1211
|
};
|
|
1196
|
-
if (reorderable) {
|
|
1212
|
+
if (reorderable && this.state.ReorderableList) {
|
|
1197
1213
|
const {
|
|
1198
1214
|
ReorderableList
|
|
1199
1215
|
} = this.state;
|
|
1200
1216
|
content = /*#__PURE__*/(0, _jsxRuntime.jsx)(ReorderableList, {
|
|
1201
|
-
beforeDrag:
|
|
1217
|
+
beforeDrag: _ref17 => {
|
|
1202
1218
|
let {
|
|
1203
1219
|
elements,
|
|
1204
1220
|
index
|
|
1205
|
-
} =
|
|
1221
|
+
} = _ref17;
|
|
1206
1222
|
const cells = Array.from(elements[index].firstElementChild.children);
|
|
1207
1223
|
const reorderableItemWidths = cells.map(cell => window.getComputedStyle(cell).width);
|
|
1208
1224
|
this.setState({
|
|
1209
1225
|
reorderableItemWidths
|
|
1210
1226
|
});
|
|
1211
1227
|
},
|
|
1212
|
-
onChange:
|
|
1228
|
+
onChange: _ref18 => {
|
|
1213
1229
|
let {
|
|
1214
1230
|
oldIndex,
|
|
1215
1231
|
newIndex
|
|
1216
|
-
} =
|
|
1232
|
+
} = _ref18;
|
|
1217
1233
|
(0, _utils.safeInvoke)(onReorderEnd, {
|
|
1218
1234
|
oldIndex,
|
|
1219
1235
|
newIndex
|
|
@@ -1226,9 +1242,11 @@ class List extends _react.Component {
|
|
|
1226
1242
|
renderItem: renderItem,
|
|
1227
1243
|
lockVertically: true,
|
|
1228
1244
|
hooks: {
|
|
1229
|
-
getChildren: children =>
|
|
1245
|
+
getChildren: children =>
|
|
1246
|
+
// @ts-expect-error
|
|
1247
|
+
children.filter(node => node.nodeName !== 'THEAD')
|
|
1230
1248
|
},
|
|
1231
|
-
useDragHandle:
|
|
1249
|
+
useDragHandle: false
|
|
1232
1250
|
});
|
|
1233
1251
|
} else {
|
|
1234
1252
|
content = renderList({
|
|
@@ -1278,10 +1296,10 @@ class List extends _react.Component {
|
|
|
1278
1296
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMeasure.default, {
|
|
1279
1297
|
bounds: true,
|
|
1280
1298
|
onResize: this.handleResize,
|
|
1281
|
-
children:
|
|
1299
|
+
children: _ref19 => {
|
|
1282
1300
|
let {
|
|
1283
1301
|
measureRef
|
|
1284
|
-
} =
|
|
1302
|
+
} = _ref19;
|
|
1285
1303
|
return createRoot(measureRef);
|
|
1286
1304
|
}
|
|
1287
1305
|
});
|
|
@@ -1289,242 +1307,12 @@ class List extends _react.Component {
|
|
|
1289
1307
|
return createRoot();
|
|
1290
1308
|
}
|
|
1291
1309
|
}
|
|
1292
|
-
List
|
|
1293
|
-
/**
|
|
1294
|
-
* Columns definition.
|
|
1295
|
-
*
|
|
1296
|
-
* In addition to the properties described below, you can use any native properties
|
|
1297
|
-
* supported by the `TH` element like `className`, `style`, etc.
|
|
1298
|
-
* @since 0.0.42
|
|
1299
|
-
*/
|
|
1300
|
-
columns: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
1301
|
-
/**
|
|
1302
|
-
* Unique column key.
|
|
1303
|
-
*/
|
|
1304
|
-
key: _propTypes.default.string.isRequired,
|
|
1305
|
-
/**
|
|
1306
|
-
* Column title.
|
|
1307
|
-
*/
|
|
1308
|
-
title: _propTypes.default.node,
|
|
1309
|
-
/**
|
|
1310
|
-
* Optional cell renderer function: `row => Component`. By default render value of cell.
|
|
1311
|
-
* The renderer function can also returns a configuration object like: `{children: 'cell content', colSpan: 3}`
|
|
1312
|
-
*/
|
|
1313
|
-
render: _propTypes.default.func,
|
|
1314
|
-
/**
|
|
1315
|
-
* Is column sortable.
|
|
1316
|
-
* Default is `false`
|
|
1317
|
-
*/
|
|
1318
|
-
sortable: _propTypes.default.bool,
|
|
1319
|
-
/**
|
|
1320
|
-
* Optional function for row comparison: `(row1, row2) => -1 | 0 | 1`
|
|
1321
|
-
*/
|
|
1322
|
-
sort: _propTypes.default.func,
|
|
1323
|
-
/**
|
|
1324
|
-
* Column alignment.
|
|
1325
|
-
*/
|
|
1326
|
-
align: _propTypes.default.oneOf(['left', 'center', 'right']),
|
|
1327
|
-
/**
|
|
1328
|
-
* Truncate the text in cell with an ellipsis.
|
|
1329
|
-
*/
|
|
1330
|
-
truncate: _propTypes.default.bool,
|
|
1331
|
-
/**
|
|
1332
|
-
* Determine type of column content.
|
|
1333
|
-
*
|
|
1334
|
-
* * title - There should a title of the row.
|
|
1335
|
-
* * controls - There should be some control: a button or a dropdown.
|
|
1336
|
-
* * actions - There should be the ListAction component.
|
|
1337
|
-
*/
|
|
1338
|
-
type: _propTypes.default.oneOf(['title', 'controls', 'actions'])
|
|
1339
|
-
})).isRequired,
|
|
1340
|
-
/**
|
|
1341
|
-
* Array of row objects.
|
|
1342
|
-
*
|
|
1343
|
-
* Each row must contains `key` property, all columns keys, and can contain `disabled` property.
|
|
1344
|
-
* @since 0.0.42
|
|
1345
|
-
*/
|
|
1346
|
-
data: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
1347
|
-
/**
|
|
1348
|
-
* Unique column key. This property can by renamed using `rowKey` property of List.
|
|
1349
|
-
*/
|
|
1350
|
-
key: _propTypes.default.string,
|
|
1351
|
-
/**
|
|
1352
|
-
* Optional property for disabling ability to select this row.
|
|
1353
|
-
*/
|
|
1354
|
-
disabled: _propTypes.default.bool,
|
|
1355
|
-
/**
|
|
1356
|
-
* Optional array of children rows.
|
|
1357
|
-
*/
|
|
1358
|
-
data: _propTypes.default.array,
|
|
1359
|
-
/**
|
|
1360
|
-
* An optional property to change the appearance of this row.<br />
|
|
1361
|
-
* `inactive, info, success, warning, danger`. (Since: 3.33.0)
|
|
1362
|
-
*/
|
|
1363
|
-
intent: _propTypes.default.oneOf(['inactive', 'info', 'success', 'warning', 'danger'])
|
|
1364
|
-
})),
|
|
1365
|
-
/**
|
|
1366
|
-
* Current sort column key
|
|
1367
|
-
* @since 0.0.42
|
|
1368
|
-
*/
|
|
1369
|
-
sortColumn: _propTypes.default.string,
|
|
1370
|
-
/**
|
|
1371
|
-
* Sort direction of the column being sorted.
|
|
1372
|
-
* @since 0.0.42
|
|
1373
|
-
*/
|
|
1374
|
-
sortDirection: _propTypes.default.oneOf(['ASC', 'DESC']),
|
|
1375
|
-
/**
|
|
1376
|
-
* Sort change handler
|
|
1377
|
-
* @since 0.0.42
|
|
1378
|
-
*/
|
|
1379
|
-
onSortChange: _propTypes.default.func,
|
|
1380
|
-
/**
|
|
1381
|
-
* Array of keys of selected rows
|
|
1382
|
-
* @since 0.0.42
|
|
1383
|
-
*/
|
|
1384
|
-
selection: _propTypes.default.array,
|
|
1385
|
-
/**
|
|
1386
|
-
* Selection change handler for list. Checkboxes will only be rendered if this prop is defined.
|
|
1387
|
-
* @since 0.0.42
|
|
1388
|
-
*/
|
|
1389
|
-
onSelectionChange: _propTypes.default.func,
|
|
1390
|
-
/**
|
|
1391
|
-
* Renderer for a selection checkbox. Allow to replace checkboxes in the List by a custom implementation.
|
|
1392
|
-
* @since 3.19.0
|
|
1393
|
-
*/
|
|
1394
|
-
renderSelectionCheckbox: _propTypes.default.func,
|
|
1395
|
-
/**
|
|
1396
|
-
* Row's key getter. Could be a string or function like: `row => <unique_string>`
|
|
1397
|
-
* @since 0.0.45
|
|
1398
|
-
*/
|
|
1399
|
-
rowKey: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
1400
|
-
/**
|
|
1401
|
-
* Renderer for a row body. Should return ReactNode.
|
|
1402
|
-
* @since 1.12.0
|
|
1403
|
-
*/
|
|
1404
|
-
renderRowBody: _propTypes.default.func,
|
|
1405
|
-
/**
|
|
1406
|
-
* Array of keys of expanded rows
|
|
1407
|
-
* @since 1.12.0
|
|
1408
|
-
*/
|
|
1409
|
-
expandedRows: _propTypes.default.array,
|
|
1410
|
-
/**
|
|
1411
|
-
* Array of keys of rows which not have expand indicator
|
|
1412
|
-
* @since 1.12.0
|
|
1413
|
-
*/
|
|
1414
|
-
notExpandableRows: _propTypes.default.array,
|
|
1415
|
-
/**
|
|
1416
|
-
* Rows expanding change handler.
|
|
1417
|
-
* @since 1.12.0
|
|
1418
|
-
*/
|
|
1419
|
-
onExpandedRowsChange: _propTypes.default.func,
|
|
1420
|
-
/**
|
|
1421
|
-
* Array of keys of loading rows. They are displayed instead of checkboxes.
|
|
1422
|
-
* @since 2.5.0
|
|
1423
|
-
*/
|
|
1424
|
-
loadingRows: _propTypes.default.array,
|
|
1425
|
-
/**
|
|
1426
|
-
* A `Pagination` element. It displays at the top and the bottom of the list. When pagination is defined, the built-in sort is disabled.
|
|
1427
|
-
* @since 2.4.0
|
|
1428
|
-
*/
|
|
1429
|
-
pagination: _propTypes.default.node,
|
|
1430
|
-
/**
|
|
1431
|
-
* Total rows count, including nested rows. Usually, it uses together with pagination.
|
|
1432
|
-
* @since 2.4.0
|
|
1433
|
-
*/
|
|
1434
|
-
totalRows: _propTypes.default.number,
|
|
1435
|
-
/**
|
|
1436
|
-
* A `Toolbar` element.
|
|
1437
|
-
* @since 2.4.0
|
|
1438
|
-
*/
|
|
1439
|
-
toolbar: _propTypes.default.node,
|
|
1440
|
-
/**
|
|
1441
|
-
* A flag that all rows are selected.
|
|
1442
|
-
* @since 2.4.0
|
|
1443
|
-
*/
|
|
1444
|
-
allRowsSelected: _propTypes.default.bool,
|
|
1445
|
-
/**
|
|
1446
|
-
* A callback executed when the allRowsSelected prop is changed.
|
|
1447
|
-
* @since 2.4.0
|
|
1448
|
-
*/
|
|
1449
|
-
onAllRowsSelectedChange: _propTypes.default.func,
|
|
1450
|
-
/**
|
|
1451
|
-
* Filtered list. Manages toolbar visibility when data is absent and defines the defaults for empty view.
|
|
1452
|
-
* @since 3.0.1
|
|
1453
|
-
*/
|
|
1454
|
-
filtered: _propTypes.default.bool,
|
|
1455
|
-
/**
|
|
1456
|
-
* A custom view for the case when data is absent.
|
|
1457
|
-
* @since 2.5.0
|
|
1458
|
-
*/
|
|
1459
|
-
emptyView: _propTypes.default.node,
|
|
1460
|
-
/**
|
|
1461
|
-
* Which part of the List component should be replaced by the empty view.
|
|
1462
|
-
* @since 2.6.0
|
|
1463
|
-
* @deprecated Use `filtered` instead.
|
|
1464
|
-
*/
|
|
1465
|
-
emptyViewMode: _propTypes.default.oneOf(['all', 'items']),
|
|
1466
|
-
/**
|
|
1467
|
-
* A slot on the right of the items.
|
|
1468
|
-
* @since 2.6.0
|
|
1469
|
-
*/
|
|
1470
|
-
sidebar: _propTypes.default.node,
|
|
1471
|
-
/**
|
|
1472
|
-
* Custom localization messages.
|
|
1473
|
-
* @since 2.6.0
|
|
1474
|
-
*/
|
|
1475
|
-
locale: _propTypes.default.shape({
|
|
1476
|
-
selectAll: _propTypes.default.node,
|
|
1477
|
-
deselectAll: _propTypes.default.node,
|
|
1478
|
-
all: _propTypes.default.node,
|
|
1479
|
-
totalRows: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
1480
|
-
selectedRows: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node])
|
|
1481
|
-
}),
|
|
1482
|
-
/**
|
|
1483
|
-
* Render List row's content vertically.
|
|
1484
|
-
* When some number is specified, it turns into vertical mode automatically if the List's width is less than the provided number.
|
|
1485
|
-
* @since 3.3.0
|
|
1486
|
-
*/
|
|
1487
|
-
vertical: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.number]),
|
|
1488
|
-
/**
|
|
1489
|
-
* Indicate the loading state of the list.
|
|
1490
|
-
* @since 3.3.1
|
|
1491
|
-
*/
|
|
1492
|
-
loading: _propTypes.default.bool,
|
|
1493
|
-
/**
|
|
1494
|
-
* Apply some props to each row.
|
|
1495
|
-
*
|
|
1496
|
-
* `virtual` - Virtual row does not have any controls.
|
|
1497
|
-
*
|
|
1498
|
-
* @since 3.11.0
|
|
1499
|
-
*/
|
|
1500
|
-
rowProps: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
1501
|
-
virtual: _propTypes.default.bool
|
|
1502
|
-
}), _propTypes.default.func]),
|
|
1503
|
-
/**
|
|
1504
|
-
* Enable reorderable view.
|
|
1505
|
-
* @since 3.18.0
|
|
1506
|
-
*/
|
|
1507
|
-
reorderable: _propTypes.default.bool,
|
|
1508
|
-
/**
|
|
1509
|
-
* Reorder end handler.
|
|
1510
|
-
* @since 3.18.0
|
|
1511
|
-
*/
|
|
1512
|
-
onReorderEnd: _propTypes.default.func,
|
|
1513
|
-
/**
|
|
1514
|
-
* @ignore
|
|
1515
|
-
*/
|
|
1516
|
-
className: _propTypes.default.string,
|
|
1517
|
-
/**
|
|
1518
|
-
* @ignore
|
|
1519
|
-
*/
|
|
1520
|
-
baseClassName: _propTypes.default.string
|
|
1521
|
-
};
|
|
1522
|
-
List.defaultProps = {
|
|
1310
|
+
(0, _defineProperty2.default)(List, "defaultProps", {
|
|
1523
1311
|
data: [],
|
|
1524
|
-
sortColumn:
|
|
1312
|
+
sortColumn: undefined,
|
|
1525
1313
|
sortDirection: 'ASC',
|
|
1526
|
-
onSortChange:
|
|
1527
|
-
onSelectionChange:
|
|
1314
|
+
onSortChange: undefined,
|
|
1315
|
+
onSelectionChange: undefined,
|
|
1528
1316
|
selection: [],
|
|
1529
1317
|
renderSelectionCheckbox: undefined,
|
|
1530
1318
|
rowKey: 'key',
|
|
@@ -1533,7 +1321,7 @@ List.defaultProps = {
|
|
|
1533
1321
|
notExpandableRows: [],
|
|
1534
1322
|
onExpandedRowsChange: undefined,
|
|
1535
1323
|
loadingRows: [],
|
|
1536
|
-
className:
|
|
1324
|
+
className: '',
|
|
1537
1325
|
baseClassName: `${_constants.CLS_PREFIX}list`,
|
|
1538
1326
|
pagination: undefined,
|
|
1539
1327
|
totalRows: undefined,
|
|
@@ -1550,5 +1338,5 @@ List.defaultProps = {
|
|
|
1550
1338
|
rowProps: undefined,
|
|
1551
1339
|
reorderable: false,
|
|
1552
1340
|
onReorderEnd: undefined
|
|
1553
|
-
};
|
|
1341
|
+
});
|
|
1554
1342
|
var _default = exports.default = List;
|