import { type GridMetrics, type GridRange, type GridState, type ModelIndex, type ModelSizeMap, type MoveOperation, type VisibleIndex } from '@deephaven/grid'; import type { dh as DhType } from '@deephaven/jsapi-types'; import { type ReverseType, type SortDirection, type FormattingRule, type SortDescriptor } from '@deephaven/jsapi-utils'; import AggregationOperation from './sidebar/aggregations/AggregationOperation'; import { type FilterData, type IrisGridState } from './IrisGrid'; import { type ColumnName, type OperationMap, type ReadonlyAdvancedFilterMap, type ReadonlyQuickFilterMap, type InputFilter, type CellData, type PendingDataMap, type UIRow, type UITotalsTableConfig, type AdvancedFilterOptions } from './CommonTypes'; import { type UIRollupConfig } from './sidebar/RollupRows'; import { type Aggregation, type AggregationSettings } from './sidebar/aggregations/Aggregations'; import { type FormattingRule as SidebarFormattingRule } from './sidebar/conditional-formatting/ConditionalFormattingUtils'; import type IrisGridModel from './IrisGridModel'; import type AdvancedSettingsType from './sidebar/AdvancedSettingsType'; import ColumnHeaderGroup, { type ColumnHeaderGroupConfig } from './ColumnHeaderGroup'; import { type PartitionConfig } from './PartitionedGridModel'; import { type IrisGridThemeType } from './IrisGridTheme'; export type HydratedIrisGridState = Pick & { metrics?: Partial; /** * The metric calculator instance, used to access the by-name user column * widths map (the source of truth across model swaps). */ metricCalculator?: IrisGridState['metricCalculator']; }; export type DehydratedPendingDataMap = [number, { data: [string, T][]; }][]; export type DehydratedAdvancedFilter = [ number, { options: AdvancedFilterOptions; } ]; export type DehydratedQuickFilter = [ number, { text: string; } ]; export type DehydratedCustomColumnFormat = [string, FormattingRule]; export type DehydratedUserColumnAlignment = [string, CanvasTextAlign]; export type DehydratedUserColumnWidth = [ColumnName, number]; export type DehydratedUserRowHeight = [number, number]; export type DehydratedPartitionConfig = PartitionConfig; /** @deprecated Use `DehydratedSort` instead */ export interface LegacyDehydratedSort { column: ModelIndex; isAbs: boolean; direction: SortDirection; } export interface DehydratedSort { column: ColumnName; isAbs: boolean; direction: string; } export interface TableSettings { quickFilters?: readonly DehydratedQuickFilter[]; advancedFilters?: readonly DehydratedAdvancedFilter[]; inputFilters?: readonly InputFilter[]; sorts?: readonly (DehydratedSort | LegacyDehydratedSort)[]; partitions?: unknown[]; partitionColumns?: ColumnName[]; } export interface DehydratedIrisGridState { advancedFilters: readonly DehydratedAdvancedFilter[]; aggregationSettings: AggregationSettings; customColumnFormatMap: readonly DehydratedCustomColumnFormat[]; columnAlignmentMap: readonly DehydratedUserColumnAlignment[]; isFilterBarShown: boolean; quickFilters: readonly DehydratedQuickFilter[]; sorts: readonly DehydratedSort[]; userColumnWidths: readonly DehydratedUserColumnWidth[]; userRowHeights: readonly DehydratedUserRowHeight[]; customColumns: readonly ColumnName[]; conditionalFormats: readonly SidebarFormattingRule[]; /** @deprecated use `reverse` instead. Can be removed after DHE sanluis release */ reverseType?: ReverseType; reverse: boolean; rollupConfig?: UIRollupConfig; showSearchBar: boolean; searchValue: string; selectDistinctColumns: readonly ColumnName[]; selectedSearchColumns: readonly ColumnName[]; invertSearchColumns: boolean; pendingDataMap: DehydratedPendingDataMap; frozenColumns: readonly ColumnName[]; columnHeaderGroups?: readonly DhType.ColumnGroup[]; partitionConfig?: DehydratedPartitionConfig; } export interface DehydratedIrisGridPanelStateV1 { isSelectingPartition: boolean; partition: string | null; advancedSettings: [AdvancedSettingsType, boolean][]; } export interface DehydratedIrisGridPanelStateV2 { isSelectingPartition: boolean; partitions: (string | null)[]; advancedSettings: [AdvancedSettingsType, boolean][]; } export type DehydratedIrisGridPanelState = DehydratedIrisGridPanelStateV1 | DehydratedIrisGridPanelStateV2; export declare function isPanelStateV1(state: DehydratedIrisGridPanelState): state is DehydratedIrisGridPanelStateV1; export declare function isPanelStateV2(state: DehydratedIrisGridPanelState): state is DehydratedIrisGridPanelStateV2; export type HydratedGridState = Pick; export type DehydratedGridState = { isStuckToBottom: boolean; isStuckToRight: boolean; movedColumns: readonly { from: string | [string, string] | ModelIndex | [ModelIndex, ModelIndex]; to: string | ModelIndex; }[]; movedRows: readonly MoveOperation[]; }; declare class IrisGridUtils { /** * Exports the state from Grid component to a JSON stringifiable object. * See IrisGridCacheUtil for memoization and comparing dehydrated states. * @param model The table model to export the Grid state for * @param gridState The state of the Grid to export * @returns An object that can be stringified and imported with {{@link hydrateGridState}} */ static dehydrateGridState(model: IrisGridModel, gridState: HydratedGridState): DehydratedGridState; /** * Import a state for Grid that was exported with {{@link dehydrateGridState}} * @param model The table model to import the state for * @param gridState The state of the panel that was saved * @returns The gridState props to set on the Grid */ static hydrateGridState(model: IrisGridModel, gridState: DehydratedGridState, customColumns?: readonly string[]): HydratedGridState; /** * Export the IrisGridPanel state. * @param model The table model the state is being dehydrated with * @param irisGridPanelState The current IrisGridPanel state * @returns The dehydrated IrisGridPanel state */ static dehydrateIrisGridPanelState(model: IrisGridModel, irisGridPanelState: { isSelectingPartition: boolean; partitions: (string | null)[]; advancedSettings: Map; }): DehydratedIrisGridPanelState; /** * Import the saved IrisGridPanel state. * @param model The model the state is being hydrated with * @param irisGridPanelState Exported IrisGridPanel state * @returns The state to apply to the IrisGridPanel */ static hydrateIrisGridPanelState(model: IrisGridModel, irisGridPanelState: DehydratedIrisGridPanelState): { isSelectingPartition: boolean; partitions: (string | null)[]; advancedSettings: Map; }; /** * Export the quick filters to JSON striginfiable object * @param quickFilters The quick filters to dehydrate * @returns The dehydrated quick filters */ static dehydrateQuickFilters(quickFilters: ReadonlyQuickFilterMap): DehydratedQuickFilter[]; static dehydrateLong(value: T): string | null; /** * Export the sorts from the provided table sorts to JSON stringifiable object * @param sorts The table sorts * @returns The dehydrated sorts */ static dehydrateSort(sorts: readonly SortDescriptor[]): DehydratedSort[]; /** * Pulls just the table settings from the panel state, eg. filters/sorts * @param panelState The dehydrated panel state * @returns A dehydrated table settings object, { partition, partitionColumn, advancedFilters, quickFilters, sorts } */ static extractTableSettings(panelState: { irisGridState: { advancedFilters: AF; quickFilters: QF; sorts: S; }; irisGridPanelState: DehydratedIrisGridPanelState; }, inputFilters?: InputFilter[]): { partitions: unknown[]; advancedFilters: AF; inputFilters: InputFilter[]; quickFilters: QF; sorts: S; }; static getInputFiltersForColumns(columns: readonly { name: string; type: string; }[], inputFilters?: readonly InputFilter[]): InputFilter[]; static getFiltersFromFilterMap(filterMap: ReadonlyAdvancedFilterMap | ReadonlyQuickFilterMap): DhType.FilterCondition[]; /** * Get array of hidden column indexes * @param userColumnWidths Map of user column widths * @returns Array of hidden column indexes */ static getHiddenColumns(userColumnWidths: ModelSizeMap): ModelIndex[]; static parseCustomColumnNames(customColumns: readonly ColumnName[]): ColumnName[]; static getRemovedCustomColumnNames(oldCustomColumns: readonly ColumnName[], customColumns: readonly ColumnName[]): ColumnName[]; static removeSortsInColumns(sorts: readonly SortDescriptor[], columnNames: readonly string[]): readonly SortDescriptor[]; static removeFiltersInColumns(columns: readonly DhType.Column[], filters: ReadonlyMap, removedColumnNames: readonly ColumnName[]): Map; static removeColumnFromMovedColumns(columns: readonly DhType.Column[], movedColumns: readonly MoveOperation[], removedColumnNames: readonly ColumnName[]): MoveOperation[]; static removeColumnsFromSelectDistinctColumns(selectDistinctColumns: readonly ColumnName[], removedColumnNames: readonly ColumnName[]): ColumnName[]; static getVisibleColumnsInRange(tableColumns: readonly DhType.Column[], left: number, right: number, movedColumns: readonly MoveOperation[], hiddenColumns: readonly number[]): DhType.Column[]; static getPrevVisibleColumns(tableColumns: readonly DhType.Column[], startIndex: VisibleIndex, count: number, movedColumns: readonly MoveOperation[], hiddenColumns: readonly VisibleIndex[]): DhType.Column[]; static getNextVisibleColumns(tableColumns: readonly DhType.Column[], startIndex: VisibleIndex, count: number, movedColumns: readonly MoveOperation[], hiddenColumns: readonly VisibleIndex[]): DhType.Column[]; static getColumnsToFetch(tableColumns: readonly DhType.Column[], viewportColumns: readonly DhType.Column[], alwaysFetchColumnNames: readonly ColumnName[]): DhType.Column[]; static getModelViewportColumns(columns: readonly DhType.Column[], left: number | null, right: number | null, movedColumns: readonly MoveOperation[], hiddenColumns?: readonly VisibleIndex[], alwaysFetchColumnNames?: readonly ColumnName[], bufferPages?: number): DhType.Column[] | undefined; /** * Validate whether the ranges passed in are valid to take a snapshot from. * Multiple selections are valid if all of the selected rows have the same columns selected. * * @param ranges The ranges to validate * @returns True if the ranges are valid, false otherwise */ static isValidSnapshotRanges(ranges: readonly GridRange[]): boolean; /** * Check if the provided value is a valid table index * @param value A value to check if it's a valid table index */ static isValidIndex(value: unknown): boolean; /** * Returns all columns used in any of the ranges provided * @param ranges The model ranges to get columns for * @param allColumns All the columns to pull from * @returns The columns selected in the range */ static columnsFromRanges(ranges: readonly GridRange[], allColumns: readonly DhType.Column[]): DhType.Column[]; /** * Transforms an iris data snapshot into a simple data matrix * @param data The Iris formatted table data * @returns A matrix of the values of the data */ static snapshotDataToMatrix(data: DhType.TableData): unknown[][]; /** * Hydrate model rollup config * @param originalColumns Original model columns * @param config Dehydrated rollup config * @param aggregationSettings Aggregation settings * @returns Rollup config for the model */ static getModelRollupConfig(originalColumns: readonly DhType.Column[], config: UIRollupConfig | undefined, aggregationSettings: AggregationSettings): DhType.RollupConfig | null; /** * Build a per-column aggregation operation map for use in a * `UITotalsTableConfig`. Rollup-only operations are skipped. */ static getOperationMap(columns: readonly DhType.Column[], aggregations: readonly Aggregation[]): OperationMap; /** * Ordered list of (non-rollup) operations used by a totals table. */ static getOperationOrder(aggregations: readonly Aggregation[]): AggregationOperation[]; /** * Hydrate model totals config for a standalone aggregations view * (no rollup). Returns `null` when there are no active aggregations * or when a rollup is active (in which case aggregations are folded * into the rollup config instead — see `getModelRollupConfig`). * * @param columns Model columns * @param rollupConfig Current rollup config (or undefined). When set * with at least one grouping column, this returns * `null` so totals don't double-up with the rollup. * @param aggregationSettings Aggregation settings */ static getModelTotalsConfig(columns: readonly DhType.Column[], rollupConfig: UIRollupConfig | undefined, aggregationSettings: AggregationSettings): UITotalsTableConfig | null; /** * Returns true when all rollback-tracked config fields are at their default * (empty) values, meaning there is no meaningful state to save or restore. */ static isEmptyConfig({ advancedFilters, aggregationSettings, conditionalFormats, customColumns, quickFilters, reverse, rollupConfig, searchFilter, selectDistinctColumns, sorts, }: { advancedFilters: ReadonlyAdvancedFilterMap; aggregationSettings: AggregationSettings; conditionalFormats: readonly SidebarFormattingRule[]; customColumns: readonly ColumnName[]; quickFilters: ReadonlyQuickFilterMap; reverse: boolean; rollupConfig?: UIRollupConfig; searchFilter?: DhType.FilterCondition; selectDistinctColumns: readonly ColumnName[]; sorts: readonly SortDescriptor[]; }): boolean; /** * @param pendingDataMap Map of pending data * @returns A map with the errors in the pending data */ static getPendingErrors(pendingDataMap: Map): void; /** * Retrieves a column from the provided array at the index, or `null` and logs an error if it's invalid * * @param columns The columns to get the column from * @param columnIndex The column index to get */ static getColumn(columns: readonly DhType.Column[], columnIndex: ModelIndex): DhType.Column | null; /** * Retrieves a column from the provided array matching the name, or `null` and logs an error if not found * @param columns The columns to get the column from * @param columnName The column name to retrieve */ static getColumnByName(columns: readonly DhType.Column[], columnName: ColumnName): DhType.Column | undefined; /** * Get filter configs with column names changed to indexes, exclude missing columns * @param columns The columns to get column indexes from * @param filters Filter configs * @returns Updated filter configs with column names changed to indexes */ static changeFilterColumnNamesToIndexes(columns: readonly DhType.Column[], filters: { name: ColumnName; filter: T; }[]): [number, T][]; /** * @param columnType The column type that the filters will be applied to. * @param filterList The list of filters to be combined. * @returns The combination of the filters in filterList as text. */ static combineFiltersFromList(columnType: string | null, filterList: FilterData[]): string; /** * Parses the column header groups provided. * If undefined, should provide default groups such as from layoutHints * * @returns Object containing groups array, max depth, map of name to parent group, and map of name to group */ static parseColumnHeaderGroups(model: IrisGridModel, groupsParam: readonly (DhType.ColumnGroup | T)[], makeColumnHeaderGroup?: (args: C) => T): { groups: T[]; maxDepth: number; parentMap: Map; groupMap: Map; }; /** * @param value The value of the cell in a column * @param columnType The type of the column * @returns The value of the cell converted to text */ static convertValueToText(value: unknown, columnType: string): string; private dh; private tableUtils; constructor(dh: typeof DhType); /** * Exports the state from IrisGrid to a JSON stringifiable object. * See IrisGridCacheUtil for memoization and comparing dehydrated states. * @param model The table model to export the state for * @param irisGridState The current state of the IrisGrid */ dehydrateIrisGridState(model: IrisGridModel, irisGridState: HydratedIrisGridState): DehydratedIrisGridState; /** * Migrates a single conditional formatting rule saved in the old format * (`column`/`value`) to the current format (`leftHandValue`/`rightHandValue`/ * `formattedColumns`). Rules already in the current format are returned * unchanged. */ static migrateConditionalFormattingRule(rule: SidebarFormattingRule): SidebarFormattingRule; /** * Import a state for IrisGrid that was exported with {{@link dehydrateIrisGridState}} * @param model The table model to import the state with * @param irisGridState The saved IrisGrid state */ hydrateIrisGridState(model: IrisGridModel, irisGridState: DehydratedIrisGridState): Omit & { userColumnWidths: ModelSizeMap; userColumnWidthsByName: Map; userRowHeights: ModelSizeMap; }; /** * Import the saved quick filters to apply to the columns. Does not actually apply the filters. * @param columns The columns the filters will be applied to * @param savedQuickFilters Exported quick filters definitions * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York * @returns The quick filters to apply to the columns */ hydrateQuickFilters(columns: readonly DhType.Column[], savedQuickFilters: readonly DehydratedQuickFilter[], timeZone?: string): ReadonlyQuickFilterMap; /** * Export the advanced filters from the provided columns to JSON striginfiable object * @param columns The columns for the filters * @param advancedFilters The advanced filters to dehydrate * @returns The dehydrated advanced filters */ dehydrateAdvancedFilters(columns: readonly DhType.Column[], advancedFilters: ReadonlyAdvancedFilterMap): DehydratedAdvancedFilter[]; /** * Import the saved advanced filters to apply to the columns. Does not actually apply the filters. * @param columns The columns the filters will be applied to * @param savedAdvancedFilters Exported advanced filters definitions * @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York * @returns The advanced filters to apply to the columns */ hydrateAdvancedFilters(columns: readonly DhType.Column[], savedAdvancedFilters: readonly DehydratedAdvancedFilter[], timeZone: string): ReadonlyAdvancedFilterMap; dehydrateAdvancedFilterOptions(column: DhType.Column, options: AdvancedFilterOptions): AdvancedFilterOptions; hydrateAdvancedFilterOptions(column: DhType.Column, options: AdvancedFilterOptions): AdvancedFilterOptions; dehydratePendingDataMap(columns: readonly DhType.Column[], pendingDataMap: PendingDataMap): DehydratedPendingDataMap; hydratePendingDataMap(columns: readonly DhType.Column[], pendingDataMap: DehydratedPendingDataMap): Map; }>; dehydratePartitionConfig(partitionColumns: readonly DhType.Column[], partitionConfig: PartitionConfig | undefined): PartitionConfig | undefined; hydratePartitionConfig(partitionColumns: readonly DhType.Column[], partitionConfig: PartitionConfig | undefined): PartitionConfig | undefined; /** * Dehydrates/serializes a value for storage. * @param value The value to dehydrate * @param columnType The column type */ dehydrateValue(value: T, columnType: string): string | T | null; /** * Hydrate a value from it's serialized state * @param value The dehydrated value that needs to be hydrated * @param columnType The type of column */ hydrateValue(value: T, columnType: string): DhType.DateWrapper | DhType.LongWrapper | T | null; dehydrateDateTime(value: number | DhType.DateWrapper | Date): string | null; hydrateDateTime(value: string): DhType.DateWrapper | null; hydrateLong(value: string): DhType.LongWrapper | null; /** * Import the saved sorts to apply to the model. Does not actually apply the sort. * @param columns The columns the sorts will be applied to * @param sorts Exported sort definitions * @param dropReverse If true, drop reverse sort descriptors from the result * @returns The sort descriptors to apply to the model */ hydrateSort(columns: readonly DhType.Column[], sorts: readonly (DehydratedSort | LegacyDehydratedSort)[], dropReverse?: boolean): readonly SortDescriptor[]; hydrateDhSort(columns: readonly DhType.Column[], sorts: readonly SortDescriptor[]): DhType.Sort[]; /** * Applies the passed in table settings directly to the provided table * @param table The table to apply the settings to * @param tableSettings Dehydrated table settings extracted with `extractTableSettings` * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York */ applyTableSettings(table: DhType.Table, tableSettings: TableSettings, timeZone: string): void; getFiltersFromInputFilters(columns: readonly DhType.Column[], inputFilters?: readonly InputFilter[], timeZone?: string): DhType.FilterCondition[]; /** * Get the dh.RangeSet representation of the provided ranges. * Ranges are sorted prior to creating the RangeSet. Only the rows are taken into account, * RangeSet does not have an option for columns. * @param ranges The ranges to get the range set for * @returns The rangeset for the provided ranges */ rangeSetFromRanges(ranges: readonly GridRange[]): DhType.RangeSet; /** * Get the color for a cell value * @param theme The IrisGrid theme * @param columnType The type of the column * @param columnName The name of the column * @param value The value of the cell * @returns The color for the cell value */ static colorForValue(theme: IrisGridThemeType, columnType: string, columnName: string, value: unknown): string; /** * Determines the text alignment for a cell value * @param columnType The type of the column * @param columnName The name of the column * @returns The text alignment for the cell value */ static textAlignForValue(columnType: string, columnName: string): CanvasTextAlign; } export default IrisGridUtils; //# sourceMappingURL=IrisGridUtils.d.ts.map