@equinor/eds-data-grid-react 0.6.2 → 0.7.1

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.
@@ -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: "TableHeaderCell__ResizeInner",
247
- componentId: "sc-1n0j3v0-0"
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: "TableHeaderCell__Resizer",
251
- componentId: "sc-1n0j3v0-1"
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
- const Cell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
254
- displayName: "TableHeaderCell__Cell",
255
- componentId: "sc-1n0j3v0-2"
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(Cell, {
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(Cell, {
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,10 @@ function EdsDataGrid({
503
585
  getSubRows,
504
586
  defaultColumn,
505
587
  onRowClick,
506
- onCellClick
588
+ onCellClick,
589
+ enableFooter,
590
+ enableSortingRemoval,
591
+ ...rest
507
592
  }) {
508
593
  logDevelopmentWarningOfPropUse({
509
594
  virtualHeight: {
@@ -653,7 +738,8 @@ function EdsDataGrid({
653
738
  enableSubRowSelection: enableSubRowSelection ?? false,
654
739
  enableColumnPinning: true,
655
740
  enablePinning: true,
656
- getRowId
741
+ getRowId,
742
+ enableSortingRemoval: enableSortingRemoval ?? true
657
743
  };
658
744
  react.useEffect(() => {
659
745
  if (columnOrder && columnOrder.length > 0) {
@@ -754,6 +840,7 @@ function EdsDataGrid({
754
840
  // These classes are primarily used to allow for feature-detection in the test-suite
755
841
  const classList = {
756
842
  'sticky-header': !!stickyHeader,
843
+ 'sticky-footer': !!stickyFooter,
757
844
  virtual: !!enableVirtual,
758
845
  paging: !!enablePagination
759
846
  };
@@ -764,13 +851,20 @@ function EdsDataGrid({
764
851
  rowStyle: rowStyle,
765
852
  headerClass: headerClass,
766
853
  headerStyle: headerStyle,
854
+ footerClass: footerClass,
855
+ footerStyle: footerStyle,
767
856
  table: table,
768
857
  enableSorting: !!enableSorting,
769
858
  enableColumnFiltering: !!enableColumnFiltering,
770
859
  stickyHeader: !!stickyHeader,
860
+ stickyFooter: !!stickyFooter,
771
861
  children: [/*#__PURE__*/jsxRuntime.jsxs(TableWrapper, {
772
- className: "table-wrapper",
773
- style: tableWrapperStyle,
862
+ ...rest,
863
+ className: `table-wrapper ${rest.className ?? ''}`,
864
+ style: {
865
+ ...rest.style,
866
+ ...tableWrapperStyle
867
+ },
774
868
  ref: parentRef,
775
869
  $height: height,
776
870
  $width: width,
@@ -837,6 +931,15 @@ function EdsDataGrid({
837
931
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
838
932
  onCellClick: onCellClick
839
933
  }, row.id))]
934
+ }), enableFooter && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Foot, {
935
+ sticky: stickyFooter,
936
+ "data-testid": "eds-grid-footer",
937
+ children: table.getFooterGroups().map(footerGroup => /*#__PURE__*/jsxRuntime.jsx(TableFooterRow, {
938
+ table: table,
939
+ footerGroup: footerGroup,
940
+ columnResizeMode: columnResizeMode,
941
+ deltaOffset: table.getState().columnSizingInfo.deltaOffset
942
+ }, footerGroup.id))
840
943
  })]
841
944
  }), externalPaginator ? externalPaginator : enablePagination && /*#__PURE__*/jsxRuntime.jsx("div", {
842
945
  style: {
@@ -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,10 @@ function EdsDataGrid({
59
63
  getSubRows,
60
64
  defaultColumn,
61
65
  onRowClick,
62
- onCellClick
66
+ onCellClick,
67
+ enableFooter,
68
+ enableSortingRemoval,
69
+ ...rest
63
70
  }) {
64
71
  logDevelopmentWarningOfPropUse({
65
72
  virtualHeight: {
@@ -209,7 +216,8 @@ function EdsDataGrid({
209
216
  enableSubRowSelection: enableSubRowSelection ?? false,
210
217
  enableColumnPinning: true,
211
218
  enablePinning: true,
212
- getRowId
219
+ getRowId,
220
+ enableSortingRemoval: enableSortingRemoval ?? true
213
221
  };
214
222
  useEffect(() => {
215
223
  if (columnOrder && columnOrder.length > 0) {
@@ -310,6 +318,7 @@ function EdsDataGrid({
310
318
  // These classes are primarily used to allow for feature-detection in the test-suite
311
319
  const classList = {
312
320
  'sticky-header': !!stickyHeader,
321
+ 'sticky-footer': !!stickyFooter,
313
322
  virtual: !!enableVirtual,
314
323
  paging: !!enablePagination
315
324
  };
@@ -320,13 +329,20 @@ function EdsDataGrid({
320
329
  rowStyle: rowStyle,
321
330
  headerClass: headerClass,
322
331
  headerStyle: headerStyle,
332
+ footerClass: footerClass,
333
+ footerStyle: footerStyle,
323
334
  table: table,
324
335
  enableSorting: !!enableSorting,
325
336
  enableColumnFiltering: !!enableColumnFiltering,
326
337
  stickyHeader: !!stickyHeader,
338
+ stickyFooter: !!stickyFooter,
327
339
  children: [/*#__PURE__*/jsxs(TableWrapper, {
328
- className: "table-wrapper",
329
- style: tableWrapperStyle,
340
+ ...rest,
341
+ className: `table-wrapper ${rest.className ?? ''}`,
342
+ style: {
343
+ ...rest.style,
344
+ ...tableWrapperStyle
345
+ },
330
346
  ref: parentRef,
331
347
  $height: height,
332
348
  $width: width,
@@ -393,6 +409,15 @@ function EdsDataGrid({
393
409
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
394
410
  onCellClick: onCellClick
395
411
  }, row.id))]
412
+ }), enableFooter && /*#__PURE__*/jsx(Table.Foot, {
413
+ sticky: stickyFooter,
414
+ "data-testid": "eds-grid-footer",
415
+ children: table.getFooterGroups().map(footerGroup => /*#__PURE__*/jsx(TableFooterRow, {
416
+ table: table,
417
+ footerGroup: footerGroup,
418
+ columnResizeMode: columnResizeMode,
419
+ deltaOffset: table.getState().columnSizingInfo.deltaOffset
420
+ }, footerGroup.id))
396
421
  })]
397
422
  }), externalPaginator ? externalPaginator : enablePagination && /*#__PURE__*/jsx("div", {
398
423
  style: {
@@ -5,6 +5,7 @@ import { jsx } from 'react/jsx-runtime';
5
5
  const EdsDataGridContext = /*#__PURE__*/createContext({
6
6
  enableSorting: false,
7
7
  stickyHeader: false,
8
+ stickyFooter: false,
8
9
  enableColumnFiltering: false,
9
10
  table: null
10
11
  });
@@ -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(Cell, {
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(Cell, {
38
+ }) : /*#__PURE__*/jsxs(TableCell, {
60
39
  $sticky: ctx.stickyHeader,
61
40
  $offset: offset,
62
41
  $pinned: pinned,
@@ -1,2 +1,3 @@
1
+ import { HTMLAttributes } from 'react';
1
2
  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;
3
+ 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, enableSortingRemoval, ...rest }: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement>): 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
  /**
@@ -234,6 +253,12 @@ type SortProps = {
234
253
  * Override the default sorting state
235
254
  */
236
255
  sortingState?: SortingState;
256
+ /**
257
+ * By default, the ability to remove sorting while cycling through the sorting states for a column is enabled.
258
+ * You can disable this behavior using the enableSortingRemoval table option.
259
+ * This behavior is useful if you want to ensure that at least one column is always sorted.
260
+ */
261
+ enableSortingRemoval?: boolean;
237
262
  };
238
263
  type ColumnProps = {
239
264
  columnPinState?: ColumnPinningState;
@@ -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.6.2",
3
+ "version": "0.7.1",
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,31 +14,31 @@
14
14
  "email": "fg_eds@equinor.com"
15
15
  },
16
16
  "peerDependencies": {
17
- "@equinor/eds-core-react": ">=0.36.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.8.4",
24
+ "@tanstack/react-virtual": "^3.10.8",
25
25
  "@equinor/eds-icons": "^0.21.0",
26
26
  "@equinor/eds-tokens": "0.9.2",
27
27
  "@equinor/eds-utils": "^0.8.5"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@rollup/plugin-babel": "^6.0.4",
31
- "@rollup/plugin-commonjs": "^26.0.1",
32
- "@rollup/plugin-node-resolve": "^15.2.3",
33
- "@storybook/addon-a11y": "^8.2.8",
34
- "@storybook/addon-actions": "^8.2.8",
35
- "@storybook/addon-docs": "^8.2.8",
36
- "@storybook/addon-essentials": "^8.2.8",
37
- "@storybook/addon-links": "^8.2.8",
38
- "@storybook/blocks": "^8.2.8",
39
- "@storybook/preview-api": "^8.2.8",
40
- "@storybook/react": "^8.2.8",
41
- "@storybook/react-vite": "^8.2.8",
31
+ "@rollup/plugin-commonjs": "^27.0.0",
32
+ "@rollup/plugin-node-resolve": "^15.3.0",
33
+ "@storybook/addon-a11y": "^8.3.4",
34
+ "@storybook/addon-actions": "^8.3.4",
35
+ "@storybook/addon-docs": "^8.3.4",
36
+ "@storybook/addon-essentials": "^8.3.4",
37
+ "@storybook/addon-links": "^8.3.4",
38
+ "@storybook/blocks": "^8.3.4",
39
+ "@storybook/preview-api": "^8.3.4",
40
+ "@storybook/react": "^8.3.4",
41
+ "@storybook/react-vite": "^8.3.4",
42
42
  "@testing-library/dom": "^10.4.0",
43
43
  "@testing-library/jest-dom": "^6.4.8",
44
44
  "@testing-library/react": "16.0.0",
@@ -48,7 +48,6 @@
48
48
  "@types/ramda": "^0.30.1",
49
49
  "@types/react": "^18.3.3",
50
50
  "@types/react-dom": "^18.3.0",
51
- "babel-loader": "^9.1.3",
52
51
  "babel-plugin-styled-components": "^2.1.4",
53
52
  "jest": "29.7.0",
54
53
  "jest-environment-jsdom": "29.7.0",
@@ -59,10 +58,10 @@
59
58
  "react": "^18.3.1",
60
59
  "react-dom": "^18.3.1",
61
60
  "react-hook-form": "^7.52.2",
62
- "rollup": "^4.20.0",
63
- "rollup-plugin-delete": "^2.0.0",
61
+ "rollup": "^4.22.5",
62
+ "rollup-plugin-delete": "^2.1.0",
64
63
  "rollup-plugin-postcss": "^4.0.2",
65
- "storybook": "^8.2.8",
64
+ "storybook": "^8.3.4",
66
65
  "styled-components": "6.1.12",
67
66
  "ts-jest": "29.2.4",
68
67
  "ts-node": "10.9.2",