@canonical/maas-react-components 1.31.0 → 1.32.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.
@@ -5,7 +5,8 @@ type GenericTableProps<T extends {
5
5
  id: number | string;
6
6
  }> = {
7
7
  className?: string;
8
- canSelect?: boolean;
8
+ canSelect?: boolean | ((row: Row<T>) => boolean);
9
+ disabledSelectionTooltip?: string | ((row: Row<T>) => string);
9
10
  columns: ColumnDef<T, Partial<T>>[];
10
11
  containerRef?: RefObject<HTMLElement | null>;
11
12
  data: T[];
@@ -35,7 +36,8 @@ type GenericTableProps<T extends {
35
36
  *
36
37
  * @param {Object} props - Component props
37
38
  * @param {string} [props.className] - Additional CSS class for the table wrapper
38
- * @param {boolean} [props.canSelect=false] - Enable row selection with checkboxes
39
+ * @param {boolean | ((row: Row<T>) => boolean)} [props.canSelect=false] - Enable row selection with checkboxes
40
+ * @param {string | ((row: Row<T>) => string)} [props.disabledSelectionTooltip] - Tooltip message or constructor on disabled checkboxes
39
41
  * @param {ColumnDef<T, Partial<T>>[]} props.columns - Column definitions
40
42
  * @param {RefObject<HTMLElement | null>} [props.containerRef] - Reference to container for size calculations
41
43
  * @param {T[]} props.data - Table data array
@@ -73,5 +75,5 @@ type GenericTableProps<T extends {
73
75
  */
74
76
  export declare const GenericTable: <T extends {
75
77
  id: number | string;
76
- }>({ className, canSelect, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, groupBy, isLoading, noData, pagination, pinGroup, sortBy, rowSelection, setRowSelection, variant, ...props }: GenericTableProps<T>) => ReactElement;
78
+ }>({ className, canSelect, disabledSelectionTooltip, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, groupBy, isLoading, noData, pagination, pinGroup, sortBy, rowSelection, setRowSelection, variant, ...props }: GenericTableProps<T>) => ReactElement;
77
79
  export {};
@@ -1,12 +1,21 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { GenericTable } from './GenericTable';
3
- declare const meta: Meta<typeof GenericTable>;
3
+ type Machine = {
4
+ id: number;
5
+ fqdn: string;
6
+ ipAddress: string;
7
+ status: string;
8
+ zone: string;
9
+ pool: string;
10
+ };
11
+ declare const meta: Meta<typeof GenericTable<Machine>>;
4
12
  export default meta;
5
- type Story = StoryObj<typeof GenericTable>;
13
+ type Story = StoryObj<typeof GenericTable<Machine>>;
6
14
  export declare const Default: Story;
7
15
  export declare const Loading: Story;
8
16
  export declare const Empty: Story;
9
17
  export declare const Selectable: Story;
18
+ export declare const ConditionallySelectable: Story;
10
19
  export declare const Grouped: Story;
11
20
  export declare const GroupedSelectable: Story;
12
21
  export declare const Paginated: Story;
@@ -5,7 +5,9 @@ type TableCheckboxProps<T> = Partial<DetailedHTMLProps<InputHTMLAttributes<HTMLI
5
5
  table?: Table<T>;
6
6
  };
7
7
  declare const TableCheckbox: {
8
- <T>({ row, ...props }: TableCheckboxProps<T>): ReactElement | null;
8
+ <T>({ row, disabledTooltip, ...props }: TableCheckboxProps<T> & {
9
+ disabledTooltip: string | ((row: Row<T>) => string);
10
+ }): ReactElement | null;
9
11
  All: <T>({ table, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element | null;
10
12
  Group: <T>({ row, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element | null;
11
13
  };
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.31.0",
4
+ "version": "1.32.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/canonical/maas-react-components.git"