@odoo/o-spreadsheet
Version:
A spreadsheet component
64 lines (63 loc) • 3.02 kB
TypeScript
import { Registry } from "../registries/registry";
import { CoreCommand, CoreCommandTypes } from "../types/commands";
import { CoreGetters } from "../types/core_getters";
import { CellPosition, RangeAdapter, UID, UnboundedZone, ZoneDimension } from "../types/misc";
import { BoundedRange, Range, RangePart, RangeStringOptions } from "../types/range";
interface RangeArgs {
zone: Readonly<UnboundedZone>;
parts: readonly RangePart[];
/** true if the user provided the range with the sheet name */
prefixSheet: boolean;
/** the name of any sheet that is invalid */
invalidSheetName?: string;
/** the sheet on which the range is defined */
sheetId: UID;
}
interface RangeXcArgs {
xc: string;
/** the name of any sheet that is invalid */
invalidSheetName?: string;
/** the sheet on which the range is defined */
sheetId: UID;
}
export declare function createRange(args: RangeArgs, getSheetSize: (sheetId: UID) => ZoneDimension): Range;
/**
* Create a range from a string XC: A1, Sheet1!A1
* The XC is expected to be valid.
*/
export declare function createRangeFromXc(args: RangeXcArgs, getSheetSize: (sheetId: UID) => ZoneDimension): Range;
export declare function createInvalidRange(sheetXC: string): Range;
export declare function isFullColRange(range: Range): boolean;
export declare function isFullRowRange(range: Range): boolean;
export declare function getRangeString(range: Range, forSheetId: UID | undefined, getSheetName: (sheetId: UID) => string, options?: RangeStringOptions): string;
/**
* Duplicate a range. If the range is on the sheetIdFrom, the range will target
* sheetIdTo.
*/
export declare function duplicateRangeInDuplicatedSheet(sheetIdFrom: UID, sheetIdTo: UID, range: Range): Range;
/**
* Create a range from a xc. If the xc is empty, this function returns undefined.
*/
export declare function createValidRange(getters: CoreGetters, sheetId: UID, xc?: string): Range | undefined;
/**
* Get all the cell positions in the given ranges. If a cell is in multiple ranges, it will be returned multiple times.
*/
export declare function getCellPositionsInRanges(ranges: Range[]): CellPosition[];
export declare function positionToBoundedRange(position: CellPosition): BoundedRange;
/**
* Check that a zone is valid regarding the order of top-bottom and left-right.
* Left should be smaller than right, top should be smaller than bottom.
* If it's not the case, simply invert them, and invert the linked parts
*/
export declare function orderRange(range: Range): Range;
type GetRangeAdapter<C extends CoreCommand> = (cmd: C) => RangeAdapter;
declare class RangeAdapterRegistry extends Registry<GetRangeAdapter<CoreCommand>> {
add<C extends CoreCommandTypes>(cmdType: C, fn: GetRangeAdapter<Extract<CoreCommand, {
type: C;
}>>): this;
get<C extends CoreCommandTypes>(cmdType: C): GetRangeAdapter<Extract<CoreCommand, {
type: C;
}>>;
}
export declare const rangeAdapterRegistry: RangeAdapterRegistry;
export {};