@awsui/components-react
Version:
AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A
93 lines (92 loc) • 3.23 kB
TypeScript
import React from 'react';
import { BaseComponentProps } from '../internal/base-component';
import { NonCancelableEventHandler, CancelableEventHandler } from '../internal/events';
export interface TableForwardRefType {
<T>(props: TableProps<T> & {
ref?: React.Ref<TableProps.Ref>;
}): JSX.Element;
}
export interface TableProps<T = any> extends BaseComponentProps {
header?: React.ReactNode;
footer?: React.ReactNode;
empty?: React.ReactNode;
items: ReadonlyArray<T>;
loading?: boolean;
loadingText?: string;
trackBy?: TableProps.TrackBy<T>;
columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<T>>;
selectionType?: TableProps.SelectionType;
selectedItems?: ReadonlyArray<T>;
filter?: React.ReactNode;
pagination?: React.ReactNode;
preferences?: React.ReactNode;
isItemDisabled?: TableProps.IsItemDisabled<T>;
wrapLines?: boolean;
resizableColumns?: boolean;
ariaLabels?: TableProps.AriaLabels<T>;
sortingColumn?: TableProps.SortingColumn<T>;
sortingDescending?: boolean;
sortingDisabled?: boolean;
visibleColumns?: ReadonlyArray<string>;
onColumnWidthsChange?: NonCancelableEventHandler<TableProps.ColumnWidthsChangeDetail>;
onSortingChange?: NonCancelableEventHandler<TableProps.SortingState<T>>;
onSelectionChange?: NonCancelableEventHandler<TableProps.SelectionChangeDetail<T>>;
onRowClick?: NonCancelableEventHandler<TableProps.OnRowClickDetail<T>>;
onRowContextMenu?: CancelableEventHandler<TableProps.OnRowContextMenuDetail<T>>;
stickyHeader?: boolean;
stickyHeaderVerticalOffset?: number;
}
export declare namespace TableProps {
type TrackBy<T> = string | ((item: T) => string);
type ColumnDefinition<T> = {
id?: string;
header: React.ReactNode;
cell(item: T): React.ReactNode;
ariaLabel?(data: LabelData): string;
width?: number | string;
minWidth?: number | string;
maxWidth?: number | string;
} & SortingColumn<T>;
type SelectionType = 'single' | 'multi';
interface SelectionState<T> {
selectedItems: ReadonlyArray<T>;
}
interface SelectionChangeDetail<T> {
selectedItems: T[];
}
type IsItemDisabled<T> = (item: T) => boolean;
interface AriaLabels<T> {
allItemsSelectionLabel: (data: TableProps.SelectionState<T>) => string;
itemSelectionLabel: (data: TableProps.SelectionState<T>, row: T) => string;
selectionGroupLabel: string;
}
interface SortingState<T> {
isDescending?: boolean;
sortingColumn: SortingColumn<T>;
}
interface SortingColumn<T> {
sortingField?: string;
sortingComparator?: (a: T, b: T) => number;
}
interface LabelData {
sorted: boolean;
descending: boolean;
disabled: boolean;
}
interface OnRowClickDetail<T> {
rowIndex: number;
item: T;
}
interface OnRowContextMenuDetail<T> {
rowIndex: number;
item: T;
clientX: number;
clientY: number;
}
interface ColumnWidthsChangeDetail {
widths: ReadonlyArray<number>;
}
interface Ref {
scrollToTop(): void;
}
}