@dfds-ui/experiences 2.0.29 → 2.2.0-alpha.0228d8d2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/dynamic-table/Body/TableBody.d.ts +1 -1
- package/cjs/dynamic-table/Body/TableBody.js +18 -17
- package/cjs/dynamic-table/Body/TableBody.types.d.ts +2 -1
- package/cjs/dynamic-table/Body/TableCell.d.ts +1 -1
- package/cjs/dynamic-table/Body/TableCell.js +9 -9
- package/cjs/dynamic-table/Body/TableCell.styles.d.ts +2 -1
- package/cjs/dynamic-table/Body/TableCell.styles.js +14 -11
- package/cjs/dynamic-table/Body/TableCell.types.d.ts +1 -2
- package/cjs/dynamic-table/Body/TableRow.d.ts +1 -1
- package/cjs/dynamic-table/Body/TableRow.js +55 -29
- package/cjs/dynamic-table/Body/TableRow.styles.d.ts +6 -2
- package/cjs/dynamic-table/Body/TableRow.styles.js +26 -14
- package/cjs/dynamic-table/Body/TableRow.types.d.ts +9 -1
- package/cjs/dynamic-table/Body/TableRowGroup.d.ts +4 -0
- package/cjs/dynamic-table/Body/TableRowGroup.js +52 -0
- package/cjs/dynamic-table/Body/TableRowGroup.types.d.ts +14 -0
- package/cjs/dynamic-table/Body/TableRowGroup.types.js +5 -0
- package/cjs/dynamic-table/DynamicTable.js +55 -67
- package/cjs/dynamic-table/DynamicTable.styles.d.ts +1 -1
- package/cjs/dynamic-table/DynamicTable.styles.js +1 -2
- package/cjs/dynamic-table/DynamicTable.types.d.ts +10 -3
- package/cjs/dynamic-table/Head/TableHead.d.ts +1 -1
- package/cjs/dynamic-table/Head/TableHead.js +49 -38
- package/cjs/dynamic-table/Head/TableHead.styles.d.ts +2 -1
- package/cjs/dynamic-table/Head/TableHead.styles.js +35 -20
- package/cjs/dynamic-table/Head/TableHead.types.d.ts +8 -4
- package/cjs/dynamic-table/Skeleton/SkeletonTable.styles.js +3 -5
- package/cjs/dynamic-table/Skeleton/helpers/createSkeletonRows.js +8 -8
- package/cjs/dynamic-table/helpers/getHeaderRow.js +1 -2
- package/cjs/dynamic-table/stories/headerRow.js +1 -2
- package/cjs/dynamic-table/stories/headerRowSortable.js +1 -2
- package/cjs/dynamic-table/stories/tableRows.js +52 -16
- package/cjs/dynamic-table/stories/tableRowsExpandable.d.ts +3 -0
- package/cjs/dynamic-table/stories/tableRowsExpandable.js +109 -0
- package/cjs/footer/Footer.d.ts +1 -1
- package/cjs/footer/Footer.js +62 -54
- package/cjs/footer/FooterColumn.d.ts +1 -1
- package/cjs/footer/FooterColumn.js +20 -19
- package/cjs/footer/FooterColumnItem.d.ts +1 -1
- package/cjs/footer/FooterColumnItem.js +15 -18
- package/cjs/footer/FooterMetaLink.d.ts +1 -1
- package/cjs/footer/FooterMetaLink.js +14 -18
- package/cjs/footer/index.js +4 -4
- package/cjs/index.js +6 -6
- package/cjs/internet-explorer-modal/IEModal.d.ts +2 -2
- package/cjs/internet-explorer-modal/IEModal.js +65 -78
- package/cjs/locale-selector/LocaleOption.d.ts +3 -3
- package/cjs/locale-selector/LocaleOption.js +9 -9
- package/cjs/locale-selector/LocaleSelector.d.ts +9 -7
- package/cjs/locale-selector/LocaleSelector.js +41 -49
- package/cjs/locale-selector/index.js +1 -1
- package/cjs/swiper/Swiper.d.ts +5 -4
- package/cjs/swiper/Swiper.js +7 -6
- package/cjs/swiper/SwiperCard.d.ts +5 -4
- package/cjs/swiper/SwiperCard.js +7 -6
- package/cjs/swiper/index.js +2 -2
- package/dynamic-table/Body/TableBody.d.ts +1 -1
- package/dynamic-table/Body/TableBody.js +22 -19
- package/dynamic-table/Body/TableBody.types.d.ts +2 -1
- package/dynamic-table/Body/TableCell.d.ts +1 -1
- package/dynamic-table/Body/TableCell.js +5 -4
- package/dynamic-table/Body/TableCell.styles.d.ts +2 -1
- package/dynamic-table/Body/TableCell.styles.js +7 -4
- package/dynamic-table/Body/TableCell.types.d.ts +1 -2
- package/dynamic-table/Body/TableRow.d.ts +1 -1
- package/dynamic-table/Body/TableRow.js +56 -26
- package/dynamic-table/Body/TableRow.styles.d.ts +6 -2
- package/dynamic-table/Body/TableRow.styles.js +10 -4
- package/dynamic-table/Body/TableRow.types.d.ts +9 -1
- package/dynamic-table/Body/TableRowGroup.d.ts +4 -0
- package/dynamic-table/Body/TableRowGroup.js +55 -0
- package/dynamic-table/Body/TableRowGroup.types.d.ts +14 -0
- package/dynamic-table/Body/TableRowGroup.types.js +1 -0
- package/dynamic-table/DynamicTable.js +47 -36
- package/dynamic-table/DynamicTable.styles.d.ts +1 -1
- package/dynamic-table/DynamicTable.types.d.ts +10 -3
- package/dynamic-table/Head/TableHead.d.ts +1 -1
- package/dynamic-table/Head/TableHead.js +51 -38
- package/dynamic-table/Head/TableHead.styles.d.ts +2 -1
- package/dynamic-table/Head/TableHead.styles.js +17 -9
- package/dynamic-table/Head/TableHead.types.d.ts +8 -4
- package/dynamic-table/Skeleton/SkeletonTable.styles.js +1 -2
- package/dynamic-table/Skeleton/helpers/createSkeletonRows.js +11 -11
- package/dynamic-table/stories/tableRows.js +50 -13
- package/dynamic-table/stories/tableRowsExpandable.d.ts +3 -0
- package/dynamic-table/stories/tableRowsExpandable.js +104 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +52 -37
- package/footer/FooterColumn.d.ts +1 -1
- package/footer/FooterColumn.js +21 -12
- package/footer/FooterColumnItem.d.ts +1 -1
- package/footer/FooterColumnItem.js +14 -7
- package/footer/FooterMetaLink.d.ts +1 -1
- package/footer/FooterMetaLink.js +14 -8
- package/internet-explorer-modal/IEModal.d.ts +2 -2
- package/internet-explorer-modal/IEModal.js +59 -48
- package/locale-selector/LocaleOption.d.ts +3 -3
- package/locale-selector/LocaleOption.js +7 -7
- package/locale-selector/LocaleSelector.d.ts +9 -7
- package/locale-selector/LocaleSelector.js +44 -41
- package/package.json +14 -14
- package/swiper/Swiper.d.ts +5 -4
- package/swiper/Swiper.js +6 -6
- package/swiper/SwiperCard.d.ts +5 -4
- package/swiper/SwiperCard.js +6 -6
|
@@ -1,44 +1,74 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Checkbox } from '@dfds-ui/forms';
|
|
3
3
|
import TableCell from './TableCell';
|
|
4
|
-
import { tableCellCheckboxStyles } from './TableCell.styles';
|
|
5
|
-
import { tableRowStyles } from './TableRow.styles';
|
|
6
|
-
import {
|
|
4
|
+
import { tableCellCheckboxStyles, tableCellExpanderStyles } from './TableCell.styles';
|
|
5
|
+
import { chevronStyles, tableRowStyles } from './TableRow.styles';
|
|
6
|
+
import { ChevronRight } from '@dfds-ui/icons/system';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
7
8
|
var TableRow = /*#__PURE__*/React.memo(function (_ref) {
|
|
8
|
-
var
|
|
9
|
+
var _row$subRows;
|
|
10
|
+
var expandable = _ref.expandable,
|
|
11
|
+
headerRow = _ref.headerRow,
|
|
9
12
|
isActive = _ref.isActive,
|
|
13
|
+
isExpanded = _ref.isExpanded,
|
|
14
|
+
_ref$isSubRow = _ref.isSubRow,
|
|
15
|
+
isSubRow = _ref$isSubRow === void 0 ? false : _ref$isSubRow,
|
|
10
16
|
onClickRow = _ref.onClickRow,
|
|
11
17
|
onSelectRow = _ref.onSelectRow,
|
|
12
18
|
row = _ref.row,
|
|
13
19
|
selectableRows = _ref.selectableRows,
|
|
14
|
-
selectedRows = _ref.selectedRows
|
|
15
|
-
|
|
20
|
+
selectedRows = _ref.selectedRows,
|
|
21
|
+
setIsExpanded = _ref.setIsExpanded,
|
|
22
|
+
_ref$showExpander = _ref.showExpander,
|
|
23
|
+
showExpander = _ref$showExpander === void 0 ? false : _ref$showExpander;
|
|
24
|
+
var hasSubRows = (((_row$subRows = row.subRows) === null || _row$subRows === void 0 ? void 0 : _row$subRows.length) || 0) > 0;
|
|
25
|
+
return _jsxs("tr", {
|
|
16
26
|
css: tableRowStyles({
|
|
17
27
|
active: isActive,
|
|
18
|
-
|
|
28
|
+
expanded: isExpanded,
|
|
29
|
+
hoverColor: !!onClickRow,
|
|
30
|
+
subRow: !!isSubRow
|
|
19
31
|
}),
|
|
20
32
|
className: row.className,
|
|
33
|
+
"data-expanded": isExpanded,
|
|
34
|
+
"data-row-type": isSubRow ? 'sub-row' : 'row',
|
|
21
35
|
onClick: function onClick() {
|
|
22
36
|
return onClickRow && onClickRow(row.id ? String(row.id) : '');
|
|
23
|
-
}
|
|
24
|
-
}, selectableRows && row.id && ___EmotionJSX("td", {
|
|
25
|
-
css: tableCellCheckboxStyles
|
|
26
|
-
}, ___EmotionJSX(Checkbox, {
|
|
27
|
-
checked: selectedRows.includes(row.id),
|
|
28
|
-
name: row.id,
|
|
29
|
-
onChange: function onChange() {
|
|
30
|
-
if (!row.id) return;
|
|
31
|
-
onSelectRow(row.id);
|
|
32
37
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
children: [expandable && _jsx("td", {
|
|
39
|
+
css: tableCellExpanderStyles(showExpander),
|
|
40
|
+
onClick: function onClick(e) {
|
|
41
|
+
if (!showExpander) return;
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
setIsExpanded(function (prev) {
|
|
44
|
+
return !prev;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
children: hasSubRows ? _jsx(ChevronRight, {
|
|
48
|
+
css: chevronStyles({
|
|
49
|
+
expanded: isExpanded
|
|
50
|
+
})
|
|
51
|
+
}) : null
|
|
52
|
+
}), selectableRows && row.id && _jsx("td", {
|
|
53
|
+
css: tableCellCheckboxStyles,
|
|
54
|
+
children: _jsx(Checkbox, {
|
|
55
|
+
checked: selectedRows.includes(row.id),
|
|
56
|
+
name: row.id,
|
|
57
|
+
onChange: function onChange() {
|
|
58
|
+
if (!row.id) return;
|
|
59
|
+
onSelectRow(row.id);
|
|
60
|
+
},
|
|
61
|
+
onLabelClick: function onLabelClick(e) {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
},
|
|
64
|
+
visualSize: "small"
|
|
65
|
+
})
|
|
66
|
+
}), headerRow.map(function (headerCell, index) {
|
|
67
|
+
return _jsx(TableCell, {
|
|
68
|
+
headerCell: headerRow === null || headerRow === void 0 ? void 0 : headerRow[index],
|
|
69
|
+
children: row[headerCell.key] || '-'
|
|
70
|
+
}, index);
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
43
73
|
});
|
|
44
74
|
export default TableRow;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { ChevronProps } from './TableRow.types';
|
|
1
2
|
export declare const genericTableRowStyles: import("@emotion/utils").SerializedStyles;
|
|
2
|
-
|
|
3
|
+
type TableRowProps = {
|
|
3
4
|
active?: boolean;
|
|
5
|
+
expanded: boolean;
|
|
4
6
|
hoverColor: boolean;
|
|
7
|
+
subRow: boolean;
|
|
5
8
|
};
|
|
6
|
-
export declare const tableRowStyles: ({ active, hoverColor }: TableRowProps) => import("@emotion/utils").SerializedStyles;
|
|
9
|
+
export declare const tableRowStyles: ({ active, expanded, hoverColor, subRow }: TableRowProps) => import("@emotion/utils").SerializedStyles;
|
|
10
|
+
export declare const chevronStyles: ({ expanded }: ChevronProps) => import("@emotion/utils").SerializedStyles;
|
|
7
11
|
export {};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { theme } from '@dfds-ui/theme';
|
|
8
8
|
import { css } from '@emotion/react';
|
|
9
|
-
export var genericTableRowStyles = /*#__PURE__*/css("border-bottom:1px solid ", theme.colors.
|
|
9
|
+
export var genericTableRowStyles = /*#__PURE__*/css("border-bottom:1px solid ", theme.colors.divider.dark, ";border-collapse:collapse;height:48px;" + (process.env.NODE_ENV === "production" ? "" : ";label:genericTableRowStyles;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0JvZHkvVGFibGVSb3cuc3R5bGVzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJd0MiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL2R5bmFtaWMtdGFibGUvQm9keS9UYWJsZVJvdy5zdHlsZXMudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdGhlbWUgfSBmcm9tICdAZGZkcy11aS90aGVtZSdcbmltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW1wb3J0IHsgQ2hldnJvblByb3BzIH0gZnJvbSAnLi9UYWJsZVJvdy50eXBlcydcblxuZXhwb3J0IGNvbnN0IGdlbmVyaWNUYWJsZVJvd1N0eWxlcyA9IGNzc2BcbiAgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkICR7dGhlbWUuY29sb3JzLmRpdmlkZXIuZGFya307XG4gIGJvcmRlci1jb2xsYXBzZTogY29sbGFwc2U7XG4gIGhlaWdodDogNDhweDtcbmBcblxudHlwZSBUYWJsZVJvd1Byb3BzID0ge1xuICBhY3RpdmU/OiBib29sZWFuXG4gIGV4cGFuZGVkOiBib29sZWFuXG4gIGhvdmVyQ29sb3I6IGJvb2xlYW5cbiAgc3ViUm93OiBib29sZWFuXG59XG5cbmV4cG9ydCBjb25zdCB0YWJsZVJvd1N0eWxlcyA9ICh7IGFjdGl2ZSwgZXhwYW5kZWQsIGhvdmVyQ29sb3IsIHN1YlJvdyB9OiBUYWJsZVJvd1Byb3BzKSA9PiBjc3NgXG4gICR7eyAuLi5nZW5lcmljVGFibGVSb3dTdHlsZXMgfX1cblxuICAmOmhvdmVyIHtcbiAgICAke2hvdmVyQ29sb3IgJiZcbiAgICBgXG4gICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5zdXJmYWNlLnNlY29uZGFyeX07XG4gICAgICBjdXJzb3I6IHBvaW50ZXI7XG4gICAgYH07XG4gIH1cblxuICAke2V4cGFuZGVkICYmXG4gIGBcbiAgICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5zdXJmYWNlLnNlY29uZGFyeX07XG5cbiAgICAmOmhvdmVyIHtcbiAgICAgICR7XG4gICAgICAgIGhvdmVyQ29sb3IgJiZcbiAgICAgICAgYFxuICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5kaXZpZGVyLmRhcmt9O1xuICAgICAgYFxuICAgICAgfTtcbiAgICB9XG4gIGB9O1xuXG4gICR7c3ViUm93ICYmXG4gICFleHBhbmRlZCAmJlxuICBgXG4gICAgZGlzcGxheTogbm9uZTtcbiAgYH07XG5cbiAgJHthY3RpdmUgJiZcbiAgYFxuICAgIGJhY2tncm91bmQtY29sb3I6ICR7dGhlbWUuY29sb3JzLmRpdmlkZXIuZGFya307XG4gIGB9O1xuYFxuXG5leHBvcnQgY29uc3QgY2hldnJvblN0eWxlcyA9ICh7IGV4cGFuZGVkIH06IENoZXZyb25Qcm9wcykgPT4gY3NzYFxuICBjb2xvcjogJHt0aGVtZS5jb2xvcnMucHJpbWFyeS5kYXJrfTtcbiAgZm9udC1zaXplOiAxLjVyZW07XG4gIHRyYW5zZm9ybTogJHtleHBhbmRlZCAmJiAncm90YXRlKDkwZGVnKSd9O1xuICB0cmFuc2l0aW9uLWR1cmF0aW9uOiAyNTBtcztcbiAgdHJhbnNpdGlvbi1wcm9wZXJ0eTogdHJhbnNmb3JtO1xuYFxuIl19 */");
|
|
10
10
|
export var tableRowStyles = function tableRowStyles(_ref) {
|
|
11
11
|
var active = _ref.active,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
expanded = _ref.expanded,
|
|
13
|
+
hoverColor = _ref.hoverColor,
|
|
14
|
+
subRow = _ref.subRow;
|
|
15
|
+
return /*#__PURE__*/css(_objectSpread({}, genericTableRowStyles), " &:hover{", hoverColor && "\n background-color: ".concat(theme.colors.surface.secondary, ";\n cursor: pointer;\n "), ";}", expanded && "\n background-color: ".concat(theme.colors.surface.secondary, ";\n\n &:hover {\n ").concat(hoverColor && "\n background-color: ".concat(theme.colors.divider.dark, ";\n "), ";\n }\n "), ";", subRow && !expanded && "\n display: none;\n ", ";", active && "\n background-color: ".concat(theme.colors.divider.dark, ";\n "), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:tableRowStyles;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0JvZHkvVGFibGVSb3cuc3R5bGVzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQjhGIiwiZmlsZSI6Ii4uLy4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0JvZHkvVGFibGVSb3cuc3R5bGVzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHRoZW1lIH0gZnJvbSAnQGRmZHMtdWkvdGhlbWUnXG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCdcbmltcG9ydCB7IENoZXZyb25Qcm9wcyB9IGZyb20gJy4vVGFibGVSb3cudHlwZXMnXG5cbmV4cG9ydCBjb25zdCBnZW5lcmljVGFibGVSb3dTdHlsZXMgPSBjc3NgXG4gIGJvcmRlci1ib3R0b206IDFweCBzb2xpZCAke3RoZW1lLmNvbG9ycy5kaXZpZGVyLmRhcmt9O1xuICBib3JkZXItY29sbGFwc2U6IGNvbGxhcHNlO1xuICBoZWlnaHQ6IDQ4cHg7XG5gXG5cbnR5cGUgVGFibGVSb3dQcm9wcyA9IHtcbiAgYWN0aXZlPzogYm9vbGVhblxuICBleHBhbmRlZDogYm9vbGVhblxuICBob3ZlckNvbG9yOiBib29sZWFuXG4gIHN1YlJvdzogYm9vbGVhblxufVxuXG5leHBvcnQgY29uc3QgdGFibGVSb3dTdHlsZXMgPSAoeyBhY3RpdmUsIGV4cGFuZGVkLCBob3ZlckNvbG9yLCBzdWJSb3cgfTogVGFibGVSb3dQcm9wcykgPT4gY3NzYFxuICAke3sgLi4uZ2VuZXJpY1RhYmxlUm93U3R5bGVzIH19XG5cbiAgJjpob3ZlciB7XG4gICAgJHtob3ZlckNvbG9yICYmXG4gICAgYFxuICAgICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuc3VyZmFjZS5zZWNvbmRhcnl9O1xuICAgICAgY3Vyc29yOiBwb2ludGVyO1xuICAgIGB9O1xuICB9XG5cbiAgJHtleHBhbmRlZCAmJlxuICBgXG4gICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuc3VyZmFjZS5zZWNvbmRhcnl9O1xuXG4gICAgJjpob3ZlciB7XG4gICAgICAke1xuICAgICAgICBob3ZlckNvbG9yICYmXG4gICAgICAgIGBcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuZGl2aWRlci5kYXJrfTtcbiAgICAgIGBcbiAgICAgIH07XG4gICAgfVxuICBgfTtcblxuICAke3N1YlJvdyAmJlxuICAhZXhwYW5kZWQgJiZcbiAgYFxuICAgIGRpc3BsYXk6IG5vbmU7XG4gIGB9O1xuXG4gICR7YWN0aXZlICYmXG4gIGBcbiAgICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5kaXZpZGVyLmRhcmt9O1xuICBgfTtcbmBcblxuZXhwb3J0IGNvbnN0IGNoZXZyb25TdHlsZXMgPSAoeyBleHBhbmRlZCB9OiBDaGV2cm9uUHJvcHMpID0+IGNzc2BcbiAgY29sb3I6ICR7dGhlbWUuY29sb3JzLnByaW1hcnkuZGFya307XG4gIGZvbnQtc2l6ZTogMS41cmVtO1xuICB0cmFuc2Zvcm06ICR7ZXhwYW5kZWQgJiYgJ3JvdGF0ZSg5MGRlZyknfTtcbiAgdHJhbnNpdGlvbi1kdXJhdGlvbjogMjUwbXM7XG4gIHRyYW5zaXRpb24tcHJvcGVydHk6IHRyYW5zZm9ybTtcbmBcbiJdfQ== */");
|
|
16
|
+
};
|
|
17
|
+
export var chevronStyles = function chevronStyles(_ref2) {
|
|
18
|
+
var expanded = _ref2.expanded;
|
|
19
|
+
return /*#__PURE__*/css("color:", theme.colors.primary.dark, ";font-size:1.5rem;transform:", expanded && 'rotate(90deg)', ";transition-duration:250ms;transition-property:transform;" + (process.env.NODE_ENV === "production" ? "" : ";label:chevronStyles;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0JvZHkvVGFibGVSb3cuc3R5bGVzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFzRGdFIiwiZmlsZSI6Ii4uLy4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0JvZHkvVGFibGVSb3cuc3R5bGVzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHRoZW1lIH0gZnJvbSAnQGRmZHMtdWkvdGhlbWUnXG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCdcbmltcG9ydCB7IENoZXZyb25Qcm9wcyB9IGZyb20gJy4vVGFibGVSb3cudHlwZXMnXG5cbmV4cG9ydCBjb25zdCBnZW5lcmljVGFibGVSb3dTdHlsZXMgPSBjc3NgXG4gIGJvcmRlci1ib3R0b206IDFweCBzb2xpZCAke3RoZW1lLmNvbG9ycy5kaXZpZGVyLmRhcmt9O1xuICBib3JkZXItY29sbGFwc2U6IGNvbGxhcHNlO1xuICBoZWlnaHQ6IDQ4cHg7XG5gXG5cbnR5cGUgVGFibGVSb3dQcm9wcyA9IHtcbiAgYWN0aXZlPzogYm9vbGVhblxuICBleHBhbmRlZDogYm9vbGVhblxuICBob3ZlckNvbG9yOiBib29sZWFuXG4gIHN1YlJvdzogYm9vbGVhblxufVxuXG5leHBvcnQgY29uc3QgdGFibGVSb3dTdHlsZXMgPSAoeyBhY3RpdmUsIGV4cGFuZGVkLCBob3ZlckNvbG9yLCBzdWJSb3cgfTogVGFibGVSb3dQcm9wcykgPT4gY3NzYFxuICAke3sgLi4uZ2VuZXJpY1RhYmxlUm93U3R5bGVzIH19XG5cbiAgJjpob3ZlciB7XG4gICAgJHtob3ZlckNvbG9yICYmXG4gICAgYFxuICAgICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuc3VyZmFjZS5zZWNvbmRhcnl9O1xuICAgICAgY3Vyc29yOiBwb2ludGVyO1xuICAgIGB9O1xuICB9XG5cbiAgJHtleHBhbmRlZCAmJlxuICBgXG4gICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuc3VyZmFjZS5zZWNvbmRhcnl9O1xuXG4gICAgJjpob3ZlciB7XG4gICAgICAke1xuICAgICAgICBob3ZlckNvbG9yICYmXG4gICAgICAgIGBcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogJHt0aGVtZS5jb2xvcnMuZGl2aWRlci5kYXJrfTtcbiAgICAgIGBcbiAgICAgIH07XG4gICAgfVxuICBgfTtcblxuICAke3N1YlJvdyAmJlxuICAhZXhwYW5kZWQgJiZcbiAgYFxuICAgIGRpc3BsYXk6IG5vbmU7XG4gIGB9O1xuXG4gICR7YWN0aXZlICYmXG4gIGBcbiAgICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5kaXZpZGVyLmRhcmt9O1xuICBgfTtcbmBcblxuZXhwb3J0IGNvbnN0IGNoZXZyb25TdHlsZXMgPSAoeyBleHBhbmRlZCB9OiBDaGV2cm9uUHJvcHMpID0+IGNzc2BcbiAgY29sb3I6ICR7dGhlbWUuY29sb3JzLnByaW1hcnkuZGFya307XG4gIGZvbnQtc2l6ZTogMS41cmVtO1xuICB0cmFuc2Zvcm06ICR7ZXhwYW5kZWQgJiYgJ3JvdGF0ZSg5MGRlZyknfTtcbiAgdHJhbnNpdGlvbi1kdXJhdGlvbjogMjUwbXM7XG4gIHRyYW5zaXRpb24tcHJvcGVydHk6IHRyYW5zZm9ybTtcbmBcbiJdfQ== */");
|
|
14
20
|
};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Header, Row } from '../DynamicTable.types';
|
|
2
|
-
export
|
|
2
|
+
export type TableRowProps = {
|
|
3
|
+
expandable?: boolean;
|
|
3
4
|
headerRow: Header[];
|
|
4
5
|
isActive: boolean;
|
|
6
|
+
isExpanded: boolean;
|
|
7
|
+
isSubRow?: boolean;
|
|
5
8
|
onClickRow?: (id: string) => void;
|
|
6
9
|
onSelectRow: (id: string) => void;
|
|
7
10
|
row: Row;
|
|
8
11
|
selectableRows: boolean;
|
|
9
12
|
selectedRows: string[];
|
|
13
|
+
setIsExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
showExpander?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type ChevronProps = {
|
|
17
|
+
expanded: boolean;
|
|
10
18
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TableRowGroupProps } from './TableRowGroup.types';
|
|
3
|
+
declare const TableRowGroup: React.MemoExoticComponent<({ activeRow, expandable, headerRow, onClickRow, onSelectRow, row, selectableRows, selectedRows, }: TableRowGroupProps) => React.JSX.Element>;
|
|
4
|
+
export default TableRowGroup;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import TableRow from './TableRow';
|
|
9
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
10
|
+
var TableRowGroup = /*#__PURE__*/React.memo(function (_ref) {
|
|
11
|
+
var activeRow = _ref.activeRow,
|
|
12
|
+
expandable = _ref.expandable,
|
|
13
|
+
headerRow = _ref.headerRow,
|
|
14
|
+
onClickRow = _ref.onClickRow,
|
|
15
|
+
onSelectRow = _ref.onSelectRow,
|
|
16
|
+
row = _ref.row,
|
|
17
|
+
selectableRows = _ref.selectableRows,
|
|
18
|
+
selectedRows = _ref.selectedRows;
|
|
19
|
+
var _React$useState = React.useState(false),
|
|
20
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
21
|
+
isExpanded = _React$useState2[0],
|
|
22
|
+
setIsExpanded = _React$useState2[1];
|
|
23
|
+
var subRows = row.subRows || [];
|
|
24
|
+
var hasSubRows = subRows.length > 0;
|
|
25
|
+
return _jsxs(_Fragment, {
|
|
26
|
+
children: [_jsx(TableRow, {
|
|
27
|
+
expandable: expandable,
|
|
28
|
+
headerRow: headerRow,
|
|
29
|
+
isActive: activeRow ? row.id === activeRow : false,
|
|
30
|
+
isExpanded: isExpanded,
|
|
31
|
+
onClickRow: onClickRow,
|
|
32
|
+
onSelectRow: onSelectRow,
|
|
33
|
+
row: row,
|
|
34
|
+
selectableRows: selectableRows,
|
|
35
|
+
selectedRows: selectedRows,
|
|
36
|
+
setIsExpanded: setIsExpanded,
|
|
37
|
+
showExpander: hasSubRows
|
|
38
|
+
}), subRows.map(function (subRow) {
|
|
39
|
+
return _jsx(TableRow, {
|
|
40
|
+
expandable: expandable,
|
|
41
|
+
headerRow: headerRow,
|
|
42
|
+
isActive: activeRow ? subRow.id === activeRow : false,
|
|
43
|
+
isExpanded: isExpanded,
|
|
44
|
+
isSubRow: true,
|
|
45
|
+
onClickRow: onClickRow,
|
|
46
|
+
onSelectRow: onSelectRow,
|
|
47
|
+
row: subRow,
|
|
48
|
+
selectableRows: selectableRows,
|
|
49
|
+
selectedRows: selectedRows,
|
|
50
|
+
setIsExpanded: setIsExpanded
|
|
51
|
+
}, subRow.id);
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
export default TableRowGroup;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Header, Row } from '../DynamicTable.types';
|
|
2
|
+
export type TableRowGroupProps = {
|
|
3
|
+
activeRow?: string;
|
|
4
|
+
expandable?: boolean;
|
|
5
|
+
headerRow: Header[];
|
|
6
|
+
onClickRow?: (id: string) => void;
|
|
7
|
+
onSelectRow: (id: string) => void;
|
|
8
|
+
row: Row;
|
|
9
|
+
selectableRows: boolean;
|
|
10
|
+
selectedRows: string[];
|
|
11
|
+
};
|
|
12
|
+
export type ChevronProps = {
|
|
13
|
+
expanded: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["activeRow", "descending", "expandable", "height", "headerRow", "isLoading", "onClickRow", "onSelectRow", "onSort", "rows", "selectedRows", "sortingBy", "stickyHeader"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
-
function _unsupportedIterableToArray(
|
|
6
|
-
function _arrayLikeToArray(
|
|
7
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0)
|
|
8
|
-
function _arrayWithHoles(
|
|
9
|
-
function _objectWithoutProperties(
|
|
10
|
-
function _objectWithoutPropertiesLoose(
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
16
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
12
17
|
import TableBody from './Body/TableBody';
|
|
13
18
|
import { tableStyles, tableWrapperStyles } from './DynamicTable.styles';
|
|
14
19
|
import TableHead from './Head/TableHead';
|
|
15
20
|
import createSkeletonRows from './Skeleton/helpers/createSkeletonRows';
|
|
16
21
|
import { fadeStyles } from './Skeleton/SkeletonTable.styles';
|
|
17
|
-
import { jsx as
|
|
22
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
18
23
|
var DynamicTable = function DynamicTable(_ref) {
|
|
19
24
|
var activeRow = _ref.activeRow,
|
|
20
25
|
descending = _ref.descending,
|
|
26
|
+
expandable = _ref.expandable,
|
|
21
27
|
height = _ref.height,
|
|
22
28
|
headerRow = _ref.headerRow,
|
|
23
29
|
isLoading = _ref.isLoading,
|
|
@@ -48,35 +54,40 @@ var DynamicTable = function DynamicTable(_ref) {
|
|
|
48
54
|
onSort(sortByKeyValue, sortDescending);
|
|
49
55
|
}
|
|
50
56
|
}, [sortDescending, onSort, sortByKeyValue]);
|
|
51
|
-
return
|
|
57
|
+
return _jsxs("div", _objectSpread(_objectSpread({
|
|
52
58
|
css: tableWrapperStyles({
|
|
53
59
|
height: height
|
|
54
60
|
})
|
|
55
|
-
}, rest),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
}, rest), {}, {
|
|
62
|
+
children: [_jsxs("table", {
|
|
63
|
+
css: tableStyles,
|
|
64
|
+
"data-cy": !isLoading ? "dynamic-table-isLoaded" : '',
|
|
65
|
+
children: [headerRow && _jsx(TableHead, {
|
|
66
|
+
expandable: expandable,
|
|
67
|
+
headerRow: headerRow,
|
|
68
|
+
onSelectRow: onSelectRow,
|
|
69
|
+
onSort: onSort,
|
|
70
|
+
rows: rows,
|
|
71
|
+
selectableRows: selectableRows,
|
|
72
|
+
selectedRows: selectedRows,
|
|
73
|
+
setSortDescending: setSortDescending,
|
|
74
|
+
setSortByKeyValue: setSortByKeyValue,
|
|
75
|
+
sortDescending: sortDescending,
|
|
76
|
+
sortByKeyValue: sortByKeyValue,
|
|
77
|
+
stickyHeader: stickyHeader
|
|
78
|
+
}), _jsx(TableBody, {
|
|
79
|
+
activeRow: activeRow,
|
|
80
|
+
expandable: expandable,
|
|
81
|
+
headerRow: headerRow,
|
|
82
|
+
onClickRow: onClickRow,
|
|
83
|
+
onSelectRow: onSelectRow,
|
|
84
|
+
rows: !isLoading ? rows : skeletonRows,
|
|
85
|
+
selectableRows: selectableRows,
|
|
86
|
+
selectedRows: selectedRows
|
|
87
|
+
})]
|
|
88
|
+
}), isLoading && _jsx("div", {
|
|
89
|
+
css: fadeStyles
|
|
90
|
+
})]
|
|
80
91
|
}));
|
|
81
92
|
};
|
|
82
93
|
export default /*#__PURE__*/React.memo(DynamicTable);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type Header = {
|
|
3
3
|
displayName: string | React.ReactElement;
|
|
4
4
|
key: string;
|
|
5
5
|
sortKey?: string;
|
|
@@ -7,14 +7,21 @@ export declare type Header = {
|
|
|
7
7
|
textAlign?: 'center' | 'left' | 'right';
|
|
8
8
|
width?: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type SubRow = {
|
|
11
11
|
className?: string;
|
|
12
12
|
id?: string;
|
|
13
13
|
[name: string]: any;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type Row = {
|
|
16
|
+
className?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
subRows?: SubRow[];
|
|
19
|
+
[name: string]: any;
|
|
20
|
+
};
|
|
21
|
+
export type DynamicTableProps = {
|
|
16
22
|
activeRow?: string;
|
|
17
23
|
descending?: boolean;
|
|
24
|
+
expandable?: boolean;
|
|
18
25
|
headerRow: Header[];
|
|
19
26
|
height?: string;
|
|
20
27
|
isLoading?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableHeadProps } from './TableHead.types';
|
|
3
|
-
declare const TableHead: React.MemoExoticComponent<({ headerRow, onSelectRow, onSort, rows, selectableRows, selectedRows, setSortDescending, setSortByKeyValue, sortDescending, sortByKeyValue, stickyHeader, }: TableHeadProps) => JSX.Element>;
|
|
3
|
+
declare const TableHead: React.MemoExoticComponent<({ expandable, headerRow, onSelectRow, onSort, rows, selectableRows, selectedRows, setSortDescending, setSortByKeyValue, sortDescending, sortByKeyValue, stickyHeader, }: TableHeadProps) => React.JSX.Element>;
|
|
4
4
|
export default TableHead;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { ChevronDown } from '@dfds-ui/icons/system';
|
|
3
3
|
import { Checkbox } from '@dfds-ui/react-components';
|
|
4
|
-
import { chevronStyles, tableHeadCellCheckboxStyles, tableHeadCellStyles } from './TableHead.styles';
|
|
4
|
+
import { chevronStyles, tableHeadCellCheckboxStyles, tableHeadCellExpanderStyles, tableHeadCellStyles } from './TableHead.styles';
|
|
5
5
|
import { genericTableRowStyles } from '../Body/TableRow.styles';
|
|
6
|
-
import { jsx as
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
7
7
|
var TableHead = /*#__PURE__*/React.memo(function (_ref) {
|
|
8
|
-
var
|
|
8
|
+
var expandable = _ref.expandable,
|
|
9
|
+
headerRow = _ref.headerRow,
|
|
9
10
|
onSelectRow = _ref.onSelectRow,
|
|
10
11
|
onSort = _ref.onSort,
|
|
11
12
|
rows = _ref.rows,
|
|
@@ -35,41 +36,53 @@ var TableHead = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
35
36
|
setSortDescending(!sortDescending);
|
|
36
37
|
}
|
|
37
38
|
}, [onSort, setSortDescending, setSortByKeyValue, sortDescending]);
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
return _jsx("thead", {
|
|
40
|
+
children: _jsxs("tr", {
|
|
41
|
+
css: genericTableRowStyles,
|
|
42
|
+
children: [expandable && _jsx("th", {
|
|
43
|
+
css: tableHeadCellExpanderStyles({
|
|
44
|
+
stickyHeader: stickyHeader
|
|
45
|
+
})
|
|
46
|
+
}), selectableRows && _jsx("th", {
|
|
47
|
+
css: tableHeadCellCheckboxStyles({
|
|
48
|
+
stickyHeader: stickyHeader
|
|
49
|
+
}),
|
|
50
|
+
children: _jsx(Checkbox, {
|
|
51
|
+
checked: selectedRows.length > 0,
|
|
52
|
+
indeterminate: true,
|
|
53
|
+
name: "all",
|
|
54
|
+
onChange: toggleAll,
|
|
55
|
+
size: "small"
|
|
56
|
+
})
|
|
57
|
+
}), headerRow.map(function (headerCell, i) {
|
|
58
|
+
var sortKey = headerCell.sortKey || headerCell.key;
|
|
59
|
+
var clickHandler = function clickHandler() {
|
|
60
|
+
return headerCell.sortable && sort(sortByKeyValue, sortKey);
|
|
61
|
+
};
|
|
62
|
+
var showChevron = String(sortByKeyValue === sortKey);
|
|
63
|
+
return _jsx("th", {
|
|
64
|
+
align: headerCell.textAlign,
|
|
65
|
+
css: tableHeadCellStyles({
|
|
66
|
+
align: headerCell.textAlign,
|
|
67
|
+
customWidth: headerCell.width,
|
|
68
|
+
sortByKey: onSort,
|
|
69
|
+
sortable: headerCell.sortable,
|
|
70
|
+
stickyHeader: stickyHeader
|
|
71
|
+
}),
|
|
72
|
+
onClick: clickHandler,
|
|
73
|
+
children: _jsxs("div", {
|
|
74
|
+
children: [_jsx("span", {
|
|
75
|
+
children: headerCell.displayName
|
|
76
|
+
}), headerCell.sortable && onSort && _jsx(ChevronDown, {
|
|
77
|
+
css: chevronStyles({
|
|
78
|
+
descending: String(sortDescending),
|
|
79
|
+
show: showChevron
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
}, i);
|
|
84
|
+
})]
|
|
43
85
|
})
|
|
44
|
-
}
|
|
45
|
-
checked: selectedRows.length > 0,
|
|
46
|
-
indeterminate: true,
|
|
47
|
-
name: "all",
|
|
48
|
-
onChange: toggleAll,
|
|
49
|
-
size: "small"
|
|
50
|
-
})), headerRow.map(function (headerCell, i) {
|
|
51
|
-
var sortKey = headerCell.sortKey || headerCell.key;
|
|
52
|
-
var clickHandler = function clickHandler() {
|
|
53
|
-
return headerCell.sortable && sort(sortByKeyValue, sortKey);
|
|
54
|
-
};
|
|
55
|
-
var showChevron = String(sortByKeyValue === sortKey);
|
|
56
|
-
return ___EmotionJSX("th", {
|
|
57
|
-
align: headerCell.textAlign,
|
|
58
|
-
css: tableHeadCellStyles({
|
|
59
|
-
align: headerCell.textAlign,
|
|
60
|
-
customWidth: headerCell.width,
|
|
61
|
-
sortByKey: onSort,
|
|
62
|
-
sortable: headerCell.sortable,
|
|
63
|
-
stickyHeader: stickyHeader
|
|
64
|
-
}),
|
|
65
|
-
key: i,
|
|
66
|
-
onClick: clickHandler
|
|
67
|
-
}, ___EmotionJSX("div", null, ___EmotionJSX("span", null, headerCell.displayName), headerCell.sortable && onSort && ___EmotionJSX(ChevronDown, {
|
|
68
|
-
css: chevronStyles({
|
|
69
|
-
descending: String(sortDescending),
|
|
70
|
-
show: showChevron
|
|
71
|
-
})
|
|
72
|
-
})));
|
|
73
|
-
})));
|
|
86
|
+
});
|
|
74
87
|
});
|
|
75
88
|
export default TableHead;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChevronProps, TableHeadCellCheckboxProps, TableHeadCellProps } from './TableHead.types';
|
|
1
|
+
import { ChevronProps, TableHeadCellCExpanderProps, TableHeadCellCheckboxProps, TableHeadCellProps } from './TableHead.types';
|
|
2
2
|
export declare const tableHeadCellStyles: ({ align, customWidth, sortable, sortByKey, stickyHeader, }: TableHeadCellProps) => import("@emotion/utils").SerializedStyles;
|
|
3
|
+
export declare const tableHeadCellExpanderStyles: ({ stickyHeader }: TableHeadCellCExpanderProps) => import("@emotion/utils").SerializedStyles;
|
|
3
4
|
export declare const tableHeadCellCheckboxStyles: ({ stickyHeader }: TableHeadCellCheckboxProps) => import("@emotion/utils").SerializedStyles;
|
|
4
5
|
export declare const chevronStyles: ({ descending, show }: ChevronProps) => import("@emotion/utils").SerializedStyles;
|