import type { HotInstance } from '../../core/types'; import type { ColumnSummary } from './columnSummary'; export interface EndpointConfig { ranges?: number[][]; reversedRowCoords?: boolean; destinationRow?: number; destinationColumn?: number; sourceColumn?: number; type?: string; forceNumeric?: boolean; suppressDataTypeErrors?: boolean; customFunction?: ((endpoint: Record) => number | string) | null; readOnly?: boolean; roundFloat?: number | boolean; result?: number | string; alterRowOffset?: number; alterColumnOffset?: number; [key: string]: unknown; } /** * Class used to make all endpoint-related operations. * * @private * @class Endpoints */ declare class Endpoints { /** * The main plugin instance. */ plugin: ColumnSummary; /** * Handsontable instance. * * @type {object} */ hot: HotInstance; /** * Array of declared plugin endpoints (calculation destination points). * * @type {Array} * @default {Array} Empty array. */ endpoints: EndpointConfig[]; /** * The plugin settings, taken from Handsontable configuration. * * @type {object|Function} * @default null */ settings: EndpointConfig[] | ((...args: unknown[]) => EndpointConfig[]); /** * Settings type. Can be either 'array' or 'function'. * * @type {string} * @default {'array'} */ settingsType: string; /** * The current endpoint (calculation destination point) in question. * * @type {object} * @default null */ currentEndpoint: EndpointConfig | null; /** * Array containing a list of changes to be applied. * * @private * @type {Array} * @default {[]} */ cellsToSetCache: [number, number | undefined, unknown][]; /** * Initializes the endpoints manager with a reference to the ColumnSummary plugin and the summary endpoint configuration. */ constructor(plugin: ColumnSummary, settings: EndpointConfig[] | ((...args: unknown[]) => EndpointConfig[])); /** * Initialize the endpoints provided in the settings. */ initEndpoints(): void; /** * Get a single endpoint object. * * @param {number} index Index of the endpoint. * @returns {object} */ getEndpoint(index: number): EndpointConfig; /** * Get an array with all the endpoints. * * @returns {Array} */ getAllEndpoints(): EndpointConfig[]; /** * Used to fill the blanks in the endpoint data provided by a settings function. * * @private * @param {Function} func Function provided in the HOT settings. * @returns {Array} An array of endpoints. */ fillMissingEndpointData(func: (...args: unknown[]) => EndpointConfig[]): EndpointConfig[]; /** * Parse plugin's settings. * * @param {Array} settings The settings array. * @returns {object[]} */ parseSettings(settings?: EndpointConfig[]): EndpointConfig[] | undefined; /** * Setter for the internal setting objects. * * @param {object} settings Object with the settings. * @param {object} endpoint Contains information about the endpoint for the the calculation. * @param {string} name Settings name. * @param {object} defaultValue Default value for the settings. */ assignSetting(settings: EndpointConfig, endpoint: EndpointConfig, name: string, defaultValue: unknown): void; /** * Resets the endpoint setup before the structure alteration (like inserting or removing rows/columns). Used for settings provided as a function. * * @private * @param {string} action Type of the action performed. * @param {number} index Row/column index. * @param {number} number Number of rows/columns added/removed. */ resetSetupBeforeStructureAlteration(action: string, index: number, number: number): void; /** * AfterCreateRow/afterCreateRow/afterRemoveRow/afterRemoveCol hook callback. Reset and reenables the summary functionality * after changing the table structure. * * @private * @param {string} action Type of the action performed. * @param {number} index Row/column index. * @param {number} number Number of rows/columns added/removed. * @param {Array} [logicRows] Array of the logical indexes. * @param {string} [source] Source of change. * @param {boolean} [forceRefresh] `true` of the endpoints should refresh after completing the function. */ resetSetupAfterStructureAlteration(action: string, index: number, number: number, logicRows: number[] | null | undefined, source: string, forceRefresh?: boolean): void; /** * Clear the offset information from the endpoint object. * * @private * @param {object} endpoint And endpoint object. */ clearOffsetInformation(endpoint: EndpointConfig): void; /** * Extend the row ranges for the provided endpoint. * * @private * @param {object} endpoint The endpoint object. * @param {number} placeOfAlteration Index of the row where the alteration takes place. * @param {number} previousPosition Previous endpoint result position. * @param {number} offset Offset generated by the alteration. */ extendEndpointRanges(endpoint: EndpointConfig, placeOfAlteration: number, previousPosition: number, offset: number): void; /** * Recreate the physical ranges for the provided endpoint. Used (for example) when a row gets moved and extends an existing range. * * @private * @param {object} endpoint An endpoint object. */ recreatePhysicalRanges(endpoint: EndpointConfig): void; /** * Shifts the endpoint coordinates by the defined offset. * * @private * @param {object} endpoint Endpoint object. * @param {number} offsetStartIndex Index of the performed change (if the change is located after the endpoint, nothing about the endpoint has to be changed. */ shiftEndpointCoordinates(endpoint: EndpointConfig, offsetStartIndex: number): void; /** * Resets (removes) the endpoints from the table. * * @param {Array} [endpoints] Array containing the endpoints. * @param {boolean} [useOffset=true] Use the cell offset value. */ resetAllEndpoints(endpoints?: EndpointConfig[], useOffset?: boolean): void; /** * Calculate and refresh all defined endpoints. */ refreshAllEndpoints(): void; /** * Calculate and refresh endpoints only in the changed columns. * * @param {Array} changes Array of changes from the `afterChange` hook. */ refreshChangedEndpoints(changes: unknown[][]): void; /** * Calculate and refresh endpoints whose `sourceColumn` (visual) matches any of the provided columns. * * @param {Set|number[]} visualColumns Visual column indexes to match against. */ refreshEndpointsBySourceColumns(visualColumns: Set | number[]): void; /** * Refreshes the cell meta information for the all endpoints after the `updateSettings` method call which in some * cases (call with `columns` option) can reset the cell metas to the initial state. */ refreshCellMetas(): void; /** * Calculate and refresh a single endpoint. * * @param {object} endpoint Contains the endpoint information. */ refreshEndpoint(endpoint: EndpointConfig): void; /** * Reset the endpoint value. * * @param {object} endpoint Contains the endpoint information. * @param {boolean} [useOffset=true] Use the cell offset value. */ resetEndpointValue(endpoint: EndpointConfig, useOffset?: boolean): void; /** * Set the endpoint value. * * @param {object} endpoint Contains the endpoint information. * @param {string} [source] Source of the call information. * @param {boolean} [render=false] `true` if it needs to render the table afterwards. */ setEndpointValue(endpoint: EndpointConfig, source: string | undefined, render?: boolean): void; /** * Throw an error for the calculation range being out of boundaries. * * @private */ throwOutOfBoundsWarning(): void; } export default Endpoints;