@canonical/maas-react-components 2.2.0 → 2.3.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 +1251 -1173
- 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 +10 -3
- package/dist/src/lib/components/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +3 -3
- package/dist/src/lib/components/GenericTable/types.d.ts +5 -1
- package/dist/src/lib/components/GenericTable/utils/processColumnDefs.d.ts +1 -2
- package/dist/src/lib/components/GenericTable/utils/renderLoadingRows.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DetailedHTMLProps, Dispatch, HTMLAttributes, ReactElement, ReactNode, RefObject, SetStateAction } from 'react';
|
|
2
2
|
import { Column, ColumnDef, ColumnSort, Header, Row, SortingState } from '@tanstack/react-table';
|
|
3
3
|
import { PaginationBarProps } from './components/PaginationBar';
|
|
4
|
-
import { SelectionProps, GenericTableData } from './types';
|
|
4
|
+
import { SelectionProps, GenericTableData, ColumnVisibilityProps } from './types';
|
|
5
5
|
type GenericTableProps<T extends GenericTableData> = {
|
|
6
6
|
"aria-label"?: string;
|
|
7
7
|
className?: string;
|
|
@@ -15,17 +15,20 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
15
15
|
isLoading: boolean;
|
|
16
16
|
loadingVariant?: "spinner" | "skeleton";
|
|
17
17
|
skeletonRowCount?: number;
|
|
18
|
+
skeletonGroupCount?: number;
|
|
18
19
|
noData?: ReactNode;
|
|
19
20
|
pagination?: PaginationBarProps;
|
|
20
21
|
pinGroup?: {
|
|
21
22
|
value: string;
|
|
22
23
|
isTop: boolean;
|
|
23
24
|
}[];
|
|
25
|
+
columnVisibility?: ColumnVisibilityProps;
|
|
24
26
|
sorting?: ColumnSort[];
|
|
25
27
|
selection?: SelectionProps<T>;
|
|
26
28
|
setSorting?: Dispatch<SetStateAction<SortingState>>;
|
|
27
29
|
showChevron?: boolean;
|
|
28
30
|
variant?: "full-height" | "regular";
|
|
31
|
+
debug?: boolean;
|
|
29
32
|
} & DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
30
33
|
/**
|
|
31
34
|
* GenericTable - A flexible and feature-rich table component for React applications
|
|
@@ -39,6 +42,8 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
39
42
|
* @param {Object} props - Component props
|
|
40
43
|
* @param {string} [props.className] - Additional CSS class for the table wrapper
|
|
41
44
|
* @param {ColumnDef<T, Partial<T>>[]} props.columns - Column definitions
|
|
45
|
+
* @param {ColumnVisibilityProps} [props.columnVisibility] - Controlled column visibility state and setter; when omitted, visibility is managed internally. See {@link ColumnVisibilityProps} for all sub-options
|
|
46
|
+
* (columnVisibility, setColumnVisibility).
|
|
42
47
|
* @param {RefObject<HTMLElement | null>} [props.containerRef] - Reference to container for size calculations
|
|
43
48
|
* @param {T[]} props.data - Table data array
|
|
44
49
|
* @param {(row: Row<T>, column: Column<T>) => boolean} [props.filterCells] - Function to filter which cells should be displayed
|
|
@@ -47,7 +52,8 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
47
52
|
* @param {string[]} [props.groupBy] - Column IDs to group rows by
|
|
48
53
|
* @param {boolean} props.isLoading - Loading state to display placeholder content
|
|
49
54
|
* @param {"spinner" | "skeleton"} [props.loadingVariant="spinner"] - Loading display style; "spinner" shows a single spinner row, "skeleton" renders skeletonRowCount pulsing skeleton rows using meta.skeleton per column when defined, falling back to a default Placeholder block
|
|
50
|
-
* @param {number} [props.skeletonRowCount=10] - Number of skeleton rows to render when loadingVariant="skeleton"
|
|
55
|
+
* @param {number} [props.skeletonRowCount=10] - Number of skeleton rows to render per group (or total when ungrouped) when loadingVariant="skeleton"
|
|
56
|
+
* @param {number} [props.skeletonGroupCount=2] - Number of skeleton group rows to render when loadingVariant="skeleton" and groupBy is set
|
|
51
57
|
* @param {ReactNode} [props.noData] - Content to display when no data is available
|
|
52
58
|
* @param {PaginationBarProps} [props.pagination] - Pagination configuration
|
|
53
59
|
* @param {{ value: string; isTop: boolean }[]} [props.pinGroup] - Group pinning configuration
|
|
@@ -57,6 +63,7 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
57
63
|
* (filterSelectable, disabledSelectionTooltip, rowSelection, rowSelectionLabelKey, setRowSelection).
|
|
58
64
|
* @param {boolean} [props.showChevron=false] - Show group row expansion state chevrons
|
|
59
65
|
* @param {"full-height" | "regular"} [props.variant="full-height"] - Table layout variant
|
|
66
|
+
* @param {boolean} [props.debug] - React Table debug output
|
|
60
67
|
*
|
|
61
68
|
* @returns {ReactElement} - The rendered table component
|
|
62
69
|
*
|
|
@@ -80,5 +87,5 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
80
87
|
* }}
|
|
81
88
|
* />
|
|
82
89
|
*/
|
|
83
|
-
export declare const GenericTable: <T extends GenericTableData>({ "aria-label": tableAriaLabel, className, columns: initialColumns, containerRef, data: initialData, filterCells, filterHeaders, getSubRows, groupBy, isLoading, loadingVariant, skeletonRowCount, noData, pagination, pinGroup, sorting: externalSorting, selection, setSorting: setExternalSorting, showChevron, variant, ...divProps }: GenericTableProps<T>) => ReactElement;
|
|
90
|
+
export declare const GenericTable: <T extends GenericTableData>({ "aria-label": tableAriaLabel, className, columns: initialColumns, columnVisibility: externalColumnVisibility, containerRef, data: initialData, filterCells, filterHeaders, getSubRows, groupBy, isLoading, loadingVariant, skeletonRowCount, skeletonGroupCount, noData, pagination, pinGroup, sorting: externalSorting, selection, setSorting: setExternalSorting, showChevron, variant, debug, ...divProps }: GenericTableProps<T>) => ReactElement;
|
|
84
91
|
export {};
|
|
@@ -6,10 +6,10 @@ type TableCheckboxProps<T> = Partial<DetailedHTMLProps<InputHTMLAttributes<HTMLI
|
|
|
6
6
|
};
|
|
7
7
|
declare const TableCheckbox: {
|
|
8
8
|
<T>({ row, disabledTooltip, isNested, ...props }: TableCheckboxProps<T> & {
|
|
9
|
-
disabledTooltip
|
|
10
|
-
isNested
|
|
9
|
+
disabledTooltip?: string | ((row: Row<T>) => string);
|
|
10
|
+
isNested?: boolean;
|
|
11
11
|
}): ReactElement | null;
|
|
12
12
|
All: <T>({ table, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
-
Group: <T>({ row, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element
|
|
13
|
+
Group: <T>({ row, ...props }: TableCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
};
|
|
15
15
|
export default TableCheckbox;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import { Row, RowData, RowSelectionState } from '@tanstack/react-table';
|
|
2
|
+
import { Row, RowData, RowSelectionState, VisibilityState } from '@tanstack/react-table';
|
|
3
3
|
declare module "@tanstack/react-table" {
|
|
4
4
|
interface ColumnMeta<TData extends RowData, TValue = unknown> {
|
|
5
5
|
/** Custom loading skeleton renderer. Overrides the default shimmer for this column. */
|
|
@@ -25,3 +25,7 @@ export type SelectionProps<T extends GenericTableData> = {
|
|
|
25
25
|
rowSelection?: RowSelectionState;
|
|
26
26
|
setRowSelection?: Dispatch<SetStateAction<RowSelectionState>>;
|
|
27
27
|
};
|
|
28
|
+
export type ColumnVisibilityProps = {
|
|
29
|
+
columnVisibility: VisibilityState;
|
|
30
|
+
setColumnVisibility: Dispatch<SetStateAction<VisibilityState>>;
|
|
31
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ColumnDef } from '@tanstack/react-table';
|
|
2
2
|
import { SelectionProps, GenericTableData } from '../types';
|
|
3
|
-
export declare const processColumnDefs: <T extends GenericTableData>({ canSelect, initialColumns,
|
|
3
|
+
export declare const processColumnDefs: <T extends GenericTableData>({ canSelect, initialColumns, groupBy, getSubRows, selection, showChevron, }: {
|
|
4
4
|
canSelect: boolean;
|
|
5
5
|
initialColumns: ColumnDef<T, Partial<T>>[];
|
|
6
|
-
isLoading: boolean;
|
|
7
6
|
groupBy: string[] | undefined;
|
|
8
7
|
getSubRows?: (originalRow: T, index: number) => T[] | undefined;
|
|
9
8
|
selection?: SelectionProps<T>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ColumnDef, Header, Table } from '@tanstack/react-table';
|
|
1
|
+
import { Column, ColumnDef, Header, Row, Table } from '@tanstack/react-table';
|
|
2
2
|
import { GenericTableData } from '../types';
|
|
3
|
-
export declare const renderLoadingRows: <T extends GenericTableData>({ table, columns, filterHeaders, loadingVariant, skeletonRowCount, }: {
|
|
3
|
+
export declare const renderLoadingRows: <T extends GenericTableData>({ table, columns, filterHeaders, filterCells, loadingVariant, skeletonRowCount, skeletonGroupCount, }: {
|
|
4
4
|
table: Table<T>;
|
|
5
5
|
columns: ColumnDef<T, Partial<T>>[];
|
|
6
6
|
filterHeaders: (header: Header<T, unknown>) => boolean;
|
|
7
|
+
filterCells: (row: Row<T>, column: Column<T>) => boolean;
|
|
7
8
|
loadingVariant?: "skeleton" | "spinner";
|
|
8
9
|
skeletonRowCount: number;
|
|
10
|
+
skeletonGroupCount: number;
|
|
9
11
|
}) => import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
|
package/package.json
CHANGED