@laerdal/life-react-components 1.3.2-dev.8 → 1.4.1-dev.2
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/dist/Button/DualFunctionButton.js +4 -0
- package/dist/Button/DualFunctionButton.js.map +1 -1
- package/dist/Button/Iconbutton.d.ts +2 -2
- package/dist/Button/Iconbutton.js +0 -1
- package/dist/Button/Iconbutton.js.map +1 -1
- package/dist/Dropdown/DropdownButton.d.ts +1 -1
- package/dist/Dropdown/DropdownButton.js +3 -1
- package/dist/Dropdown/DropdownButton.js.map +1 -1
- package/dist/Dropdown/DropdownButtonTypes.d.ts +1 -0
- package/dist/Dropdown/DropdownContent.js +8 -8
- package/dist/Dropdown/DropdownContent.js.map +1 -1
- package/dist/Dropdown/DropdownFilter.d.ts +1 -1
- package/dist/Dropdown/DropdownFilter.js.map +1 -1
- package/dist/HyperLink/HyperLink.d.ts +1 -1
- package/dist/HyperLink/HyperLink.js +2 -2
- package/dist/HyperLink/HyperLink.js.map +1 -1
- package/dist/InputFields/Checkbox.d.ts +3 -2
- package/dist/InputFields/Checkbox.js +13 -11
- package/dist/InputFields/Checkbox.js.map +1 -1
- package/dist/Modals/ModalDialog.d.ts +2 -1
- package/dist/Modals/ModalDialog.js +7 -4
- package/dist/Modals/ModalDialog.js.map +1 -1
- package/dist/Modals/ModalNote.d.ts +1 -1
- package/dist/Modals/ModalNote.js +1 -1
- package/dist/Modals/ModalNote.js.map +1 -1
- package/dist/Table/Table.js +158 -231
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.d.ts +9 -0
- package/dist/Table/TableBody.js +164 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableFooter.d.ts +15 -0
- package/dist/Table/TableFooter.js +103 -0
- package/dist/Table/TableFooter.js.map +1 -0
- package/dist/Table/TableHeaders.d.ts +9 -0
- package/dist/Table/TableHeaders.js +83 -0
- package/dist/Table/TableHeaders.js.map +1 -0
- package/dist/Table/TableStyles.d.ts +19 -7
- package/dist/Table/TableStyles.js +22 -9
- package/dist/Table/TableStyles.js.map +1 -1
- package/dist/Table/TableTypes.d.ts +26 -16
- package/package.json +1 -1
package/dist/Table/Table.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
4
|
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
+
|
|
3
9
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
10
|
|
|
5
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -14,41 +20,41 @@ import * as React from 'react';
|
|
|
14
20
|
* Import custom components.
|
|
15
21
|
*/
|
|
16
22
|
|
|
17
|
-
import { MoreVertical, ChevronRight, ChevronLeft, ArrowLineDown, ArrowLineUp } from '../icons/systemicons/SystemIcons';
|
|
18
|
-
import { SystemIcons as icons } from '../icons/index';
|
|
19
|
-
import { DropdownFilter } from '../Dropdown/index';
|
|
20
|
-
import { IconButton, Button } from '../Button/index';
|
|
21
23
|
import { Size } from '../types';
|
|
22
24
|
/**
|
|
23
25
|
* Import custom styles.
|
|
24
26
|
*/
|
|
25
27
|
|
|
26
|
-
import {
|
|
27
|
-
import { TableHeaderRowCol, TableColumnHeaderCol, TableContainer, TableDataCol, TableDataRow, TableFooterCol, TableWrapper, TableLoadingIndicator } from './TableStyles';
|
|
28
|
+
import { StyledTable, StyledTableSpinner, TableWrapper } from './TableStyles';
|
|
28
29
|
/**
|
|
29
30
|
* Import custom types.
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
import { LoadingIndicator } from '../LoadingIndicator';
|
|
34
|
+
import TableHeader from './TableHeaders';
|
|
35
|
+
import TableFooter from './TableFooter';
|
|
36
|
+
import TableBody from './TableBody';
|
|
33
37
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
38
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
39
|
|
|
36
|
-
var Table = function Table(
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
var Table = function Table(props) {
|
|
41
|
+
var onPreviousPageClick = props.onPreviousPageClick,
|
|
42
|
+
onNextPageClick = props.onNextPageClick,
|
|
43
|
+
onRowsPerPageChange = props.onRowsPerPageChange,
|
|
44
|
+
onTriggerSortingChange = props.onTriggerSortingChange,
|
|
45
|
+
columns = props.columns,
|
|
46
|
+
rows = props.rows,
|
|
47
|
+
remoteOperations = props.remoteOperations,
|
|
48
|
+
pagination = props.pagination,
|
|
49
|
+
showLoadingIndicator = props.showLoadingIndicator,
|
|
50
|
+
selectable = props.selectable,
|
|
51
|
+
multiSelect = props.multiSelect,
|
|
52
|
+
keyExpr = props.keyExpr,
|
|
53
|
+
accordion = props.accordion,
|
|
54
|
+
_props$collapsed = props.collapsed,
|
|
55
|
+
collapsed = _props$collapsed === void 0 ? true : _props$collapsed,
|
|
56
|
+
collapsedRows = props.collapsedRows; // States used within the component
|
|
57
|
+
|
|
52
58
|
var _React$useState = React.useState(10),
|
|
53
59
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
60
|
rowsPerPage = _React$useState2[0],
|
|
@@ -93,14 +99,47 @@ var Table = function Table(_ref) {
|
|
|
93
99
|
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
94
100
|
total = _React$useState18[0],
|
|
95
101
|
setTotal = _React$useState18[1];
|
|
102
|
+
|
|
103
|
+
var _React$useState19 = React.useState(true),
|
|
104
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
105
|
+
isCollapsed = _React$useState20[0],
|
|
106
|
+
setIsCollapsed = _React$useState20[1];
|
|
107
|
+
|
|
108
|
+
var _React$useState21 = React.useState('none'),
|
|
109
|
+
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
110
|
+
selectAllState = _React$useState22[0],
|
|
111
|
+
setSelectAllState = _React$useState22[1];
|
|
112
|
+
|
|
113
|
+
var _React$useState23 = React.useState(multiSelect ? [] : undefined),
|
|
114
|
+
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
115
|
+
selected = _React$useState24[0],
|
|
116
|
+
setSelected = _React$useState24[1];
|
|
117
|
+
|
|
118
|
+
React.useEffect(function () {
|
|
119
|
+
setSelected(props.selectedRows || (multiSelect ? [] : undefined));
|
|
120
|
+
}, [props.selectedRows, multiSelect]);
|
|
121
|
+
/**
|
|
122
|
+
* update select all checkbox state
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
React.useEffect(function () {
|
|
126
|
+
if (multiSelect) {
|
|
127
|
+
var currentList = currentPageRows.map(function (row) {
|
|
128
|
+
return keyExpr ? row[keyExpr] : row;
|
|
129
|
+
});
|
|
130
|
+
var count = selected.filter(function (item) {
|
|
131
|
+
return currentList.includes(item);
|
|
132
|
+
}).length;
|
|
133
|
+
setSelectAllState(count === currentList.length ? 'all' : count > 0 ? 'some' : 'none');
|
|
134
|
+
}
|
|
135
|
+
}, [currentPageRows, multiSelect, selected, keyExpr]);
|
|
96
136
|
/**
|
|
97
137
|
* Takes care of local pagination.
|
|
98
138
|
* Works only in case remote pagination is not defined or is set to false.
|
|
99
139
|
*/
|
|
100
140
|
|
|
101
|
-
|
|
102
141
|
React.useEffect(function () {
|
|
103
|
-
if (!
|
|
142
|
+
if (!remoteOperations) {
|
|
104
143
|
// Let's retrieve temporary filtered rows and update globally filtered rows
|
|
105
144
|
var tmpFilteredRows = filterAndSortRows();
|
|
106
145
|
setFilteredRows(tmpFilteredRows);
|
|
@@ -114,14 +153,14 @@ var Table = function Table(_ref) {
|
|
|
114
153
|
|
|
115
154
|
setCurrentPageRows(tmpFilteredRows.slice(rowsFrom, rowsTo));
|
|
116
155
|
}
|
|
117
|
-
}, [rowsPerPage, rows, currentPage, columns, sortedColumn, sortedDirection,
|
|
156
|
+
}, [rowsPerPage, rows, currentPage, columns, sortedColumn, sortedDirection, remoteOperations]);
|
|
118
157
|
/**
|
|
119
158
|
* Takes care of remote pagination.
|
|
120
159
|
* Works only in case remote pagination is set to true.
|
|
121
160
|
*/
|
|
122
161
|
|
|
123
162
|
React.useEffect(function () {
|
|
124
|
-
if (
|
|
163
|
+
if (remoteOperations) {
|
|
125
164
|
setCurrentPageRows(rows); // Let's assign pagination values
|
|
126
165
|
|
|
127
166
|
setFrom(pagination === null || pagination === void 0 ? void 0 : pagination.from);
|
|
@@ -130,7 +169,19 @@ var Table = function Table(_ref) {
|
|
|
130
169
|
setCurrentPage(pagination === null || pagination === void 0 ? void 0 : pagination.currentPage);
|
|
131
170
|
setRowsPerPage(pagination === null || pagination === void 0 ? void 0 : pagination.rowsPerPage);
|
|
132
171
|
}
|
|
133
|
-
}, [
|
|
172
|
+
}, [remoteOperations, pagination, rows]);
|
|
173
|
+
/**
|
|
174
|
+
* Sets number of rows to display when accordion.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
React.useEffect(function () {
|
|
178
|
+
if (!accordion) return;
|
|
179
|
+
setRowsPerPage(isCollapsed ? collapsedRows || 10 : rows.length);
|
|
180
|
+
}, [rows, accordion, collapsedRows, isCollapsed]);
|
|
181
|
+
React.useEffect(function () {
|
|
182
|
+
if (!accordion) return;
|
|
183
|
+
setIsCollapsed(!!collapsed);
|
|
184
|
+
}, [accordion, collapsed]);
|
|
134
185
|
/**
|
|
135
186
|
* Filters out a rows by specific column filters and sorts them if any sorting is set.
|
|
136
187
|
* @returns Filtered and sorted rows.
|
|
@@ -214,8 +265,8 @@ var Table = function Table(_ref) {
|
|
|
214
265
|
setSortedColumn(column.key);
|
|
215
266
|
setSortedDirection('desc'); // Let's trigger remote sorting trigger function
|
|
216
267
|
|
|
217
|
-
if (
|
|
218
|
-
|
|
268
|
+
if (remoteOperations && onTriggerSortingChange) {
|
|
269
|
+
onTriggerSortingChange(column.key, 'desc');
|
|
219
270
|
}
|
|
220
271
|
} else {
|
|
221
272
|
tmpColumn.sortingDirection = 'asc'; // Update sorted column and direction
|
|
@@ -223,8 +274,8 @@ var Table = function Table(_ref) {
|
|
|
223
274
|
setSortedColumn(column.key);
|
|
224
275
|
setSortedDirection('asc'); // Let's trigger remote sorting trigger function
|
|
225
276
|
|
|
226
|
-
if (
|
|
227
|
-
|
|
277
|
+
if (remoteOperations && onTriggerSortingChange) {
|
|
278
|
+
onTriggerSortingChange(column.key, 'asc');
|
|
228
279
|
}
|
|
229
280
|
}
|
|
230
281
|
} else {
|
|
@@ -234,8 +285,8 @@ var Table = function Table(_ref) {
|
|
|
234
285
|
setSortedColumn(column.key);
|
|
235
286
|
setSortedDirection('asc'); // Let's trigger remote sorting trigger function
|
|
236
287
|
|
|
237
|
-
if (
|
|
238
|
-
|
|
288
|
+
if (remoteOperations && onTriggerSortingChange) {
|
|
289
|
+
onTriggerSortingChange(column.key, 'asc');
|
|
239
290
|
}
|
|
240
291
|
}
|
|
241
292
|
} else if (tmpColumn.sortingDirection !== undefined) {
|
|
@@ -252,10 +303,10 @@ var Table = function Table(_ref) {
|
|
|
252
303
|
|
|
253
304
|
|
|
254
305
|
var previousPage = function previousPage() {
|
|
255
|
-
if (
|
|
306
|
+
if (remoteOperations) {
|
|
256
307
|
// Let's inform parent component about page change
|
|
257
|
-
if (
|
|
258
|
-
|
|
308
|
+
if (onPreviousPageClick) {
|
|
309
|
+
onPreviousPageClick();
|
|
259
310
|
}
|
|
260
311
|
} else {
|
|
261
312
|
// Let's change the page within the component
|
|
@@ -268,10 +319,10 @@ var Table = function Table(_ref) {
|
|
|
268
319
|
|
|
269
320
|
|
|
270
321
|
var nextPage = function nextPage() {
|
|
271
|
-
if (
|
|
322
|
+
if (remoteOperations) {
|
|
272
323
|
// Let's inform parent component about page change
|
|
273
|
-
if (
|
|
274
|
-
|
|
324
|
+
if (onNextPageClick) {
|
|
325
|
+
onNextPageClick();
|
|
275
326
|
}
|
|
276
327
|
} else {
|
|
277
328
|
// Let's change the page within the component
|
|
@@ -286,10 +337,10 @@ var Table = function Table(_ref) {
|
|
|
286
337
|
|
|
287
338
|
var changeRowsPerPage = function changeRowsPerPage(value) {
|
|
288
339
|
// Let's check if we are using remote pagination
|
|
289
|
-
if (
|
|
340
|
+
if (remoteOperations) {
|
|
290
341
|
// Inform parent component about rows per page change
|
|
291
|
-
if (
|
|
292
|
-
|
|
342
|
+
if (onRowsPerPageChange) {
|
|
343
|
+
onRowsPerPageChange(value);
|
|
293
344
|
}
|
|
294
345
|
} else {
|
|
295
346
|
// Let's reset current page to 1
|
|
@@ -297,74 +348,7 @@ var Table = function Table(_ref) {
|
|
|
297
348
|
} // Let's set rows per page
|
|
298
349
|
|
|
299
350
|
|
|
300
|
-
setRowsPerPage(
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* Renders the table header.
|
|
304
|
-
*/
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
var renderHeader = function renderHeader() {
|
|
308
|
-
return /*#__PURE__*/_jsxs("thead", {
|
|
309
|
-
children: [title && /*#__PURE__*/_jsx("tr", {
|
|
310
|
-
"data-testid": "TestTableHeaderRow",
|
|
311
|
-
children: /*#__PURE__*/_jsx(TableHeaderRowCol, {
|
|
312
|
-
colSpan: columns.length,
|
|
313
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
314
|
-
children: [title, /*#__PURE__*/_jsx(MoreVertical, {
|
|
315
|
-
size: "18px",
|
|
316
|
-
color: COLORS.neutral_600
|
|
317
|
-
})]
|
|
318
|
-
})
|
|
319
|
-
})
|
|
320
|
-
}), /*#__PURE__*/_jsx("tr", {
|
|
321
|
-
"data-testid": "TestTableColumnHeaderRow",
|
|
322
|
-
children: columns.map(function (column) {
|
|
323
|
-
return /*#__PURE__*/_jsxs(TableColumnHeaderCol, {
|
|
324
|
-
onClick: function onClick() {
|
|
325
|
-
return sortTableColumn(column);
|
|
326
|
-
},
|
|
327
|
-
style: {
|
|
328
|
-
width: column.width
|
|
329
|
-
},
|
|
330
|
-
className: "".concat(column.sortable ? 'sortable' : '', " ").concat(!title ? 'no-border' : '', " ").concat(column.justify ? "justify-".concat(column.justify) : ''),
|
|
331
|
-
children: [column.name, column.sortingDirection === 'asc' ? /*#__PURE__*/_jsx(ArrowLineUp, {
|
|
332
|
-
size: "20px"
|
|
333
|
-
}) : column.sortingDirection === 'desc' ? /*#__PURE__*/_jsx(ArrowLineDown, {
|
|
334
|
-
size: "20px"
|
|
335
|
-
}) : '']
|
|
336
|
-
}, column.key);
|
|
337
|
-
})
|
|
338
|
-
})]
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
342
|
-
* Function which is called when a mouse click happens on a link to pass data to the parent component.
|
|
343
|
-
* @param row - Row in which the link is located.
|
|
344
|
-
* @param key - Key of the column for which the link is set.
|
|
345
|
-
* @param event - Click event handler.
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
var onLinkClick = function onLinkClick(row, key, event) {
|
|
350
|
-
if (linkClick) {
|
|
351
|
-
event.stopPropagation();
|
|
352
|
-
linkClick(row, key);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
/**
|
|
356
|
-
* Function which is called when a mouse click happens on an icon to pass data to the parent component.
|
|
357
|
-
* @param row - Row in which the icon is located.
|
|
358
|
-
* @param key - Key of the column for which the icon is set.
|
|
359
|
-
* @param event - Click event handler.
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
var onIconClick = function onIconClick(row, key, event) {
|
|
364
|
-
if (iconClick) {
|
|
365
|
-
event.stopPropagation();
|
|
366
|
-
iconClick(row, key);
|
|
367
|
-
}
|
|
351
|
+
setRowsPerPage(value);
|
|
368
352
|
};
|
|
369
353
|
/**
|
|
370
354
|
* Function which is called when a mouse click happens on a row to pass data to the parent component.
|
|
@@ -375,133 +359,57 @@ var Table = function Table(_ref) {
|
|
|
375
359
|
var onRowClick = function onRowClick(row) {
|
|
376
360
|
var _window, _window$getSelection;
|
|
377
361
|
|
|
378
|
-
var selectedText = (_window = window) === null || _window === void 0 ? void 0 : (_window$getSelection = _window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.toString();
|
|
362
|
+
var selectedText = (_window = window) === null || _window === void 0 ? void 0 : (_window$getSelection = _window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.toString();
|
|
379
363
|
|
|
380
|
-
if ((selectedText === null || selectedText === void 0 ? void 0 : selectedText.length) === 0 &&
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* Renders the table body.
|
|
386
|
-
*/
|
|
364
|
+
if ((selectedText === null || selectedText === void 0 ? void 0 : selectedText.length) === 0 && selectable) {
|
|
365
|
+
var value = keyExpr ? row[keyExpr] : row;
|
|
366
|
+
var currentSelection = value;
|
|
387
367
|
|
|
368
|
+
if (!!multiSelect) {
|
|
369
|
+
var existing = selected === null || selected === void 0 ? void 0 : selected.indexOf(value);
|
|
388
370
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
color: column.colorFn(row, column.key),
|
|
401
|
-
maxWidth: column.width
|
|
402
|
-
} : {
|
|
403
|
-
maxWidth: column.width
|
|
404
|
-
},
|
|
405
|
-
className: "".concat(column.shortenText && "truncate-text", " ").concat(column.justify ? "justify-".concat(column.justify) : '', " "),
|
|
406
|
-
title: column.shortenText && row[column.key],
|
|
407
|
-
children: column.isLink && row[column.key] ? /*#__PURE__*/_jsx(Button, {
|
|
408
|
-
size: Size.Small,
|
|
409
|
-
variant: "tertiary",
|
|
410
|
-
onClick: function onClick(event) {
|
|
411
|
-
return onLinkClick(row, column.key, event);
|
|
412
|
-
},
|
|
413
|
-
style: column.colorFn && {
|
|
414
|
-
color: column.colorFn(row, column.key)
|
|
415
|
-
},
|
|
416
|
-
children: row[column.key]
|
|
417
|
-
}) : column.isIcon && column.icon ? /*#__PURE__*/_jsx(IconButton, {
|
|
418
|
-
variant: "secondary",
|
|
419
|
-
shape: "circular",
|
|
420
|
-
useTransparentBackground: true,
|
|
421
|
-
action: function action(event) {
|
|
422
|
-
return onIconClick(row, column.key, event);
|
|
423
|
-
},
|
|
424
|
-
children: icons[column.icon]({
|
|
425
|
-
size: '24',
|
|
426
|
-
className: 'icon'
|
|
427
|
-
})
|
|
428
|
-
}) : column.customContent ? column.customContent(row, column.key) : row[column.key]
|
|
429
|
-
}, "row_".concat(index, "_").concat(column.key));
|
|
430
|
-
})
|
|
431
|
-
}, "row_".concat(index));
|
|
432
|
-
}) : /*#__PURE__*/_jsx(TableDataRow, {
|
|
433
|
-
className: "no-rows",
|
|
434
|
-
"data-testid": "TestTableNoDataRow",
|
|
435
|
-
children: /*#__PURE__*/_jsx(TableDataCol, {
|
|
436
|
-
colSpan: columns.length,
|
|
437
|
-
className: "center",
|
|
438
|
-
children: "There are no rows to display"
|
|
439
|
-
})
|
|
440
|
-
})
|
|
441
|
-
});
|
|
371
|
+
if (existing > -1) {
|
|
372
|
+
currentSelection = _toConsumableArray(selected);
|
|
373
|
+
currentSelection.splice(existing, 1);
|
|
374
|
+
} else {
|
|
375
|
+
currentSelection = [].concat(_toConsumableArray(selected), [currentSelection]);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
setSelected(currentSelection);
|
|
380
|
+
props.onSelectionChange && props.onSelectionChange(currentSelection);
|
|
381
|
+
}
|
|
442
382
|
};
|
|
443
383
|
/**
|
|
444
|
-
*
|
|
384
|
+
* Function which is called when user clicks checkbox to select or deselect all rows.
|
|
445
385
|
*/
|
|
446
386
|
|
|
447
387
|
|
|
448
|
-
var
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
return /*#__PURE__*/_jsx("tfoot", {
|
|
452
|
-
children: /*#__PURE__*/_jsx("tr", {
|
|
453
|
-
children: /*#__PURE__*/_jsx(TableFooterCol, {
|
|
454
|
-
colSpan: columns.length,
|
|
455
|
-
"data-testid": "TestTableFooterRow",
|
|
456
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
457
|
-
children: [/*#__PURE__*/_jsx("span", {
|
|
458
|
-
children: "Rows per page: "
|
|
459
|
-
}), /*#__PURE__*/_jsx(DropdownFilter, {
|
|
460
|
-
id: "rows-per-page",
|
|
461
|
-
list: rowsPerPageValues.map(function (x) {
|
|
462
|
-
return {
|
|
463
|
-
label: x
|
|
464
|
-
};
|
|
465
|
-
}),
|
|
466
|
-
disableSorting: true,
|
|
467
|
-
onSelect: function onSelect(value) {
|
|
468
|
-
return changeRowsPerPage(value);
|
|
469
|
-
},
|
|
470
|
-
initalValue: rowsPerPage.toString(),
|
|
471
|
-
isButton: true
|
|
472
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
473
|
-
className: "current-page-info",
|
|
474
|
-
children: [total === 0 ? 0 : from, "-", to, " of ", total]
|
|
475
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
476
|
-
className: "controls",
|
|
477
|
-
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
478
|
-
variant: "secondary",
|
|
479
|
-
shape: "circular",
|
|
480
|
-
action: function action() {
|
|
481
|
-
return previousPage();
|
|
482
|
-
},
|
|
483
|
-
disabled: from === 1,
|
|
484
|
-
children: /*#__PURE__*/_jsx(ChevronLeft, {
|
|
485
|
-
size: "24",
|
|
486
|
-
color: COLORS.neutral_600
|
|
487
|
-
})
|
|
488
|
-
}), /*#__PURE__*/_jsx(IconButton, {
|
|
489
|
-
variant: "secondary",
|
|
490
|
-
shape: "circular",
|
|
491
|
-
action: function action() {
|
|
492
|
-
return nextPage();
|
|
493
|
-
},
|
|
494
|
-
disabled: to === total,
|
|
495
|
-
children: /*#__PURE__*/_jsx(ChevronRight, {
|
|
496
|
-
size: "24",
|
|
497
|
-
color: COLORS.neutral_600
|
|
498
|
-
})
|
|
499
|
-
})]
|
|
500
|
-
})]
|
|
501
|
-
})
|
|
502
|
-
})
|
|
503
|
-
})
|
|
388
|
+
var onSelectAllClick = function onSelectAllClick() {
|
|
389
|
+
var currentList = currentPageRows.map(function (row) {
|
|
390
|
+
return keyExpr ? row[keyExpr] : row;
|
|
504
391
|
});
|
|
392
|
+
|
|
393
|
+
switch (selectAllState) {
|
|
394
|
+
case 'all':
|
|
395
|
+
setSelected(_toConsumableArray(selected).filter(function (item) {
|
|
396
|
+
return !currentList.includes(item);
|
|
397
|
+
}));
|
|
398
|
+
setSelectAllState('none');
|
|
399
|
+
break;
|
|
400
|
+
|
|
401
|
+
case 'none':
|
|
402
|
+
setSelected([].concat(_toConsumableArray(selected), _toConsumableArray(currentList)));
|
|
403
|
+
setSelectAllState('all');
|
|
404
|
+
break;
|
|
405
|
+
|
|
406
|
+
case 'some':
|
|
407
|
+
setSelected([].concat(_toConsumableArray(selected), _toConsumableArray(currentList.filter(function (item) {
|
|
408
|
+
return !selected.includes(item);
|
|
409
|
+
}))));
|
|
410
|
+
setSelectAllState('all');
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
505
413
|
};
|
|
506
414
|
/**
|
|
507
415
|
* Return Table component.
|
|
@@ -509,12 +417,31 @@ var Table = function Table(_ref) {
|
|
|
509
417
|
|
|
510
418
|
|
|
511
419
|
return /*#__PURE__*/_jsxs(TableWrapper, {
|
|
512
|
-
children: [/*#__PURE__*/_jsxs(
|
|
420
|
+
children: [/*#__PURE__*/_jsxs(StyledTable, {
|
|
513
421
|
cellPadding: "0",
|
|
514
422
|
cellSpacing: "0",
|
|
515
423
|
"data-testid": "TestTable",
|
|
516
|
-
|
|
517
|
-
|
|
424
|
+
className: 'table',
|
|
425
|
+
children: [/*#__PURE__*/_jsx(TableHeader, _objectSpread(_objectSpread({}, props), {}, {
|
|
426
|
+
sortByColumn: sortTableColumn,
|
|
427
|
+
onSelectAllClick: onSelectAllClick,
|
|
428
|
+
selectAllState: selectAllState
|
|
429
|
+
})), /*#__PURE__*/_jsx(TableBody, _objectSpread(_objectSpread({}, props), {}, {
|
|
430
|
+
currentPageRows: currentPageRows,
|
|
431
|
+
selected: selected,
|
|
432
|
+
onRowClick: onRowClick
|
|
433
|
+
})), /*#__PURE__*/_jsx(TableFooter, _objectSpread(_objectSpread({}, props), {}, {
|
|
434
|
+
onRowsPerPageChange: changeRowsPerPage,
|
|
435
|
+
rowsPerPage: rowsPerPage,
|
|
436
|
+
setIsCollapsed: setIsCollapsed,
|
|
437
|
+
isCollapsed: isCollapsed,
|
|
438
|
+
from: from,
|
|
439
|
+
to: to,
|
|
440
|
+
total: total,
|
|
441
|
+
nextPage: nextPage,
|
|
442
|
+
prevPage: previousPage
|
|
443
|
+
}))]
|
|
444
|
+
}), showLoadingIndicator && /*#__PURE__*/_jsx(StyledTableSpinner, {
|
|
518
445
|
children: /*#__PURE__*/_jsx(LoadingIndicator, {
|
|
519
446
|
size: Size.Medium,
|
|
520
447
|
color: "#ffffff"
|