import { type Ref } from 'react'; import type { DatasourceDataResponseItem, DatasourceResponseSchemaProperty, DatasourceTableStatusType, DatasourceType } from '@atlaskit/linking-types'; import type { NextPageType } from '../../hooks/useDatasourceTableState'; export type DatasourceTypeWithOnlyValues = { [K in DatasourceType['type']]: { type: K; values: Extract['value'][]; }; }[DatasourceType['type']]; /** Object typing a list of data objects for type K */ export type DatasourceTypeWithOnlyTypeValues = { type: K; values: Extract['value'][]; }; export type DatasourceTypeValueType = Extract['value']; export type TableViewPropsRenderType = (item: DatasourceTypeWithOnlyValues) => React.ReactNode; export interface ColumnSizesMap { [key: string]: number; } export interface IssueLikeDataTableViewProps { /** * Map of column key to custom column width */ columnCustomSizes?: ColumnSizesMap; /** * All available columns/properties. * Consumer should not reorder these columns to align with `visibleColumnKeys`. * UI will display them according to `visibleColumnKeys` */ columns: DatasourceResponseSchemaProperty[]; /** * Datasource extension key. Optional as value may not have been returned yet */ extensionKey?: string | null; hasNextPage: boolean; itemIds: string[]; items: DatasourceDataResponseItem[]; onColumnResize?: (key: string, width: number) => void; onLoadDatasourceDetails: () => Promise; onNextPage: NextPageType; /** * Callback to be invoked whenever a user changes the visible columns in a datasource table * either by selecting/unselecting or reordering (drag and drop) * * @param visibleColumnKeys the array of keys for all of the selected columns */ onVisibleColumnKeysChange?: (visibleColumnKeys: string[]) => void; /** * Callback to be invoked whenever user changes wrap attribute of the column. * * @param key Column key * @param shouldWrap Whenever column should wrap */ onWrappedColumnChange?: (key: string, shouldWrap: boolean) => void; /** * A function to define new or override existing render components. * eg: * const renderItem: TableViewPropsRenderType = item => { * if (item.type === 'icon') { * return ( * * ); * } * return fallbackRenderType(item); * }; */ renderItem?: TableViewPropsRenderType; /** * If this number is set it will restrict (max-height) maximum size of the component AND make main container a scrollable container. * It this number is 0 it will not restrict height and not make container scrollable. */ scrollableContainerHeight?: number; status: DatasourceTableStatusType; testId?: string; /** * List of properties/column keys that are visible/selected */ visibleColumnKeys: string[]; /** * List of column keys that needs to be shown without truncation (content will wrap to a new line) */ wrappedColumnKeys?: string[]; } export interface HeaderRowCellType { content?: React.ReactNode | string; key: string; shouldTruncate?: boolean; width?: number; } export interface RowType { cells: Array; key?: string; ref?: Ref; } export interface RowCellType { content?: React.ReactNode | string; key: string; shouldTruncate?: boolean; type?: DatasourceType['type']; width?: number; }