@equinor/apollo-components 1.12.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +68 -80
- package/dist/index.js +338 -335
- package/dist/index.mjs +340 -333
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -310,12 +310,11 @@ var CellWrapper2 = styled8.div`
|
|
|
310
310
|
margin-left: -16px;
|
|
311
311
|
z-index: 2;
|
|
312
312
|
`;
|
|
313
|
-
function SelectColumnDef(props
|
|
314
|
-
const selectionMode = props.
|
|
315
|
-
const showBothSelectAndSubRowsToggle = props.hideExpandControls === false;
|
|
313
|
+
function SelectColumnDef(props) {
|
|
314
|
+
const selectionMode = props.mode;
|
|
316
315
|
return {
|
|
317
316
|
id: "select",
|
|
318
|
-
size:
|
|
317
|
+
size: props.includeExpansionButton ? 96 : 48,
|
|
319
318
|
header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ jsx7(CellWrapper2, {
|
|
320
319
|
children: /* @__PURE__ */ jsx7(Checkbox, {
|
|
321
320
|
checked: table.getIsAllRowsSelected(),
|
|
@@ -358,55 +357,142 @@ function SelectColumnDef(props = {}) {
|
|
|
358
357
|
};
|
|
359
358
|
}
|
|
360
359
|
|
|
361
|
-
// src/DataTable/
|
|
362
|
-
import {
|
|
363
|
-
import
|
|
360
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
361
|
+
import { Button as Button3, Checkbox as Checkbox2, Divider, Icon as Icon4, Popover, Tooltip } from "@equinor/eds-core-react";
|
|
362
|
+
import { close, view_column } from "@equinor/eds-icons";
|
|
363
|
+
import { useRef, useState as useState2 } from "react";
|
|
364
|
+
import styled9 from "styled-components";
|
|
364
365
|
|
|
365
|
-
// src/DataTable/
|
|
366
|
-
|
|
366
|
+
// src/DataTable/utils.tsx
|
|
367
|
+
function capitalizeHeader(context) {
|
|
368
|
+
const header = context.header.id;
|
|
369
|
+
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
370
|
+
}
|
|
371
|
+
function enableOrUndefined(enabled, value) {
|
|
372
|
+
return Boolean(enabled) ? value : void 0;
|
|
373
|
+
}
|
|
374
|
+
function getColumnHeader(column) {
|
|
375
|
+
const columnHeader = column.columnDef.header;
|
|
376
|
+
if (!columnHeader)
|
|
377
|
+
return column.id;
|
|
378
|
+
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
379
|
+
}
|
|
380
|
+
function prependSelectColumn(columns, config) {
|
|
381
|
+
if (!(config == null ? void 0 : config.selectColumn))
|
|
382
|
+
return columns;
|
|
383
|
+
if (config.selectColumn === "default")
|
|
384
|
+
return [SelectColumnDef(config), ...columns];
|
|
385
|
+
return [config.selectColumn(), ...columns];
|
|
386
|
+
}
|
|
387
|
+
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
388
|
+
if (valueOrFn === void 0)
|
|
389
|
+
return defaultValue;
|
|
390
|
+
if (typeof valueOrFn === "function")
|
|
391
|
+
return valueOrFn(fnProps);
|
|
392
|
+
return valueOrFn;
|
|
393
|
+
}
|
|
367
394
|
|
|
368
|
-
// src/DataTable/components/
|
|
369
|
-
import {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
395
|
+
// src/DataTable/components/ColumnSelect.tsx
|
|
396
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
397
|
+
var ColumnSelectContent = styled9.div`
|
|
398
|
+
display: grid;
|
|
399
|
+
grid-template-columns: repeat(2, 1fr);
|
|
400
|
+
grid-gap: 0.5rem;
|
|
401
|
+
`;
|
|
402
|
+
var ActionsWrapper = styled9.div`
|
|
373
403
|
display: flex;
|
|
374
|
-
|
|
404
|
+
align-items: center;
|
|
405
|
+
justify-content: flex-end;
|
|
406
|
+
gap: 0.5rem;
|
|
375
407
|
`;
|
|
376
|
-
function
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
408
|
+
function ColumnSelect({ table }) {
|
|
409
|
+
const [isOpen, setIsOpen] = useState2(false);
|
|
410
|
+
const referenceElement = useRef(null);
|
|
411
|
+
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
412
|
+
return /* @__PURE__ */ jsxs5(Fragment2, {
|
|
413
|
+
children: [
|
|
414
|
+
/* @__PURE__ */ jsx8(Tooltip, {
|
|
415
|
+
title: "Select columns",
|
|
416
|
+
placement: "left",
|
|
417
|
+
children: /* @__PURE__ */ jsx8(Button3, {
|
|
418
|
+
"aria-haspopup": true,
|
|
419
|
+
id: "column-select-anchor",
|
|
420
|
+
"aria-controls": "column-select-popover",
|
|
421
|
+
"aria-expanded": isOpen,
|
|
422
|
+
ref: referenceElement,
|
|
423
|
+
variant: "ghost_icon",
|
|
424
|
+
onClick: () => setIsOpen(true),
|
|
425
|
+
children: /* @__PURE__ */ jsx8(Icon4, {
|
|
426
|
+
name: "view_column",
|
|
427
|
+
data: view_column
|
|
428
|
+
})
|
|
385
429
|
})
|
|
430
|
+
}),
|
|
431
|
+
/* @__PURE__ */ jsxs5(Popover, {
|
|
432
|
+
open: isOpen,
|
|
433
|
+
id: "column-select-popover",
|
|
434
|
+
anchorEl: referenceElement.current,
|
|
435
|
+
placement: "bottom-end",
|
|
436
|
+
onClose: () => setIsOpen(false),
|
|
437
|
+
children: [
|
|
438
|
+
/* @__PURE__ */ jsxs5(Popover.Header, {
|
|
439
|
+
children: [
|
|
440
|
+
/* @__PURE__ */ jsx8(Popover.Title, {
|
|
441
|
+
children: "Column settings"
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx8(Button3, {
|
|
444
|
+
variant: "ghost_icon",
|
|
445
|
+
"aria-label": "Close column select",
|
|
446
|
+
onClick: () => setIsOpen(false),
|
|
447
|
+
children: /* @__PURE__ */ jsx8(Icon4, {
|
|
448
|
+
name: "close",
|
|
449
|
+
data: close,
|
|
450
|
+
size: 24
|
|
451
|
+
})
|
|
452
|
+
})
|
|
453
|
+
]
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsxs5(Popover.Content, {
|
|
456
|
+
children: [
|
|
457
|
+
/* @__PURE__ */ jsx8(ColumnSelectContent, {
|
|
458
|
+
children: selectableColumns.map((column) => {
|
|
459
|
+
return /* @__PURE__ */ jsx8(Checkbox2, {
|
|
460
|
+
checked: column.getIsVisible(),
|
|
461
|
+
label: getColumnHeader(column),
|
|
462
|
+
onChange: column.getToggleVisibilityHandler()
|
|
463
|
+
}, column.id);
|
|
464
|
+
})
|
|
465
|
+
}),
|
|
466
|
+
/* @__PURE__ */ jsx8(Divider, {
|
|
467
|
+
variant: "small"
|
|
468
|
+
}),
|
|
469
|
+
/* @__PURE__ */ jsx8(ActionsWrapper, {
|
|
470
|
+
children: /* @__PURE__ */ jsx8(Button3, {
|
|
471
|
+
color: "secondary",
|
|
472
|
+
variant: "ghost",
|
|
473
|
+
disabled: table.getIsAllColumnsVisible(),
|
|
474
|
+
onClick: () => table.toggleAllColumnsVisible(true),
|
|
475
|
+
children: "Reset to default"
|
|
476
|
+
})
|
|
477
|
+
})
|
|
478
|
+
]
|
|
479
|
+
})
|
|
480
|
+
]
|
|
386
481
|
})
|
|
387
|
-
|
|
482
|
+
]
|
|
388
483
|
});
|
|
389
484
|
}
|
|
390
485
|
|
|
391
|
-
// src/DataTable/components/TableBody.tsx
|
|
392
|
-
import { Table as Table4 } from "@equinor/eds-core-react";
|
|
393
|
-
import styled10 from "styled-components";
|
|
394
|
-
var TableBody = styled10(Table4.Body)`
|
|
395
|
-
// The following attribute are important for fixed column width
|
|
396
|
-
// CHANGE THES WITH CAUTION
|
|
397
|
-
background: inherit;
|
|
398
|
-
`;
|
|
399
|
-
|
|
400
486
|
// src/DataTable/components/TableHeader.tsx
|
|
401
|
-
import { Table as
|
|
487
|
+
import { Table as Table4 } from "@equinor/eds-core-react";
|
|
402
488
|
|
|
403
489
|
// src/cells/HeaderCell.tsx
|
|
404
|
-
import { Icon as
|
|
490
|
+
import { Icon as Icon5, Table as Table3 } from "@equinor/eds-core-react";
|
|
405
491
|
import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
|
|
406
492
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
407
|
-
import
|
|
408
|
-
import { jsx as jsx9, jsxs as
|
|
409
|
-
var HeaderDiv =
|
|
493
|
+
import styled10 from "styled-components";
|
|
494
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
495
|
+
var HeaderDiv = styled10.div`
|
|
410
496
|
display: flex;
|
|
411
497
|
align-items: center;
|
|
412
498
|
gap: 0.25rem;
|
|
@@ -432,7 +518,7 @@ var HeaderCell = ({ header }) => {
|
|
|
432
518
|
})
|
|
433
519
|
}, header.id);
|
|
434
520
|
}
|
|
435
|
-
return /* @__PURE__ */ jsx9(
|
|
521
|
+
return /* @__PURE__ */ jsx9(Table3.Cell, {
|
|
436
522
|
...cellProps,
|
|
437
523
|
children: /* @__PURE__ */ jsx9(HeaderContent, {
|
|
438
524
|
header
|
|
@@ -442,17 +528,17 @@ var HeaderCell = ({ header }) => {
|
|
|
442
528
|
function HeaderContent({ header }) {
|
|
443
529
|
if (header.isPlaceholder)
|
|
444
530
|
return null;
|
|
445
|
-
return /* @__PURE__ */
|
|
531
|
+
return /* @__PURE__ */ jsxs6(HeaderDiv, {
|
|
446
532
|
children: [
|
|
447
533
|
flexRender2(header.column.columnDef.header, header.getContext()),
|
|
448
534
|
{
|
|
449
|
-
asc: /* @__PURE__ */ jsx9(
|
|
535
|
+
asc: /* @__PURE__ */ jsx9(Icon5, {
|
|
450
536
|
data: arrow_drop_up
|
|
451
537
|
}),
|
|
452
|
-
desc: /* @__PURE__ */ jsx9(
|
|
538
|
+
desc: /* @__PURE__ */ jsx9(Icon5, {
|
|
453
539
|
data: arrow_drop_down
|
|
454
540
|
}),
|
|
455
|
-
none: /* @__PURE__ */ jsx9(
|
|
541
|
+
none: /* @__PURE__ */ jsx9(Icon5, {
|
|
456
542
|
data: arrow_drop_down
|
|
457
543
|
})
|
|
458
544
|
}[header.column.getIsSorted()] ?? null
|
|
@@ -475,9 +561,9 @@ function getSort({ column }) {
|
|
|
475
561
|
// src/DataTable/components/TableHeader.tsx
|
|
476
562
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
477
563
|
function TableHeader({ table, sticky }) {
|
|
478
|
-
return /* @__PURE__ */ jsx10(
|
|
564
|
+
return /* @__PURE__ */ jsx10(Table4.Head, {
|
|
479
565
|
sticky,
|
|
480
|
-
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(
|
|
566
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(Table4.Row, {
|
|
481
567
|
children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx10(HeaderCell, {
|
|
482
568
|
header
|
|
483
569
|
}, header.id))
|
|
@@ -485,14 +571,60 @@ function TableHeader({ table, sticky }) {
|
|
|
485
571
|
});
|
|
486
572
|
}
|
|
487
573
|
|
|
574
|
+
// src/DataTable/DataTable.tsx
|
|
575
|
+
import {
|
|
576
|
+
getCoreRowModel,
|
|
577
|
+
getExpandedRowModel,
|
|
578
|
+
getFilteredRowModel,
|
|
579
|
+
getSortedRowModel,
|
|
580
|
+
useReactTable
|
|
581
|
+
} from "@tanstack/react-table";
|
|
582
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
583
|
+
import styled16 from "styled-components";
|
|
584
|
+
|
|
585
|
+
// src/DataTable/components/BasicTable.tsx
|
|
586
|
+
import { Table as EdsTable } from "@equinor/eds-core-react";
|
|
587
|
+
|
|
588
|
+
// src/DataTable/components/PlaceholderRow.tsx
|
|
589
|
+
import { DotProgress, Table as Table5, Typography } from "@equinor/eds-core-react";
|
|
590
|
+
import styled11 from "styled-components";
|
|
591
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
592
|
+
var PlaceholderTextWrapper = styled11.div`
|
|
593
|
+
display: flex;
|
|
594
|
+
justify-content: center;
|
|
595
|
+
`;
|
|
596
|
+
function PlaceholderRow({ isLoading }) {
|
|
597
|
+
return /* @__PURE__ */ jsx11(Table5.Row, {
|
|
598
|
+
children: /* @__PURE__ */ jsx11(Table5.Cell, {
|
|
599
|
+
colSpan: 100,
|
|
600
|
+
children: /* @__PURE__ */ jsx11(PlaceholderTextWrapper, {
|
|
601
|
+
children: isLoading ? /* @__PURE__ */ jsx11(DotProgress, {
|
|
602
|
+
color: "primary"
|
|
603
|
+
}) : /* @__PURE__ */ jsx11(Typography, {
|
|
604
|
+
children: "No data available"
|
|
605
|
+
})
|
|
606
|
+
})
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/DataTable/components/TableBody.tsx
|
|
612
|
+
import { Table as Table6 } from "@equinor/eds-core-react";
|
|
613
|
+
import styled12 from "styled-components";
|
|
614
|
+
var TableBody = styled12(Table6.Body)`
|
|
615
|
+
// The following attribute are important for fixed column width
|
|
616
|
+
// CHANGE THES WITH CAUTION
|
|
617
|
+
background: inherit;
|
|
618
|
+
`;
|
|
619
|
+
|
|
488
620
|
// src/DataTable/components/TableRow.tsx
|
|
489
621
|
import { Table as Table7 } from "@equinor/eds-core-react";
|
|
490
|
-
import
|
|
491
|
-
import { jsx as
|
|
622
|
+
import styled13 from "styled-components";
|
|
623
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
492
624
|
function TableRow({ row, rowConfig, cellConfig }) {
|
|
493
625
|
var _a;
|
|
494
626
|
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
495
|
-
const tableRowContent = /* @__PURE__ */
|
|
627
|
+
const tableRowContent = /* @__PURE__ */ jsx12(StyledTableRow, {
|
|
496
628
|
active: row.getIsSelected(),
|
|
497
629
|
style: {
|
|
498
630
|
cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
|
|
@@ -506,7 +638,7 @@ function TableRow({ row, rowConfig, cellConfig }) {
|
|
|
506
638
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
507
639
|
children: row.getVisibleCells().map((cell) => {
|
|
508
640
|
var _a2;
|
|
509
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ jsx12(DynamicCell, {
|
|
510
642
|
cell,
|
|
511
643
|
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
512
644
|
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
@@ -515,7 +647,7 @@ function TableRow({ row, rowConfig, cellConfig }) {
|
|
|
515
647
|
});
|
|
516
648
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
517
649
|
}
|
|
518
|
-
var StyledTableRow =
|
|
650
|
+
var StyledTableRow = styled13(Table7.Row)`
|
|
519
651
|
/* Background color must be inherited here. Does not work with inline styling */
|
|
520
652
|
${({ active }) => active ? "" : "background-color: inherit;"}
|
|
521
653
|
`;
|
|
@@ -528,27 +660,32 @@ function handleRowEvent(row, handler) {
|
|
|
528
660
|
}
|
|
529
661
|
|
|
530
662
|
// src/DataTable/components/BasicTable.tsx
|
|
531
|
-
import { jsx as
|
|
663
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
532
664
|
function BasicTable({
|
|
533
665
|
table,
|
|
534
666
|
rowConfig,
|
|
535
667
|
cellConfig,
|
|
536
668
|
stickyHeader,
|
|
537
|
-
isLoading
|
|
669
|
+
isLoading,
|
|
670
|
+
tableCaption
|
|
538
671
|
}) {
|
|
539
672
|
const tableRows = table.getRowModel().rows;
|
|
540
|
-
return /* @__PURE__ */
|
|
673
|
+
return /* @__PURE__ */ jsxs7(EdsTable, {
|
|
541
674
|
children: [
|
|
542
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ jsx13(EdsTable.Caption, {
|
|
676
|
+
hidden: true,
|
|
677
|
+
children: tableCaption
|
|
678
|
+
}),
|
|
679
|
+
/* @__PURE__ */ jsx13(TableHeader, {
|
|
543
680
|
sticky: stickyHeader,
|
|
544
681
|
table
|
|
545
682
|
}),
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */
|
|
683
|
+
/* @__PURE__ */ jsx13(TableBody, {
|
|
684
|
+
children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx13(TableRow, {
|
|
548
685
|
row,
|
|
549
686
|
rowConfig,
|
|
550
687
|
cellConfig
|
|
551
|
-
}, row.id)) : /* @__PURE__ */
|
|
688
|
+
}, row.id)) : /* @__PURE__ */ jsx13(PlaceholderRow, {
|
|
552
689
|
isLoading
|
|
553
690
|
})
|
|
554
691
|
})
|
|
@@ -559,27 +696,18 @@ function BasicTable({
|
|
|
559
696
|
// src/DataTable/components/DataTableHeader.tsx
|
|
560
697
|
import { Typography as Typography2 } from "@equinor/eds-core-react";
|
|
561
698
|
import { search } from "@equinor/eds-icons";
|
|
562
|
-
import { useAtom } from "jotai";
|
|
563
699
|
import styled15 from "styled-components";
|
|
564
700
|
|
|
565
|
-
// src/DataTable/atoms.ts
|
|
566
|
-
import { atom } from "jotai";
|
|
567
|
-
var columnVisibilityAtom = atom({});
|
|
568
|
-
var globalFilterAtom = atom("");
|
|
569
|
-
var rowSelectionAtom = atom({});
|
|
570
|
-
var tableSortingAtom = atom([]);
|
|
571
|
-
var expandedRowsAtom = atom({});
|
|
572
|
-
|
|
573
701
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
574
|
-
import { Button as
|
|
575
|
-
import { close } from "@equinor/eds-icons";
|
|
576
|
-
import { useEffect, useState as
|
|
577
|
-
import
|
|
578
|
-
import { jsx as
|
|
579
|
-
var Wrapper3 =
|
|
702
|
+
import { Button as Button4, Icon as Icon6, Input, Tooltip as Tooltip2 } from "@equinor/eds-core-react";
|
|
703
|
+
import { close as close2 } from "@equinor/eds-icons";
|
|
704
|
+
import { useEffect, useState as useState3 } from "react";
|
|
705
|
+
import styled14 from "styled-components";
|
|
706
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
707
|
+
var Wrapper3 = styled14.div`
|
|
580
708
|
width: 200px;
|
|
581
709
|
`;
|
|
582
|
-
var CloseButton =
|
|
710
|
+
var CloseButton = styled14(Button4)`
|
|
583
711
|
width: 24px;
|
|
584
712
|
height: 24px;
|
|
585
713
|
`;
|
|
@@ -590,7 +718,7 @@ function DebouncedInput({
|
|
|
590
718
|
debounce = 500,
|
|
591
719
|
...props
|
|
592
720
|
}) {
|
|
593
|
-
const [value, setValue] =
|
|
721
|
+
const [value, setValue] = useState3(initialValue);
|
|
594
722
|
useEffect(() => {
|
|
595
723
|
setValue(initialValue);
|
|
596
724
|
}, [initialValue]);
|
|
@@ -600,23 +728,23 @@ function DebouncedInput({
|
|
|
600
728
|
}, debounce);
|
|
601
729
|
return () => clearTimeout(timeout);
|
|
602
730
|
}, [value]);
|
|
603
|
-
return /* @__PURE__ */
|
|
604
|
-
children: /* @__PURE__ */
|
|
731
|
+
return /* @__PURE__ */ jsx14(Wrapper3, {
|
|
732
|
+
children: /* @__PURE__ */ jsx14(Input, {
|
|
605
733
|
...props,
|
|
606
734
|
value,
|
|
607
|
-
leftAdornments: icon && /* @__PURE__ */
|
|
735
|
+
leftAdornments: icon && /* @__PURE__ */ jsx14(Icon6, {
|
|
608
736
|
name: icon.name,
|
|
609
737
|
data: icon,
|
|
610
738
|
size: 18
|
|
611
739
|
}),
|
|
612
|
-
rightAdornments: !!value && /* @__PURE__ */
|
|
740
|
+
rightAdornments: !!value && /* @__PURE__ */ jsx14(Tooltip2, {
|
|
613
741
|
title: "Clear input",
|
|
614
|
-
children: /* @__PURE__ */
|
|
742
|
+
children: /* @__PURE__ */ jsx14(CloseButton, {
|
|
615
743
|
variant: "ghost_icon",
|
|
616
744
|
onClick: () => setValue(""),
|
|
617
|
-
children: /* @__PURE__ */
|
|
618
|
-
name:
|
|
619
|
-
data:
|
|
745
|
+
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
746
|
+
name: close2.name,
|
|
747
|
+
data: close2,
|
|
620
748
|
size: 18
|
|
621
749
|
})
|
|
622
750
|
})
|
|
@@ -636,128 +764,6 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
636
764
|
return itemRank.passed;
|
|
637
765
|
};
|
|
638
766
|
|
|
639
|
-
// src/DataTable/components/ColumnSelect.tsx
|
|
640
|
-
import { Button as Button4, Checkbox as Checkbox2, Divider, Icon as Icon6, Popover } from "@equinor/eds-core-react";
|
|
641
|
-
import { close as close2, view_column } from "@equinor/eds-icons";
|
|
642
|
-
import { useRef, useState as useState3 } from "react";
|
|
643
|
-
import styled14 from "styled-components";
|
|
644
|
-
|
|
645
|
-
// src/DataTable/utils.tsx
|
|
646
|
-
function capitalizeHeader(context) {
|
|
647
|
-
const header = context.header.id;
|
|
648
|
-
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
649
|
-
}
|
|
650
|
-
function enableOrUndefined(enabled, value) {
|
|
651
|
-
return Boolean(enabled) ? value : void 0;
|
|
652
|
-
}
|
|
653
|
-
function getColumnHeader(column) {
|
|
654
|
-
const columnHeader = column.columnDef.header;
|
|
655
|
-
if (!columnHeader)
|
|
656
|
-
return column.id;
|
|
657
|
-
return typeof columnHeader === "string" ? columnHeader : column.id;
|
|
658
|
-
}
|
|
659
|
-
function prependSelectColumn(columns, config) {
|
|
660
|
-
if (!(config == null ? void 0 : config.selectColumn))
|
|
661
|
-
return columns;
|
|
662
|
-
if (config.selectColumn === "default")
|
|
663
|
-
return [SelectColumnDef(config), ...columns];
|
|
664
|
-
return [config.selectColumn(), ...columns];
|
|
665
|
-
}
|
|
666
|
-
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
667
|
-
if (valueOrFn === void 0)
|
|
668
|
-
return defaultValue;
|
|
669
|
-
if (typeof valueOrFn === "function")
|
|
670
|
-
return valueOrFn(fnProps);
|
|
671
|
-
return valueOrFn;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
// src/DataTable/components/ColumnSelect.tsx
|
|
675
|
-
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
676
|
-
var ColumnSelectContent = styled14.div`
|
|
677
|
-
display: grid;
|
|
678
|
-
grid-template-columns: repeat(2, 1fr);
|
|
679
|
-
grid-gap: 0.5rem;
|
|
680
|
-
`;
|
|
681
|
-
var ActionsWrapper = styled14.div`
|
|
682
|
-
display: flex;
|
|
683
|
-
align-items: center;
|
|
684
|
-
justify-content: flex-end;
|
|
685
|
-
gap: 0.5rem;
|
|
686
|
-
`;
|
|
687
|
-
function ColumnSelect({ table }) {
|
|
688
|
-
const [isOpen, setIsOpen] = useState3(false);
|
|
689
|
-
const referenceElement = useRef(null);
|
|
690
|
-
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
691
|
-
return /* @__PURE__ */ jsxs7(Fragment2, {
|
|
692
|
-
children: [
|
|
693
|
-
/* @__PURE__ */ jsx14(Button4, {
|
|
694
|
-
"aria-haspopup": true,
|
|
695
|
-
id: "column-select-anchor",
|
|
696
|
-
"aria-controls": "column-select-popover",
|
|
697
|
-
"aria-expanded": isOpen,
|
|
698
|
-
ref: referenceElement,
|
|
699
|
-
variant: "ghost_icon",
|
|
700
|
-
onClick: () => setIsOpen(true),
|
|
701
|
-
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
702
|
-
name: "view_column",
|
|
703
|
-
data: view_column
|
|
704
|
-
})
|
|
705
|
-
}),
|
|
706
|
-
/* @__PURE__ */ jsxs7(Popover, {
|
|
707
|
-
open: isOpen,
|
|
708
|
-
id: "column-select-popover",
|
|
709
|
-
anchorEl: referenceElement.current,
|
|
710
|
-
placement: "bottom-end",
|
|
711
|
-
onClose: () => setIsOpen(false),
|
|
712
|
-
children: [
|
|
713
|
-
/* @__PURE__ */ jsxs7(Popover.Header, {
|
|
714
|
-
children: [
|
|
715
|
-
/* @__PURE__ */ jsx14(Popover.Title, {
|
|
716
|
-
children: "Column settings"
|
|
717
|
-
}),
|
|
718
|
-
/* @__PURE__ */ jsx14(Button4, {
|
|
719
|
-
variant: "ghost_icon",
|
|
720
|
-
"aria-label": "Close column select",
|
|
721
|
-
onClick: () => setIsOpen(false),
|
|
722
|
-
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
723
|
-
name: "close",
|
|
724
|
-
data: close2,
|
|
725
|
-
size: 24
|
|
726
|
-
})
|
|
727
|
-
})
|
|
728
|
-
]
|
|
729
|
-
}),
|
|
730
|
-
/* @__PURE__ */ jsxs7(Popover.Content, {
|
|
731
|
-
children: [
|
|
732
|
-
/* @__PURE__ */ jsx14(ColumnSelectContent, {
|
|
733
|
-
children: selectableColumns.map((column) => {
|
|
734
|
-
return /* @__PURE__ */ jsx14(Checkbox2, {
|
|
735
|
-
checked: column.getIsVisible(),
|
|
736
|
-
label: getColumnHeader(column),
|
|
737
|
-
onChange: column.getToggleVisibilityHandler()
|
|
738
|
-
}, column.id);
|
|
739
|
-
})
|
|
740
|
-
}),
|
|
741
|
-
/* @__PURE__ */ jsx14(Divider, {
|
|
742
|
-
variant: "small"
|
|
743
|
-
}),
|
|
744
|
-
/* @__PURE__ */ jsx14(ActionsWrapper, {
|
|
745
|
-
children: /* @__PURE__ */ jsx14(Button4, {
|
|
746
|
-
color: "secondary",
|
|
747
|
-
variant: "ghost",
|
|
748
|
-
disabled: table.getIsAllColumnsVisible(),
|
|
749
|
-
onClick: () => table.toggleAllColumnsVisible(true),
|
|
750
|
-
children: "Reset to default"
|
|
751
|
-
})
|
|
752
|
-
})
|
|
753
|
-
]
|
|
754
|
-
})
|
|
755
|
-
]
|
|
756
|
-
})
|
|
757
|
-
]
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
|
|
761
767
|
// src/DataTable/components/DataTableHeader.tsx
|
|
762
768
|
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
763
769
|
var DataTableHeaderWrapper = styled15.div`
|
|
@@ -765,7 +771,7 @@ var DataTableHeaderWrapper = styled15.div`
|
|
|
765
771
|
align-items: center;
|
|
766
772
|
justify-content: space-between;
|
|
767
773
|
gap: 0.5rem;
|
|
768
|
-
padding:
|
|
774
|
+
padding: 1rem;
|
|
769
775
|
`;
|
|
770
776
|
var FilterContainer = styled15.div`
|
|
771
777
|
display: flex;
|
|
@@ -773,30 +779,47 @@ var FilterContainer = styled15.div`
|
|
|
773
779
|
gap: 1rem;
|
|
774
780
|
justify-content: flex-end;
|
|
775
781
|
`;
|
|
776
|
-
function
|
|
782
|
+
function ActionsHeaderRow({
|
|
783
|
+
table,
|
|
784
|
+
actionsRow,
|
|
785
|
+
tableCaption,
|
|
786
|
+
globalFilter
|
|
787
|
+
}) {
|
|
777
788
|
var _a;
|
|
778
|
-
const [globalFilter, setGlobalFilter] = useAtom(globalFilterAtom);
|
|
779
789
|
return /* @__PURE__ */ jsxs8(DataTableHeaderWrapper, {
|
|
780
790
|
className: "--table-caption",
|
|
781
|
-
captionPadding: props.captionPadding,
|
|
782
791
|
children: [
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
children:
|
|
792
|
+
/* @__PURE__ */ jsxs8(FilterContainer, {
|
|
793
|
+
className: "--filter-container-left",
|
|
794
|
+
children: [
|
|
795
|
+
(actionsRow == null ? void 0 : actionsRow.enableTableCaption) && /* @__PURE__ */ jsx15(Typography2, {
|
|
796
|
+
variant: "h3",
|
|
797
|
+
children: tableCaption
|
|
798
|
+
}),
|
|
799
|
+
(_a = actionsRow == null ? void 0 : actionsRow.customActions) == null ? void 0 : _a.call(actionsRow, table)
|
|
800
|
+
]
|
|
786
801
|
}),
|
|
787
802
|
/* @__PURE__ */ jsx15(FilterContainer, {
|
|
788
|
-
className: "--filter-container",
|
|
803
|
+
className: "--filter-container-right",
|
|
789
804
|
children: /* @__PURE__ */ jsxs8(Fragment3, {
|
|
790
805
|
children: [
|
|
791
|
-
(
|
|
792
|
-
value: globalFilter,
|
|
806
|
+
(actionsRow == null ? void 0 : actionsRow.enableGlobalFilterInput) && /* @__PURE__ */ jsx15(DebouncedInput, {
|
|
807
|
+
value: globalFilter.state,
|
|
793
808
|
icon: search,
|
|
794
|
-
placeholder:
|
|
795
|
-
onChange: (value) =>
|
|
809
|
+
placeholder: actionsRow.globalFilterPlaceholder ?? "Search all columns",
|
|
810
|
+
onChange: (value) => globalFilter.onChange(String(value))
|
|
796
811
|
}),
|
|
797
|
-
(
|
|
798
|
-
(config == null ? void 0 : config.columnSelect) && /* @__PURE__ */ jsx15(ColumnSelect, {
|
|
812
|
+
(actionsRow == null ? void 0 : actionsRow.enableColumnSelect) && /* @__PURE__ */ jsx15(ColumnSelect, {
|
|
799
813
|
table
|
|
814
|
+
}),
|
|
815
|
+
(actionsRow == null ? void 0 : actionsRow.totalRowCount) && /* @__PURE__ */ jsxs8("span", {
|
|
816
|
+
children: [
|
|
817
|
+
table.options.data.length.toLocaleString(),
|
|
818
|
+
" /",
|
|
819
|
+
" ",
|
|
820
|
+
actionsRow.totalRowCount.toLocaleString(),
|
|
821
|
+
" rows"
|
|
822
|
+
]
|
|
800
823
|
})
|
|
801
824
|
]
|
|
802
825
|
})
|
|
@@ -844,6 +867,10 @@ function VirtualTable({
|
|
|
844
867
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
845
868
|
return /* @__PURE__ */ jsxs9(Table9, {
|
|
846
869
|
children: [
|
|
870
|
+
/* @__PURE__ */ jsx17(Table9.Caption, {
|
|
871
|
+
hidden: true,
|
|
872
|
+
children: props.tableCaption
|
|
873
|
+
}),
|
|
847
874
|
/* @__PURE__ */ jsx17(TableHeader, {
|
|
848
875
|
sticky: props.stickyHeader,
|
|
849
876
|
table
|
|
@@ -901,7 +928,7 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
|
901
928
|
return onTableContainerScroll;
|
|
902
929
|
}
|
|
903
930
|
|
|
904
|
-
// src/DataTable/
|
|
931
|
+
// src/DataTable/DataTable.tsx
|
|
905
932
|
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
906
933
|
var DataTableWrapper = styled16.div`
|
|
907
934
|
width: ${(props) => props.width ?? "100%"};
|
|
@@ -920,30 +947,103 @@ var DataTableWrapper = styled16.div`
|
|
|
920
947
|
}
|
|
921
948
|
}
|
|
922
949
|
`;
|
|
923
|
-
function
|
|
924
|
-
var _a, _b;
|
|
925
|
-
const {
|
|
950
|
+
function DataTable(props) {
|
|
951
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
952
|
+
const { columns, data, actionsRow, cellConfig, sorting } = props;
|
|
953
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = useState4({});
|
|
954
|
+
const [columnVisibility, setColumnVisibility] = [
|
|
955
|
+
((_a = props.columnVisibility) == null ? void 0 : _a.state) ?? internalColumnVisibility,
|
|
956
|
+
((_b = props.columnVisibility) == null ? void 0 : _b.onChange) ?? setInternalColumnVisibility
|
|
957
|
+
];
|
|
958
|
+
const [internalGlobalFilterState, setInternalGlobalFilterState] = useState4("");
|
|
959
|
+
const [globalFilterState, setGlobalFilterState] = [
|
|
960
|
+
((_c = props.globalFilter) == null ? void 0 : _c.state) ?? internalGlobalFilterState,
|
|
961
|
+
((_d = props.globalFilter) == null ? void 0 : _d.onChange) ?? setInternalGlobalFilterState
|
|
962
|
+
];
|
|
963
|
+
const shouldEnableGlobalFilter = ((_e = props.actionsRow) == null ? void 0 : _e.enableGlobalFilterInput) || Boolean(props.globalFilter);
|
|
964
|
+
function enableGlobalFilter(value) {
|
|
965
|
+
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
966
|
+
}
|
|
967
|
+
const [internalSortingState, setInternalSortingState] = useState4([]);
|
|
968
|
+
const [sortingState, setSortingState] = [
|
|
969
|
+
((_f = props.sorting) == null ? void 0 : _f.state) ?? internalSortingState,
|
|
970
|
+
((_g = props.sorting) == null ? void 0 : _g.onChange) ?? setInternalSortingState
|
|
971
|
+
];
|
|
972
|
+
const [internalRowSelectionState, setInternalRowSelectionState] = useState4({});
|
|
973
|
+
const [rowSelectionState, setRowSelectionState] = [
|
|
974
|
+
((_h = props.rowSelection) == null ? void 0 : _h.state) ?? internalRowSelectionState,
|
|
975
|
+
((_i = props.rowSelection) == null ? void 0 : _i.onChange) ?? setInternalRowSelectionState
|
|
976
|
+
];
|
|
977
|
+
const [internalExpandedState, setInternalExpandedState] = useState4({});
|
|
978
|
+
const [expandedState, setExpandedState] = [
|
|
979
|
+
((_j = props.expansion) == null ? void 0 : _j.state) ?? internalExpandedState,
|
|
980
|
+
((_k = props.expansion) == null ? void 0 : _k.onChange) ?? setInternalExpandedState
|
|
981
|
+
];
|
|
982
|
+
const table = useReactTable({
|
|
983
|
+
columns: prependSelectColumn(columns, props.rowSelection),
|
|
984
|
+
data,
|
|
985
|
+
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
986
|
+
state: {
|
|
987
|
+
expanded: expandedState,
|
|
988
|
+
globalFilter: enableGlobalFilter(globalFilterState),
|
|
989
|
+
sorting: ((_l = props.sorting) == null ? void 0 : _l.enableSorting) ? ((_m = props.sorting) == null ? void 0 : _m.state) ?? sortingState : void 0,
|
|
990
|
+
rowSelection: rowSelectionState,
|
|
991
|
+
columnVisibility
|
|
992
|
+
},
|
|
993
|
+
defaultColumn: {
|
|
994
|
+
cell: ({ cell }) => {
|
|
995
|
+
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
996
|
+
return /* @__PURE__ */ jsx18(TypographyCustom, {
|
|
997
|
+
truncate: truncateMode === "hover",
|
|
998
|
+
children: cell.getValue()
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
},
|
|
1002
|
+
enableSorting: sorting == null ? void 0 : sorting.enableSorting,
|
|
1003
|
+
manualSorting: sorting == null ? void 0 : sorting.manualSorting,
|
|
1004
|
+
enableExpanding: Boolean(props.expansion),
|
|
1005
|
+
enableMultiRowSelection: ((_n = props.rowSelection) == null ? void 0 : _n.mode) === "multiple",
|
|
1006
|
+
enableSubRowSelection: ((_o = props.rowSelection) == null ? void 0 : _o.mode) !== "single",
|
|
1007
|
+
filterFromLeafRows: actionsRow == null ? void 0 : actionsRow.filterFromLeafRows,
|
|
1008
|
+
getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
|
|
1009
|
+
getCoreRowModel: getCoreRowModel(),
|
|
1010
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
1011
|
+
getSortedRowModel: getSortedRowModel(),
|
|
1012
|
+
onExpandedChange: setExpandedState,
|
|
1013
|
+
onRowSelectionChange: setRowSelectionState,
|
|
1014
|
+
onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (sorting == null ? void 0 : sorting.onChange) ?? setSortingState : void 0,
|
|
1015
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
1016
|
+
onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
|
|
1017
|
+
getSubRows: props == null ? void 0 : props.getSubRows,
|
|
1018
|
+
getRowId: props == null ? void 0 : props.getRowId
|
|
1019
|
+
});
|
|
1020
|
+
useEffect3(() => {
|
|
1021
|
+
var _a2;
|
|
1022
|
+
if ((_a2 = props.expansion) == null ? void 0 : _a2.expandAllByDefault) {
|
|
1023
|
+
table.toggleAllRowsExpanded();
|
|
1024
|
+
}
|
|
1025
|
+
}, [table, (_p = props.expansion) == null ? void 0 : _p.expandAllByDefault]);
|
|
1026
|
+
const { isLoading, rowConfig } = props;
|
|
926
1027
|
const tableContainerRef = useRef2(null);
|
|
927
1028
|
const onTableContainerScroll = useFetchMoreOnBottomReached(
|
|
928
1029
|
tableContainerRef,
|
|
929
1030
|
props.infiniteScroll
|
|
930
1031
|
);
|
|
931
1032
|
return /* @__PURE__ */ jsxs10(DataTableWrapper, {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
tableLayout: config == null ? void 0 : config.tableLayout,
|
|
1033
|
+
height: props == null ? void 0 : props.height,
|
|
1034
|
+
width: props == null ? void 0 : props.width,
|
|
1035
|
+
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
936
1036
|
children: [
|
|
937
|
-
/* @__PURE__ */ jsx18(
|
|
938
|
-
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
939
|
-
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
1037
|
+
props.actionsRow && /* @__PURE__ */ jsx18(ActionsHeaderRow, {
|
|
940
1038
|
table,
|
|
941
|
-
|
|
1039
|
+
actionsRow: props.actionsRow,
|
|
1040
|
+
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
1041
|
+
tableCaption: props.tableCaption
|
|
942
1042
|
}),
|
|
943
1043
|
/* @__PURE__ */ jsx18("div", {
|
|
944
1044
|
...props.tableContainerProps,
|
|
945
|
-
className: "--table-container " + ((
|
|
946
|
-
onScroll: ((
|
|
1045
|
+
className: "--table-container " + ((_q = props.tableContainerProps) == null ? void 0 : _q.className),
|
|
1046
|
+
onScroll: ((_r = props.tableContainerProps) == null ? void 0 : _r.onScroll) ?? onTableContainerScroll,
|
|
947
1047
|
ref: (node) => {
|
|
948
1048
|
var _a2;
|
|
949
1049
|
if (node) {
|
|
@@ -953,121 +1053,32 @@ function DataTableRaw(props) {
|
|
|
953
1053
|
}
|
|
954
1054
|
}
|
|
955
1055
|
},
|
|
956
|
-
children: (
|
|
1056
|
+
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
|
|
957
1057
|
containerRef: tableContainerRef,
|
|
1058
|
+
tableCaption: props.tableCaption,
|
|
958
1059
|
table,
|
|
959
1060
|
rowConfig,
|
|
960
1061
|
cellConfig,
|
|
961
1062
|
isLoading,
|
|
962
|
-
stickyHeader:
|
|
1063
|
+
stickyHeader: (_s = props.headerConfig) == null ? void 0 : _s.sticky
|
|
963
1064
|
}) : /* @__PURE__ */ jsx18(BasicTable, {
|
|
1065
|
+
tableCaption: props.tableCaption,
|
|
964
1066
|
table,
|
|
965
1067
|
rowConfig,
|
|
966
1068
|
cellConfig,
|
|
967
1069
|
isLoading,
|
|
968
|
-
stickyHeader:
|
|
1070
|
+
stickyHeader: (_t = props.headerConfig) == null ? void 0 : _t.sticky
|
|
969
1071
|
})
|
|
970
1072
|
})
|
|
971
1073
|
]
|
|
972
1074
|
});
|
|
973
1075
|
}
|
|
974
|
-
|
|
975
|
-
// src/DataTable/useDataTable.tsx
|
|
976
|
-
import {
|
|
977
|
-
getCoreRowModel,
|
|
978
|
-
getExpandedRowModel,
|
|
979
|
-
getFilteredRowModel,
|
|
980
|
-
getSortedRowModel,
|
|
981
|
-
useReactTable
|
|
982
|
-
} from "@tanstack/react-table";
|
|
983
|
-
import { useAtom as useAtom2 } from "jotai";
|
|
984
|
-
import { useEffect as useEffect3 } from "react";
|
|
985
|
-
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
986
|
-
function useDataTable(props) {
|
|
987
|
-
const { columns, data, filters, config, cellConfig, sortConfig } = props;
|
|
988
|
-
const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
|
|
989
|
-
const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
|
|
990
|
-
const [sorting, setSorting] = useAtom2(tableSortingAtom);
|
|
991
|
-
const [rowSelectionState, setRowSelectionState] = useAtom2(rowSelectionAtom);
|
|
992
|
-
const [expanded, setExpanded] = useAtom2(expandedRowsAtom);
|
|
993
|
-
function enableGlobalFilter(value) {
|
|
994
|
-
return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
|
|
995
|
-
}
|
|
996
|
-
const table = useReactTable({
|
|
997
|
-
columns: prependSelectColumn(columns, config),
|
|
998
|
-
data,
|
|
999
|
-
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
1000
|
-
state: {
|
|
1001
|
-
expanded,
|
|
1002
|
-
globalFilter: enableGlobalFilter(globalFilter),
|
|
1003
|
-
sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
|
|
1004
|
-
rowSelection: rowSelectionState,
|
|
1005
|
-
columnVisibility
|
|
1006
|
-
},
|
|
1007
|
-
defaultColumn: {
|
|
1008
|
-
cell: ({ cell }) => {
|
|
1009
|
-
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
1010
|
-
return /* @__PURE__ */ jsx19(TypographyCustom, {
|
|
1011
|
-
truncate: truncateMode === "hover",
|
|
1012
|
-
children: cell.getValue()
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
},
|
|
1016
|
-
enableSorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) ?? (config == null ? void 0 : config.sortable),
|
|
1017
|
-
manualSorting: sortConfig == null ? void 0 : sortConfig.manualSorting,
|
|
1018
|
-
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
1019
|
-
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
1020
|
-
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
1021
|
-
filterFromLeafRows: filters == null ? void 0 : filters.filterFromLeafRows,
|
|
1022
|
-
getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
|
|
1023
|
-
getCoreRowModel: getCoreRowModel(),
|
|
1024
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
1025
|
-
getSortedRowModel: getSortedRowModel(),
|
|
1026
|
-
onExpandedChange: setExpanded,
|
|
1027
|
-
onRowSelectionChange: setRowSelectionState,
|
|
1028
|
-
onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
|
|
1029
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
1030
|
-
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
|
|
1031
|
-
getSubRows: config == null ? void 0 : config.getSubRows,
|
|
1032
|
-
getRowId: config == null ? void 0 : config.getRowId
|
|
1033
|
-
});
|
|
1034
|
-
useEffect3(() => {
|
|
1035
|
-
if (config && config.expandAllByDefault) {
|
|
1036
|
-
table.toggleAllRowsExpanded();
|
|
1037
|
-
}
|
|
1038
|
-
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
1039
|
-
return table;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// src/DataTable/DataTable.tsx
|
|
1043
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1044
|
-
function DataTable(props) {
|
|
1045
|
-
const table = useDataTable(props);
|
|
1046
|
-
return /* @__PURE__ */ jsx20(DataTableRaw, {
|
|
1047
|
-
table,
|
|
1048
|
-
...props
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
// src/DataTable/Provider.tsx
|
|
1053
|
-
import { Provider } from "jotai";
|
|
1054
|
-
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1055
|
-
function DataTableProvider({ children, ...props }) {
|
|
1056
|
-
return /* @__PURE__ */ jsx21(Provider, {
|
|
1057
|
-
...props,
|
|
1058
|
-
children
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
// src/DataTable/index.ts
|
|
1063
|
-
var DataTable2 = DataTable;
|
|
1064
|
-
DataTable2.Provider = DataTableProvider;
|
|
1065
1076
|
export {
|
|
1066
1077
|
AppShell,
|
|
1067
1078
|
AppSidebar,
|
|
1068
1079
|
ChipsCell,
|
|
1069
1080
|
ColumnSelect,
|
|
1070
|
-
|
|
1081
|
+
DataTable,
|
|
1071
1082
|
DynamicCell,
|
|
1072
1083
|
HierarchyCell,
|
|
1073
1084
|
SelectColumnDef,
|
|
@@ -1075,9 +1086,5 @@ export {
|
|
|
1075
1086
|
TableHeader,
|
|
1076
1087
|
TypographyCustom,
|
|
1077
1088
|
capitalizeHeader,
|
|
1078
|
-
|
|
1079
|
-
globalFilterAtom,
|
|
1080
|
-
prependSelectColumn,
|
|
1081
|
-
rowSelectionAtom,
|
|
1082
|
-
tableSortingAtom
|
|
1089
|
+
prependSelectColumn
|
|
1083
1090
|
};
|