@equinor/apollo-components 1.7.0 → 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 +9 -2
- package/dist/index.js +116 -111
- package/dist/index.mjs +113 -109
- 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, Row, ColumnDef, RowSelectionState, SortingState,
|
|
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,11 @@ 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;
|
|
47
49
|
}
|
|
48
50
|
interface RowConfig<T> {
|
|
49
51
|
getRowBackground?: (row: Row<T>) => string | undefined;
|
|
@@ -96,6 +98,11 @@ declare const tableSortingAtom: jotai.PrimitiveAtom<SortingState> & {
|
|
|
96
98
|
init: SortingState;
|
|
97
99
|
};
|
|
98
100
|
|
|
101
|
+
interface ColumnSelectProps<T> {
|
|
102
|
+
table: Table<T>;
|
|
103
|
+
}
|
|
104
|
+
declare function ColumnSelect<T>({ table }: ColumnSelectProps<T>): JSX.Element;
|
|
105
|
+
|
|
99
106
|
interface TableHeaderProps<T> {
|
|
100
107
|
table: Table<T>;
|
|
101
108
|
sticky?: boolean;
|
|
@@ -133,4 +140,4 @@ declare type TypographyProps = {
|
|
|
133
140
|
*/
|
|
134
141
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
135
142
|
|
|
136
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, 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,
|
|
@@ -590,11 +591,83 @@ function BasicTable({
|
|
|
590
591
|
});
|
|
591
592
|
}
|
|
592
593
|
|
|
593
|
-
// src/DataTable/components/
|
|
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
|
|
594
601
|
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
595
602
|
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
596
603
|
var import_react2 = require("react");
|
|
597
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"));
|
|
598
671
|
|
|
599
672
|
// src/DataTable/utils.tsx
|
|
600
673
|
function capitalizeHeader(context) {
|
|
@@ -619,25 +692,25 @@ function prependSelectColumn(columns, config) {
|
|
|
619
692
|
}
|
|
620
693
|
|
|
621
694
|
// src/DataTable/components/ColumnSelect.tsx
|
|
622
|
-
var
|
|
623
|
-
var ColumnSelectContent =
|
|
695
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
696
|
+
var ColumnSelectContent = import_styled_components13.default.div`
|
|
624
697
|
display: grid;
|
|
625
698
|
grid-template-columns: repeat(2, 1fr);
|
|
626
699
|
grid-gap: 0.5rem;
|
|
627
700
|
`;
|
|
628
|
-
var ActionsWrapper =
|
|
701
|
+
var ActionsWrapper = import_styled_components13.default.div`
|
|
629
702
|
display: flex;
|
|
630
703
|
align-items: center;
|
|
631
704
|
justify-content: flex-end;
|
|
632
705
|
gap: 0.5rem;
|
|
633
706
|
`;
|
|
634
707
|
function ColumnSelect({ table }) {
|
|
635
|
-
const [isOpen, setIsOpen] = (0,
|
|
636
|
-
const referenceElement = (0,
|
|
708
|
+
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
709
|
+
const referenceElement = (0, import_react3.useRef)(null);
|
|
637
710
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
638
|
-
return /* @__PURE__ */ (0,
|
|
711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, {
|
|
639
712
|
children: [
|
|
640
|
-
/* @__PURE__ */ (0,
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
|
|
641
714
|
"aria-haspopup": true,
|
|
642
715
|
id: "column-select-anchor",
|
|
643
716
|
"aria-controls": "column-select-popover",
|
|
@@ -645,51 +718,51 @@ function ColumnSelect({ table }) {
|
|
|
645
718
|
ref: referenceElement,
|
|
646
719
|
variant: "ghost_icon",
|
|
647
720
|
onClick: () => setIsOpen(true),
|
|
648
|
-
children: /* @__PURE__ */ (0,
|
|
721
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
649
722
|
name: "view_column",
|
|
650
|
-
data:
|
|
723
|
+
data: import_eds_icons6.view_column
|
|
651
724
|
})
|
|
652
725
|
}),
|
|
653
|
-
/* @__PURE__ */ (0,
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover, {
|
|
654
727
|
open: isOpen,
|
|
655
728
|
id: "column-select-popover",
|
|
656
729
|
anchorEl: referenceElement.current,
|
|
657
730
|
placement: "bottom-end",
|
|
658
731
|
onClose: () => setIsOpen(false),
|
|
659
732
|
children: [
|
|
660
|
-
/* @__PURE__ */ (0,
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover.Header, {
|
|
661
734
|
children: [
|
|
662
|
-
/* @__PURE__ */ (0,
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Popover.Title, {
|
|
663
736
|
children: "Column settings"
|
|
664
737
|
}),
|
|
665
|
-
/* @__PURE__ */ (0,
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
|
|
666
739
|
variant: "ghost_icon",
|
|
667
740
|
"aria-label": "Close column select",
|
|
668
741
|
onClick: () => setIsOpen(false),
|
|
669
|
-
children: /* @__PURE__ */ (0,
|
|
742
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
670
743
|
name: "close",
|
|
671
|
-
data:
|
|
744
|
+
data: import_eds_icons6.close,
|
|
672
745
|
size: 24
|
|
673
746
|
})
|
|
674
747
|
})
|
|
675
748
|
]
|
|
676
749
|
}),
|
|
677
|
-
/* @__PURE__ */ (0,
|
|
750
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover.Content, {
|
|
678
751
|
children: [
|
|
679
|
-
/* @__PURE__ */ (0,
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ColumnSelectContent, {
|
|
680
753
|
children: selectableColumns.map((column) => {
|
|
681
|
-
return /* @__PURE__ */ (0,
|
|
754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Checkbox, {
|
|
682
755
|
checked: column.getIsVisible(),
|
|
683
756
|
label: getColumnHeader(column),
|
|
684
757
|
onChange: column.getToggleVisibilityHandler()
|
|
685
758
|
}, column.id);
|
|
686
759
|
})
|
|
687
760
|
}),
|
|
688
|
-
/* @__PURE__ */ (0,
|
|
761
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Divider, {
|
|
689
762
|
variant: "small"
|
|
690
763
|
}),
|
|
691
|
-
/* @__PURE__ */ (0,
|
|
692
|
-
children: /* @__PURE__ */ (0,
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ActionsWrapper, {
|
|
765
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
|
|
693
766
|
color: "secondary",
|
|
694
767
|
variant: "ghost",
|
|
695
768
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -705,78 +778,6 @@ function ColumnSelect({ table }) {
|
|
|
705
778
|
});
|
|
706
779
|
}
|
|
707
780
|
|
|
708
|
-
// src/DataTable/components/DataTableHeader.tsx
|
|
709
|
-
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
710
|
-
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
711
|
-
var import_jotai2 = require("jotai");
|
|
712
|
-
var import_styled_components14 = __toESM(require("styled-components"));
|
|
713
|
-
|
|
714
|
-
// src/DataTable/filters/DebouncedInput.tsx
|
|
715
|
-
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
716
|
-
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
717
|
-
var import_react3 = require("react");
|
|
718
|
-
var import_styled_components13 = __toESM(require("styled-components"));
|
|
719
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
720
|
-
var Wrapper3 = import_styled_components13.default.div`
|
|
721
|
-
width: 200px;
|
|
722
|
-
`;
|
|
723
|
-
var CloseButton = (0, import_styled_components13.default)(import_eds_core_react13.Button)`
|
|
724
|
-
width: 24px;
|
|
725
|
-
height: 24px;
|
|
726
|
-
`;
|
|
727
|
-
function DebouncedInput({
|
|
728
|
-
value: initialValue,
|
|
729
|
-
onChange,
|
|
730
|
-
icon,
|
|
731
|
-
debounce = 500,
|
|
732
|
-
...props
|
|
733
|
-
}) {
|
|
734
|
-
const [value, setValue] = (0, import_react3.useState)(initialValue);
|
|
735
|
-
(0, import_react3.useEffect)(() => {
|
|
736
|
-
setValue(initialValue);
|
|
737
|
-
}, [initialValue]);
|
|
738
|
-
(0, import_react3.useEffect)(() => {
|
|
739
|
-
const timeout = setTimeout(() => {
|
|
740
|
-
onChange(value);
|
|
741
|
-
}, debounce);
|
|
742
|
-
return () => clearTimeout(timeout);
|
|
743
|
-
}, [value]);
|
|
744
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Wrapper3, {
|
|
745
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Input, {
|
|
746
|
-
...props,
|
|
747
|
-
value,
|
|
748
|
-
leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
749
|
-
name: icon.name,
|
|
750
|
-
data: icon,
|
|
751
|
-
size: 18
|
|
752
|
-
}),
|
|
753
|
-
rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Tooltip, {
|
|
754
|
-
title: "Clear input",
|
|
755
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CloseButton, {
|
|
756
|
-
variant: "ghost_icon",
|
|
757
|
-
onClick: () => setValue(""),
|
|
758
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
|
|
759
|
-
name: import_eds_icons6.close.name,
|
|
760
|
-
data: import_eds_icons6.close,
|
|
761
|
-
size: 18
|
|
762
|
-
})
|
|
763
|
-
})
|
|
764
|
-
}),
|
|
765
|
-
onChange: (event) => setValue(event.target.value)
|
|
766
|
-
})
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// src/DataTable/filters/functions.ts
|
|
771
|
-
var import_match_sorter_utils = require("@tanstack/match-sorter-utils");
|
|
772
|
-
var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
773
|
-
const itemRank = (0, import_match_sorter_utils.rankItem)(row.getValue(columnId), value);
|
|
774
|
-
addMeta({
|
|
775
|
-
itemRank
|
|
776
|
-
});
|
|
777
|
-
return itemRank.passed;
|
|
778
|
-
};
|
|
779
|
-
|
|
780
781
|
// src/DataTable/components/DataTableHeader.tsx
|
|
781
782
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
782
783
|
var DataTableHeaderWrapper = import_styled_components14.default.div`
|
|
@@ -792,7 +793,8 @@ var FilterContainer = import_styled_components14.default.div`
|
|
|
792
793
|
gap: 1rem;
|
|
793
794
|
justify-content: flex-end;
|
|
794
795
|
`;
|
|
795
|
-
|
|
796
|
+
function DataTableHeader({ config, table, ...props }) {
|
|
797
|
+
var _a;
|
|
796
798
|
const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
|
|
797
799
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DataTableHeaderWrapper, {
|
|
798
800
|
className: "--table-caption",
|
|
@@ -802,21 +804,26 @@ var DataTableHeader = (props) => {
|
|
|
802
804
|
variant: "h3",
|
|
803
805
|
children: props == null ? void 0 : props.tableCaption
|
|
804
806
|
}),
|
|
805
|
-
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FilterContainer, {
|
|
806
808
|
className: "--filter-container",
|
|
807
|
-
children:
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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
|
+
})
|
|
816
823
|
})
|
|
817
824
|
]
|
|
818
825
|
});
|
|
819
|
-
}
|
|
826
|
+
}
|
|
820
827
|
|
|
821
828
|
// src/DataTable/components/VirtualTable.tsx
|
|
822
829
|
var import_eds_core_react16 = require("@equinor/eds-core-react");
|
|
@@ -964,12 +971,9 @@ function DataTable({
|
|
|
964
971
|
children: [
|
|
965
972
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
|
|
966
973
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
967
|
-
enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
|
|
968
|
-
globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
|
|
969
974
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
})
|
|
975
|
+
table,
|
|
976
|
+
config: filters
|
|
973
977
|
}),
|
|
974
978
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
|
|
975
979
|
ref: tableContainerRef,
|
|
@@ -1009,6 +1013,7 @@ DataTable2.Provider = DataTableProvider;
|
|
|
1009
1013
|
AppShell,
|
|
1010
1014
|
AppSidebar,
|
|
1011
1015
|
ChipsCell,
|
|
1016
|
+
ColumnSelect,
|
|
1012
1017
|
DataTable,
|
|
1013
1018
|
DynamicCell,
|
|
1014
1019
|
HierarchyCell,
|
package/dist/index.mjs
CHANGED
|
@@ -552,11 +552,83 @@ function BasicTable({
|
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
-
// src/DataTable/components/
|
|
556
|
-
import {
|
|
557
|
-
import {
|
|
558
|
-
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";
|
|
559
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";
|
|
560
632
|
|
|
561
633
|
// src/DataTable/utils.tsx
|
|
562
634
|
function capitalizeHeader(context) {
|
|
@@ -581,25 +653,25 @@ function prependSelectColumn(columns, config) {
|
|
|
581
653
|
}
|
|
582
654
|
|
|
583
655
|
// src/DataTable/components/ColumnSelect.tsx
|
|
584
|
-
import { Fragment as Fragment2, jsx as
|
|
585
|
-
var ColumnSelectContent =
|
|
656
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
657
|
+
var ColumnSelectContent = styled12.div`
|
|
586
658
|
display: grid;
|
|
587
659
|
grid-template-columns: repeat(2, 1fr);
|
|
588
660
|
grid-gap: 0.5rem;
|
|
589
661
|
`;
|
|
590
|
-
var ActionsWrapper =
|
|
662
|
+
var ActionsWrapper = styled12.div`
|
|
591
663
|
display: flex;
|
|
592
664
|
align-items: center;
|
|
593
665
|
justify-content: flex-end;
|
|
594
666
|
gap: 0.5rem;
|
|
595
667
|
`;
|
|
596
668
|
function ColumnSelect({ table }) {
|
|
597
|
-
const [isOpen, setIsOpen] =
|
|
669
|
+
const [isOpen, setIsOpen] = useState3(false);
|
|
598
670
|
const referenceElement = useRef(null);
|
|
599
671
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
600
672
|
return /* @__PURE__ */ jsxs8(Fragment2, {
|
|
601
673
|
children: [
|
|
602
|
-
/* @__PURE__ */
|
|
674
|
+
/* @__PURE__ */ jsx14(Button4, {
|
|
603
675
|
"aria-haspopup": true,
|
|
604
676
|
id: "column-select-anchor",
|
|
605
677
|
"aria-controls": "column-select-popover",
|
|
@@ -607,7 +679,7 @@ function ColumnSelect({ table }) {
|
|
|
607
679
|
ref: referenceElement,
|
|
608
680
|
variant: "ghost_icon",
|
|
609
681
|
onClick: () => setIsOpen(true),
|
|
610
|
-
children: /* @__PURE__ */
|
|
682
|
+
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
611
683
|
name: "view_column",
|
|
612
684
|
data: view_column
|
|
613
685
|
})
|
|
@@ -621,16 +693,16 @@ function ColumnSelect({ table }) {
|
|
|
621
693
|
children: [
|
|
622
694
|
/* @__PURE__ */ jsxs8(Popover.Header, {
|
|
623
695
|
children: [
|
|
624
|
-
/* @__PURE__ */
|
|
696
|
+
/* @__PURE__ */ jsx14(Popover.Title, {
|
|
625
697
|
children: "Column settings"
|
|
626
698
|
}),
|
|
627
|
-
/* @__PURE__ */
|
|
699
|
+
/* @__PURE__ */ jsx14(Button4, {
|
|
628
700
|
variant: "ghost_icon",
|
|
629
701
|
"aria-label": "Close column select",
|
|
630
702
|
onClick: () => setIsOpen(false),
|
|
631
|
-
children: /* @__PURE__ */
|
|
703
|
+
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
632
704
|
name: "close",
|
|
633
|
-
data:
|
|
705
|
+
data: close2,
|
|
634
706
|
size: 24
|
|
635
707
|
})
|
|
636
708
|
})
|
|
@@ -638,20 +710,20 @@ function ColumnSelect({ table }) {
|
|
|
638
710
|
}),
|
|
639
711
|
/* @__PURE__ */ jsxs8(Popover.Content, {
|
|
640
712
|
children: [
|
|
641
|
-
/* @__PURE__ */
|
|
713
|
+
/* @__PURE__ */ jsx14(ColumnSelectContent, {
|
|
642
714
|
children: selectableColumns.map((column) => {
|
|
643
|
-
return /* @__PURE__ */
|
|
715
|
+
return /* @__PURE__ */ jsx14(Checkbox2, {
|
|
644
716
|
checked: column.getIsVisible(),
|
|
645
717
|
label: getColumnHeader(column),
|
|
646
718
|
onChange: column.getToggleVisibilityHandler()
|
|
647
719
|
}, column.id);
|
|
648
720
|
})
|
|
649
721
|
}),
|
|
650
|
-
/* @__PURE__ */
|
|
722
|
+
/* @__PURE__ */ jsx14(Divider, {
|
|
651
723
|
variant: "small"
|
|
652
724
|
}),
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
children: /* @__PURE__ */
|
|
725
|
+
/* @__PURE__ */ jsx14(ActionsWrapper, {
|
|
726
|
+
children: /* @__PURE__ */ jsx14(Button4, {
|
|
655
727
|
color: "secondary",
|
|
656
728
|
variant: "ghost",
|
|
657
729
|
disabled: table.getIsAllColumnsVisible(),
|
|
@@ -668,79 +740,7 @@ function ColumnSelect({ table }) {
|
|
|
668
740
|
}
|
|
669
741
|
|
|
670
742
|
// src/DataTable/components/DataTableHeader.tsx
|
|
671
|
-
import {
|
|
672
|
-
import { search } from "@equinor/eds-icons";
|
|
673
|
-
import { useAtom } from "jotai";
|
|
674
|
-
import styled13 from "styled-components";
|
|
675
|
-
|
|
676
|
-
// src/DataTable/filters/DebouncedInput.tsx
|
|
677
|
-
import { Button as Button4, Icon as Icon6, Input, Tooltip } from "@equinor/eds-core-react";
|
|
678
|
-
import { close as close2 } from "@equinor/eds-icons";
|
|
679
|
-
import { useEffect, useState as useState3 } from "react";
|
|
680
|
-
import styled12 from "styled-components";
|
|
681
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
682
|
-
var Wrapper3 = styled12.div`
|
|
683
|
-
width: 200px;
|
|
684
|
-
`;
|
|
685
|
-
var CloseButton = styled12(Button4)`
|
|
686
|
-
width: 24px;
|
|
687
|
-
height: 24px;
|
|
688
|
-
`;
|
|
689
|
-
function DebouncedInput({
|
|
690
|
-
value: initialValue,
|
|
691
|
-
onChange,
|
|
692
|
-
icon,
|
|
693
|
-
debounce = 500,
|
|
694
|
-
...props
|
|
695
|
-
}) {
|
|
696
|
-
const [value, setValue] = useState3(initialValue);
|
|
697
|
-
useEffect(() => {
|
|
698
|
-
setValue(initialValue);
|
|
699
|
-
}, [initialValue]);
|
|
700
|
-
useEffect(() => {
|
|
701
|
-
const timeout = setTimeout(() => {
|
|
702
|
-
onChange(value);
|
|
703
|
-
}, debounce);
|
|
704
|
-
return () => clearTimeout(timeout);
|
|
705
|
-
}, [value]);
|
|
706
|
-
return /* @__PURE__ */ jsx14(Wrapper3, {
|
|
707
|
-
children: /* @__PURE__ */ jsx14(Input, {
|
|
708
|
-
...props,
|
|
709
|
-
value,
|
|
710
|
-
leftAdornments: icon && /* @__PURE__ */ jsx14(Icon6, {
|
|
711
|
-
name: icon.name,
|
|
712
|
-
data: icon,
|
|
713
|
-
size: 18
|
|
714
|
-
}),
|
|
715
|
-
rightAdornments: !!value && /* @__PURE__ */ jsx14(Tooltip, {
|
|
716
|
-
title: "Clear input",
|
|
717
|
-
children: /* @__PURE__ */ jsx14(CloseButton, {
|
|
718
|
-
variant: "ghost_icon",
|
|
719
|
-
onClick: () => setValue(""),
|
|
720
|
-
children: /* @__PURE__ */ jsx14(Icon6, {
|
|
721
|
-
name: close2.name,
|
|
722
|
-
data: close2,
|
|
723
|
-
size: 18
|
|
724
|
-
})
|
|
725
|
-
})
|
|
726
|
-
}),
|
|
727
|
-
onChange: (event) => setValue(event.target.value)
|
|
728
|
-
})
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// src/DataTable/filters/functions.ts
|
|
733
|
-
import { rankItem } from "@tanstack/match-sorter-utils";
|
|
734
|
-
var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
735
|
-
const itemRank = rankItem(row.getValue(columnId), value);
|
|
736
|
-
addMeta({
|
|
737
|
-
itemRank
|
|
738
|
-
});
|
|
739
|
-
return itemRank.passed;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
// src/DataTable/components/DataTableHeader.tsx
|
|
743
|
-
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
743
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
744
744
|
var DataTableHeaderWrapper = styled13.div`
|
|
745
745
|
display: flex;
|
|
746
746
|
align-items: center;
|
|
@@ -754,7 +754,8 @@ var FilterContainer = styled13.div`
|
|
|
754
754
|
gap: 1rem;
|
|
755
755
|
justify-content: flex-end;
|
|
756
756
|
`;
|
|
757
|
-
|
|
757
|
+
function DataTableHeader({ config, table, ...props }) {
|
|
758
|
+
var _a;
|
|
758
759
|
const [globalFilter, setGlobalFilter] = useAtom(globalFilterAtom);
|
|
759
760
|
return /* @__PURE__ */ jsxs9(DataTableHeaderWrapper, {
|
|
760
761
|
className: "--table-caption",
|
|
@@ -764,21 +765,26 @@ var DataTableHeader = (props) => {
|
|
|
764
765
|
variant: "h3",
|
|
765
766
|
children: props == null ? void 0 : props.tableCaption
|
|
766
767
|
}),
|
|
767
|
-
|
|
768
|
+
/* @__PURE__ */ jsx15(FilterContainer, {
|
|
768
769
|
className: "--filter-container",
|
|
769
|
-
children:
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
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
|
+
})
|
|
778
784
|
})
|
|
779
785
|
]
|
|
780
786
|
});
|
|
781
|
-
}
|
|
787
|
+
}
|
|
782
788
|
|
|
783
789
|
// src/DataTable/components/VirtualTable.tsx
|
|
784
790
|
import { Table as Table8 } from "@equinor/eds-core-react";
|
|
@@ -926,12 +932,9 @@ function DataTable({
|
|
|
926
932
|
children: [
|
|
927
933
|
/* @__PURE__ */ jsx18(DataTableHeader, {
|
|
928
934
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
929
|
-
enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
|
|
930
|
-
globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
|
|
931
935
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
})
|
|
936
|
+
table,
|
|
937
|
+
config: filters
|
|
935
938
|
}),
|
|
936
939
|
/* @__PURE__ */ jsx18("div", {
|
|
937
940
|
ref: tableContainerRef,
|
|
@@ -970,6 +973,7 @@ export {
|
|
|
970
973
|
AppShell,
|
|
971
974
|
AppSidebar,
|
|
972
975
|
ChipsCell,
|
|
976
|
+
ColumnSelect,
|
|
973
977
|
DataTable2 as DataTable,
|
|
974
978
|
DynamicCell,
|
|
975
979
|
HierarchyCell,
|