@equinor/apollo-components 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +46 -8
- package/dist/index.js +424 -147
- package/dist/index.mjs +411 -137
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,13 @@ __export(src_exports, {
|
|
|
30
30
|
AppSidebar: () => AppSidebar,
|
|
31
31
|
ChipsCell: () => ChipsCell,
|
|
32
32
|
DataTable: () => DataTable2,
|
|
33
|
+
DynamicCell: () => DynamicCell,
|
|
34
|
+
HierarchyCell: () => HierarchyCell,
|
|
35
|
+
SelectColumnDef: () => SelectColumnDef,
|
|
36
|
+
StickyCell: () => StickyCell,
|
|
37
|
+
TypographyCustom: () => TypographyCustom,
|
|
33
38
|
globalFilterAtom: () => globalFilterAtom,
|
|
39
|
+
prependSelectColumn: () => prependSelectColumn,
|
|
34
40
|
rowSelectionAtom: () => rowSelectionAtom,
|
|
35
41
|
tableSortingAtom: () => tableSortingAtom
|
|
36
42
|
});
|
|
@@ -177,11 +183,221 @@ var ChipsCell = (props) => {
|
|
|
177
183
|
});
|
|
178
184
|
};
|
|
179
185
|
|
|
186
|
+
// src/cells/DynamicCell.tsx
|
|
187
|
+
var import_eds_core_react4 = require("@equinor/eds-core-react");
|
|
188
|
+
var import_react_table = require("@tanstack/react-table");
|
|
189
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
190
|
+
|
|
191
|
+
// src/cells/StickyCell.tsx
|
|
192
|
+
var import_eds_core_react3 = require("@equinor/eds-core-react");
|
|
193
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
194
|
+
var StickyCell = (0, import_styled_components4.default)(import_eds_core_react3.Table.Cell)`
|
|
195
|
+
position: sticky;
|
|
196
|
+
right: 0;
|
|
197
|
+
top: 0;
|
|
198
|
+
z-index: 4;
|
|
199
|
+
`;
|
|
200
|
+
var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
|
|
201
|
+
z-index: 5;
|
|
202
|
+
`;
|
|
203
|
+
|
|
204
|
+
// src/cells/styles.ts
|
|
205
|
+
var import_styled_components5 = require("styled-components");
|
|
206
|
+
var leftCellShadow = import_styled_components5.css`
|
|
207
|
+
&:before {
|
|
208
|
+
box-shadow: -1px 0 1px -1px inset;
|
|
209
|
+
content: ' ';
|
|
210
|
+
height: 100%;
|
|
211
|
+
top: 0;
|
|
212
|
+
left: -1px;
|
|
213
|
+
position: absolute;
|
|
214
|
+
width: 1px;
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
// src/cells/DynamicCell.tsx
|
|
219
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
220
|
+
var StyledStickyCell = (0, import_styled_components6.default)(StickyCell)`
|
|
221
|
+
background-clip: padding-box;
|
|
222
|
+
${leftCellShadow}
|
|
223
|
+
`;
|
|
224
|
+
var StyledCell = (0, import_styled_components6.default)(import_eds_core_react4.Table.Cell)`
|
|
225
|
+
background-color: ${(props) => props.backgroundColor ? props.backgroundColor + " !important" : void 0};
|
|
226
|
+
`;
|
|
227
|
+
function DynamicCell({ cell, highlight }) {
|
|
228
|
+
var _a;
|
|
229
|
+
const cellContent = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
230
|
+
if ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.sticky) {
|
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledStickyCell, {
|
|
232
|
+
"data-column": cell.column.id,
|
|
233
|
+
children: cellContent
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledCell, {
|
|
237
|
+
"data-column": cell.column.id,
|
|
238
|
+
backgroundColor: highlight ? "#d5eaf4" : void 0,
|
|
239
|
+
children: cellContent
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/cells/HierarchyCell.tsx
|
|
244
|
+
var import_eds_tokens4 = require("@equinor/eds-tokens");
|
|
245
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
246
|
+
|
|
247
|
+
// src/cells/TypographyCustom.tsx
|
|
248
|
+
var import_eds_core_react5 = require("@equinor/eds-core-react");
|
|
249
|
+
var import_eds_tokens3 = require("@equinor/eds-tokens");
|
|
250
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
251
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
252
|
+
var truncateStyle = {
|
|
253
|
+
overflow: "hidden",
|
|
254
|
+
whiteSpace: "nowrap",
|
|
255
|
+
textOverflow: "ellipsis"
|
|
256
|
+
};
|
|
257
|
+
var TypographyCustom = (props) => {
|
|
258
|
+
const { noWrap, showAllOnHover, style: styleFromProps, ...edsTypographyProps } = props;
|
|
259
|
+
if (noWrap && showAllOnHover)
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HoverCapture, {
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ShowAllWrapperWrapper, {
|
|
263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
264
|
+
...edsTypographyProps,
|
|
265
|
+
ref: void 0,
|
|
266
|
+
style: {
|
|
267
|
+
...styleFromProps,
|
|
268
|
+
whiteSpace: "nowrap"
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
273
|
+
...edsTypographyProps,
|
|
274
|
+
style: {
|
|
275
|
+
...styleFromProps,
|
|
276
|
+
...truncateStyle
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
});
|
|
281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
282
|
+
...edsTypographyProps,
|
|
283
|
+
style: { ...styleFromProps, ...noWrap ? truncateStyle : {} }
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
var HoverCapture = import_styled_components7.default.div`
|
|
287
|
+
position: relative;
|
|
288
|
+
z-index: 0;
|
|
289
|
+
|
|
290
|
+
padding: 0.5em;
|
|
291
|
+
margin: -0.5em;
|
|
292
|
+
|
|
293
|
+
&:hover > * {
|
|
294
|
+
opacity: 1;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
var ShowAllWrapperWrapper = import_styled_components7.default.div`
|
|
298
|
+
position: absolute;
|
|
299
|
+
z-index: 1;
|
|
300
|
+
pointer-events: none;
|
|
301
|
+
|
|
302
|
+
opacity: 0;
|
|
303
|
+
padding-right: 1em;
|
|
304
|
+
background-color: ${import_eds_tokens3.tokens.colors.interactive.table__cell__fill_hover.hex};
|
|
305
|
+
`;
|
|
306
|
+
|
|
307
|
+
// src/cells/HierarchyCell.tsx
|
|
308
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
309
|
+
var CellWrapper = (0, import_styled_components8.default)(TypographyCustom)`
|
|
310
|
+
height: 100%;
|
|
311
|
+
display: flex;
|
|
312
|
+
align-items: center;
|
|
313
|
+
|
|
314
|
+
${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
|
|
315
|
+
|
|
316
|
+
${({ depth }) => depth > 0 && import_styled_components8.css`
|
|
317
|
+
border-left: 3px solid ${import_eds_tokens4.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
318
|
+
gap: 0.5rem;
|
|
319
|
+
.--divider {
|
|
320
|
+
width: ${depth * 32}px;
|
|
321
|
+
background-color: ${import_eds_tokens4.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
322
|
+
height: 3px;
|
|
323
|
+
border-radius: 0 5px 5px 0;
|
|
324
|
+
}
|
|
325
|
+
`}
|
|
326
|
+
`;
|
|
327
|
+
function HierarchyCell(cell) {
|
|
328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(CellWrapper, {
|
|
329
|
+
depth: cell.row.depth,
|
|
330
|
+
expanded: cell.row.getIsExpanded(),
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
|
|
333
|
+
className: "--divider"
|
|
334
|
+
}),
|
|
335
|
+
cell.getValue()
|
|
336
|
+
]
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/cells/SelectColumnDef.tsx
|
|
341
|
+
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
342
|
+
var import_eds_icons3 = require("@equinor/eds-icons");
|
|
343
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
344
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
345
|
+
var CellWrapper2 = import_styled_components9.default.div`
|
|
346
|
+
display: flex;
|
|
347
|
+
align-items: center;
|
|
348
|
+
width: 48px;
|
|
349
|
+
margin-left: -16px;
|
|
350
|
+
`;
|
|
351
|
+
function SelectColumnDef(selectionMode) {
|
|
352
|
+
return {
|
|
353
|
+
id: "select",
|
|
354
|
+
header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellWrapper2, {
|
|
355
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
356
|
+
checked: table.getIsAllRowsSelected(),
|
|
357
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
358
|
+
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
359
|
+
onChange: table.getToggleAllRowsSelectedHandler()
|
|
360
|
+
})
|
|
361
|
+
}) : null,
|
|
362
|
+
cell: ({ table, row }) => {
|
|
363
|
+
const paddingLeft = "0px";
|
|
364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellWrapper2, {
|
|
365
|
+
paddingLeft,
|
|
366
|
+
rowDepth: row.depth,
|
|
367
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
|
|
368
|
+
children: [
|
|
369
|
+
selectionMode === "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Radio, {
|
|
370
|
+
checked: row.getIsSelected(),
|
|
371
|
+
"aria-label": `Select row ${row.id}`,
|
|
372
|
+
onChange: row.getToggleSelectedHandler()
|
|
373
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
374
|
+
checked: row.getIsSelected(),
|
|
375
|
+
indeterminate: row.getIsSomeSelected(),
|
|
376
|
+
"aria-label": `Select row ${row.id}`,
|
|
377
|
+
onChange: row.getToggleSelectedHandler()
|
|
378
|
+
}),
|
|
379
|
+
row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
|
|
380
|
+
variant: "ghost_icon",
|
|
381
|
+
color: "secondary",
|
|
382
|
+
"aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
|
|
383
|
+
onClick: row.getToggleExpandedHandler(),
|
|
384
|
+
style: { cursor: "pointer" },
|
|
385
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, {
|
|
386
|
+
data: row.getIsExpanded() ? import_eds_icons3.chevron_up : import_eds_icons3.chevron_down
|
|
387
|
+
})
|
|
388
|
+
})
|
|
389
|
+
]
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
180
396
|
// src/DataTable/DataTable.tsx
|
|
181
|
-
var
|
|
397
|
+
var import_react_table5 = require("@tanstack/react-table");
|
|
182
398
|
var import_jotai3 = require("jotai");
|
|
183
399
|
var import_react4 = require("react");
|
|
184
|
-
var
|
|
400
|
+
var import_styled_components15 = __toESM(require("styled-components"));
|
|
185
401
|
|
|
186
402
|
// src/DataTable/atoms.ts
|
|
187
403
|
var import_jotai = require("jotai");
|
|
@@ -189,85 +405,129 @@ var columnVisibilityAtom = (0, import_jotai.atom)({});
|
|
|
189
405
|
var globalFilterAtom = (0, import_jotai.atom)("");
|
|
190
406
|
var rowSelectionAtom = (0, import_jotai.atom)({});
|
|
191
407
|
var tableSortingAtom = (0, import_jotai.atom)([]);
|
|
408
|
+
var expandedRowsAtom = (0, import_jotai.atom)({});
|
|
192
409
|
|
|
193
410
|
// src/DataTable/components/BasicTable.tsx
|
|
194
|
-
var
|
|
195
|
-
var
|
|
411
|
+
var import_eds_core_react10 = require("@equinor/eds-core-react");
|
|
412
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
413
|
+
|
|
414
|
+
// src/DataTable/components/PlaceholderRow.tsx
|
|
415
|
+
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
416
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
417
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
418
|
+
var PlaceholderTextWrapper = import_styled_components10.default.div`
|
|
419
|
+
display: flex;
|
|
420
|
+
justify-content: center;
|
|
421
|
+
`;
|
|
422
|
+
function PlaceholderRow({ isLoading }) {
|
|
423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Table.Row, {
|
|
424
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Table.Cell, {
|
|
425
|
+
colSpan: 100,
|
|
426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PlaceholderTextWrapper, {
|
|
427
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.DotProgress, {
|
|
428
|
+
color: "primary"
|
|
429
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Typography, {
|
|
430
|
+
children: "No data available"
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
})
|
|
434
|
+
});
|
|
435
|
+
}
|
|
196
436
|
|
|
197
437
|
// src/DataTable/components/TableHeader.tsx
|
|
198
|
-
var
|
|
438
|
+
var import_eds_core_react9 = require("@equinor/eds-core-react");
|
|
199
439
|
|
|
200
|
-
// src/
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
var
|
|
206
|
-
var HeaderDiv =
|
|
440
|
+
// src/cells/HeaderCell.tsx
|
|
441
|
+
var import_eds_core_react8 = require("@equinor/eds-core-react");
|
|
442
|
+
var import_eds_icons4 = require("@equinor/eds-icons");
|
|
443
|
+
var import_react_table2 = require("@tanstack/react-table");
|
|
444
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
445
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
446
|
+
var HeaderDiv = import_styled_components11.default.div`
|
|
207
447
|
display: flex;
|
|
208
448
|
align-items: center;
|
|
209
449
|
gap: 0.25rem;
|
|
210
450
|
`;
|
|
451
|
+
var StyledStickyCell2 = (0, import_styled_components11.default)(StickyCell)`
|
|
452
|
+
z-index: 5;
|
|
453
|
+
${leftCellShadow}
|
|
454
|
+
`;
|
|
211
455
|
var HeaderCell = ({ header }) => {
|
|
212
|
-
|
|
456
|
+
var _a;
|
|
457
|
+
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
|
|
458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledStickyCell2, {
|
|
459
|
+
colSpan: header.colSpan,
|
|
460
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
461
|
+
header
|
|
462
|
+
})
|
|
463
|
+
}, header.id);
|
|
464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
|
|
213
465
|
colSpan: header.colSpan,
|
|
214
|
-
children:
|
|
215
|
-
|
|
216
|
-
children: [
|
|
217
|
-
(0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
218
|
-
{
|
|
219
|
-
asc: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Icon, {
|
|
220
|
-
data: import_eds_icons3.arrow_down
|
|
221
|
-
}),
|
|
222
|
-
desc: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Icon, {
|
|
223
|
-
data: import_eds_icons3.arrow_up
|
|
224
|
-
})
|
|
225
|
-
}[header.column.getIsSorted()] ?? null
|
|
226
|
-
]
|
|
466
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
467
|
+
header
|
|
227
468
|
})
|
|
228
469
|
}, header.id);
|
|
229
470
|
};
|
|
471
|
+
function HeaderContent({ header }) {
|
|
472
|
+
if (header.isPlaceholder)
|
|
473
|
+
return null;
|
|
474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(HeaderDiv, {
|
|
475
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
476
|
+
children: [
|
|
477
|
+
(0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
478
|
+
{
|
|
479
|
+
asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
480
|
+
data: import_eds_icons4.arrow_drop_down
|
|
481
|
+
}),
|
|
482
|
+
desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
483
|
+
data: import_eds_icons4.arrow_drop_up
|
|
484
|
+
})
|
|
485
|
+
}[header.column.getIsSorted()] ?? null
|
|
486
|
+
]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
230
489
|
|
|
231
490
|
// src/DataTable/components/TableHeader.tsx
|
|
232
|
-
var
|
|
233
|
-
var TableHeader = ({ table, sticky }) => /* @__PURE__ */ (0,
|
|
491
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
492
|
+
var TableHeader = ({ table, sticky }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Head, {
|
|
234
493
|
sticky,
|
|
235
|
-
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0,
|
|
236
|
-
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0,
|
|
494
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
|
|
495
|
+
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HeaderCell, {
|
|
237
496
|
header
|
|
238
497
|
}, header.id))
|
|
239
498
|
}, headerGroup.id))
|
|
240
499
|
});
|
|
241
500
|
|
|
242
501
|
// src/DataTable/components/BasicTable.tsx
|
|
243
|
-
var
|
|
244
|
-
function BasicTable({ table, stickyHeader }) {
|
|
245
|
-
|
|
502
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
503
|
+
function BasicTable({ table, stickyHeader, isLoading }) {
|
|
504
|
+
const tableRows = table.getRowModel().rows;
|
|
505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_eds_core_react10.Table, {
|
|
246
506
|
children: [
|
|
247
|
-
/* @__PURE__ */ (0,
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TableHeader, {
|
|
248
508
|
sticky: stickyHeader,
|
|
249
509
|
table
|
|
250
510
|
}),
|
|
251
|
-
/* @__PURE__ */ (0,
|
|
252
|
-
children:
|
|
253
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
254
|
-
children: (0,
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Body, {
|
|
512
|
+
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
|
|
513
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
|
|
514
|
+
children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
255
515
|
}, cell.id))
|
|
256
|
-
}, row.id))
|
|
516
|
+
}, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PlaceholderRow, {
|
|
517
|
+
isLoading
|
|
518
|
+
})
|
|
257
519
|
})
|
|
258
520
|
]
|
|
259
521
|
});
|
|
260
522
|
}
|
|
261
523
|
|
|
262
524
|
// src/DataTable/components/ColumnSelect.tsx
|
|
263
|
-
var
|
|
264
|
-
var
|
|
525
|
+
var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
526
|
+
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
265
527
|
var import_react2 = require("react");
|
|
266
|
-
var
|
|
528
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
267
529
|
|
|
268
530
|
// src/DataTable/utils.tsx
|
|
269
|
-
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
270
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
271
531
|
function enableOrUndefined(enabled, value) {
|
|
272
532
|
return Boolean(enabled) ? value : void 0;
|
|
273
533
|
}
|
|
@@ -277,41 +537,22 @@ function getColumnHeader(column) {
|
|
|
277
537
|
return column.id;
|
|
278
538
|
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
279
539
|
}
|
|
280
|
-
function
|
|
281
|
-
if (!
|
|
540
|
+
function prependSelectColumn(columns, config) {
|
|
541
|
+
if (!(config == null ? void 0 : config.selectColumn))
|
|
282
542
|
return columns;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
style: { width: "48px" },
|
|
287
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
288
|
-
checked: table.getIsAllRowsSelected(),
|
|
289
|
-
indeterminate: table.getIsSomeRowsSelected(),
|
|
290
|
-
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
291
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
292
|
-
})
|
|
293
|
-
}) : null,
|
|
294
|
-
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
|
|
295
|
-
style: { width: "48px" },
|
|
296
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
297
|
-
checked: row.getIsSelected(),
|
|
298
|
-
indeterminate: row.getIsSomeSelected(),
|
|
299
|
-
"aria-label": `Select row ${row.id}`,
|
|
300
|
-
onChange: row.getToggleSelectedHandler()
|
|
301
|
-
})
|
|
302
|
-
})
|
|
303
|
-
};
|
|
304
|
-
return [selectColumn, ...columns];
|
|
543
|
+
if (config.selectColumn === "default")
|
|
544
|
+
return [SelectColumnDef(config == null ? void 0 : config.rowSelectionMode), ...columns];
|
|
545
|
+
return [config.selectColumn(), ...columns];
|
|
305
546
|
}
|
|
306
547
|
|
|
307
548
|
// src/DataTable/components/ColumnSelect.tsx
|
|
308
|
-
var
|
|
309
|
-
var ColumnSelectContent =
|
|
549
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
550
|
+
var ColumnSelectContent = import_styled_components12.default.div`
|
|
310
551
|
display: grid;
|
|
311
552
|
grid-template-columns: repeat(2, 1fr);
|
|
312
553
|
grid-gap: 0.5rem;
|
|
313
554
|
`;
|
|
314
|
-
var ActionsWrapper =
|
|
555
|
+
var ActionsWrapper = import_styled_components12.default.div`
|
|
315
556
|
display: flex;
|
|
316
557
|
align-items: center;
|
|
317
558
|
justify-content: flex-end;
|
|
@@ -321,9 +562,9 @@ function ColumnSelect({ table }) {
|
|
|
321
562
|
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
322
563
|
const referenceElement = (0, import_react2.useRef)(null);
|
|
323
564
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
324
|
-
return /* @__PURE__ */ (0,
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, {
|
|
325
566
|
children: [
|
|
326
|
-
/* @__PURE__ */ (0,
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
|
|
327
568
|
"aria-haspopup": true,
|
|
328
569
|
id: "column-select-anchor",
|
|
329
570
|
"aria-controls": "column-select-popover",
|
|
@@ -331,51 +572,51 @@ function ColumnSelect({ table }) {
|
|
|
331
572
|
ref: referenceElement,
|
|
332
573
|
variant: "ghost_icon",
|
|
333
574
|
onClick: () => setIsOpen(true),
|
|
334
|
-
children: /* @__PURE__ */ (0,
|
|
575
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Icon, {
|
|
335
576
|
name: "view_column",
|
|
336
|
-
data:
|
|
577
|
+
data: import_eds_icons5.view_column
|
|
337
578
|
})
|
|
338
579
|
}),
|
|
339
|
-
/* @__PURE__ */ (0,
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover, {
|
|
340
581
|
open: isOpen,
|
|
341
582
|
id: "column-select-popover",
|
|
342
583
|
anchorEl: referenceElement.current,
|
|
343
584
|
placement: "bottom-end",
|
|
344
585
|
onClose: () => setIsOpen(false),
|
|
345
586
|
children: [
|
|
346
|
-
/* @__PURE__ */ (0,
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover.Header, {
|
|
347
588
|
children: [
|
|
348
|
-
/* @__PURE__ */ (0,
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Popover.Title, {
|
|
349
590
|
children: "Column settings"
|
|
350
591
|
}),
|
|
351
|
-
/* @__PURE__ */ (0,
|
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
|
|
352
593
|
variant: "ghost_icon",
|
|
353
594
|
"aria-label": "Close column select",
|
|
354
595
|
onClick: () => setIsOpen(false),
|
|
355
|
-
children: /* @__PURE__ */ (0,
|
|
596
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Icon, {
|
|
356
597
|
name: "close",
|
|
357
|
-
data:
|
|
598
|
+
data: import_eds_icons5.close,
|
|
358
599
|
size: 24
|
|
359
600
|
})
|
|
360
601
|
})
|
|
361
602
|
]
|
|
362
603
|
}),
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
604
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover.Content, {
|
|
364
605
|
children: [
|
|
365
|
-
/* @__PURE__ */ (0,
|
|
606
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ColumnSelectContent, {
|
|
366
607
|
children: selectableColumns.map((column) => {
|
|
367
|
-
return /* @__PURE__ */ (0,
|
|
608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
|
|
368
609
|
checked: column.getIsVisible(),
|
|
369
610
|
label: getColumnHeader(column),
|
|
370
611
|
onChange: column.getToggleVisibilityHandler()
|
|
371
612
|
}, column.id);
|
|
372
613
|
})
|
|
373
614
|
}),
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Divider, {
|
|
375
616
|
variant: "small"
|
|
376
617
|
}),
|
|
377
|
-
/* @__PURE__ */ (0,
|
|
378
|
-
children: /* @__PURE__ */ (0,
|
|
618
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionsWrapper, {
|
|
619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
|
|
379
620
|
color: "secondary",
|
|
380
621
|
variant: "ghost",
|
|
381
622
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -392,21 +633,21 @@ function ColumnSelect({ table }) {
|
|
|
392
633
|
}
|
|
393
634
|
|
|
394
635
|
// src/DataTable/components/DataTableHeader.tsx
|
|
395
|
-
var
|
|
396
|
-
var
|
|
636
|
+
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
637
|
+
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
397
638
|
var import_jotai2 = require("jotai");
|
|
398
|
-
var
|
|
639
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
399
640
|
|
|
400
641
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
401
|
-
var
|
|
402
|
-
var
|
|
642
|
+
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
643
|
+
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
403
644
|
var import_react3 = require("react");
|
|
404
|
-
var
|
|
405
|
-
var
|
|
406
|
-
var Wrapper3 =
|
|
645
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
646
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
647
|
+
var Wrapper3 = import_styled_components13.default.div`
|
|
407
648
|
width: 200px;
|
|
408
649
|
`;
|
|
409
|
-
var CloseButton = (0,
|
|
650
|
+
var CloseButton = (0, import_styled_components13.default)(import_eds_core_react12.Button)`
|
|
410
651
|
width: 24px;
|
|
411
652
|
height: 24px;
|
|
412
653
|
`;
|
|
@@ -427,23 +668,23 @@ function DebouncedInput({
|
|
|
427
668
|
}, debounce);
|
|
428
669
|
return () => clearTimeout(timeout);
|
|
429
670
|
}, [value]);
|
|
430
|
-
return /* @__PURE__ */ (0,
|
|
431
|
-
children: /* @__PURE__ */ (0,
|
|
671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Wrapper3, {
|
|
672
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Input, {
|
|
432
673
|
...props,
|
|
433
674
|
value,
|
|
434
|
-
leftAdornments: icon && /* @__PURE__ */ (0,
|
|
675
|
+
leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
|
|
435
676
|
name: icon.name,
|
|
436
677
|
data: icon,
|
|
437
678
|
size: 18
|
|
438
679
|
}),
|
|
439
|
-
rightAdornments: !!value && /* @__PURE__ */ (0,
|
|
680
|
+
rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Tooltip, {
|
|
440
681
|
title: "Clear input",
|
|
441
|
-
children: /* @__PURE__ */ (0,
|
|
682
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseButton, {
|
|
442
683
|
variant: "ghost_icon",
|
|
443
684
|
onClick: () => setValue(""),
|
|
444
|
-
children: /* @__PURE__ */ (0,
|
|
445
|
-
name:
|
|
446
|
-
data:
|
|
685
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
|
|
686
|
+
name: import_eds_icons6.close.name,
|
|
687
|
+
data: import_eds_icons6.close,
|
|
447
688
|
size: 18
|
|
448
689
|
})
|
|
449
690
|
})
|
|
@@ -464,15 +705,15 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
464
705
|
};
|
|
465
706
|
|
|
466
707
|
// src/DataTable/components/DataTableHeader.tsx
|
|
467
|
-
var
|
|
468
|
-
var DataTableHeaderWrapper =
|
|
708
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
709
|
+
var DataTableHeaderWrapper = import_styled_components14.default.div`
|
|
469
710
|
display: flex;
|
|
470
711
|
align-items: center;
|
|
471
712
|
justify-content: space-between;
|
|
472
713
|
gap: 0.5rem;
|
|
473
714
|
padding: ${(props) => props.captionPadding ?? "1rem"};
|
|
474
715
|
`;
|
|
475
|
-
var FilterContainer =
|
|
716
|
+
var FilterContainer = import_styled_components14.default.div`
|
|
476
717
|
display: flex;
|
|
477
718
|
align-items: center;
|
|
478
719
|
gap: 1rem;
|
|
@@ -480,20 +721,20 @@ var FilterContainer = import_styled_components7.default.div`
|
|
|
480
721
|
`;
|
|
481
722
|
var DataTableHeader = (props) => {
|
|
482
723
|
const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
|
|
483
|
-
return /* @__PURE__ */ (0,
|
|
724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DataTableHeaderWrapper, {
|
|
484
725
|
className: "--table-caption",
|
|
485
726
|
captionPadding: props.captionPadding,
|
|
486
727
|
children: [
|
|
487
|
-
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0,
|
|
728
|
+
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Typography, {
|
|
488
729
|
variant: "h3",
|
|
489
730
|
children: props == null ? void 0 : props.tableCaption
|
|
490
731
|
}),
|
|
491
|
-
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0,
|
|
732
|
+
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(FilterContainer, {
|
|
492
733
|
className: "--filter-container",
|
|
493
734
|
children: [
|
|
494
|
-
/* @__PURE__ */ (0,
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DebouncedInput, {
|
|
495
736
|
value: globalFilter,
|
|
496
|
-
icon:
|
|
737
|
+
icon: import_eds_icons7.search,
|
|
497
738
|
placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
|
|
498
739
|
onChange: (value) => setGlobalFilter(String(value))
|
|
499
740
|
}),
|
|
@@ -505,25 +746,25 @@ var DataTableHeader = (props) => {
|
|
|
505
746
|
};
|
|
506
747
|
|
|
507
748
|
// src/DataTable/components/VirtualTable.tsx
|
|
508
|
-
var
|
|
509
|
-
var
|
|
749
|
+
var import_eds_core_react15 = require("@equinor/eds-core-react");
|
|
750
|
+
var import_react_table4 = require("@tanstack/react-table");
|
|
510
751
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
511
752
|
|
|
512
753
|
// src/DataTable/components/PaddingRow.tsx
|
|
513
|
-
var
|
|
514
|
-
var
|
|
754
|
+
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
755
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
515
756
|
var PaddingRow = (props) => {
|
|
516
757
|
if (!props.height)
|
|
517
758
|
return null;
|
|
518
|
-
return /* @__PURE__ */ (0,
|
|
519
|
-
children: /* @__PURE__ */ (0,
|
|
759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Table.Row, {
|
|
760
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Table.Cell, {
|
|
520
761
|
style: { height: `${props.height}px` }
|
|
521
762
|
})
|
|
522
763
|
});
|
|
523
764
|
};
|
|
524
765
|
|
|
525
766
|
// src/DataTable/components/VirtualTable.tsx
|
|
526
|
-
var
|
|
767
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
527
768
|
function VirtualTable({ table, containerRef, ...props }) {
|
|
528
769
|
var _a, _b;
|
|
529
770
|
const { rows } = table.getRowModel();
|
|
@@ -535,27 +776,29 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
535
776
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
536
777
|
const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
|
|
537
778
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
538
|
-
return /* @__PURE__ */ (0,
|
|
779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_eds_core_react15.Table, {
|
|
539
780
|
children: [
|
|
540
|
-
/* @__PURE__ */ (0,
|
|
781
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableHeader, {
|
|
541
782
|
sticky: props.stickyHeader,
|
|
542
783
|
table
|
|
543
784
|
}),
|
|
544
|
-
/* @__PURE__ */ (0,
|
|
785
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_eds_core_react15.Table.Body, {
|
|
545
786
|
children: [
|
|
546
|
-
/* @__PURE__ */ (0,
|
|
787
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaddingRow, {
|
|
547
788
|
height: paddingTop
|
|
548
789
|
}),
|
|
549
|
-
virtualRows.map((virtualRow) => {
|
|
790
|
+
rows.length ? virtualRows.map((virtualRow) => {
|
|
550
791
|
const row = rows[virtualRow.index];
|
|
551
|
-
return /* @__PURE__ */ (0,
|
|
792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Row, {
|
|
552
793
|
active: row.getIsSelected(),
|
|
553
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
554
|
-
children: (0,
|
|
794
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
|
|
795
|
+
children: (0, import_react_table4.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
555
796
|
}, cell.id))
|
|
556
797
|
}, row.id);
|
|
798
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PlaceholderRow, {
|
|
799
|
+
isLoading: props.isLoading
|
|
557
800
|
}),
|
|
558
|
-
/* @__PURE__ */ (0,
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaddingRow, {
|
|
559
802
|
height: paddingBottom
|
|
560
803
|
})
|
|
561
804
|
]
|
|
@@ -565,8 +808,8 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
565
808
|
}
|
|
566
809
|
|
|
567
810
|
// src/DataTable/DataTable.tsx
|
|
568
|
-
var
|
|
569
|
-
var DataTableWrapper =
|
|
811
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
812
|
+
var DataTableWrapper = import_styled_components15.default.div`
|
|
570
813
|
width: ${(props) => props.width ?? "100%"};
|
|
571
814
|
|
|
572
815
|
.--table-container {
|
|
@@ -576,61 +819,89 @@ var DataTableWrapper = import_styled_components8.default.div`
|
|
|
576
819
|
|
|
577
820
|
table {
|
|
578
821
|
width: 100%;
|
|
822
|
+
table-layout: auto;
|
|
579
823
|
}
|
|
580
824
|
}
|
|
581
825
|
`;
|
|
582
|
-
function DataTable({
|
|
826
|
+
function DataTable({
|
|
827
|
+
columns,
|
|
828
|
+
data,
|
|
829
|
+
isLoading,
|
|
830
|
+
header,
|
|
831
|
+
filters,
|
|
832
|
+
config
|
|
833
|
+
}) {
|
|
583
834
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
584
835
|
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
585
836
|
const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
|
|
586
837
|
const [rowSelectionState, setRowSelectionState] = (0, import_jotai3.useAtom)(rowSelectionAtom);
|
|
838
|
+
const [expanded, setExpanded] = (0, import_jotai3.useAtom)(expandedRowsAtom);
|
|
587
839
|
function enableGlobalFilter(value) {
|
|
588
840
|
return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
|
|
589
841
|
}
|
|
590
|
-
const table = (0,
|
|
591
|
-
columns:
|
|
842
|
+
const table = (0, import_react_table5.useReactTable)({
|
|
843
|
+
columns: prependSelectColumn(columns, config),
|
|
592
844
|
data,
|
|
593
|
-
getCoreRowModel: (0, import_react_table4.getCoreRowModel)(),
|
|
594
|
-
getFilteredRowModel: enableGlobalFilter((0, import_react_table4.getFilteredRowModel)()),
|
|
595
845
|
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
596
846
|
state: {
|
|
847
|
+
expanded,
|
|
597
848
|
globalFilter: enableGlobalFilter(globalFilter),
|
|
598
849
|
sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
|
|
599
850
|
rowSelection: rowSelectionState,
|
|
600
851
|
columnVisibility
|
|
601
852
|
},
|
|
602
|
-
|
|
603
|
-
|
|
853
|
+
defaultColumn: {
|
|
854
|
+
cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TypographyCustom, {
|
|
855
|
+
noWrap: true,
|
|
856
|
+
children: cell.getValue()
|
|
857
|
+
})
|
|
858
|
+
},
|
|
604
859
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
860
|
+
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
861
|
+
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
862
|
+
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
863
|
+
getFilteredRowModel: enableGlobalFilter((0, import_react_table5.getFilteredRowModel)()),
|
|
864
|
+
getCoreRowModel: (0, import_react_table5.getCoreRowModel)(),
|
|
865
|
+
getExpandedRowModel: (0, import_react_table5.getExpandedRowModel)(),
|
|
866
|
+
getSortedRowModel: (0, import_react_table5.getSortedRowModel)(),
|
|
867
|
+
onExpandedChange: setExpanded,
|
|
868
|
+
onRowSelectionChange: setRowSelectionState,
|
|
605
869
|
onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
|
|
606
|
-
getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
|
|
607
870
|
onColumnVisibilityChange: setColumnVisibility,
|
|
608
|
-
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
|
|
871
|
+
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
|
|
872
|
+
getSubRows: config == null ? void 0 : config.getSubRows
|
|
609
873
|
});
|
|
874
|
+
(0, import_react4.useEffect)(() => {
|
|
875
|
+
if (config && config.expandAllByDefault) {
|
|
876
|
+
table.toggleAllRowsExpanded();
|
|
877
|
+
}
|
|
878
|
+
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
610
879
|
const tableContainerRef = (0, import_react4.useRef)(null);
|
|
611
|
-
return /* @__PURE__ */ (0,
|
|
880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DataTableWrapper, {
|
|
612
881
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
613
882
|
height: config == null ? void 0 : config.height,
|
|
614
883
|
width: config == null ? void 0 : config.width,
|
|
615
884
|
children: [
|
|
616
|
-
/* @__PURE__ */ (0,
|
|
885
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DataTableHeader, {
|
|
617
886
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
618
887
|
enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
|
|
619
888
|
globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
|
|
620
889
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
621
|
-
filterActions: /* @__PURE__ */ (0,
|
|
890
|
+
filterActions: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ColumnSelect, {
|
|
622
891
|
table
|
|
623
892
|
})
|
|
624
893
|
}),
|
|
625
|
-
/* @__PURE__ */ (0,
|
|
894
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
|
|
626
895
|
ref: tableContainerRef,
|
|
627
896
|
className: "--table-container",
|
|
628
|
-
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0,
|
|
897
|
+
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VirtualTable, {
|
|
629
898
|
containerRef: tableContainerRef,
|
|
630
899
|
table,
|
|
900
|
+
isLoading,
|
|
631
901
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
632
|
-
}) : /* @__PURE__ */ (0,
|
|
902
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BasicTable, {
|
|
633
903
|
table,
|
|
904
|
+
isLoading,
|
|
634
905
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
635
906
|
})
|
|
636
907
|
})
|
|
@@ -640,9 +911,9 @@ function DataTable({ columns, data, header, filters, config }) {
|
|
|
640
911
|
|
|
641
912
|
// src/DataTable/Provider.tsx
|
|
642
913
|
var import_jotai4 = require("jotai");
|
|
643
|
-
var
|
|
914
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
644
915
|
function DataTableProvider({ children, ...props }) {
|
|
645
|
-
return /* @__PURE__ */ (0,
|
|
916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jotai4.Provider, {
|
|
646
917
|
...props,
|
|
647
918
|
children
|
|
648
919
|
});
|
|
@@ -657,7 +928,13 @@ DataTable2.Provider = DataTableProvider;
|
|
|
657
928
|
AppSidebar,
|
|
658
929
|
ChipsCell,
|
|
659
930
|
DataTable,
|
|
931
|
+
DynamicCell,
|
|
932
|
+
HierarchyCell,
|
|
933
|
+
SelectColumnDef,
|
|
934
|
+
StickyCell,
|
|
935
|
+
TypographyCustom,
|
|
660
936
|
globalFilterAtom,
|
|
937
|
+
prependSelectColumn,
|
|
661
938
|
rowSelectionAtom,
|
|
662
939
|
tableSortingAtom
|
|
663
940
|
});
|