import type { Event, EventTarget } from 'event-target-shim'; import { type BoundedAxisRange, type ColumnRestriction, type DataBarGridModel, type DataBarOptions, type GridCell, GridModel, type GridRange, type GridThemeType, type ModelIndex, type MoveOperation, type VisibleIndex } from '@deephaven/grid'; import type { dh as DhType } from '@deephaven/jsapi-types'; import { type Formatter, type SortDescriptor } from '@deephaven/jsapi-utils'; import { type ColumnName, type UITotalsTableConfig, type PendingDataMap, type PendingDataErrorMap, type PendingOperationDetail } from './CommonTypes'; import type ColumnHeaderGroup from './ColumnHeaderGroup'; export type DisplayColumn = DhType.Column & { /** * Name to display with the column. * The `name` property on `Column` is a unique identifier and must be a valid Java identifier, * whereas `displayName` can be any string and does not need to be unique. */ displayName?: string; /** * Whether this column is a proxy column for other columns or not. * If it's a proxy column, it may not appear in some lists. */ isProxy?: boolean; }; type IrisGridModelEventNames = (typeof IrisGridModel.EVENT)[keyof typeof IrisGridModel.EVENT]; type IrisGridModelEventMap = { [E in IrisGridModelEventNames]: Event; }; /** * Abstract class that extends the GridModel to have more functionality, like filtering and sorting. * For use from IrisGrid. * Provides some abstraction from the dh.Table and dh.TreeTable classes, so we can treat them somewhat the same. * Note that it still uses dh.Column, dh.FilterCondition, dh.Sort, etc., still. Theoretically should abstract * those out as well, so there's no dependency on IrisAPI at all, but it's a lot of work for no real gain at this time. */ declare abstract class IrisGridModel> = Record>, TMode extends 'standard' | 'strict' = 'standard'> extends GridModel implements DataBarGridModel { static EVENT: Readonly<{ readonly UPDATED: "UPDATED"; readonly FORMATTER_UPDATED: "FORMATTER_UPDATED"; readonly REQUEST_FAILED: "REQUEST_FAILED"; readonly COLUMNS_CHANGED: "COLUMNS_CHANGED"; readonly TABLE_CHANGED: "TABLE_CHANGED"; /** * Fired by `IrisGridProxyModel` whenever its inner model is swapped for a * different instance (e.g. pivot-builder swapping a table model for a pivot * model, or back). The `detail` is the new inner model. Unlike * `TABLE_CHANGED` (only dispatched for table-template models), this fires on * every inner-model swap regardless of model class, so the host can reset * view state (e.g. `movedColumns`) that the previous model owned. */ readonly SCHEMA_CHANGED: "SCHEMA_CHANGED"; readonly FILTERS_CHANGED: "FILTERS_CHANGED"; readonly SORTS_CHANGED: "SORTS_CHANGED"; readonly DISCONNECT: "DISCONNECT"; readonly RECONNECT: "RECONNECT"; readonly TOTALS_UPDATED: "TOTALS_UPDATED"; /** Fired when the viewport is applied to the table and we're waiting for a response. */ readonly PENDING_DATA_UPDATED: "PENDING_DATA_UPDATED"; readonly VIEWPORT_UPDATED: "VIEWPORT_UPDATED"; /** * Fired when an async, config-changing operation has begun. Raises the * IrisGrid loading scrim. Detail is an optional, self-describing * {@link PendingOperationDetail} so an initiator (e.g. a plugin) can raise * the scrim for an operation IrisGrid has no built-in knowledge of. */ readonly PENDING: "PENDING"; /** * Optional completion signal for a pending operation that does NOT * naturally end in `UPDATED` / `COLUMNS_CHANGED` / `REQUEST_FAILED`. * Built-in operations never need this; their existing events clear the * scrim. * * Assumes a single outstanding model-driven operation: the scrim is not * ref-counted, so a `PENDING_CLEARED` clears it regardless of other * in-flight operations. Ref-counting is deferred to the planned migration * that routes built-in `startLoading` calls through these events, where a * depth counter can stay balanced. */ readonly PENDING_CLEARED: "PENDING_CLEARED"; }>; constructor(dh: typeof DhType); dh: typeof DhType; listenerCount: number; addEventListener(type0: T, callback0?: EventTarget.EventListener | null, options0?: boolean | EventTarget.AddOptions): void; removeEventListener(type0: T, callback0?: EventTarget.EventListener | null, options0?: boolean | EventTarget.Options): void; /** * Function called when first listener is added. * Override for implementation specific behaviour. */ startListening(): void; /** * Function called when last listener is removed. * Override for implementation specific behaviour. */ stopListening(): void; /** * Dispatch a `PENDING` event to raise the IrisGrid loading scrim for an * async, config-changing operation initiated on this model. * @param detail Optional self-describing detail (scrim text and options). */ protected dispatchPending(detail?: PendingOperationDetail): void; /** * Gets the columns for this model * @returns All columns in the model */ abstract get columns(): readonly DisplayColumn[]; /** * Retrieve the aggregated columns for this model * @returns The columns that are aggregated */ get aggregatedColumns(): readonly DisplayColumn[]; /** * Retrieve the grouped columns for this model * @returns The columns that are grouped */ get groupedColumns(): readonly DisplayColumn[]; /** * Gets the columns for the model before any transformations (such as rollups) are applied. * @returns All original columns in the model. */ get originalColumns(): readonly DisplayColumn[]; /** * Gets the column index for this model * @param name The model column name. * @returns The numeric index of the requested column. */ abstract getColumnIndexByName(name: string): ModelIndex | undefined; /** * Retrieve the source cell for a given cell. Returns something different if the cell is a proxied cell * that retrieves data from another cell. * @param column Column to get the source for * @param row Row to get the source for * @returns Source cell where the data is coming from */ sourceForCell(column: ModelIndex, row: ModelIndex): GridCell; /** * Retrieve the range of columns to clear filters on for a given column. * @param column Column to get the range of filters to clear. * @returns Axis range of the column filters to clear, or `null` if this should not have a clear filter option. */ getClearFilterRange(column: ModelIndex): BoundedAxisRange | null; /** List of column movements defined by the model. Used as initial movements for IrisGrid */ get initialMovedColumns(): readonly MoveOperation[]; /** List of row movements defined by the model. Used as initial movements for IrisGrid */ get initialMovedRows(): readonly MoveOperation[]; /** List of column header groups defined by the model */ get initialColumnHeaderGroups(): readonly ColumnHeaderGroup[]; /** * @param column The model column index * @param row The model row index * @returns The format stored for that cell */ abstract formatForCell(column: ModelIndex, row: ModelIndex): DhType.Format | undefined; /** * @param column The model column index * @param row The model row index * @returns The value stored for that cell */ abstract valueForCell(column: ModelIndex, row: ModelIndex): unknown; /** * @returns The filters set on this model */ abstract get filter(): readonly DhType.FilterCondition[]; /** * @param filter The filters to set */ abstract set filter(filter: readonly DhType.FilterCondition[]); /** * @returns The formatter used when formatting data */ abstract get formatter(): Formatter; /** * @param formatter The formatter to set */ abstract set formatter(formatter: Formatter); /** * @returns The column alignment map */ abstract get columnAlignmentMap(): ReadonlyMap; /** * @param columnAlignmentMap The column alignment map to set */ abstract set columnAlignmentMap(columnAlignmentMap: Map); /** * @param value The value to format * @param columnType The column type to format * @param columnName The column name to format */ abstract displayString(value: unknown, columnType: string, columnName?: ColumnName): string; /** * @returns The sorts used on this model */ abstract get sort(): readonly SortDescriptor[]; /** * @param sort The sorts to use on this model */ abstract set sort(sort: readonly SortDescriptor[]); /** /** * @returns The custom columns on this model */ abstract get customColumns(): readonly ColumnName[]; /** * @param customColumns The custom columns to use */ abstract set customColumns(customColumns: readonly ColumnName[]); /** * @returns The format columns on this model */ abstract get formatColumns(): readonly DhType.CustomColumn[]; /** * @param formatColumns The format columns to use */ abstract set formatColumns(formatColumns: readonly DhType.CustomColumn[]); /** * @param columns The columns to treat as frozen */ abstract updateFrozenColumns(columns: readonly ColumnName[]): void; /** * @returns The config to use for rolling up this table */ abstract get rollupConfig(): DhType.RollupConfig | null; abstract set rollupConfig(rollupConfig: DhType.RollupConfig | null); /** * @returns The config to use for the totals table of this model */ abstract get totalsConfig(): UITotalsTableConfig | null; abstract set totalsConfig(totalsConfig: UITotalsTableConfig | null); /** * @returns The LayoutHints to use for the columns of this table model */ get layoutHints(): DhType.LayoutHints | null | undefined; /** * @returns Names of columns which should be locked to the front, but not floating */ get frontColumns(): readonly ColumnName[]; /** * @returns Names of columns which should be locked to the back, but not floating */ get backColumns(): readonly ColumnName[]; /** * @returns Names of key columns */ get keyColumnSet(): Set; /** * @returns Names of value columns */ get valueColumnSet(): Set; /** * @returns Names of columns which should be frozen to the front and floating */ get frozenColumns(): readonly ColumnName[]; /** * @param index The column index to check * @returns Whether the column is one of LayoutHints' frozen columns */ isColumnFrozen(index: ModelIndex): boolean; /** * @param index The column index to check * @returns Whether the column is sortable */ isColumnSortable(index: ModelIndex): boolean; /** * @deprecated Replaced with isPartitionRequired() * @returns True if this model requires a filter to be set */ get isFilterRequired(): boolean; get isReversible(): boolean; /** * @returns Returns a raw table that is frozen and can be used for exporting data */ abstract export(): Promise; /** * @returns True if this model supports the columnStatistics(column) function */ get isColumnStatisticsAvailable(): boolean; /** * The description for this model. * @returns The description of the model */ get description(): string; /** * @param column The column to get statistics for * @returns The column statistics */ abstract columnStatistics(column: DhType.Column): Promise; /** * @returns True if this model supports aggregatedColumns */ get isAggregatedColumnsAvailable(): boolean; /** * @returns True if this model supports customColumns */ get isCustomColumnsAvailable(): boolean; /** * @returns True if this model supports customColumns */ get isFormatColumnsAvailable(): boolean; /** * @returns True if this model supports the export() function */ get isExportAvailable(): boolean; /** * @returns True if this model supports the valuesTable(column) function */ get isValuesTableAvailable(): boolean; /** * @returns True if this model should allow the chart builder */ get isChartBuilderAvailable(): boolean; /** * @returns True if this model should allow to organize columns */ get isOrganizeColumnsAvailable(): boolean; /** * @returns True if the rollup rows functionality is available */ get isRollupAvailable(): boolean; /** * @returns True if select distinct functionality is available */ get isSelectDistinctAvailable(): boolean; /** * @returns True if the totals functionality is available */ get isTotalsAvailable(): boolean; /** * The names of columns with select distinct enabled * @returns An array of column names */ abstract get selectDistinctColumns(): readonly ColumnName[]; /** * Set the columns with select distinct enabled * @param names The array of column names to enable select distinct on */ abstract set selectDistinctColumns(names: readonly ColumnName[]); /** * The pending data for this model * @returns A map of row index to a map of column name/value pairs */ abstract get pendingDataMap(): PendingDataMap; /** * Set the pending data for this model * @param A map of row index to a map of column name/value pairs */ abstract set pendingDataMap(map: PendingDataMap); /** * @returns The count of pending rows to show */ abstract get pendingRowCount(): number; /** * Set the count of pending rows to show * @param count The count of pending rows to show */ abstract set pendingRowCount(count: number); /** * Errors for the pending data * @returns Map from row number to the error */ abstract get pendingDataErrors(): PendingDataErrorMap; /** * Commit pending data and save all data to the table */ abstract commitPending(): Promise; /** * Check if viewport is still loading data */ get isViewportPending(): boolean; /** * Check if a column is filterable * @param columnIndex The column index to check for filterability * @returns True if the current provided column index is filterable, false otherwise */ isFilterable(columnIndex: ModelIndex): boolean; /** * Set the indices of the viewport * @param top Top of viewport * @param bottom Bottom of viewport * @param columns The columns in the viewport. `undefined` for all columns */ abstract setViewport(top: VisibleIndex, bottom: VisibleIndex, columns?: DhType.Column[]): void; /** * Takes a snapshot of the provided ranges * @param ranges The model ranges to take the snapshot of * @returns Returns the data in a row/column matrix */ abstract snapshot(ranges: readonly GridRange[]): Promise; /** * @param ranges The ranges to take a snapshot of * @param includeHeaders Whether to include the headers in the snapshot or not * @param formatValue A function to format a value for a cell. Defaults to model format value. * @returns A text formatted snapshot of the data for the specified range set */ abstract textSnapshot(ranges: readonly GridRange[], includeHeaders?: boolean, formatValue?: (value: unknown, column: DhType.Column, row?: DhType.Row) => string): Promise; /** * @param column The columns to get the distinct values for * @returns A table partitioned on the specified columns in the order given in */ abstract valuesTable(columns: DhType.Column | readonly DhType.Column[]): Promise; /** * Close this model. It can no longer be used after being closed */ close(): void; /** * Don't allow any rows to be movable in any IrisGrids by default. Just columns. */ isRowMovable(): boolean; abstract seekRow(startRow: number, column: DhType.Column, valueType: DhType.ValueTypeType, value: unknown, insensitive?: boolean, contains?: boolean, isBackwards?: boolean): Promise; get isSeekRowAvailable(): boolean; abstract get columnHeaderGroups(): readonly ColumnHeaderGroup[]; abstract set columnHeaderGroups(groups: readonly ColumnHeaderGroup[]); abstract get columnHeaderGroupMap(): ReadonlyMap; abstract getColumnHeaderParentGroup(modelIndex: ModelIndex, depth: number): ColumnHeaderGroup | undefined; dataBarOptionsForCell(column: number, row: number, theme: GridThemeType): DataBarOptions; tooltipForCell(column: ModelIndex, row: ModelIndex): string | null; getColumnRestrictions(column: ModelIndex): ColumnRestriction[]; } export declare const STRING_LIST_RESTRICTION_TYPE: "io.deephaven.proto.backplane.grpc.StringListRestriction"; /** * Restriction type for columns whose values must come from a predefined list of strings. */ export type StringListRestriction = ColumnRestriction & { type: typeof STRING_LIST_RESTRICTION_TYPE; allowedValues: string[]; }; export default IrisGridModel; //# sourceMappingURL=IrisGridModel.d.ts.map