@dfds-ui/experiences 0.10.0 → 1.0.0-alpha.8d4fd23a
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 +4 -0
- package/cjs/dynamic-table/Body/TableBody.js +57 -0
- package/cjs/dynamic-table/Body/TableBody.types.d.ts +10 -0
- package/cjs/dynamic-table/Body/TableBody.types.js +5 -0
- package/cjs/dynamic-table/Body/TableCell.d.ts +4 -0
- package/cjs/dynamic-table/Body/TableCell.js +26 -0
- package/cjs/dynamic-table/Body/TableCell.styles.d.ts +14 -0
- package/cjs/dynamic-table/Body/TableCell.styles.js +43 -0
- package/cjs/dynamic-table/Body/TableCell.types.d.ts +5 -0
- package/cjs/dynamic-table/Body/TableCell.types.js +5 -0
- package/cjs/dynamic-table/Body/TableRow.d.ts +4 -0
- package/cjs/dynamic-table/Body/TableRow.js +51 -0
- package/cjs/dynamic-table/Body/TableRow.styles.d.ts +10 -0
- package/cjs/dynamic-table/Body/TableRow.styles.js +39 -0
- package/cjs/dynamic-table/Body/TableRow.types.d.ts +10 -0
- package/cjs/dynamic-table/Body/TableRow.types.js +5 -0
- package/cjs/dynamic-table/DynamicTable.d.ts +4 -29
- package/cjs/dynamic-table/DynamicTable.js +55 -174
- package/cjs/dynamic-table/DynamicTable.styles.d.ts +12 -5
- package/cjs/dynamic-table/DynamicTable.styles.js +23 -29
- package/cjs/dynamic-table/DynamicTable.types.d.ts +26 -0
- package/cjs/dynamic-table/DynamicTable.types.js +5 -0
- package/cjs/dynamic-table/Head/TableHead.d.ts +4 -0
- package/cjs/dynamic-table/Head/TableHead.js +85 -0
- package/cjs/dynamic-table/Head/TableHead.styles.d.ts +24 -0
- package/cjs/dynamic-table/Head/TableHead.styles.js +89 -0
- package/cjs/dynamic-table/Head/TableHead.types.d.ts +33 -0
- package/cjs/dynamic-table/Head/TableHead.types.js +5 -0
- package/cjs/dynamic-table/Skeleton/SkeletonTable.styles.d.ts +4 -0
- package/cjs/dynamic-table/Skeleton/SkeletonTable.styles.js +28 -0
- package/cjs/dynamic-table/Skeleton/helpers/createSkeletonRows.d.ts +3 -0
- package/cjs/dynamic-table/Skeleton/helpers/createSkeletonRows.js +40 -0
- package/cjs/dynamic-table/helpers/getHeaderRow.d.ts +3 -0
- package/cjs/dynamic-table/helpers/getHeaderRow.js +27 -0
- package/cjs/dynamic-table/stories/headerRow.d.ts +3 -0
- package/cjs/dynamic-table/stories/headerRow.js +26 -0
- package/cjs/dynamic-table/stories/headerRowSortable.d.ts +3 -0
- package/cjs/dynamic-table/stories/headerRowSortable.js +28 -0
- package/cjs/dynamic-table/stories/tableRows.d.ts +3 -0
- package/cjs/dynamic-table/stories/tableRows.js +76 -0
- package/dynamic-table/Body/TableBody.d.ts +4 -0
- package/dynamic-table/Body/TableBody.js +52 -0
- package/dynamic-table/Body/TableBody.types.d.ts +10 -0
- package/dynamic-table/Body/TableBody.types.js +1 -0
- package/dynamic-table/Body/TableCell.d.ts +4 -0
- package/dynamic-table/Body/TableCell.js +13 -0
- package/dynamic-table/Body/TableCell.styles.d.ts +14 -0
- package/dynamic-table/Body/TableCell.styles.js +32 -0
- package/dynamic-table/Body/TableCell.types.d.ts +5 -0
- package/dynamic-table/Body/TableCell.types.js +1 -0
- package/dynamic-table/Body/TableRow.d.ts +4 -0
- package/dynamic-table/Body/TableRow.js +39 -0
- package/dynamic-table/Body/TableRow.styles.d.ts +10 -0
- package/dynamic-table/Body/TableRow.styles.js +23 -0
- package/dynamic-table/Body/TableRow.types.d.ts +10 -0
- package/dynamic-table/Body/TableRow.types.js +1 -0
- package/dynamic-table/DynamicTable.d.ts +4 -29
- package/dynamic-table/DynamicTable.js +55 -189
- package/dynamic-table/DynamicTable.styles.d.ts +12 -5
- package/dynamic-table/DynamicTable.styles.js +16 -17
- package/dynamic-table/DynamicTable.types.d.ts +26 -0
- package/dynamic-table/DynamicTable.types.js +1 -0
- package/dynamic-table/Head/TableHead.d.ts +4 -0
- package/dynamic-table/Head/TableHead.js +69 -0
- package/dynamic-table/Head/TableHead.styles.d.ts +24 -0
- package/dynamic-table/Head/TableHead.styles.js +72 -0
- package/dynamic-table/Head/TableHead.types.d.ts +33 -0
- package/dynamic-table/Head/TableHead.types.js +1 -0
- package/dynamic-table/Skeleton/SkeletonTable.styles.d.ts +4 -0
- package/dynamic-table/Skeleton/SkeletonTable.styles.js +18 -0
- package/dynamic-table/Skeleton/helpers/createSkeletonRows.d.ts +3 -0
- package/dynamic-table/Skeleton/helpers/createSkeletonRows.js +43 -0
- package/dynamic-table/helpers/getHeaderRow.d.ts +3 -0
- package/dynamic-table/helpers/getHeaderRow.js +19 -0
- package/dynamic-table/stories/headerRow.d.ts +3 -0
- package/dynamic-table/stories/headerRow.js +19 -0
- package/dynamic-table/stories/headerRowSortable.d.ts +3 -0
- package/dynamic-table/stories/headerRowSortable.js +21 -0
- package/dynamic-table/stories/tableRows.d.ts +3 -0
- package/dynamic-table/stories/tableRows.js +67 -0
- package/package.json +9 -9
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
-
|
|
9
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
2
|
|
|
11
3
|
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."); }
|
|
@@ -18,198 +10,72 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
18
10
|
|
|
19
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
12
|
|
|
21
|
-
import React, {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
13
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import TableBody from './Body/TableBody';
|
|
15
|
+
import { TableStyled, TableWrapperStyled } from './DynamicTable.styles';
|
|
16
|
+
import TableHead from './Head/TableHead';
|
|
17
|
+
import createSkeletonRows from './Skeleton/helpers/createSkeletonRows';
|
|
18
|
+
import { Fade } from './Skeleton/SkeletonTable.styles';
|
|
25
19
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
26
20
|
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
21
|
var DynamicTable = function DynamicTable(_ref) {
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
var activeRow = _ref.activeRow,
|
|
23
|
+
descending = _ref.descending,
|
|
24
|
+
height = _ref.height,
|
|
25
|
+
headerRow = _ref.headerRow,
|
|
26
|
+
isLoading = _ref.isLoading,
|
|
27
|
+
onClickRow = _ref.onClickRow,
|
|
35
28
|
onSelectRow = _ref.onSelectRow,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
onSort = _ref.onSort,
|
|
30
|
+
rows = _ref.rows,
|
|
31
|
+
_ref$selectedRows = _ref.selectedRows,
|
|
32
|
+
selectedRows = _ref$selectedRows === void 0 ? [] : _ref$selectedRows,
|
|
33
|
+
sortingBy = _ref.sortingBy,
|
|
39
34
|
stickyHeader = _ref.stickyHeader;
|
|
40
|
-
var keys = dataKeys || [];
|
|
41
|
-
|
|
42
|
-
if (!dataKeys) {
|
|
43
|
-
var newKeys = Object.keys(data[0]);
|
|
44
|
-
|
|
45
|
-
for (var i = 0; i < newKeys.length; i++) {
|
|
46
|
-
keys.push({
|
|
47
|
-
displayName: newKeys[i],
|
|
48
|
-
key: newKeys[i],
|
|
49
|
-
rightAlign: false
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
keys = dataKeys || keys;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var itemsAreSelectable = onSelectFunction && keys.some(function (key) {
|
|
57
|
-
return key.key === 'id';
|
|
58
|
-
}); // states
|
|
59
35
|
|
|
60
|
-
|
|
36
|
+
// states
|
|
37
|
+
var _useState = useState(sortingBy || ''),
|
|
61
38
|
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
sortByKeyValue = _useState2[0],
|
|
40
|
+
setSortByKeyValue = _useState2[1];
|
|
64
41
|
|
|
65
|
-
var _useState3 = useState(
|
|
42
|
+
var _useState3 = useState(sortingBy && descending || false),
|
|
66
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var _useState5 = useState(false),
|
|
71
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
72
|
-
sortByDescending = _useState6[0],
|
|
73
|
-
setSortByDescending = _useState6[1];
|
|
44
|
+
sortDescending = _useState4[0],
|
|
45
|
+
setSortDescending = _useState4[1];
|
|
74
46
|
|
|
47
|
+
var selectableRows = !!onSelectRow;
|
|
48
|
+
var skeletonRows = useMemo(function () {
|
|
49
|
+
return createSkeletonRows(headerRow);
|
|
50
|
+
}, [headerRow]);
|
|
75
51
|
useEffect(function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var updateSelectedRows = function updateSelectedRows(id) {
|
|
80
|
-
if (itemsAreSelectable) {
|
|
81
|
-
var selection = _toConsumableArray(selectedRows);
|
|
82
|
-
|
|
83
|
-
if (selectedRows.includes(id)) {
|
|
84
|
-
var index = selectedRows.indexOf(id);
|
|
85
|
-
if (index !== -1) selection.splice(index, 1);
|
|
86
|
-
setSelectedRows(selection);
|
|
87
|
-
} else {
|
|
88
|
-
selection.push(id);
|
|
89
|
-
setSelectedRows(selection);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var toggleAll = function toggleAll() {
|
|
95
|
-
if (onSelectFunction) {
|
|
96
|
-
if (selectedRows.length === 0) {
|
|
97
|
-
var newArray = [];
|
|
98
|
-
|
|
99
|
-
for (var _i2 = 0; _i2 < data.length; _i2++) {
|
|
100
|
-
newArray.push(data[_i2].id);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
setSelectedRows(newArray);
|
|
104
|
-
onSelectFunction(selectedRows);
|
|
105
|
-
} else {
|
|
106
|
-
setSelectedRows([]);
|
|
107
|
-
onSelectFunction(selectedRows);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
var sort = function sort(oldKey, newKey) {
|
|
113
|
-
if (onSortByKey) {
|
|
114
|
-
if (oldKey !== newKey) {
|
|
115
|
-
setSortByKeyValue(newKey);
|
|
116
|
-
setSortByDescending(false);
|
|
117
|
-
} else {
|
|
118
|
-
setSortByDescending(!sortByDescending);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var selectRow = function selectRow(id) {
|
|
124
|
-
onSelectRow && onSelectRow(id);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
useEffect(function () {
|
|
128
|
-
if (onSortByKey) {
|
|
129
|
-
onSortByKey(sortByKeyValue, sortByDescending);
|
|
130
|
-
}
|
|
131
|
-
}, [sortByDescending, sortByKeyValue, onSortByKey]);
|
|
132
|
-
return ___EmotionJSX("div", {
|
|
133
|
-
css: dynamicTableWrapperStyle({
|
|
134
|
-
stickyHeader: stickyHeader,
|
|
135
|
-
fixedHeight: fixedHeight,
|
|
136
|
-
columns: keys.length,
|
|
137
|
-
onSelectFunction: onSelectFunction,
|
|
138
|
-
onSortByKey: onSortByKey
|
|
139
|
-
})
|
|
140
|
-
}, ___EmotionJSX("table", {
|
|
141
|
-
className: className
|
|
142
|
-
}, hasHeader && ___EmotionJSX("thead", null, ___EmotionJSX("tr", null, itemsAreSelectable && ___EmotionJSX("th", {
|
|
143
|
-
className: "checkboxColumn"
|
|
144
|
-
}, ___EmotionJSX(Checkbox, {
|
|
145
|
-
indeterminate: true,
|
|
146
|
-
size: "small",
|
|
147
|
-
name: "all",
|
|
148
|
-
checked: selectedRows.length > 0,
|
|
149
|
-
onChange: function onChange() {
|
|
150
|
-
toggleAll();
|
|
52
|
+
if (onSort) {
|
|
53
|
+
onSort(sortByKeyValue, sortDescending);
|
|
151
54
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}))), ___EmotionJSX("tbody", null, data.map(function (row, i) {
|
|
177
|
-
return ___EmotionJSX("tr", {
|
|
178
|
-
className: "dynamicTableRow-".concat(i),
|
|
179
|
-
css: rowStyle({
|
|
180
|
-
hoverColor: !!onSelectRow
|
|
181
|
-
}),
|
|
182
|
-
key: i
|
|
183
|
-
}, itemsAreSelectable && ___EmotionJSX("td", {
|
|
184
|
-
className: "checkboxColumn"
|
|
185
|
-
}, ___EmotionJSX(Checkbox, {
|
|
186
|
-
size: "small",
|
|
187
|
-
name: row.id,
|
|
188
|
-
checked: selectedRows.includes(row.id),
|
|
189
|
-
onChange: function onChange() {
|
|
190
|
-
updateSelectedRows(row.id);
|
|
191
|
-
}
|
|
192
|
-
})), keys.map(function (cell, index) {
|
|
193
|
-
var cellElement = row[cell.key];
|
|
194
|
-
return ___EmotionJSX("td", {
|
|
195
|
-
className: "dynamicTableColumn-".concat(cell.key),
|
|
196
|
-
onClick: function onClick() {
|
|
197
|
-
return onSelectRow && row.id ? selectRow(row.id) : null;
|
|
198
|
-
},
|
|
199
|
-
css: cellStyle({
|
|
200
|
-
onSelectFunction: !!onSelectFunction,
|
|
201
|
-
columns: keys.length,
|
|
202
|
-
bold: cell.bold,
|
|
203
|
-
customColumnWidth: cell.customColumnWidth,
|
|
204
|
-
color: !badgesScheme && colorScheme && colorScheme.colors && colorScheme.colors[cellElement] || null
|
|
205
|
-
}),
|
|
206
|
-
align: cell.rightAlign ? 'right' : 'left',
|
|
207
|
-
key: index
|
|
208
|
-
}, !(badgesScheme !== null && badgesScheme !== void 0 && badgesScheme.intentMapping[cellElement]) && ___EmotionJSX("span", null, cellElement || '-'), (badgesScheme === null || badgesScheme === void 0 ? void 0 : badgesScheme.intentMapping[cellElement]) && ___EmotionJSX(Badge, {
|
|
209
|
-
intent: badgesScheme.intentMapping[cellElement]
|
|
210
|
-
}, cellElement || '-'));
|
|
211
|
-
}));
|
|
212
|
-
}))));
|
|
55
|
+
}, [sortDescending, onSort, sortByKeyValue]);
|
|
56
|
+
return ___EmotionJSX(TableWrapperStyled, {
|
|
57
|
+
height: height
|
|
58
|
+
}, ___EmotionJSX(TableStyled, null, headerRow && ___EmotionJSX(TableHead, {
|
|
59
|
+
headerRow: headerRow,
|
|
60
|
+
onSelectRow: onSelectRow,
|
|
61
|
+
onSort: onSort,
|
|
62
|
+
rows: rows,
|
|
63
|
+
selectableRows: selectableRows,
|
|
64
|
+
selectedRows: selectedRows,
|
|
65
|
+
setSortDescending: setSortDescending,
|
|
66
|
+
setSortByKeyValue: setSortByKeyValue,
|
|
67
|
+
sortDescending: sortDescending,
|
|
68
|
+
sortByKeyValue: sortByKeyValue,
|
|
69
|
+
stickyHeader: stickyHeader
|
|
70
|
+
}), ___EmotionJSX(TableBody, {
|
|
71
|
+
activeRow: activeRow,
|
|
72
|
+
headerRow: headerRow,
|
|
73
|
+
onClickRow: onClickRow,
|
|
74
|
+
onSelectRow: onSelectRow,
|
|
75
|
+
rows: !isLoading ? rows : skeletonRows,
|
|
76
|
+
selectableRows: selectableRows,
|
|
77
|
+
selectedRows: selectedRows
|
|
78
|
+
})), isLoading && ___EmotionJSX(Fade, null));
|
|
213
79
|
};
|
|
214
80
|
|
|
215
|
-
export default DynamicTable;
|
|
81
|
+
export default /*#__PURE__*/React.memo(DynamicTable);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
1
|
+
declare type TableWrapperProps = {
|
|
2
|
+
height?: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const TableWrapperStyled: import("@emotion/styled").StyledComponent<{
|
|
5
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
6
|
+
as?: import("react").ElementType<any> | undefined;
|
|
7
|
+
} & TableWrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
8
|
+
export declare const TableStyled: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
+
as?: import("react").ElementType<any> | undefined;
|
|
11
|
+
}, import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, {}>;
|
|
12
|
+
export {};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _styled from "@emotion/styled/base";
|
|
2
2
|
import { theme } from '@dfds-ui/theme';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
3
|
+
export var TableWrapperStyled = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
4
|
+
target: "e1dds0xk1"
|
|
5
|
+
} : {
|
|
6
|
+
target: "e1dds0xk1",
|
|
7
|
+
label: "TableWrapperStyled"
|
|
8
|
+
})("color:", theme.colors.text.primary, ";display:flex;flex-direction:column;overflow-x:auto;width:100%;", function (_ref) {
|
|
9
|
+
var height = _ref.height;
|
|
10
|
+
return height && "\n height: ".concat(height, ";\n overflow-y: ").concat(height && 'auto', ";\n ");
|
|
11
|
+
}, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0R5bmFtaWNUYWJsZS5zdHlsZXMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU8rRCIsImZpbGUiOiIuLi8uLi9zcmMvZHluYW1pYy10YWJsZS9EeW5hbWljVGFibGUuc3R5bGVzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHRoZW1lIH0gZnJvbSAnQGRmZHMtdWkvdGhlbWUnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcblxudHlwZSBUYWJsZVdyYXBwZXJQcm9wcyA9IHtcbiAgaGVpZ2h0Pzogc3RyaW5nXG59XG5cbmV4cG9ydCBjb25zdCBUYWJsZVdyYXBwZXJTdHlsZWQgPSBzdHlsZWQuZGl2PFRhYmxlV3JhcHBlclByb3BzPmBcbiAgY29sb3I6ICR7dGhlbWUuY29sb3JzLnRleHQucHJpbWFyeX07XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGZsZXgtZGlyZWN0aW9uOiBjb2x1bW47XG4gIG92ZXJmbG93LXg6IGF1dG87XG4gIHdpZHRoOiAxMDAlO1xuXG4gICR7KHsgaGVpZ2h0IH0pID0+XG4gICAgaGVpZ2h0ICYmXG4gICAgYFxuICAgICAgaGVpZ2h0OiAke2hlaWdodH07XG4gICAgICBvdmVyZmxvdy15OiAke2hlaWdodCAmJiAnYXV0byd9O1xuICAgIGB9O1xuYFxuXG5leHBvcnQgY29uc3QgVGFibGVTdHlsZWQgPSBzdHlsZWQudGFibGVgXG4gIGJhY2tncm91bmQtY29sb3I6ICR7dGhlbWUuY29sb3JzLnN1cmZhY2UucHJpbWFyeX07XG4gIGZvbnQtZmFtaWx5OiBWZXJkYW5hLCBzYW5zLXNlcmlmO1xuICBmb250LXNpemU6IDEycHg7XG4gIGxpbmUtaGVpZ2h0OiAxNnB4O1xuICB3aWR0aDogMTAwJTtcbmBcbiJdfQ== */"));
|
|
12
|
+
export var TableStyled = _styled("table", process.env.NODE_ENV === "production" ? {
|
|
13
|
+
target: "e1dds0xk0"
|
|
14
|
+
} : {
|
|
15
|
+
target: "e1dds0xk0",
|
|
16
|
+
label: "TableStyled"
|
|
17
|
+
})("background-color:", theme.colors.surface.primary, ";font-family:Verdana,sans-serif;font-size:12px;line-height:16px;width:100%;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9keW5hbWljLXRhYmxlL0R5bmFtaWNUYWJsZS5zdHlsZXMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXNCdUMiLCJmaWxlIjoiLi4vLi4vc3JjL2R5bmFtaWMtdGFibGUvRHluYW1pY1RhYmxlLnN0eWxlcy50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyB0aGVtZSB9IGZyb20gJ0BkZmRzLXVpL3RoZW1lJ1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5cbnR5cGUgVGFibGVXcmFwcGVyUHJvcHMgPSB7XG4gIGhlaWdodD86IHN0cmluZ1xufVxuXG5leHBvcnQgY29uc3QgVGFibGVXcmFwcGVyU3R5bGVkID0gc3R5bGVkLmRpdjxUYWJsZVdyYXBwZXJQcm9wcz5gXG4gIGNvbG9yOiAke3RoZW1lLmNvbG9ycy50ZXh0LnByaW1hcnl9O1xuICBkaXNwbGF5OiBmbGV4O1xuICBmbGV4LWRpcmVjdGlvbjogY29sdW1uO1xuICBvdmVyZmxvdy14OiBhdXRvO1xuICB3aWR0aDogMTAwJTtcblxuICAkeyh7IGhlaWdodCB9KSA9PlxuICAgIGhlaWdodCAmJlxuICAgIGBcbiAgICAgIGhlaWdodDogJHtoZWlnaHR9O1xuICAgICAgb3ZlcmZsb3cteTogJHtoZWlnaHQgJiYgJ2F1dG8nfTtcbiAgICBgfTtcbmBcblxuZXhwb3J0IGNvbnN0IFRhYmxlU3R5bGVkID0gc3R5bGVkLnRhYmxlYFxuICBiYWNrZ3JvdW5kLWNvbG9yOiAke3RoZW1lLmNvbG9ycy5zdXJmYWNlLnByaW1hcnl9O1xuICBmb250LWZhbWlseTogVmVyZGFuYSwgc2Fucy1zZXJpZjtcbiAgZm9udC1zaXplOiAxMnB4O1xuICBsaW5lLWhlaWdodDogMTZweDtcbiAgd2lkdGg6IDEwMCU7XG5gXG4iXX0= */"));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare type Header = {
|
|
2
|
+
displayName: string;
|
|
3
|
+
key: string;
|
|
4
|
+
sortKey?: string;
|
|
5
|
+
sortable?: boolean;
|
|
6
|
+
textAlign?: 'center' | 'left' | 'right';
|
|
7
|
+
width?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type Row = {
|
|
10
|
+
id?: string;
|
|
11
|
+
[name: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export declare type DynamicTableProps = {
|
|
14
|
+
activeRow?: string;
|
|
15
|
+
descending?: boolean;
|
|
16
|
+
headerRow: Header[];
|
|
17
|
+
height?: string;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
onClickRow?: (id: string) => void;
|
|
20
|
+
onSelectRow?: (list: string[]) => void;
|
|
21
|
+
onSort?: (value: string, sortDescending: boolean) => void;
|
|
22
|
+
rows: Row[];
|
|
23
|
+
selectedRows?: string[];
|
|
24
|
+
sortingBy?: string;
|
|
25
|
+
stickyHeader?: boolean;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
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>;
|
|
4
|
+
export default TableHead;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Checkbox } from '@dfds-ui/react-components';
|
|
3
|
+
import { ChevronStyled, TableHeadCellCheckboxStyled, TableHeadCellStyled, TableHeadRow } from './TableHead.styles';
|
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
5
|
+
var TableHead = /*#__PURE__*/React.memo(function (_ref) {
|
|
6
|
+
var headerRow = _ref.headerRow,
|
|
7
|
+
onSelectRow = _ref.onSelectRow,
|
|
8
|
+
onSort = _ref.onSort,
|
|
9
|
+
rows = _ref.rows,
|
|
10
|
+
selectableRows = _ref.selectableRows,
|
|
11
|
+
selectedRows = _ref.selectedRows,
|
|
12
|
+
setSortDescending = _ref.setSortDescending,
|
|
13
|
+
setSortByKeyValue = _ref.setSortByKeyValue,
|
|
14
|
+
sortDescending = _ref.sortDescending,
|
|
15
|
+
sortByKeyValue = _ref.sortByKeyValue,
|
|
16
|
+
stickyHeader = _ref.stickyHeader;
|
|
17
|
+
var toggleAll = useCallback(function () {
|
|
18
|
+
if (!onSelectRow) return;
|
|
19
|
+
var newArray = [];
|
|
20
|
+
|
|
21
|
+
if (selectedRows.length === 0) {
|
|
22
|
+
for (var i = 0; i < rows.length; i++) {
|
|
23
|
+
newArray.push(rows[i].id || '');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onSelectRow(newArray);
|
|
28
|
+
}, [onSelectRow, rows, selectedRows]);
|
|
29
|
+
var sort = useCallback(function (oldKey, newKey) {
|
|
30
|
+
if (!onSort) return;
|
|
31
|
+
|
|
32
|
+
if (oldKey !== newKey) {
|
|
33
|
+
setSortByKeyValue(newKey);
|
|
34
|
+
setSortDescending(false);
|
|
35
|
+
} else {
|
|
36
|
+
setSortDescending(!sortDescending);
|
|
37
|
+
}
|
|
38
|
+
}, [onSort, setSortDescending, setSortByKeyValue, sortDescending]);
|
|
39
|
+
return ___EmotionJSX("thead", null, ___EmotionJSX(TableHeadRow, null, selectableRows && ___EmotionJSX(TableHeadCellCheckboxStyled, {
|
|
40
|
+
stickyHeader: stickyHeader
|
|
41
|
+
}, ___EmotionJSX(Checkbox, {
|
|
42
|
+
checked: selectedRows.length > 0,
|
|
43
|
+
indeterminate: true,
|
|
44
|
+
name: "all",
|
|
45
|
+
onChange: toggleAll,
|
|
46
|
+
size: "small"
|
|
47
|
+
})), headerRow.map(function (headerCell, i) {
|
|
48
|
+
var sortKey = headerCell.sortKey || headerCell.key;
|
|
49
|
+
|
|
50
|
+
var clickHandler = function clickHandler() {
|
|
51
|
+
return headerCell.sortable && sort(sortByKeyValue, sortKey);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var showChevron = String(sortByKeyValue === sortKey);
|
|
55
|
+
return ___EmotionJSX(TableHeadCellStyled, {
|
|
56
|
+
align: headerCell.textAlign,
|
|
57
|
+
key: i,
|
|
58
|
+
onClick: clickHandler,
|
|
59
|
+
sortByKey: onSort,
|
|
60
|
+
sortable: headerCell.sortable,
|
|
61
|
+
stickyHeader: stickyHeader,
|
|
62
|
+
customWidth: headerCell.width
|
|
63
|
+
}, ___EmotionJSX("div", null, ___EmotionJSX("span", null, headerCell.displayName), headerCell.sortable && onSort && ___EmotionJSX(ChevronStyled, {
|
|
64
|
+
descending: String(sortDescending),
|
|
65
|
+
show: showChevron
|
|
66
|
+
})));
|
|
67
|
+
})));
|
|
68
|
+
});
|
|
69
|
+
export default TableHead;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChevronProps, GenericTableHeadCellProps, TableHeadCellCheckboxProps, TableHeadCellProps } from './TableHead.types';
|
|
2
|
+
export declare const TableHeadRow: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, {}>;
|
|
6
|
+
export declare const TableHeadCellStyled: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any> | undefined;
|
|
9
|
+
} & GenericTableHeadCellProps & import("react").ClassAttributes<HTMLTableHeaderCellElement> & import("react").ThHTMLAttributes<HTMLTableHeaderCellElement> & {
|
|
10
|
+
children?: import("react").ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
} & TableHeadCellProps, {}, {}>;
|
|
14
|
+
export declare const TableHeadCellCheckboxStyled: import("@emotion/styled").StyledComponent<{
|
|
15
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
16
|
+
as?: import("react").ElementType<any> | undefined;
|
|
17
|
+
} & GenericTableHeadCellProps & import("react").ClassAttributes<HTMLTableHeaderCellElement> & import("react").ThHTMLAttributes<HTMLTableHeaderCellElement> & {
|
|
18
|
+
children?: import("react").ReactNode;
|
|
19
|
+
} & {
|
|
20
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
21
|
+
} & TableHeadCellCheckboxProps, {}, {}>;
|
|
22
|
+
export declare const ChevronStyled: import("@emotion/styled").StyledComponent<Pick<import("react").SVGProps<SVGSVGElement>, "string" | "filter" | "values" | "fill" | "max" | "type" | "accumulate" | "offset" | "key" | "id" | "media" | "origin" | "height" | "width" | "end" | "name" | "alignmentBaseline" | "baselineShift" | "clip" | "clipPath" | "clipRule" | "color" | "colorInterpolation" | "colorInterpolationFilters" | "cursor" | "direction" | "display" | "dominantBaseline" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "imageRendering" | "letterSpacing" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "mask" | "opacity" | "order" | "overflow" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "textDecoration" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "wordSpacing" | "writingMode" | "alphabetic" | "hanging" | "ideographic" | "style" | "path" | "method" | "target" | "lang" | "className" | "children" | "tabIndex" | "orientation" | "local" | "x" | "y" | "mathematical" | "azimuth" | "colorRendering" | "glyphOrientationVertical" | "vectorEffect" | "additive" | "unicodeRange" | "crossOrigin" | "href" | "min" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "accentHeight" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unitsPerEm" | "vAlphabetic" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "yChannelSelector" | "z" | "zoomAndPan" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css"> & import("react").RefAttributes<SVGSVGElement> & {
|
|
23
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
24
|
+
} & ChevronProps, {}, {}>;
|