@equinor/apollo-components 1.11.1 → 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 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, SortingState, HeaderContext } from '@tanstack/react-table';
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
@@ -461,7 +461,8 @@ var HeaderDiv = import_styled_components11.default.div`
461
461
  var HeaderCell = ({ header }) => {
462
462
  var _a;
463
463
  const style = {
464
- width: header.column.getSize()
464
+ width: header.column.getSize(),
465
+ zIndex: 10
465
466
  };
466
467
  const cellProps = {
467
468
  style,
@@ -880,8 +881,9 @@ function VirtualTable({
880
881
  const { rows } = table.getRowModel();
881
882
  const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
882
883
  count: rows.length,
883
- estimateSize: () => 35,
884
- getScrollElement: () => containerRef.current
884
+ estimateSize: () => 48,
885
+ getScrollElement: () => containerRef.current,
886
+ overscan: 5
885
887
  });
886
888
  const virtualRows = rowVirtualizer.getVirtualItems();
887
889
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
@@ -979,7 +981,7 @@ var import_jotai3 = require("jotai");
979
981
  var import_react5 = require("react");
980
982
  var import_jsx_runtime19 = require("react/jsx-runtime");
981
983
  function useDataTable(props) {
982
- const { columns, data, filters, config, cellConfig } = props;
984
+ const { columns, data, filters, config, cellConfig, sortConfig } = props;
983
985
  const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
984
986
  const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
985
987
  const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
@@ -995,7 +997,7 @@ function useDataTable(props) {
995
997
  state: {
996
998
  expanded,
997
999
  globalFilter: enableGlobalFilter(globalFilter),
998
- sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
1000
+ sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
999
1001
  rowSelection: rowSelectionState,
1000
1002
  columnVisibility
1001
1003
  },
@@ -1008,7 +1010,8 @@ function useDataTable(props) {
1008
1010
  });
1009
1011
  }
1010
1012
  },
1011
- 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,
1012
1015
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
1013
1016
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
1014
1017
  enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
@@ -1019,7 +1022,7 @@ function useDataTable(props) {
1019
1022
  getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
1020
1023
  onExpandedChange: setExpanded,
1021
1024
  onRowSelectionChange: setRowSelectionState,
1022
- onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
1025
+ onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
1023
1026
  onColumnVisibilityChange: setColumnVisibility,
1024
1027
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
1025
1028
  getSubRows: config == null ? void 0 : config.getSubRows,
package/dist/index.mjs CHANGED
@@ -415,7 +415,8 @@ var HeaderDiv = styled11.div`
415
415
  var HeaderCell = ({ header }) => {
416
416
  var _a;
417
417
  const style = {
418
- width: header.column.getSize()
418
+ width: header.column.getSize(),
419
+ zIndex: 10
419
420
  };
420
421
  const cellProps = {
421
422
  style,
@@ -834,8 +835,9 @@ function VirtualTable({
834
835
  const { rows } = table.getRowModel();
835
836
  const rowVirtualizer = useVirtualizer({
836
837
  count: rows.length,
837
- estimateSize: () => 35,
838
- getScrollElement: () => containerRef.current
838
+ estimateSize: () => 48,
839
+ getScrollElement: () => containerRef.current,
840
+ overscan: 5
839
841
  });
840
842
  const virtualRows = rowVirtualizer.getVirtualItems();
841
843
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
@@ -939,7 +941,7 @@ import { useAtom as useAtom2 } from "jotai";
939
941
  import { useEffect as useEffect2 } from "react";
940
942
  import { jsx as jsx19 } from "react/jsx-runtime";
941
943
  function useDataTable(props) {
942
- const { columns, data, filters, config, cellConfig } = props;
944
+ const { columns, data, filters, config, cellConfig, sortConfig } = props;
943
945
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
944
946
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
945
947
  const [sorting, setSorting] = useAtom2(tableSortingAtom);
@@ -955,7 +957,7 @@ function useDataTable(props) {
955
957
  state: {
956
958
  expanded,
957
959
  globalFilter: enableGlobalFilter(globalFilter),
958
- sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
960
+ sorting: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.sorting) ?? sorting : void 0,
959
961
  rowSelection: rowSelectionState,
960
962
  columnVisibility
961
963
  },
@@ -968,7 +970,8 @@ function useDataTable(props) {
968
970
  });
969
971
  }
970
972
  },
971
- 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,
972
975
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
973
976
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
974
977
  enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
@@ -979,7 +982,7 @@ function useDataTable(props) {
979
982
  getSortedRowModel: getSortedRowModel(),
980
983
  onExpandedChange: setExpanded,
981
984
  onRowSelectionChange: setRowSelectionState,
982
- onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
985
+ onSortingChange: (sortConfig == null ? void 0 : sortConfig.enableSorting) || (config == null ? void 0 : config.sortable) ? (sortConfig == null ? void 0 : sortConfig.onSortingChange) ?? setSorting : void 0,
983
986
  onColumnVisibilityChange: setColumnVisibility,
984
987
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
985
988
  getSubRows: config == null ? void 0 : config.getSubRows,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",