@equinor/apollo-components 1.6.2 → 1.7.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 +14 -4
- package/dist/index.js +127 -104
- package/dist/index.mjs +104 -81
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconData } from '@equinor/eds-icons';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, ComponentProps } from 'react';
|
|
4
|
-
import { Cell, CellContext,
|
|
4
|
+
import { Cell, CellContext, Row, ColumnDef, RowSelectionState, SortingState, Table, HeaderContext } from '@tanstack/react-table';
|
|
5
5
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
6
6
|
import * as styled_components from 'styled-components';
|
|
7
7
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
@@ -45,6 +45,15 @@ interface FilterConfig {
|
|
|
45
45
|
globalFilterPlaceholder?: string;
|
|
46
46
|
filterFromLeafRows?: boolean;
|
|
47
47
|
}
|
|
48
|
+
interface RowConfig<T> {
|
|
49
|
+
getRowBackground?: (row: Row<T>) => string | undefined;
|
|
50
|
+
onClick?: (row: Row<T>) => void;
|
|
51
|
+
onMouseEnter?: (row: Row<T>) => void;
|
|
52
|
+
onMouseLeave?: (row: Row<T>) => void;
|
|
53
|
+
}
|
|
54
|
+
interface CellConfig<T> {
|
|
55
|
+
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
56
|
+
}
|
|
48
57
|
declare type RowSelectionMode = 'single' | 'multiple';
|
|
49
58
|
declare type DataTableConfig<T> = {
|
|
50
59
|
height?: string;
|
|
@@ -55,7 +64,6 @@ declare type DataTableConfig<T> = {
|
|
|
55
64
|
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
|
56
65
|
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
57
66
|
getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
|
|
58
|
-
onRowClick?: (row: Row<T>) => void;
|
|
59
67
|
} & ExpansionConfig;
|
|
60
68
|
interface ExpansionConfig {
|
|
61
69
|
expandAllByDefault?: boolean;
|
|
@@ -68,10 +76,12 @@ interface DataTableProps<T> {
|
|
|
68
76
|
isLoading?: boolean;
|
|
69
77
|
className?: string;
|
|
70
78
|
config?: DataTableConfig<T>;
|
|
79
|
+
cellConfig?: CellConfig<T>;
|
|
80
|
+
rowConfig?: RowConfig<T>;
|
|
71
81
|
filters?: FilterConfig;
|
|
72
82
|
header?: HeaderConfig;
|
|
73
83
|
}
|
|
74
|
-
declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, }: DataTableProps<T>): JSX.Element;
|
|
84
|
+
declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, rowConfig, }: DataTableProps<T>): JSX.Element;
|
|
75
85
|
|
|
76
86
|
declare type DataTableProviderProps = ComponentProps<typeof Provider>;
|
|
77
87
|
declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
|
|
@@ -123,4 +133,4 @@ declare type TypographyProps = {
|
|
|
123
133
|
*/
|
|
124
134
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
125
135
|
|
|
126
|
-
export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
|
136
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -159,6 +159,12 @@ function stringToHslColor(str, s = 80, l = 85) {
|
|
|
159
159
|
const h = hash % 360;
|
|
160
160
|
return "hsl(" + h + ", " + s + "%, " + l + "%)";
|
|
161
161
|
}
|
|
162
|
+
function stopPropagation(handler) {
|
|
163
|
+
return (e) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
handler(e);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
162
168
|
|
|
163
169
|
// src/cells/ChipsCell.tsx
|
|
164
170
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -375,27 +381,18 @@ function SelectColumnDef(selectionMode) {
|
|
|
375
381
|
selectionMode === "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Radio, {
|
|
376
382
|
checked: row.getIsSelected(),
|
|
377
383
|
"aria-label": `Select row ${row.id}`,
|
|
378
|
-
onChange: (
|
|
379
|
-
e.stopPropagation();
|
|
380
|
-
row.getToggleSelectedHandler()(e);
|
|
381
|
-
}
|
|
384
|
+
onChange: stopPropagation(row.getToggleSelectedHandler())
|
|
382
385
|
}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
|
|
383
386
|
checked: row.getIsSelected(),
|
|
384
387
|
indeterminate: row.getIsSomeSelected(),
|
|
385
388
|
"aria-label": `Select row ${row.id}`,
|
|
386
|
-
onChange: (
|
|
387
|
-
e.stopPropagation();
|
|
388
|
-
row.getToggleSelectedHandler()(e);
|
|
389
|
-
}
|
|
389
|
+
onChange: stopPropagation(row.getToggleSelectedHandler())
|
|
390
390
|
}),
|
|
391
391
|
row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
|
|
392
392
|
variant: "ghost_icon",
|
|
393
393
|
color: "secondary",
|
|
394
394
|
"aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
|
|
395
|
-
onClick: (
|
|
396
|
-
e.stopPropagation();
|
|
397
|
-
row.getToggleExpandedHandler()();
|
|
398
|
-
},
|
|
395
|
+
onClick: stopPropagation(row.getToggleExpandedHandler()),
|
|
399
396
|
style: { cursor: "pointer" },
|
|
400
397
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, {
|
|
401
398
|
data: row.getIsExpanded() ? import_eds_icons3.chevron_up : import_eds_icons3.chevron_down
|
|
@@ -409,7 +406,7 @@ function SelectColumnDef(selectionMode) {
|
|
|
409
406
|
}
|
|
410
407
|
|
|
411
408
|
// src/DataTable/DataTable.tsx
|
|
412
|
-
var
|
|
409
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
413
410
|
var import_jotai3 = require("jotai");
|
|
414
411
|
var import_react4 = require("react");
|
|
415
412
|
var import_styled_components15 = __toESM(require("styled-components"));
|
|
@@ -423,8 +420,7 @@ var tableSortingAtom = (0, import_jotai.atom)([]);
|
|
|
423
420
|
var expandedRowsAtom = (0, import_jotai.atom)({});
|
|
424
421
|
|
|
425
422
|
// src/DataTable/components/BasicTable.tsx
|
|
426
|
-
var
|
|
427
|
-
var import_react_table3 = require("@tanstack/react-table");
|
|
423
|
+
var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
428
424
|
|
|
429
425
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
430
426
|
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
@@ -538,28 +534,55 @@ function TableHeader({ table, sticky }) {
|
|
|
538
534
|
});
|
|
539
535
|
}
|
|
540
536
|
|
|
541
|
-
// src/DataTable/components/
|
|
537
|
+
// src/DataTable/components/TableRow.tsx
|
|
538
|
+
var import_eds_core_react10 = require("@equinor/eds-core-react");
|
|
542
539
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
543
|
-
function
|
|
540
|
+
function TableRow({ row, rowConfig, cellConfig }) {
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
|
|
542
|
+
active: row.getIsSelected(),
|
|
543
|
+
style: { cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial" },
|
|
544
|
+
onClick: () => {
|
|
545
|
+
var _a;
|
|
546
|
+
return (_a = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a.call(rowConfig, row);
|
|
547
|
+
},
|
|
548
|
+
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
549
|
+
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
550
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DynamicCell, {
|
|
551
|
+
cell,
|
|
552
|
+
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor
|
|
553
|
+
}, cell.id))
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function handleRowEvent(row, handler) {
|
|
557
|
+
if (!handler)
|
|
558
|
+
return void 0;
|
|
559
|
+
return () => {
|
|
560
|
+
handler(row);
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/DataTable/components/BasicTable.tsx
|
|
565
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
566
|
+
function BasicTable({
|
|
567
|
+
table,
|
|
568
|
+
rowConfig,
|
|
569
|
+
cellConfig,
|
|
570
|
+
stickyHeader,
|
|
571
|
+
isLoading
|
|
572
|
+
}) {
|
|
544
573
|
const tableRows = table.getRowModel().rows;
|
|
545
|
-
return /* @__PURE__ */ (0,
|
|
574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table, {
|
|
546
575
|
children: [
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHeader, {
|
|
548
577
|
sticky: stickyHeader,
|
|
549
578
|
table
|
|
550
579
|
}),
|
|
551
|
-
/* @__PURE__ */ (0,
|
|
552
|
-
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return (_a = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a.call(config, row);
|
|
558
|
-
},
|
|
559
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
|
|
560
|
-
children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
561
|
-
}, cell.id))
|
|
562
|
-
}, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PlaceholderRow, {
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Body, {
|
|
581
|
+
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, {
|
|
582
|
+
row,
|
|
583
|
+
rowConfig,
|
|
584
|
+
cellConfig
|
|
585
|
+
}, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PlaceholderRow, {
|
|
563
586
|
isLoading
|
|
564
587
|
})
|
|
565
588
|
})
|
|
@@ -568,7 +591,7 @@ function BasicTable({ table, config, stickyHeader, isLoading }) {
|
|
|
568
591
|
}
|
|
569
592
|
|
|
570
593
|
// src/DataTable/components/ColumnSelect.tsx
|
|
571
|
-
var
|
|
594
|
+
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
572
595
|
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
573
596
|
var import_react2 = require("react");
|
|
574
597
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
@@ -596,7 +619,7 @@ function prependSelectColumn(columns, config) {
|
|
|
596
619
|
}
|
|
597
620
|
|
|
598
621
|
// src/DataTable/components/ColumnSelect.tsx
|
|
599
|
-
var
|
|
622
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
600
623
|
var ColumnSelectContent = import_styled_components12.default.div`
|
|
601
624
|
display: grid;
|
|
602
625
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -612,9 +635,9 @@ function ColumnSelect({ table }) {
|
|
|
612
635
|
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
613
636
|
const referenceElement = (0, import_react2.useRef)(null);
|
|
614
637
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
615
|
-
return /* @__PURE__ */ (0,
|
|
638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, {
|
|
616
639
|
children: [
|
|
617
|
-
/* @__PURE__ */ (0,
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
|
|
618
641
|
"aria-haspopup": true,
|
|
619
642
|
id: "column-select-anchor",
|
|
620
643
|
"aria-controls": "column-select-popover",
|
|
@@ -622,28 +645,28 @@ function ColumnSelect({ table }) {
|
|
|
622
645
|
ref: referenceElement,
|
|
623
646
|
variant: "ghost_icon",
|
|
624
647
|
onClick: () => setIsOpen(true),
|
|
625
|
-
children: /* @__PURE__ */ (0,
|
|
648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
|
|
626
649
|
name: "view_column",
|
|
627
650
|
data: import_eds_icons5.view_column
|
|
628
651
|
})
|
|
629
652
|
}),
|
|
630
|
-
/* @__PURE__ */ (0,
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover, {
|
|
631
654
|
open: isOpen,
|
|
632
655
|
id: "column-select-popover",
|
|
633
656
|
anchorEl: referenceElement.current,
|
|
634
657
|
placement: "bottom-end",
|
|
635
658
|
onClose: () => setIsOpen(false),
|
|
636
659
|
children: [
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover.Header, {
|
|
638
661
|
children: [
|
|
639
|
-
/* @__PURE__ */ (0,
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Popover.Title, {
|
|
640
663
|
children: "Column settings"
|
|
641
664
|
}),
|
|
642
|
-
/* @__PURE__ */ (0,
|
|
665
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
|
|
643
666
|
variant: "ghost_icon",
|
|
644
667
|
"aria-label": "Close column select",
|
|
645
668
|
onClick: () => setIsOpen(false),
|
|
646
|
-
children: /* @__PURE__ */ (0,
|
|
669
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
|
|
647
670
|
name: "close",
|
|
648
671
|
data: import_eds_icons5.close,
|
|
649
672
|
size: 24
|
|
@@ -651,22 +674,22 @@ function ColumnSelect({ table }) {
|
|
|
651
674
|
})
|
|
652
675
|
]
|
|
653
676
|
}),
|
|
654
|
-
/* @__PURE__ */ (0,
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover.Content, {
|
|
655
678
|
children: [
|
|
656
|
-
/* @__PURE__ */ (0,
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ColumnSelectContent, {
|
|
657
680
|
children: selectableColumns.map((column) => {
|
|
658
|
-
return /* @__PURE__ */ (0,
|
|
681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Checkbox, {
|
|
659
682
|
checked: column.getIsVisible(),
|
|
660
683
|
label: getColumnHeader(column),
|
|
661
684
|
onChange: column.getToggleVisibilityHandler()
|
|
662
685
|
}, column.id);
|
|
663
686
|
})
|
|
664
687
|
}),
|
|
665
|
-
/* @__PURE__ */ (0,
|
|
688
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Divider, {
|
|
666
689
|
variant: "small"
|
|
667
690
|
}),
|
|
668
|
-
/* @__PURE__ */ (0,
|
|
669
|
-
children: /* @__PURE__ */ (0,
|
|
691
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ActionsWrapper, {
|
|
692
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
|
|
670
693
|
color: "secondary",
|
|
671
694
|
variant: "ghost",
|
|
672
695
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -683,21 +706,21 @@ function ColumnSelect({ table }) {
|
|
|
683
706
|
}
|
|
684
707
|
|
|
685
708
|
// src/DataTable/components/DataTableHeader.tsx
|
|
686
|
-
var
|
|
709
|
+
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
687
710
|
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
688
711
|
var import_jotai2 = require("jotai");
|
|
689
712
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
690
713
|
|
|
691
714
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
692
|
-
var
|
|
715
|
+
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
693
716
|
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
694
717
|
var import_react3 = require("react");
|
|
695
718
|
var import_styled_components13 = __toESM(require("styled-components"));
|
|
696
|
-
var
|
|
719
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
697
720
|
var Wrapper3 = import_styled_components13.default.div`
|
|
698
721
|
width: 200px;
|
|
699
722
|
`;
|
|
700
|
-
var CloseButton = (0, import_styled_components13.default)(
|
|
723
|
+
var CloseButton = (0, import_styled_components13.default)(import_eds_core_react13.Button)`
|
|
701
724
|
width: 24px;
|
|
702
725
|
height: 24px;
|
|
703
726
|
`;
|
|
@@ -718,21 +741,21 @@ function DebouncedInput({
|
|
|
718
741
|
}, debounce);
|
|
719
742
|
return () => clearTimeout(timeout);
|
|
720
743
|
}, [value]);
|
|
721
|
-
return /* @__PURE__ */ (0,
|
|
722
|
-
children: /* @__PURE__ */ (0,
|
|
744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Wrapper3, {
|
|
745
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Input, {
|
|
723
746
|
...props,
|
|
724
747
|
value,
|
|
725
|
-
leftAdornments: icon && /* @__PURE__ */ (0,
|
|
748
|
+
leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
726
749
|
name: icon.name,
|
|
727
750
|
data: icon,
|
|
728
751
|
size: 18
|
|
729
752
|
}),
|
|
730
|
-
rightAdornments: !!value && /* @__PURE__ */ (0,
|
|
753
|
+
rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Tooltip, {
|
|
731
754
|
title: "Clear input",
|
|
732
|
-
children: /* @__PURE__ */ (0,
|
|
755
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CloseButton, {
|
|
733
756
|
variant: "ghost_icon",
|
|
734
757
|
onClick: () => setValue(""),
|
|
735
|
-
children: /* @__PURE__ */ (0,
|
|
758
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
736
759
|
name: import_eds_icons6.close.name,
|
|
737
760
|
data: import_eds_icons6.close,
|
|
738
761
|
size: 18
|
|
@@ -755,7 +778,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
755
778
|
};
|
|
756
779
|
|
|
757
780
|
// src/DataTable/components/DataTableHeader.tsx
|
|
758
|
-
var
|
|
781
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
759
782
|
var DataTableHeaderWrapper = import_styled_components14.default.div`
|
|
760
783
|
display: flex;
|
|
761
784
|
align-items: center;
|
|
@@ -771,18 +794,18 @@ var FilterContainer = import_styled_components14.default.div`
|
|
|
771
794
|
`;
|
|
772
795
|
var DataTableHeader = (props) => {
|
|
773
796
|
const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
|
|
774
|
-
return /* @__PURE__ */ (0,
|
|
797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DataTableHeaderWrapper, {
|
|
775
798
|
className: "--table-caption",
|
|
776
799
|
captionPadding: props.captionPadding,
|
|
777
800
|
children: [
|
|
778
|
-
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0,
|
|
801
|
+
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Typography, {
|
|
779
802
|
variant: "h3",
|
|
780
803
|
children: props == null ? void 0 : props.tableCaption
|
|
781
804
|
}),
|
|
782
|
-
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0,
|
|
805
|
+
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(FilterContainer, {
|
|
783
806
|
className: "--filter-container",
|
|
784
807
|
children: [
|
|
785
|
-
/* @__PURE__ */ (0,
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DebouncedInput, {
|
|
786
809
|
value: globalFilter,
|
|
787
810
|
icon: import_eds_icons7.search,
|
|
788
811
|
placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
|
|
@@ -796,26 +819,31 @@ var DataTableHeader = (props) => {
|
|
|
796
819
|
};
|
|
797
820
|
|
|
798
821
|
// src/DataTable/components/VirtualTable.tsx
|
|
799
|
-
var
|
|
800
|
-
var import_react_table4 = require("@tanstack/react-table");
|
|
822
|
+
var import_eds_core_react16 = require("@equinor/eds-core-react");
|
|
801
823
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
802
824
|
|
|
803
825
|
// src/DataTable/components/PaddingRow.tsx
|
|
804
|
-
var
|
|
805
|
-
var
|
|
826
|
+
var import_eds_core_react15 = require("@equinor/eds-core-react");
|
|
827
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
806
828
|
var PaddingRow = (props) => {
|
|
807
829
|
if (!props.height)
|
|
808
830
|
return null;
|
|
809
|
-
return /* @__PURE__ */ (0,
|
|
810
|
-
children: /* @__PURE__ */ (0,
|
|
831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Row, {
|
|
832
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
|
|
811
833
|
style: { height: `${props.height}px` }
|
|
812
834
|
})
|
|
813
835
|
});
|
|
814
836
|
};
|
|
815
837
|
|
|
816
838
|
// src/DataTable/components/VirtualTable.tsx
|
|
817
|
-
var
|
|
818
|
-
function VirtualTable({
|
|
839
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
840
|
+
function VirtualTable({
|
|
841
|
+
table,
|
|
842
|
+
rowConfig,
|
|
843
|
+
cellConfig,
|
|
844
|
+
containerRef,
|
|
845
|
+
...props
|
|
846
|
+
}) {
|
|
819
847
|
var _a, _b;
|
|
820
848
|
const { rows } = table.getRowModel();
|
|
821
849
|
const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
@@ -826,34 +854,28 @@ function VirtualTable({ table, config, containerRef, ...props }) {
|
|
|
826
854
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
827
855
|
const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
|
|
828
856
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
829
|
-
return /* @__PURE__ */ (0,
|
|
857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table, {
|
|
830
858
|
children: [
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
859
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, {
|
|
832
860
|
sticky: props.stickyHeader,
|
|
833
861
|
table
|
|
834
862
|
}),
|
|
835
|
-
/* @__PURE__ */ (0,
|
|
863
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table.Body, {
|
|
836
864
|
children: [
|
|
837
|
-
/* @__PURE__ */ (0,
|
|
865
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaddingRow, {
|
|
838
866
|
height: paddingTop
|
|
839
867
|
}),
|
|
840
868
|
rows.length ? virtualRows.map((virtualRow) => {
|
|
841
869
|
const row = rows[virtualRow.index];
|
|
842
|
-
return /* @__PURE__ */ (0,
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
var _a2;
|
|
847
|
-
return (_a2 = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a2.call(config, row);
|
|
848
|
-
},
|
|
849
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
|
|
850
|
-
children: (0, import_react_table4.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
851
|
-
}, cell.id))
|
|
870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableRow, {
|
|
871
|
+
row,
|
|
872
|
+
rowConfig,
|
|
873
|
+
cellConfig
|
|
852
874
|
}, row.id);
|
|
853
|
-
}) : /* @__PURE__ */ (0,
|
|
875
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PlaceholderRow, {
|
|
854
876
|
isLoading: props.isLoading
|
|
855
877
|
}),
|
|
856
|
-
/* @__PURE__ */ (0,
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaddingRow, {
|
|
857
879
|
height: paddingBottom
|
|
858
880
|
})
|
|
859
881
|
]
|
|
@@ -863,7 +885,7 @@ function VirtualTable({ table, config, containerRef, ...props }) {
|
|
|
863
885
|
}
|
|
864
886
|
|
|
865
887
|
// src/DataTable/DataTable.tsx
|
|
866
|
-
var
|
|
888
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
867
889
|
var DataTableWrapper = import_styled_components15.default.div`
|
|
868
890
|
width: ${(props) => props.width ?? "100%"};
|
|
869
891
|
|
|
@@ -884,7 +906,8 @@ function DataTable({
|
|
|
884
906
|
isLoading,
|
|
885
907
|
header,
|
|
886
908
|
filters,
|
|
887
|
-
config
|
|
909
|
+
config,
|
|
910
|
+
rowConfig
|
|
888
911
|
}) {
|
|
889
912
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
890
913
|
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
@@ -894,7 +917,7 @@ function DataTable({
|
|
|
894
917
|
function enableGlobalFilter(value) {
|
|
895
918
|
return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
|
|
896
919
|
}
|
|
897
|
-
const table = (0,
|
|
920
|
+
const table = (0, import_react_table3.useReactTable)({
|
|
898
921
|
columns: prependSelectColumn(columns, config),
|
|
899
922
|
data,
|
|
900
923
|
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
@@ -906,7 +929,7 @@ function DataTable({
|
|
|
906
929
|
columnVisibility
|
|
907
930
|
},
|
|
908
931
|
defaultColumn: {
|
|
909
|
-
cell: (cell) => /* @__PURE__ */ (0,
|
|
932
|
+
cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TypographyCustom, {
|
|
910
933
|
noWrap: true,
|
|
911
934
|
children: cell.getValue()
|
|
912
935
|
})
|
|
@@ -916,10 +939,10 @@ function DataTable({
|
|
|
916
939
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
917
940
|
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
918
941
|
filterFromLeafRows: filters == null ? void 0 : filters.filterFromLeafRows,
|
|
919
|
-
getFilteredRowModel: enableGlobalFilter((0,
|
|
920
|
-
getCoreRowModel: (0,
|
|
921
|
-
getExpandedRowModel: (0,
|
|
922
|
-
getSortedRowModel: (0,
|
|
942
|
+
getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
|
|
943
|
+
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
944
|
+
getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
|
|
945
|
+
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
923
946
|
onExpandedChange: setExpanded,
|
|
924
947
|
onRowSelectionChange: setRowSelectionState,
|
|
925
948
|
onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
|
|
@@ -934,32 +957,32 @@ function DataTable({
|
|
|
934
957
|
}
|
|
935
958
|
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
936
959
|
const tableContainerRef = (0, import_react4.useRef)(null);
|
|
937
|
-
return /* @__PURE__ */ (0,
|
|
960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
|
|
938
961
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
939
962
|
height: config == null ? void 0 : config.height,
|
|
940
963
|
width: config == null ? void 0 : config.width,
|
|
941
964
|
children: [
|
|
942
|
-
/* @__PURE__ */ (0,
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
|
|
943
966
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
944
967
|
enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
|
|
945
968
|
globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
|
|
946
969
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
947
|
-
filterActions: /* @__PURE__ */ (0,
|
|
970
|
+
filterActions: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColumnSelect, {
|
|
948
971
|
table
|
|
949
972
|
})
|
|
950
973
|
}),
|
|
951
|
-
/* @__PURE__ */ (0,
|
|
974
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
|
|
952
975
|
ref: tableContainerRef,
|
|
953
976
|
className: "--table-container",
|
|
954
|
-
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0,
|
|
977
|
+
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
|
|
955
978
|
containerRef: tableContainerRef,
|
|
956
979
|
table,
|
|
957
|
-
|
|
980
|
+
rowConfig,
|
|
958
981
|
isLoading,
|
|
959
982
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
960
|
-
}) : /* @__PURE__ */ (0,
|
|
983
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
961
984
|
table,
|
|
962
|
-
|
|
985
|
+
rowConfig,
|
|
963
986
|
isLoading,
|
|
964
987
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
965
988
|
})
|
|
@@ -970,9 +993,9 @@ function DataTable({
|
|
|
970
993
|
|
|
971
994
|
// src/DataTable/Provider.tsx
|
|
972
995
|
var import_jotai4 = require("jotai");
|
|
973
|
-
var
|
|
996
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
974
997
|
function DataTableProvider({ children, ...props }) {
|
|
975
|
-
return /* @__PURE__ */ (0,
|
|
998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jotai4.Provider, {
|
|
976
999
|
...props,
|
|
977
1000
|
children
|
|
978
1001
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -113,6 +113,12 @@ function stringToHslColor(str, s = 80, l = 85) {
|
|
|
113
113
|
const h = hash % 360;
|
|
114
114
|
return "hsl(" + h + ", " + s + "%, " + l + "%)";
|
|
115
115
|
}
|
|
116
|
+
function stopPropagation(handler) {
|
|
117
|
+
return (e) => {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
handler(e);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
116
122
|
|
|
117
123
|
// src/cells/ChipsCell.tsx
|
|
118
124
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
@@ -331,27 +337,18 @@ function SelectColumnDef(selectionMode) {
|
|
|
331
337
|
selectionMode === "single" ? /* @__PURE__ */ jsx7(Radio, {
|
|
332
338
|
checked: row.getIsSelected(),
|
|
333
339
|
"aria-label": `Select row ${row.id}`,
|
|
334
|
-
onChange: (
|
|
335
|
-
e.stopPropagation();
|
|
336
|
-
row.getToggleSelectedHandler()(e);
|
|
337
|
-
}
|
|
340
|
+
onChange: stopPropagation(row.getToggleSelectedHandler())
|
|
338
341
|
}) : /* @__PURE__ */ jsx7(Checkbox, {
|
|
339
342
|
checked: row.getIsSelected(),
|
|
340
343
|
indeterminate: row.getIsSomeSelected(),
|
|
341
344
|
"aria-label": `Select row ${row.id}`,
|
|
342
|
-
onChange: (
|
|
343
|
-
e.stopPropagation();
|
|
344
|
-
row.getToggleSelectedHandler()(e);
|
|
345
|
-
}
|
|
345
|
+
onChange: stopPropagation(row.getToggleSelectedHandler())
|
|
346
346
|
}),
|
|
347
347
|
row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ jsx7(Button2, {
|
|
348
348
|
variant: "ghost_icon",
|
|
349
349
|
color: "secondary",
|
|
350
350
|
"aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
|
|
351
|
-
onClick: (
|
|
352
|
-
e.stopPropagation();
|
|
353
|
-
row.getToggleExpandedHandler()();
|
|
354
|
-
},
|
|
351
|
+
onClick: stopPropagation(row.getToggleExpandedHandler()),
|
|
355
352
|
style: { cursor: "pointer" },
|
|
356
353
|
children: /* @__PURE__ */ jsx7(Icon3, {
|
|
357
354
|
data: row.getIsExpanded() ? chevron_up : chevron_down
|
|
@@ -386,7 +383,6 @@ var expandedRowsAtom = atom({});
|
|
|
386
383
|
|
|
387
384
|
// src/DataTable/components/BasicTable.tsx
|
|
388
385
|
import { Table as EdsTable } from "@equinor/eds-core-react";
|
|
389
|
-
import { flexRender as flexRender3 } from "@tanstack/react-table";
|
|
390
386
|
|
|
391
387
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
392
388
|
import { DotProgress, Table as Table3, Typography } from "@equinor/eds-core-react";
|
|
@@ -500,28 +496,55 @@ function TableHeader({ table, sticky }) {
|
|
|
500
496
|
});
|
|
501
497
|
}
|
|
502
498
|
|
|
499
|
+
// src/DataTable/components/TableRow.tsx
|
|
500
|
+
import { Table as Table6 } from "@equinor/eds-core-react";
|
|
501
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
502
|
+
function TableRow({ row, rowConfig, cellConfig }) {
|
|
503
|
+
return /* @__PURE__ */ jsx11(Table6.Row, {
|
|
504
|
+
active: row.getIsSelected(),
|
|
505
|
+
style: { cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial" },
|
|
506
|
+
onClick: () => {
|
|
507
|
+
var _a;
|
|
508
|
+
return (_a = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a.call(rowConfig, row);
|
|
509
|
+
},
|
|
510
|
+
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
511
|
+
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
512
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(DynamicCell, {
|
|
513
|
+
cell,
|
|
514
|
+
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor
|
|
515
|
+
}, cell.id))
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function handleRowEvent(row, handler) {
|
|
519
|
+
if (!handler)
|
|
520
|
+
return void 0;
|
|
521
|
+
return () => {
|
|
522
|
+
handler(row);
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
|
|
503
526
|
// src/DataTable/components/BasicTable.tsx
|
|
504
|
-
import { jsx as
|
|
505
|
-
function BasicTable({
|
|
527
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
528
|
+
function BasicTable({
|
|
529
|
+
table,
|
|
530
|
+
rowConfig,
|
|
531
|
+
cellConfig,
|
|
532
|
+
stickyHeader,
|
|
533
|
+
isLoading
|
|
534
|
+
}) {
|
|
506
535
|
const tableRows = table.getRowModel().rows;
|
|
507
536
|
return /* @__PURE__ */ jsxs7(EdsTable, {
|
|
508
537
|
children: [
|
|
509
|
-
/* @__PURE__ */
|
|
538
|
+
/* @__PURE__ */ jsx12(TableHeader, {
|
|
510
539
|
sticky: stickyHeader,
|
|
511
540
|
table
|
|
512
541
|
}),
|
|
513
|
-
/* @__PURE__ */
|
|
514
|
-
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return (_a = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a.call(config, row);
|
|
520
|
-
},
|
|
521
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(EdsTable.Cell, {
|
|
522
|
-
children: flexRender3(cell.column.columnDef.cell, cell.getContext())
|
|
523
|
-
}, cell.id))
|
|
524
|
-
}, row.id)) : /* @__PURE__ */ jsx11(PlaceholderRow, {
|
|
542
|
+
/* @__PURE__ */ jsx12(EdsTable.Body, {
|
|
543
|
+
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx12(TableRow, {
|
|
544
|
+
row,
|
|
545
|
+
rowConfig,
|
|
546
|
+
cellConfig
|
|
547
|
+
}, row.id)) : /* @__PURE__ */ jsx12(PlaceholderRow, {
|
|
525
548
|
isLoading
|
|
526
549
|
})
|
|
527
550
|
})
|
|
@@ -558,7 +581,7 @@ function prependSelectColumn(columns, config) {
|
|
|
558
581
|
}
|
|
559
582
|
|
|
560
583
|
// src/DataTable/components/ColumnSelect.tsx
|
|
561
|
-
import { Fragment as Fragment2, jsx as
|
|
584
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
562
585
|
var ColumnSelectContent = styled11.div`
|
|
563
586
|
display: grid;
|
|
564
587
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -576,7 +599,7 @@ function ColumnSelect({ table }) {
|
|
|
576
599
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
577
600
|
return /* @__PURE__ */ jsxs8(Fragment2, {
|
|
578
601
|
children: [
|
|
579
|
-
/* @__PURE__ */
|
|
602
|
+
/* @__PURE__ */ jsx13(Button3, {
|
|
580
603
|
"aria-haspopup": true,
|
|
581
604
|
id: "column-select-anchor",
|
|
582
605
|
"aria-controls": "column-select-popover",
|
|
@@ -584,7 +607,7 @@ function ColumnSelect({ table }) {
|
|
|
584
607
|
ref: referenceElement,
|
|
585
608
|
variant: "ghost_icon",
|
|
586
609
|
onClick: () => setIsOpen(true),
|
|
587
|
-
children: /* @__PURE__ */
|
|
610
|
+
children: /* @__PURE__ */ jsx13(Icon5, {
|
|
588
611
|
name: "view_column",
|
|
589
612
|
data: view_column
|
|
590
613
|
})
|
|
@@ -598,14 +621,14 @@ function ColumnSelect({ table }) {
|
|
|
598
621
|
children: [
|
|
599
622
|
/* @__PURE__ */ jsxs8(Popover.Header, {
|
|
600
623
|
children: [
|
|
601
|
-
/* @__PURE__ */
|
|
624
|
+
/* @__PURE__ */ jsx13(Popover.Title, {
|
|
602
625
|
children: "Column settings"
|
|
603
626
|
}),
|
|
604
|
-
/* @__PURE__ */
|
|
627
|
+
/* @__PURE__ */ jsx13(Button3, {
|
|
605
628
|
variant: "ghost_icon",
|
|
606
629
|
"aria-label": "Close column select",
|
|
607
630
|
onClick: () => setIsOpen(false),
|
|
608
|
-
children: /* @__PURE__ */
|
|
631
|
+
children: /* @__PURE__ */ jsx13(Icon5, {
|
|
609
632
|
name: "close",
|
|
610
633
|
data: close,
|
|
611
634
|
size: 24
|
|
@@ -615,20 +638,20 @@ function ColumnSelect({ table }) {
|
|
|
615
638
|
}),
|
|
616
639
|
/* @__PURE__ */ jsxs8(Popover.Content, {
|
|
617
640
|
children: [
|
|
618
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ jsx13(ColumnSelectContent, {
|
|
619
642
|
children: selectableColumns.map((column) => {
|
|
620
|
-
return /* @__PURE__ */
|
|
643
|
+
return /* @__PURE__ */ jsx13(Checkbox2, {
|
|
621
644
|
checked: column.getIsVisible(),
|
|
622
645
|
label: getColumnHeader(column),
|
|
623
646
|
onChange: column.getToggleVisibilityHandler()
|
|
624
647
|
}, column.id);
|
|
625
648
|
})
|
|
626
649
|
}),
|
|
627
|
-
/* @__PURE__ */
|
|
650
|
+
/* @__PURE__ */ jsx13(Divider, {
|
|
628
651
|
variant: "small"
|
|
629
652
|
}),
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
children: /* @__PURE__ */
|
|
653
|
+
/* @__PURE__ */ jsx13(ActionsWrapper, {
|
|
654
|
+
children: /* @__PURE__ */ jsx13(Button3, {
|
|
632
655
|
color: "secondary",
|
|
633
656
|
variant: "ghost",
|
|
634
657
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -655,7 +678,7 @@ import { Button as Button4, Icon as Icon6, Input, Tooltip } from "@equinor/eds-c
|
|
|
655
678
|
import { close as close2 } from "@equinor/eds-icons";
|
|
656
679
|
import { useEffect, useState as useState3 } from "react";
|
|
657
680
|
import styled12 from "styled-components";
|
|
658
|
-
import { jsx as
|
|
681
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
659
682
|
var Wrapper3 = styled12.div`
|
|
660
683
|
width: 200px;
|
|
661
684
|
`;
|
|
@@ -680,21 +703,21 @@ function DebouncedInput({
|
|
|
680
703
|
}, debounce);
|
|
681
704
|
return () => clearTimeout(timeout);
|
|
682
705
|
}, [value]);
|
|
683
|
-
return /* @__PURE__ */
|
|
684
|
-
children: /* @__PURE__ */
|
|
706
|
+
return /* @__PURE__ */ jsx14(Wrapper3, {
|
|
707
|
+
children: /* @__PURE__ */ jsx14(Input, {
|
|
685
708
|
...props,
|
|
686
709
|
value,
|
|
687
|
-
leftAdornments: icon && /* @__PURE__ */
|
|
710
|
+
leftAdornments: icon && /* @__PURE__ */ jsx14(Icon6, {
|
|
688
711
|
name: icon.name,
|
|
689
712
|
data: icon,
|
|
690
713
|
size: 18
|
|
691
714
|
}),
|
|
692
|
-
rightAdornments: !!value && /* @__PURE__ */
|
|
715
|
+
rightAdornments: !!value && /* @__PURE__ */ jsx14(Tooltip, {
|
|
693
716
|
title: "Clear input",
|
|
694
|
-
children: /* @__PURE__ */
|
|
717
|
+
children: /* @__PURE__ */ jsx14(CloseButton, {
|
|
695
718
|
variant: "ghost_icon",
|
|
696
719
|
onClick: () => setValue(""),
|
|
697
|
-
children: /* @__PURE__ */
|
|
720
|
+
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
698
721
|
name: close2.name,
|
|
699
722
|
data: close2,
|
|
700
723
|
size: 18
|
|
@@ -717,7 +740,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
717
740
|
};
|
|
718
741
|
|
|
719
742
|
// src/DataTable/components/DataTableHeader.tsx
|
|
720
|
-
import { jsx as
|
|
743
|
+
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
721
744
|
var DataTableHeaderWrapper = styled13.div`
|
|
722
745
|
display: flex;
|
|
723
746
|
align-items: center;
|
|
@@ -737,14 +760,14 @@ var DataTableHeader = (props) => {
|
|
|
737
760
|
className: "--table-caption",
|
|
738
761
|
captionPadding: props.captionPadding,
|
|
739
762
|
children: [
|
|
740
|
-
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */
|
|
763
|
+
(props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx15(Typography2, {
|
|
741
764
|
variant: "h3",
|
|
742
765
|
children: props == null ? void 0 : props.tableCaption
|
|
743
766
|
}),
|
|
744
767
|
(props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs9(FilterContainer, {
|
|
745
768
|
className: "--filter-container",
|
|
746
769
|
children: [
|
|
747
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ jsx15(DebouncedInput, {
|
|
748
771
|
value: globalFilter,
|
|
749
772
|
icon: search,
|
|
750
773
|
placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
|
|
@@ -759,25 +782,30 @@ var DataTableHeader = (props) => {
|
|
|
759
782
|
|
|
760
783
|
// src/DataTable/components/VirtualTable.tsx
|
|
761
784
|
import { Table as Table8 } from "@equinor/eds-core-react";
|
|
762
|
-
import { flexRender as flexRender4 } from "@tanstack/react-table";
|
|
763
785
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
764
786
|
|
|
765
787
|
// src/DataTable/components/PaddingRow.tsx
|
|
766
788
|
import { Table as Table7 } from "@equinor/eds-core-react";
|
|
767
|
-
import { jsx as
|
|
789
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
768
790
|
var PaddingRow = (props) => {
|
|
769
791
|
if (!props.height)
|
|
770
792
|
return null;
|
|
771
|
-
return /* @__PURE__ */
|
|
772
|
-
children: /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ jsx16(Table7.Row, {
|
|
794
|
+
children: /* @__PURE__ */ jsx16(Table7.Cell, {
|
|
773
795
|
style: { height: `${props.height}px` }
|
|
774
796
|
})
|
|
775
797
|
});
|
|
776
798
|
};
|
|
777
799
|
|
|
778
800
|
// src/DataTable/components/VirtualTable.tsx
|
|
779
|
-
import { jsx as
|
|
780
|
-
function VirtualTable({
|
|
801
|
+
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
802
|
+
function VirtualTable({
|
|
803
|
+
table,
|
|
804
|
+
rowConfig,
|
|
805
|
+
cellConfig,
|
|
806
|
+
containerRef,
|
|
807
|
+
...props
|
|
808
|
+
}) {
|
|
781
809
|
var _a, _b;
|
|
782
810
|
const { rows } = table.getRowModel();
|
|
783
811
|
const rowVirtualizer = useVirtualizer({
|
|
@@ -790,32 +818,26 @@ function VirtualTable({ table, config, containerRef, ...props }) {
|
|
|
790
818
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
791
819
|
return /* @__PURE__ */ jsxs10(Table8, {
|
|
792
820
|
children: [
|
|
793
|
-
/* @__PURE__ */
|
|
821
|
+
/* @__PURE__ */ jsx17(TableHeader, {
|
|
794
822
|
sticky: props.stickyHeader,
|
|
795
823
|
table
|
|
796
824
|
}),
|
|
797
825
|
/* @__PURE__ */ jsxs10(Table8.Body, {
|
|
798
826
|
children: [
|
|
799
|
-
/* @__PURE__ */
|
|
827
|
+
/* @__PURE__ */ jsx17(PaddingRow, {
|
|
800
828
|
height: paddingTop
|
|
801
829
|
}),
|
|
802
830
|
rows.length ? virtualRows.map((virtualRow) => {
|
|
803
831
|
const row = rows[virtualRow.index];
|
|
804
|
-
return /* @__PURE__ */
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
var _a2;
|
|
809
|
-
return (_a2 = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a2.call(config, row);
|
|
810
|
-
},
|
|
811
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx16(Table8.Cell, {
|
|
812
|
-
children: flexRender4(cell.column.columnDef.cell, cell.getContext())
|
|
813
|
-
}, cell.id))
|
|
832
|
+
return /* @__PURE__ */ jsx17(TableRow, {
|
|
833
|
+
row,
|
|
834
|
+
rowConfig,
|
|
835
|
+
cellConfig
|
|
814
836
|
}, row.id);
|
|
815
|
-
}) : /* @__PURE__ */
|
|
837
|
+
}) : /* @__PURE__ */ jsx17(PlaceholderRow, {
|
|
816
838
|
isLoading: props.isLoading
|
|
817
839
|
}),
|
|
818
|
-
/* @__PURE__ */
|
|
840
|
+
/* @__PURE__ */ jsx17(PaddingRow, {
|
|
819
841
|
height: paddingBottom
|
|
820
842
|
})
|
|
821
843
|
]
|
|
@@ -825,7 +847,7 @@ function VirtualTable({ table, config, containerRef, ...props }) {
|
|
|
825
847
|
}
|
|
826
848
|
|
|
827
849
|
// src/DataTable/DataTable.tsx
|
|
828
|
-
import { jsx as
|
|
850
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
829
851
|
var DataTableWrapper = styled14.div`
|
|
830
852
|
width: ${(props) => props.width ?? "100%"};
|
|
831
853
|
|
|
@@ -846,7 +868,8 @@ function DataTable({
|
|
|
846
868
|
isLoading,
|
|
847
869
|
header,
|
|
848
870
|
filters,
|
|
849
|
-
config
|
|
871
|
+
config,
|
|
872
|
+
rowConfig
|
|
850
873
|
}) {
|
|
851
874
|
const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
|
|
852
875
|
const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
|
|
@@ -868,7 +891,7 @@ function DataTable({
|
|
|
868
891
|
columnVisibility
|
|
869
892
|
},
|
|
870
893
|
defaultColumn: {
|
|
871
|
-
cell: (cell) => /* @__PURE__ */
|
|
894
|
+
cell: (cell) => /* @__PURE__ */ jsx18(TypographyCustom, {
|
|
872
895
|
noWrap: true,
|
|
873
896
|
children: cell.getValue()
|
|
874
897
|
})
|
|
@@ -901,27 +924,27 @@ function DataTable({
|
|
|
901
924
|
height: config == null ? void 0 : config.height,
|
|
902
925
|
width: config == null ? void 0 : config.width,
|
|
903
926
|
children: [
|
|
904
|
-
/* @__PURE__ */
|
|
927
|
+
/* @__PURE__ */ jsx18(DataTableHeader, {
|
|
905
928
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
906
929
|
enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
|
|
907
930
|
globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
|
|
908
931
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
909
|
-
filterActions: /* @__PURE__ */
|
|
932
|
+
filterActions: /* @__PURE__ */ jsx18(ColumnSelect, {
|
|
910
933
|
table
|
|
911
934
|
})
|
|
912
935
|
}),
|
|
913
|
-
/* @__PURE__ */
|
|
936
|
+
/* @__PURE__ */ jsx18("div", {
|
|
914
937
|
ref: tableContainerRef,
|
|
915
938
|
className: "--table-container",
|
|
916
|
-
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */
|
|
939
|
+
children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
|
|
917
940
|
containerRef: tableContainerRef,
|
|
918
941
|
table,
|
|
919
|
-
|
|
942
|
+
rowConfig,
|
|
920
943
|
isLoading,
|
|
921
944
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
922
|
-
}) : /* @__PURE__ */
|
|
945
|
+
}) : /* @__PURE__ */ jsx18(BasicTable, {
|
|
923
946
|
table,
|
|
924
|
-
|
|
947
|
+
rowConfig,
|
|
925
948
|
isLoading,
|
|
926
949
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
927
950
|
})
|
|
@@ -932,9 +955,9 @@ function DataTable({
|
|
|
932
955
|
|
|
933
956
|
// src/DataTable/Provider.tsx
|
|
934
957
|
import { Provider } from "jotai";
|
|
935
|
-
import { jsx as
|
|
958
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
936
959
|
function DataTableProvider({ children, ...props }) {
|
|
937
|
-
return /* @__PURE__ */
|
|
960
|
+
return /* @__PURE__ */ jsx19(Provider, {
|
|
938
961
|
...props,
|
|
939
962
|
children
|
|
940
963
|
});
|