import { RowClickedEvent, RowDoubleClickedEvent, RowHeightParams } from '@xh/hoist/kit/ag-grid'; import { ColumnRenderer, GridConfig, GridModel, GroupRowRenderer, RowClassFn, RowClassRuleFn, GridSorterLike, GridContextMenuSpec, GridGroupSortFn } from '@xh/hoist/cmp/grid'; import { HoistModel, LoadSpec, PlainObject, Some } from '@xh/hoist/core'; import { Store, StoreConfig, StoreRecord, StoreRecordOrId, StoreSelectionConfig, StoreSelectionModel, StoreTransaction } from '@xh/hoist/data'; import { ReactNode } from 'react'; /** * Configuration for a {@link DataViewModel} - a list-style data component that renders * each record using a custom `renderer` function. Built on {@link GridModel} internally. * * @see DataViewModel */ export interface DataViewConfig { /** A Store instance, or a config to create one. */ store?: Store | StoreConfig; /** Renderer to use for each data row. */ renderer?: ColumnRenderer; /** Row height (in px) for each item displayed in the view, or a function which returns a number.*/ itemHeight?: number | ItemHeightFn; /** Field(s) by which to do full-width row grouping. */ groupBy?: Some; /** Height (in px) of a group row. */ groupRowHeight?: number; /** Function used to render group rows. */ groupRowRenderer?: GroupRowRenderer; /** True (default) to show a count of group member rows within each full-width group row. */ showGroupRowCounts?: boolean; /** * Function to use to sort full-row groups. Called with two group values to compare * in the form of a standard JS comparator. Default is an ascending string sort. * Set to `null` to prevent sorting of groups. */ groupSortFn?: GridGroupSortFn; /** Sort specification. */ sortBy?: Some; /** Specification of selection behavior. Defaults to 'single' (desktop) and 'disabled' (mobile) */ selModel?: StoreSelectionModel | StoreSelectionConfig | 'single' | 'multiple' | 'disabled'; /** Text/HTML to display if view has no records.*/ emptyText?: ReactNode; /** True (default) to hide empty text until after the Store has been loaded at least once. */ hideEmptyTextBeforeLoad?: boolean; /** True to highlight the currently hovered row.*/ showHover?: boolean; /** True to render row borders.*/ rowBorders?: boolean; /** True to use alternating backgrounds for rows.*/ stripeRows?: boolean; /** * Array of RecordActions, dividers, or token strings with which to create a context menu. * May also be specified as a function returning same. */ contextMenu?: GridContextMenuSpec; /** * Closure to generate CSS class names for a row. * NOTE that, once added, classes will *not* be removed if the data changes. * Use `rowClassRules` instead if StoreRecord data can change across refreshes. */ rowClassFn?: RowClassFn; /** * Object keying CSS class names to functions determining if they should be added or * removed from the row. See Ag-Grid docs on "row styles" for details. */ rowClassRules?: Record; /** * Callback when a row is clicked. (Note that the event received may be null - e.g. for clicks * on full-width group rows.) */ onRowClicked?: (e: RowClickedEvent) => void; /** * Callback when a row is double-clicked. (Note that the event received may be null - e.g. for * clicks on full-width group rows.) */ onRowDoubleClicked?: (e: RowDoubleClickedEvent) => void; /** * "Escape hatch" object to pass directly to GridModel. Note these options may be used * / overwritten by the framework itself, and are not all guaranteed to be compatible * with its usages of GridModel. */ gridOptions?: Omit; } export type ItemHeightFn = (params: { record: StoreRecord; dataViewModel: DataViewModel; agParams: RowHeightParams; }) => number; /** * Model for a {@link DataView} - a list-style data component that renders each record * using a custom `renderer` function. Built on {@link GridModel} internally. * * Use DataView when you need full control over how each row is rendered as a single * custom element (e.g. a card or summary tile), as opposed to the column-based layout * of a standard Grid. For a middle ground with multi-zone row layouts, see * {@link ZoneGridModel}. * * Key configs: `renderer` (required - produces the visual for each row), `itemHeight`, * `groupBy`, and standard store/selection options inherited from GridModel. * * @see DataView * @see DataViewConfig */ export declare class DataViewModel extends HoistModel { gridModel: GridModel; itemHeight: number | ItemHeightFn; groupRowHeight: number; constructor(config: DataViewConfig); get store(): Store; get empty(): boolean; get selModel(): StoreSelectionModel; get hasSelection(): boolean; get selectedRecords(): StoreRecord[]; get selectedRecord(): StoreRecord; get selectedId(): import("@xh/hoist/data").StoreRecordId; get groupBy(): string[]; get sortBy(): import("@xh/hoist/cmp/grid").GridSorter[]; selectAsync(records: Some, opts?: { ensureVisible?: boolean; clearSelection?: boolean; }): Promise; preSelectFirstAsync(): Promise; selectFirstAsync(opts?: { ensureVisible?: boolean; }): Promise; ensureSelectionVisibleAsync(): Promise; doLoadAsync(loadSpec: LoadSpec): Promise; loadData(rawData: any[], rawSummaryData?: PlainObject): void; updateData(rawData: PlainObject[] | StoreTransaction): import("@xh/hoist/data").StoreChangeLog; clear(): void; setGroupBy(colIds: Some): void; setSortBy(sorters: Some): void; }