UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

149 lines (147 loc) 5.81 kB
import { CartesianDirection, CellRangeLookup, CellCoords, CellRangeCoords } from "@sheetxl/common"; export declare const EMPTY_RANGE: CellRangeCoords; export declare const REGEX_INVALID_SHEET_CHARS: RegExp; export declare const REGEX_AUTO_SHEET_NAME: RegExp; export declare const MESSAGE_ERROR_SHEET_NAME_BLANK = "A sheet name can not be blank."; export declare const MESSAGE_ERROR_SHEET_NAME_INVALID_CHARS: (sheetName?: string) => string; export declare const MESSAGE_ERROR_SHEET_NAME_TOO_LONG = "A sheet name can not be longer than 31 characters."; export declare const MESSAGE_ERROR_SHEET_NAME_QUOTES = "A sheet name can not begin or end with a \"'\" (single quote)."; /** * Simple utility function to check if coords is within range * @param coords * @param range */ export declare const isCoordsWithinRange: (coords: CellCoords, range: CellRangeCoords) => boolean; /** * This is a more advanced use case of ranges that takes an array of ranges and uses an r-tree algo to * determine if the ranges intersects. * @param ranges * @returns */ export declare const rangesArrayIntersect: (ranges: CellRangeCoords[]) => boolean; /** * Check if a coord is inside a range * @param needle * @param haystack */ export declare const coordsInsideRange: (needle: CellCoords, haystack: CellRangeCoords) => boolean; /** * Finds the union of 2 ranges */ export declare const unionRange: (a: CellRangeCoords, b: CellRangeCoords) => CellRangeCoords; /** * Finds the intersection of 2 ranges. * @returns null if no intersection */ export declare const intersectRanges: (a: CellRangeCoords, b: CellRangeCoords) => CellRangeCoords; export declare const unionRanges: (ranges: CellRangeCoords[]) => CellRangeCoords; export declare const rangeFromCoords: (coords: CellCoords) => CellRangeCoords; export declare const toValidRange: (rangeOrCoords: CellRangeCoords | CellCoords) => CellRangeCoords; /** * Check if range spans multiple cells * @param coords */ export declare const isSingleCell: (coords: CellRangeCoords | undefined) => boolean; /** * Check if two coords are equal * @param a * @param b */ export declare const isEqualCoords: (a: CellCoords | null, b: CellCoords | null) => boolean; /** * Check if two ranges are equal * @param a * @param b */ export declare const isEqualRanges: (a?: CellRangeCoords, b?: CellRangeCoords) => boolean; /** * Check if two ranges arrays are equal * @param a * @param b */ export declare const isEqualRangesArrays: (a?: CellRangeCoords[], b?: CellRangeCoords[]) => boolean; /** * Check if 2 ranges overlap * @param range1 * @param range2 */ export declare const isRangesIntersect: (range1: CellRangeCoords, range2: CellRangeCoords) => boolean; /** * Check if range a is contains with range b * @param a * @param b * @returns */ export declare const isRangeWithinRange: (a: CellRangeCoords, b: CellRangeCoords) => boolean; export declare const flatten2DArray: (array: any[]) => any[]; export declare const build2DArray: (values: any, width: number) => any[][]; export declare const stringToArray: (input: string) => any[]; export declare const arrayToString: (input: any[]) => string; /** * Validates sheet name. * * The character count **MUST** be greater than or equal to 1 and less than or equal to 31. * The string MUST NOT contain the any of the following characters: * * * 0x0000 * * 0x0003 * * colon (:) * * backslash (\) * * asterisk (*) * * question mark (?) * * forward slash (/) * * opening square bracket ([) * * closing square bracket (]) * * The string MUST NOT begin or end with the single quote (') character. * * @param sheetName the name to validate * @throws IllegalArgumentException if validation fails */ export declare const validateSheetName: (sheetName: string) => string; /** * Get maximum bound of an range given other ranges. Will return the union. (useful for to merged cell selection) * * @param range * @param rangesLookup */ export declare const extendRangeToIntersectingRanges: (range: CellRangeCoords, rangesLookup: CellRangeCoords[] | CellRangeLookup) => CellRangeCoords; export declare const extendRangeToUnionRanges: (range: CellRangeCoords, rangesLookup: CellRangeCoords[] | CellRangeLookup) => CellRangeCoords; /** * Sorts ranges in 2 directions but weighted to direction. * @remarks * * Will also sort nulls to the end. * * Only uses the colStart and rowStart. It does not account for colEnd and rowEnd. * * @param ranges * @param direction @defaultValue CartesianDirection.Right */ export declare const sortRanges: (ranges: CellRangeCoords[], direction?: CartesianDirection, additionalSort?: ((a: CellRangeCoords, b: CellRangeCoords) => number)) => CellRangeCoords[]; export declare const removeRangesWithOffsets: (ranges: CellRangeCoords[], set: Set<number>) => CellRangeCoords[]; /** * Return true if the outer span intersects the inner span * @remarks * Assumes End is always greater than or equal to start */ export declare const isSplitSpan: (outerStart: number, outerEnd: number, innerStart: number, innerEnd: number) => boolean; /** * Return true if the outer span encloses the inner span. * @remarks * Assumes isSplitSpan is false */ export declare const isWithinSpan: (outerStart: number, outerEnd: number, innerStart: number, innerEnd: number) => boolean; /** * Subtract Range b from from a. * This will always return either 0 - 4 ranges. * If no interaction then b will be returned. * If beforeSplit === rangeToRemove then empty array is returned * @param beforeSplit * @param rangeToRemove * @returns */ export declare const subRanges: (beforeSplit: CellRangeCoords, rangeToRemove: CellRangeCoords) => CellRangeCoords[]; /** * If ranges can be aligned then they will be otherwise return null * @param ranges */ //# sourceMappingURL=RangeUtils.d.ts.map