@rhc-shared-components/packages-table 1.0.3 → 1.0.5
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/components/ExcludedPackagesTable.d.ts +7 -6
- package/dist/components/FilterInput.d.ts +7 -6
- package/dist/components/FilterableTable.d.ts +19 -19
- package/dist/components/Select.d.ts +10 -9
- package/dist/components/ToggleGroup.d.ts +11 -10
- package/dist/components/VulnerabilitiesTable.d.ts +8 -7
- package/dist/index.d.ts +15 -14
- package/dist/index.js +504 -707
- package/dist/index.modern.js +299 -456
- package/dist/index.test.d.ts +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -79
package/dist/index.modern.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useEffect, useCallback, cloneElement } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Toolbar, ToolbarContent, ToolbarItem, Bullseye, Title, Spinner, EmptyState, EmptyStateHeader, EmptyStateIcon, Pagination, SearchInput, ToggleGroup as ToggleGroup$1, ToggleGroupItem, Tabs, Tab } from '@patternfly/react-core';
|
|
4
4
|
import { sortBy, uniqueId } from 'lodash';
|
|
5
|
+
import { setTabIndex, handleArrows } from '@patternfly/react-core/dist/esm/helpers/KeyboardHandler';
|
|
6
|
+
import { useOUIAProps } from '@patternfly/react-core/dist/esm/helpers/OUIA/ouia';
|
|
5
7
|
import { useOUIAProps as useOUIAProps$1 } from '@patternfly/react-core/dist/esm/helpers';
|
|
6
8
|
import mergeWith from 'lodash/mergeWith';
|
|
7
9
|
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
@@ -15,7 +17,17 @@ import { Checkbox } from '@patternfly/react-core/dist/esm/components/Checkbox';
|
|
|
15
17
|
import { Select, SelectOption } from '@patternfly/react-core/deprecated';
|
|
16
18
|
import { format } from 'date-fns';
|
|
17
19
|
|
|
18
|
-
var css_248z = ".vulnerabilities-table .impact-icon {\n font-size: 1.5rem;\n padding-right: 0.5rem;\n}\n.vulnerabilities-table .impact-icon.color-critical {\n color: #a30000;\n}\n.vulnerabilities-table .impact-icon.color-important {\n color: #ec7a08;\n}\n.vulnerabilities-table .impact-icon.color-moderate {\n color: #f5c12e;\n}\n.vulnerabilities-table .impact-icon.color-low {\n color: #777;\n}\n.vulnerabilities-table__affected-packages-cell {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n.vulnerabilities-table__impact-cell {\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n}\n\n.filterable-table {\n padding-bottom: var(--pf-v5-global--spacer--lg);\n}\n.filterable-table__bottom-pagination[class] {\n margin-top: 1rem;\n}\n.filterable-table .pf-v5-c-
|
|
20
|
+
var css_248z = ".vulnerabilities-table .impact-icon {\n font-size: 1.5rem;\n padding-right: 0.5rem;\n}\n.vulnerabilities-table .impact-icon.color-critical {\n color: #a30000;\n}\n.vulnerabilities-table .impact-icon.color-important {\n color: #ec7a08;\n}\n.vulnerabilities-table .impact-icon.color-moderate {\n color: #f5c12e;\n}\n.vulnerabilities-table .impact-icon.color-low {\n color: #777;\n}\n.vulnerabilities-table__affected-packages-cell {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n.vulnerabilities-table__impact-cell {\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n}\n\n.filterable-table {\n padding-bottom: var(--pf-v5-global--spacer--lg);\n}\n.filterable-table__bottom-pagination[class] {\n margin-top: 1rem;\n}\n.filterable-table .pf-v5-c-toolbar__content {\n --pf-v5-c-toolbar__content--PaddingRight: 0;\n --pf-v5-c-toolbar__content--PaddingLeft: 0;\n}\n.filterable-table .pf-v5-c-input-group__text {\n --pf-v5-c-input-group__text--PaddingRight: 0;\n}\n.filterable-table .pf-v5-c-pagination.pf-m-bottom {\n --pf-v5-c-pagination--m-bottom--md--PaddingRight: 0;\n}\n\n.packages-table .pf-v5-c-tabs__item > button {\n padding: 1rem 1.5rem;\n}\n.packages-table__excluded-packages-disclaimer {\n margin: 1rem 0 0 0.5rem;\n}\n\n.filter-input {\n width: 18rem;\n}";
|
|
21
|
+
|
|
22
|
+
function _extends() {
|
|
23
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
24
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
25
|
+
var t = arguments[e];
|
|
26
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
27
|
+
}
|
|
28
|
+
return n;
|
|
29
|
+
}, _extends.apply(null, arguments);
|
|
30
|
+
}
|
|
19
31
|
|
|
20
32
|
/******************************************************************************
|
|
21
33
|
Copyright (c) Microsoft Corporation.
|
|
@@ -31,52 +43,23 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
31
43
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
32
44
|
PERFORMANCE OF THIS SOFTWARE.
|
|
33
45
|
***************************************************************************** */
|
|
34
|
-
function __rest
|
|
46
|
+
function __rest(s, e) {
|
|
35
47
|
var t = {};
|
|
36
|
-
|
|
37
48
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
38
|
-
|
|
39
49
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
50
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
41
51
|
}
|
|
42
52
|
return t;
|
|
43
53
|
}
|
|
44
|
-
|
|
45
54
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
55
|
var e = new Error(message);
|
|
47
56
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
57
|
};
|
|
49
58
|
|
|
50
|
-
/*! *****************************************************************************
|
|
51
|
-
Copyright (c) Microsoft Corporation.
|
|
52
|
-
|
|
53
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
54
|
-
purpose with or without fee is hereby granted.
|
|
55
|
-
|
|
56
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
57
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
58
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
59
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
60
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
61
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
62
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
63
|
-
***************************************************************************** */
|
|
64
|
-
function __rest(s, e) {
|
|
65
|
-
var t = {};
|
|
66
|
-
|
|
67
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
68
|
-
|
|
69
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
71
|
-
}
|
|
72
|
-
return t;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
59
|
let currentId = 0;
|
|
76
60
|
/**
|
|
77
61
|
* Factory to create Icon class components for consumers
|
|
78
62
|
*/
|
|
79
|
-
|
|
80
63
|
function createIcon({
|
|
81
64
|
name,
|
|
82
65
|
xOffset = 0,
|
|
@@ -86,21 +69,18 @@ function createIcon({
|
|
|
86
69
|
svgPath
|
|
87
70
|
}) {
|
|
88
71
|
var _a;
|
|
89
|
-
|
|
90
72
|
return _a = class SVGIcon extends React.Component {
|
|
91
73
|
constructor() {
|
|
92
74
|
super(...arguments);
|
|
93
75
|
this.id = `icon-title-${currentId++}`;
|
|
94
76
|
}
|
|
95
|
-
|
|
96
77
|
render() {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
const _b = this.props,
|
|
79
|
+
{
|
|
80
|
+
title,
|
|
81
|
+
className
|
|
82
|
+
} = _b,
|
|
83
|
+
props = __rest(_b, ["title", "className"]);
|
|
104
84
|
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
105
85
|
const hasTitle = Boolean(title);
|
|
106
86
|
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
@@ -119,7 +99,6 @@ function createIcon({
|
|
|
119
99
|
d: svgPath
|
|
120
100
|
}));
|
|
121
101
|
}
|
|
122
|
-
|
|
123
102
|
}, _a.displayName = name, _a;
|
|
124
103
|
}
|
|
125
104
|
|
|
@@ -136,46 +115,42 @@ var EllipsisVIcon$1 = EllipsisVIcon;
|
|
|
136
115
|
|
|
137
116
|
const ActionsColumnBase = _a => {
|
|
138
117
|
var {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
items,
|
|
119
|
+
isDisabled,
|
|
120
|
+
rowData,
|
|
121
|
+
extraData,
|
|
122
|
+
actionsToggle,
|
|
123
|
+
popperProps = {
|
|
124
|
+
position: 'end',
|
|
125
|
+
direction: 'down'
|
|
126
|
+
},
|
|
127
|
+
innerRef,
|
|
128
|
+
firstActionItemRef,
|
|
129
|
+
isOnOpenChangeDisabled = false
|
|
130
|
+
} = _a,
|
|
131
|
+
props = __rest(_a, ["items", "isDisabled", "rowData", "extraData", "actionsToggle", "popperProps", "innerRef", "firstActionItemRef", "isOnOpenChangeDisabled"]);
|
|
154
132
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
155
|
-
|
|
156
133
|
const onToggle = () => {
|
|
157
134
|
setIsOpen(!isOpen);
|
|
158
135
|
};
|
|
159
|
-
|
|
160
136
|
const onActionClick = (event, onClick) => {
|
|
161
137
|
// Only prevent default if onClick is provided. This allows href support.
|
|
162
138
|
if (onClick) {
|
|
163
|
-
event.preventDefault();
|
|
164
|
-
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
// tslint:disable-next-line:no-unused-expression
|
|
165
141
|
onClick(event, extraData && extraData.rowIndex, rowData, extraData);
|
|
166
142
|
}
|
|
167
143
|
};
|
|
168
|
-
|
|
169
|
-
|
|
144
|
+
return React.createElement(React.Fragment, null, items.filter(item => item.isOutsideDropdown)
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
170
146
|
.map((_a, key) => {
|
|
171
147
|
var {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
148
|
+
title,
|
|
149
|
+
itemKey,
|
|
150
|
+
onClick,
|
|
151
|
+
isOutsideDropdown
|
|
152
|
+
} = _a,
|
|
153
|
+
props = __rest(_a, ["title", "itemKey", "onClick", "isOutsideDropdown"]);
|
|
179
154
|
return typeof title === 'string' ? React.createElement(Button, Object.assign({
|
|
180
155
|
onClick: event => onActionClick(event, onClick)
|
|
181
156
|
}, props, {
|
|
@@ -208,22 +183,20 @@ const ActionsColumnBase = _a => {
|
|
|
208
183
|
popperProps: popperProps
|
|
209
184
|
}), React.createElement(DropdownList, null, items.filter(item => !item.isOutsideDropdown).map((_a, index) => {
|
|
210
185
|
var {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
186
|
+
title,
|
|
187
|
+
itemKey,
|
|
188
|
+
onClick,
|
|
189
|
+
tooltipProps,
|
|
190
|
+
isSeparator,
|
|
191
|
+
shouldCloseOnClick = true
|
|
192
|
+
} = _a,
|
|
193
|
+
props = __rest(_a, ["title", "itemKey", "onClick", "tooltipProps", "isSeparator", "shouldCloseOnClick"]);
|
|
220
194
|
if (isSeparator) {
|
|
221
195
|
return React.createElement(Divider, {
|
|
222
196
|
key: itemKey || index,
|
|
223
197
|
"data-key": itemKey || index
|
|
224
198
|
});
|
|
225
199
|
}
|
|
226
|
-
|
|
227
200
|
const item = React.createElement(DropdownItem, Object.assign({
|
|
228
201
|
onClick: event => {
|
|
229
202
|
onActionClick(event, onClick);
|
|
@@ -234,7 +207,6 @@ const ActionsColumnBase = _a => {
|
|
|
234
207
|
"data-key": itemKey || index,
|
|
235
208
|
ref: index === 0 ? firstActionItemRef : undefined
|
|
236
209
|
}), title);
|
|
237
|
-
|
|
238
210
|
if (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content) {
|
|
239
211
|
return React.createElement(Tooltip, Object.assign({
|
|
240
212
|
key: itemKey || index
|
|
@@ -244,7 +216,6 @@ const ActionsColumnBase = _a => {
|
|
|
244
216
|
}
|
|
245
217
|
}))));
|
|
246
218
|
};
|
|
247
|
-
|
|
248
219
|
const ActionsColumn = React.forwardRef((props, ref) => React.createElement(ActionsColumnBase, Object.assign({}, props, {
|
|
249
220
|
innerRef: ref
|
|
250
221
|
})));
|
|
@@ -271,12 +242,10 @@ function css(...args) {
|
|
|
271
242
|
const hasOwn = {}.hasOwnProperty;
|
|
272
243
|
args.filter(Boolean).forEach(arg => {
|
|
273
244
|
const argType = typeof arg;
|
|
274
|
-
|
|
275
245
|
if (argType === 'string' || argType === 'number') {
|
|
276
246
|
classes.push(arg);
|
|
277
247
|
} else if (Array.isArray(arg) && arg.length) {
|
|
278
248
|
const inner = css(...arg);
|
|
279
|
-
|
|
280
249
|
if (inner) {
|
|
281
250
|
classes.push(inner);
|
|
282
251
|
}
|
|
@@ -384,13 +353,12 @@ var styles$1 = {
|
|
|
384
353
|
|
|
385
354
|
const CollapseColumn = _a => {
|
|
386
355
|
var {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
356
|
+
className = '',
|
|
357
|
+
children = null,
|
|
358
|
+
isOpen,
|
|
359
|
+
onToggle
|
|
360
|
+
} = _a,
|
|
361
|
+
props = __rest(_a, ["className", "children", "isOpen", "onToggle"]);
|
|
394
362
|
return React.createElement(React.Fragment, null, isOpen !== undefined && React.createElement(Button, Object.assign({
|
|
395
363
|
className: css(className, isOpen && styles$1.modifiers.expanded)
|
|
396
364
|
}, props, {
|
|
@@ -417,13 +385,12 @@ var GripVerticalIcon$1 = GripVerticalIcon;
|
|
|
417
385
|
|
|
418
386
|
const DraggableCell = _a => {
|
|
419
387
|
var {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
388
|
+
className,
|
|
389
|
+
onClick,
|
|
390
|
+
'aria-label': ariaLabel,
|
|
391
|
+
id
|
|
392
|
+
} = _a,
|
|
393
|
+
props = __rest(_a, ["className", "onClick", 'aria-label', "id"]);
|
|
427
394
|
return React.createElement(Button, Object.assign({
|
|
428
395
|
id: id,
|
|
429
396
|
variant: "plain",
|
|
@@ -472,14 +439,11 @@ const HelpIcon = createIcon(HelpIconConfig);
|
|
|
472
439
|
var HelpIcon$1 = HelpIcon;
|
|
473
440
|
|
|
474
441
|
var TableTextVariant;
|
|
475
|
-
|
|
476
442
|
(function (TableTextVariant) {
|
|
477
443
|
TableTextVariant["div"] = "div";
|
|
478
444
|
TableTextVariant["nav"] = "nav";
|
|
479
445
|
})(TableTextVariant || (TableTextVariant = {}));
|
|
480
|
-
|
|
481
446
|
var WrapModifier;
|
|
482
|
-
|
|
483
447
|
(function (WrapModifier) {
|
|
484
448
|
WrapModifier["wrap"] = "wrap";
|
|
485
449
|
WrapModifier["nowrap"] = "nowrap";
|
|
@@ -487,35 +451,30 @@ var WrapModifier;
|
|
|
487
451
|
WrapModifier["breakWord"] = "breakWord";
|
|
488
452
|
WrapModifier["fitContent"] = "fitContent";
|
|
489
453
|
})(WrapModifier || (WrapModifier = {}));
|
|
490
|
-
|
|
491
454
|
const TableText = _a => {
|
|
492
455
|
var {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
456
|
+
children = null,
|
|
457
|
+
className = '',
|
|
458
|
+
variant = 'span',
|
|
459
|
+
wrapModifier = null,
|
|
460
|
+
tooltip: tooltipProp = '',
|
|
461
|
+
tooltipProps = {},
|
|
462
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
463
|
+
focused = false,
|
|
464
|
+
tooltipHasDefaultBehavior = false
|
|
465
|
+
} = _a,
|
|
466
|
+
props = __rest(_a, ["children", "className", "variant", "wrapModifier", "tooltip", "tooltipProps", "onMouseEnter", "focused", "tooltipHasDefaultBehavior"]);
|
|
505
467
|
const Component = variant;
|
|
506
468
|
const textRef = React.createRef();
|
|
507
469
|
const [tooltip, setTooltip] = React.useState(tooltipProp);
|
|
508
|
-
|
|
509
470
|
const onMouseEnter = event => {
|
|
510
471
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
511
472
|
setTooltip(tooltipProp || event.target.innerText);
|
|
512
473
|
} else {
|
|
513
474
|
setTooltip('');
|
|
514
475
|
}
|
|
515
|
-
|
|
516
476
|
onMouseEnterProp(event);
|
|
517
477
|
};
|
|
518
|
-
|
|
519
478
|
const onFocus = element => {
|
|
520
479
|
if (element.offsetWidth < element.scrollWidth) {
|
|
521
480
|
setTooltip(tooltipProp || element.innerText);
|
|
@@ -523,7 +482,6 @@ const TableText = _a => {
|
|
|
523
482
|
setTooltip('');
|
|
524
483
|
}
|
|
525
484
|
};
|
|
526
|
-
|
|
527
485
|
const text = React.createElement(Component, Object.assign({
|
|
528
486
|
ref: textRef,
|
|
529
487
|
onMouseEnter: !tooltipHasDefaultBehavior ? onMouseEnter : undefined,
|
|
@@ -641,24 +599,21 @@ var treeViewStyles = {
|
|
|
641
599
|
};
|
|
642
600
|
|
|
643
601
|
var RowSelectVariant;
|
|
644
|
-
|
|
645
602
|
(function (RowSelectVariant) {
|
|
646
603
|
RowSelectVariant["radio"] = "radio";
|
|
647
604
|
RowSelectVariant["checkbox"] = "checkbox";
|
|
648
605
|
})(RowSelectVariant || (RowSelectVariant = {}));
|
|
649
|
-
|
|
650
606
|
const SelectColumn = _a => {
|
|
651
607
|
var {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
608
|
+
children = null,
|
|
609
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
610
|
+
className,
|
|
611
|
+
onSelect = null,
|
|
612
|
+
selectVariant,
|
|
613
|
+
tooltip,
|
|
614
|
+
tooltipProps
|
|
615
|
+
} = _a,
|
|
616
|
+
props = __rest(_a, ["children", "className", "onSelect", "selectVariant", "tooltip", "tooltipProps"]);
|
|
662
617
|
const inputRef = React.createRef();
|
|
663
618
|
const content = React.createElement(React.Fragment, null, React.createElement("label", null, React.createElement("input", Object.assign({}, props, {
|
|
664
619
|
ref: inputRef,
|
|
@@ -707,25 +662,21 @@ const selectable = (label, {
|
|
|
707
662
|
column,
|
|
708
663
|
property
|
|
709
664
|
};
|
|
710
|
-
|
|
711
665
|
if (rowData && rowData.hasOwnProperty('parent') && !rowData.showSelect && !rowData.fullWidth) {
|
|
712
666
|
return {
|
|
713
667
|
component: 'td',
|
|
714
668
|
isVisible: true
|
|
715
669
|
};
|
|
716
670
|
}
|
|
717
|
-
|
|
718
671
|
const rowId = rowIndex !== undefined ? rowIndex : -1;
|
|
719
672
|
/**
|
|
720
673
|
* @param {React.FormEvent} event - React form event
|
|
721
674
|
*/
|
|
722
|
-
|
|
723
675
|
function selectClick(event) {
|
|
724
|
-
const selected = rowIndex === undefined ? event.currentTarget.checked : rowData && !rowData.selected;
|
|
725
|
-
|
|
676
|
+
const selected = rowIndex === undefined ? event.currentTarget.checked : rowData && !rowData.selected;
|
|
677
|
+
// tslint:disable-next-line:no-unused-expression
|
|
726
678
|
onSelect && onSelect(event, selected, rowId, rowData, extraData);
|
|
727
679
|
}
|
|
728
|
-
|
|
729
680
|
const customProps = Object.assign(Object.assign(Object.assign({}, rowId !== -1 ? {
|
|
730
681
|
checked: rowData && !!rowData.selected,
|
|
731
682
|
'aria-label': `Select row ${rowIndex}`
|
|
@@ -739,13 +690,11 @@ const selectable = (label, {
|
|
|
739
690
|
disabled: true
|
|
740
691
|
});
|
|
741
692
|
let selectName = 'check-all';
|
|
742
|
-
|
|
743
693
|
if (rowId !== -1 && selectVariant === RowSelectVariant.checkbox) {
|
|
744
694
|
selectName = `checkrow${rowIndex}`;
|
|
745
695
|
} else if (rowId !== -1) {
|
|
746
696
|
selectName = 'radioGroup';
|
|
747
697
|
}
|
|
748
|
-
|
|
749
698
|
return {
|
|
750
699
|
className: css(styles$1.tableCheck),
|
|
751
700
|
component: rowId !== -1 ? 'td' : 'th',
|
|
@@ -793,35 +742,30 @@ const ArrowsAltVIcon = createIcon(ArrowsAltVIconConfig);
|
|
|
793
742
|
var ArrowsAltVIcon$1 = ArrowsAltVIcon;
|
|
794
743
|
|
|
795
744
|
var SortByDirection;
|
|
796
|
-
|
|
797
745
|
(function (SortByDirection) {
|
|
798
746
|
SortByDirection["asc"] = "asc";
|
|
799
747
|
SortByDirection["desc"] = "desc";
|
|
800
748
|
})(SortByDirection || (SortByDirection = {}));
|
|
801
|
-
|
|
802
749
|
const SortColumn = _a => {
|
|
803
750
|
var {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
751
|
+
children = null,
|
|
752
|
+
className = '',
|
|
753
|
+
isSortedBy = false,
|
|
754
|
+
onSort = null,
|
|
755
|
+
sortDirection = '',
|
|
756
|
+
type = 'button',
|
|
757
|
+
tooltip,
|
|
758
|
+
tooltipProps,
|
|
759
|
+
tooltipHasDefaultBehavior
|
|
760
|
+
} = _a,
|
|
761
|
+
props = __rest(_a, ["children", "className", "isSortedBy", "onSort", "sortDirection", "type", "tooltip", "tooltipProps", "tooltipHasDefaultBehavior"]);
|
|
816
762
|
let SortedByIcon;
|
|
817
763
|
const [focused, setFocused] = React.useState(false);
|
|
818
|
-
|
|
819
764
|
if (isSortedBy) {
|
|
820
765
|
SortedByIcon = sortDirection === SortByDirection.asc ? LongArrowAltUpIcon$1 : LongArrowAltDownIcon$1;
|
|
821
766
|
} else {
|
|
822
767
|
SortedByIcon = ArrowsAltVIcon$1;
|
|
823
768
|
}
|
|
824
|
-
|
|
825
769
|
return React.createElement("button", Object.assign({}, props, {
|
|
826
770
|
type: type,
|
|
827
771
|
className: css(className, styles$1.tableButton),
|
|
@@ -893,23 +837,21 @@ const sortable = (label, {
|
|
|
893
837
|
/**
|
|
894
838
|
* @param {React.MouseEvent} event - React mouse event
|
|
895
839
|
*/
|
|
896
|
-
|
|
897
840
|
function sortClicked(event) {
|
|
898
841
|
let reversedDirection;
|
|
899
|
-
|
|
900
842
|
if (!isSortedBy) {
|
|
901
843
|
reversedDirection = sortBy.defaultDirection ? sortBy.defaultDirection : SortByDirection.asc;
|
|
902
844
|
} else {
|
|
903
845
|
reversedDirection = sortBy.direction === SortByDirection.asc ? SortByDirection.desc : SortByDirection.asc;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
846
|
+
}
|
|
847
|
+
// tslint:disable-next-line:no-unused-expression
|
|
907
848
|
onSort && onSort(event, columnIndex, reversedDirection, extraData);
|
|
908
849
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
'aria-sort':
|
|
850
|
+
return Object.assign(Object.assign({
|
|
851
|
+
className: css(styles$1.tableSort, isSortedBy && styles$1.modifiers.selected, className)
|
|
852
|
+
}, isSortedBy && {
|
|
853
|
+
'aria-sort': `${sortBy.direction}ending`
|
|
854
|
+
}), {
|
|
913
855
|
children: React.createElement(SortColumn, {
|
|
914
856
|
isSortedBy: isSortedBy,
|
|
915
857
|
sortDirection: isSortedBy ? sortBy.direction : '',
|
|
@@ -919,11 +861,10 @@ const sortable = (label, {
|
|
|
919
861
|
tooltipProps: tooltipProps,
|
|
920
862
|
tooltipHasDefaultBehavior: tooltipHasDefaultBehavior
|
|
921
863
|
}, label)
|
|
922
|
-
};
|
|
864
|
+
});
|
|
923
865
|
};
|
|
924
866
|
|
|
925
867
|
const resolveOrDefault = (resolver, defaultValue, rowData, extraData) => typeof resolver === 'function' ? resolver(rowData, extraData) : defaultValue;
|
|
926
|
-
|
|
927
868
|
const cellActions = (actions, actionResolver, areActionsDisabled) => (label, {
|
|
928
869
|
rowData,
|
|
929
870
|
column,
|
|
@@ -965,12 +906,10 @@ const cellActions = (actions, actionResolver, areActionsDisabled) => (label, {
|
|
|
965
906
|
};
|
|
966
907
|
|
|
967
908
|
const camelize = s => s.toUpperCase().replace('-', '').replace('_', '');
|
|
968
|
-
|
|
969
909
|
const toCamel = s => s.replace(/([-_][a-z])/gi, camelize);
|
|
970
910
|
/**
|
|
971
911
|
* @param {string} input - String to capitalize
|
|
972
912
|
*/
|
|
973
|
-
|
|
974
913
|
function capitalize(input) {
|
|
975
914
|
return input[0].toUpperCase() + input.substring(1);
|
|
976
915
|
}
|
|
@@ -1012,13 +951,11 @@ const collapsible = (value, {
|
|
|
1012
951
|
/**
|
|
1013
952
|
* @param {React.MouseEvent} event - Mouse event
|
|
1014
953
|
*/
|
|
1015
|
-
|
|
1016
954
|
function onToggle(event) {
|
|
1017
|
-
const open = rowData ? !rowData.isOpen : !allRowsExpanded;
|
|
1018
|
-
|
|
955
|
+
const open = rowData ? !rowData.isOpen : !allRowsExpanded;
|
|
956
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1019
957
|
onCollapse && onCollapse(event, rowIndex, open, rowData, extraData);
|
|
1020
958
|
}
|
|
1021
|
-
|
|
1022
959
|
return {
|
|
1023
960
|
className: ((rowData === null || rowData === void 0 ? void 0 : rowData.isOpen) !== undefined || rowId === -1) && css(styles$1.tableToggle),
|
|
1024
961
|
isVisible: !(rowData === null || rowData === void 0 ? void 0 : rowData.fullWidth),
|
|
@@ -1040,7 +977,6 @@ const compoundExpand = (value, {
|
|
|
1040
977
|
if (!value) {
|
|
1041
978
|
return null;
|
|
1042
979
|
}
|
|
1043
|
-
|
|
1044
980
|
const {
|
|
1045
981
|
title,
|
|
1046
982
|
props
|
|
@@ -1060,12 +996,10 @@ const compoundExpand = (value, {
|
|
|
1060
996
|
/**
|
|
1061
997
|
* @param {React.MouseEvent} event - Mouse event
|
|
1062
998
|
*/
|
|
1063
|
-
|
|
1064
999
|
function onToggle(event) {
|
|
1065
1000
|
// tslint:disable-next-line:no-unused-expression
|
|
1066
1001
|
onExpand && onExpand(event, rowIndex, columnIndex, props.isOpen, rowData, extraData);
|
|
1067
1002
|
}
|
|
1068
|
-
|
|
1069
1003
|
return {
|
|
1070
1004
|
className: css(styles$1.tableCompoundExpansionToggle, props.isOpen && styles$1.modifiers.expanded),
|
|
1071
1005
|
children: props.isOpen !== undefined && React.createElement("button", {
|
|
@@ -1113,19 +1047,17 @@ const info = ({
|
|
|
1113
1047
|
className: className
|
|
1114
1048
|
}, value)
|
|
1115
1049
|
});
|
|
1116
|
-
|
|
1117
1050
|
return infoObj;
|
|
1118
1051
|
};
|
|
1119
1052
|
|
|
1120
1053
|
const FavoritesCell = _a => {
|
|
1121
1054
|
var {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1055
|
+
className = '',
|
|
1056
|
+
onFavorite,
|
|
1057
|
+
isFavorited,
|
|
1058
|
+
rowIndex
|
|
1059
|
+
} = _a,
|
|
1060
|
+
props = __rest(_a, ["className", "onFavorite", "isFavorited", "rowIndex"]);
|
|
1129
1061
|
const ariaProps = rowIndex === undefined ? {} : {
|
|
1130
1062
|
id: `favorites-button-${rowIndex}`,
|
|
1131
1063
|
'aria-labelledby': `favorites-button-${rowIndex}`
|
|
@@ -1159,8 +1091,8 @@ const favoritable = (value, {
|
|
|
1159
1091
|
columnIndex,
|
|
1160
1092
|
column,
|
|
1161
1093
|
property
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1094
|
+
};
|
|
1095
|
+
// this is a child row which should not display the favorites icon
|
|
1164
1096
|
if (rowData && rowData.hasOwnProperty('parent') && !rowData.fullWidth) {
|
|
1165
1097
|
return {
|
|
1166
1098
|
component: 'td',
|
|
@@ -1170,13 +1102,10 @@ const favoritable = (value, {
|
|
|
1170
1102
|
/**
|
|
1171
1103
|
* @param {React.MouseEvent} event - Mouse event
|
|
1172
1104
|
*/
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
1105
|
function favoritesClick(event) {
|
|
1176
1106
|
// tslint:disable-next-line:no-unused-expression
|
|
1177
1107
|
onFavorite && onFavorite(event, rowData && !rowData.favorited, rowIndex, rowData, extraData);
|
|
1178
1108
|
}
|
|
1179
|
-
|
|
1180
1109
|
const additionalProps = rowData.favoritesProps || {};
|
|
1181
1110
|
return {
|
|
1182
1111
|
className: css(styles$1.tableFavorite, rowData && rowData.favorited && styles$1.modifiers.favorited),
|
|
@@ -1227,11 +1156,9 @@ const treeRow = (onCollapse, onCheckChange, onToggleRowDetails) => (value, {
|
|
|
1227
1156
|
className: styles$1.tableText,
|
|
1228
1157
|
key: "table-text"
|
|
1229
1158
|
}, content));
|
|
1230
|
-
|
|
1231
1159
|
const onChange = (isChecked, event) => {
|
|
1232
1160
|
onCheckChange(event, isChecked, rowIndex, content, rowData);
|
|
1233
1161
|
};
|
|
1234
|
-
|
|
1235
1162
|
return {
|
|
1236
1163
|
component: 'th',
|
|
1237
1164
|
className: treeViewStyles.tableTreeViewTitleCell,
|
|
@@ -1277,7 +1204,6 @@ const treeRow = (onCollapse, onCheckChange, onToggleRowDetails) => (value, {
|
|
|
1277
1204
|
};
|
|
1278
1205
|
|
|
1279
1206
|
var TableGridBreakpoint;
|
|
1280
|
-
|
|
1281
1207
|
(function (TableGridBreakpoint) {
|
|
1282
1208
|
TableGridBreakpoint["none"] = "";
|
|
1283
1209
|
TableGridBreakpoint["grid"] = "grid";
|
|
@@ -1286,9 +1212,7 @@ var TableGridBreakpoint;
|
|
|
1286
1212
|
TableGridBreakpoint["gridXl"] = "grid-xl";
|
|
1287
1213
|
TableGridBreakpoint["grid2xl"] = "grid-2xl";
|
|
1288
1214
|
})(TableGridBreakpoint || (TableGridBreakpoint = {}));
|
|
1289
|
-
|
|
1290
1215
|
var TableVariant;
|
|
1291
|
-
|
|
1292
1216
|
(function (TableVariant) {
|
|
1293
1217
|
TableVariant["compact"] = "compact";
|
|
1294
1218
|
})(TableVariant || (TableVariant = {}));
|
|
@@ -1296,45 +1220,41 @@ var TableVariant;
|
|
|
1296
1220
|
const TableContext = React.createContext({
|
|
1297
1221
|
registerSelectableRow: () => {}
|
|
1298
1222
|
});
|
|
1299
|
-
|
|
1300
1223
|
const TableBase = _a => {
|
|
1301
1224
|
var _b, _c;
|
|
1302
|
-
|
|
1303
1225
|
var {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1226
|
+
children,
|
|
1227
|
+
className,
|
|
1228
|
+
variant,
|
|
1229
|
+
borders = true,
|
|
1230
|
+
isStickyHeader = false,
|
|
1231
|
+
gridBreakPoint = TableGridBreakpoint.gridMd,
|
|
1232
|
+
'aria-label': ariaLabel,
|
|
1233
|
+
role = 'grid',
|
|
1234
|
+
innerRef,
|
|
1235
|
+
ouiaId,
|
|
1236
|
+
ouiaSafe = true,
|
|
1237
|
+
isTreeTable = false,
|
|
1238
|
+
isNested = false,
|
|
1239
|
+
isStriped = false,
|
|
1240
|
+
isExpandable = false,
|
|
1241
|
+
hasNoInset = false,
|
|
1242
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1243
|
+
nestedHeaderColumnSpans,
|
|
1244
|
+
selectableRowCaptionText
|
|
1245
|
+
} = _a,
|
|
1246
|
+
props = __rest(_a, ["children", "className", "variant", "borders", "isStickyHeader", "gridBreakPoint", 'aria-label', "role", "innerRef", "ouiaId", "ouiaSafe", "isTreeTable", "isNested", "isStriped", "isExpandable", "hasNoInset", "nestedHeaderColumnSpans", "selectableRowCaptionText"]);
|
|
1326
1247
|
const ref = React.useRef(null);
|
|
1327
1248
|
const tableRef = innerRef || ref;
|
|
1328
1249
|
const [hasSelectableRows, setHasSelectableRows] = React.useState(false);
|
|
1329
1250
|
const [tableCaption, setTableCaption] = React.useState();
|
|
1330
1251
|
React.useEffect(() => {
|
|
1331
|
-
document.addEventListener('keydown', handleKeys);
|
|
1332
|
-
|
|
1252
|
+
document.addEventListener('keydown', handleKeys);
|
|
1253
|
+
// sets up roving tab-index to tree tables only
|
|
1333
1254
|
if (tableRef && tableRef.current && tableRef.current.classList.contains('pf-m-tree-view')) {
|
|
1334
1255
|
const tbody = tableRef.current.querySelector('tbody');
|
|
1335
1256
|
tbody && setTabIndex(Array.from(tbody.querySelectorAll('button, a, input')));
|
|
1336
1257
|
}
|
|
1337
|
-
|
|
1338
1258
|
return function cleanup() {
|
|
1339
1259
|
document.removeEventListener('keydown', handleKeys);
|
|
1340
1260
|
};
|
|
@@ -1354,31 +1274,25 @@ const TableBase = _a => {
|
|
|
1354
1274
|
const grid = (_b = stylesGrid.modifiers) === null || _b === void 0 ? void 0 : _b[toCamel(gridBreakPoint || '').replace(/-?2xl/, '_2xl')];
|
|
1355
1275
|
const breakPointPrefix = `treeView${gridBreakPoint.charAt(0).toUpperCase() + gridBreakPoint.slice(1)}`;
|
|
1356
1276
|
const treeGrid = (_c = treeViewStyles.modifiers) === null || _c === void 0 ? void 0 : _c[toCamel(breakPointPrefix || '').replace(/-?2xl/, '_2xl')];
|
|
1357
|
-
|
|
1358
1277
|
const handleKeys = event => {
|
|
1359
|
-
if (isNested || !(tableRef && tableRef.current && tableRef.current.classList.contains(treeViewStyles.modifiers.treeView)) ||
|
|
1278
|
+
if (isNested || !(tableRef && tableRef.current && tableRef.current.classList.contains(treeViewStyles.modifiers.treeView)) ||
|
|
1279
|
+
// implements roving tab-index to tree tables only
|
|
1360
1280
|
tableRef && tableRef.current !== event.target.closest(`.${styles$1.table}:not(.pf-m-nested)`)) {
|
|
1361
1281
|
return;
|
|
1362
1282
|
}
|
|
1363
|
-
|
|
1364
1283
|
const activeElement = document.activeElement;
|
|
1365
1284
|
const key = event.key;
|
|
1366
1285
|
const rows = Array.from(tableRef.current.querySelectorAll('tbody tr')).filter(el => !el.classList.contains('pf-m-disabled') && !el.hidden);
|
|
1367
|
-
|
|
1368
1286
|
if (key === 'Space' || key === 'Enter') {
|
|
1369
1287
|
activeElement.click();
|
|
1370
1288
|
event.preventDefault();
|
|
1371
1289
|
}
|
|
1372
|
-
|
|
1373
1290
|
const getFocusableElement = element => element.querySelectorAll('button:not(:disabled), input:not(:disabled), a:not(:disabled)')[0];
|
|
1374
|
-
|
|
1375
1291
|
handleArrows(event, rows, element => element === activeElement.closest('tr'), getFocusableElement, ['button', 'input', 'a'], undefined, false, true, false);
|
|
1376
1292
|
};
|
|
1377
|
-
|
|
1378
1293
|
const registerSelectableRow = () => {
|
|
1379
1294
|
!hasSelectableRows && setHasSelectableRows(true);
|
|
1380
1295
|
};
|
|
1381
|
-
|
|
1382
1296
|
return React.createElement(TableContext.Provider, {
|
|
1383
1297
|
value: {
|
|
1384
1298
|
registerSelectableRow
|
|
@@ -1392,7 +1306,6 @@ const TableBase = _a => {
|
|
|
1392
1306
|
role: 'treegrid'
|
|
1393
1307
|
}, ouiaProps, props), hasSelectableRows && tableCaption, children));
|
|
1394
1308
|
};
|
|
1395
|
-
|
|
1396
1309
|
const Table = React.forwardRef((props, ref) => React.createElement(TableBase, Object.assign({}, props, {
|
|
1397
1310
|
innerRef: ref
|
|
1398
1311
|
})));
|
|
@@ -1400,29 +1313,28 @@ Table.displayName = 'Table';
|
|
|
1400
1313
|
|
|
1401
1314
|
const TrBase = _a => {
|
|
1402
1315
|
var {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1316
|
+
children,
|
|
1317
|
+
className,
|
|
1318
|
+
isExpanded,
|
|
1319
|
+
isEditable,
|
|
1320
|
+
isHidden = false,
|
|
1321
|
+
isClickable = false,
|
|
1322
|
+
isRowSelected = false,
|
|
1323
|
+
isStriped = false,
|
|
1324
|
+
isBorderRow = false,
|
|
1325
|
+
isControlRow = false,
|
|
1326
|
+
innerRef,
|
|
1327
|
+
ouiaId,
|
|
1328
|
+
ouiaSafe = true,
|
|
1329
|
+
resetOffset = false,
|
|
1330
|
+
onRowClick,
|
|
1331
|
+
isSelectable,
|
|
1332
|
+
'aria-label': passedAriaLabel
|
|
1333
|
+
} = _a,
|
|
1334
|
+
props = __rest(_a, ["children", "className", "isExpanded", "isEditable", "isHidden", "isClickable", "isRowSelected", "isStriped", "isBorderRow", "isControlRow", "innerRef", "ouiaId", "ouiaSafe", "resetOffset", "onRowClick", "isSelectable", 'aria-label']);
|
|
1422
1335
|
const ouiaProps = useOUIAProps$1('TableRow', ouiaId, ouiaSafe);
|
|
1423
1336
|
const [computedAriaLabel, setComputedAriaLabel] = React.useState('');
|
|
1424
1337
|
let onKeyDown = null;
|
|
1425
|
-
|
|
1426
1338
|
if (onRowClick) {
|
|
1427
1339
|
onKeyDown = e => {
|
|
1428
1340
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -1431,7 +1343,6 @@ const TrBase = _a => {
|
|
|
1431
1343
|
}
|
|
1432
1344
|
};
|
|
1433
1345
|
}
|
|
1434
|
-
|
|
1435
1346
|
const rowIsHidden = isHidden || isExpanded !== undefined && !isExpanded;
|
|
1436
1347
|
const {
|
|
1437
1348
|
registerSelectableRow
|
|
@@ -1446,7 +1357,7 @@ const TrBase = _a => {
|
|
|
1446
1357
|
}, [isRowSelected, isSelectable, registerSelectableRow, rowIsHidden]);
|
|
1447
1358
|
const ariaLabel = passedAriaLabel || computedAriaLabel;
|
|
1448
1359
|
return React.createElement(React.Fragment, null, React.createElement("tr", Object.assign({
|
|
1449
|
-
className: css(styles$1.tableTr, className, isExpanded !== undefined && styles$1.tableExpandableRow, isExpanded && styles$1.modifiers.expanded, isEditable && inlineStyles.modifiers.inlineEditable, isClickable && styles$1.modifiers.clickable, isRowSelected && styles$1.modifiers.selected, isStriped && styles$1.modifiers.striped, isBorderRow && styles$1.modifiers.borderRow, resetOffset && styles$1.modifiers.firstCellOffsetReset),
|
|
1360
|
+
className: css(styles$1.tableTr, className, isExpanded !== undefined && styles$1.tableExpandableRow, isExpanded && styles$1.modifiers.expanded, isEditable && inlineStyles.modifiers.inlineEditable, isClickable && styles$1.modifiers.clickable, isRowSelected && styles$1.modifiers.selected, isStriped && styles$1.modifiers.striped, isBorderRow && styles$1.modifiers.borderRow, isControlRow && styles$1.tableControlRow, resetOffset && styles$1.modifiers.firstCellOffsetReset),
|
|
1450
1361
|
hidden: rowIsHidden
|
|
1451
1362
|
}, isClickable && {
|
|
1452
1363
|
tabIndex: 0
|
|
@@ -1458,7 +1369,6 @@ const TrBase = _a => {
|
|
|
1458
1369
|
onKeyDown
|
|
1459
1370
|
}, ouiaProps, props), children));
|
|
1460
1371
|
};
|
|
1461
|
-
|
|
1462
1372
|
const Tr = React.forwardRef((props, ref) => React.createElement(TrBase, Object.assign({}, props, {
|
|
1463
1373
|
innerRef: ref
|
|
1464
1374
|
})));
|
|
@@ -1466,20 +1376,18 @@ Tr.displayName = 'Tr';
|
|
|
1466
1376
|
|
|
1467
1377
|
const TheadBase = _a => {
|
|
1468
1378
|
var {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1379
|
+
children,
|
|
1380
|
+
className,
|
|
1381
|
+
noWrap = false,
|
|
1382
|
+
innerRef,
|
|
1383
|
+
hasNestedHeader
|
|
1384
|
+
} = _a,
|
|
1385
|
+
props = __rest(_a, ["children", "className", "noWrap", "innerRef", "hasNestedHeader"]);
|
|
1477
1386
|
return React.createElement("thead", Object.assign({
|
|
1478
1387
|
className: css(styles$1.tableThead, className, noWrap && styles$1.modifiers.nowrap, hasNestedHeader && styles$1.modifiers.nestedColumnHeader),
|
|
1479
1388
|
ref: innerRef
|
|
1480
1389
|
}, props), children);
|
|
1481
1390
|
};
|
|
1482
|
-
|
|
1483
1391
|
const Thead = React.forwardRef((props, ref) => React.createElement(TheadBase, Object.assign({}, props, {
|
|
1484
1392
|
innerRef: ref
|
|
1485
1393
|
})));
|
|
@@ -1487,22 +1395,20 @@ Thead.displayName = 'Thead';
|
|
|
1487
1395
|
|
|
1488
1396
|
const TbodyBase = _a => {
|
|
1489
1397
|
var {
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1398
|
+
children,
|
|
1399
|
+
className,
|
|
1400
|
+
isExpanded,
|
|
1401
|
+
innerRef,
|
|
1402
|
+
isEvenStriped = false,
|
|
1403
|
+
isOddStriped = false
|
|
1404
|
+
} = _a,
|
|
1405
|
+
props = __rest(_a, ["children", "className", "isExpanded", "innerRef", "isEvenStriped", "isOddStriped"]);
|
|
1499
1406
|
return React.createElement("tbody", Object.assign({
|
|
1500
1407
|
role: "rowgroup",
|
|
1501
1408
|
className: css(styles$1.tableTbody, className, isExpanded && styles$1.modifiers.expanded, isOddStriped && styles$1.modifiers.striped, isEvenStriped && styles$1.modifiers.stripedEven),
|
|
1502
1409
|
ref: innerRef
|
|
1503
1410
|
}, props), children);
|
|
1504
1411
|
};
|
|
1505
|
-
|
|
1506
1412
|
const Tbody = React.forwardRef((props, ref) => React.createElement(TbodyBase, Object.assign({}, props, {
|
|
1507
1413
|
innerRef: ref
|
|
1508
1414
|
})));
|
|
@@ -1532,16 +1438,13 @@ var styles = {
|
|
|
1532
1438
|
/**
|
|
1533
1439
|
* @param {any} props - Props
|
|
1534
1440
|
*/
|
|
1535
|
-
|
|
1536
1441
|
function mergeProps(...props) {
|
|
1537
1442
|
const firstProps = props[0];
|
|
1538
1443
|
const restProps = props.slice(1);
|
|
1539
|
-
|
|
1540
1444
|
if (!restProps.length) {
|
|
1541
1445
|
return mergeWith({}, firstProps);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1446
|
+
}
|
|
1447
|
+
// Avoid mutating the first prop collection
|
|
1545
1448
|
return mergeWith(mergeWith({}, firstProps), ...restProps, (a, b, key) => {
|
|
1546
1449
|
if (key === 'children') {
|
|
1547
1450
|
if (a && b) {
|
|
@@ -1549,19 +1452,16 @@ function mergeProps(...props) {
|
|
|
1549
1452
|
return React.cloneElement(a, {
|
|
1550
1453
|
children: b
|
|
1551
1454
|
});
|
|
1552
|
-
}
|
|
1455
|
+
}
|
|
1456
|
+
// Children have to be merged in reverse order for Reactabular
|
|
1553
1457
|
// logic to work.
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
1458
|
return Object.assign(Object.assign({}, b), a);
|
|
1557
1459
|
}
|
|
1558
|
-
|
|
1559
1460
|
if (key === 'className') {
|
|
1560
1461
|
// Process class names through classNames to merge properly
|
|
1561
1462
|
// as a string.
|
|
1562
1463
|
return css(a, b);
|
|
1563
1464
|
}
|
|
1564
|
-
|
|
1565
1465
|
return undefined;
|
|
1566
1466
|
});
|
|
1567
1467
|
}
|
|
@@ -1589,56 +1489,50 @@ var cssStickyCellRight = c_table__sticky_cell_Right;
|
|
|
1589
1489
|
|
|
1590
1490
|
const ThBase = _a => {
|
|
1591
1491
|
var {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1492
|
+
children,
|
|
1493
|
+
className,
|
|
1494
|
+
component = 'th',
|
|
1495
|
+
dataLabel,
|
|
1496
|
+
scope = 'col',
|
|
1497
|
+
textCenter = false,
|
|
1498
|
+
sort = null,
|
|
1499
|
+
modifier,
|
|
1500
|
+
select = null,
|
|
1501
|
+
expand: collapse = null,
|
|
1502
|
+
tooltip = '',
|
|
1503
|
+
tooltipProps,
|
|
1504
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
1505
|
+
width,
|
|
1506
|
+
visibility,
|
|
1507
|
+
innerRef,
|
|
1508
|
+
info: infoProps,
|
|
1509
|
+
isStickyColumn = false,
|
|
1510
|
+
hasRightBorder = false,
|
|
1511
|
+
hasLeftBorder = false,
|
|
1512
|
+
stickyMinWidth = '120px',
|
|
1513
|
+
stickyLeftOffset,
|
|
1514
|
+
stickyRightOffset,
|
|
1515
|
+
isSubheader = false,
|
|
1516
|
+
screenReaderText,
|
|
1517
|
+
'aria-label': ariaLabel
|
|
1518
|
+
} = _a,
|
|
1519
|
+
props = __rest(_a, ["children", "className", "component", "dataLabel", "scope", "textCenter", "sort", "modifier", "select", "expand", "tooltip", "tooltipProps", "onMouseEnter", "width", "visibility", "innerRef", "info", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset", "isSubheader", "screenReaderText", 'aria-label']);
|
|
1621
1520
|
if (!children && !screenReaderText && !ariaLabel) {
|
|
1622
1521
|
// eslint-disable-next-line no-console
|
|
1623
1522
|
console.warn('Th: Table headers must have an accessible name. If the Th is intended to be visually empty, pass in screenReaderText. If the Th contains only non-text, interactive content such as a checkbox or expand toggle, pass in an aria-label.');
|
|
1624
1523
|
}
|
|
1625
|
-
|
|
1626
1524
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1627
1525
|
const [truncated, setTruncated] = React.useState(false);
|
|
1628
1526
|
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1629
|
-
|
|
1630
1527
|
const onMouseEnter = event => {
|
|
1631
1528
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1632
1529
|
!showTooltip && setShowTooltip(true);
|
|
1633
1530
|
} else {
|
|
1634
1531
|
showTooltip && setShowTooltip(false);
|
|
1635
1532
|
}
|
|
1636
|
-
|
|
1637
1533
|
onMouseEnterProp(event);
|
|
1638
1534
|
};
|
|
1639
|
-
|
|
1640
1535
|
let sortParams = null;
|
|
1641
|
-
|
|
1642
1536
|
if (sort) {
|
|
1643
1537
|
if (sort.isFavorites) {
|
|
1644
1538
|
sortParams = sortableFavorites({
|
|
@@ -1662,7 +1556,6 @@ const ThBase = _a => {
|
|
|
1662
1556
|
});
|
|
1663
1557
|
}
|
|
1664
1558
|
}
|
|
1665
|
-
|
|
1666
1559
|
const selectParams = select ? selectable(children, {
|
|
1667
1560
|
rowData: {
|
|
1668
1561
|
selected: select.isSelected,
|
|
@@ -1691,29 +1584,25 @@ const ThBase = _a => {
|
|
|
1691
1584
|
}) : null;
|
|
1692
1585
|
const widthParams = width ? cellWidth(width)() : null;
|
|
1693
1586
|
const visibilityParams = visibility ? classNames(...visibility.map(vis => Visibility[vis]))() : null;
|
|
1694
|
-
let transformedChildren = (sortParams === null || sortParams === void 0 ? void 0 : sortParams.children) || (selectParams === null || selectParams === void 0 ? void 0 : selectParams.children) || (collapseParams === null || collapseParams === void 0 ? void 0 : collapseParams.children) || children;
|
|
1695
|
-
|
|
1587
|
+
let transformedChildren = (sortParams === null || sortParams === void 0 ? void 0 : sortParams.children) || (selectParams === null || selectParams === void 0 ? void 0 : selectParams.children) || (collapseParams === null || collapseParams === void 0 ? void 0 : collapseParams.children) || children;
|
|
1588
|
+
// info can wrap other transformedChildren
|
|
1696
1589
|
let infoParams = null;
|
|
1697
|
-
|
|
1698
1590
|
if (infoProps) {
|
|
1699
1591
|
infoParams = info(infoProps)(transformedChildren);
|
|
1700
1592
|
transformedChildren = infoParams.children;
|
|
1701
1593
|
}
|
|
1702
|
-
|
|
1703
1594
|
const merged = mergeProps(sortParams, selectParams, collapseParams, widthParams, visibilityParams, infoParams);
|
|
1704
|
-
|
|
1705
1595
|
const {
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1596
|
+
// ignore the merged children since we transform them ourselves so we can wrap it with info
|
|
1597
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1598
|
+
children: mergedChildren = null,
|
|
1599
|
+
// selectable adds this but we don't want it
|
|
1600
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1601
|
+
isVisible = null,
|
|
1602
|
+
className: mergedClassName = '',
|
|
1603
|
+
component: MergedComponent = component
|
|
1604
|
+
} = merged,
|
|
1605
|
+
mergedProps = __rest(merged, ["children", "isVisible", "className", "component"]);
|
|
1717
1606
|
React.useEffect(() => {
|
|
1718
1607
|
setTruncated(cellRef.current.offsetWidth < cellRef.current.scrollWidth);
|
|
1719
1608
|
}, [cellRef]);
|
|
@@ -1744,7 +1633,6 @@ const ThBase = _a => {
|
|
|
1744
1633
|
isVisible: true
|
|
1745
1634
|
}, tooltipProps))) : cell;
|
|
1746
1635
|
};
|
|
1747
|
-
|
|
1748
1636
|
const Th = React.forwardRef((props, ref) => React.createElement(ThBase, Object.assign({}, props, {
|
|
1749
1637
|
innerRef: ref
|
|
1750
1638
|
})));
|
|
@@ -1766,49 +1654,45 @@ const draggable = (value, {
|
|
|
1766
1654
|
|
|
1767
1655
|
const TdBase = _a => {
|
|
1768
1656
|
var {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1657
|
+
children,
|
|
1658
|
+
className,
|
|
1659
|
+
isActionCell = false,
|
|
1660
|
+
component = 'td',
|
|
1661
|
+
dataLabel,
|
|
1662
|
+
textCenter = false,
|
|
1663
|
+
modifier,
|
|
1664
|
+
select = null,
|
|
1665
|
+
actions = null,
|
|
1666
|
+
expand = null,
|
|
1667
|
+
treeRow: treeRowProp = null,
|
|
1668
|
+
compoundExpand: compoundExpandProp = null,
|
|
1669
|
+
noPadding,
|
|
1670
|
+
width,
|
|
1671
|
+
visibility,
|
|
1672
|
+
innerRef,
|
|
1673
|
+
favorites = null,
|
|
1674
|
+
draggableRow: draggableRowProp = null,
|
|
1675
|
+
tooltip = '',
|
|
1676
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
1677
|
+
isStickyColumn = false,
|
|
1678
|
+
hasRightBorder = false,
|
|
1679
|
+
hasLeftBorder = false,
|
|
1680
|
+
stickyMinWidth = '120px',
|
|
1681
|
+
stickyLeftOffset,
|
|
1682
|
+
stickyRightOffset
|
|
1683
|
+
} = _a,
|
|
1684
|
+
props = __rest(_a, ["children", "className", "isActionCell", "component", "dataLabel", "textCenter", "modifier", "select", "actions", "expand", "treeRow", "compoundExpand", "noPadding", "width", "visibility", "innerRef", "favorites", "draggableRow", "tooltip", "onMouseEnter", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset"]);
|
|
1798
1685
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1799
1686
|
const [truncated, setTruncated] = React.useState(false);
|
|
1800
1687
|
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1801
|
-
|
|
1802
1688
|
const onMouseEnter = event => {
|
|
1803
1689
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1804
1690
|
!showTooltip && setShowTooltip(true);
|
|
1805
1691
|
} else {
|
|
1806
1692
|
showTooltip && setShowTooltip(false);
|
|
1807
1693
|
}
|
|
1808
|
-
|
|
1809
1694
|
onMouseEnterProp(event);
|
|
1810
1695
|
};
|
|
1811
|
-
|
|
1812
1696
|
const selectParams = select ? selectable(children, {
|
|
1813
1697
|
rowIndex: select.rowIndex,
|
|
1814
1698
|
rowData: {
|
|
@@ -1894,17 +1778,15 @@ const TdBase = _a => {
|
|
|
1894
1778
|
}
|
|
1895
1779
|
}) : null;
|
|
1896
1780
|
const merged = mergeProps(selectParams, actionParams, expandableParams, compoundParams, widthParams, visibilityParams, favoriteParams, treeRowParams, draggableParams);
|
|
1897
|
-
|
|
1898
1781
|
const {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1782
|
+
// selectable adds this but we don't want it
|
|
1783
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1784
|
+
isVisible = null,
|
|
1785
|
+
children: mergedChildren = null,
|
|
1786
|
+
className: mergedClassName = '',
|
|
1787
|
+
component: MergedComponent = component
|
|
1788
|
+
} = merged,
|
|
1789
|
+
mergedProps = __rest(merged, ["isVisible", "children", "className", "component"]);
|
|
1908
1790
|
const treeTableTitleCell = className && className.includes(treeViewStyles.tableTreeViewTitleCell) || mergedClassName && mergedClassName.includes(treeViewStyles.tableTreeViewTitleCell);
|
|
1909
1791
|
React.useEffect(() => {
|
|
1910
1792
|
setTruncated(cellRef.current.offsetWidth < cellRef.current.scrollWidth);
|
|
@@ -1933,7 +1815,6 @@ const TdBase = _a => {
|
|
|
1933
1815
|
isVisible: true
|
|
1934
1816
|
})) : cell;
|
|
1935
1817
|
};
|
|
1936
|
-
|
|
1937
1818
|
const Td = React.forwardRef((props, ref) => React.createElement(TdBase, Object.assign({}, props, {
|
|
1938
1819
|
innerRef: ref
|
|
1939
1820
|
})));
|
|
@@ -1970,25 +1851,22 @@ function FilterableTable({
|
|
|
1970
1851
|
actions,
|
|
1971
1852
|
perPageOptions
|
|
1972
1853
|
}) {
|
|
1973
|
-
|
|
1974
1854
|
const [page, setPage] = useState(DEFAULT_PAGE);
|
|
1975
1855
|
const [perPage, setPerPage] = useState(DEFAULT_PERPAGE );
|
|
1976
1856
|
const [sortTableBy, setSortTableBy] = useState({});
|
|
1977
1857
|
const [rows, setRows] = useState([]);
|
|
1978
1858
|
const [filteredItems, setFilteredItems] = useState(items);
|
|
1979
1859
|
const [tableFilters, setTableFilters] = useState([]);
|
|
1980
|
-
/**
|
|
1981
|
-
* Sorts table by the selected column in ascending or decending order
|
|
1982
|
-
* @param _event click
|
|
1983
|
-
* @param index column index
|
|
1984
|
-
* @param direction asc || desc
|
|
1860
|
+
/**
|
|
1861
|
+
* Sorts table by the selected column in ascending or decending order
|
|
1862
|
+
* @param _event click
|
|
1863
|
+
* @param index column index
|
|
1864
|
+
* @param direction asc || desc
|
|
1985
1865
|
*/
|
|
1986
|
-
|
|
1987
1866
|
const onSort = (_event, index, direction) => {
|
|
1988
1867
|
var _columns$index, _columns$index2;
|
|
1989
|
-
|
|
1990
|
-
const
|
|
1991
|
-
const sortFn = columns == null ? void 0 : (_columns$index2 = columns[index]) == null ? void 0 : _columns$index2.sortFn;
|
|
1868
|
+
const sortField = columns == null || (_columns$index = columns[index]) == null ? void 0 : _columns$index.sortField;
|
|
1869
|
+
const sortFn = columns == null || (_columns$index2 = columns[index]) == null ? void 0 : _columns$index2.sortFn;
|
|
1992
1870
|
const sortedRows = sortFn ? sortBy(filteredItems, sortFn) : sortField ? sortBy(filteredItems, item => item[sortField]) : filteredItems;
|
|
1993
1871
|
setSortTableBy({
|
|
1994
1872
|
index,
|
|
@@ -1996,44 +1874,37 @@ function FilterableTable({
|
|
|
1996
1874
|
});
|
|
1997
1875
|
setFilteredItems(direction === SortByDirection.asc ? [...sortedRows] : [...(sortedRows == null ? void 0 : sortedRows.reverse())]);
|
|
1998
1876
|
};
|
|
1999
|
-
/**
|
|
2000
|
-
* Set table rows to display based on current list of filtered items, page, and perPage settings
|
|
1877
|
+
/**
|
|
1878
|
+
* Set table rows to display based on current list of filtered items, page, and perPage settings
|
|
2001
1879
|
*/
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
1880
|
useEffect(() => {
|
|
2005
1881
|
const startIndex = (page - 1) * perPage;
|
|
2006
1882
|
const endIndex = startIndex + perPage;
|
|
2007
1883
|
const itemsInPage = filteredItems.slice(startIndex, endIndex);
|
|
2008
1884
|
setRows(itemsInPage);
|
|
2009
1885
|
}, [filteredItems, page, perPage]);
|
|
2010
|
-
/**
|
|
2011
|
-
* If the list of items change, reset to the first page
|
|
1886
|
+
/**
|
|
1887
|
+
* If the list of items change, reset to the first page
|
|
2012
1888
|
*/
|
|
2013
|
-
|
|
2014
1889
|
function handleItemsPropChange() {
|
|
2015
1890
|
setPage(1);
|
|
2016
1891
|
}
|
|
2017
|
-
|
|
2018
1892
|
const handleItemsPropChangeCallback = useCallback(handleItemsPropChange, [setPage, items]);
|
|
2019
1893
|
useEffect(handleItemsPropChangeCallback, [handleItemsPropChangeCallback]);
|
|
2020
|
-
/**
|
|
2021
|
-
* Whenever a filter is selected or a user enter a search string, run each item through each filter condition
|
|
2022
|
-
* and check it includes the search string. Only inlcude the item in the table if it passes all filter/search string
|
|
2023
|
-
* conditions.
|
|
1894
|
+
/**
|
|
1895
|
+
* Whenever a filter is selected or a user enter a search string, run each item through each filter condition
|
|
1896
|
+
* and check it includes the search string. Only inlcude the item in the table if it passes all filter/search string
|
|
1897
|
+
* conditions.
|
|
2024
1898
|
*/
|
|
2025
|
-
|
|
2026
1899
|
useEffect(() => setFilteredItems(items.filter(item => tableFilters.map((f, i) => {
|
|
2027
|
-
var _filters$i
|
|
2028
|
-
|
|
2029
|
-
return !f ? true : filters == null ? void 0 : (_filters$i = filters[i]) == null ? void 0 : (_filters$i$props = _filters$i.props) == null ? void 0 : _filters$i$props.onChange(f, item);
|
|
1900
|
+
var _filters$i;
|
|
1901
|
+
return !f ? true : filters == null || (_filters$i = filters[i]) == null || (_filters$i = _filters$i.props) == null ? void 0 : _filters$i.onChange(f, item);
|
|
2030
1902
|
}).reduce((r, v) => r && v, true))), [filters, items, tableFilters]);
|
|
2031
|
-
/**
|
|
2032
|
-
* Whenever a new filter is selected by the user, update the state of selectedFilters
|
|
2033
|
-
* @param selected filter selections
|
|
2034
|
-
* @param index filter to update with new selections
|
|
1903
|
+
/**
|
|
1904
|
+
* Whenever a new filter is selected by the user, update the state of selectedFilters
|
|
1905
|
+
* @param selected filter selections
|
|
1906
|
+
* @param index filter to update with new selections
|
|
2035
1907
|
*/
|
|
2036
|
-
|
|
2037
1908
|
const onFilterChange = (selected, index) => {
|
|
2038
1909
|
handleItemsPropChangeCallback();
|
|
2039
1910
|
setTableFilters(prevState => {
|
|
@@ -2041,13 +1912,11 @@ function FilterableTable({
|
|
|
2041
1912
|
return [...prevState];
|
|
2042
1913
|
});
|
|
2043
1914
|
};
|
|
2044
|
-
/**
|
|
2045
|
-
* Pagination component
|
|
2046
|
-
* @param variant top or bottom
|
|
2047
|
-
* @returns Pagination component based on variant
|
|
1915
|
+
/**
|
|
1916
|
+
* Pagination component
|
|
1917
|
+
* @param variant top or bottom
|
|
1918
|
+
* @returns Pagination component based on variant
|
|
2048
1919
|
*/
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
1920
|
const renderPagination = variant => {
|
|
2052
1921
|
return (filteredItems == null ? void 0 : filteredItems.length) > 0 && React__default.createElement(Pagination, {
|
|
2053
1922
|
itemCount: (filteredItems == null ? void 0 : filteredItems.length) || 0,
|
|
@@ -2066,11 +1935,9 @@ function FilterableTable({
|
|
|
2066
1935
|
}
|
|
2067
1936
|
});
|
|
2068
1937
|
};
|
|
2069
|
-
/**
|
|
2070
|
-
* Toolbar populated with provided filters
|
|
1938
|
+
/**
|
|
1939
|
+
* Toolbar populated with provided filters
|
|
2071
1940
|
*/
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
1941
|
const header = React__default.createElement(Toolbar, null, React__default.createElement(ToolbarContent, null, filters == null ? void 0 : filters.map((el, i) => {
|
|
2075
1942
|
return React__default.createElement(ToolbarItem, {
|
|
2076
1943
|
key: i,
|
|
@@ -2099,7 +1966,7 @@ function FilterableTable({
|
|
|
2099
1966
|
})))) : React__default.createElement(React__default.Fragment, null, header, React__default.createElement(Table, {
|
|
2100
1967
|
"aria-label": 'Packages Table',
|
|
2101
1968
|
gridBreakPoint: 'grid-xl'
|
|
2102
|
-
}, React__default.createElement(Thead, null, React__default.createElement(Tr, null, columns.map((col, colIdx) => React__default.createElement(Th,
|
|
1969
|
+
}, React__default.createElement(Thead, null, React__default.createElement(Tr, null, columns.map((col, colIdx) => React__default.createElement(Th, _extends({
|
|
2103
1970
|
key: `pkg-table-head-${colIdx}`
|
|
2104
1971
|
}, col.sortField ? {
|
|
2105
1972
|
sort: {
|
|
@@ -2111,7 +1978,6 @@ function FilterableTable({
|
|
|
2111
1978
|
key: `pkg-table-row-${rowIdx}`
|
|
2112
1979
|
}, columns.map((_col, colIdx) => {
|
|
2113
1980
|
var _renderRow;
|
|
2114
|
-
|
|
2115
1981
|
return React__default.createElement(Td, {
|
|
2116
1982
|
key: `pkg-table-row-${rowIdx}-col-${colIdx}`
|
|
2117
1983
|
}, (_renderRow = renderRow(row)) == null ? void 0 : _renderRow[colIdx]);
|
|
@@ -2131,7 +1997,6 @@ const FilterInput = ({
|
|
|
2131
1997
|
placeholder
|
|
2132
1998
|
}) => {
|
|
2133
1999
|
const [searchStr, setSearchStr] = useState('');
|
|
2134
|
-
|
|
2135
2000
|
const onChange = (event, text) => {
|
|
2136
2001
|
event.stopPropagation();
|
|
2137
2002
|
event.preventDefault();
|
|
@@ -2140,7 +2005,6 @@ const FilterInput = ({
|
|
|
2140
2005
|
return text;
|
|
2141
2006
|
});
|
|
2142
2007
|
};
|
|
2143
|
-
|
|
2144
2008
|
return React__default.createElement("div", {
|
|
2145
2009
|
className: 'filter-input'
|
|
2146
2010
|
}, React__default.createElement(SearchInput, {
|
|
@@ -2179,12 +2043,10 @@ const ExcludedPackagesTable = ({
|
|
|
2179
2043
|
rel: 'noopener noreferrer'
|
|
2180
2044
|
}, nvra) : React__default.createElement("span", null, nvra), summary];
|
|
2181
2045
|
};
|
|
2182
|
-
|
|
2183
2046
|
const onTextInputFilterChange = (text, {
|
|
2184
2047
|
nvra,
|
|
2185
2048
|
summary
|
|
2186
2049
|
}) => `${nvra + summary}`.toLowerCase().includes(text.toLowerCase());
|
|
2187
|
-
|
|
2188
2050
|
return React__default.createElement("div", {
|
|
2189
2051
|
className: 'excluded-packages-table'
|
|
2190
2052
|
}, React__default.createElement(FilterableTable, {
|
|
@@ -2224,15 +2086,12 @@ function EcoSelect({
|
|
|
2224
2086
|
}) {
|
|
2225
2087
|
const [isOpen, setIsOpen] = useState(false);
|
|
2226
2088
|
const [selected, setSelected] = useState([]);
|
|
2227
|
-
|
|
2228
2089
|
const onToggle = isOpen => setIsOpen(isOpen);
|
|
2229
|
-
|
|
2230
2090
|
const onSelect = (event, selection) => {
|
|
2231
2091
|
const result = selected.includes(selection) ? selected.filter(item => item !== selection) : [selection, ...selected];
|
|
2232
2092
|
setSelected(result);
|
|
2233
2093
|
onChange && onChange(result, event);
|
|
2234
2094
|
};
|
|
2235
|
-
|
|
2236
2095
|
const id = uniqueId('select-');
|
|
2237
2096
|
return React__default.createElement("div", {
|
|
2238
2097
|
className: 'select'
|
|
@@ -2254,7 +2113,6 @@ function EcoSelect({
|
|
|
2254
2113
|
|
|
2255
2114
|
const ToggleGroup = props => {
|
|
2256
2115
|
const [selected, setSelected] = useState('');
|
|
2257
|
-
|
|
2258
2116
|
const onClick = (_, event) => {
|
|
2259
2117
|
const id = event.currentTarget.id;
|
|
2260
2118
|
setSelected(() => {
|
|
@@ -2262,7 +2120,6 @@ const ToggleGroup = props => {
|
|
|
2262
2120
|
return id;
|
|
2263
2121
|
});
|
|
2264
2122
|
};
|
|
2265
|
-
|
|
2266
2123
|
return React__default.createElement(ToggleGroup$1, {
|
|
2267
2124
|
"aria-label": props['aria-label']
|
|
2268
2125
|
}, props.options.map((option, index) => React__default.createElement(ToggleGroupItem, {
|
|
@@ -2289,7 +2146,6 @@ const VulnerabilitiesTable = ({
|
|
|
2289
2146
|
className: `impact-icon color-${severity.toLowerCase()}`
|
|
2290
2147
|
}), React__default.createElement("span", null, severity)));
|
|
2291
2148
|
};
|
|
2292
|
-
|
|
2293
2149
|
const getCVE = ({
|
|
2294
2150
|
cve_id
|
|
2295
2151
|
}) => {
|
|
@@ -2301,7 +2157,6 @@ const VulnerabilitiesTable = ({
|
|
|
2301
2157
|
rel: 'noopener noreferrer'
|
|
2302
2158
|
}, cve_id)));
|
|
2303
2159
|
};
|
|
2304
|
-
|
|
2305
2160
|
const getAffectedPackages = rpms => {
|
|
2306
2161
|
return React__default.createElement(React__default.Fragment, null, rpms == null ? void 0 : rpms.map(({
|
|
2307
2162
|
gpg,
|
|
@@ -2324,7 +2179,6 @@ const VulnerabilitiesTable = ({
|
|
|
2324
2179
|
}, React__default.createElement("span", null, nvra));
|
|
2325
2180
|
}));
|
|
2326
2181
|
};
|
|
2327
|
-
|
|
2328
2182
|
const getRPMAdvisory = ({
|
|
2329
2183
|
advisory_type,
|
|
2330
2184
|
advisory_id
|
|
@@ -2337,11 +2191,9 @@ const VulnerabilitiesTable = ({
|
|
|
2337
2191
|
rel: 'noopener noreferrer'
|
|
2338
2192
|
}, advisory_type, "-", advisory_id) : React__default.createElement("span", null, "-")));
|
|
2339
2193
|
};
|
|
2340
|
-
|
|
2341
2194
|
const renderVulnerabilitiesRow = vulnerability => {
|
|
2342
2195
|
return [getImpact(vulnerability), getCVE(vulnerability), getAffectedPackages(vulnerability.rpm_nvra_with_link_data), getRPMAdvisory(vulnerability), vulnerability != null && vulnerability.creation_date ? format(new Date(vulnerability == null ? void 0 : vulnerability.creation_date), 'MMM dd, yyyy hh:mm a') : ''];
|
|
2343
2196
|
};
|
|
2344
|
-
|
|
2345
2197
|
const onTextInputFilterChange = (text, {
|
|
2346
2198
|
rpm_nvra_with_link_data,
|
|
2347
2199
|
severity,
|
|
@@ -2353,15 +2205,12 @@ const VulnerabilitiesTable = ({
|
|
|
2353
2205
|
}) => result += nvra, '');
|
|
2354
2206
|
return `${severity + cve_id + advisory_id + nvraList}`.toLowerCase().includes(text.toLowerCase());
|
|
2355
2207
|
};
|
|
2356
|
-
|
|
2357
2208
|
const onStatusFilterChange = (selected, vulnerability) => {
|
|
2358
2209
|
return selected === 'fixed' ? !!(vulnerability != null && vulnerability.advisory_id) : selected === 'unfixed' ? !(vulnerability != null && vulnerability.advisory_id) : true;
|
|
2359
2210
|
};
|
|
2360
|
-
|
|
2361
2211
|
const onImpactFilterChange = (selected, vulnerability) => {
|
|
2362
2212
|
return selected.length > 0 ? selected.includes(vulnerability.severity) : true;
|
|
2363
2213
|
};
|
|
2364
|
-
|
|
2365
2214
|
return React__default.createElement("div", {
|
|
2366
2215
|
className: 'vulnerabilities-table'
|
|
2367
2216
|
}, React__default.createElement(FilterableTable, {
|
|
@@ -2432,10 +2281,8 @@ const severitySortOrder = {
|
|
|
2432
2281
|
Moderate: 3,
|
|
2433
2282
|
Low: 4
|
|
2434
2283
|
};
|
|
2435
|
-
|
|
2436
2284
|
const InsertCss = () => {
|
|
2437
2285
|
const styleId = 'example-component-styles';
|
|
2438
|
-
|
|
2439
2286
|
if (!document.getElementById(styleId)) {
|
|
2440
2287
|
const styleTag = document.createElement('style');
|
|
2441
2288
|
styleTag.id = styleId;
|
|
@@ -2443,7 +2290,6 @@ const InsertCss = () => {
|
|
|
2443
2290
|
document.body.appendChild(styleTag);
|
|
2444
2291
|
}
|
|
2445
2292
|
};
|
|
2446
|
-
|
|
2447
2293
|
const PackagesTable = ({
|
|
2448
2294
|
vulnerabilities: _vulnerabilities = [],
|
|
2449
2295
|
rpms: _rpms = [],
|
|
@@ -2455,45 +2301,42 @@ const PackagesTable = ({
|
|
|
2455
2301
|
const [activeKey, setActiveKey] = React.useState(0);
|
|
2456
2302
|
React.useEffect(() => {
|
|
2457
2303
|
const VALID_REDHAT_GPG_KEYS = ['199e2f91fd431d51', '5326810137017186', '45689c882fa658e0', '219180cddb42a60e', '7514f77d8366b0d9', 'fd372689897da07a', '938a80caf21541eb', '08b871e6a5787476'];
|
|
2458
|
-
|
|
2459
2304
|
const packages = _rpms.filter(({
|
|
2460
2305
|
gpg
|
|
2461
2306
|
}) => !VALID_REDHAT_GPG_KEYS.includes(gpg));
|
|
2462
|
-
|
|
2463
2307
|
setExcludedPackages(packages);
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2308
|
+
const validPackages = _rpms.filter(({
|
|
2309
|
+
gpg
|
|
2310
|
+
}) => VALID_REDHAT_GPG_KEYS.includes(gpg));
|
|
2311
|
+
const uniqueVulnerabilities = [..._vulnerabilities];
|
|
2312
|
+
// augment vulnerabilities with link data
|
|
2466
2313
|
uniqueVulnerabilities.forEach(vulnerability => {
|
|
2467
|
-
vulnerability.rpm_nvra_with_link_data = [];
|
|
2468
|
-
|
|
2314
|
+
vulnerability.rpm_nvra_with_link_data = [];
|
|
2315
|
+
// // CONNCERT-2121
|
|
2469
2316
|
if (vulnerability != null && vulnerability.affected_packages) {
|
|
2470
2317
|
var _vulnerability$affect;
|
|
2471
|
-
|
|
2472
|
-
vulnerability == null ? void 0 : (_vulnerability$affect = vulnerability.affected_packages) == null ? void 0 : _vulnerability$affect.forEach(({
|
|
2318
|
+
vulnerability == null || (_vulnerability$affect = vulnerability.affected_packages) == null || _vulnerability$affect.forEach(({
|
|
2473
2319
|
name,
|
|
2474
2320
|
arch
|
|
2475
2321
|
}) => {
|
|
2476
|
-
const link_data =
|
|
2322
|
+
const link_data = validPackages == null ? void 0 : validPackages.filter(rpm => rpm.name === name && rpm.architecture === arch);
|
|
2477
2323
|
vulnerability.rpm_nvra_with_link_data.push(link_data[0]);
|
|
2478
2324
|
});
|
|
2479
2325
|
} else {
|
|
2480
2326
|
var _vulnerability$packag;
|
|
2481
|
-
|
|
2482
|
-
vulnerability == null ? void 0 : (_vulnerability$packag = vulnerability.packages) == null ? void 0 : _vulnerability$packag.forEach(p => {
|
|
2327
|
+
vulnerability == null || (_vulnerability$packag = vulnerability.packages) == null || _vulnerability$packag.forEach(p => {
|
|
2483
2328
|
var _p$rpm_nvra;
|
|
2484
|
-
|
|
2485
|
-
return p == null ? void 0 : (_p$rpm_nvra = p.rpm_nvra) == null ? void 0 : _p$rpm_nvra.forEach(rpm_nvra => {
|
|
2329
|
+
return p == null || (_p$rpm_nvra = p.rpm_nvra) == null ? void 0 : _p$rpm_nvra.forEach(rpm_nvra => {
|
|
2486
2330
|
const link_data = _rpms == null ? void 0 : _rpms.filter(pk => pk.nvra === rpm_nvra);
|
|
2487
2331
|
vulnerability.rpm_nvra_with_link_data.push(link_data[0]);
|
|
2488
2332
|
});
|
|
2489
2333
|
});
|
|
2490
2334
|
}
|
|
2491
|
-
|
|
2492
2335
|
return vulnerability;
|
|
2493
|
-
});
|
|
2494
|
-
|
|
2495
|
-
uniqueVulnerabilities.sort(vulnerability => severitySortOrder[vulnerability.severity]);
|
|
2496
|
-
|
|
2336
|
+
});
|
|
2337
|
+
// sort vulnerabilities by severity
|
|
2338
|
+
uniqueVulnerabilities.sort(vulnerability => severitySortOrder[vulnerability.severity]);
|
|
2339
|
+
// filter out vulnerabilities with duplicate CVE IDs
|
|
2497
2340
|
uniqueVulnerabilities.filter((value, index, self) => self.findIndex(vulnerability => vulnerability.cve_id === value.cve_id) === index);
|
|
2498
2341
|
setUniqueVulnerabilities(uniqueVulnerabilities);
|
|
2499
2342
|
}, [_rpms, _vulnerabilities]);
|