mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allowing any[] type for VirtualList items prop
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
ccd38b5cbe
commit
5e9762c11d
@ -20,7 +20,7 @@ export type TableSortParams = { sortBy: TableSortBy; orderBy: TableOrderBy };
|
||||
export type TableSortCallback<D = any> = (data: D) => string | number | (string | number)[];
|
||||
|
||||
export interface TableProps extends React.DOMAttributes<HTMLDivElement> {
|
||||
items?: ItemObject[]; // Raw items data
|
||||
items?: any[]; // Raw items data
|
||||
className?: string;
|
||||
autoSize?: boolean; // Setup auto-sizing for all columns (flex: 1 0)
|
||||
selectable?: boolean; // Highlight rows on hover
|
||||
@ -40,7 +40,7 @@ export interface TableProps extends React.DOMAttributes<HTMLDivElement> {
|
||||
rowPadding?: string;
|
||||
rowLineHeight?: string;
|
||||
customRowHeights?: (item: object, lineHeight: number, paddings: number) => number;
|
||||
getTableRow?: (uid: string) => React.ReactElement<TableRowProps>;
|
||||
getTableRow?: (uid: string | number) => React.ReactElement<TableRowProps>;
|
||||
}
|
||||
|
||||
@observer
|
||||
|
||||
@ -13,8 +13,8 @@ import debounce from "lodash/debounce";
|
||||
import isEqual from "lodash/isEqual";
|
||||
import ResizeSensor from "css-element-queries/src/ResizeSensor";
|
||||
|
||||
interface Props<T extends ItemObject = any> {
|
||||
items: T[];
|
||||
interface Props {
|
||||
items: any[];
|
||||
rowHeights: number[];
|
||||
className?: string;
|
||||
width?: number | string;
|
||||
@ -126,8 +126,7 @@ interface RowProps extends ListChildComponentProps {
|
||||
const Row = observer((props: RowProps) => {
|
||||
const { index, style, data } = props;
|
||||
const { items, getRow } = data;
|
||||
const item = items[index];
|
||||
const uid = typeof item == "string" ? index : items[index].getId();
|
||||
const uid = items[index].getId ? items[index].getId() : index;
|
||||
const row = getRow(uid);
|
||||
if (!row) return null;
|
||||
return React.cloneElement(row, {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user