Skip to content

Commit 215918a

Browse files
committed
fix(docs): Display extended interfaces in the docs
1 parent e797073 commit 215918a

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

packages/module/src/DataViewTable/DataViewTable.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,38 @@ import { DataViewTableTree, DataViewTableTreeProps } from '../DataViewTableTree'
88
import { DataViewTableBasic, DataViewTableBasicProps } from '../DataViewTableBasic';
99

1010
// Table head typings
11-
export type DataViewTh = ReactNode | { cell: ReactNode; props?: ThProps };
11+
export type DataViewTh = ReactNode | {
12+
/** Table head cell node */
13+
cell: ReactNode;
14+
/** Props passed to Th */
15+
props?: ThProps
16+
};
1217
export const isDataViewThObject = (value: DataViewTh): value is { cell: ReactNode; props?: ThProps } => value != null && typeof value === 'object' && 'cell' in value;
1318

1419
// Basic table typings
15-
export interface DataViewTrObject { row: DataViewTd[], id?: string, props?: TrProps }
16-
export type DataViewTd = ReactNode | { cell: ReactNode; props?: TdProps };
20+
export interface DataViewTrObject {
21+
/** Array of rows */
22+
row: DataViewTd[],
23+
/** Unique identifier of a row */
24+
id?: string,
25+
/** Props passed to Tr */
26+
props?: TrProps
27+
}
28+
29+
export type DataViewTd = ReactNode | {
30+
/** Table body cell node */
31+
cell: ReactNode;
32+
/** Props passed to Td */
33+
props?: TdProps
34+
};
35+
1736
export type DataViewTr = DataViewTd[] | DataViewTrObject;
1837

1938
export const isDataViewTdObject = (value: DataViewTd): value is { cell: ReactNode; props?: TdProps } => value != null && typeof value === 'object' && 'cell' in value;
2039
export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewTd[], id?: string } => value != null && typeof value === 'object' && 'row' in value;
2140

2241
// Tree table typings
42+
/** extends DataViewTrObject */
2343
export interface DataViewTrTree extends DataViewTrObject { id: string, children?: DataViewTrTree[] }
2444

2545
export type DataViewTableProps =

packages/module/src/DataViewTableBasic/DataViewTableBasic.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DataViewTableHead } from '../DataViewTableHead';
1111
import { DataViewTh, DataViewTr, isDataViewTdObject, isDataViewTrObject } from '../DataViewTable';
1212
import { DataViewState } from '../DataView/DataView';
1313

14+
/** extends TableProps */
1415
export interface DataViewTableBasicProps extends Omit<TableProps, 'onSelect' | 'rows'> {
1516
/** Columns definition */
1617
columns: DataViewTh[];

packages/module/src/DataViewTableHead/DataViewTableHead.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { useInternalContext } from '../InternalContext';
99
import { DataViewTh, isDataViewThObject } from '../DataViewTable';
1010

11+
/** extends TheadProps */
1112
export interface DataViewTableHeadProps extends TheadProps {
1213
/** Indicates whether table is a tree */
1314
isTreeTable?: boolean;

packages/module/src/DataViewTableTree/DataViewTableTree.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const isNodeChecked = (node: DataViewTrTree, isSelected: (node: DataViewTrTree)
3030
return allSelected;
3131
};
3232

33+
/** extends TableProps */
3334
export interface DataViewTableTreeProps extends Omit<TableProps, 'onSelect' | 'rows'> {
3435
/** Columns definition */
3536
columns: DataViewTh[];

packages/module/src/Hooks/pagination.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface UseDataViewPaginationProps {
2020
perPageParam?: string;
2121
}
2222

23+
/** extends UseDataViewPaginationProps */
2324
export interface DataViewPaginationProps extends UseDataViewPaginationProps {
2425
/** Current page number */
2526
page: number;

packages/module/src/Hooks/selection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export interface UseDataViewSelectionProps {
88
initialSelected?: (any)[];
99
}
1010

11-
export const useDataViewSelection = ({ matchOption, initialSelected = [] }: UseDataViewSelectionProps) => {
12-
const [ selected, setSelected ] = useState<any[]>(initialSelected);
11+
export const useDataViewSelection = (props?: UseDataViewSelectionProps) => {
12+
const [ selected, setSelected ] = useState<any[]>(props?.initialSelected ?? []);
13+
const matchOption = props?.matchOption ? props.matchOption : (option, another) => (option === another);
1314

1415
const onSelect = (isSelecting: boolean, items?: any[] | any) => {
1516
isSelecting && items ?

packages/module/src/InternalContext/InternalContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface InternalContextProps {
1717
activeState?: DataViewState | string;
1818
}
1919

20+
/** extends InternalContextProps */
2021
export interface InternalContextValue extends InternalContextProps {
2122
/** Flag indicating if data view is selectable (auto-calculated) */
2223
isSelectable: boolean;

0 commit comments

Comments
 (0)