@equinor/eds-data-grid-react 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eds-data-grid-react.cjs +113 -17
- package/dist/esm/EdsDataGrid.js +19 -1
- package/dist/esm/EdsDataGridContext.js +1 -0
- package/dist/esm/components/Resizer.js +12 -0
- package/dist/esm/components/TableCell.js +19 -0
- package/dist/esm/components/TableFooterCell.js +69 -0
- package/dist/esm/components/TableFooterRow.js +21 -0
- package/dist/esm/components/TableHeaderCell.js +4 -25
- package/dist/types/EdsDataGrid.d.ts +1 -1
- package/dist/types/EdsDataGridContext.d.ts +3 -0
- package/dist/types/EdsDataGridProps.d.ts +19 -0
- package/dist/types/components/Resizer.d.ts +8 -0
- package/dist/types/components/TableCell.d.ts +18 -0
- package/dist/types/components/TableFooterCell.d.ts +9 -0
- package/dist/types/components/TableFooterRow.d.ts +9 -0
- package/package.json +4 -4
|
@@ -6,8 +6,8 @@ var reactVirtual = require('@tanstack/react-virtual');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
-
var edsTokens = require('@equinor/eds-tokens');
|
|
10
9
|
var edsIcons = require('@equinor/eds-icons');
|
|
10
|
+
var edsTokens = require('@equinor/eds-tokens');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
@@ -17,6 +17,7 @@ var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
|
17
17
|
const EdsDataGridContext = /*#__PURE__*/react.createContext({
|
|
18
18
|
enableSorting: false,
|
|
19
19
|
stickyHeader: false,
|
|
20
|
+
stickyFooter: false,
|
|
20
21
|
enableColumnFiltering: false,
|
|
21
22
|
table: null
|
|
22
23
|
});
|
|
@@ -236,23 +237,18 @@ const SortIndicator = ({
|
|
|
236
237
|
}[column.getIsSorted()] ?? null;
|
|
237
238
|
};
|
|
238
239
|
|
|
239
|
-
const getSortLabel = sorted => {
|
|
240
|
-
if (sorted) {
|
|
241
|
-
return `${sorted}ending`;
|
|
242
|
-
}
|
|
243
|
-
return 'none';
|
|
244
|
-
};
|
|
245
240
|
const ResizeInner = styled__default.default.div.withConfig({
|
|
246
|
-
displayName: "
|
|
247
|
-
componentId: "sc-
|
|
241
|
+
displayName: "Resizer__ResizeInner",
|
|
242
|
+
componentId: "sc-plcbjs-0"
|
|
248
243
|
})(["width:2px;opacity:0;height:100%;"]);
|
|
249
244
|
const Resizer = styled__default.default.div.withConfig({
|
|
250
|
-
displayName: "
|
|
251
|
-
componentId: "sc-
|
|
245
|
+
displayName: "Resizer",
|
|
246
|
+
componentId: "sc-plcbjs-1"
|
|
252
247
|
})(["transform:", ";", "{opacity:", ";}position:absolute;right:0;top:0;height:100%;width:5px;cursor:col-resize;user-select:none;touch-action:none;display:flex;justify-content:flex-end;"], props => props.$columnResizeMode === 'onEnd' ? 'translateX(0px)' : 'none', ResizeInner, props => props.$isResizing ? 1 : 0);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
248
|
+
|
|
249
|
+
const TableCell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
250
|
+
displayName: "TableCell",
|
|
251
|
+
componentId: "sc-1g0k23m-0"
|
|
256
252
|
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
257
253
|
if (p.$pinned) {
|
|
258
254
|
return `${p.$pinned}: ${p.$offset}px;`;
|
|
@@ -262,6 +258,13 @@ const Cell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
|
262
258
|
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
263
259
|
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
264
260
|
}, ResizeInner, edsTokens.tokens.colors.interactive.primary__hover.rgba);
|
|
261
|
+
|
|
262
|
+
const getSortLabel = sorted => {
|
|
263
|
+
if (sorted) {
|
|
264
|
+
return `${sorted}ending`;
|
|
265
|
+
}
|
|
266
|
+
return 'none';
|
|
267
|
+
};
|
|
265
268
|
function TableHeaderCell({
|
|
266
269
|
header,
|
|
267
270
|
columnResizeMode
|
|
@@ -275,7 +278,7 @@ function TableHeaderCell({
|
|
|
275
278
|
}
|
|
276
279
|
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - header.getSize();
|
|
277
280
|
}, [pinned, header, table]);
|
|
278
|
-
return header.isPlaceholder ? /*#__PURE__*/jsxRuntime.jsx(
|
|
281
|
+
return header.isPlaceholder ? /*#__PURE__*/jsxRuntime.jsx(TableCell, {
|
|
279
282
|
$sticky: ctx.stickyHeader,
|
|
280
283
|
$offset: offset,
|
|
281
284
|
$pinned: pinned,
|
|
@@ -284,7 +287,7 @@ function TableHeaderCell({
|
|
|
284
287
|
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
285
288
|
},
|
|
286
289
|
"aria-hidden": true
|
|
287
|
-
}) : /*#__PURE__*/jsxRuntime.jsxs(
|
|
290
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(TableCell, {
|
|
288
291
|
$sticky: ctx.stickyHeader,
|
|
289
292
|
$offset: offset,
|
|
290
293
|
$pinned: pinned,
|
|
@@ -348,6 +351,82 @@ function TableHeaderRow({
|
|
|
348
351
|
});
|
|
349
352
|
}
|
|
350
353
|
|
|
354
|
+
function TableFooterCell({
|
|
355
|
+
footer,
|
|
356
|
+
columnResizeMode
|
|
357
|
+
}) {
|
|
358
|
+
const ctx = useTableContext();
|
|
359
|
+
const table = ctx.table;
|
|
360
|
+
const pinned = footer.column.getIsPinned();
|
|
361
|
+
const offset = react.useMemo(() => {
|
|
362
|
+
if (!pinned) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
return pinned === 'left' ? footer.getStart() : table.getTotalSize() - footer.getStart() - footer.getSize();
|
|
366
|
+
}, [pinned, footer, table]);
|
|
367
|
+
return footer.isPlaceholder ? /*#__PURE__*/jsxRuntime.jsx(TableCell, {
|
|
368
|
+
$sticky: ctx.stickyFooter,
|
|
369
|
+
$offset: offset,
|
|
370
|
+
$pinned: pinned,
|
|
371
|
+
className: ctx.footerClass ? ctx.footerClass(footer.column) : '',
|
|
372
|
+
style: {
|
|
373
|
+
...(ctx.footerStyle ? ctx.footerStyle(footer.column) : {})
|
|
374
|
+
},
|
|
375
|
+
"aria-hidden": true
|
|
376
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(TableCell, {
|
|
377
|
+
$sticky: ctx.stickyFooter,
|
|
378
|
+
$offset: offset,
|
|
379
|
+
$pinned: pinned,
|
|
380
|
+
className: ctx.footerClass ? ctx.footerClass(footer.column) : '',
|
|
381
|
+
onClick: footer.column.getToggleSortingHandler(),
|
|
382
|
+
colSpan: footer.colSpan,
|
|
383
|
+
style: {
|
|
384
|
+
width: footer.getSize(),
|
|
385
|
+
verticalAlign: ctx.enableColumnFiltering ? 'top' : 'middle',
|
|
386
|
+
...(ctx.footerStyle ? ctx.footerStyle(footer.column) : {})
|
|
387
|
+
},
|
|
388
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
389
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
390
|
+
style: {
|
|
391
|
+
display: 'flex',
|
|
392
|
+
flexDirection: 'column'
|
|
393
|
+
},
|
|
394
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
395
|
+
className: "table-footer-cell-label",
|
|
396
|
+
children: reactTable.flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
397
|
+
})
|
|
398
|
+
}), !footer.column.columnDef.meta?.customFilterInput && /*#__PURE__*/jsxRuntime.jsx(SortIndicator, {
|
|
399
|
+
column: footer.column
|
|
400
|
+
})]
|
|
401
|
+
}), columnResizeMode && /*#__PURE__*/jsxRuntime.jsx(Resizer, {
|
|
402
|
+
onClick: e => e.stopPropagation(),
|
|
403
|
+
onMouseDown: footer.getResizeHandler(),
|
|
404
|
+
onTouchStart: footer.getResizeHandler(),
|
|
405
|
+
$isResizing: footer.column.getIsResizing(),
|
|
406
|
+
$columnResizeMode: columnResizeMode,
|
|
407
|
+
className: 'resize-handle',
|
|
408
|
+
"data-testid": 'resize-handle',
|
|
409
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ResizeInner, {})
|
|
410
|
+
})]
|
|
411
|
+
}, footer.id);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function TableFooterRow({
|
|
415
|
+
footerGroup,
|
|
416
|
+
columnResizeMode,
|
|
417
|
+
deltaOffset,
|
|
418
|
+
table
|
|
419
|
+
}) {
|
|
420
|
+
return /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
421
|
+
children: footerGroup.headers.map(footer => /*#__PURE__*/jsxRuntime.jsx(TableFooterCell, {
|
|
422
|
+
footer: footer,
|
|
423
|
+
table: table,
|
|
424
|
+
columnResizeMode: columnResizeMode,
|
|
425
|
+
deltaOffset: deltaOffset
|
|
426
|
+
}, footer.id))
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
351
430
|
const StyledCell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
352
431
|
displayName: "TableBodyCell__StyledCell",
|
|
353
432
|
componentId: "sc-1gsd2k4-0"
|
|
@@ -470,6 +549,7 @@ function EdsDataGrid({
|
|
|
470
549
|
enablePagination,
|
|
471
550
|
enableSorting,
|
|
472
551
|
stickyHeader,
|
|
552
|
+
stickyFooter,
|
|
473
553
|
onSelectRow,
|
|
474
554
|
onRowSelectionChange,
|
|
475
555
|
caption,
|
|
@@ -485,6 +565,8 @@ function EdsDataGrid({
|
|
|
485
565
|
rowStyle,
|
|
486
566
|
headerClass,
|
|
487
567
|
headerStyle,
|
|
568
|
+
footerClass,
|
|
569
|
+
footerStyle,
|
|
488
570
|
externalPaginator,
|
|
489
571
|
onSortingChange,
|
|
490
572
|
manualSorting,
|
|
@@ -503,7 +585,8 @@ function EdsDataGrid({
|
|
|
503
585
|
getSubRows,
|
|
504
586
|
defaultColumn,
|
|
505
587
|
onRowClick,
|
|
506
|
-
onCellClick
|
|
588
|
+
onCellClick,
|
|
589
|
+
enableFooter
|
|
507
590
|
}) {
|
|
508
591
|
logDevelopmentWarningOfPropUse({
|
|
509
592
|
virtualHeight: {
|
|
@@ -754,6 +837,7 @@ function EdsDataGrid({
|
|
|
754
837
|
// These classes are primarily used to allow for feature-detection in the test-suite
|
|
755
838
|
const classList = {
|
|
756
839
|
'sticky-header': !!stickyHeader,
|
|
840
|
+
'sticky-footer': !!stickyFooter,
|
|
757
841
|
virtual: !!enableVirtual,
|
|
758
842
|
paging: !!enablePagination
|
|
759
843
|
};
|
|
@@ -764,10 +848,13 @@ function EdsDataGrid({
|
|
|
764
848
|
rowStyle: rowStyle,
|
|
765
849
|
headerClass: headerClass,
|
|
766
850
|
headerStyle: headerStyle,
|
|
851
|
+
footerClass: footerClass,
|
|
852
|
+
footerStyle: footerStyle,
|
|
767
853
|
table: table,
|
|
768
854
|
enableSorting: !!enableSorting,
|
|
769
855
|
enableColumnFiltering: !!enableColumnFiltering,
|
|
770
856
|
stickyHeader: !!stickyHeader,
|
|
857
|
+
stickyFooter: !!stickyFooter,
|
|
771
858
|
children: [/*#__PURE__*/jsxRuntime.jsxs(TableWrapper, {
|
|
772
859
|
className: "table-wrapper",
|
|
773
860
|
style: tableWrapperStyle,
|
|
@@ -837,6 +924,15 @@ function EdsDataGrid({
|
|
|
837
924
|
onClick: onRowClick ? event => onRowClick(row, event) : undefined,
|
|
838
925
|
onCellClick: onCellClick
|
|
839
926
|
}, row.id))]
|
|
927
|
+
}), enableFooter && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Foot, {
|
|
928
|
+
sticky: stickyFooter,
|
|
929
|
+
"data-testid": "eds-grid-footer",
|
|
930
|
+
children: table.getFooterGroups().map(footerGroup => /*#__PURE__*/jsxRuntime.jsx(TableFooterRow, {
|
|
931
|
+
table: table,
|
|
932
|
+
footerGroup: footerGroup,
|
|
933
|
+
columnResizeMode: columnResizeMode,
|
|
934
|
+
deltaOffset: table.getState().columnSizingInfo.deltaOffset
|
|
935
|
+
}, footerGroup.id))
|
|
840
936
|
})]
|
|
841
937
|
}), externalPaginator ? externalPaginator : enablePagination && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
842
938
|
style: {
|
package/dist/esm/EdsDataGrid.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useState, useEffect, useMemo, useRef, useCallback } from 'react';
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { TableProvider } from './EdsDataGridContext.js';
|
|
7
7
|
import { TableHeaderRow } from './components/TableHeaderRow.js';
|
|
8
|
+
import { TableFooterRow } from './components/TableFooterRow.js';
|
|
8
9
|
import { TableRow } from './components/TableRow.js';
|
|
9
10
|
import { addPxSuffixIfInputHasNoPrefix, logDevelopmentWarningOfPropUse } from './utils.js';
|
|
10
11
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -26,6 +27,7 @@ function EdsDataGrid({
|
|
|
26
27
|
enablePagination,
|
|
27
28
|
enableSorting,
|
|
28
29
|
stickyHeader,
|
|
30
|
+
stickyFooter,
|
|
29
31
|
onSelectRow,
|
|
30
32
|
onRowSelectionChange,
|
|
31
33
|
caption,
|
|
@@ -41,6 +43,8 @@ function EdsDataGrid({
|
|
|
41
43
|
rowStyle,
|
|
42
44
|
headerClass,
|
|
43
45
|
headerStyle,
|
|
46
|
+
footerClass,
|
|
47
|
+
footerStyle,
|
|
44
48
|
externalPaginator,
|
|
45
49
|
onSortingChange,
|
|
46
50
|
manualSorting,
|
|
@@ -59,7 +63,8 @@ function EdsDataGrid({
|
|
|
59
63
|
getSubRows,
|
|
60
64
|
defaultColumn,
|
|
61
65
|
onRowClick,
|
|
62
|
-
onCellClick
|
|
66
|
+
onCellClick,
|
|
67
|
+
enableFooter
|
|
63
68
|
}) {
|
|
64
69
|
logDevelopmentWarningOfPropUse({
|
|
65
70
|
virtualHeight: {
|
|
@@ -310,6 +315,7 @@ function EdsDataGrid({
|
|
|
310
315
|
// These classes are primarily used to allow for feature-detection in the test-suite
|
|
311
316
|
const classList = {
|
|
312
317
|
'sticky-header': !!stickyHeader,
|
|
318
|
+
'sticky-footer': !!stickyFooter,
|
|
313
319
|
virtual: !!enableVirtual,
|
|
314
320
|
paging: !!enablePagination
|
|
315
321
|
};
|
|
@@ -320,10 +326,13 @@ function EdsDataGrid({
|
|
|
320
326
|
rowStyle: rowStyle,
|
|
321
327
|
headerClass: headerClass,
|
|
322
328
|
headerStyle: headerStyle,
|
|
329
|
+
footerClass: footerClass,
|
|
330
|
+
footerStyle: footerStyle,
|
|
323
331
|
table: table,
|
|
324
332
|
enableSorting: !!enableSorting,
|
|
325
333
|
enableColumnFiltering: !!enableColumnFiltering,
|
|
326
334
|
stickyHeader: !!stickyHeader,
|
|
335
|
+
stickyFooter: !!stickyFooter,
|
|
327
336
|
children: [/*#__PURE__*/jsxs(TableWrapper, {
|
|
328
337
|
className: "table-wrapper",
|
|
329
338
|
style: tableWrapperStyle,
|
|
@@ -393,6 +402,15 @@ function EdsDataGrid({
|
|
|
393
402
|
onClick: onRowClick ? event => onRowClick(row, event) : undefined,
|
|
394
403
|
onCellClick: onCellClick
|
|
395
404
|
}, row.id))]
|
|
405
|
+
}), enableFooter && /*#__PURE__*/jsx(Table.Foot, {
|
|
406
|
+
sticky: stickyFooter,
|
|
407
|
+
"data-testid": "eds-grid-footer",
|
|
408
|
+
children: table.getFooterGroups().map(footerGroup => /*#__PURE__*/jsx(TableFooterRow, {
|
|
409
|
+
table: table,
|
|
410
|
+
footerGroup: footerGroup,
|
|
411
|
+
columnResizeMode: columnResizeMode,
|
|
412
|
+
deltaOffset: table.getState().columnSizingInfo.deltaOffset
|
|
413
|
+
}, footerGroup.id))
|
|
396
414
|
})]
|
|
397
415
|
}), externalPaginator ? externalPaginator : enablePagination && /*#__PURE__*/jsx("div", {
|
|
398
416
|
style: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const ResizeInner = styled.div.withConfig({
|
|
4
|
+
displayName: "Resizer__ResizeInner",
|
|
5
|
+
componentId: "sc-plcbjs-0"
|
|
6
|
+
})(["width:2px;opacity:0;height:100%;"]);
|
|
7
|
+
const Resizer = styled.div.withConfig({
|
|
8
|
+
displayName: "Resizer",
|
|
9
|
+
componentId: "sc-plcbjs-1"
|
|
10
|
+
})(["transform:", ";", "{opacity:", ";}position:absolute;right:0;top:0;height:100%;width:5px;cursor:col-resize;user-select:none;touch-action:none;display:flex;justify-content:flex-end;"], props => props.$columnResizeMode === 'onEnd' ? 'translateX(0px)' : 'none', ResizeInner, props => props.$isResizing ? 1 : 0);
|
|
11
|
+
|
|
12
|
+
export { ResizeInner, Resizer };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Table } from '@equinor/eds-core-react';
|
|
2
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { ResizeInner } from './Resizer.js';
|
|
5
|
+
|
|
6
|
+
const TableCell = styled(Table.Cell).withConfig({
|
|
7
|
+
displayName: "TableCell",
|
|
8
|
+
componentId: "sc-1g0k23m-0"
|
|
9
|
+
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
10
|
+
if (p.$pinned) {
|
|
11
|
+
return `${p.$pinned}: ${p.$offset}px;`;
|
|
12
|
+
}
|
|
13
|
+
return '';
|
|
14
|
+
}, p => {
|
|
15
|
+
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
16
|
+
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
17
|
+
}, ResizeInner, tokens.colors.interactive.primary__hover.rgba);
|
|
18
|
+
|
|
19
|
+
export { TableCell };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { flexRender } from '@tanstack/react-table';
|
|
2
|
+
import { useTableContext } from '../EdsDataGridContext.js';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { SortIndicator } from './SortIndicator.js';
|
|
5
|
+
import { Resizer, ResizeInner } from './Resizer.js';
|
|
6
|
+
import { TableCell } from './TableCell.js';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
function TableFooterCell({
|
|
10
|
+
footer,
|
|
11
|
+
columnResizeMode
|
|
12
|
+
}) {
|
|
13
|
+
const ctx = useTableContext();
|
|
14
|
+
const table = ctx.table;
|
|
15
|
+
const pinned = footer.column.getIsPinned();
|
|
16
|
+
const offset = useMemo(() => {
|
|
17
|
+
if (!pinned) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return pinned === 'left' ? footer.getStart() : table.getTotalSize() - footer.getStart() - footer.getSize();
|
|
21
|
+
}, [pinned, footer, table]);
|
|
22
|
+
return footer.isPlaceholder ? /*#__PURE__*/jsx(TableCell, {
|
|
23
|
+
$sticky: ctx.stickyFooter,
|
|
24
|
+
$offset: offset,
|
|
25
|
+
$pinned: pinned,
|
|
26
|
+
className: ctx.footerClass ? ctx.footerClass(footer.column) : '',
|
|
27
|
+
style: {
|
|
28
|
+
...(ctx.footerStyle ? ctx.footerStyle(footer.column) : {})
|
|
29
|
+
},
|
|
30
|
+
"aria-hidden": true
|
|
31
|
+
}) : /*#__PURE__*/jsxs(TableCell, {
|
|
32
|
+
$sticky: ctx.stickyFooter,
|
|
33
|
+
$offset: offset,
|
|
34
|
+
$pinned: pinned,
|
|
35
|
+
className: ctx.footerClass ? ctx.footerClass(footer.column) : '',
|
|
36
|
+
onClick: footer.column.getToggleSortingHandler(),
|
|
37
|
+
colSpan: footer.colSpan,
|
|
38
|
+
style: {
|
|
39
|
+
width: footer.getSize(),
|
|
40
|
+
verticalAlign: ctx.enableColumnFiltering ? 'top' : 'middle',
|
|
41
|
+
...(ctx.footerStyle ? ctx.footerStyle(footer.column) : {})
|
|
42
|
+
},
|
|
43
|
+
children: [/*#__PURE__*/jsxs(Fragment, {
|
|
44
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
45
|
+
style: {
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column'
|
|
48
|
+
},
|
|
49
|
+
children: /*#__PURE__*/jsx("span", {
|
|
50
|
+
className: "table-footer-cell-label",
|
|
51
|
+
children: flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
52
|
+
})
|
|
53
|
+
}), !footer.column.columnDef.meta?.customFilterInput && /*#__PURE__*/jsx(SortIndicator, {
|
|
54
|
+
column: footer.column
|
|
55
|
+
})]
|
|
56
|
+
}), columnResizeMode && /*#__PURE__*/jsx(Resizer, {
|
|
57
|
+
onClick: e => e.stopPropagation(),
|
|
58
|
+
onMouseDown: footer.getResizeHandler(),
|
|
59
|
+
onTouchStart: footer.getResizeHandler(),
|
|
60
|
+
$isResizing: footer.column.getIsResizing(),
|
|
61
|
+
$columnResizeMode: columnResizeMode,
|
|
62
|
+
className: 'resize-handle',
|
|
63
|
+
"data-testid": 'resize-handle',
|
|
64
|
+
children: /*#__PURE__*/jsx(ResizeInner, {})
|
|
65
|
+
})]
|
|
66
|
+
}, footer.id);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { TableFooterCell };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Table } from '@equinor/eds-core-react';
|
|
2
|
+
import { TableFooterCell } from './TableFooterCell.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function TableFooterRow({
|
|
6
|
+
footerGroup,
|
|
7
|
+
columnResizeMode,
|
|
8
|
+
deltaOffset,
|
|
9
|
+
table
|
|
10
|
+
}) {
|
|
11
|
+
return /*#__PURE__*/jsx(Table.Row, {
|
|
12
|
+
children: footerGroup.headers.map(footer => /*#__PURE__*/jsx(TableFooterCell, {
|
|
13
|
+
footer: footer,
|
|
14
|
+
table: table,
|
|
15
|
+
columnResizeMode: columnResizeMode,
|
|
16
|
+
deltaOffset: deltaOffset
|
|
17
|
+
}, footer.id))
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { TableFooterRow };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { flexRender } from '@tanstack/react-table';
|
|
2
|
-
import { Table } from '@equinor/eds-core-react';
|
|
3
2
|
import { useTableContext } from '../EdsDataGridContext.js';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { tokens } from '@equinor/eds-tokens';
|
|
6
3
|
import { useMemo } from 'react';
|
|
7
4
|
import { FilterWrapper } from './FilterWrapper.js';
|
|
8
5
|
import { SortIndicator } from './SortIndicator.js';
|
|
6
|
+
import { Resizer, ResizeInner } from './Resizer.js';
|
|
7
|
+
import { TableCell } from './TableCell.js';
|
|
9
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
9
|
|
|
11
10
|
const getSortLabel = sorted => {
|
|
@@ -14,26 +13,6 @@ const getSortLabel = sorted => {
|
|
|
14
13
|
}
|
|
15
14
|
return 'none';
|
|
16
15
|
};
|
|
17
|
-
const ResizeInner = styled.div.withConfig({
|
|
18
|
-
displayName: "TableHeaderCell__ResizeInner",
|
|
19
|
-
componentId: "sc-1n0j3v0-0"
|
|
20
|
-
})(["width:2px;opacity:0;height:100%;"]);
|
|
21
|
-
const Resizer = styled.div.withConfig({
|
|
22
|
-
displayName: "TableHeaderCell__Resizer",
|
|
23
|
-
componentId: "sc-1n0j3v0-1"
|
|
24
|
-
})(["transform:", ";", "{opacity:", ";}position:absolute;right:0;top:0;height:100%;width:5px;cursor:col-resize;user-select:none;touch-action:none;display:flex;justify-content:flex-end;"], props => props.$columnResizeMode === 'onEnd' ? 'translateX(0px)' : 'none', ResizeInner, props => props.$isResizing ? 1 : 0);
|
|
25
|
-
const Cell = styled(Table.Cell).withConfig({
|
|
26
|
-
displayName: "TableHeaderCell__Cell",
|
|
27
|
-
componentId: "sc-1n0j3v0-2"
|
|
28
|
-
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
29
|
-
if (p.$pinned) {
|
|
30
|
-
return `${p.$pinned}: ${p.$offset}px;`;
|
|
31
|
-
}
|
|
32
|
-
return '';
|
|
33
|
-
}, p => {
|
|
34
|
-
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
35
|
-
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
36
|
-
}, ResizeInner, tokens.colors.interactive.primary__hover.rgba);
|
|
37
16
|
function TableHeaderCell({
|
|
38
17
|
header,
|
|
39
18
|
columnResizeMode
|
|
@@ -47,7 +26,7 @@ function TableHeaderCell({
|
|
|
47
26
|
}
|
|
48
27
|
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - header.getSize();
|
|
49
28
|
}, [pinned, header, table]);
|
|
50
|
-
return header.isPlaceholder ? /*#__PURE__*/jsx(
|
|
29
|
+
return header.isPlaceholder ? /*#__PURE__*/jsx(TableCell, {
|
|
51
30
|
$sticky: ctx.stickyHeader,
|
|
52
31
|
$offset: offset,
|
|
53
32
|
$pinned: pinned,
|
|
@@ -56,7 +35,7 @@ function TableHeaderCell({
|
|
|
56
35
|
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
57
36
|
},
|
|
58
37
|
"aria-hidden": true
|
|
59
|
-
}) : /*#__PURE__*/jsxs(
|
|
38
|
+
}) : /*#__PURE__*/jsxs(TableCell, {
|
|
60
39
|
$sticky: ctx.stickyHeader,
|
|
61
40
|
$offset: offset,
|
|
62
41
|
$pinned: pinned,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { EdsDataGridProps } from './EdsDataGridProps';
|
|
2
|
-
export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, selectedRows, rowSelectionState, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, onSelectRow, onRowSelectionChange, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, externalPaginator, onSortingChange, manualSorting, sortingState, columnPinState, scrollbarHorizontal, width, minWidth, height, getRowId, rowVirtualizerInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowClick, onCellClick, }: EdsDataGridProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, selectedRows, rowSelectionState, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, stickyFooter, onSelectRow, onRowSelectionChange, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, footerClass, footerStyle, externalPaginator, onSortingChange, manualSorting, sortingState, columnPinState, scrollbarHorizontal, width, minWidth, height, getRowId, rowVirtualizerInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowClick, onCellClick, enableFooter, }: EdsDataGridProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { Column, Row, Table as TanStackTable } from '@tanstack/react-table';
|
|
|
3
3
|
type Context<T> = {
|
|
4
4
|
enableSorting: boolean;
|
|
5
5
|
stickyHeader: boolean;
|
|
6
|
+
stickyFooter: boolean;
|
|
6
7
|
enableColumnFiltering: boolean;
|
|
7
8
|
table: TanStackTable<T> | null;
|
|
8
9
|
cellClass?: (row: Row<T>, columnId: string) => string;
|
|
@@ -11,6 +12,8 @@ type Context<T> = {
|
|
|
11
12
|
rowStyle?: (row: Row<T>) => CSSProperties;
|
|
12
13
|
headerClass?: (column: Column<T>) => string;
|
|
13
14
|
headerStyle?: (column: Column<T>) => CSSProperties;
|
|
15
|
+
footerClass?: (column: Column<T>) => string;
|
|
16
|
+
footerStyle?: (column: Column<T>) => CSSProperties;
|
|
14
17
|
};
|
|
15
18
|
export declare const EdsDataGridContext: import("react").Context<Context<any>>;
|
|
16
19
|
export declare function TableProvider<T>({ children, ...props }: Context<T> & {
|
|
@@ -26,6 +26,11 @@ type BaseProps<T> = {
|
|
|
26
26
|
* @default false
|
|
27
27
|
*/
|
|
28
28
|
stickyHeader?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Make the table footer sticky
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
stickyFooter?: boolean;
|
|
29
34
|
/**
|
|
30
35
|
* Element to display in Table.Caption
|
|
31
36
|
* @default undefined
|
|
@@ -75,6 +80,10 @@ type BaseProps<T> = {
|
|
|
75
80
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#defaultcolumn)
|
|
76
81
|
*/
|
|
77
82
|
defaultColumn?: Partial<ColumnDef<T, unknown>>;
|
|
83
|
+
/**
|
|
84
|
+
* Optional props to show table footer
|
|
85
|
+
*/
|
|
86
|
+
enableFooter?: boolean;
|
|
78
87
|
};
|
|
79
88
|
type RowSelectionProps<T> = {
|
|
80
89
|
/**
|
|
@@ -157,6 +166,16 @@ type StyleProps<T> = {
|
|
|
157
166
|
* @param column
|
|
158
167
|
*/
|
|
159
168
|
headerStyle?: (column: Column<T>) => CSSProperties;
|
|
169
|
+
/**
|
|
170
|
+
* Function that can be used to set custom classes on a footer cell
|
|
171
|
+
* @param column
|
|
172
|
+
*/
|
|
173
|
+
footerClass?: (column: Column<T>) => string;
|
|
174
|
+
/**
|
|
175
|
+
* Function that can be used to set custom styles on a footer cell
|
|
176
|
+
* @param column
|
|
177
|
+
*/
|
|
178
|
+
footerStyle?: (column: Column<T>) => CSSProperties;
|
|
160
179
|
};
|
|
161
180
|
type FilterProps = {
|
|
162
181
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnResizeMode } from '@tanstack/react-table';
|
|
2
|
+
type ResizeProps = {
|
|
3
|
+
$columnResizeMode: ColumnResizeMode | null | undefined;
|
|
4
|
+
$isResizing: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const ResizeInner: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
|
+
export declare const Resizer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ResizeProps>> & string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ColumnPinningPosition } from '@tanstack/react-table';
|
|
2
|
+
export declare const TableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<{
|
|
3
|
+
variant?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Variants;
|
|
4
|
+
color?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Colors;
|
|
5
|
+
sort?: React.AriaAttributes["aria-sort"];
|
|
6
|
+
} & import("react").TdHTMLAttributes<HTMLTableCellElement> & import("react").RefAttributes<HTMLTableCellElement>, "ref"> & {
|
|
7
|
+
ref?: import("react").Ref<HTMLTableCellElement>;
|
|
8
|
+
}) | (Omit<{
|
|
9
|
+
variant?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Variants;
|
|
10
|
+
color?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Colors;
|
|
11
|
+
sort?: React.AriaAttributes["aria-sort"];
|
|
12
|
+
} & import("react").ThHTMLAttributes<HTMLTableCellElement> & import("react").RefAttributes<HTMLTableCellElement>, "ref"> & {
|
|
13
|
+
ref?: import("react").Ref<HTMLTableCellElement>;
|
|
14
|
+
}), {
|
|
15
|
+
$sticky: boolean;
|
|
16
|
+
$pinned: ColumnPinningPosition;
|
|
17
|
+
$offset: number;
|
|
18
|
+
}>> & string & Omit<import("react").ForwardRefExoticComponent<import("@equinor/eds-core-react").CellProps & import("react").RefAttributes<HTMLTableCellElement>>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnResizeMode, Header, Table as TanStackTable } from '@tanstack/react-table';
|
|
2
|
+
type Props<T> = {
|
|
3
|
+
footer: Header<T, unknown>;
|
|
4
|
+
columnResizeMode: ColumnResizeMode | null | undefined;
|
|
5
|
+
deltaOffset: number | null;
|
|
6
|
+
table: TanStackTable<T>;
|
|
7
|
+
};
|
|
8
|
+
export declare function TableFooterCell<T>({ footer, columnResizeMode }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnResizeMode, HeaderGroup, Table as TanStackTable } from '@tanstack/react-table';
|
|
2
|
+
type Props<T> = {
|
|
3
|
+
footerGroup: HeaderGroup<T>;
|
|
4
|
+
columnResizeMode?: ColumnResizeMode | null;
|
|
5
|
+
deltaOffset: number | null;
|
|
6
|
+
table: TanStackTable<T>;
|
|
7
|
+
};
|
|
8
|
+
export declare function TableFooterRow<T>({ footerGroup, columnResizeMode, deltaOffset, table, }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-data-grid-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A feature-rich data-grid written in React, implementing the Equinor Design System",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"email": "fg_eds@equinor.com"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@equinor/eds-core-react": ">=0.
|
|
17
|
+
"@equinor/eds-core-react": ">=0.42.0",
|
|
18
18
|
"react": ">=16.8",
|
|
19
19
|
"react-dom": ">=16.8",
|
|
20
20
|
"styled-components": ">=5.1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tanstack/react-table": "^8.20.1",
|
|
24
|
-
"@tanstack/react-virtual": "^3.
|
|
25
|
-
"@equinor/eds-icons": "^0.21.0",
|
|
24
|
+
"@tanstack/react-virtual": "^3.10.6",
|
|
26
25
|
"@equinor/eds-tokens": "0.9.2",
|
|
26
|
+
"@equinor/eds-icons": "^0.21.0",
|
|
27
27
|
"@equinor/eds-utils": "^0.8.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|