@equinor/eds-data-grid-react 0.7.1 → 0.7.3

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.
@@ -468,7 +468,8 @@ function TableBodyCell({
468
468
  function TableRow({
469
469
  row,
470
470
  onCellClick,
471
- onClick
471
+ onClick,
472
+ onContextMenu
472
473
  }) {
473
474
  const {
474
475
  rowClass,
@@ -480,6 +481,7 @@ function TableRow({
480
481
  },
481
482
  className: `${row.getIsSelected() ? 'selected' : ''} ${rowClass?.(row)}`,
482
483
  onClick: onClick,
484
+ onContextMenu: onContextMenu,
483
485
  children: row.getVisibleCells().map(cell => /*#__PURE__*/jsxRuntime.jsx(TableBodyCell, {
484
486
  cell: cell,
485
487
  onClick: onCellClick ? event => onCellClick(cell, event) : undefined
@@ -578,12 +580,14 @@ function EdsDataGrid({
578
580
  height,
579
581
  getRowId,
580
582
  rowVirtualizerInstanceRef,
583
+ tableInstanceRef,
581
584
  columnSizing,
582
585
  onColumnResize,
583
586
  expansionState,
584
587
  setExpansionState,
585
588
  getSubRows,
586
589
  defaultColumn,
590
+ onRowContextMenu,
587
591
  onRowClick,
588
592
  onCellClick,
589
593
  enableFooter,
@@ -803,6 +807,9 @@ function EdsDataGrid({
803
807
  }));
804
808
  }, [pageSize]);
805
809
  const table = reactTable.useReactTable(options);
810
+ if (tableInstanceRef) {
811
+ tableInstanceRef.current = table;
812
+ }
806
813
  let tableWrapperStyle = {};
807
814
 
808
815
  /**
@@ -911,6 +918,7 @@ function EdsDataGrid({
911
918
  const row = table.getRowModel().rows[virtualItem.index];
912
919
  return /*#__PURE__*/jsxRuntime.jsx(TableRow, {
913
920
  row: row,
921
+ onContextMenu: onRowContextMenu ? event => onRowContextMenu(row, event) : undefined,
914
922
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
915
923
  onCellClick: onCellClick
916
924
  }, virtualItem.index);
@@ -928,6 +936,7 @@ function EdsDataGrid({
928
936
  })]
929
937
  }), !enableVirtual && table.getRowModel().rows.map(row => /*#__PURE__*/jsxRuntime.jsx(TableRow, {
930
938
  row: row,
939
+ onContextMenu: onRowContextMenu ? event => onRowContextMenu(row, event) : undefined,
931
940
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
932
941
  onCellClick: onCellClick
933
942
  }, row.id))]
@@ -56,12 +56,14 @@ function EdsDataGrid({
56
56
  height,
57
57
  getRowId,
58
58
  rowVirtualizerInstanceRef,
59
+ tableInstanceRef,
59
60
  columnSizing,
60
61
  onColumnResize,
61
62
  expansionState,
62
63
  setExpansionState,
63
64
  getSubRows,
64
65
  defaultColumn,
66
+ onRowContextMenu,
65
67
  onRowClick,
66
68
  onCellClick,
67
69
  enableFooter,
@@ -281,6 +283,9 @@ function EdsDataGrid({
281
283
  }));
282
284
  }, [pageSize]);
283
285
  const table = useReactTable(options);
286
+ if (tableInstanceRef) {
287
+ tableInstanceRef.current = table;
288
+ }
284
289
  let tableWrapperStyle = {};
285
290
 
286
291
  /**
@@ -389,6 +394,7 @@ function EdsDataGrid({
389
394
  const row = table.getRowModel().rows[virtualItem.index];
390
395
  return /*#__PURE__*/jsx(TableRow, {
391
396
  row: row,
397
+ onContextMenu: onRowContextMenu ? event => onRowContextMenu(row, event) : undefined,
392
398
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
393
399
  onCellClick: onCellClick
394
400
  }, virtualItem.index);
@@ -406,6 +412,7 @@ function EdsDataGrid({
406
412
  })]
407
413
  }), !enableVirtual && table.getRowModel().rows.map(row => /*#__PURE__*/jsx(TableRow, {
408
414
  row: row,
415
+ onContextMenu: onRowContextMenu ? event => onRowContextMenu(row, event) : undefined,
409
416
  onClick: onRowClick ? event => onRowClick(row, event) : undefined,
410
417
  onCellClick: onCellClick
411
418
  }, row.id))]
@@ -7,7 +7,8 @@ import { jsx } from 'react/jsx-runtime';
7
7
  function TableRow({
8
8
  row,
9
9
  onCellClick,
10
- onClick
10
+ onClick,
11
+ onContextMenu
11
12
  }) {
12
13
  const {
13
14
  rowClass,
@@ -19,6 +20,7 @@ function TableRow({
19
20
  },
20
21
  className: `${row.getIsSelected() ? 'selected' : ''} ${rowClass?.(row)}`,
21
22
  onClick: onClick,
23
+ onContextMenu: onContextMenu,
22
24
  children: row.getVisibleCells().map(cell => /*#__PURE__*/jsx(TableBodyCell, {
23
25
  cell: cell,
24
26
  onClick: onCellClick ? event => onCellClick(cell, event) : undefined
@@ -1,3 +1,3 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  import { EdsDataGridProps } from './EdsDataGridProps';
3
- export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, selectedRows, rowSelectionState, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, stickyFooter, onSelectRow, onRowSelectionChange, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, footerClass, footerStyle, externalPaginator, onSortingChange, manualSorting, sortingState, columnPinState, scrollbarHorizontal, width, minWidth, height, getRowId, rowVirtualizerInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowClick, onCellClick, enableFooter, enableSortingRemoval, ...rest }: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, selectedRows, rowSelectionState, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, stickyFooter, onSelectRow, onRowSelectionChange, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, footerClass, footerStyle, externalPaginator, onSortingChange, manualSorting, sortingState, columnPinState, scrollbarHorizontal, width, minWidth, height, getRowId, rowVirtualizerInstanceRef, tableInstanceRef, columnSizing, onColumnResize, expansionState, setExpansionState, getSubRows, defaultColumn, onRowContextMenu, onRowClick, onCellClick, enableFooter, enableSortingRemoval, ...rest }: EdsDataGridProps<T> & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Cell, Column, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSizingState, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, TableOptions } from '@tanstack/react-table';
1
+ import { Cell, Column, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSizingState, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, Table, TableOptions } from '@tanstack/react-table';
2
2
  import { Virtualizer } from '@tanstack/react-virtual';
3
3
  import { CSSProperties, MouseEvent, MutableRefObject, ReactElement } from 'react';
4
4
  type BaseProps<T> = {
@@ -186,6 +186,13 @@ type FilterProps = {
186
186
  enableColumnFiltering?: boolean;
187
187
  };
188
188
  type HandlersProps<T> = {
189
+ /**
190
+ *
191
+ * @param row the current row
192
+ * @param event The right-click event
193
+ * @returns
194
+ */
195
+ onRowContextMenu?: (row: Row<T>, event: MouseEvent<HTMLTableRowElement>) => unknown;
189
196
  /**
190
197
  * Row click handler.
191
198
  *
@@ -265,15 +272,16 @@ type ColumnProps = {
265
272
  columnSizing?: ColumnSizingState;
266
273
  onColumnResize?: (e: ColumnSizingState) => void;
267
274
  };
268
- type RefProps = {
275
+ type RefProps<T> = {
269
276
  rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, Element> | null>;
277
+ tableInstanceRef?: MutableRefObject<Table<T> | null>;
270
278
  };
271
279
  type ExpansionProps<T> = {
272
280
  expansionState?: ExpandedState;
273
281
  setExpansionState?: React.Dispatch<React.SetStateAction<ExpandedState>>;
274
282
  getSubRows?: (row: T, rowIndex: number) => Array<T>;
275
283
  };
276
- export type EdsDataGridProps<T> = BaseProps<T> & RowSelectionProps<T> & StyleProps<T> & HandlersProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & RefProps & ExpansionProps<T> & {
284
+ export type EdsDataGridProps<T> = BaseProps<T> & RowSelectionProps<T> & StyleProps<T> & HandlersProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & RefProps<T> & ExpansionProps<T> & {
277
285
  /**
278
286
  * Which columns are visible. If not set, all columns are visible. undefined means that the column is visible.
279
287
  * @default undefined
@@ -5,5 +5,5 @@ type Props<T> = {
5
5
  row: Row<T>;
6
6
  onCellClick?: EdsDataGridProps<T>['onCellClick'];
7
7
  } & HTMLAttributes<HTMLTableRowElement>;
8
- export declare function TableRow<T>({ row, onCellClick, onClick }: Props<T>): import("react/jsx-runtime").JSX.Element;
8
+ export declare function TableRow<T>({ row, onCellClick, onClick, onContextMenu, }: Props<T>): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-data-grid-react",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "A feature-rich data-grid written in React, implementing the Equinor Design System",
5
5
  "license": "MIT",
6
6
  "types": "dist/types/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "@tanstack/react-table": "^8.20.1",
24
24
  "@tanstack/react-virtual": "^3.10.8",
25
25
  "@equinor/eds-icons": "^0.21.0",
26
- "@equinor/eds-tokens": "0.9.2",
27
- "@equinor/eds-utils": "^0.8.5"
26
+ "@equinor/eds-utils": "^0.8.5",
27
+ "@equinor/eds-tokens": "0.9.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@rollup/plugin-babel": "^6.0.4",