@equinor/eds-data-grid-react 0.7.7 → 0.8.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.
- package/dist/eds-data-grid-react.cjs +66 -30
- package/dist/esm/EdsDataGrid.js +7 -2
- package/dist/esm/components/DebouncedInput.js +0 -1
- package/dist/esm/components/FilterWrapper.js +3 -1
- package/dist/esm/components/TableCell.js +10 -4
- package/dist/esm/components/TableHeaderCell.js +31 -5
- package/dist/types/EdsDataGrid.d.ts +1 -1
- package/dist/types/EdsDataGridProps.d.ts +11 -1
- package/dist/types/components/TableCell.d.ts +2 -0
- package/package.json +5 -5
|
@@ -59,7 +59,6 @@ function DebouncedInput({
|
|
|
59
59
|
label: props.placeholder,
|
|
60
60
|
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Input, {
|
|
61
61
|
type: 'number',
|
|
62
|
-
placeholder: '0',
|
|
63
62
|
value: value,
|
|
64
63
|
onChange: e => setValue(e.target.valueAsNumber)
|
|
65
64
|
})
|
|
@@ -161,6 +160,34 @@ function Filter({
|
|
|
161
160
|
});
|
|
162
161
|
}
|
|
163
162
|
|
|
163
|
+
const ResizeInner = styled__default.default.div.withConfig({
|
|
164
|
+
displayName: "Resizer__ResizeInner",
|
|
165
|
+
componentId: "sc-plcbjs-0"
|
|
166
|
+
})(["width:2px;opacity:0;height:100%;"]);
|
|
167
|
+
const Resizer = styled__default.default.div.withConfig({
|
|
168
|
+
displayName: "Resizer",
|
|
169
|
+
componentId: "sc-plcbjs-1"
|
|
170
|
+
})(["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;z-index:1;"], props => props.$columnResizeMode === 'onEnd' ? 'translateX(0px)' : 'none', ResizeInner, props => props.$isResizing ? 1 : 0);
|
|
171
|
+
|
|
172
|
+
const FilterVisibility = styled__default.default.div.withConfig({
|
|
173
|
+
displayName: "TableCell__FilterVisibility",
|
|
174
|
+
componentId: "sc-1g0k23m-0"
|
|
175
|
+
})([""]);
|
|
176
|
+
const TableCell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
177
|
+
displayName: "TableCell",
|
|
178
|
+
componentId: "sc-1g0k23m-1"
|
|
179
|
+
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}", ":not(:focus-within){opacity:", ";}&:hover ", "{opacity:1;}", ":focus-within{opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
180
|
+
if (p.$pinned) {
|
|
181
|
+
return `${p.$pinned}: ${p.$offset}px;`;
|
|
182
|
+
}
|
|
183
|
+
return '';
|
|
184
|
+
}, p => {
|
|
185
|
+
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
186
|
+
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
187
|
+
}, ResizeInner, edsTokens.tokens.colors.interactive.primary__hover.rgba, FilterVisibility, ({
|
|
188
|
+
$activeFilter
|
|
189
|
+
}) => $activeFilter ? 1 : 0, FilterVisibility, FilterVisibility);
|
|
190
|
+
|
|
164
191
|
/* istanbul ignore file */
|
|
165
192
|
|
|
166
193
|
function FilterWrapper({
|
|
@@ -189,7 +216,8 @@ function FilterWrapper({
|
|
|
189
216
|
return value;
|
|
190
217
|
};
|
|
191
218
|
const onChange = react.useCallback(value => column.setFilterValue(value), [column]);
|
|
192
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
219
|
+
return /*#__PURE__*/jsxRuntime.jsxs(FilterVisibility, {
|
|
220
|
+
onClick: e => e.stopPropagation(),
|
|
193
221
|
children: [/*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Button, {
|
|
194
222
|
"aria-haspopup": true,
|
|
195
223
|
"aria-expanded": open,
|
|
@@ -238,28 +266,6 @@ const SortIndicator = ({
|
|
|
238
266
|
}[column.getIsSorted()] ?? null;
|
|
239
267
|
};
|
|
240
268
|
|
|
241
|
-
const ResizeInner = styled__default.default.div.withConfig({
|
|
242
|
-
displayName: "Resizer__ResizeInner",
|
|
243
|
-
componentId: "sc-plcbjs-0"
|
|
244
|
-
})(["width:2px;opacity:0;height:100%;"]);
|
|
245
|
-
const Resizer = styled__default.default.div.withConfig({
|
|
246
|
-
displayName: "Resizer",
|
|
247
|
-
componentId: "sc-plcbjs-1"
|
|
248
|
-
})(["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;z-index:1;"], props => props.$columnResizeMode === 'onEnd' ? 'translateX(0px)' : 'none', ResizeInner, props => props.$isResizing ? 1 : 0);
|
|
249
|
-
|
|
250
|
-
const TableCell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
251
|
-
displayName: "TableCell",
|
|
252
|
-
componentId: "sc-1g0k23m-0"
|
|
253
|
-
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
254
|
-
if (p.$pinned) {
|
|
255
|
-
return `${p.$pinned}: ${p.$offset}px;`;
|
|
256
|
-
}
|
|
257
|
-
return '';
|
|
258
|
-
}, p => {
|
|
259
|
-
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
260
|
-
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
261
|
-
}, ResizeInner, edsTokens.tokens.colors.interactive.primary__hover.rgba);
|
|
262
|
-
|
|
263
269
|
const SortButton = styled__default.default.button.withConfig({
|
|
264
270
|
displayName: "TableHeaderCell__SortButton",
|
|
265
271
|
componentId: "sc-1n0j3v0-0"
|
|
@@ -281,6 +287,15 @@ function TableHeaderCell({
|
|
|
281
287
|
const ctx = useTableContext();
|
|
282
288
|
const table = ctx.table;
|
|
283
289
|
const pinned = header.column.getIsPinned();
|
|
290
|
+
const isFiltered = header.column.getIsFiltered();
|
|
291
|
+
const filterValue = header.column.getFilterValue();
|
|
292
|
+
const hasActiveFilters = react.useMemo(() => {
|
|
293
|
+
if (!isFiltered) return false;
|
|
294
|
+
if (Array.isArray(filterValue)) {
|
|
295
|
+
return filterValue.length > 0 && filterValue.some(v => !!v || v === 0); // avoid empty strings counting
|
|
296
|
+
}
|
|
297
|
+
return !!filterValue;
|
|
298
|
+
}, [isFiltered, filterValue]);
|
|
284
299
|
const canSort = header.column.getCanSort();
|
|
285
300
|
const canFilter = header.column.getCanFilter();
|
|
286
301
|
const offset = react.useMemo(() => {
|
|
@@ -289,6 +304,12 @@ function TableHeaderCell({
|
|
|
289
304
|
}
|
|
290
305
|
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - header.getSize();
|
|
291
306
|
}, [pinned, header, table]);
|
|
307
|
+
const {
|
|
308
|
+
density
|
|
309
|
+
} = edsCoreReact.useEds();
|
|
310
|
+
// Future improvement: If we down the line end up granting the ability to customize row height, we should move this to the table-context
|
|
311
|
+
const rowHeight = density === 'compact' ? 32 : 48;
|
|
312
|
+
const vertOffset = ctx.stickyHeader ? (header.depth - 1) * rowHeight : undefined;
|
|
292
313
|
const tableCellPadding = react.useMemo(() => {
|
|
293
314
|
if (canSort && canFilter) {
|
|
294
315
|
return '0 var(--eds_table__cell__padding_x, 16px) 0 0';
|
|
@@ -304,13 +325,15 @@ function TableHeaderCell({
|
|
|
304
325
|
$pinned: pinned,
|
|
305
326
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
306
327
|
style: {
|
|
307
|
-
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
328
|
+
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {}),
|
|
329
|
+
top: vertOffset
|
|
308
330
|
},
|
|
309
331
|
"aria-hidden": true
|
|
310
332
|
}) : /*#__PURE__*/jsxRuntime.jsxs(TableCell, {
|
|
311
333
|
$sticky: ctx.stickyHeader,
|
|
312
334
|
$offset: offset,
|
|
313
335
|
$pinned: pinned,
|
|
336
|
+
$activeFilter: hasActiveFilters,
|
|
314
337
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
315
338
|
"aria-sort": getSortLabel(header.column.getIsSorted()),
|
|
316
339
|
colSpan: header.colSpan,
|
|
@@ -318,7 +341,8 @@ function TableHeaderCell({
|
|
|
318
341
|
width: header.getSize(),
|
|
319
342
|
verticalAlign: ctx.enableColumnFiltering ? 'top' : 'middle',
|
|
320
343
|
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {}),
|
|
321
|
-
padding: tableCellPadding
|
|
344
|
+
padding: tableCellPadding,
|
|
345
|
+
top: vertOffset
|
|
322
346
|
},
|
|
323
347
|
children: [canSort ? /*#__PURE__*/jsxRuntime.jsxs(SortButton, {
|
|
324
348
|
tabIndex: -1,
|
|
@@ -333,8 +357,15 @@ function TableHeaderCell({
|
|
|
333
357
|
}) : /*#__PURE__*/jsxRuntime.jsx(TableHeaderCellLabel, {
|
|
334
358
|
className: "table-header-cell-label",
|
|
335
359
|
children: reactTable.flexRender(header.column.columnDef.header, header.getContext())
|
|
336
|
-
}), canFilter && !header.column.columnDef.meta?.customFilterInput ?
|
|
337
|
-
|
|
360
|
+
}), canFilter && !header.column.columnDef.meta?.customFilterInput ?
|
|
361
|
+
/*#__PURE__*/
|
|
362
|
+
// Supressing this warning - div is not interactive, but prevents propagation of events to avoid unintended sorting
|
|
363
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
364
|
+
jsxRuntime.jsx(FilterVisibility, {
|
|
365
|
+
onClick: e => e.stopPropagation(),
|
|
366
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FilterWrapper, {
|
|
367
|
+
column: header.column
|
|
368
|
+
})
|
|
338
369
|
}) : null, columnResizeMode && /*#__PURE__*/jsxRuntime.jsx(Resizer, {
|
|
339
370
|
onMouseDown: header.getResizeHandler(),
|
|
340
371
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -561,6 +592,8 @@ function EdsDataGridInner({
|
|
|
561
592
|
selectedRows,
|
|
562
593
|
rowSelectionState,
|
|
563
594
|
enableColumnFiltering,
|
|
595
|
+
columnFiltersState,
|
|
596
|
+
onColumnFiltersChange,
|
|
564
597
|
debug,
|
|
565
598
|
enablePagination,
|
|
566
599
|
enableSorting,
|
|
@@ -647,6 +680,9 @@ function EdsDataGridInner({
|
|
|
647
680
|
react.useEffect(() => {
|
|
648
681
|
setVisible(columnVisibility ?? {});
|
|
649
682
|
}, [columnVisibility, setVisible]);
|
|
683
|
+
react.useEffect(() => {
|
|
684
|
+
setColumnFilters(columnFiltersState);
|
|
685
|
+
}, [columnFiltersState]);
|
|
650
686
|
react.useEffect(() => {
|
|
651
687
|
setColumnPin(s => columnPinState ?? s);
|
|
652
688
|
}, [columnPinState]);
|
|
@@ -727,6 +763,7 @@ function EdsDataGridInner({
|
|
|
727
763
|
},
|
|
728
764
|
state: {
|
|
729
765
|
sorting,
|
|
766
|
+
columnFilters: columnFilters,
|
|
730
767
|
columnPinning: columnPin,
|
|
731
768
|
rowSelection: internalRowSelectionState,
|
|
732
769
|
columnOrder: columnOrderState,
|
|
@@ -783,7 +820,7 @@ function EdsDataGridInner({
|
|
|
783
820
|
if (enableColumnFiltering) {
|
|
784
821
|
options.state.columnFilters = columnFilters;
|
|
785
822
|
options.state.globalFilter = globalFilter;
|
|
786
|
-
options.onColumnFiltersChange = setColumnFilters;
|
|
823
|
+
options.onColumnFiltersChange = onColumnFiltersChange ?? setColumnFilters;
|
|
787
824
|
options.onGlobalFilterChange = setGlobalFilter;
|
|
788
825
|
options.getFacetedRowModel = reactTable.getFacetedRowModel();
|
|
789
826
|
options.getFacetedUniqueValues = reactTable.getFacetedUniqueValues();
|
|
@@ -910,7 +947,6 @@ function EdsDataGridInner({
|
|
|
910
947
|
children: [caption && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Caption, {
|
|
911
948
|
children: caption
|
|
912
949
|
}), /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Head, {
|
|
913
|
-
sticky: stickyHeader,
|
|
914
950
|
children: table.getHeaderGroups().map(headerGroup => /*#__PURE__*/jsxRuntime.jsx(TableHeaderRow, {
|
|
915
951
|
table: table,
|
|
916
952
|
headerGroup: headerGroup,
|
package/dist/esm/EdsDataGrid.js
CHANGED
|
@@ -24,6 +24,8 @@ function EdsDataGridInner({
|
|
|
24
24
|
selectedRows,
|
|
25
25
|
rowSelectionState,
|
|
26
26
|
enableColumnFiltering,
|
|
27
|
+
columnFiltersState,
|
|
28
|
+
onColumnFiltersChange,
|
|
27
29
|
debug,
|
|
28
30
|
enablePagination,
|
|
29
31
|
enableSorting,
|
|
@@ -110,6 +112,9 @@ function EdsDataGridInner({
|
|
|
110
112
|
useEffect(() => {
|
|
111
113
|
setVisible(columnVisibility ?? {});
|
|
112
114
|
}, [columnVisibility, setVisible]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
setColumnFilters(columnFiltersState);
|
|
117
|
+
}, [columnFiltersState]);
|
|
113
118
|
useEffect(() => {
|
|
114
119
|
setColumnPin(s => columnPinState ?? s);
|
|
115
120
|
}, [columnPinState]);
|
|
@@ -190,6 +195,7 @@ function EdsDataGridInner({
|
|
|
190
195
|
},
|
|
191
196
|
state: {
|
|
192
197
|
sorting,
|
|
198
|
+
columnFilters: columnFilters,
|
|
193
199
|
columnPinning: columnPin,
|
|
194
200
|
rowSelection: internalRowSelectionState,
|
|
195
201
|
columnOrder: columnOrderState,
|
|
@@ -246,7 +252,7 @@ function EdsDataGridInner({
|
|
|
246
252
|
if (enableColumnFiltering) {
|
|
247
253
|
options.state.columnFilters = columnFilters;
|
|
248
254
|
options.state.globalFilter = globalFilter;
|
|
249
|
-
options.onColumnFiltersChange = setColumnFilters;
|
|
255
|
+
options.onColumnFiltersChange = onColumnFiltersChange ?? setColumnFilters;
|
|
250
256
|
options.onGlobalFilterChange = setGlobalFilter;
|
|
251
257
|
options.getFacetedRowModel = getFacetedRowModel();
|
|
252
258
|
options.getFacetedUniqueValues = getFacetedUniqueValues();
|
|
@@ -373,7 +379,6 @@ function EdsDataGridInner({
|
|
|
373
379
|
children: [caption && /*#__PURE__*/jsx(Table.Caption, {
|
|
374
380
|
children: caption
|
|
375
381
|
}), /*#__PURE__*/jsx(Table.Head, {
|
|
376
|
-
sticky: stickyHeader,
|
|
377
382
|
children: table.getHeaderGroups().map(headerGroup => /*#__PURE__*/jsx(TableHeaderRow, {
|
|
378
383
|
table: table,
|
|
379
384
|
headerGroup: headerGroup,
|
|
@@ -4,6 +4,7 @@ import { filter_alt_active, filter_alt } from '@equinor/eds-icons';
|
|
|
4
4
|
import { tokens } from '@equinor/eds-tokens';
|
|
5
5
|
import { Filter } from './Filter.js';
|
|
6
6
|
import { useTableContext } from '../EdsDataGridContext.js';
|
|
7
|
+
import { FilterVisibility } from './TableCell.js';
|
|
7
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
10
|
/* istanbul ignore file */
|
|
@@ -34,7 +35,8 @@ function FilterWrapper({
|
|
|
34
35
|
return value;
|
|
35
36
|
};
|
|
36
37
|
const onChange = useCallback(value => column.setFilterValue(value), [column]);
|
|
37
|
-
return /*#__PURE__*/jsxs(
|
|
38
|
+
return /*#__PURE__*/jsxs(FilterVisibility, {
|
|
39
|
+
onClick: e => e.stopPropagation(),
|
|
38
40
|
children: [/*#__PURE__*/jsx(Button, {
|
|
39
41
|
"aria-haspopup": true,
|
|
40
42
|
"aria-expanded": open,
|
|
@@ -3,10 +3,14 @@ import { tokens } from '@equinor/eds-tokens';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { ResizeInner } from './Resizer.js';
|
|
5
5
|
|
|
6
|
+
const FilterVisibility = styled.div.withConfig({
|
|
7
|
+
displayName: "TableCell__FilterVisibility",
|
|
8
|
+
componentId: "sc-1g0k23m-0"
|
|
9
|
+
})([""]);
|
|
6
10
|
const TableCell = styled(Table.Cell).withConfig({
|
|
7
11
|
displayName: "TableCell",
|
|
8
|
-
componentId: "sc-1g0k23m-
|
|
9
|
-
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
12
|
+
componentId: "sc-1g0k23m-1"
|
|
13
|
+
})(["font-weight:bold;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}", ":not(:focus-within){opacity:", ";}&:hover ", "{opacity:1;}", ":focus-within{opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
10
14
|
if (p.$pinned) {
|
|
11
15
|
return `${p.$pinned}: ${p.$offset}px;`;
|
|
12
16
|
}
|
|
@@ -14,6 +18,8 @@ const TableCell = styled(Table.Cell).withConfig({
|
|
|
14
18
|
}, p => {
|
|
15
19
|
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
16
20
|
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
17
|
-
}, ResizeInner, tokens.colors.interactive.primary__hover.rgba
|
|
21
|
+
}, ResizeInner, tokens.colors.interactive.primary__hover.rgba, FilterVisibility, ({
|
|
22
|
+
$activeFilter
|
|
23
|
+
}) => $activeFilter ? 1 : 0, FilterVisibility, FilterVisibility);
|
|
18
24
|
|
|
19
|
-
export { TableCell };
|
|
25
|
+
export { FilterVisibility, TableCell };
|
|
@@ -4,8 +4,9 @@ import { useMemo } from 'react';
|
|
|
4
4
|
import { FilterWrapper } from './FilterWrapper.js';
|
|
5
5
|
import { SortIndicator } from './SortIndicator.js';
|
|
6
6
|
import { Resizer, ResizeInner } from './Resizer.js';
|
|
7
|
-
import { TableCell } from './TableCell.js';
|
|
7
|
+
import { TableCell, FilterVisibility } from './TableCell.js';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
|
+
import { useEds } from '@equinor/eds-core-react';
|
|
9
10
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
11
|
|
|
11
12
|
const SortButton = styled.button.withConfig({
|
|
@@ -29,6 +30,15 @@ function TableHeaderCell({
|
|
|
29
30
|
const ctx = useTableContext();
|
|
30
31
|
const table = ctx.table;
|
|
31
32
|
const pinned = header.column.getIsPinned();
|
|
33
|
+
const isFiltered = header.column.getIsFiltered();
|
|
34
|
+
const filterValue = header.column.getFilterValue();
|
|
35
|
+
const hasActiveFilters = useMemo(() => {
|
|
36
|
+
if (!isFiltered) return false;
|
|
37
|
+
if (Array.isArray(filterValue)) {
|
|
38
|
+
return filterValue.length > 0 && filterValue.some(v => !!v || v === 0); // avoid empty strings counting
|
|
39
|
+
}
|
|
40
|
+
return !!filterValue;
|
|
41
|
+
}, [isFiltered, filterValue]);
|
|
32
42
|
const canSort = header.column.getCanSort();
|
|
33
43
|
const canFilter = header.column.getCanFilter();
|
|
34
44
|
const offset = useMemo(() => {
|
|
@@ -37,6 +47,12 @@ function TableHeaderCell({
|
|
|
37
47
|
}
|
|
38
48
|
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - header.getSize();
|
|
39
49
|
}, [pinned, header, table]);
|
|
50
|
+
const {
|
|
51
|
+
density
|
|
52
|
+
} = useEds();
|
|
53
|
+
// Future improvement: If we down the line end up granting the ability to customize row height, we should move this to the table-context
|
|
54
|
+
const rowHeight = density === 'compact' ? 32 : 48;
|
|
55
|
+
const vertOffset = ctx.stickyHeader ? (header.depth - 1) * rowHeight : undefined;
|
|
40
56
|
const tableCellPadding = useMemo(() => {
|
|
41
57
|
if (canSort && canFilter) {
|
|
42
58
|
return '0 var(--eds_table__cell__padding_x, 16px) 0 0';
|
|
@@ -52,13 +68,15 @@ function TableHeaderCell({
|
|
|
52
68
|
$pinned: pinned,
|
|
53
69
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
54
70
|
style: {
|
|
55
|
-
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
71
|
+
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {}),
|
|
72
|
+
top: vertOffset
|
|
56
73
|
},
|
|
57
74
|
"aria-hidden": true
|
|
58
75
|
}) : /*#__PURE__*/jsxs(TableCell, {
|
|
59
76
|
$sticky: ctx.stickyHeader,
|
|
60
77
|
$offset: offset,
|
|
61
78
|
$pinned: pinned,
|
|
79
|
+
$activeFilter: hasActiveFilters,
|
|
62
80
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
63
81
|
"aria-sort": getSortLabel(header.column.getIsSorted()),
|
|
64
82
|
colSpan: header.colSpan,
|
|
@@ -66,7 +84,8 @@ function TableHeaderCell({
|
|
|
66
84
|
width: header.getSize(),
|
|
67
85
|
verticalAlign: ctx.enableColumnFiltering ? 'top' : 'middle',
|
|
68
86
|
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {}),
|
|
69
|
-
padding: tableCellPadding
|
|
87
|
+
padding: tableCellPadding,
|
|
88
|
+
top: vertOffset
|
|
70
89
|
},
|
|
71
90
|
children: [canSort ? /*#__PURE__*/jsxs(SortButton, {
|
|
72
91
|
tabIndex: -1,
|
|
@@ -81,8 +100,15 @@ function TableHeaderCell({
|
|
|
81
100
|
}) : /*#__PURE__*/jsx(TableHeaderCellLabel, {
|
|
82
101
|
className: "table-header-cell-label",
|
|
83
102
|
children: flexRender(header.column.columnDef.header, header.getContext())
|
|
84
|
-
}), canFilter && !header.column.columnDef.meta?.customFilterInput ?
|
|
85
|
-
|
|
103
|
+
}), canFilter && !header.column.columnDef.meta?.customFilterInput ?
|
|
104
|
+
/*#__PURE__*/
|
|
105
|
+
// Supressing this warning - div is not interactive, but prevents propagation of events to avoid unintended sorting
|
|
106
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
107
|
+
jsx(FilterVisibility, {
|
|
108
|
+
onClick: e => e.stopPropagation(),
|
|
109
|
+
children: /*#__PURE__*/jsx(FilterWrapper, {
|
|
110
|
+
column: header.column
|
|
111
|
+
})
|
|
86
112
|
}) : null, columnResizeMode && /*#__PURE__*/jsx(Resizer, {
|
|
87
113
|
onMouseDown: header.getResizeHandler(),
|
|
88
114
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes, ForwardedRef } from 'react';
|
|
2
2
|
import { EdsDataGridProps } from './EdsDataGridProps';
|
|
3
|
-
declare function EdsDataGridInner<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, tableInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowContextMenu, onRowClick, onRowDoubleClick, onCellClick, enableFooter, enableSortingRemoval, ...rest }: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement>, ref: ForwardedRef<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function EdsDataGridInner<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, selectedRows, rowSelectionState, enableColumnFiltering, columnFiltersState, onColumnFiltersChange, 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, tableInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowContextMenu, onRowClick, onRowDoubleClick, onCellClick, enableFooter, enableSortingRemoval, ...rest }: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement>, ref: ForwardedRef<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const EdsDataGrid: <T>(props: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
ref?: ForwardedRef<HTMLDivElement>;
|
|
6
6
|
}) => ReturnType<typeof EdsDataGridInner>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cell, Column, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSizingState, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, Table, TableOptions } from '@tanstack/react-table';
|
|
1
|
+
import { Cell, Column, ColumnDef, ColumnFilter, ColumnPinningState, ColumnResizeMode, ColumnSizingState, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, Table, TableOptions } from '@tanstack/react-table';
|
|
2
2
|
import { Virtualizer } from '@tanstack/react-virtual';
|
|
3
3
|
import { CSSProperties, MouseEvent, MutableRefObject, ReactElement } from 'react';
|
|
4
4
|
type BaseProps<T> = {
|
|
@@ -184,6 +184,16 @@ type FilterProps = {
|
|
|
184
184
|
* @default false
|
|
185
185
|
*/
|
|
186
186
|
enableColumnFiltering?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Initial filter state
|
|
189
|
+
* @default undefined
|
|
190
|
+
*/
|
|
191
|
+
columnFiltersState?: Array<ColumnFilter>;
|
|
192
|
+
/**
|
|
193
|
+
* Callback for when the filter state changes
|
|
194
|
+
* @default undefined
|
|
195
|
+
*/
|
|
196
|
+
onColumnFiltersChange?: OnChangeFn<Array<ColumnFilter>>;
|
|
187
197
|
};
|
|
188
198
|
type HandlersProps<T> = {
|
|
189
199
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ColumnPinningPosition } from '@tanstack/react-table';
|
|
2
|
+
export declare const FilterVisibility: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
3
|
export declare const TableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<{
|
|
3
4
|
variant?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Variants;
|
|
4
5
|
color?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Colors;
|
|
@@ -15,4 +16,5 @@ export declare const TableCell: import("styled-components/dist/types").IStyledCo
|
|
|
15
16
|
$sticky: boolean;
|
|
16
17
|
$pinned: ColumnPinningPosition;
|
|
17
18
|
$offset: number;
|
|
19
|
+
$activeFilter?: boolean;
|
|
18
20
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<import("@equinor/eds-core-react").CellProps & import("react").RefAttributes<HTMLTableCellElement>>, keyof import("react").Component<any, {}, any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-data-grid-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tanstack/react-table": "^8.21.3",
|
|
24
|
-
"@tanstack/react-virtual": "^3.13.
|
|
24
|
+
"@tanstack/react-virtual": "^3.13.8",
|
|
25
25
|
"@equinor/eds-icons": "^0.22.0",
|
|
26
26
|
"@equinor/eds-tokens": "0.9.2",
|
|
27
27
|
"@equinor/eds-utils": "^0.8.7"
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"rollup": "^4.40.1",
|
|
62
62
|
"rollup-plugin-delete": "^2.2.0",
|
|
63
63
|
"rollup-plugin-postcss": "^4.0.2",
|
|
64
|
-
"storybook": "^8.6.
|
|
65
|
-
"styled-components": "6.1.
|
|
66
|
-
"ts-jest": "29.3.
|
|
64
|
+
"storybook": "^8.6.14",
|
|
65
|
+
"styled-components": "6.1.18",
|
|
66
|
+
"ts-jest": "29.3.3",
|
|
67
67
|
"ts-node": "10.9.2",
|
|
68
68
|
"tsc-watch": "^6.2.1",
|
|
69
69
|
"typescript": "~5.8.3"
|