@equinor/apollo-components 1.2.1 → 1.3.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 +1 -1
- package/dist/index.js +86 -77
- package/dist/index.mjs +74 -65
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -260,11 +260,52 @@ function BasicTable({ table, stickyHeader }) {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
// src/DataTable/components/ColumnSelect.tsx
|
|
263
|
-
var
|
|
263
|
+
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
264
264
|
var import_eds_icons4 = require("@equinor/eds-icons");
|
|
265
265
|
var import_react2 = require("react");
|
|
266
266
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
267
|
+
|
|
268
|
+
// src/DataTable/utils.tsx
|
|
269
|
+
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
267
270
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
271
|
+
function enableOrUndefined(enabled, value) {
|
|
272
|
+
return Boolean(enabled) ? value : void 0;
|
|
273
|
+
}
|
|
274
|
+
function getColumnHeader(column) {
|
|
275
|
+
const columnHeader = column.columnDef.header;
|
|
276
|
+
if (!columnHeader)
|
|
277
|
+
return column.id;
|
|
278
|
+
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
279
|
+
}
|
|
280
|
+
function prependSelectColumnIfEnabled(columns, config) {
|
|
281
|
+
if (!Boolean(config == null ? void 0 : config.rowSelection))
|
|
282
|
+
return columns;
|
|
283
|
+
const selectColumn = {
|
|
284
|
+
id: "select",
|
|
285
|
+
header: ({ table }) => (config == null ? void 0 : config.rowSelection) === "multiple" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
|
|
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];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
308
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
268
309
|
var ColumnSelectContent = import_styled_components5.default.div`
|
|
269
310
|
display: grid;
|
|
270
311
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -280,9 +321,9 @@ function ColumnSelect({ table }) {
|
|
|
280
321
|
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
281
322
|
const referenceElement = (0, import_react2.useRef)(null);
|
|
282
323
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
283
|
-
return /* @__PURE__ */ (0,
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, {
|
|
284
325
|
children: [
|
|
285
|
-
/* @__PURE__ */ (0,
|
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
286
327
|
"aria-haspopup": true,
|
|
287
328
|
id: "column-select-anchor",
|
|
288
329
|
"aria-controls": "column-select-popover",
|
|
@@ -290,28 +331,28 @@ function ColumnSelect({ table }) {
|
|
|
290
331
|
ref: referenceElement,
|
|
291
332
|
variant: "ghost_icon",
|
|
292
333
|
onClick: () => setIsOpen(true),
|
|
293
|
-
children: /* @__PURE__ */ (0,
|
|
334
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
|
|
294
335
|
name: "view_column",
|
|
295
336
|
data: import_eds_icons4.view_column
|
|
296
337
|
})
|
|
297
338
|
}),
|
|
298
|
-
/* @__PURE__ */ (0,
|
|
339
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover, {
|
|
299
340
|
open: isOpen,
|
|
300
341
|
id: "column-select-popover",
|
|
301
342
|
anchorEl: referenceElement.current,
|
|
302
343
|
placement: "bottom-end",
|
|
303
344
|
onClose: () => setIsOpen(false),
|
|
304
345
|
children: [
|
|
305
|
-
/* @__PURE__ */ (0,
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Header, {
|
|
306
347
|
children: [
|
|
307
|
-
/* @__PURE__ */ (0,
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Popover.Title, {
|
|
308
349
|
children: "Column settings"
|
|
309
350
|
}),
|
|
310
|
-
/* @__PURE__ */ (0,
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
311
352
|
variant: "ghost_icon",
|
|
312
353
|
"aria-label": "Close column select",
|
|
313
354
|
onClick: () => setIsOpen(false),
|
|
314
|
-
children: /* @__PURE__ */ (0,
|
|
355
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
|
|
315
356
|
name: "close",
|
|
316
357
|
data: import_eds_icons4.close,
|
|
317
358
|
size: 24
|
|
@@ -319,22 +360,22 @@ function ColumnSelect({ table }) {
|
|
|
319
360
|
})
|
|
320
361
|
]
|
|
321
362
|
}),
|
|
322
|
-
/* @__PURE__ */ (0,
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Content, {
|
|
323
364
|
children: [
|
|
324
|
-
/* @__PURE__ */ (0,
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ColumnSelectContent, {
|
|
325
366
|
children: selectableColumns.map((column) => {
|
|
326
|
-
return /* @__PURE__ */ (0,
|
|
367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Checkbox, {
|
|
327
368
|
checked: column.getIsVisible(),
|
|
328
|
-
label: column
|
|
369
|
+
label: getColumnHeader(column),
|
|
329
370
|
onChange: column.getToggleVisibilityHandler()
|
|
330
371
|
}, column.id);
|
|
331
372
|
})
|
|
332
373
|
}),
|
|
333
|
-
/* @__PURE__ */ (0,
|
|
374
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Divider, {
|
|
334
375
|
variant: "small"
|
|
335
376
|
}),
|
|
336
|
-
/* @__PURE__ */ (0,
|
|
337
|
-
children: /* @__PURE__ */ (0,
|
|
377
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ActionsWrapper, {
|
|
378
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
338
379
|
color: "secondary",
|
|
339
380
|
variant: "ghost",
|
|
340
381
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -351,21 +392,21 @@ function ColumnSelect({ table }) {
|
|
|
351
392
|
}
|
|
352
393
|
|
|
353
394
|
// src/DataTable/components/DataTableHeader.tsx
|
|
354
|
-
var
|
|
395
|
+
var import_eds_core_react9 = require("@equinor/eds-core-react");
|
|
355
396
|
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
356
397
|
var import_jotai2 = require("jotai");
|
|
357
398
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
358
399
|
|
|
359
400
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
360
|
-
var
|
|
401
|
+
var import_eds_core_react8 = require("@equinor/eds-core-react");
|
|
361
402
|
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
362
403
|
var import_react3 = require("react");
|
|
363
404
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
364
|
-
var
|
|
405
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
365
406
|
var Wrapper3 = import_styled_components6.default.div`
|
|
366
407
|
width: 200px;
|
|
367
408
|
`;
|
|
368
|
-
var CloseButton = (0, import_styled_components6.default)(
|
|
409
|
+
var CloseButton = (0, import_styled_components6.default)(import_eds_core_react8.Button)`
|
|
369
410
|
width: 24px;
|
|
370
411
|
height: 24px;
|
|
371
412
|
`;
|
|
@@ -386,21 +427,21 @@ function DebouncedInput({
|
|
|
386
427
|
}, debounce);
|
|
387
428
|
return () => clearTimeout(timeout);
|
|
388
429
|
}, [value]);
|
|
389
|
-
return /* @__PURE__ */ (0,
|
|
390
|
-
children: /* @__PURE__ */ (0,
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Wrapper3, {
|
|
431
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Input, {
|
|
391
432
|
...props,
|
|
392
433
|
value,
|
|
393
|
-
leftAdornments: icon && /* @__PURE__ */ (0,
|
|
434
|
+
leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
394
435
|
name: icon.name,
|
|
395
436
|
data: icon,
|
|
396
437
|
size: 18
|
|
397
438
|
}),
|
|
398
|
-
rightAdornments: !!value && /* @__PURE__ */ (0,
|
|
439
|
+
rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Tooltip, {
|
|
399
440
|
title: "Clear input",
|
|
400
|
-
children: /* @__PURE__ */ (0,
|
|
441
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, {
|
|
401
442
|
variant: "ghost_icon",
|
|
402
443
|
onClick: () => setValue(""),
|
|
403
|
-
children: /* @__PURE__ */ (0,
|
|
444
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
404
445
|
name: import_eds_icons5.close.name,
|
|
405
446
|
data: import_eds_icons5.close,
|
|
406
447
|
size: 18
|
|
@@ -423,7 +464,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
423
464
|
};
|
|
424
465
|
|
|
425
466
|
// src/DataTable/components/DataTableHeader.tsx
|
|
426
|
-
var
|
|
467
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
427
468
|
var DataTableHeaderWrapper = import_styled_components7.default.div`
|
|
428
469
|
display: flex;
|
|
429
470
|
align-items: center;
|
|
@@ -439,18 +480,18 @@ var FilterContainer = import_styled_components7.default.div`
|
|
|
439
480
|
`;
|
|
440
481
|
var DataTableHeader = (props) => {
|
|
441
482
|
const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
|
|
442
|
-
return /* @__PURE__ */ (0,
|
|
483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(DataTableHeaderWrapper, {
|
|
443
484
|
className: "--table-caption",
|
|
444
485
|
captionPadding: props.captionPadding,
|
|
445
486
|
children: [
|
|
446
|
-
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0,
|
|
487
|
+
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Typography, {
|
|
447
488
|
variant: "h3",
|
|
448
489
|
children: props == null ? void 0 : props.tableCaption
|
|
449
490
|
}),
|
|
450
|
-
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0,
|
|
491
|
+
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(FilterContainer, {
|
|
451
492
|
className: "--filter-container",
|
|
452
493
|
children: [
|
|
453
|
-
/* @__PURE__ */ (0,
|
|
494
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DebouncedInput, {
|
|
454
495
|
value: globalFilter,
|
|
455
496
|
icon: import_eds_icons6.search,
|
|
456
497
|
placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
|
|
@@ -464,25 +505,25 @@ var DataTableHeader = (props) => {
|
|
|
464
505
|
};
|
|
465
506
|
|
|
466
507
|
// src/DataTable/components/VirtualTable.tsx
|
|
467
|
-
var
|
|
508
|
+
var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
468
509
|
var import_react_table3 = require("@tanstack/react-table");
|
|
469
510
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
470
511
|
|
|
471
512
|
// src/DataTable/components/PaddingRow.tsx
|
|
472
|
-
var
|
|
473
|
-
var
|
|
513
|
+
var import_eds_core_react10 = require("@equinor/eds-core-react");
|
|
514
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
474
515
|
var PaddingRow = (props) => {
|
|
475
516
|
if (!props.height)
|
|
476
517
|
return null;
|
|
477
|
-
return /* @__PURE__ */ (0,
|
|
478
|
-
children: /* @__PURE__ */ (0,
|
|
518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
|
|
519
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
|
|
479
520
|
style: { height: `${props.height}px` }
|
|
480
521
|
})
|
|
481
522
|
});
|
|
482
523
|
};
|
|
483
524
|
|
|
484
525
|
// src/DataTable/components/VirtualTable.tsx
|
|
485
|
-
var
|
|
526
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
486
527
|
function VirtualTable({ table, containerRef, ...props }) {
|
|
487
528
|
var _a, _b;
|
|
488
529
|
const { rows } = table.getRowModel();
|
|
@@ -494,27 +535,27 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
494
535
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
495
536
|
const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
|
|
496
537
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
497
|
-
return /* @__PURE__ */ (0,
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table, {
|
|
498
539
|
children: [
|
|
499
|
-
/* @__PURE__ */ (0,
|
|
540
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHeader, {
|
|
500
541
|
sticky: props.stickyHeader,
|
|
501
542
|
table
|
|
502
543
|
}),
|
|
503
|
-
/* @__PURE__ */ (0,
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table.Body, {
|
|
504
545
|
children: [
|
|
505
|
-
/* @__PURE__ */ (0,
|
|
546
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaddingRow, {
|
|
506
547
|
height: paddingTop
|
|
507
548
|
}),
|
|
508
549
|
virtualRows.map((virtualRow) => {
|
|
509
550
|
const row = rows[virtualRow.index];
|
|
510
|
-
return /* @__PURE__ */ (0,
|
|
551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Row, {
|
|
511
552
|
active: row.getIsSelected(),
|
|
512
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
553
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Cell, {
|
|
513
554
|
children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
514
555
|
}, cell.id))
|
|
515
556
|
}, row.id);
|
|
516
557
|
}),
|
|
517
|
-
/* @__PURE__ */ (0,
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaddingRow, {
|
|
518
559
|
height: paddingBottom
|
|
519
560
|
})
|
|
520
561
|
]
|
|
@@ -523,39 +564,6 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
523
564
|
});
|
|
524
565
|
}
|
|
525
566
|
|
|
526
|
-
// src/DataTable/utils.tsx
|
|
527
|
-
var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
528
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
529
|
-
function enableOrUndefined(enabled, value) {
|
|
530
|
-
return Boolean(enabled) ? value : void 0;
|
|
531
|
-
}
|
|
532
|
-
function prependSelectColumnIfEnabled(columns, config) {
|
|
533
|
-
if (!(config == null ? void 0 : config.enableRowSelection))
|
|
534
|
-
return columns;
|
|
535
|
-
const selectColumn = {
|
|
536
|
-
id: "select",
|
|
537
|
-
header: ({ table }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {
|
|
538
|
-
style: { width: "48px" },
|
|
539
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
|
|
540
|
-
checked: table.getIsAllRowsSelected(),
|
|
541
|
-
indeterminate: table.getIsSomeRowsSelected(),
|
|
542
|
-
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
543
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
544
|
-
})
|
|
545
|
-
}),
|
|
546
|
-
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {
|
|
547
|
-
style: { width: "48px" },
|
|
548
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
|
|
549
|
-
checked: row.getIsSelected(),
|
|
550
|
-
indeterminate: row.getIsSomeSelected(),
|
|
551
|
-
"aria-label": `Select row ${row.id}`,
|
|
552
|
-
onChange: row.getToggleSelectedHandler()
|
|
553
|
-
})
|
|
554
|
-
})
|
|
555
|
-
};
|
|
556
|
-
return [selectColumn, ...columns];
|
|
557
|
-
}
|
|
558
|
-
|
|
559
567
|
// src/DataTable/DataTable.tsx
|
|
560
568
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
561
569
|
var DataTableWrapper = import_styled_components8.default.div`
|
|
@@ -592,6 +600,7 @@ function DataTable({ columns, data, header, filters, config }) {
|
|
|
592
600
|
columnVisibility
|
|
593
601
|
},
|
|
594
602
|
onRowSelectionChange: setRowSelectionState,
|
|
603
|
+
enableMultiRowSelection: (config == null ? void 0 : config.rowSelection) === "multiple",
|
|
595
604
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
596
605
|
onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
|
|
597
606
|
getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
|
package/dist/index.mjs
CHANGED
|
@@ -227,11 +227,52 @@ function BasicTable({ table, stickyHeader }) {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// src/DataTable/components/ColumnSelect.tsx
|
|
230
|
-
import { Button as Button2, Checkbox, Divider, Icon as Icon4, Popover } from "@equinor/eds-core-react";
|
|
230
|
+
import { Button as Button2, Checkbox as Checkbox2, Divider, Icon as Icon4, Popover } from "@equinor/eds-core-react";
|
|
231
231
|
import { close, view_column } from "@equinor/eds-icons";
|
|
232
232
|
import { useRef, useState as useState2 } from "react";
|
|
233
233
|
import styled5 from "styled-components";
|
|
234
|
-
|
|
234
|
+
|
|
235
|
+
// src/DataTable/utils.tsx
|
|
236
|
+
import { Checkbox } from "@equinor/eds-core-react";
|
|
237
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
238
|
+
function enableOrUndefined(enabled, value) {
|
|
239
|
+
return Boolean(enabled) ? value : void 0;
|
|
240
|
+
}
|
|
241
|
+
function getColumnHeader(column) {
|
|
242
|
+
const columnHeader = column.columnDef.header;
|
|
243
|
+
if (!columnHeader)
|
|
244
|
+
return column.id;
|
|
245
|
+
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
246
|
+
}
|
|
247
|
+
function prependSelectColumnIfEnabled(columns, config) {
|
|
248
|
+
if (!Boolean(config == null ? void 0 : config.rowSelection))
|
|
249
|
+
return columns;
|
|
250
|
+
const selectColumn = {
|
|
251
|
+
id: "select",
|
|
252
|
+
header: ({ table }) => (config == null ? void 0 : config.rowSelection) === "multiple" ? /* @__PURE__ */ jsx7("div", {
|
|
253
|
+
style: { width: "48px" },
|
|
254
|
+
children: /* @__PURE__ */ jsx7(Checkbox, {
|
|
255
|
+
checked: table.getIsAllRowsSelected(),
|
|
256
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
257
|
+
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
258
|
+
onChange: table.getToggleAllRowsSelectedHandler()
|
|
259
|
+
})
|
|
260
|
+
}) : null,
|
|
261
|
+
cell: ({ row }) => /* @__PURE__ */ jsx7("div", {
|
|
262
|
+
style: { width: "48px" },
|
|
263
|
+
children: /* @__PURE__ */ jsx7(Checkbox, {
|
|
264
|
+
checked: row.getIsSelected(),
|
|
265
|
+
indeterminate: row.getIsSomeSelected(),
|
|
266
|
+
"aria-label": `Select row ${row.id}`,
|
|
267
|
+
onChange: row.getToggleSelectedHandler()
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
};
|
|
271
|
+
return [selectColumn, ...columns];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
275
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
235
276
|
var ColumnSelectContent = styled5.div`
|
|
236
277
|
display: grid;
|
|
237
278
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -249,7 +290,7 @@ function ColumnSelect({ table }) {
|
|
|
249
290
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
250
291
|
return /* @__PURE__ */ jsxs5(Fragment, {
|
|
251
292
|
children: [
|
|
252
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ jsx8(Button2, {
|
|
253
294
|
"aria-haspopup": true,
|
|
254
295
|
id: "column-select-anchor",
|
|
255
296
|
"aria-controls": "column-select-popover",
|
|
@@ -257,7 +298,7 @@ function ColumnSelect({ table }) {
|
|
|
257
298
|
ref: referenceElement,
|
|
258
299
|
variant: "ghost_icon",
|
|
259
300
|
onClick: () => setIsOpen(true),
|
|
260
|
-
children: /* @__PURE__ */
|
|
301
|
+
children: /* @__PURE__ */ jsx8(Icon4, {
|
|
261
302
|
name: "view_column",
|
|
262
303
|
data: view_column
|
|
263
304
|
})
|
|
@@ -271,14 +312,14 @@ function ColumnSelect({ table }) {
|
|
|
271
312
|
children: [
|
|
272
313
|
/* @__PURE__ */ jsxs5(Popover.Header, {
|
|
273
314
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ jsx8(Popover.Title, {
|
|
275
316
|
children: "Column settings"
|
|
276
317
|
}),
|
|
277
|
-
/* @__PURE__ */
|
|
318
|
+
/* @__PURE__ */ jsx8(Button2, {
|
|
278
319
|
variant: "ghost_icon",
|
|
279
320
|
"aria-label": "Close column select",
|
|
280
321
|
onClick: () => setIsOpen(false),
|
|
281
|
-
children: /* @__PURE__ */
|
|
322
|
+
children: /* @__PURE__ */ jsx8(Icon4, {
|
|
282
323
|
name: "close",
|
|
283
324
|
data: close,
|
|
284
325
|
size: 24
|
|
@@ -288,20 +329,20 @@ function ColumnSelect({ table }) {
|
|
|
288
329
|
}),
|
|
289
330
|
/* @__PURE__ */ jsxs5(Popover.Content, {
|
|
290
331
|
children: [
|
|
291
|
-
/* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ jsx8(ColumnSelectContent, {
|
|
292
333
|
children: selectableColumns.map((column) => {
|
|
293
|
-
return /* @__PURE__ */
|
|
334
|
+
return /* @__PURE__ */ jsx8(Checkbox2, {
|
|
294
335
|
checked: column.getIsVisible(),
|
|
295
|
-
label: column
|
|
336
|
+
label: getColumnHeader(column),
|
|
296
337
|
onChange: column.getToggleVisibilityHandler()
|
|
297
338
|
}, column.id);
|
|
298
339
|
})
|
|
299
340
|
}),
|
|
300
|
-
/* @__PURE__ */
|
|
341
|
+
/* @__PURE__ */ jsx8(Divider, {
|
|
301
342
|
variant: "small"
|
|
302
343
|
}),
|
|
303
|
-
/* @__PURE__ */
|
|
304
|
-
children: /* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ jsx8(ActionsWrapper, {
|
|
345
|
+
children: /* @__PURE__ */ jsx8(Button2, {
|
|
305
346
|
color: "secondary",
|
|
306
347
|
variant: "ghost",
|
|
307
348
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -328,7 +369,7 @@ import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-c
|
|
|
328
369
|
import { close as close2 } from "@equinor/eds-icons";
|
|
329
370
|
import { useEffect, useState as useState3 } from "react";
|
|
330
371
|
import styled6 from "styled-components";
|
|
331
|
-
import { jsx as
|
|
372
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
332
373
|
var Wrapper3 = styled6.div`
|
|
333
374
|
width: 200px;
|
|
334
375
|
`;
|
|
@@ -353,21 +394,21 @@ function DebouncedInput({
|
|
|
353
394
|
}, debounce);
|
|
354
395
|
return () => clearTimeout(timeout);
|
|
355
396
|
}, [value]);
|
|
356
|
-
return /* @__PURE__ */
|
|
357
|
-
children: /* @__PURE__ */
|
|
397
|
+
return /* @__PURE__ */ jsx9(Wrapper3, {
|
|
398
|
+
children: /* @__PURE__ */ jsx9(Input, {
|
|
358
399
|
...props,
|
|
359
400
|
value,
|
|
360
|
-
leftAdornments: icon && /* @__PURE__ */
|
|
401
|
+
leftAdornments: icon && /* @__PURE__ */ jsx9(Icon5, {
|
|
361
402
|
name: icon.name,
|
|
362
403
|
data: icon,
|
|
363
404
|
size: 18
|
|
364
405
|
}),
|
|
365
|
-
rightAdornments: !!value && /* @__PURE__ */
|
|
406
|
+
rightAdornments: !!value && /* @__PURE__ */ jsx9(Tooltip, {
|
|
366
407
|
title: "Clear input",
|
|
367
|
-
children: /* @__PURE__ */
|
|
408
|
+
children: /* @__PURE__ */ jsx9(CloseButton, {
|
|
368
409
|
variant: "ghost_icon",
|
|
369
410
|
onClick: () => setValue(""),
|
|
370
|
-
children: /* @__PURE__ */
|
|
411
|
+
children: /* @__PURE__ */ jsx9(Icon5, {
|
|
371
412
|
name: close2.name,
|
|
372
413
|
data: close2,
|
|
373
414
|
size: 18
|
|
@@ -390,7 +431,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
390
431
|
};
|
|
391
432
|
|
|
392
433
|
// src/DataTable/components/DataTableHeader.tsx
|
|
393
|
-
import { jsx as
|
|
434
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
394
435
|
var DataTableHeaderWrapper = styled7.div`
|
|
395
436
|
display: flex;
|
|
396
437
|
align-items: center;
|
|
@@ -410,14 +451,14 @@ var DataTableHeader = (props) => {
|
|
|
410
451
|
className: "--table-caption",
|
|
411
452
|
captionPadding: props.captionPadding,
|
|
412
453
|
children: [
|
|
413
|
-
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */
|
|
454
|
+
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx10(Typography, {
|
|
414
455
|
variant: "h3",
|
|
415
456
|
children: props == null ? void 0 : props.tableCaption
|
|
416
457
|
}),
|
|
417
458
|
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs6(FilterContainer, {
|
|
418
459
|
className: "--filter-container",
|
|
419
460
|
children: [
|
|
420
|
-
/* @__PURE__ */
|
|
461
|
+
/* @__PURE__ */ jsx10(DebouncedInput, {
|
|
421
462
|
value: globalFilter,
|
|
422
463
|
icon: search,
|
|
423
464
|
placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
|
|
@@ -437,19 +478,19 @@ import { useVirtualizer } from "@tanstack/react-virtual";
|
|
|
437
478
|
|
|
438
479
|
// src/DataTable/components/PaddingRow.tsx
|
|
439
480
|
import { Table as Table4 } from "@equinor/eds-core-react";
|
|
440
|
-
import { jsx as
|
|
481
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
441
482
|
var PaddingRow = (props) => {
|
|
442
483
|
if (!props.height)
|
|
443
484
|
return null;
|
|
444
|
-
return /* @__PURE__ */
|
|
445
|
-
children: /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ jsx11(Table4.Row, {
|
|
486
|
+
children: /* @__PURE__ */ jsx11(Table4.Cell, {
|
|
446
487
|
style: { height: `${props.height}px` }
|
|
447
488
|
})
|
|
448
489
|
});
|
|
449
490
|
};
|
|
450
491
|
|
|
451
492
|
// src/DataTable/components/VirtualTable.tsx
|
|
452
|
-
import { jsx as
|
|
493
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
453
494
|
function VirtualTable({ table, containerRef, ...props }) {
|
|
454
495
|
var _a, _b;
|
|
455
496
|
const { rows } = table.getRowModel();
|
|
@@ -463,25 +504,25 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
463
504
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
464
505
|
return /* @__PURE__ */ jsxs7(Table5, {
|
|
465
506
|
children: [
|
|
466
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ jsx12(TableHeader, {
|
|
467
508
|
sticky: props.stickyHeader,
|
|
468
509
|
table
|
|
469
510
|
}),
|
|
470
511
|
/* @__PURE__ */ jsxs7(Table5.Body, {
|
|
471
512
|
children: [
|
|
472
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ jsx12(PaddingRow, {
|
|
473
514
|
height: paddingTop
|
|
474
515
|
}),
|
|
475
516
|
virtualRows.map((virtualRow) => {
|
|
476
517
|
const row = rows[virtualRow.index];
|
|
477
|
-
return /* @__PURE__ */
|
|
518
|
+
return /* @__PURE__ */ jsx12(Table5.Row, {
|
|
478
519
|
active: row.getIsSelected(),
|
|
479
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */
|
|
520
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx12(Table5.Cell, {
|
|
480
521
|
children: flexRender3(cell.column.columnDef.cell, cell.getContext())
|
|
481
522
|
}, cell.id))
|
|
482
523
|
}, row.id);
|
|
483
524
|
}),
|
|
484
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ jsx12(PaddingRow, {
|
|
485
526
|
height: paddingBottom
|
|
486
527
|
})
|
|
487
528
|
]
|
|
@@ -490,39 +531,6 @@ function VirtualTable({ table, containerRef, ...props }) {
|
|
|
490
531
|
});
|
|
491
532
|
}
|
|
492
533
|
|
|
493
|
-
// src/DataTable/utils.tsx
|
|
494
|
-
import { Checkbox as Checkbox2 } from "@equinor/eds-core-react";
|
|
495
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
496
|
-
function enableOrUndefined(enabled, value) {
|
|
497
|
-
return Boolean(enabled) ? value : void 0;
|
|
498
|
-
}
|
|
499
|
-
function prependSelectColumnIfEnabled(columns, config) {
|
|
500
|
-
if (!(config == null ? void 0 : config.enableRowSelection))
|
|
501
|
-
return columns;
|
|
502
|
-
const selectColumn = {
|
|
503
|
-
id: "select",
|
|
504
|
-
header: ({ table }) => /* @__PURE__ */ jsx12("div", {
|
|
505
|
-
style: { width: "48px" },
|
|
506
|
-
children: /* @__PURE__ */ jsx12(Checkbox2, {
|
|
507
|
-
checked: table.getIsAllRowsSelected(),
|
|
508
|
-
indeterminate: table.getIsSomeRowsSelected(),
|
|
509
|
-
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
510
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
511
|
-
})
|
|
512
|
-
}),
|
|
513
|
-
cell: ({ row }) => /* @__PURE__ */ jsx12("div", {
|
|
514
|
-
style: { width: "48px" },
|
|
515
|
-
children: /* @__PURE__ */ jsx12(Checkbox2, {
|
|
516
|
-
checked: row.getIsSelected(),
|
|
517
|
-
indeterminate: row.getIsSomeSelected(),
|
|
518
|
-
"aria-label": `Select row ${row.id}`,
|
|
519
|
-
onChange: row.getToggleSelectedHandler()
|
|
520
|
-
})
|
|
521
|
-
})
|
|
522
|
-
};
|
|
523
|
-
return [selectColumn, ...columns];
|
|
524
|
-
}
|
|
525
|
-
|
|
526
534
|
// src/DataTable/DataTable.tsx
|
|
527
535
|
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
528
536
|
var DataTableWrapper = styled8.div`
|
|
@@ -559,6 +567,7 @@ function DataTable({ columns, data, header, filters, config }) {
|
|
|
559
567
|
columnVisibility
|
|
560
568
|
},
|
|
561
569
|
onRowSelectionChange: setRowSelectionState,
|
|
570
|
+
enableMultiRowSelection: (config == null ? void 0 : config.rowSelection) === "multiple",
|
|
562
571
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
563
572
|
onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
|
|
564
573
|
getSortedRowModel: getSortedRowModel(),
|