@canonical/maas-react-components 1.35.0 → 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.
@@ -1,12 +1,19 @@
1
- import { Dispatch, ReactElement, ReactNode, RefObject, SetStateAction, DetailedHTMLProps, HTMLAttributes } from 'react';
1
+ import { DetailedHTMLProps, Dispatch, HTMLAttributes, ReactElement, ReactNode, RefObject, SetStateAction } from 'react';
2
2
  import { Column, ColumnDef, ColumnSort, Header, Row, RowSelectionState, SortingState } from '@tanstack/react-table';
3
3
  import { PaginationBarProps } from './PaginationBar';
4
+ type SelectionProps<T extends {
5
+ id: number | string;
6
+ }> = {
7
+ filterSelectable?: (row: Row<T>) => boolean;
8
+ disabledSelectionTooltip?: string | ((row: Row<T>) => string);
9
+ rowSelectionLabelKey?: keyof T;
10
+ rowSelection?: RowSelectionState;
11
+ setRowSelection?: Dispatch<SetStateAction<RowSelectionState>>;
12
+ };
4
13
  type GenericTableProps<T extends {
5
14
  id: number | string;
6
15
  }> = {
7
16
  className?: string;
8
- canSelect?: boolean | ((row: Row<T>) => boolean);
9
- disabledSelectionTooltip?: string | ((row: Row<T>) => string);
10
17
  columns: ColumnDef<T, Partial<T>>[];
11
18
  containerRef?: RefObject<HTMLElement | null>;
12
19
  data: T[];
@@ -22,9 +29,8 @@ type GenericTableProps<T extends {
22
29
  isTop: boolean;
23
30
  }[];
24
31
  sorting?: ColumnSort[];
32
+ selection?: SelectionProps<T>;
25
33
  setSorting?: Dispatch<SetStateAction<SortingState>>;
26
- rowSelection?: RowSelectionState;
27
- setRowSelection?: Dispatch<SetStateAction<RowSelectionState>>;
28
34
  showChevron?: boolean;
29
35
  variant?: "full-height" | "regular";
30
36
  } & DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
@@ -39,8 +45,6 @@ type GenericTableProps<T extends {
39
45
  *
40
46
  * @param {Object} props - Component props
41
47
  * @param {string} [props.className] - Additional CSS class for the table wrapper
42
- * @param {boolean | ((row: Row<T>) => boolean)} [props.canSelect=false] - Enable row selection with checkboxes
43
- * @param {string | ((row: Row<T>) => string)} [props.disabledSelectionTooltip] - Tooltip message or constructor on disabled checkboxes
44
48
  * @param {ColumnDef<T, Partial<T>>[]} props.columns - Column definitions
45
49
  * @param {RefObject<HTMLElement | null>} [props.containerRef] - Reference to container for size calculations
46
50
  * @param {T[]} props.data - Table data array
@@ -54,8 +58,12 @@ type GenericTableProps<T extends {
54
58
  * @param {{ value: string; isTop: boolean }[]} [props.pinGroup] - Group pinning configuration
55
59
  * @param {ColumnSort[]} [props.sorting] - Initial sort configuration
56
60
  * @param {Dispatch<SetStateAction<SortingState>>} [props.setSorting] - Sorting state setter
57
- * @param {RowSelectionState} [props.rowSelection] - Selected rows state
58
- * @param {Dispatch<SetStateAction<RowSelectionState>>} [props.setRowSelection] - Selection state setter
61
+ * @param {SelectionProps} [props.selection] - Selection configuration
62
+ * @param {((row: Row<T>) => boolean)} [props.selection.filterSelectable] - Function to filter which rows should be selectable
63
+ * @param {string | ((row: Row<T>) => string)} [props.selection.disabledSelectionTooltip] - Tooltip message or constructor on disabled checkboxes
64
+ * @param {RowSelectionState} [props.selection.rowSelection] - Selected rows state
65
+ * @param {keyof T} [props.selection.rowSelectionLabelKey] - Key of T to use as aria-labels for row checkboxes (e.g. "select {keyof T}")
66
+ * @param {Dispatch<SetStateAction<RowSelectionState>>} [props.selection.setRowSelection] - Selection state setter
59
67
  * @param {boolean} [props.showChevron=false] - Show group row expansion state chevrons
60
68
  * @param {"full-height" | "regular"} [props.variant="full-height"] - Table layout variant
61
69
  *
@@ -81,5 +89,5 @@ type GenericTableProps<T extends {
81
89
  */
82
90
  export declare const GenericTable: <T extends {
83
91
  id: number | string;
84
- }>({ className, canSelect, disabledSelectionTooltip, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, getSubRows, groupBy, isLoading, noData, pagination, pinGroup, sorting, setSorting, rowSelection, setRowSelection, showChevron, variant, ...props }: GenericTableProps<T>) => ReactElement;
92
+ } & Record<string, unknown>>({ className, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, getSubRows, groupBy, isLoading, noData, pagination, pinGroup, sorting, selection, setSorting, showChevron, variant, ...props }: GenericTableProps<T>) => ReactElement;
85
93
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/maas-react-components",
3
3
  "description": "React components for use in MAAS UI projects.",
4
- "version": "1.35.0",
4
+ "version": "2.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/canonical/maas-react-components.git"