/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { ReactNode } from "react"; import type { SingleOrMany } from "@k8slens/utilities"; import { getInjectionToken } from "@ogre-tools/injectable"; export interface ItemObject { getId(): string; getName(): string; } export type TableSortBy = string; export type TableOrderBy = "asc" | "desc"; export interface TableSortParams { sortBy: TableSortBy; orderBy: TableOrderBy; } export type TableSortCallback = (data: Item) => undefined | string | number | (string | number)[]; export type TableSortCallbacks = Record>; export type SearchFilter = (item: I) => SingleOrMany; export interface TableCellProps extends React.DOMAttributes { /** * used for configuration visibility of columns */ id?: string; /** * Any css class names for this table cell. Only used if `title` is a "simple" react node */ className?: string; /** * The actual value of the cell */ title?: ReactNode; /** * content inside could be scrolled */ scrollable?: boolean; /** * render cell with a checkbox */ checkbox?: boolean; /** * mark checkbox as checked or not */ isChecked?: boolean; /** * column name, must be same as key in sortable object */ sortBy?: TableSortBy; /** * id of the column which follow same visibility rules */ showWithColumn?: string; /** * @internal */ _sorting?: Partial; /** * @internal */ _sort?(sortBy: TableSortBy): void; /** * @internal * indicator, might come from parent , don't use this prop outside (!) */ _nowrap?: boolean; } export interface KubeObjectListLayoutColumn { id: string; kind: string; apiVersion: string; priority: number; sortingCallBack?: TableSortCallback; searchFilter?: SearchFilter; header: TableCellProps | undefined | null; content: (item: Item) => ReactNode | TableCellProps; } export const kubeObjectListLayoutColumnInjectionToken = getInjectionToken>({ id: "kube-object-list-layout-column", });