@equinor/apollo-components 1.11.2 → 1.12.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 +10 -2
- package/dist/index.js +5 -4
- package/dist/index.mjs +5 -4
- 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, ReactElement, ComponentProps } from 'react';
|
|
4
|
-
import { Cell, CellContext, Table, Row, ColumnDef, VisibilityState, RowSelectionState,
|
|
4
|
+
import { Cell, CellContext, Table, Row, SortingState, OnChangeFn, ColumnDef, VisibilityState, RowSelectionState, 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';
|
|
@@ -65,6 +65,12 @@ interface RowConfig<T> {
|
|
|
65
65
|
onMouseLeave?: (row: Row<T>) => void;
|
|
66
66
|
}
|
|
67
67
|
declare type TruncateMode = 'wrap' | 'hover';
|
|
68
|
+
declare type SortConfig = {
|
|
69
|
+
enableSorting?: boolean;
|
|
70
|
+
manualSorting?: boolean;
|
|
71
|
+
sorting?: SortingState;
|
|
72
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
73
|
+
};
|
|
68
74
|
interface CellConfig<T> {
|
|
69
75
|
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
70
76
|
getShouldHighlight?: (cell: Cell<T, unknown>) => boolean;
|
|
@@ -89,6 +95,7 @@ declare type DataTableConfig<T> = {
|
|
|
89
95
|
* Default size is 150px.
|
|
90
96
|
*/
|
|
91
97
|
tableLayout?: TableLayout;
|
|
98
|
+
/** @deprecated use `cellConfig.enableSorting` instead. This is to align with \@tanstack/react-table types. */
|
|
92
99
|
sortable?: boolean;
|
|
93
100
|
virtual?: boolean;
|
|
94
101
|
rowSelectionMode?: RowSelectionMode;
|
|
@@ -107,6 +114,7 @@ interface DataTableCommonProps<T> {
|
|
|
107
114
|
config?: DataTableConfig<T>;
|
|
108
115
|
cellConfig?: CellConfig<T>;
|
|
109
116
|
rowConfig?: RowConfig<T>;
|
|
117
|
+
sortConfig?: SortConfig;
|
|
110
118
|
filters?: FilterConfig;
|
|
111
119
|
header?: HeaderConfig;
|
|
112
120
|
}
|
|
@@ -172,4 +180,4 @@ declare type TypographyProps = {
|
|
|
172
180
|
} & TypographyProps$1;
|
|
173
181
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
174
182
|
|
|
175
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, columnVisibilityAtom, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
|
183
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, columnVisibilityAtom, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -981,7 +981,7 @@ var import_jotai3 = require("jotai");
|
|
|
981
981
|
var import_react5 = require("react");
|
|
982
982
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
983
983
|
function useDataTable(props) {
|
|
984
|
-
const { columns, data, filters, config, cellConfig } = props;
|
|
984
|
+
const { columns, data, filters, config, cellConfig, sortConfig } = props;
|
|
985
985
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
986
986
|
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
987
987
|
const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
|
|
@@ -997,7 +997,7 @@ function useDataTable(props) {
|
|
|
997
997
|
state: {
|
|
998
998
|
expanded,
|
|
999
999
|
globalFilter: enableGlobalFilter(globalFilter),
|
|
1000
|
-
sorting:
|
|
1000
|
+
sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
|
|
1001
1001
|
rowSelection: rowSelectionState,
|
|
1002
1002
|
columnVisibility
|
|
1003
1003
|
},
|
|
@@ -1010,7 +1010,8 @@ function useDataTable(props) {
|
|
|
1010
1010
|
});
|
|
1011
1011
|
}
|
|
1012
1012
|
},
|
|
1013
|
-
enableSorting: config == null ? void 0 : config.sortable,
|
|
1013
|
+
enableSorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) ?? (config == null ? void 0 : config.sortable),
|
|
1014
|
+
manualSorting: sortConfig == null ? void 0 : sortConfig.manualSorting,
|
|
1014
1015
|
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
1015
1016
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
1016
1017
|
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
@@ -1021,7 +1022,7 @@ function useDataTable(props) {
|
|
|
1021
1022
|
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
1022
1023
|
onExpandedChange: setExpanded,
|
|
1023
1024
|
onRowSelectionChange: setRowSelectionState,
|
|
1024
|
-
onSortingChange:
|
|
1025
|
+
onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
|
|
1025
1026
|
onColumnVisibilityChange: setColumnVisibility,
|
|
1026
1027
|
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
|
|
1027
1028
|
getSubRows: config == null ? void 0 : config.getSubRows,
|
package/dist/index.mjs
CHANGED
|
@@ -941,7 +941,7 @@ import { useAtom as useAtom2 } from "jotai";
|
|
|
941
941
|
import { useEffect as useEffect2 } from "react";
|
|
942
942
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
943
943
|
function useDataTable(props) {
|
|
944
|
-
const { columns, data, filters, config, cellConfig } = props;
|
|
944
|
+
const { columns, data, filters, config, cellConfig, sortConfig } = props;
|
|
945
945
|
const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
|
|
946
946
|
const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
|
|
947
947
|
const [sorting, setSorting] = useAtom2(tableSortingAtom);
|
|
@@ -957,7 +957,7 @@ function useDataTable(props) {
|
|
|
957
957
|
state: {
|
|
958
958
|
expanded,
|
|
959
959
|
globalFilter: enableGlobalFilter(globalFilter),
|
|
960
|
-
sorting:
|
|
960
|
+
sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
|
|
961
961
|
rowSelection: rowSelectionState,
|
|
962
962
|
columnVisibility
|
|
963
963
|
},
|
|
@@ -970,7 +970,8 @@ function useDataTable(props) {
|
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
972
|
},
|
|
973
|
-
enableSorting: config == null ? void 0 : config.sortable,
|
|
973
|
+
enableSorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) ?? (config == null ? void 0 : config.sortable),
|
|
974
|
+
manualSorting: sortConfig == null ? void 0 : sortConfig.manualSorting,
|
|
974
975
|
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
975
976
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
976
977
|
enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
|
|
@@ -981,7 +982,7 @@ function useDataTable(props) {
|
|
|
981
982
|
getSortedRowModel: getSortedRowModel(),
|
|
982
983
|
onExpandedChange: setExpanded,
|
|
983
984
|
onRowSelectionChange: setRowSelectionState,
|
|
984
|
-
onSortingChange:
|
|
985
|
+
onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
|
|
985
986
|
onColumnVisibilityChange: setColumnVisibility,
|
|
986
987
|
onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
|
|
987
988
|
getSubRows: config == null ? void 0 : config.getSubRows,
|