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