@equinor/apollo-components 1.12.3 → 3.0.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 +70 -86
- package/dist/index.js +342 -337
- package/dist/index.mjs +344 -335
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ __export(src_exports, {
|
|
|
30
30
|
AppSidebar: () => AppSidebar,
|
|
31
31
|
ChipsCell: () => ChipsCell,
|
|
32
32
|
ColumnSelect: () => ColumnSelect,
|
|
33
|
-
DataTable: () =>
|
|
33
|
+
DataTable: () => DataTable,
|
|
34
34
|
DynamicCell: () => DynamicCell,
|
|
35
35
|
HierarchyCell: () => HierarchyCell,
|
|
36
36
|
SelectColumnDef: () => SelectColumnDef,
|
|
@@ -38,11 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
TableHeader: () => TableHeader,
|
|
39
39
|
TypographyCustom: () => TypographyCustom,
|
|
40
40
|
capitalizeHeader: () => capitalizeHeader,
|
|
41
|
-
|
|
42
|
-
globalFilterAtom: () => globalFilterAtom,
|
|
43
|
-
prependSelectColumn: () => prependSelectColumn,
|
|
44
|
-
rowSelectionAtom: () => rowSelectionAtom,
|
|
45
|
-
tableSortingAtom: () => tableSortingAtom
|
|
41
|
+
prependSelectColumn: () => prependSelectColumn
|
|
46
42
|
});
|
|
47
43
|
module.exports = __toCommonJS(src_exports);
|
|
48
44
|
|
|
@@ -356,12 +352,11 @@ var CellWrapper2 = import_styled_components8.default.div`
|
|
|
356
352
|
margin-left: -16px;
|
|
357
353
|
z-index: 2;
|
|
358
354
|
`;
|
|
359
|
-
function SelectColumnDef(props
|
|
360
|
-
const selectionMode = props.
|
|
361
|
-
const showBothSelectAndSubRowsToggle = props.hideExpandControls === false;
|
|
355
|
+
function SelectColumnDef(props) {
|
|
356
|
+
const selectionMode = props.mode;
|
|
362
357
|
return {
|
|
363
358
|
id: "select",
|
|
364
|
-
size:
|
|
359
|
+
size: props.includeExpansionButton ? 96 : 48,
|
|
365
360
|
header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellWrapper2, {
|
|
366
361
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
367
362
|
checked: table.getIsAllRowsSelected(),
|
|
@@ -404,55 +399,142 @@ function SelectColumnDef(props = {}) {
|
|
|
404
399
|
};
|
|
405
400
|
}
|
|
406
401
|
|
|
407
|
-
// src/DataTable/
|
|
408
|
-
var import_react5 = require("react");
|
|
409
|
-
var import_styled_components16 = __toESM(require("styled-components"));
|
|
410
|
-
|
|
411
|
-
// src/DataTable/components/BasicTable.tsx
|
|
412
|
-
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
413
|
-
|
|
414
|
-
// src/DataTable/components/PlaceholderRow.tsx
|
|
402
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
415
403
|
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
404
|
+
var import_eds_icons4 = require("@equinor/eds-icons");
|
|
405
|
+
var import_react2 = require("react");
|
|
416
406
|
var import_styled_components9 = __toESM(require("styled-components"));
|
|
407
|
+
|
|
408
|
+
// src/DataTable/utils.tsx
|
|
409
|
+
function capitalizeHeader(context) {
|
|
410
|
+
const header = context.header.id;
|
|
411
|
+
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
412
|
+
}
|
|
413
|
+
function enableOrUndefined(enabled, value) {
|
|
414
|
+
return Boolean(enabled) ? value : void 0;
|
|
415
|
+
}
|
|
416
|
+
function getColumnHeader(column) {
|
|
417
|
+
const columnHeader = column.columnDef.header;
|
|
418
|
+
if (!columnHeader)
|
|
419
|
+
return column.id;
|
|
420
|
+
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
421
|
+
}
|
|
422
|
+
function prependSelectColumn(columns, config) {
|
|
423
|
+
if (!(config == null ? void 0 : config.selectColumn))
|
|
424
|
+
return columns;
|
|
425
|
+
if (config.selectColumn === "default")
|
|
426
|
+
return [SelectColumnDef(config), ...columns];
|
|
427
|
+
return [config.selectColumn(), ...columns];
|
|
428
|
+
}
|
|
429
|
+
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
430
|
+
if (valueOrFn === void 0)
|
|
431
|
+
return defaultValue;
|
|
432
|
+
if (typeof valueOrFn === "function")
|
|
433
|
+
return valueOrFn(fnProps);
|
|
434
|
+
return valueOrFn;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
417
438
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
418
|
-
var
|
|
439
|
+
var ColumnSelectContent = import_styled_components9.default.div`
|
|
440
|
+
display: grid;
|
|
441
|
+
grid-template-columns: repeat(2, 1fr);
|
|
442
|
+
grid-gap: 0.5rem;
|
|
443
|
+
`;
|
|
444
|
+
var ActionsWrapper = import_styled_components9.default.div`
|
|
419
445
|
display: flex;
|
|
420
|
-
|
|
446
|
+
align-items: center;
|
|
447
|
+
justify-content: flex-end;
|
|
448
|
+
gap: 0.5rem;
|
|
421
449
|
`;
|
|
422
|
-
function
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
450
|
+
function ColumnSelect({ table }) {
|
|
451
|
+
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
452
|
+
const referenceElement = (0, import_react2.useRef)(null);
|
|
453
|
+
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, {
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Tooltip, {
|
|
457
|
+
title: "Select columns",
|
|
458
|
+
placement: "left",
|
|
459
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
460
|
+
"aria-haspopup": true,
|
|
461
|
+
id: "column-select-anchor",
|
|
462
|
+
"aria-controls": "column-select-popover",
|
|
463
|
+
"aria-expanded": isOpen,
|
|
464
|
+
ref: referenceElement,
|
|
465
|
+
variant: "ghost_icon",
|
|
466
|
+
onClick: () => setIsOpen(true),
|
|
467
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
|
|
468
|
+
name: "view_column",
|
|
469
|
+
data: import_eds_icons4.view_column
|
|
470
|
+
})
|
|
431
471
|
})
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover, {
|
|
474
|
+
open: isOpen,
|
|
475
|
+
id: "column-select-popover",
|
|
476
|
+
anchorEl: referenceElement.current,
|
|
477
|
+
placement: "bottom-end",
|
|
478
|
+
onClose: () => setIsOpen(false),
|
|
479
|
+
children: [
|
|
480
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Header, {
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Popover.Title, {
|
|
483
|
+
children: "Column settings"
|
|
484
|
+
}),
|
|
485
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
486
|
+
variant: "ghost_icon",
|
|
487
|
+
"aria-label": "Close column select",
|
|
488
|
+
onClick: () => setIsOpen(false),
|
|
489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
|
|
490
|
+
name: "close",
|
|
491
|
+
data: import_eds_icons4.close,
|
|
492
|
+
size: 24
|
|
493
|
+
})
|
|
494
|
+
})
|
|
495
|
+
]
|
|
496
|
+
}),
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Content, {
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ColumnSelectContent, {
|
|
500
|
+
children: selectableColumns.map((column) => {
|
|
501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Checkbox, {
|
|
502
|
+
checked: column.getIsVisible(),
|
|
503
|
+
label: getColumnHeader(column),
|
|
504
|
+
onChange: column.getToggleVisibilityHandler()
|
|
505
|
+
}, column.id);
|
|
506
|
+
})
|
|
507
|
+
}),
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Divider, {
|
|
509
|
+
variant: "small"
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ActionsWrapper, {
|
|
512
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
|
|
513
|
+
color: "secondary",
|
|
514
|
+
variant: "ghost",
|
|
515
|
+
disabled: table.getIsAllColumnsVisible(),
|
|
516
|
+
onClick: () => table.toggleAllColumnsVisible(true),
|
|
517
|
+
children: "Reset to default"
|
|
518
|
+
})
|
|
519
|
+
})
|
|
520
|
+
]
|
|
521
|
+
})
|
|
522
|
+
]
|
|
432
523
|
})
|
|
433
|
-
|
|
524
|
+
]
|
|
434
525
|
});
|
|
435
526
|
}
|
|
436
527
|
|
|
437
|
-
// src/DataTable/components/TableBody.tsx
|
|
438
|
-
var import_eds_core_react8 = require("@equinor/eds-core-react");
|
|
439
|
-
var import_styled_components10 = __toESM(require("styled-components"));
|
|
440
|
-
var TableBody = (0, import_styled_components10.default)(import_eds_core_react8.Table.Body)`
|
|
441
|
-
// The following attribute are important for fixed column width
|
|
442
|
-
// CHANGE THES WITH CAUTION
|
|
443
|
-
background: inherit;
|
|
444
|
-
`;
|
|
445
|
-
|
|
446
528
|
// src/DataTable/components/TableHeader.tsx
|
|
447
|
-
var
|
|
529
|
+
var import_eds_core_react9 = require("@equinor/eds-core-react");
|
|
448
530
|
|
|
449
531
|
// src/cells/HeaderCell.tsx
|
|
450
|
-
var
|
|
451
|
-
var
|
|
532
|
+
var import_eds_core_react8 = require("@equinor/eds-core-react");
|
|
533
|
+
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
452
534
|
var import_react_table2 = require("@tanstack/react-table");
|
|
453
|
-
var
|
|
535
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
454
536
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
455
|
-
var HeaderDiv =
|
|
537
|
+
var HeaderDiv = import_styled_components10.default.div`
|
|
456
538
|
display: flex;
|
|
457
539
|
align-items: center;
|
|
458
540
|
gap: 0.25rem;
|
|
@@ -478,7 +560,7 @@ var HeaderCell = ({ header }) => {
|
|
|
478
560
|
})
|
|
479
561
|
}, header.id);
|
|
480
562
|
}
|
|
481
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
|
|
482
564
|
...cellProps,
|
|
483
565
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
484
566
|
header
|
|
@@ -492,14 +574,14 @@ function HeaderContent({ header }) {
|
|
|
492
574
|
children: [
|
|
493
575
|
(0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
494
576
|
{
|
|
495
|
-
asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
496
|
-
data:
|
|
577
|
+
asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
578
|
+
data: import_eds_icons5.arrow_drop_up
|
|
497
579
|
}),
|
|
498
|
-
desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
499
|
-
data:
|
|
580
|
+
desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
581
|
+
data: import_eds_icons5.arrow_drop_down
|
|
500
582
|
}),
|
|
501
|
-
none: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
502
|
-
data:
|
|
583
|
+
none: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
|
|
584
|
+
data: import_eds_icons5.arrow_drop_down
|
|
503
585
|
})
|
|
504
586
|
}[header.column.getIsSorted()] ?? null
|
|
505
587
|
]
|
|
@@ -521,9 +603,9 @@ function getSort({ column }) {
|
|
|
521
603
|
// src/DataTable/components/TableHeader.tsx
|
|
522
604
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
523
605
|
function TableHeader({ table, sticky }) {
|
|
524
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Head, {
|
|
525
607
|
sticky,
|
|
526
|
-
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
608
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
|
|
527
609
|
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HeaderCell, {
|
|
528
610
|
header
|
|
529
611
|
}, header.id))
|
|
@@ -531,14 +613,54 @@ function TableHeader({ table, sticky }) {
|
|
|
531
613
|
});
|
|
532
614
|
}
|
|
533
615
|
|
|
534
|
-
// src/DataTable/
|
|
616
|
+
// src/DataTable/DataTable.tsx
|
|
617
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
618
|
+
var import_react5 = require("react");
|
|
619
|
+
var import_styled_components16 = __toESM(require("styled-components"));
|
|
620
|
+
|
|
621
|
+
// src/DataTable/components/BasicTable.tsx
|
|
622
|
+
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
623
|
+
|
|
624
|
+
// src/DataTable/components/PlaceholderRow.tsx
|
|
625
|
+
var import_eds_core_react10 = require("@equinor/eds-core-react");
|
|
626
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
627
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
628
|
+
var PlaceholderTextWrapper = import_styled_components11.default.div`
|
|
629
|
+
display: flex;
|
|
630
|
+
justify-content: center;
|
|
631
|
+
`;
|
|
632
|
+
function PlaceholderRow({ isLoading }) {
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
|
|
634
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
|
|
635
|
+
colSpan: 100,
|
|
636
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PlaceholderTextWrapper, {
|
|
637
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.DotProgress, {
|
|
638
|
+
color: "primary"
|
|
639
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Typography, {
|
|
640
|
+
children: "No data available"
|
|
641
|
+
})
|
|
642
|
+
})
|
|
643
|
+
})
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// src/DataTable/components/TableBody.tsx
|
|
535
648
|
var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
536
649
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
537
|
-
var
|
|
650
|
+
var TableBody = (0, import_styled_components12.default)(import_eds_core_react11.Table.Body)`
|
|
651
|
+
// The following attribute are important for fixed column width
|
|
652
|
+
// CHANGE THES WITH CAUTION
|
|
653
|
+
background: inherit;
|
|
654
|
+
`;
|
|
655
|
+
|
|
656
|
+
// src/DataTable/components/TableRow.tsx
|
|
657
|
+
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
658
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
659
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
538
660
|
function TableRow({ row, rowConfig, cellConfig }) {
|
|
539
661
|
var _a;
|
|
540
662
|
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
541
|
-
const tableRowContent = /* @__PURE__ */ (0,
|
|
663
|
+
const tableRowContent = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(StyledTableRow, {
|
|
542
664
|
active: row.getIsSelected(),
|
|
543
665
|
style: {
|
|
544
666
|
cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
|
|
@@ -552,7 +674,7 @@ function TableRow({ row, rowConfig, cellConfig }) {
|
|
|
552
674
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
553
675
|
children: row.getVisibleCells().map((cell) => {
|
|
554
676
|
var _a2;
|
|
555
|
-
return /* @__PURE__ */ (0,
|
|
677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DynamicCell, {
|
|
556
678
|
cell,
|
|
557
679
|
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
558
680
|
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
@@ -561,7 +683,7 @@ function TableRow({ row, rowConfig, cellConfig }) {
|
|
|
561
683
|
});
|
|
562
684
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
563
685
|
}
|
|
564
|
-
var StyledTableRow = (0,
|
|
686
|
+
var StyledTableRow = (0, import_styled_components13.default)(import_eds_core_react12.Table.Row)`
|
|
565
687
|
/* Background color must be inherited here. Does not work with inline styling */
|
|
566
688
|
${({ active }) => active ? "" : "background-color: inherit;"}
|
|
567
689
|
`;
|
|
@@ -574,27 +696,32 @@ function handleRowEvent(row, handler) {
|
|
|
574
696
|
}
|
|
575
697
|
|
|
576
698
|
// src/DataTable/components/BasicTable.tsx
|
|
577
|
-
var
|
|
699
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
578
700
|
function BasicTable({
|
|
579
701
|
table,
|
|
580
702
|
rowConfig,
|
|
581
703
|
cellConfig,
|
|
582
704
|
stickyHeader,
|
|
583
|
-
isLoading
|
|
705
|
+
isLoading,
|
|
706
|
+
tableCaption
|
|
584
707
|
}) {
|
|
585
708
|
const tableRows = table.getRowModel().rows;
|
|
586
|
-
return /* @__PURE__ */ (0,
|
|
709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react13.Table, {
|
|
587
710
|
children: [
|
|
588
|
-
/* @__PURE__ */ (0,
|
|
711
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react13.Table.Caption, {
|
|
712
|
+
hidden: true,
|
|
713
|
+
children: tableCaption
|
|
714
|
+
}),
|
|
715
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TableHeader, {
|
|
589
716
|
sticky: stickyHeader,
|
|
590
717
|
table
|
|
591
718
|
}),
|
|
592
|
-
/* @__PURE__ */ (0,
|
|
593
|
-
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0,
|
|
719
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TableBody, {
|
|
720
|
+
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TableRow, {
|
|
594
721
|
row,
|
|
595
722
|
rowConfig,
|
|
596
723
|
cellConfig
|
|
597
|
-
}, row.id)) : /* @__PURE__ */ (0,
|
|
724
|
+
}, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PlaceholderRow, {
|
|
598
725
|
isLoading
|
|
599
726
|
})
|
|
600
727
|
})
|
|
@@ -605,27 +732,18 @@ function BasicTable({
|
|
|
605
732
|
// src/DataTable/components/DataTableHeader.tsx
|
|
606
733
|
var import_eds_core_react15 = require("@equinor/eds-core-react");
|
|
607
734
|
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
608
|
-
var import_jotai2 = require("jotai");
|
|
609
735
|
var import_styled_components15 = __toESM(require("styled-components"));
|
|
610
736
|
|
|
611
|
-
// src/DataTable/atoms.ts
|
|
612
|
-
var import_jotai = require("jotai");
|
|
613
|
-
var columnVisibilityAtom = (0, import_jotai.atom)({});
|
|
614
|
-
var globalFilterAtom = (0, import_jotai.atom)("");
|
|
615
|
-
var rowSelectionAtom = (0, import_jotai.atom)({});
|
|
616
|
-
var tableSortingAtom = (0, import_jotai.atom)([]);
|
|
617
|
-
var expandedRowsAtom = (0, import_jotai.atom)({});
|
|
618
|
-
|
|
619
737
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
620
|
-
var
|
|
621
|
-
var
|
|
622
|
-
var
|
|
623
|
-
var
|
|
624
|
-
var
|
|
625
|
-
var Wrapper3 =
|
|
738
|
+
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
739
|
+
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
740
|
+
var import_react3 = require("react");
|
|
741
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
742
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
743
|
+
var Wrapper3 = import_styled_components14.default.div`
|
|
626
744
|
width: 200px;
|
|
627
745
|
`;
|
|
628
|
-
var CloseButton = (0,
|
|
746
|
+
var CloseButton = (0, import_styled_components14.default)(import_eds_core_react14.Button)`
|
|
629
747
|
width: 24px;
|
|
630
748
|
height: 24px;
|
|
631
749
|
`;
|
|
@@ -636,33 +754,33 @@ function DebouncedInput({
|
|
|
636
754
|
debounce = 500,
|
|
637
755
|
...props
|
|
638
756
|
}) {
|
|
639
|
-
const [value, setValue] = (0,
|
|
640
|
-
(0,
|
|
757
|
+
const [value, setValue] = (0, import_react3.useState)(initialValue);
|
|
758
|
+
(0, import_react3.useEffect)(() => {
|
|
641
759
|
setValue(initialValue);
|
|
642
760
|
}, [initialValue]);
|
|
643
|
-
(0,
|
|
761
|
+
(0, import_react3.useEffect)(() => {
|
|
644
762
|
const timeout = setTimeout(() => {
|
|
645
763
|
onChange(value);
|
|
646
764
|
}, debounce);
|
|
647
765
|
return () => clearTimeout(timeout);
|
|
648
766
|
}, [value]);
|
|
649
|
-
return /* @__PURE__ */ (0,
|
|
650
|
-
children: /* @__PURE__ */ (0,
|
|
767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Wrapper3, {
|
|
768
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Input, {
|
|
651
769
|
...props,
|
|
652
770
|
value,
|
|
653
|
-
leftAdornments: icon && /* @__PURE__ */ (0,
|
|
771
|
+
leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
|
|
654
772
|
name: icon.name,
|
|
655
773
|
data: icon,
|
|
656
774
|
size: 18
|
|
657
775
|
}),
|
|
658
|
-
rightAdornments: !!value && /* @__PURE__ */ (0,
|
|
776
|
+
rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Tooltip, {
|
|
659
777
|
title: "Clear input",
|
|
660
|
-
children: /* @__PURE__ */ (0,
|
|
778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CloseButton, {
|
|
661
779
|
variant: "ghost_icon",
|
|
662
780
|
onClick: () => setValue(""),
|
|
663
|
-
children: /* @__PURE__ */ (0,
|
|
664
|
-
name:
|
|
665
|
-
data:
|
|
781
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
|
|
782
|
+
name: import_eds_icons6.close.name,
|
|
783
|
+
data: import_eds_icons6.close,
|
|
666
784
|
size: 18
|
|
667
785
|
})
|
|
668
786
|
})
|
|
@@ -682,136 +800,14 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
682
800
|
return itemRank.passed;
|
|
683
801
|
};
|
|
684
802
|
|
|
685
|
-
// src/DataTable/components/ColumnSelect.tsx
|
|
686
|
-
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
687
|
-
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
688
|
-
var import_react3 = require("react");
|
|
689
|
-
var import_styled_components14 = __toESM(require("styled-components"));
|
|
690
|
-
|
|
691
|
-
// src/DataTable/utils.tsx
|
|
692
|
-
function capitalizeHeader(context) {
|
|
693
|
-
const header = context.header.id;
|
|
694
|
-
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
695
|
-
}
|
|
696
|
-
function enableOrUndefined(enabled, value) {
|
|
697
|
-
return Boolean(enabled) ? value : void 0;
|
|
698
|
-
}
|
|
699
|
-
function getColumnHeader(column) {
|
|
700
|
-
const columnHeader = column.columnDef.header;
|
|
701
|
-
if (!columnHeader)
|
|
702
|
-
return column.id;
|
|
703
|
-
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
704
|
-
}
|
|
705
|
-
function prependSelectColumn(columns, config) {
|
|
706
|
-
if (!(config == null ? void 0 : config.selectColumn))
|
|
707
|
-
return columns;
|
|
708
|
-
if (config.selectColumn === "default")
|
|
709
|
-
return [SelectColumnDef(config), ...columns];
|
|
710
|
-
return [config.selectColumn(), ...columns];
|
|
711
|
-
}
|
|
712
|
-
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
713
|
-
if (valueOrFn === void 0)
|
|
714
|
-
return defaultValue;
|
|
715
|
-
if (typeof valueOrFn === "function")
|
|
716
|
-
return valueOrFn(fnProps);
|
|
717
|
-
return valueOrFn;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
// src/DataTable/components/ColumnSelect.tsx
|
|
721
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
722
|
-
var ColumnSelectContent = import_styled_components14.default.div`
|
|
723
|
-
display: grid;
|
|
724
|
-
grid-template-columns: repeat(2, 1fr);
|
|
725
|
-
grid-gap: 0.5rem;
|
|
726
|
-
`;
|
|
727
|
-
var ActionsWrapper = import_styled_components14.default.div`
|
|
728
|
-
display: flex;
|
|
729
|
-
align-items: center;
|
|
730
|
-
justify-content: flex-end;
|
|
731
|
-
gap: 0.5rem;
|
|
732
|
-
`;
|
|
733
|
-
function ColumnSelect({ table }) {
|
|
734
|
-
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
735
|
-
const referenceElement = (0, import_react3.useRef)(null);
|
|
736
|
-
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
737
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, {
|
|
738
|
-
children: [
|
|
739
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
|
|
740
|
-
"aria-haspopup": true,
|
|
741
|
-
id: "column-select-anchor",
|
|
742
|
-
"aria-controls": "column-select-popover",
|
|
743
|
-
"aria-expanded": isOpen,
|
|
744
|
-
ref: referenceElement,
|
|
745
|
-
variant: "ghost_icon",
|
|
746
|
-
onClick: () => setIsOpen(true),
|
|
747
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
|
|
748
|
-
name: "view_column",
|
|
749
|
-
data: import_eds_icons6.view_column
|
|
750
|
-
})
|
|
751
|
-
}),
|
|
752
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover, {
|
|
753
|
-
open: isOpen,
|
|
754
|
-
id: "column-select-popover",
|
|
755
|
-
anchorEl: referenceElement.current,
|
|
756
|
-
placement: "bottom-end",
|
|
757
|
-
onClose: () => setIsOpen(false),
|
|
758
|
-
children: [
|
|
759
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover.Header, {
|
|
760
|
-
children: [
|
|
761
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Popover.Title, {
|
|
762
|
-
children: "Column settings"
|
|
763
|
-
}),
|
|
764
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
|
|
765
|
-
variant: "ghost_icon",
|
|
766
|
-
"aria-label": "Close column select",
|
|
767
|
-
onClick: () => setIsOpen(false),
|
|
768
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
|
|
769
|
-
name: "close",
|
|
770
|
-
data: import_eds_icons6.close,
|
|
771
|
-
size: 24
|
|
772
|
-
})
|
|
773
|
-
})
|
|
774
|
-
]
|
|
775
|
-
}),
|
|
776
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover.Content, {
|
|
777
|
-
children: [
|
|
778
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ColumnSelectContent, {
|
|
779
|
-
children: selectableColumns.map((column) => {
|
|
780
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Checkbox, {
|
|
781
|
-
checked: column.getIsVisible(),
|
|
782
|
-
label: getColumnHeader(column),
|
|
783
|
-
onChange: column.getToggleVisibilityHandler()
|
|
784
|
-
}, column.id);
|
|
785
|
-
})
|
|
786
|
-
}),
|
|
787
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Divider, {
|
|
788
|
-
variant: "small"
|
|
789
|
-
}),
|
|
790
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ActionsWrapper, {
|
|
791
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
|
|
792
|
-
color: "secondary",
|
|
793
|
-
variant: "ghost",
|
|
794
|
-
disabled: table.getIsAllColumnsVisible(),
|
|
795
|
-
onClick: () => table.toggleAllColumnsVisible(true),
|
|
796
|
-
children: "Reset to default"
|
|
797
|
-
})
|
|
798
|
-
})
|
|
799
|
-
]
|
|
800
|
-
})
|
|
801
|
-
]
|
|
802
|
-
})
|
|
803
|
-
]
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
|
|
807
803
|
// src/DataTable/components/DataTableHeader.tsx
|
|
808
804
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
809
|
-
var
|
|
805
|
+
var TableBannerWrapper = import_styled_components15.default.div`
|
|
810
806
|
display: flex;
|
|
811
807
|
align-items: center;
|
|
812
808
|
justify-content: space-between;
|
|
813
809
|
gap: 0.5rem;
|
|
814
|
-
padding: ${(props) => props.
|
|
810
|
+
padding: ${(props) => props.padding || "1rem"};
|
|
815
811
|
`;
|
|
816
812
|
var FilterContainer = import_styled_components15.default.div`
|
|
817
813
|
display: flex;
|
|
@@ -819,30 +815,49 @@ var FilterContainer = import_styled_components15.default.div`
|
|
|
819
815
|
gap: 1rem;
|
|
820
816
|
justify-content: flex-end;
|
|
821
817
|
`;
|
|
822
|
-
function
|
|
818
|
+
function TableBanner({
|
|
819
|
+
table,
|
|
820
|
+
bannerConfig,
|
|
821
|
+
tableCaption,
|
|
822
|
+
globalFilter
|
|
823
|
+
}) {
|
|
823
824
|
var _a;
|
|
824
|
-
|
|
825
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DataTableHeaderWrapper, {
|
|
825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(TableBannerWrapper, {
|
|
826
826
|
className: "--table-caption",
|
|
827
|
-
|
|
827
|
+
padding: bannerConfig == null ? void 0 : bannerConfig.padding,
|
|
828
828
|
children: [
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
children:
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(FilterContainer, {
|
|
830
|
+
className: "--filter-container-left",
|
|
831
|
+
children: [
|
|
832
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react15.Typography, {
|
|
833
|
+
variant: "h3",
|
|
834
|
+
as: "h2",
|
|
835
|
+
children: tableCaption
|
|
836
|
+
}),
|
|
837
|
+
(_a = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _a.call(bannerConfig, table)
|
|
838
|
+
]
|
|
832
839
|
}),
|
|
833
840
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FilterContainer, {
|
|
834
|
-
className: "--filter-container",
|
|
841
|
+
className: "--filter-container-right",
|
|
835
842
|
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, {
|
|
836
843
|
children: [
|
|
837
|
-
(
|
|
838
|
-
value: globalFilter,
|
|
844
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableGlobalFilterInput) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DebouncedInput, {
|
|
845
|
+
value: globalFilter.state,
|
|
839
846
|
icon: import_eds_icons7.search,
|
|
840
|
-
placeholder:
|
|
841
|
-
onChange: (value) =>
|
|
847
|
+
placeholder: bannerConfig.globalFilterPlaceholder ?? "Search all columns",
|
|
848
|
+
onChange: (value) => globalFilter.onChange(String(value))
|
|
842
849
|
}),
|
|
843
|
-
(
|
|
844
|
-
(config == null ? void 0 : config.columnSelect) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ColumnSelect, {
|
|
850
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableColumnSelect) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ColumnSelect, {
|
|
845
851
|
table
|
|
852
|
+
}),
|
|
853
|
+
(bannerConfig == null ? void 0 : bannerConfig.totalRowCount) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", {
|
|
854
|
+
children: [
|
|
855
|
+
table.options.data.length.toLocaleString(),
|
|
856
|
+
" /",
|
|
857
|
+
" ",
|
|
858
|
+
bannerConfig.totalRowCount.toLocaleString(),
|
|
859
|
+
" rows"
|
|
860
|
+
]
|
|
846
861
|
})
|
|
847
862
|
]
|
|
848
863
|
})
|
|
@@ -890,6 +905,10 @@ function VirtualTable({
|
|
|
890
905
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
891
906
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react17.Table, {
|
|
892
907
|
children: [
|
|
908
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_eds_core_react17.Table.Caption, {
|
|
909
|
+
hidden: true,
|
|
910
|
+
children: props.tableCaption
|
|
911
|
+
}),
|
|
893
912
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, {
|
|
894
913
|
sticky: props.stickyHeader,
|
|
895
914
|
table
|
|
@@ -947,7 +966,7 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
|
947
966
|
return onTableContainerScroll;
|
|
948
967
|
}
|
|
949
968
|
|
|
950
|
-
// src/DataTable/
|
|
969
|
+
// src/DataTable/DataTable.tsx
|
|
951
970
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
952
971
|
var DataTableWrapper = import_styled_components16.default.div`
|
|
953
972
|
width: ${(props) => props.width ?? "100%"};
|
|
@@ -966,30 +985,103 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
966
985
|
}
|
|
967
986
|
}
|
|
968
987
|
`;
|
|
969
|
-
function
|
|
970
|
-
var _a, _b;
|
|
971
|
-
const {
|
|
988
|
+
function DataTable(props) {
|
|
989
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
990
|
+
const { columns, data, bannerConfig, cellConfig, sorting } = props;
|
|
991
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = (0, import_react5.useState)({});
|
|
992
|
+
const [columnVisibility, setColumnVisibility] = [
|
|
993
|
+
((_a = props.columnVisibility) == null ? void 0 : _a.state) ?? internalColumnVisibility,
|
|
994
|
+
((_b = props.columnVisibility) == null ? void 0 : _b.onChange) ?? setInternalColumnVisibility
|
|
995
|
+
];
|
|
996
|
+
const [internalGlobalFilterState, setInternalGlobalFilterState] = (0, import_react5.useState)("");
|
|
997
|
+
const [globalFilterState, setGlobalFilterState] = [
|
|
998
|
+
((_c = props.globalFilter) == null ? void 0 : _c.state) ?? internalGlobalFilterState,
|
|
999
|
+
((_d = props.globalFilter) == null ? void 0 : _d.onChange) ?? setInternalGlobalFilterState
|
|
1000
|
+
];
|
|
1001
|
+
const shouldEnableGlobalFilter = ((_e = props.bannerConfig) == null ? void 0 : _e.enableGlobalFilterInput) || Boolean(props.globalFilter);
|
|
1002
|
+
function enableGlobalFilter(value) {
|
|
1003
|
+
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
1004
|
+
}
|
|
1005
|
+
const [internalSortingState, setInternalSortingState] = (0, import_react5.useState)([]);
|
|
1006
|
+
const [sortingState, setSortingState] = [
|
|
1007
|
+
((_f = props.sorting) == null ? void 0 : _f.state) ?? internalSortingState,
|
|
1008
|
+
((_g = props.sorting) == null ? void 0 : _g.onChange) ?? setInternalSortingState
|
|
1009
|
+
];
|
|
1010
|
+
const [internalRowSelectionState, setInternalRowSelectionState] = (0, import_react5.useState)({});
|
|
1011
|
+
const [rowSelectionState, setRowSelectionState] = [
|
|
1012
|
+
((_h = props.rowSelection) == null ? void 0 : _h.state) ?? internalRowSelectionState,
|
|
1013
|
+
((_i = props.rowSelection) == null ? void 0 : _i.onChange) ?? setInternalRowSelectionState
|
|
1014
|
+
];
|
|
1015
|
+
const [internalExpandedState, setInternalExpandedState] = (0, import_react5.useState)({});
|
|
1016
|
+
const [expandedState, setExpandedState] = [
|
|
1017
|
+
((_j = props.expansion) == null ? void 0 : _j.state) ?? internalExpandedState,
|
|
1018
|
+
((_k = props.expansion) == null ? void 0 : _k.onChange) ?? setInternalExpandedState
|
|
1019
|
+
];
|
|
1020
|
+
const table = (0, import_react_table3.useReactTable)({
|
|
1021
|
+
columns: prependSelectColumn(columns, props.rowSelection),
|
|
1022
|
+
data,
|
|
1023
|
+
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
1024
|
+
state: {
|
|
1025
|
+
expanded: expandedState,
|
|
1026
|
+
globalFilter: enableGlobalFilter(globalFilterState),
|
|
1027
|
+
sorting: ((_l = props.sorting) == null ? void 0 : _l.enableSorting) ? ((_m = props.sorting) == null ? void 0 : _m.state) ?? sortingState : void 0,
|
|
1028
|
+
rowSelection: rowSelectionState,
|
|
1029
|
+
columnVisibility
|
|
1030
|
+
},
|
|
1031
|
+
defaultColumn: {
|
|
1032
|
+
cell: ({ cell }) => {
|
|
1033
|
+
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
1034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TypographyCustom, {
|
|
1035
|
+
truncate: truncateMode === "hover",
|
|
1036
|
+
children: cell.getValue()
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
enableSorting: sorting == null ? void 0 : sorting.enableSorting,
|
|
1041
|
+
manualSorting: sorting == null ? void 0 : sorting.manualSorting,
|
|
1042
|
+
enableExpanding: Boolean(props.expansion),
|
|
1043
|
+
enableMultiRowSelection: ((_n = props.rowSelection) == null ? void 0 : _n.mode) === "multiple",
|
|
1044
|
+
enableSubRowSelection: ((_o = props.rowSelection) == null ? void 0 : _o.mode) !== "single",
|
|
1045
|
+
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
1046
|
+
getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
|
|
1047
|
+
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
1048
|
+
getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
|
|
1049
|
+
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
1050
|
+
onExpandedChange: setExpandedState,
|
|
1051
|
+
onRowSelectionChange: setRowSelectionState,
|
|
1052
|
+
onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (sorting == null ? void 0 : sorting.onChange) ?? setSortingState : void 0,
|
|
1053
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
1054
|
+
onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
|
|
1055
|
+
getSubRows: props == null ? void 0 : props.getSubRows,
|
|
1056
|
+
getRowId: props == null ? void 0 : props.getRowId
|
|
1057
|
+
});
|
|
1058
|
+
(0, import_react5.useEffect)(() => {
|
|
1059
|
+
var _a2;
|
|
1060
|
+
if ((_a2 = props.expansion) == null ? void 0 : _a2.expandAllByDefault) {
|
|
1061
|
+
table.toggleAllRowsExpanded();
|
|
1062
|
+
}
|
|
1063
|
+
}, [table, (_p = props.expansion) == null ? void 0 : _p.expandAllByDefault]);
|
|
1064
|
+
const { isLoading, rowConfig } = props;
|
|
972
1065
|
const tableContainerRef = (0, import_react5.useRef)(null);
|
|
973
1066
|
const onTableContainerScroll = useFetchMoreOnBottomReached(
|
|
974
1067
|
tableContainerRef,
|
|
975
1068
|
props.infiniteScroll
|
|
976
1069
|
);
|
|
977
1070
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
tableLayout: config == null ? void 0 : config.tableLayout,
|
|
1071
|
+
height: props == null ? void 0 : props.height,
|
|
1072
|
+
width: props == null ? void 0 : props.width,
|
|
1073
|
+
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
982
1074
|
children: [
|
|
983
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
984
|
-
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
985
|
-
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
1075
|
+
props.bannerConfig && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TableBanner, {
|
|
986
1076
|
table,
|
|
987
|
-
|
|
1077
|
+
bannerConfig: props.bannerConfig,
|
|
1078
|
+
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
1079
|
+
tableCaption: props.tableCaption
|
|
988
1080
|
}),
|
|
989
1081
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
|
|
990
1082
|
...props.tableContainerProps,
|
|
991
|
-
className: "--table-container " + ((
|
|
992
|
-
onScroll: ((
|
|
1083
|
+
className: "--table-container " + ((_q = props.tableContainerProps) == null ? void 0 : _q.className),
|
|
1084
|
+
onScroll: ((_r = props.tableContainerProps) == null ? void 0 : _r.onScroll) ?? onTableContainerScroll,
|
|
993
1085
|
ref: (node) => {
|
|
994
1086
|
var _a2;
|
|
995
1087
|
if (node) {
|
|
@@ -999,109 +1091,26 @@ function DataTableRaw(props) {
|
|
|
999
1091
|
}
|
|
1000
1092
|
}
|
|
1001
1093
|
},
|
|
1002
|
-
children: (
|
|
1094
|
+
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
|
|
1003
1095
|
containerRef: tableContainerRef,
|
|
1096
|
+
tableCaption: props.tableCaption,
|
|
1004
1097
|
table,
|
|
1005
1098
|
rowConfig,
|
|
1006
1099
|
cellConfig,
|
|
1007
1100
|
isLoading,
|
|
1008
|
-
stickyHeader:
|
|
1101
|
+
stickyHeader: props.stickyHeader
|
|
1009
1102
|
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
1103
|
+
tableCaption: props.tableCaption,
|
|
1010
1104
|
table,
|
|
1011
1105
|
rowConfig,
|
|
1012
1106
|
cellConfig,
|
|
1013
1107
|
isLoading,
|
|
1014
|
-
stickyHeader:
|
|
1108
|
+
stickyHeader: props.stickyHeader
|
|
1015
1109
|
})
|
|
1016
1110
|
})
|
|
1017
1111
|
]
|
|
1018
1112
|
});
|
|
1019
1113
|
}
|
|
1020
|
-
|
|
1021
|
-
// src/DataTable/useDataTable.tsx
|
|
1022
|
-
var import_react_table3 = require("@tanstack/react-table");
|
|
1023
|
-
var import_jotai3 = require("jotai");
|
|
1024
|
-
var import_react6 = require("react");
|
|
1025
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1026
|
-
function useDataTable(props) {
|
|
1027
|
-
const { columns, data, filters, config, cellConfig, sortConfig } = props;
|
|
1028
|
-
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
1029
|
-
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
1030
|
-
const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
|
|
1031
|
-
const [rowSelectionState, setRowSelectionState] = (0, import_jotai3.useAtom)(rowSelectionAtom);
|
|
1032
|
-
const [expanded, setExpanded] = (0, import_jotai3.useAtom)(expandedRowsAtom);
|
|
1033
|
-
function enableGlobalFilter(value) {
|
|
1034
|
-
return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
|
|
1035
|
-
}
|
|
1036
|
-
const table = (0, import_react_table3.useReactTable)({
|
|
1037
|
-
columns: prependSelectColumn(columns, config),
|
|
1038
|
-
data,
|
|
1039
|
-
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
1040
|
-
state: {
|
|
1041
|
-
expanded,
|
|
1042
|
-
globalFilter: enableGlobalFilter(globalFilter),
|
|
1043
|
-
sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
|
|
1044
|
-
rowSelection: rowSelectionState,
|
|
1045
|
-
columnVisibility
|
|
1046
|
-
},
|
|
1047
|
-
defaultColumn: {
|
|
1048
|
-
cell: ({ cell }) => {
|
|
1049
|
-
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
1050
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypographyCustom, {
|
|
1051
|
-
truncate: truncateMode === "hover",
|
|
1052
|
-
children: cell.getValue()
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
},
|
|
1056
|
-
enableSorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) ?? (config == null ? void 0 : config.sortable),
|
|
1057
|
-
manualSorting: sortConfig == null ? void 0 : sortConfig.manualSorting,
|
|
1058
|
-
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
1059
|
-
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
1060
|
-
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
1061
|
-
filterFromLeafRows: filters == null ? void 0 : filters.filterFromLeafRows,
|
|
1062
|
-
getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
|
|
1063
|
-
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
1064
|
-
getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
|
|
1065
|
-
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
1066
|
-
onExpandedChange: setExpanded,
|
|
1067
|
-
onRowSelectionChange: setRowSelectionState,
|
|
1068
|
-
onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
|
|
1069
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
1070
|
-
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
|
|
1071
|
-
getSubRows: config == null ? void 0 : config.getSubRows,
|
|
1072
|
-
getRowId: config == null ? void 0 : config.getRowId
|
|
1073
|
-
});
|
|
1074
|
-
(0, import_react6.useEffect)(() => {
|
|
1075
|
-
if (config && config.expandAllByDefault) {
|
|
1076
|
-
table.toggleAllRowsExpanded();
|
|
1077
|
-
}
|
|
1078
|
-
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
1079
|
-
return table;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
// src/DataTable/DataTable.tsx
|
|
1083
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1084
|
-
function DataTable(props) {
|
|
1085
|
-
const table = useDataTable(props);
|
|
1086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DataTableRaw, {
|
|
1087
|
-
table,
|
|
1088
|
-
...props
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// src/DataTable/Provider.tsx
|
|
1093
|
-
var import_jotai4 = require("jotai");
|
|
1094
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1095
|
-
function DataTableProvider({ children, ...props }) {
|
|
1096
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jotai4.Provider, {
|
|
1097
|
-
...props,
|
|
1098
|
-
children
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
// src/DataTable/index.ts
|
|
1103
|
-
var DataTable2 = DataTable;
|
|
1104
|
-
DataTable2.Provider = DataTableProvider;
|
|
1105
1114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1106
1115
|
0 && (module.exports = {
|
|
1107
1116
|
AppShell,
|
|
@@ -1116,9 +1125,5 @@ DataTable2.Provider = DataTableProvider;
|
|
|
1116
1125
|
TableHeader,
|
|
1117
1126
|
TypographyCustom,
|
|
1118
1127
|
capitalizeHeader,
|
|
1119
|
-
|
|
1120
|
-
globalFilterAtom,
|
|
1121
|
-
prependSelectColumn,
|
|
1122
|
-
rowSelectionAtom,
|
|
1123
|
-
tableSortingAtom
|
|
1128
|
+
prependSelectColumn
|
|
1124
1129
|
});
|