@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { Fragment, cloneElement, isValidElement, createRef, Component } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { CSSTransition } from 'react-transition-group';
|
|
@@ -25,7 +25,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
25
25
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
import { createElement as _createElement } from "react";
|
|
28
|
-
|
|
28
|
+
// eslint-disable-next-line func-style
|
|
29
|
+
function getRowKey(row, props) {
|
|
29
30
|
const {
|
|
30
31
|
rowKey
|
|
31
32
|
} = props;
|
|
@@ -33,7 +34,7 @@ const getRowKey = (row, props) => {
|
|
|
33
34
|
return rowKey(row);
|
|
34
35
|
}
|
|
35
36
|
return row[rowKey];
|
|
36
|
-
}
|
|
37
|
+
}
|
|
37
38
|
const Tbody = _ref => {
|
|
38
39
|
let {
|
|
39
40
|
baseClassName,
|
|
@@ -133,7 +134,6 @@ const getHumanTotalRows = _ref2 => {
|
|
|
133
134
|
return null;
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
|
-
|
|
137
137
|
/**
|
|
138
138
|
* `List` component is used for displaying a collection of tabular data.
|
|
139
139
|
* [More details about designing of lists.](#!/Sets%20of%20Objects)
|
|
@@ -145,26 +145,32 @@ class List extends Component {
|
|
|
145
145
|
_defineProperty(this, "state", {
|
|
146
146
|
sortInPlace: !this.props.pagination,
|
|
147
147
|
vertical: false,
|
|
148
|
-
expandedRows: this.props.expandedRows,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
expandedRows: this.props.expandedRows ?? [],
|
|
149
|
+
ReorderableList: undefined,
|
|
150
|
+
reorderableItemWidths: [],
|
|
151
|
+
prevExpandedRows: this.props.expandedRows ?? [],
|
|
152
|
+
sortColumn: undefined,
|
|
153
|
+
prevSortColumn: undefined,
|
|
154
|
+
sortDirection: undefined,
|
|
155
|
+
prevSortDirection: undefined,
|
|
156
|
+
selection: this.props.selection ?? [],
|
|
157
|
+
prevSelection: this.props.selection ?? [],
|
|
158
|
+
prevData: [],
|
|
159
|
+
prevPagination: undefined
|
|
154
160
|
});
|
|
161
|
+
_defineProperty(this, "needScroll", false);
|
|
155
162
|
_defineProperty(this, "anchorRef", /*#__PURE__*/createRef());
|
|
156
|
-
_defineProperty(this, "flatData", data => data.reduce((acc,
|
|
157
|
-
|
|
158
|
-
data
|
|
159
|
-
|
|
160
|
-
} = _ref3;
|
|
163
|
+
_defineProperty(this, "flatData", data => data.reduce((acc, item) => {
|
|
164
|
+
const {
|
|
165
|
+
data
|
|
166
|
+
} = item;
|
|
161
167
|
const {
|
|
162
168
|
virtual
|
|
163
|
-
} = this.getRowProps(
|
|
169
|
+
} = this.getRowProps(item);
|
|
164
170
|
if (virtual) {
|
|
165
171
|
return [...acc, ...(data ? this.flatData(data) : [])];
|
|
166
172
|
}
|
|
167
|
-
return [...acc,
|
|
173
|
+
return [...acc, item, ...(data ? this.flatData(data) : [])];
|
|
168
174
|
}, []));
|
|
169
175
|
_defineProperty(this, "handleRowSelectionChange", (checked, rowKey) => {
|
|
170
176
|
const {
|
|
@@ -182,13 +188,14 @@ class List extends Component {
|
|
|
182
188
|
});
|
|
183
189
|
_defineProperty(this, "handleGlobalSelectionChange", headerChecked => {
|
|
184
190
|
const {
|
|
185
|
-
onAllRowsSelectedChange
|
|
191
|
+
onAllRowsSelectedChange,
|
|
192
|
+
data
|
|
186
193
|
} = this.props;
|
|
187
194
|
const {
|
|
188
195
|
selection
|
|
189
196
|
} = this.state;
|
|
190
197
|
const nextSelection = [];
|
|
191
|
-
this.flatData(
|
|
198
|
+
this.flatData(data ?? []).forEach(row => {
|
|
192
199
|
const key = getRowKey(row, this.props);
|
|
193
200
|
if (row.disabled || this.isRowLoading(row)) {
|
|
194
201
|
if (selection.indexOf(key) !== -1) {
|
|
@@ -205,15 +212,17 @@ class List extends Component {
|
|
|
205
212
|
}
|
|
206
213
|
this.setSelection(nextSelection);
|
|
207
214
|
});
|
|
208
|
-
_defineProperty(this, "handleResize",
|
|
215
|
+
_defineProperty(this, "handleResize", _ref3 => {
|
|
209
216
|
let {
|
|
210
217
|
bounds
|
|
211
|
-
} =
|
|
212
|
-
this.
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
} = _ref3;
|
|
219
|
+
if (bounds && this.props.vertical) {
|
|
220
|
+
this.setState({
|
|
221
|
+
vertical: typeof this.props.vertical === 'boolean' ? this.props.vertical : bounds.width < this.props.vertical
|
|
222
|
+
});
|
|
223
|
+
}
|
|
215
224
|
});
|
|
216
|
-
_defineProperty(this, "isRowLoading", row => this.props.loadingRows
|
|
225
|
+
_defineProperty(this, "isRowLoading", row => this.props.loadingRows?.indexOf(getRowKey(row, this.props)) !== -1);
|
|
217
226
|
_defineProperty(this, "getRowTitle", row => {
|
|
218
227
|
const {
|
|
219
228
|
columns
|
|
@@ -260,7 +269,7 @@ class List extends Component {
|
|
|
260
269
|
} = this.state;
|
|
261
270
|
const headerExpanded = this.isAnyRowsExpanded(data, expandedRows);
|
|
262
271
|
const nextExpandedRows = [];
|
|
263
|
-
this.flatData(
|
|
272
|
+
this.flatData(data ?? []).forEach(row => {
|
|
264
273
|
const key = getRowKey(row, this.props);
|
|
265
274
|
if (!this.isRowExpandable(row)) {
|
|
266
275
|
if (expandedRows.indexOf(key) !== -1) {
|
|
@@ -283,7 +292,7 @@ class List extends Component {
|
|
|
283
292
|
}
|
|
284
293
|
});
|
|
285
294
|
}
|
|
286
|
-
static getDerivedStateFromProps(
|
|
295
|
+
static getDerivedStateFromProps(_ref4, _ref5) {
|
|
287
296
|
let {
|
|
288
297
|
sortColumn,
|
|
289
298
|
sortDirection,
|
|
@@ -297,7 +306,7 @@ class List extends Component {
|
|
|
297
306
|
rowKey,
|
|
298
307
|
totalRows,
|
|
299
308
|
filtered
|
|
300
|
-
} =
|
|
309
|
+
} = _ref4;
|
|
301
310
|
let {
|
|
302
311
|
prevSortColumn,
|
|
303
312
|
prevSortDirection,
|
|
@@ -306,7 +315,7 @@ class List extends Component {
|
|
|
306
315
|
prevPagination,
|
|
307
316
|
prevExpandedRows,
|
|
308
317
|
...state
|
|
309
|
-
} =
|
|
318
|
+
} = _ref5;
|
|
310
319
|
let nextState = {};
|
|
311
320
|
if (prevSortColumn !== sortColumn || prevSortDirection !== sortDirection) {
|
|
312
321
|
nextState = {
|
|
@@ -317,18 +326,18 @@ class List extends Component {
|
|
|
317
326
|
}
|
|
318
327
|
const additionalExpanded = [];
|
|
319
328
|
if (prevData !== data) {
|
|
320
|
-
const isSingleElementInCurrentExpanded = () => state.expandedRows.includes(getRowKey(data[0], {
|
|
329
|
+
const isSingleElementInCurrentExpanded = () => data && state.expandedRows.includes(getRowKey(data[0], {
|
|
321
330
|
rowKey
|
|
322
331
|
}));
|
|
323
332
|
if (renderRowBody && data?.length === 1 && (!pagination || totalRows === 1) && (!prevData || prevData?.length === 0 || isSingleElementInCurrentExpanded()) && (!filtered || isSingleElementInCurrentExpanded())) {
|
|
324
333
|
const key = getRowKey(data[0], {
|
|
325
334
|
rowKey
|
|
326
335
|
});
|
|
327
|
-
if (notExpandableRows
|
|
336
|
+
if (notExpandableRows?.indexOf(key) === -1) {
|
|
328
337
|
additionalExpanded.push(key);
|
|
329
338
|
}
|
|
330
339
|
}
|
|
331
|
-
const keys = data.map(row => getRowKey(row, {
|
|
340
|
+
const keys = (data ?? []).map(row => getRowKey(row, {
|
|
332
341
|
rowKey
|
|
333
342
|
}));
|
|
334
343
|
const nextSelection = state.selection.filter(key => keys.indexOf(key) !== -1);
|
|
@@ -340,13 +349,13 @@ class List extends Component {
|
|
|
340
349
|
if (prevSelection !== selection) {
|
|
341
350
|
nextState = {
|
|
342
351
|
...nextState,
|
|
343
|
-
selection
|
|
352
|
+
selection: selection ?? []
|
|
344
353
|
};
|
|
345
354
|
}
|
|
346
355
|
if (prevExpandedRows !== expandedRows || additionalExpanded.length) {
|
|
347
356
|
nextState = {
|
|
348
357
|
...nextState,
|
|
349
|
-
expandedRows: [...expandedRows, ...additionalExpanded]
|
|
358
|
+
expandedRows: [...(expandedRows ?? []), ...additionalExpanded]
|
|
350
359
|
};
|
|
351
360
|
}
|
|
352
361
|
if (prevPagination !== pagination) {
|
|
@@ -389,10 +398,11 @@ class List extends Component {
|
|
|
389
398
|
}
|
|
390
399
|
}
|
|
391
400
|
applyReorderableList() {
|
|
392
|
-
import( /* webpackChunkName: "react-movable" */'@plesk/react-movable').then(
|
|
401
|
+
import( /* webpackChunkName: "react-movable" */'@plesk/react-movable').then(_ref6 => {
|
|
393
402
|
let {
|
|
394
403
|
List: ReorderableList
|
|
395
|
-
} =
|
|
404
|
+
} = _ref6;
|
|
405
|
+
// @ts-expect-error
|
|
396
406
|
this.setState({
|
|
397
407
|
ReorderableList
|
|
398
408
|
});
|
|
@@ -408,13 +418,16 @@ class List extends Component {
|
|
|
408
418
|
data,
|
|
409
419
|
columns
|
|
410
420
|
} = this.props;
|
|
421
|
+
if (!data) {
|
|
422
|
+
return [];
|
|
423
|
+
}
|
|
411
424
|
if (!sortInPlace) {
|
|
412
425
|
return data;
|
|
413
426
|
}
|
|
414
|
-
const [column] = columns.filter(
|
|
427
|
+
const [column] = columns.filter(_ref7 => {
|
|
415
428
|
let {
|
|
416
429
|
key
|
|
417
|
-
} =
|
|
430
|
+
} = _ref7;
|
|
418
431
|
return key === sortColumn;
|
|
419
432
|
});
|
|
420
433
|
const defaultSort = (a, b) => {
|
|
@@ -426,7 +439,7 @@ class List extends Component {
|
|
|
426
439
|
}
|
|
427
440
|
return 0;
|
|
428
441
|
};
|
|
429
|
-
if (!column) {
|
|
442
|
+
if (!column || !sortColumn) {
|
|
430
443
|
return data;
|
|
431
444
|
}
|
|
432
445
|
return data.sort((a, b) => (column.sort ? column.sort(a, b) : defaultSort(a[sortColumn], b[sortColumn])) * (sortDirection === 'ASC' ? 1 : -1));
|
|
@@ -435,22 +448,22 @@ class List extends Component {
|
|
|
435
448
|
const {
|
|
436
449
|
sortInPlace
|
|
437
450
|
} = this.state;
|
|
438
|
-
|
|
451
|
+
const {
|
|
439
452
|
sortColumn,
|
|
440
453
|
sortDirection
|
|
441
454
|
} = this.state;
|
|
442
|
-
|
|
443
|
-
|
|
455
|
+
const nextSortDirection = sortColumn === columnKey && sortDirection === 'ASC' ? 'DESC' : 'ASC';
|
|
456
|
+
const nextSortColumn = columnKey;
|
|
444
457
|
if (sortInPlace) {
|
|
445
458
|
this.setState({
|
|
446
|
-
sortColumn,
|
|
447
|
-
sortDirection
|
|
459
|
+
sortColumn: nextSortColumn,
|
|
460
|
+
sortDirection: nextSortDirection
|
|
448
461
|
});
|
|
449
462
|
}
|
|
450
463
|
if (this.props.onSortChange) {
|
|
451
464
|
this.props.onSortChange({
|
|
452
|
-
sortColumn,
|
|
453
|
-
sortDirection
|
|
465
|
+
sortColumn: nextSortColumn,
|
|
466
|
+
sortDirection: nextSortDirection
|
|
454
467
|
});
|
|
455
468
|
}
|
|
456
469
|
}
|
|
@@ -475,7 +488,7 @@ class List extends Component {
|
|
|
475
488
|
if (virtual) {
|
|
476
489
|
return false;
|
|
477
490
|
}
|
|
478
|
-
return this.props.notExpandableRows
|
|
491
|
+
return this.props.notExpandableRows?.indexOf(getRowKey(row, this.props)) === -1;
|
|
479
492
|
}
|
|
480
493
|
handleRowExpandingChange(row) {
|
|
481
494
|
let expandedRows;
|
|
@@ -494,7 +507,7 @@ class List extends Component {
|
|
|
494
507
|
});
|
|
495
508
|
safeInvoke(this.props.onExpandedRowsChange, expandedRows.slice());
|
|
496
509
|
}
|
|
497
|
-
renderRow(
|
|
510
|
+
renderRow(_ref8) {
|
|
498
511
|
let {
|
|
499
512
|
row,
|
|
500
513
|
index,
|
|
@@ -503,7 +516,7 @@ class List extends Component {
|
|
|
503
516
|
parent,
|
|
504
517
|
isDragged,
|
|
505
518
|
reorderableProps
|
|
506
|
-
} =
|
|
519
|
+
} = _ref8;
|
|
507
520
|
const {
|
|
508
521
|
baseClassName,
|
|
509
522
|
renderRowBody,
|
|
@@ -513,10 +526,10 @@ class List extends Component {
|
|
|
513
526
|
vertical,
|
|
514
527
|
reorderableItemWidths
|
|
515
528
|
} = this.state;
|
|
516
|
-
const hasActions = realColumn.some(
|
|
529
|
+
const hasActions = realColumn.some(_ref9 => {
|
|
517
530
|
let {
|
|
518
531
|
type
|
|
519
|
-
} =
|
|
532
|
+
} = _ref9;
|
|
520
533
|
return type === 'actions';
|
|
521
534
|
});
|
|
522
535
|
const {
|
|
@@ -542,7 +555,7 @@ class List extends Component {
|
|
|
542
555
|
}, className),
|
|
543
556
|
...rowProps,
|
|
544
557
|
onClick: renderRowBody ? this.createRowClickHandler(row) : undefined,
|
|
545
|
-
children: realColumn.map((
|
|
558
|
+
children: realColumn.map((_ref10, index) => {
|
|
546
559
|
let {
|
|
547
560
|
key,
|
|
548
561
|
title,
|
|
@@ -551,7 +564,7 @@ class List extends Component {
|
|
|
551
564
|
cellProps,
|
|
552
565
|
truncate,
|
|
553
566
|
type
|
|
554
|
-
} =
|
|
567
|
+
} = _ref10;
|
|
555
568
|
if (skipCells > 0) {
|
|
556
569
|
skipCells -= 1;
|
|
557
570
|
return null;
|
|
@@ -562,7 +575,7 @@ class List extends Component {
|
|
|
562
575
|
width
|
|
563
576
|
};
|
|
564
577
|
}
|
|
565
|
-
if (isDragged) {
|
|
578
|
+
if (isDragged && reorderableItemWidths) {
|
|
566
579
|
style = {
|
|
567
580
|
width: reorderableItemWidths[index]
|
|
568
581
|
};
|
|
@@ -659,13 +672,13 @@ class List extends Component {
|
|
|
659
672
|
}
|
|
660
673
|
return element;
|
|
661
674
|
}
|
|
662
|
-
renderRowBody(
|
|
675
|
+
renderRowBody(_ref11) {
|
|
663
676
|
let {
|
|
664
677
|
row,
|
|
665
678
|
index,
|
|
666
679
|
realColumn,
|
|
667
680
|
parent
|
|
668
|
-
} =
|
|
681
|
+
} = _ref11;
|
|
669
682
|
const {
|
|
670
683
|
baseClassName,
|
|
671
684
|
renderRowBody
|
|
@@ -676,16 +689,16 @@ class List extends Component {
|
|
|
676
689
|
if (!renderRowBody) {
|
|
677
690
|
return null;
|
|
678
691
|
}
|
|
679
|
-
const reorderable = realColumn.find(
|
|
692
|
+
const reorderable = realColumn.find(_ref12 => {
|
|
680
693
|
let {
|
|
681
694
|
key
|
|
682
|
-
} =
|
|
695
|
+
} = _ref12;
|
|
683
696
|
return key === 'reorderable';
|
|
684
697
|
});
|
|
685
|
-
const expander = realColumn.find(
|
|
698
|
+
const expander = realColumn.find(_ref13 => {
|
|
686
699
|
let {
|
|
687
700
|
key
|
|
688
|
-
} =
|
|
701
|
+
} = _ref13;
|
|
689
702
|
return key === 'expander';
|
|
690
703
|
});
|
|
691
704
|
const isRowExpanded = this.isRowExpanded(row);
|
|
@@ -830,7 +843,7 @@ class List extends Component {
|
|
|
830
843
|
itemsPerPageOptions = ITEMS_PER_PAGE_OPTIONS
|
|
831
844
|
} = pagination.props;
|
|
832
845
|
if (Array.isArray(itemsPerPageOptions)) {
|
|
833
|
-
const numericOptions = itemsPerPageOptions.filter(
|
|
846
|
+
const numericOptions = itemsPerPageOptions.filter(Number);
|
|
834
847
|
if (numericOptions.length) {
|
|
835
848
|
const min = Math.min(...numericOptions);
|
|
836
849
|
if (totalRows <= min) {
|
|
@@ -893,6 +906,9 @@ class List extends Component {
|
|
|
893
906
|
pagination,
|
|
894
907
|
loading
|
|
895
908
|
} = this.props;
|
|
909
|
+
if (!pagination) {
|
|
910
|
+
return null;
|
|
911
|
+
}
|
|
896
912
|
const paginationProps = {
|
|
897
913
|
loading
|
|
898
914
|
};
|
|
@@ -955,7 +971,7 @@ class List extends Component {
|
|
|
955
971
|
const {
|
|
956
972
|
vertical
|
|
957
973
|
} = this.state;
|
|
958
|
-
if (
|
|
974
|
+
if (!(data && data.length > 0) && !filtered && emptyViewMode === 'all') {
|
|
959
975
|
return this.renderEmptyView();
|
|
960
976
|
}
|
|
961
977
|
const realColumn = columns.map((column, i) => {
|
|
@@ -1107,14 +1123,14 @@ class List extends Component {
|
|
|
1107
1123
|
}
|
|
1108
1124
|
const hasTitle = !vertical && columns.some(column => column.title);
|
|
1109
1125
|
let content;
|
|
1110
|
-
if (
|
|
1126
|
+
if (!(data && data.length > 0) && (filtered || emptyViewMode === 'items')) {
|
|
1111
1127
|
content = this.renderEmptyView();
|
|
1112
1128
|
} else {
|
|
1113
|
-
const renderList =
|
|
1129
|
+
const renderList = _ref14 => {
|
|
1114
1130
|
let {
|
|
1115
1131
|
children,
|
|
1116
1132
|
props: reorderableProps
|
|
1117
|
-
} =
|
|
1133
|
+
} = _ref14;
|
|
1118
1134
|
return /*#__PURE__*/_jsx(FocusVisibleManager, {
|
|
1119
1135
|
children: /*#__PURE__*/_jsxs("table", {
|
|
1120
1136
|
className: classNames(`${baseClassName}__table`, {
|
|
@@ -1128,7 +1144,7 @@ class List extends Component {
|
|
|
1128
1144
|
className: classNames(`${baseClassName}__table-thead`, {
|
|
1129
1145
|
[`${baseClassName}__row--expanded`]: this.isAnyRowsExpanded(data, this.state.expandedRows)
|
|
1130
1146
|
}),
|
|
1131
|
-
children: realColumn.map(
|
|
1147
|
+
children: realColumn.map(_ref15 => {
|
|
1132
1148
|
let {
|
|
1133
1149
|
key,
|
|
1134
1150
|
title,
|
|
@@ -1140,7 +1156,7 @@ class List extends Component {
|
|
|
1140
1156
|
type,
|
|
1141
1157
|
cellProps,
|
|
1142
1158
|
...headerProps
|
|
1143
|
-
} =
|
|
1159
|
+
} = _ref15;
|
|
1144
1160
|
if (sortable) {
|
|
1145
1161
|
title = /*#__PURE__*/_jsx("div", {
|
|
1146
1162
|
className: "th__action",
|
|
@@ -1171,7 +1187,7 @@ class List extends Component {
|
|
|
1171
1187
|
})
|
|
1172
1188
|
});
|
|
1173
1189
|
};
|
|
1174
|
-
const renderItem =
|
|
1190
|
+
const renderItem = _ref16 => {
|
|
1175
1191
|
let {
|
|
1176
1192
|
value: {
|
|
1177
1193
|
row
|
|
@@ -1179,7 +1195,7 @@ class List extends Component {
|
|
|
1179
1195
|
index,
|
|
1180
1196
|
props: reorderableProps,
|
|
1181
1197
|
isDragged
|
|
1182
|
-
} =
|
|
1198
|
+
} = _ref16;
|
|
1183
1199
|
return this.renderRow({
|
|
1184
1200
|
row,
|
|
1185
1201
|
index,
|
|
@@ -1189,27 +1205,27 @@ class List extends Component {
|
|
|
1189
1205
|
isDragged
|
|
1190
1206
|
});
|
|
1191
1207
|
};
|
|
1192
|
-
if (reorderable) {
|
|
1208
|
+
if (reorderable && this.state.ReorderableList) {
|
|
1193
1209
|
const {
|
|
1194
1210
|
ReorderableList
|
|
1195
1211
|
} = this.state;
|
|
1196
1212
|
content = /*#__PURE__*/_jsx(ReorderableList, {
|
|
1197
|
-
beforeDrag:
|
|
1213
|
+
beforeDrag: _ref17 => {
|
|
1198
1214
|
let {
|
|
1199
1215
|
elements,
|
|
1200
1216
|
index
|
|
1201
|
-
} =
|
|
1217
|
+
} = _ref17;
|
|
1202
1218
|
const cells = Array.from(elements[index].firstElementChild.children);
|
|
1203
1219
|
const reorderableItemWidths = cells.map(cell => window.getComputedStyle(cell).width);
|
|
1204
1220
|
this.setState({
|
|
1205
1221
|
reorderableItemWidths
|
|
1206
1222
|
});
|
|
1207
1223
|
},
|
|
1208
|
-
onChange:
|
|
1224
|
+
onChange: _ref18 => {
|
|
1209
1225
|
let {
|
|
1210
1226
|
oldIndex,
|
|
1211
1227
|
newIndex
|
|
1212
|
-
} =
|
|
1228
|
+
} = _ref18;
|
|
1213
1229
|
safeInvoke(onReorderEnd, {
|
|
1214
1230
|
oldIndex,
|
|
1215
1231
|
newIndex
|
|
@@ -1222,9 +1238,11 @@ class List extends Component {
|
|
|
1222
1238
|
renderItem: renderItem,
|
|
1223
1239
|
lockVertically: true,
|
|
1224
1240
|
hooks: {
|
|
1225
|
-
getChildren: children =>
|
|
1241
|
+
getChildren: children =>
|
|
1242
|
+
// @ts-expect-error
|
|
1243
|
+
children.filter(node => node.nodeName !== 'THEAD')
|
|
1226
1244
|
},
|
|
1227
|
-
useDragHandle:
|
|
1245
|
+
useDragHandle: false
|
|
1228
1246
|
});
|
|
1229
1247
|
} else {
|
|
1230
1248
|
content = renderList({
|
|
@@ -1274,10 +1292,10 @@ class List extends Component {
|
|
|
1274
1292
|
return /*#__PURE__*/_jsx(Measure, {
|
|
1275
1293
|
bounds: true,
|
|
1276
1294
|
onResize: this.handleResize,
|
|
1277
|
-
children:
|
|
1295
|
+
children: _ref19 => {
|
|
1278
1296
|
let {
|
|
1279
1297
|
measureRef
|
|
1280
|
-
} =
|
|
1298
|
+
} = _ref19;
|
|
1281
1299
|
return createRoot(measureRef);
|
|
1282
1300
|
}
|
|
1283
1301
|
});
|
|
@@ -1285,242 +1303,12 @@ class List extends Component {
|
|
|
1285
1303
|
return createRoot();
|
|
1286
1304
|
}
|
|
1287
1305
|
}
|
|
1288
|
-
List
|
|
1289
|
-
/**
|
|
1290
|
-
* Columns definition.
|
|
1291
|
-
*
|
|
1292
|
-
* In addition to the properties described below, you can use any native properties
|
|
1293
|
-
* supported by the `TH` element like `className`, `style`, etc.
|
|
1294
|
-
* @since 0.0.42
|
|
1295
|
-
*/
|
|
1296
|
-
columns: PropTypes.arrayOf(PropTypes.shape({
|
|
1297
|
-
/**
|
|
1298
|
-
* Unique column key.
|
|
1299
|
-
*/
|
|
1300
|
-
key: PropTypes.string.isRequired,
|
|
1301
|
-
/**
|
|
1302
|
-
* Column title.
|
|
1303
|
-
*/
|
|
1304
|
-
title: PropTypes.node,
|
|
1305
|
-
/**
|
|
1306
|
-
* Optional cell renderer function: `row => Component`. By default render value of cell.
|
|
1307
|
-
* The renderer function can also returns a configuration object like: `{children: 'cell content', colSpan: 3}`
|
|
1308
|
-
*/
|
|
1309
|
-
render: PropTypes.func,
|
|
1310
|
-
/**
|
|
1311
|
-
* Is column sortable.
|
|
1312
|
-
* Default is `false`
|
|
1313
|
-
*/
|
|
1314
|
-
sortable: PropTypes.bool,
|
|
1315
|
-
/**
|
|
1316
|
-
* Optional function for row comparison: `(row1, row2) => -1 | 0 | 1`
|
|
1317
|
-
*/
|
|
1318
|
-
sort: PropTypes.func,
|
|
1319
|
-
/**
|
|
1320
|
-
* Column alignment.
|
|
1321
|
-
*/
|
|
1322
|
-
align: PropTypes.oneOf(['left', 'center', 'right']),
|
|
1323
|
-
/**
|
|
1324
|
-
* Truncate the text in cell with an ellipsis.
|
|
1325
|
-
*/
|
|
1326
|
-
truncate: PropTypes.bool,
|
|
1327
|
-
/**
|
|
1328
|
-
* Determine type of column content.
|
|
1329
|
-
*
|
|
1330
|
-
* * title - There should a title of the row.
|
|
1331
|
-
* * controls - There should be some control: a button or a dropdown.
|
|
1332
|
-
* * actions - There should be the ListAction component.
|
|
1333
|
-
*/
|
|
1334
|
-
type: PropTypes.oneOf(['title', 'controls', 'actions'])
|
|
1335
|
-
})).isRequired,
|
|
1336
|
-
/**
|
|
1337
|
-
* Array of row objects.
|
|
1338
|
-
*
|
|
1339
|
-
* Each row must contains `key` property, all columns keys, and can contain `disabled` property.
|
|
1340
|
-
* @since 0.0.42
|
|
1341
|
-
*/
|
|
1342
|
-
data: PropTypes.arrayOf(PropTypes.shape({
|
|
1343
|
-
/**
|
|
1344
|
-
* Unique column key. This property can by renamed using `rowKey` property of List.
|
|
1345
|
-
*/
|
|
1346
|
-
key: PropTypes.string,
|
|
1347
|
-
/**
|
|
1348
|
-
* Optional property for disabling ability to select this row.
|
|
1349
|
-
*/
|
|
1350
|
-
disabled: PropTypes.bool,
|
|
1351
|
-
/**
|
|
1352
|
-
* Optional array of children rows.
|
|
1353
|
-
*/
|
|
1354
|
-
data: PropTypes.array,
|
|
1355
|
-
/**
|
|
1356
|
-
* An optional property to change the appearance of this row.<br />
|
|
1357
|
-
* `inactive, info, success, warning, danger`. (Since: 3.33.0)
|
|
1358
|
-
*/
|
|
1359
|
-
intent: PropTypes.oneOf(['inactive', 'info', 'success', 'warning', 'danger'])
|
|
1360
|
-
})),
|
|
1361
|
-
/**
|
|
1362
|
-
* Current sort column key
|
|
1363
|
-
* @since 0.0.42
|
|
1364
|
-
*/
|
|
1365
|
-
sortColumn: PropTypes.string,
|
|
1366
|
-
/**
|
|
1367
|
-
* Sort direction of the column being sorted.
|
|
1368
|
-
* @since 0.0.42
|
|
1369
|
-
*/
|
|
1370
|
-
sortDirection: PropTypes.oneOf(['ASC', 'DESC']),
|
|
1371
|
-
/**
|
|
1372
|
-
* Sort change handler
|
|
1373
|
-
* @since 0.0.42
|
|
1374
|
-
*/
|
|
1375
|
-
onSortChange: PropTypes.func,
|
|
1376
|
-
/**
|
|
1377
|
-
* Array of keys of selected rows
|
|
1378
|
-
* @since 0.0.42
|
|
1379
|
-
*/
|
|
1380
|
-
selection: PropTypes.array,
|
|
1381
|
-
/**
|
|
1382
|
-
* Selection change handler for list. Checkboxes will only be rendered if this prop is defined.
|
|
1383
|
-
* @since 0.0.42
|
|
1384
|
-
*/
|
|
1385
|
-
onSelectionChange: PropTypes.func,
|
|
1386
|
-
/**
|
|
1387
|
-
* Renderer for a selection checkbox. Allow to replace checkboxes in the List by a custom implementation.
|
|
1388
|
-
* @since 3.19.0
|
|
1389
|
-
*/
|
|
1390
|
-
renderSelectionCheckbox: PropTypes.func,
|
|
1391
|
-
/**
|
|
1392
|
-
* Row's key getter. Could be a string or function like: `row => <unique_string>`
|
|
1393
|
-
* @since 0.0.45
|
|
1394
|
-
*/
|
|
1395
|
-
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
1396
|
-
/**
|
|
1397
|
-
* Renderer for a row body. Should return ReactNode.
|
|
1398
|
-
* @since 1.12.0
|
|
1399
|
-
*/
|
|
1400
|
-
renderRowBody: PropTypes.func,
|
|
1401
|
-
/**
|
|
1402
|
-
* Array of keys of expanded rows
|
|
1403
|
-
* @since 1.12.0
|
|
1404
|
-
*/
|
|
1405
|
-
expandedRows: PropTypes.array,
|
|
1406
|
-
/**
|
|
1407
|
-
* Array of keys of rows which not have expand indicator
|
|
1408
|
-
* @since 1.12.0
|
|
1409
|
-
*/
|
|
1410
|
-
notExpandableRows: PropTypes.array,
|
|
1411
|
-
/**
|
|
1412
|
-
* Rows expanding change handler.
|
|
1413
|
-
* @since 1.12.0
|
|
1414
|
-
*/
|
|
1415
|
-
onExpandedRowsChange: PropTypes.func,
|
|
1416
|
-
/**
|
|
1417
|
-
* Array of keys of loading rows. They are displayed instead of checkboxes.
|
|
1418
|
-
* @since 2.5.0
|
|
1419
|
-
*/
|
|
1420
|
-
loadingRows: PropTypes.array,
|
|
1421
|
-
/**
|
|
1422
|
-
* A `Pagination` element. It displays at the top and the bottom of the list. When pagination is defined, the built-in sort is disabled.
|
|
1423
|
-
* @since 2.4.0
|
|
1424
|
-
*/
|
|
1425
|
-
pagination: PropTypes.node,
|
|
1426
|
-
/**
|
|
1427
|
-
* Total rows count, including nested rows. Usually, it uses together with pagination.
|
|
1428
|
-
* @since 2.4.0
|
|
1429
|
-
*/
|
|
1430
|
-
totalRows: PropTypes.number,
|
|
1431
|
-
/**
|
|
1432
|
-
* A `Toolbar` element.
|
|
1433
|
-
* @since 2.4.0
|
|
1434
|
-
*/
|
|
1435
|
-
toolbar: PropTypes.node,
|
|
1436
|
-
/**
|
|
1437
|
-
* A flag that all rows are selected.
|
|
1438
|
-
* @since 2.4.0
|
|
1439
|
-
*/
|
|
1440
|
-
allRowsSelected: PropTypes.bool,
|
|
1441
|
-
/**
|
|
1442
|
-
* A callback executed when the allRowsSelected prop is changed.
|
|
1443
|
-
* @since 2.4.0
|
|
1444
|
-
*/
|
|
1445
|
-
onAllRowsSelectedChange: PropTypes.func,
|
|
1446
|
-
/**
|
|
1447
|
-
* Filtered list. Manages toolbar visibility when data is absent and defines the defaults for empty view.
|
|
1448
|
-
* @since 3.0.1
|
|
1449
|
-
*/
|
|
1450
|
-
filtered: PropTypes.bool,
|
|
1451
|
-
/**
|
|
1452
|
-
* A custom view for the case when data is absent.
|
|
1453
|
-
* @since 2.5.0
|
|
1454
|
-
*/
|
|
1455
|
-
emptyView: PropTypes.node,
|
|
1456
|
-
/**
|
|
1457
|
-
* Which part of the List component should be replaced by the empty view.
|
|
1458
|
-
* @since 2.6.0
|
|
1459
|
-
* @deprecated Use `filtered` instead.
|
|
1460
|
-
*/
|
|
1461
|
-
emptyViewMode: PropTypes.oneOf(['all', 'items']),
|
|
1462
|
-
/**
|
|
1463
|
-
* A slot on the right of the items.
|
|
1464
|
-
* @since 2.6.0
|
|
1465
|
-
*/
|
|
1466
|
-
sidebar: PropTypes.node,
|
|
1467
|
-
/**
|
|
1468
|
-
* Custom localization messages.
|
|
1469
|
-
* @since 2.6.0
|
|
1470
|
-
*/
|
|
1471
|
-
locale: PropTypes.shape({
|
|
1472
|
-
selectAll: PropTypes.node,
|
|
1473
|
-
deselectAll: PropTypes.node,
|
|
1474
|
-
all: PropTypes.node,
|
|
1475
|
-
totalRows: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
1476
|
-
selectedRows: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
1477
|
-
}),
|
|
1478
|
-
/**
|
|
1479
|
-
* Render List row's content vertically.
|
|
1480
|
-
* When some number is specified, it turns into vertical mode automatically if the List's width is less than the provided number.
|
|
1481
|
-
* @since 3.3.0
|
|
1482
|
-
*/
|
|
1483
|
-
vertical: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
|
|
1484
|
-
/**
|
|
1485
|
-
* Indicate the loading state of the list.
|
|
1486
|
-
* @since 3.3.1
|
|
1487
|
-
*/
|
|
1488
|
-
loading: PropTypes.bool,
|
|
1489
|
-
/**
|
|
1490
|
-
* Apply some props to each row.
|
|
1491
|
-
*
|
|
1492
|
-
* `virtual` - Virtual row does not have any controls.
|
|
1493
|
-
*
|
|
1494
|
-
* @since 3.11.0
|
|
1495
|
-
*/
|
|
1496
|
-
rowProps: PropTypes.oneOfType([PropTypes.shape({
|
|
1497
|
-
virtual: PropTypes.bool
|
|
1498
|
-
}), PropTypes.func]),
|
|
1499
|
-
/**
|
|
1500
|
-
* Enable reorderable view.
|
|
1501
|
-
* @since 3.18.0
|
|
1502
|
-
*/
|
|
1503
|
-
reorderable: PropTypes.bool,
|
|
1504
|
-
/**
|
|
1505
|
-
* Reorder end handler.
|
|
1506
|
-
* @since 3.18.0
|
|
1507
|
-
*/
|
|
1508
|
-
onReorderEnd: PropTypes.func,
|
|
1509
|
-
/**
|
|
1510
|
-
* @ignore
|
|
1511
|
-
*/
|
|
1512
|
-
className: PropTypes.string,
|
|
1513
|
-
/**
|
|
1514
|
-
* @ignore
|
|
1515
|
-
*/
|
|
1516
|
-
baseClassName: PropTypes.string
|
|
1517
|
-
};
|
|
1518
|
-
List.defaultProps = {
|
|
1306
|
+
_defineProperty(List, "defaultProps", {
|
|
1519
1307
|
data: [],
|
|
1520
|
-
sortColumn:
|
|
1308
|
+
sortColumn: undefined,
|
|
1521
1309
|
sortDirection: 'ASC',
|
|
1522
|
-
onSortChange:
|
|
1523
|
-
onSelectionChange:
|
|
1310
|
+
onSortChange: undefined,
|
|
1311
|
+
onSelectionChange: undefined,
|
|
1524
1312
|
selection: [],
|
|
1525
1313
|
renderSelectionCheckbox: undefined,
|
|
1526
1314
|
rowKey: 'key',
|
|
@@ -1529,7 +1317,7 @@ List.defaultProps = {
|
|
|
1529
1317
|
notExpandableRows: [],
|
|
1530
1318
|
onExpandedRowsChange: undefined,
|
|
1531
1319
|
loadingRows: [],
|
|
1532
|
-
className:
|
|
1320
|
+
className: '',
|
|
1533
1321
|
baseClassName: `${CLS_PREFIX}list`,
|
|
1534
1322
|
pagination: undefined,
|
|
1535
1323
|
totalRows: undefined,
|
|
@@ -1546,5 +1334,5 @@ List.defaultProps = {
|
|
|
1546
1334
|
rowProps: undefined,
|
|
1547
1335
|
reorderable: false,
|
|
1548
1336
|
onReorderEnd: undefined
|
|
1549
|
-
};
|
|
1337
|
+
});
|
|
1550
1338
|
export default List;
|