// import { styleObjectType } from 'toolbox'; type styleObjectType = { [key: string]: string | number }; /** * Base grid function parameter(s) */ interface GridConfigFnParams { values: { [key: string]: any }; } interface CardFnParams extends GridConfigFnParams { recordIndex: number; } /** * Row function parameters. For example - functions like css, style rule functions */ interface RowFnParams extends GridConfigFnParams { rowIndex: number; } /** * Cell function parameters. For example - functions like css, style rule functions * For cells current cell value is also needed apart from values */ interface CellFnParams extends RowFnParams { cellValue: any; cellIndex: number; } type cellRendererFn = (params: CellFnParams) => string; type cellCallbackMultiRetFnStr = (params: CellFnParams) => (string | string[]); type cellCallbackMultiRetFnObj = (params: CellFnParams) => styleObjectType; type cellCssClassField = string | string[] | cellCallbackMultiRetFnStr; type cellCssStyleField = styleObjectType | cellCallbackMultiRetFnObj; type inlineChartStyleFn = (params: CellFnParams) => InlineChartStyle; type LayoutKeyType = keyof Layout; /** * Type of grid columns */ enum ColumnType { String = 'string', Number = 'number', DateTime = 'datetime', HTML = 'html', Chart = 'chart' } enum ValueTextPositionType { top = 'top', bottom = 'bottom', left = 'left', right = 'right', inside = 'inside' } enum ValueTextAlignmentType { start = 'start', end = 'end', middle = 'middle' } interface InlineChartStyle { positivebarclass?: string | string[]; positivebarstyle?: styleObjectType; negativebarclass?: string | string[]; negativebarstyle?: styleObjectType; hundredpercentbarclass?: string | string[]; hundredpercentbarstyle?: styleObjectType; valuetextclass?: string | string[]; valuetextstyle?: styleObjectType; } interface InlineChartConfig { type?: string; minvalue?: number; maxvalue?: number; showvalue?: boolean; showhundredpercentbar: boolean; barheight?: string | number; valuetextposition?: ValueTextPositionType; valuetextalignment?: ValueTextAlignmentType; style?: inlineChartStyleFn | InlineChartStyle; } interface DerivedInlineChartConfig extends InlineChartConfig { pxBarHeight?: number; } interface TooltipOptions { enable?: boolean; enableheadertooltip?: boolean; headertooltip?: string; enablecelltooltip?: boolean; celltooltip?: cellCallbackMultiRetFnStr; enablehelpericon?: boolean; enableheaderhelpericon?: boolean; enablecellhelpericon?: boolean; } interface SortableOptions { enable?: boolean; showSortIndicator?: boolean; order?: 'asc' | 'desc'; } interface HoverOptions { enable?: boolean; class?: cellCssClassField | rowCssClassField; style?: cellCssStyleField | rowCssStyleField; } interface ShowPagesConfig { enable?: boolean; showtotal?: boolean; userinput?: boolean; } interface PageSizeConfig { default?: number; options?: boolean | number[] } interface Pagination { enable?: boolean; showpages?: ShowPagesConfig; pagesize?: PageSizeConfig; showrecordcount?: boolean; showjumptoendbuttons?: boolean; showjumptofirstpagebutton?: boolean; showjumptolastpagebutton?: boolean; } /** * Column configuration options */ interface ColumnOptions { field?: string; headertext?: string; class?: cellCssClassField; style?: cellCssStyleField; headerclass?: cellCssClassField; headerstyle?: cellCssStyleField; cellclass?: cellCssClassField; cellstyle?: cellCssStyleField; width?: number; minwidth?: string | number; maxwidth?: string | number; wraptext?: string | boolean; sortable?: SortableOptions; hover?: HoverOptions; type?: ColumnType; template?: cellRendererFn; formatter?: cellRendererFn; chartconfig?: InlineChartConfig; tooltip?: TooltipOptions; } interface DerivedColumnOptions extends ColumnOptions { minContent?: number | string; maxContent?: number | string; scale?: any; pxWidth: number, pxMinWidth: number, pxMaxWidth?: number, derivedChartConfig?: DerivedInlineChartConfig } type rowCallbackMultiRetFnStr = (params: RowFnParams) => (string | string[]); type rowCallbackMultiRetFnObj = (params: RowFnParams) => styleObjectType; type rowCssClassField = string | string[] | rowCallbackMultiRetFnStr; type rowCssStyleField = styleObjectType | rowCallbackMultiRetFnObj; /** * Row selection */ interface RowSelection { enable?: boolean; selectionclass?: rowCssClassField; selectionstyle?: rowCssStyleField; enableselectioncheckbox?: boolean; rowselection?: string; } /** * Row configuration options */ interface RowOptions { rowheight?: string | number; headerrowheight?: string | number; class?: rowCssClassField; style?: rowCssStyleField; hover?: HoverOptions; selection?: RowSelection; } /** * will be used for internal purposes */ interface DerivedRowOptions extends RowOptions { pxRowHeight: number, pxHeaderRowHeight: number } /** * Layout type */ enum LayoutType { Row = 'row', Card = 'card' } /** * Layout density type */ enum LayoutDensityType { Default = 'default', Compact = 'compact', Comfortable = 'comfortable' } type templateFn = (params: CardFnParams) => string; /** * Layout definition */ interface Layout { type?: LayoutType; density?: LayoutDensityType; autoheight?: boolean; cardtemplate?: templateFn; numcards?: number; } interface GridOptions { columns: DerivedColumnOptions[]; layout?: Layout; rowoptions?: DerivedRowOptions; pagination?: Pagination; } interface ViewportGridOptions extends Partial { defaultColumnOptions?: ColumnOptions } /** * Viewport definition */ interface Viewport { minscreenwidth?: number; maxscreenwidth?: number; config?: ViewportGridOptions; } /** * Grid configurations */ interface GridConfig extends GridOptions { viewports?: { [key: string]: Viewport } events?: { [key: string]: Function } defaultcolumnoptions: any, columnGroups: Array, defaultColGroupOptions: Object } interface DomContainerProps { height: number, width: number } export { ColumnType, DomContainerProps, LayoutType, LayoutDensityType, ColumnOptions, DerivedColumnOptions, cellCssClassField, cellCssStyleField, rowCssClassField, rowCssStyleField, styleObjectType, RowOptions, RowFnParams, CellFnParams, CardFnParams, templateFn, Layout, Viewport, GridConfig, ValueTextPositionType, ValueTextAlignmentType, InlineChartConfig, InlineChartStyle, ViewportGridOptions, GridOptions, RowSelection, HoverOptions, DerivedRowOptions, DerivedInlineChartConfig, Pagination, LayoutKeyType };