@sheetxl/models
Version:
Models - A Headless javascript spreadsheet library.
91 lines • 3.89 kB
TypeScript
import { CellRangeCoords, RemoveListener } from "@sheetxl/common";
import { TransactionStore, ITransaction, ChangeSet } from "../transaction";
import { IAnchoredItem, IAnchoredItemListener, AnchorType } from "./IAnchoredItem";
export type AnchoredItemShiftCallback = (after: CellRangeCoords, before: CellRangeCoords, intersect: CellRangeCoords, isColumnShift: boolean, shiftAmount: number) => CellRangeCoords | void;
export type AnchoredItemResizeCallback = () => void;
export type AnchoredItemDeleteCallback = () => void;
export interface AnchoredItemOptions {
/**
*
* @param anchor Set the anchor on the container
*/
setAnchorOnContainer(anchor: CellRangeCoords): void;
/**
* Delete from the container
*/
deleteFromContainer(): void;
/**
* Notify anchored item that the anchor bounds have changed due to an insert/remove.
* @param callback
*/
setContainerAnchorShiftCallback(callback: AnchoredItemShiftCallback): void;
/**
* Notify anchored item that the pixel bounds have changed due to a resize.
* @param callback
*/
setContainerAnchorResizeCallback?(callback: AnchoredItemResizeCallback): void;
/**
* Notify anchored item that the record has been deleted from the container.
* @param callback
*/
setContainerAnchorDeleteCallback?(callback: AnchoredItemDeleteCallback): void;
/**
* Notify drawing it's protection has been updated from the container.
* @param callback
*/
setContainerProtectionCallback(callback: () => void): void;
/**
* The anchor used when the item is first created.
*/
initialAnchor: CellRangeCoords;
/**
* A transaction store that can be used to undo/redo changes to the table.
*/
transactionStore?: TransactionStore;
/**
* If protected the container can protected the item.
*/
isProtected: () => boolean;
}
export interface AnchoredItemTransactionState {
anchor: CellRangeCoords;
anchorType: AnchorType;
}
export interface AnchoredItemTransactionInputs {
}
/**
* An implement of IAnchorItem
*/
export declare abstract class AbstractAnchoredItem<STATE extends AnchoredItemTransactionState, INPUT extends AnchoredItemTransactionInputs = AnchoredItemTransactionInputs> implements IAnchoredItem {
protected _listeners: Set<IAnchoredItemListener>;
protected _options: AnchoredItemOptions;
private _transactionStore;
private _transactionStoreRemoveListener;
private _closed;
constructor(options: AnchoredItemOptions);
protected onRecordChange(_change: ChangeSet<STATE, AnchoredItemTransactionInputs>): void;
delete(): void;
getAnchor(): CellRangeCoords;
setAnchorType?(anchorType: AnchorType): void;
getAnchorType?(): AnchorType;
pushTransaction(description?: string): ITransaction;
protected _getTransactionState(): STATE;
protected _pushTransaction(description: string): ITransaction;
protected _updateTransactionState(description?: string, updateState?: Partial<STATE>, //(prevState: STATE) => STATE,
updaterInputs?: (prevInputs: INPUT) => INPUT): void;
protected _processAnchorOnContainerShift(after: CellRangeCoords, _before: CellRangeCoords, _intersect: CellRangeCoords, _isColumnShift: boolean, _shiftAmount: number): CellRangeCoords | void;
isProtected(): boolean;
protected _processAnchorOnContainerResize(): void;
protected _processAnchorOnContainerDelete(): void;
protected _processContainerProtection(): void;
notifyAnchorUpdate(anchor?: CellRangeCoords): void;
notifyProtectedChange(): void;
notifyOnDelete(): void;
notifyOnClose(): void;
addListener(listener: IAnchoredItemListener): RemoveListener;
isClosed(): boolean;
close(): void;
get isAnchoredItem(): true;
}
export default AbstractAnchoredItem;
//# sourceMappingURL=AnchoredItem.d.ts.map