import type { DataAccessObject, DomBindings, WalkontableInstance } from './types'; import type Settings from './settings'; import type Table from './table'; import type EventManager from '../../../eventManager'; import type { CalculationTypeLike, ColumnsCalculationType, RowsCalculationType } from './calculator/viewportBase'; import { ViewportColumnsCalculator, ViewportRowsCalculator } from './calculator'; import { PositionCache } from './utils/positionCache'; /** * @class Viewport */ declare class Viewport { /** * @type {DataAccessObject} */ dataAccessObject: DataAccessObject; /** * @type {WalkontableInstance} */ wot: WalkontableInstance; /** * @type {WalkontableInstance} */ instance: WalkontableInstance; /** * @type {DomBindings} */ domBindings: DomBindings; /** * @type {Settings} */ wtSettings: Settings; /** * @type {Table} */ wtTable: Table; /** * @type {Record} */ oversizedRows: Record; /** * @type {Record} */ oversizedColumnHeaders: Record; /** * @type {Record} */ hasOversizedColumnHeadersMarked: Record; /** * @type {number} */ clientHeight: number; /** * @type {number} */ columnHeaderHeight: number; /** * @type {number} */ rowHeaderWidth: number; /** * @type {RowsCalculationType | null} */ rowsVisibleCalculator: RowsCalculationType | null; /** * @type {ColumnsCalculationType | null} */ columnsVisibleCalculator: ColumnsCalculationType | null; /** * @type {Map CalculationTypeLike>} */ rowsCalculatorTypes: Map CalculationTypeLike>; /** * @type {Map CalculationTypeLike>} */ columnsCalculatorTypes: Map CalculationTypeLike>; /** * @type {EventManager} */ eventManager: EventManager; /** * @type {RowsCalculationType | null} */ rowsRenderCalculator: RowsCalculationType | null; /** * @type {ColumnsCalculationType | null} */ columnsRenderCalculator: ColumnsCalculationType | null; /** * @type {RowsCalculationType | null} */ rowsPartiallyVisibleCalculator: RowsCalculationType | null; /** * @type {ColumnsCalculationType | null} */ columnsPartiallyVisibleCalculator: ColumnsCalculationType | null; /** * @type {PositionCache} */ rowHeightCache: PositionCache; /** * @type {PositionCache} */ columnWidthCache: PositionCache; /** * @param {ViewportDao} dataAccessObject The Walkontable instance. * @param {DomBindings} domBindings Bindings into DOM. * @param {Settings} wtSettings The Walkontable settings. * @param {EventManager} eventManager The instance event manager. * @param {Table} wtTable The table. */ constructor(dataAccessObject: DataAccessObject, domBindings: DomBindings, wtSettings: Settings, eventManager: EventManager, wtTable: Table); /** * @returns {number} */ getWorkspaceHeight(): number; /** * @returns {number} */ getViewportHeight(): number; /** * Gets the width of the table workspace (in pixels). The workspace size in the current * implementation returns the width of the table holder element including scrollbar width when * the table has defined size and the width of the window excluding scrollbar width when * the table has no defined size (the window is a scrollable container). * * This is a bug, as the method should always return stable values, always without scrollbar width. * Changing this behavior would break the column calculators, which would also need to be adjusted. * * @returns {number} */ getWorkspaceWidth(): number; /** * @returns {number} */ getViewportWidth(): number; /** * Checks if viewport has vertical scroll. * * @returns {boolean} */ hasVerticalScroll(): boolean; /** * Checks if viewport has horizontal scroll. * * @returns {boolean} */ hasHorizontalScroll(): boolean; /** * Checks if the table uses the window as a viewport and if there is a vertical scrollbar. * * @returns {boolean} */ isVerticallyScrollableByWindow(): boolean; /** * Checks if the table uses the window as a viewport and if there is a horizontal scrollbar. * * @returns {boolean} */ isHorizontallyScrollableByWindow(): boolean; /** * @param {number} from The visual column index from the width sum is start calculated. * @param {number} length The length of the column to traverse. * @returns {number} */ sumColumnWidths(from: number, length: number): number; /** * @returns {number} */ getWorkspaceOffset(): { left: number; top: number; }; /** * @returns {number} */ getColumnHeaderHeight(): number; /** * @returns {number} */ getRowHeaderWidth(): number; /** * Creates rows calculators. The type of the calculations can be chosen from the list: * - 'rendered' Calculates rows that should be rendered within the current table's viewport; * - 'fullyVisible' Calculates rows that are fully visible (used mostly for scrolling purposes); * - 'partiallyVisible' Calculates rows that are partially visible (used mostly for scrolling purposes). * * @param {'rendered' | 'fullyVisible' | 'partiallyVisible'} calculatorTypes The list of the calculation types. * @returns {ViewportRowsCalculator} */ createRowsCalculator(calculatorTypes?: string[]): ViewportRowsCalculator; /** * Creates columns calculators. The type of the calculations can be chosen from the list: * - 'rendered' Calculates columns that should be rendered within the current table's viewport; * - 'fullyVisible' Calculates columns that are fully visible (used mostly for scrolling purposes); * - 'partiallyVisible' Calculates columns that are partially visible (used mostly for scrolling purposes). * * @param {'rendered' | 'fullyVisible' | 'partiallyVisible'} calculatorTypes The list of the calculation types. * @returns {ViewportColumnsCalculator} */ createColumnsCalculator(calculatorTypes?: string[]): ViewportColumnsCalculator; /** * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and * cols should be rendered). * * @param {boolean} fastDraw If `true`, will try to avoid full redraw and only update the border positions. * If `false` or `undefined`, will perform a full redraw. * @returns {boolean} The fastDraw value, possibly modified. */ createCalculators(fastDraw?: boolean): boolean; /** * Creates rows and columns calculators (after draw, to determine what are * the actually fully visible and partially visible rows and columns). */ createVisibleCalculators(): void; /** * Returns information whether proposedFullyVisibleRowsCalculator viewport * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator). * * @param {ViewportRowsCalculator} proposedFullyVisibleRowsCalculator The instance of the fully visible rows viewport calculator to compare with. * @param {ViewportRowsCalculator} proposedPartiallyVisibleRowsCalculator The instance of the partially visible rows viewport calculator to compare with. * @returns {boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed). * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed). */ areAllProposedVisibleRowsAlreadyRendered(proposedFullyVisibleRowsCalculator: RowsCalculationType | undefined, proposedPartiallyVisibleRowsCalculator: RowsCalculationType | undefined): boolean; /** * Returns information whether proposedFullyVisibleColumnsCalculator viewport * is contained inside column rendered in previous draw (cached in columnsRenderCalculator). * * @param {ViewportRowsCalculator} proposedFullyVisibleColumnsCalculator The instance of the fully visible columns viewport calculator to compare with. * @param {ViewportRowsCalculator} proposedPartiallyVisibleColumnsCalculator The instance of the partially visible columns viewport calculator to compare with. * @returns {boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed). * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed). */ areAllProposedVisibleColumnsAlreadyRendered(proposedFullyVisibleColumnsCalculator: ColumnsCalculationType | undefined, proposedPartiallyVisibleColumnsCalculator: ColumnsCalculationType | undefined): boolean; /** * Marks the row height position cache as stale. The cache will be rebuilt * on the next viewport calculation. */ invalidateRowHeightCache(): void; /** * Marks the column width position cache as stale. The cache will be rebuilt * on the next viewport calculation. */ invalidateColumnWidthCache(): void; /** * Marks both the row height and column width position caches as stale. */ invalidateAllCaches(): void; /** * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings. */ resetHasOversizedColumnHeadersMarked(): void; } export default Viewport;