@itwin/itwinui-react
Version:
A react component library for iTwinUI
45 lines (44 loc) • 1.65 kB
TypeScript
import * as React from 'react';
import type { CellProps, CellRendererProps, Row } from '../../../react-table/react-table.js';
export declare const EXPANDER_CELL_ID = "iui-table-expander";
/**
* Expander column that adds sub-content expander column to the Table.
* It is recommended to use it as the first column or after selection column.
* @example
* const subComponent = useCallback(
* (row: Row) => (
* <div style={{ padding: 16 }}>
* <Text variant='leading'>Extra information</Text>
* <pre>
* <code>{JSON.stringify({ values: row.values }, null, 2)}</code>
* </pre>
* </div>
* ),
* [],
* );
* const isExpanderDisabled = useCallback((rowData) => {
* return rowData.name === 'Name2';
* }, []);
* const columns = useMemo(() => [
* ExpanderColumn({ subComponent, isDisabled: isExpanderDisabled }),
* // Rest of your columns
* ], [isExpanderDisabled, subComponent]);
*/
export declare const ExpanderColumn: <T extends Record<string, unknown>>(props?: {
/** Function that returns expanded content. If row doesn't have it, then should return `false`/`null`. */
subComponent?: (row: Row<T>) => React.ReactNode;
/** Function that returns whether expander is disabled */
isDisabled?: (rowData: T) => boolean;
}) => {
id: string;
disableResizing: boolean;
disableGroupBy: boolean;
disableReordering: boolean;
minWidth: number;
width: number;
maxWidth: number;
columnClassName: string;
cellClassName: string;
Cell: (props: CellProps<T>) => React.JSX.Element | null;
cellRenderer: (props: CellRendererProps<T>) => React.JSX.Element;
};