import type { ScrollDao, DomBindings, WalkontableInstance } from '../types'; import type Settings from '../settings'; import type Table from '../table'; import type Viewport from '../viewport'; import type Overlays from '../overlays'; import type { SelectionManager } from '../selection/manager'; import type Event from '../event'; import EventManager from '../../../../eventManager'; import Scroll from '../scroll'; import CellCoords from '../cell/coords'; import CellRange from '../cell/range'; /** * @abstract * @class Walkontable */ export default class CoreAbstract { /** * Index signature required for WalkontableInstance structural compatibility. */ [key: string]: unknown; /** * The main table instance. * * @type {Table} */ wtTable: Table; /** * The scroll handler instance. * * @type {Scroll} */ wtScroll: Scroll; /** * The viewport calculator instance. * * @type {Viewport} */ wtViewport: Viewport; /** * The overlays manager instance. * * @type {Overlays} */ wtOverlays: Overlays; /** * The selection manager instance. * * @type {SelectionManager} */ selectionManager: SelectionManager; /** * The event handler instance. * * @type {Event} */ wtEvent: Event; /** * Reference to the source walkontable instance (used for clones). * * @type {WalkontableInstance} */ cloneSource: WalkontableInstance; /** * The walkontable instance id. * * @public * @type {Readonly} */ guid: string; /** * Flag indicating whether the current drawing operation was interrupted. * * @type {boolean} */ drawInterrupted: boolean; /** * Flag indicating whether the table has been drawn. * * @type {boolean} */ drawn: boolean; /** * The name of the overlay that currently renders the table. * * @public * @type {string} */ activeOverlayName: string; /** * The DOM bindings. * * @public * @type {DomBindings} */ domBindings: DomBindings; /** * Settings. * * @public * @type {Settings} */ wtSettings: Settings; /** * Gets or creates the event manager instance. * * @returns {EventManager} The event manager instance. */ get eventManager(): EventManager; /** * Gets the root document from dom bindings. * * @returns {Document} The root document. */ get rootDocument(): Document; /** * Gets the root window from dom bindings. * * @returns {Window} The root window. */ get rootWindow(): Window; /** * Delegates to wtSettings.getSetting. * * @param {string} key The settings key. * @param {...unknown} args Additional arguments. * @returns {unknown} */ getSetting(key: string, ...args: unknown[]): unknown; /** * Delegates to wtSettings.update. * * @param {string} key The settings key. * @param {unknown} value The value to set. */ update(key: string, value: unknown): void; /** * @param {HTMLTableElement} table Main table. * @param {Settings} settings The Walkontable settings. */ constructor(table: HTMLTableElement, settings: Settings); /** * Finds and stores original table headers, setting up column header rendering callbacks if not already configured. */ findOriginalHeaders(): void; /** * Creates and returns the CellCoords object. * * @param {*} row The row index. * @param {*} column The column index. * @returns {CellCoords} */ createCellCoords(row: number, column: number): CellCoords; /** * Creates and returns the CellRange object. * * @param {CellCoords} highlight The highlight coordinates. * @param {CellCoords} from The from coordinates. * @param {CellCoords} to The to coordinates. * @returns {CellRange} */ createCellRange(highlight: CellCoords, from: CellCoords, to: CellCoords): CellRange; /** * Force rerender of Walkontable. * * @param {boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering * the data. It will only work if Table.draw() does not force * rendering anyway. * @returns {Walkontable} */ draw(fastDraw?: boolean): this; /** * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer, * if not set or set to false, returns TD from the master table. * * @param {CellCoords} coords The cell coordinates. * @param {boolean} [topmost=false] If set to `true`, it returns the TD element from the topmost overlay. For example, * if the wanted cell is in the range of fixed rows, it will return a TD element * from the top overlay. * @returns {HTMLElement} */ getCell(coords: { row: number | null; col: number | null; }, topmost?: boolean): -1 | HTMLElement | -5 | -2 | -3 | -4 | undefined; /** * Scrolls the viewport to a cell (rerenders if needed). * * @param {CellCoords} coords The cell coordinates to scroll to. * @param {'auto' | 'start' | 'end'} [horizontalSnap='auto'] If `'start'`, viewport is scrolled to show * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport. * @param {'auto' | 'top' | 'bottom'} [verticalSnap='auto'] If `'top'`, viewport is scrolled to show * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on the bottom of * the table. When `'auto'`, the viewport is scrolled only when the row is outside of the viewport. * @returns {boolean} */ scrollViewport(coords: { row: number | null; col: number | null; }, horizontalSnap: string, verticalSnap: string): boolean; /** * Scrolls the viewport to a column (rerenders if needed). * * @param {number} column Visual column index. * @param {'auto' | 'start' | 'end'} [snapping='auto'] If `'start'`, viewport is scrolled to show * the cell on the left of the table. If `'end'`, viewport is scrolled to show the cell on the right of * the table. When `'auto'`, the viewport is scrolled only when the column is outside of the viewport. * @returns {boolean} */ scrollViewportHorizontally(column: number, snapping: string): boolean; /** * Scrolls the viewport to a row (rerenders if needed). * * @param {number} row Visual row index. * @param {'auto' | 'top' | 'bottom'} [snapping='auto'] If `'top'`, viewport is scrolled to show * the cell on the top of the table. If `'bottom'`, viewport is scrolled to show the cell on * the bottom of the table. When `'auto'`, the viewport is scrolled only when the row is outside of * the viewport. * @returns {boolean} */ scrollViewportVertically(row: number, snapping: string): boolean; /** * @returns {Array} */ getViewport(): number[]; /** * Gets the overlay instance by its name. Returns null in the base implementation. * * @param {string} _overlayName The overlay name. * @returns {object | null} */ getOverlayByName(_overlayName: string): object | null; /** * Exports settings as CSS class names. No-op in the base implementation. */ exportSettingsAsClassNames(): void; /** * Destroy instance. */ destroy(): void; /** * Create data access object for scroll. * * @protected * @returns {ScrollDao} */ createScrollDao(): ScrollDao; /** * Create data access object for wtTable. * * @protected * @returns {Record} */ getTableDao(): Record; }