@equinor/eds-data-grid-react 0.1.0-beta.3 → 0.3.0-rc
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 +458 -353
- package/dist/esm/EdsDataGrid.js +172 -159
- package/dist/esm/EdsDataGridContext.js +6 -9
- package/dist/esm/components/DebouncedInput.js +59 -47
- package/dist/esm/components/Filter.js +100 -46
- package/dist/esm/components/TableBodyCell.js +35 -20
- package/dist/esm/components/TableHeaderCell.js +65 -48
- package/dist/esm/components/TableHeaderRow.js +12 -13
- package/dist/esm/components/TableRow.js +23 -19
- package/dist/types/EdsDataGrid.d.ts +2 -133
- package/dist/types/EdsDataGridContext.d.ts +1 -1
- package/dist/types/EdsDataGridProps.d.ts +204 -0
- package/dist/types/components/DebouncedInput.d.ts +3 -2
- package/dist/types/components/Filter.d.ts +1 -1
- package/dist/types/components/TableBodyCell.d.ts +1 -1
- package/dist/types/components/TableHeaderCell.d.ts +1 -1
- package/dist/types/components/TableHeaderRow.d.ts +1 -1
- package/dist/types/components/TableRow.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +3 -0
- package/package.json +43 -45
|
@@ -1,443 +1,549 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
|
-
var reactTable = require('@tanstack/react-table');
|
|
6
3
|
var edsCoreReact = require('@equinor/eds-core-react');
|
|
4
|
+
var reactTable = require('@tanstack/react-table');
|
|
5
|
+
var reactVirtual = require('@tanstack/react-virtual');
|
|
7
6
|
var react = require('react');
|
|
8
7
|
var edsIcons = require('@equinor/eds-icons');
|
|
9
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
10
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
9
|
var styled = require('styled-components');
|
|
12
10
|
var edsTokens = require('@equinor/eds-tokens');
|
|
13
|
-
var reactVirtual = require('@tanstack/react-virtual');
|
|
14
11
|
|
|
15
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
13
|
|
|
17
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefault(_objectSpread);
|
|
18
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
|
|
19
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
|
|
20
14
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
21
15
|
|
|
22
|
-
var _excluded$1 = ["children"];
|
|
23
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
|
|
17
|
+
const EdsDataGridContext = /*#__PURE__*/react.createContext({
|
|
25
18
|
enableSorting: false,
|
|
26
19
|
stickyHeader: false,
|
|
27
20
|
enableColumnFiltering: false,
|
|
28
21
|
table: null
|
|
29
22
|
});
|
|
30
|
-
function TableProvider(
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
function TableProvider({
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}) {
|
|
33
27
|
return /*#__PURE__*/jsxRuntime.jsx(EdsDataGridContext.Provider, {
|
|
34
28
|
value: props,
|
|
35
29
|
children: children
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
|
-
|
|
39
|
-
return react.useContext(EdsDataGridContext);
|
|
40
|
-
};
|
|
32
|
+
const useTableContext = () => react.useContext(EdsDataGridContext);
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
/* istanbul ignore file */
|
|
43
35
|
// File ignored, as relevant actions are covered via Filter.test.tsx
|
|
44
|
-
function DebouncedInput(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
value = _useState2[0],
|
|
55
|
-
setValue = _useState2[1];
|
|
56
|
-
react.useEffect(function () {
|
|
36
|
+
function DebouncedInput({
|
|
37
|
+
value: initialValue,
|
|
38
|
+
values,
|
|
39
|
+
onChange,
|
|
40
|
+
debounce = 500,
|
|
41
|
+
label,
|
|
42
|
+
...props
|
|
43
|
+
}) {
|
|
44
|
+
const [value, setValue] = react.useState(initialValue);
|
|
45
|
+
react.useEffect(() => {
|
|
57
46
|
setValue(initialValue);
|
|
58
47
|
}, [initialValue]);
|
|
59
|
-
react.useEffect(
|
|
60
|
-
|
|
48
|
+
react.useEffect(() => {
|
|
49
|
+
const timeout = setTimeout(() => {
|
|
61
50
|
onChange(value);
|
|
62
51
|
}, debounce);
|
|
63
|
-
return
|
|
64
|
-
return clearTimeout(timeout);
|
|
65
|
-
};
|
|
52
|
+
return () => clearTimeout(timeout);
|
|
66
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
54
|
}, [value]);
|
|
68
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
}) : /*#__PURE__*/jsxRuntime.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
55
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
56
|
+
children: props.type === 'number' ? /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.InputWrapper, {
|
|
57
|
+
label: props.placeholder,
|
|
58
|
+
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Input, {
|
|
59
|
+
type: 'number',
|
|
60
|
+
placeholder: '0',
|
|
61
|
+
value: value,
|
|
62
|
+
onChange: e => setValue(e.target.valueAsNumber)
|
|
63
|
+
})
|
|
64
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
65
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Autocomplete, {
|
|
66
|
+
options: values,
|
|
67
|
+
autoWidth: true,
|
|
68
|
+
multiple: true,
|
|
69
|
+
optionComponent: opt => opt === 'NULL_OR_UNDEFINED' ? '<Blank>' : opt,
|
|
70
|
+
"data-testid": 'autocomplete'
|
|
71
|
+
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */,
|
|
72
|
+
label: `Select ${label ?? ''}`,
|
|
73
|
+
placeholder: props.placeholder ?? 'Search',
|
|
74
|
+
disablePortal: false /*TODO: Check with Oddbjørn re. sizing/position*/,
|
|
75
|
+
selectedOptions: value,
|
|
76
|
+
onOptionsChange: c => setValue(c.selectedItems),
|
|
77
|
+
multiline: true
|
|
78
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
79
|
+
style: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
flexWrap: 'wrap',
|
|
82
|
+
marginTop: '8px'
|
|
83
|
+
},
|
|
84
|
+
children: value.map(v => /*#__PURE__*/jsxRuntime.jsxs(edsCoreReact.Chip, {
|
|
85
|
+
title: v,
|
|
86
|
+
onKeyDownCapture: event => {
|
|
87
|
+
if (['Backspace', 'Delete'].includes(event.key)) {
|
|
88
|
+
onChange(value.filter(item => item !== v));
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
style: {
|
|
92
|
+
margin: '4px'
|
|
93
|
+
},
|
|
94
|
+
onDelete: () => onChange(value.filter(item => item !== v)),
|
|
95
|
+
children: [v.slice(0, 20), v.length > 20 ? '...' : '']
|
|
96
|
+
}, v))
|
|
97
|
+
})]
|
|
92
98
|
})
|
|
93
99
|
});
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
/* istanbul ignore file */
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const NumberContainer = styled__default.default.div.withConfig({
|
|
105
|
+
displayName: "Filter__NumberContainer",
|
|
106
|
+
componentId: "sc-ytpdpw-0"
|
|
107
|
+
})(["display:grid;grid-template-columns:80px 80px;grid-column-gap:32px;"]);
|
|
108
|
+
function Filter({
|
|
109
|
+
column,
|
|
110
|
+
table
|
|
111
|
+
}) {
|
|
112
|
+
const firstValue = table.getPreFilteredRowModel().flatRows[0]?.getValue(column.id);
|
|
113
|
+
const [open, setOpen] = react.useState(false);
|
|
114
|
+
const filterIconRef = react.useRef();
|
|
115
|
+
const togglePopover = event => {
|
|
116
|
+
event.stopPropagation();
|
|
117
|
+
setOpen(!open);
|
|
118
|
+
};
|
|
119
|
+
const columnText = react.useMemo(() => {
|
|
120
|
+
let header;
|
|
121
|
+
try {
|
|
122
|
+
if (typeof column.columnDef.header === 'function') {
|
|
123
|
+
const obj = column.columnDef.header(
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument
|
|
125
|
+
{});
|
|
126
|
+
header = obj.props.children;
|
|
127
|
+
} else {
|
|
128
|
+
header = column.columnDef.header;
|
|
129
|
+
}
|
|
130
|
+
} catch {
|
|
131
|
+
/*em all*/
|
|
132
|
+
}
|
|
133
|
+
return header;
|
|
134
|
+
}, [column.columnDef]);
|
|
135
|
+
const columnFilterValue = column.getFilterValue();
|
|
136
|
+
const sortedUniqueValues = react.useMemo(() => typeof firstValue === 'number' ? [] : Array.from(column.getFacetedUniqueValues().keys()).sort().map(v => v ?? 'NULL_OR_UNDEFINED'),
|
|
109
137
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
138
|
[column.getFacetedUniqueValues()]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
const hasActiveFilters = value => {
|
|
140
|
+
if (Array.isArray(value)) {
|
|
141
|
+
if (typeof firstValue === 'number') {
|
|
142
|
+
return value.some(v => !isNaN(v) && !!v);
|
|
143
|
+
} else {
|
|
144
|
+
return value.filter(v => !!v).length > 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
};
|
|
149
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
150
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Button, {
|
|
151
|
+
"aria-haspopup": true,
|
|
152
|
+
"aria-expanded": open,
|
|
153
|
+
"data-testid": 'open-filters',
|
|
154
|
+
ref: filterIconRef,
|
|
155
|
+
onClick: togglePopover,
|
|
156
|
+
variant: 'ghost_icon',
|
|
157
|
+
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Icon, {
|
|
158
|
+
color: edsTokens.tokens.colors.text.static_icons__default.hex,
|
|
159
|
+
data: hasActiveFilters(columnFilterValue) ? edsIcons.filter_alt_active : edsIcons.filter_alt
|
|
160
|
+
})
|
|
161
|
+
}), /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Popover, {
|
|
162
|
+
style: {
|
|
163
|
+
width: typeof firstValue === 'number' ? '220px' : '340px'
|
|
134
164
|
},
|
|
135
|
-
|
|
165
|
+
anchorEl: filterIconRef.current,
|
|
166
|
+
open: open,
|
|
167
|
+
onClose: () => setOpen(false),
|
|
168
|
+
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Popover.Content, {
|
|
169
|
+
style: {
|
|
170
|
+
width: typeof firstValue === 'number' ? '180px' : '310px'
|
|
171
|
+
},
|
|
172
|
+
children: typeof firstValue === 'number' ? /*#__PURE__*/jsxRuntime.jsxs(NumberContainer, {
|
|
173
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DebouncedInput, {
|
|
174
|
+
type: "number",
|
|
175
|
+
values: sortedUniqueValues,
|
|
176
|
+
min: Number(column.getFacetedMinMaxValues()?.[0] ?? ''),
|
|
177
|
+
max: Number(column.getFacetedMinMaxValues()?.[1] ?? ''),
|
|
178
|
+
value: columnFilterValue?.[0] ?? '',
|
|
179
|
+
onChange: value => column.setFilterValue(old => [value, old?.[1]]),
|
|
180
|
+
placeholder: `Min ${column.getFacetedMinMaxValues()?.[0] ? `(${column.getFacetedMinMaxValues()?.[0]})` : ''}`
|
|
181
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DebouncedInput, {
|
|
182
|
+
type: "number",
|
|
183
|
+
values: sortedUniqueValues,
|
|
184
|
+
min: Number(column.getFacetedMinMaxValues()?.[0] ?? ''),
|
|
185
|
+
max: Number(column.getFacetedMinMaxValues()?.[1] ?? ''),
|
|
186
|
+
value: columnFilterValue?.[1] ?? '',
|
|
187
|
+
onChange: value => column.setFilterValue(old => [old?.[0], value]),
|
|
188
|
+
placeholder: `Max ${column.getFacetedMinMaxValues()?.[1] ? `(${column.getFacetedMinMaxValues()?.[1]})` : ''}`
|
|
189
|
+
})]
|
|
190
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(DebouncedInput, {
|
|
191
|
+
type: "text",
|
|
192
|
+
label: columnText,
|
|
193
|
+
values: sortedUniqueValues,
|
|
194
|
+
debounce: 100,
|
|
195
|
+
value: columnFilterValue ?? [],
|
|
196
|
+
onChange: value => column.setFilterValue(value),
|
|
197
|
+
placeholder: `${(columnFilterValue ?? []).length} / ${column.getFacetedUniqueValues().size} selected`,
|
|
198
|
+
list: column.id + 'list'
|
|
199
|
+
})
|
|
200
|
+
})
|
|
136
201
|
})]
|
|
137
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(DebouncedInput, {
|
|
138
|
-
type: "text",
|
|
139
|
-
values: sortedUniqueValues,
|
|
140
|
-
value: columnFilterValue !== null && columnFilterValue !== void 0 ? columnFilterValue : '',
|
|
141
|
-
onChange: function onChange(value) {
|
|
142
|
-
return column.setFilterValue(value);
|
|
143
|
-
},
|
|
144
|
-
placeholder: "Search (".concat(column.getFacetedUniqueValues().size, ")"),
|
|
145
|
-
list: column.id + 'list'
|
|
146
202
|
});
|
|
147
203
|
}
|
|
148
204
|
|
|
149
|
-
|
|
205
|
+
const getSortLabel = sorted => {
|
|
150
206
|
if (sorted) {
|
|
151
|
-
return
|
|
207
|
+
return `${sorted}ending`;
|
|
152
208
|
}
|
|
153
209
|
return 'none';
|
|
154
210
|
};
|
|
155
|
-
|
|
156
|
-
displayName: "
|
|
211
|
+
const ResizeInner = styled__default.default.div.withConfig({
|
|
212
|
+
displayName: "TableHeaderCell__ResizeInner",
|
|
157
213
|
componentId: "sc-1n0j3v0-0"
|
|
158
|
-
})(["
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return props.$isResizing ? 1 : 0;
|
|
162
|
-
});
|
|
163
|
-
var Cell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
164
|
-
displayName: "TableHeaderCell__Cell",
|
|
214
|
+
})(["width:2px;opacity:0;height:100%;"]);
|
|
215
|
+
const Resizer = styled__default.default.div.withConfig({
|
|
216
|
+
displayName: "TableHeaderCell__Resizer",
|
|
165
217
|
componentId: "sc-1n0j3v0-1"
|
|
166
|
-
})(["
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
218
|
+
})(["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);
|
|
219
|
+
const Cell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
220
|
+
displayName: "TableHeaderCell__Cell",
|
|
221
|
+
componentId: "sc-1n0j3v0-2"
|
|
222
|
+
})(["font-weight:bold;height:30px;position:", ";top:0;", " ", ";&:hover ", "{background:", ";opacity:1;}"], p => p.$sticky || p.$pinned ? 'sticky' : 'relative', p => {
|
|
223
|
+
if (p.$pinned) {
|
|
224
|
+
return `${p.$pinned}: ${p.$offset}px;`;
|
|
225
|
+
}
|
|
226
|
+
return '';
|
|
227
|
+
}, p => {
|
|
228
|
+
if (p.$sticky && p.$pinned) return 'z-index: 13';
|
|
229
|
+
if (p.$sticky || p.$pinned) return 'z-index: 12';
|
|
230
|
+
}, ResizeInner, edsTokens.tokens.colors.interactive.primary__hover.rgba);
|
|
231
|
+
function TableHeaderCell({
|
|
232
|
+
header,
|
|
233
|
+
columnResizeMode
|
|
234
|
+
}) {
|
|
235
|
+
const ctx = useTableContext();
|
|
236
|
+
const table = ctx.table;
|
|
237
|
+
const pinned = header.column.getIsPinned();
|
|
238
|
+
const offset = react.useMemo(() => {
|
|
239
|
+
if (!pinned) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - header.getSize();
|
|
243
|
+
}, [pinned, header, table]);
|
|
175
244
|
return header.isPlaceholder ? /*#__PURE__*/jsxRuntime.jsx(Cell, {
|
|
176
|
-
sticky: ctx.stickyHeader,
|
|
245
|
+
$sticky: ctx.stickyHeader,
|
|
246
|
+
$offset: offset,
|
|
247
|
+
$pinned: pinned,
|
|
177
248
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
178
|
-
style:
|
|
249
|
+
style: {
|
|
250
|
+
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
251
|
+
},
|
|
179
252
|
"aria-hidden": true
|
|
180
253
|
}) : /*#__PURE__*/jsxRuntime.jsxs(Cell, {
|
|
181
|
-
sticky: ctx.stickyHeader,
|
|
254
|
+
$sticky: ctx.stickyHeader,
|
|
255
|
+
$offset: offset,
|
|
256
|
+
$pinned: pinned,
|
|
182
257
|
className: ctx.headerClass ? ctx.headerClass(header.column) : '',
|
|
183
258
|
"aria-sort": getSortLabel(header.column.getIsSorted()),
|
|
184
259
|
onClick: header.column.getToggleSortingHandler(),
|
|
185
260
|
key: header.id,
|
|
186
261
|
colSpan: header.colSpan,
|
|
187
|
-
style:
|
|
262
|
+
style: {
|
|
188
263
|
width: header.getSize(),
|
|
189
|
-
verticalAlign: ctx.enableColumnFiltering ? '
|
|
190
|
-
|
|
264
|
+
verticalAlign: ctx.enableColumnFiltering ? 'top' : 'middle',
|
|
265
|
+
...(ctx.headerStyle ? ctx.headerStyle(header.column) : {})
|
|
266
|
+
},
|
|
191
267
|
children: [/*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
192
|
-
children: [/*#__PURE__*/jsxRuntime.
|
|
268
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
193
269
|
style: {
|
|
194
270
|
display: 'flex',
|
|
195
271
|
flexDirection: 'column'
|
|
196
272
|
},
|
|
197
|
-
children:
|
|
273
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
198
274
|
className: "table-header-cell-label",
|
|
199
275
|
children: reactTable.flexRender(header.column.columnDef.header, header.getContext())
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
// Supressing this warning - div is not interactive, but prevents propagation of events to avoid unintended sorting
|
|
203
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
204
|
-
jsxRuntime.jsx("div", {
|
|
205
|
-
onClick: function onClick(e) {
|
|
206
|
-
return e.stopPropagation();
|
|
207
|
-
},
|
|
208
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Filter, {
|
|
209
|
-
column: header.column,
|
|
210
|
-
table: table
|
|
211
|
-
})
|
|
212
|
-
}) : null]
|
|
213
|
-
}), (_asc$desc = {
|
|
276
|
+
})
|
|
277
|
+
}), {
|
|
214
278
|
asc: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Icon, {
|
|
215
279
|
data: edsIcons.arrow_up
|
|
216
280
|
}),
|
|
217
281
|
desc: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Icon, {
|
|
218
282
|
data: edsIcons.arrow_down
|
|
219
283
|
})
|
|
220
|
-
}[header.column.getIsSorted()]
|
|
284
|
+
}[header.column.getIsSorted()] ?? null, header.column.getCanFilter() ?
|
|
285
|
+
|
|
286
|
+
// Supressing this warning - div is not interactive, but prevents propagation of events to avoid unintended sorting
|
|
287
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
288
|
+
jsxRuntime.jsx("div", {
|
|
289
|
+
onClick: e => e.stopPropagation(),
|
|
290
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Filter, {
|
|
291
|
+
column: header.column,
|
|
292
|
+
table: table
|
|
293
|
+
})
|
|
294
|
+
}) : null]
|
|
221
295
|
}), columnResizeMode && /*#__PURE__*/jsxRuntime.jsx(Resizer, {
|
|
222
|
-
onClick:
|
|
223
|
-
return e.stopPropagation();
|
|
224
|
-
},
|
|
296
|
+
onClick: e => e.stopPropagation(),
|
|
225
297
|
onMouseDown: header.getResizeHandler(),
|
|
226
298
|
onTouchStart: header.getResizeHandler(),
|
|
227
299
|
$isResizing: header.column.getIsResizing(),
|
|
228
300
|
$columnResizeMode: columnResizeMode,
|
|
229
301
|
className: 'resize-handle',
|
|
230
|
-
"data-testid": 'resize-handle'
|
|
302
|
+
"data-testid": 'resize-handle',
|
|
303
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ResizeInner, {})
|
|
231
304
|
})]
|
|
232
305
|
});
|
|
233
306
|
}
|
|
234
307
|
|
|
235
|
-
function TableHeaderRow(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
308
|
+
function TableHeaderRow({
|
|
309
|
+
headerGroup,
|
|
310
|
+
columnResizeMode,
|
|
311
|
+
deltaOffset,
|
|
312
|
+
table
|
|
313
|
+
}) {
|
|
240
314
|
return /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
241
|
-
children: headerGroup.headers.map(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}, header.id);
|
|
248
|
-
})
|
|
315
|
+
children: headerGroup.headers.map(header => /*#__PURE__*/jsxRuntime.jsx(TableHeaderCell, {
|
|
316
|
+
header: header,
|
|
317
|
+
table: table,
|
|
318
|
+
columnResizeMode: columnResizeMode,
|
|
319
|
+
deltaOffset: deltaOffset
|
|
320
|
+
}, header.id))
|
|
249
321
|
});
|
|
250
322
|
}
|
|
251
323
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
324
|
+
const StyledCell = styled__default.default(edsCoreReact.Table.Cell).withConfig({
|
|
325
|
+
displayName: "TableBodyCell__StyledCell",
|
|
326
|
+
componentId: "sc-1gsd2k4-0"
|
|
327
|
+
})(["position:", ";", " z-index:", ";background-color:inherit;"], p => p.$pinned ? 'sticky' : 'relative', p => {
|
|
328
|
+
if (p.$pinned) {
|
|
329
|
+
return `${p.$pinned}: ${p.$offset}px;`;
|
|
330
|
+
}
|
|
331
|
+
return '';
|
|
332
|
+
}, p => p.$pinned ? 11 : 'auto');
|
|
333
|
+
function TableBodyCell({
|
|
334
|
+
cell
|
|
335
|
+
}) {
|
|
336
|
+
const {
|
|
337
|
+
cellClass,
|
|
338
|
+
cellStyle,
|
|
339
|
+
table
|
|
340
|
+
} = useTableContext();
|
|
341
|
+
const pinned = cell.column.getIsPinned();
|
|
342
|
+
const pinnedOffset = react.useMemo(() => {
|
|
343
|
+
if (!pinned) {
|
|
344
|
+
return 0;
|
|
345
|
+
}
|
|
346
|
+
const header = table.getFlatHeaders().find(h => h.id === cell.column.id);
|
|
347
|
+
return pinned === 'left' ? header.getStart() : table.getTotalSize() - header.getStart() - cell.column.getSize();
|
|
348
|
+
}, [pinned, cell.column, table]);
|
|
349
|
+
return /*#__PURE__*/jsxRuntime.jsx(StyledCell, {
|
|
350
|
+
$pinned: pinned,
|
|
351
|
+
$offset: pinnedOffset,
|
|
259
352
|
className: cellClass ? cellClass(cell.row, cell.column.id) : '',
|
|
260
353
|
key: cell.id,
|
|
261
|
-
style:
|
|
354
|
+
style: {
|
|
262
355
|
width: cell.column.getSize(),
|
|
263
356
|
maxWidth: cell.column.getSize(),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}, (_cellStyle = cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle(cell.row, cell.column.id)) !== null && _cellStyle !== void 0 ? _cellStyle : {}),
|
|
268
|
-
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Typography, {
|
|
269
|
-
as: "span",
|
|
270
|
-
group: "table",
|
|
271
|
-
variant: "cell_text",
|
|
272
|
-
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
273
|
-
})
|
|
357
|
+
...(cellStyle?.(cell.row, cell.column.id) ?? {})
|
|
358
|
+
},
|
|
359
|
+
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
274
360
|
});
|
|
275
361
|
}
|
|
276
362
|
|
|
277
|
-
function TableRow(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
rowClass
|
|
282
|
-
rowStyle
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
onClick: function onClick() {
|
|
289
|
-
return row.getCanSelect() ? row.toggleSelected() : null;
|
|
363
|
+
function TableRow({
|
|
364
|
+
row
|
|
365
|
+
}) {
|
|
366
|
+
const {
|
|
367
|
+
rowClass,
|
|
368
|
+
rowStyle
|
|
369
|
+
} = useTableContext();
|
|
370
|
+
return /*#__PURE__*/jsxRuntime.jsx(StyledTableRow, {
|
|
371
|
+
style: {
|
|
372
|
+
cursor: row.getCanSelect() ? 'pointer' : 'inherit',
|
|
373
|
+
...(rowStyle?.(row) ?? {})
|
|
290
374
|
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
})
|
|
375
|
+
className: `${row.getIsSelected() ? 'selected' : ''} ${rowClass?.(row)}`,
|
|
376
|
+
onClick: () => row.getCanSelect() ? row.toggleSelected() : null,
|
|
377
|
+
children: row.getVisibleCells().map(cell => /*#__PURE__*/jsxRuntime.jsx(TableBodyCell, {
|
|
378
|
+
cell: cell
|
|
379
|
+
}, cell.id))
|
|
296
380
|
});
|
|
297
381
|
}
|
|
298
382
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
setVisible(columnVisibility !== null && columnVisibility !== void 0 ? columnVisibility : {});
|
|
383
|
+
// Neccessary to have this attribute as class to prevent overriding hover color
|
|
384
|
+
const StyledTableRow = styled__default.default(edsCoreReact.Table.Row).withConfig({
|
|
385
|
+
displayName: "TableRow__StyledTableRow",
|
|
386
|
+
componentId: "sc-1vjfq5p-0"
|
|
387
|
+
})(["background-color:inherit;"]);
|
|
388
|
+
|
|
389
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
390
|
+
function EdsDataGrid({
|
|
391
|
+
rows,
|
|
392
|
+
columns,
|
|
393
|
+
columnResizeMode,
|
|
394
|
+
pageSize,
|
|
395
|
+
rowSelection,
|
|
396
|
+
selectedRows,
|
|
397
|
+
enableColumnFiltering,
|
|
398
|
+
debug,
|
|
399
|
+
enablePagination,
|
|
400
|
+
enableSorting,
|
|
401
|
+
stickyHeader,
|
|
402
|
+
onSelectRow,
|
|
403
|
+
caption,
|
|
404
|
+
enableVirtual,
|
|
405
|
+
virtualHeight,
|
|
406
|
+
columnVisibility,
|
|
407
|
+
columnVisibilityChange,
|
|
408
|
+
emptyMessage,
|
|
409
|
+
columnOrder,
|
|
410
|
+
cellClass,
|
|
411
|
+
cellStyle,
|
|
412
|
+
rowClass,
|
|
413
|
+
rowStyle,
|
|
414
|
+
headerClass,
|
|
415
|
+
headerStyle,
|
|
416
|
+
externalPaginator,
|
|
417
|
+
onSortingChange,
|
|
418
|
+
manualSorting,
|
|
419
|
+
sortingState,
|
|
420
|
+
columnPinState,
|
|
421
|
+
scrollbarHorizontal,
|
|
422
|
+
width,
|
|
423
|
+
minWidth,
|
|
424
|
+
height,
|
|
425
|
+
getRowId,
|
|
426
|
+
rowVirtualizerInstanceRef
|
|
427
|
+
}) {
|
|
428
|
+
const [sorting, setSorting] = react.useState(sortingState ?? []);
|
|
429
|
+
const [selection, setSelection] = react.useState(selectedRows ?? {});
|
|
430
|
+
const [columnPin, setColumnPin] = react.useState(columnPinState ?? {});
|
|
431
|
+
const [columnFilters, setColumnFilters] = react.useState([]);
|
|
432
|
+
const [visible, setVisible] = react.useState(columnVisibility ?? {});
|
|
433
|
+
const [globalFilter, setGlobalFilter] = react.useState('');
|
|
434
|
+
const [columnOrderState, setColumnOrderState] = react.useState([]);
|
|
435
|
+
const [page, setPage] = react.useState({
|
|
436
|
+
pageIndex: 0,
|
|
437
|
+
pageSize: pageSize ?? 25
|
|
438
|
+
});
|
|
439
|
+
react.useEffect(() => {
|
|
440
|
+
setVisible(columnVisibility ?? {});
|
|
358
441
|
}, [columnVisibility, setVisible]);
|
|
359
|
-
react.useEffect(
|
|
360
|
-
|
|
442
|
+
react.useEffect(() => {
|
|
443
|
+
setColumnPin(s => columnPinState ?? s);
|
|
444
|
+
}, [columnPinState]);
|
|
445
|
+
react.useEffect(() => {
|
|
446
|
+
setSorting(sortingState);
|
|
447
|
+
}, [sortingState]);
|
|
448
|
+
react.useEffect(() => {
|
|
449
|
+
setSelection(selectedRows ?? {});
|
|
361
450
|
}, [selectedRows]);
|
|
362
451
|
|
|
363
452
|
/**
|
|
364
453
|
* By default, the filter-function accepts single-value filters. This adds multi-filter functionality out of the box.
|
|
365
454
|
*/
|
|
366
|
-
|
|
367
|
-
return columns.map(
|
|
455
|
+
const _columns = react.useMemo(() => {
|
|
456
|
+
return columns.map(column => {
|
|
368
457
|
if (column.filterFn || column.enableColumnFilter === false) {
|
|
369
458
|
return column;
|
|
370
459
|
}
|
|
371
460
|
/* istanbul ignore next */
|
|
372
|
-
return
|
|
373
|
-
|
|
374
|
-
|
|
461
|
+
return {
|
|
462
|
+
...column,
|
|
463
|
+
filterFn: (row, columnId, filterValue) => {
|
|
375
464
|
if (debug) {
|
|
376
465
|
console.log('filterFn', row, columnId, filterValue);
|
|
377
466
|
}
|
|
378
467
|
if (!filterValue || (Array.isArray(filterValue) || typeof filterValue === 'string') && filterValue.length === 0) {
|
|
379
468
|
return true;
|
|
380
469
|
}
|
|
381
|
-
|
|
470
|
+
const value = row.getValue(columnId) ?? 'NULL_OR_UNDEFINED';
|
|
382
471
|
if (Array.isArray(filterValue)) {
|
|
383
|
-
|
|
384
|
-
return typeof v === 'number';
|
|
385
|
-
});
|
|
472
|
+
const numeric = filterValue.some(v => typeof v === 'number');
|
|
386
473
|
if (numeric) {
|
|
387
|
-
|
|
388
|
-
_ref3 = _slicedToArray__default.default(_ref2, 2),
|
|
389
|
-
start = _ref3[0],
|
|
390
|
-
end = _ref3[1];
|
|
474
|
+
const [start, end] = filterValue;
|
|
391
475
|
return Number(value) >= (isNaN(start) ? 0 : start) && Number(value) <= (!end || isNaN(end) ? Infinity : end);
|
|
392
476
|
} else {
|
|
393
|
-
|
|
394
|
-
return !!v;
|
|
395
|
-
});
|
|
477
|
+
const validFilterValue = filterValue.filter(v => !!v);
|
|
396
478
|
if (validFilterValue.length === 0) return true;
|
|
397
479
|
return filterValue.includes(value);
|
|
398
480
|
}
|
|
399
481
|
}
|
|
400
482
|
return value === filterValue;
|
|
401
483
|
}
|
|
402
|
-
}
|
|
484
|
+
};
|
|
403
485
|
});
|
|
404
486
|
}, [debug, columns]);
|
|
405
487
|
|
|
406
488
|
/**
|
|
407
489
|
* Set up default table options
|
|
408
490
|
*/
|
|
409
|
-
|
|
491
|
+
const options = {
|
|
410
492
|
data: rows,
|
|
411
493
|
columns: _columns,
|
|
494
|
+
defaultColumn: {
|
|
495
|
+
cell: context => {
|
|
496
|
+
return /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Typography, {
|
|
497
|
+
style: {
|
|
498
|
+
overflow: 'hidden',
|
|
499
|
+
whiteSpace: 'nowrap',
|
|
500
|
+
textOverflow: 'ellipsis'
|
|
501
|
+
},
|
|
502
|
+
group: "table",
|
|
503
|
+
variant: "cell_text",
|
|
504
|
+
children: String(context.getValue() ?? '')
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
},
|
|
412
508
|
columnResizeMode: columnResizeMode,
|
|
413
509
|
state: {
|
|
414
|
-
sorting
|
|
510
|
+
sorting,
|
|
511
|
+
columnPinning: columnPin,
|
|
415
512
|
rowSelection: selection,
|
|
416
513
|
columnOrder: columnOrderState
|
|
417
514
|
},
|
|
418
|
-
onSortingChange:
|
|
515
|
+
onSortingChange: changes => {
|
|
516
|
+
if (onSortingChange) {
|
|
517
|
+
onSortingChange(changes);
|
|
518
|
+
}
|
|
519
|
+
setSorting(changes);
|
|
520
|
+
},
|
|
419
521
|
enableColumnFilters: !!enableColumnFiltering,
|
|
420
522
|
enableFilters: !!enableColumnFiltering,
|
|
421
|
-
enableSorting: enableSorting
|
|
523
|
+
enableSorting: enableSorting ?? false,
|
|
524
|
+
manualSorting: manualSorting ?? false,
|
|
422
525
|
enableColumnResizing: !!columnResizeMode,
|
|
423
526
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
424
527
|
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
425
528
|
debugTable: debug,
|
|
426
529
|
debugHeaders: debug,
|
|
427
530
|
debugColumns: debug,
|
|
428
|
-
enableRowSelection: rowSelection
|
|
531
|
+
enableRowSelection: rowSelection ?? false,
|
|
532
|
+
enableColumnPinning: true,
|
|
533
|
+
enablePinning: true,
|
|
534
|
+
getRowId
|
|
429
535
|
};
|
|
430
|
-
react.useEffect(
|
|
536
|
+
react.useEffect(() => {
|
|
431
537
|
if (columnOrder && columnOrder.length > 0) {
|
|
432
|
-
setColumnOrderState(columnOrder
|
|
538
|
+
setColumnOrderState(columnOrder ?? []);
|
|
433
539
|
}
|
|
434
540
|
}, [columnOrder]);
|
|
435
541
|
|
|
436
542
|
/**
|
|
437
543
|
* Set up handlers for rowSelection
|
|
438
544
|
*/
|
|
439
|
-
if (rowSelection
|
|
440
|
-
options.onRowSelectionChange =
|
|
545
|
+
if (rowSelection ?? false) {
|
|
546
|
+
options.onRowSelectionChange = updaterOrValue => {
|
|
441
547
|
if (onSelectRow) {
|
|
442
548
|
onSelectRow(updaterOrValue);
|
|
443
549
|
}
|
|
@@ -462,7 +568,7 @@ function EdsDataGrid(_ref) {
|
|
|
462
568
|
/**
|
|
463
569
|
* Set up config for pagination
|
|
464
570
|
*/
|
|
465
|
-
if (enablePagination
|
|
571
|
+
if (enablePagination ?? false) {
|
|
466
572
|
options.state.pagination = page;
|
|
467
573
|
options.getPaginationRowModel = reactTable.getPaginationRowModel();
|
|
468
574
|
}
|
|
@@ -472,8 +578,8 @@ function EdsDataGrid(_ref) {
|
|
|
472
578
|
*/
|
|
473
579
|
if (columnVisibility) {
|
|
474
580
|
options.state.columnVisibility = visible;
|
|
475
|
-
options.onColumnVisibilityChange =
|
|
476
|
-
|
|
581
|
+
options.onColumnVisibilityChange = vis => {
|
|
582
|
+
let updated;
|
|
477
583
|
if (typeof vis === 'function') {
|
|
478
584
|
updated = vis(visible);
|
|
479
585
|
} else {
|
|
@@ -483,15 +589,14 @@ function EdsDataGrid(_ref) {
|
|
|
483
589
|
setVisible(updated);
|
|
484
590
|
};
|
|
485
591
|
}
|
|
486
|
-
react.useEffect(
|
|
487
|
-
setPage(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
});
|
|
592
|
+
react.useEffect(() => {
|
|
593
|
+
setPage(prev => ({
|
|
594
|
+
...prev,
|
|
595
|
+
pageSize: pageSize ?? 25
|
|
596
|
+
}));
|
|
492
597
|
}, [pageSize]);
|
|
493
|
-
|
|
494
|
-
|
|
598
|
+
const table = reactTable.useReactTable(options);
|
|
599
|
+
let parentRefStyle = {};
|
|
495
600
|
|
|
496
601
|
/**
|
|
497
602
|
* Style the parent container to enable virtualization.
|
|
@@ -499,34 +604,34 @@ function EdsDataGrid(_ref) {
|
|
|
499
604
|
*/
|
|
500
605
|
if (enableVirtual) {
|
|
501
606
|
parentRefStyle = {
|
|
502
|
-
height:
|
|
607
|
+
height: height ?? virtualHeight ?? 500,
|
|
503
608
|
overflow: 'auto',
|
|
504
609
|
position: 'relative'
|
|
505
610
|
};
|
|
506
611
|
}
|
|
507
|
-
|
|
612
|
+
const parentRef = react.useRef(null);
|
|
508
613
|
|
|
509
614
|
/**
|
|
510
615
|
* Virtualization setup
|
|
511
616
|
*/
|
|
512
|
-
|
|
513
|
-
density
|
|
514
|
-
|
|
617
|
+
const {
|
|
618
|
+
density
|
|
619
|
+
} = edsCoreReact.useEds();
|
|
620
|
+
const estimateSize = react.useCallback(() => {
|
|
515
621
|
return density === 'compact' ? 32 : 48;
|
|
516
622
|
}, [density]);
|
|
517
|
-
|
|
623
|
+
const virtualizer = reactVirtual.useVirtualizer({
|
|
518
624
|
count: table.getRowModel().rows.length,
|
|
519
|
-
getScrollElement:
|
|
520
|
-
|
|
521
|
-
},
|
|
522
|
-
estimateSize: estimateSize
|
|
625
|
+
getScrollElement: () => parentRef.current,
|
|
626
|
+
estimateSize
|
|
523
627
|
});
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
628
|
+
if (rowVirtualizerInstanceRef) rowVirtualizerInstanceRef.current = virtualizer;
|
|
629
|
+
const virtualRows = virtualizer.getVirtualItems();
|
|
630
|
+
const paddingTop = virtualRows.length ? virtualRows[0].start : 0;
|
|
631
|
+
const paddingBottom = virtualRows.length ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end : 0;
|
|
527
632
|
|
|
528
633
|
// These classes are primarily used to allow for feature-detection in the test-suite
|
|
529
|
-
|
|
634
|
+
const classList = {
|
|
530
635
|
'sticky-header': !!stickyHeader,
|
|
531
636
|
virtual: !!enableVirtual,
|
|
532
637
|
paging: !!enablePagination
|
|
@@ -544,82 +649,82 @@ function EdsDataGrid(_ref) {
|
|
|
544
649
|
stickyHeader: !!stickyHeader,
|
|
545
650
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
546
651
|
className: "table-wrapper",
|
|
547
|
-
style:
|
|
652
|
+
style: {
|
|
653
|
+
height: height ?? 'auto',
|
|
654
|
+
...parentRefStyle,
|
|
655
|
+
width: scrollbarHorizontal ? width ?? '100%' : 'auto',
|
|
656
|
+
overflow: 'auto',
|
|
657
|
+
contain: 'layout paint style'
|
|
658
|
+
},
|
|
548
659
|
ref: parentRef,
|
|
549
660
|
children: [/*#__PURE__*/jsxRuntime.jsxs(edsCoreReact.Table, {
|
|
550
|
-
className: Object.entries(classList).filter(
|
|
551
|
-
var _ref5 = _slicedToArray__default.default(_ref4, 2),
|
|
552
|
-
k = _ref5[1];
|
|
553
|
-
return k;
|
|
554
|
-
}).map(function (_ref6) {
|
|
555
|
-
var _ref7 = _slicedToArray__default.default(_ref6, 1),
|
|
556
|
-
k = _ref7[0];
|
|
557
|
-
return k;
|
|
558
|
-
}).join(' '),
|
|
661
|
+
className: Object.entries(classList).filter(([, k]) => k).map(([k]) => k).join(' '),
|
|
559
662
|
style: {
|
|
560
|
-
|
|
663
|
+
tableLayout: scrollbarHorizontal ? 'fixed' : 'auto',
|
|
664
|
+
width: table.getTotalSize(),
|
|
665
|
+
minWidth: scrollbarHorizontal ? minWidth : 'auto'
|
|
561
666
|
},
|
|
562
667
|
children: [caption && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Caption, {
|
|
563
668
|
children: caption
|
|
564
669
|
}), /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Head, {
|
|
565
670
|
sticky: stickyHeader,
|
|
566
|
-
children: table.getHeaderGroups().map(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}, headerGroup.id);
|
|
573
|
-
})
|
|
671
|
+
children: table.getHeaderGroups().map(headerGroup => /*#__PURE__*/jsxRuntime.jsx(TableHeaderRow, {
|
|
672
|
+
table: table,
|
|
673
|
+
headerGroup: headerGroup,
|
|
674
|
+
columnResizeMode: columnResizeMode,
|
|
675
|
+
deltaOffset: table.getState().columnSizingInfo.deltaOffset
|
|
676
|
+
}, headerGroup.id))
|
|
574
677
|
}), /*#__PURE__*/jsxRuntime.jsxs(edsCoreReact.Table.Body, {
|
|
678
|
+
style: {
|
|
679
|
+
backgroundColor: 'inherit'
|
|
680
|
+
},
|
|
575
681
|
children: [table.getRowModel().rows.length === 0 && emptyMessage && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
576
682
|
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Cell, {
|
|
577
|
-
colSpan: table.
|
|
683
|
+
colSpan: table.getFlatHeaders().length,
|
|
578
684
|
children: emptyMessage
|
|
579
685
|
})
|
|
580
686
|
}), enableVirtual && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
581
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
687
|
+
children: [paddingTop > 0 && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
582
688
|
"data-testid": "virtual-padding-top",
|
|
583
689
|
className: 'virtual-padding-top',
|
|
690
|
+
style: {
|
|
691
|
+
pointerEvents: 'none'
|
|
692
|
+
},
|
|
584
693
|
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Cell, {
|
|
585
694
|
style: {
|
|
586
|
-
height:
|
|
695
|
+
height: `${paddingTop}px`
|
|
587
696
|
}
|
|
588
697
|
})
|
|
589
|
-
}), virtualRows.map(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}, row.index);
|
|
593
|
-
}), /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
698
|
+
}), virtualRows.map(row => /*#__PURE__*/jsxRuntime.jsx(TableRow, {
|
|
699
|
+
row: table.getRowModel().rows[row.index]
|
|
700
|
+
}, row.index)), paddingBottom > 0 && /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Row, {
|
|
594
701
|
"data-testid": "virtual-padding-bottom",
|
|
595
702
|
className: 'virtual-padding-bottom',
|
|
703
|
+
style: {
|
|
704
|
+
pointerEvents: 'none'
|
|
705
|
+
},
|
|
596
706
|
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Table.Cell, {
|
|
597
707
|
style: {
|
|
598
|
-
height:
|
|
708
|
+
height: `${paddingBottom}px`
|
|
599
709
|
}
|
|
600
710
|
})
|
|
601
711
|
})]
|
|
602
|
-
}), !enableVirtual && table.getRowModel().rows.map(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}, row.id);
|
|
606
|
-
})]
|
|
712
|
+
}), !enableVirtual && table.getRowModel().rows.map(row => /*#__PURE__*/jsxRuntime.jsx(TableRow, {
|
|
713
|
+
row: row
|
|
714
|
+
}, row.id))]
|
|
607
715
|
})]
|
|
608
|
-
}), enablePagination && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
716
|
+
}), externalPaginator ? externalPaginator : enablePagination && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
609
717
|
style: {
|
|
610
|
-
maxWidth:
|
|
718
|
+
maxWidth: `${table.getTotalSize()}px`
|
|
611
719
|
},
|
|
612
720
|
children: /*#__PURE__*/jsxRuntime.jsx(edsCoreReact.Pagination, {
|
|
613
721
|
totalItems: table.getFilteredRowModel().rows.length,
|
|
614
722
|
withItemIndicator: true,
|
|
615
723
|
itemsPerPage: page.pageSize,
|
|
616
|
-
onChange:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
});
|
|
621
|
-
});
|
|
622
|
-
},
|
|
724
|
+
onChange: (e, p) => setPage(s => ({
|
|
725
|
+
...s,
|
|
726
|
+
pageIndex: p - 1
|
|
727
|
+
})),
|
|
623
728
|
defaultPage: 1
|
|
624
729
|
})
|
|
625
730
|
})]
|