@canonical/maas-react-components 1.31.0 → 1.33.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/@canonical/maas-react-components.es.js +963 -916
- package/dist/@canonical/maas-react-components.umd.js +13 -13
- package/dist/maas-react-components.css +1 -1
- package/dist/src/lib/components/GenericTable/GenericTable.d.ts +9 -5
- package/dist/src/lib/components/GenericTable/GenericTable.stories.d.ts +13 -2
- package/dist/src/lib/components/GenericTable/TableCheckbox/TableCheckbox.d.ts +4 -1
- package/package.json +1 -1
|
@@ -5,12 +5,14 @@ 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[];
|
|
12
13
|
filterCells?: (row: Row<T>, column: Column<T>) => boolean;
|
|
13
14
|
filterHeaders?: (header: Header<T, unknown>) => boolean;
|
|
15
|
+
getSubRows?: (originalRow: T, index: number) => T[] | undefined;
|
|
14
16
|
groupBy?: string[];
|
|
15
17
|
isLoading: boolean;
|
|
16
18
|
noData?: ReactNode;
|
|
@@ -35,12 +37,14 @@ type GenericTableProps<T extends {
|
|
|
35
37
|
*
|
|
36
38
|
* @param {Object} props - Component props
|
|
37
39
|
* @param {string} [props.className] - Additional CSS class for the table wrapper
|
|
38
|
-
* @param {boolean} [props.canSelect=false] - Enable row selection with checkboxes
|
|
40
|
+
* @param {boolean | ((row: Row<T>) => boolean)} [props.canSelect=false] - Enable row selection with checkboxes
|
|
41
|
+
* @param {string | ((row: Row<T>) => string)} [props.disabledSelectionTooltip] - Tooltip message or constructor on disabled checkboxes
|
|
39
42
|
* @param {ColumnDef<T, Partial<T>>[]} props.columns - Column definitions
|
|
40
43
|
* @param {RefObject<HTMLElement | null>} [props.containerRef] - Reference to container for size calculations
|
|
41
44
|
* @param {T[]} props.data - Table data array
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
45
|
+
* @param {(row: Row<T>, column: Column<T>) => boolean} [props.filterCells] - Function to filter which cells should be displayed
|
|
46
|
+
* @param {(header: Header<T, unknown>) => boolean} [props.filterHeaders] - Function to filter which headers should be displayed
|
|
47
|
+
* @param {(originalRow: T, index: number) => T[] | undefined} [props.getSubRows] - Function that returns the T.prop that contains nested T data
|
|
44
48
|
* @param {string[]} [props.groupBy] - Column IDs to group rows by
|
|
45
49
|
* @param {boolean} props.isLoading - Loading state to display placeholder content
|
|
46
50
|
* @param {ReactNode} [props.noData] - Content to display when no data is available
|
|
@@ -73,5 +77,5 @@ type GenericTableProps<T extends {
|
|
|
73
77
|
*/
|
|
74
78
|
export declare const GenericTable: <T extends {
|
|
75
79
|
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;
|
|
80
|
+
}>({ className, canSelect, disabledSelectionTooltip, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, getSubRows, groupBy, isLoading, noData, pagination, pinGroup, sortBy, rowSelection, setRowSelection, variant, ...props }: GenericTableProps<T>) => ReactElement;
|
|
77
81
|
export {};
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { GenericTable } from './GenericTable';
|
|
3
|
-
|
|
3
|
+
type Machine = {
|
|
4
|
+
id: number;
|
|
5
|
+
fqdn: string;
|
|
6
|
+
ipAddress: string;
|
|
7
|
+
status: string;
|
|
8
|
+
zone: string;
|
|
9
|
+
pool: string;
|
|
10
|
+
children?: Machine[];
|
|
11
|
+
};
|
|
12
|
+
declare const meta: Meta<typeof GenericTable<Machine>>;
|
|
4
13
|
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof GenericTable
|
|
14
|
+
type Story = StoryObj<typeof GenericTable<Machine>>;
|
|
6
15
|
export declare const Default: Story;
|
|
7
16
|
export declare const Loading: Story;
|
|
8
17
|
export declare const Empty: Story;
|
|
9
18
|
export declare const Selectable: Story;
|
|
19
|
+
export declare const ConditionallySelectable: Story;
|
|
10
20
|
export declare const Grouped: Story;
|
|
11
21
|
export declare const GroupedSelectable: Story;
|
|
22
|
+
export declare const GroupedNested: Story;
|
|
12
23
|
export declare const Paginated: Story;
|
|
13
24
|
export declare const Searchable: Story;
|
|
14
25
|
export declare const Scrollable: Story;
|
|
@@ -5,7 +5,10 @@ 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>
|
|
8
|
+
<T>({ row, disabledTooltip, isNested, ...props }: TableCheckboxProps<T> & {
|
|
9
|
+
disabledTooltip: string | ((row: Row<T>) => string);
|
|
10
|
+
isNested: boolean;
|
|
11
|
+
}): ReactElement | null;
|
|
9
12
|
All: <T>({ table, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
13
|
Group: <T>({ row, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
14
|
};
|
package/package.json
CHANGED