UNPKG

@focuson/form_components

Version:

Components that can be used by @focuson/forms

53 lines (52 loc) 4.34 kB
import { CommonStateProps } from "./common"; import { NameAnd } from "@focuson/utils"; import { LensState } from "@focuson/state"; import { Transform } from "@focuson/lens"; import { PageSelectionContext } from "@focuson/pages"; export interface CommonTableProps<S, T, Context> extends CommonStateProps<S, T[], Context> { /** If set then the selected index will be copied here as the table items are selected. */ copySelectedIndexTo?: LensState<S, number, Context>; /** If set then the selected index will be copied here as the table items are selected */ copySelectedItemTo?: LensState<S, T, Context>; joiners?: string | string[]; prefixFilter?: LensState<S, string, Context>; prefixColumn?: keyof T; maxCount?: string; emptyData?: string; tableTitle?: string; scrollAfter?: string; /** A list of fields that we want to be right justified */ rights?: string[]; } export interface TableProps<S, T, Context> extends CommonTableProps<S, T, Context> { order: (keyof T)[]; } export declare function getValueForTable<T>(o: keyof T, row: T, joiners: undefined | string | string[]): any; export declare const transformsForUpdateSelected: <S, T, C>(copySelectedIndexTo?: LensState<S, number, C>, copySelectedItemTo?: LensState<S, T, C>) => (i: number, row: T) => Transform<S, any>[]; export declare function defaultOnClick<S, Context, T>(props: CommonTableProps<S, T, Context>): (i: number, row: T) => (e: any) => void; export type OneRowFn<T> = (row: T, i: number, classForTr: string | undefined, rights: string[] | undefined, onClick: (i: number, row: T) => (e: any) => void) => JSX.Element; export declare function addClassRowFn<T>(fn: OneRowFn<T>, classFn: (t: T) => string | undefined): OneRowFn<T>; export type DisplayTitleFn = (id: string, field: string, i: number) => JSX.Element; export declare const defaultDisplayTitleFn: DisplayTitleFn; export declare const rawTable: <S, T, Context extends PageSelectionContext<S>>(titles: any[], onClick: (i: number, row: T) => (e: any) => void, oneRow: OneRowFn<T>, displayTitleFn?: DisplayTitleFn) => (props: CommonTableProps<S, T, Context>) => import("react/jsx-runtime").JSX.Element; export declare function tdClassForTable(rights: string[] | undefined, s: any): string; export declare const defaultOneRowWithGetValue: <T extends unknown>(getValue: (o: keyof T, row: T, joiners: undefined | string | string[]) => any) => (id: string, order: (keyof T)[], joiners: string | string[] | undefined, ...extraTds: ((i: number, row: T) => JSX.Element)[]) => OneRowFn<T>; export declare const defaultOneRow: <T>(id: string, order: (keyof T)[], joiners: string | string[] | undefined, ...extraTds: ((i: number, row: T) => JSX.Element)[]) => OneRowFn<T>; export declare function Table<S, T, Context extends PageSelectionContext<S>>(props: TableProps<S, T, Context>): import("react/jsx-runtime").JSX.Element; export declare const oneRowForStructure: <S, T extends unknown, Context>(id: string, state: LensState<S, T[], Context>, paths: NameAnd<(s: LensState<S, T, Context>) => LensState<S, any, Context>>, ...extraTds: ((i: number, row: T) => JSX.Element)[]) => OneRowFn<T>; export interface StructureTableProps<S, T, Context> extends CommonTableProps<S, T, Context> { paths: NameAnd<(s: LensState<S, T, Context>) => LensState<S, any, Context>>; } export declare function StructureTable<S, T, Context extends PageSelectionContext<S>>(props: StructureTableProps<S, T, Context>): import("react/jsx-runtime").JSX.Element; export interface TableWithHighLightIfOverProps<S, T, Context> extends TableProps<S, T, Context> { nameOfCellForMinimum: keyof T; minimumValue: number; classNameOfHighlight: string; } export declare function TableWithHighLightIfOver<S, T, Context extends PageSelectionContext<S>>(props: TableWithHighLightIfOverProps<S, T, Context>): import("react/jsx-runtime").JSX.Element; export interface TableWithHighLightIfOverDataDependantProps<S, T, Context> extends TableProps<S, T, Context> { nameOfCellForMinimum: keyof T; minimumPath: LensState<S, number, Context>; classNameOfHighlight: string; } export declare function TableWithHighLightIfOverDataDependant<S, T, Context extends PageSelectionContext<S>>(props: TableWithHighLightIfOverDataDependantProps<S, T, Context>): import("react/jsx-runtime").JSX.Element;