@sheetxl/models
Version:
Models - A Headless javascript spreadsheet library.
238 lines • 7.46 kB
TypeScript
import { RemoveListener, TopLeft, CellCoords, CellRangeCoords, JSONSerializable } from "@sheetxl/common";
import { SerializableProperties } from "../primitives";
import { IListenerSource } from "../listener";
import { IDrawingModel, DrawingContainerViewEvent, IDrawingContainerView } from "../drawing";
import { AdjustedColor } from "../color";
/**
* Represents the current selection with a cell range.
*/
export interface CellSelection {
/**
* The coordinates of the cell that will receive
* actions that operate on a single cell.
* @remarks
*/
activeCoords?: CellCoords;
/**
* A list of cell ranges that are currently selected.
*/
ranges?: CellRangeCoords[];
/**
* The current range is the is active or -1 if no ranges are selected.
* @remarks
* This must be an index of the ranges array.
*/
activeRangeIndex?: number;
}
/**
* The coordinates for a FreezePane.
* can have either a coordinate or a topLeft or both.
*/
export interface FreezePanes {
/**
* required at least one to be set.
*/
coords?: Partial<CellCoords>;
/**
* If scrolling then this will be set.
* Note - If the current view has a scroll offset and
* freeze is called it will 'transfer' the scroll coordinates.
*/
topLeft?: Partial<TopLeft>;
}
/**
* The default style for displaying the header text.
* @remarks
* This is a suggestion and may be ignored by the HeaderRenderer
*/
export declare enum HeaderTextStyle {
A1 = "a1",
Zero = "zero",
One = "one"
}
/**
* A listener for changes to the ISheetView object.
*/
export interface ISheetViewListener {
/**
* Called when the SheetView object changes.
*
* This is not called when individual properties on the view change.
* @param update
*/
onViewChange?(update: ISheetView | null | undefined): void;
/**
* Called when the sheetView changes.
* @param update
*/
onTopLeftChange?(update: Partial<TopLeft> | null | undefined): void;
/**
* Called when the selection changes.
* @param update
*/
onSelectionChange?(update: CellSelection | null | undefined): void;
/**
* Called when freeze or split settings have changed
*/
onFreezeSplitChange?(update: FreezePanes | null | undefined): void;
/**
* Called when the drawing selection changes.
* @param update
*/
onDrawingSelectionChange?(update: readonly IDrawingModel[] | null | undefined): void;
}
export declare enum SheetViewListenerType {
/**
* Called when the SheetView object changes.
*
* This is not called when individual properties on the view change.
* @param update
*/
View = "view",
/**
* Called when the sheetView changes.
* @param update
*/
TopLeft = "topLeft",
/**
* Called when the selection changes.
* @param update
*/
Selection = "selection",
/**
* Called when freeze or split settings have changed
*/
FreezeSplit = "freezeSplit",
/**
* Called when the drawing selection changes.
* @param update
*/
DrawingSelection = "drawingSelection"
}
export interface SheetViewEvent extends DrawingContainerViewEvent<ISheetView> {
}
export interface IUpdatableSheetView extends ISheetView, IListenerSource<SheetViewEvent>, JSONSerializable<SerializableProperties<ISheetView> | null> {
addListener: (listener: ISheetViewListener) => RemoveListener;
toJSON(): SerializableProperties<ISheetView> | null;
fromJSON(json: SerializableProperties<ISheetView>): void;
readonly isISheetView: true;
}
/**
* View settings for a single sheet.
* Sheets Views in Excel have sheetViews and CustomSheetViews
*
* TODO/Note - Excel has lots of SheetViews concepts. It seems to be due to evolution
* SheetView - Supports an unnamed list but only the first view seems to be used. This has embedded panes
*
* customWorkbookViews/customSheetViews - Names for SheetViews is managed as the customWorkbookViews level but creates
* a point via guid to customSheetViews. These are subclasses of sheetView that add hiddenColumns/hiddenRows and filters
* And ExcelOnline views (365 SheetViews)
*
* Note - We allow a sheet to contain one ISheetModel.
* All remaining sheetViews must be managed somewhere else. We allow Workbooks to manage sheetViews
*/
export interface ISheetView extends IDrawingContainerView<ISheetView>, IListenerSource<SheetViewEvent> {
/**
* The current cell selection for the sheet.
*/
selection: CellSelection;
/**
* The default top left corner accounting for scrolling.
*/
topLeft: TopLeft;
/**
* The freeze panes.
*/
freezePanes: FreezePanes;
/**
* Show/Hide row headers.
* @defaultValue true;
*/
showRowHeaders: boolean;
/**
* Show/Hide columns headers.
* @defaultValue true;
*/
showColumnHeaders: boolean;
/**
* Show/Hide row gridlines.
* @defaultValue true;
*/
showRowGridlines: boolean;
/**
* Show/Hide column gridlines.
* @defaultValue true;
*/
showColumnGridlines: boolean;
/**
* Style of displaying default row header text
* Note - This does not affect how formulas are resolved
*
* @defaultValue HeaderTextStyle.A1
* // TODO - allow a function callback (but this won't be persisted)
*/
rowHeaderStyle: HeaderTextStyle;
/**
* Style of displaying default row header column
* Note - This does not affect how formulas are resolved
*
* @defaultValue HeaderTextStyle.One
* // TODO - allow a function callback (but this won't be persisted)
*/
columnHeaderStyle: HeaderTextStyle;
/**
* Zoom. This is expressed as a percentage. Values can be between 10 (10%) or 400 (400%)
* @defaultValue 100
* // TODO - support zoomScaleNormal, zoomScalePageLayout, zoomScaleSheetLayoutView,
*/
zoomScale: number;
/**
* Indicate if view is showing formulas or values
* @defaultValue false
*/
showFormulas: boolean;
/**
* Indicate whether the sheet should show 0 (zero) or blanks in cells containing zero values.
*
* @defaultValue true
*
* @remarks
*
* When false, cells with zero value appear blank instead of showing the number zero.
*/
showZeros: boolean;
/**
* The color of the gridline on the sheet.
*
* @defaultValue null (adopts the app theme color)
*
* @remarks
*
* gridLine color is a sheet view attribute but in Excel is a workbook attribute.
* If null then use the app theme
*/
gridLineColor: AdjustedColor | null;
/**
* Add a drawing to the selection.
* If addToSelection is true then the
* items will be added to the selection
* @param drawing
* @param addToSelection
*/
selectDrawings(drawing: IDrawingModel[], addToSelection?: boolean): void;
/**
* Removes the drawings from selection (if they were selected)
* @param drawing
*/
unselectDrawings(drawing: IDrawingModel[]): void;
}
/**
* Frozen FreezePanes for easy comparisons.
*/
export declare const EMPTY_FREEZE_PANES: FreezePanes;
/**
* Frozen CellSelection for easy comparisons.
*/
export declare const EMPTY_SELECTION: CellSelection;
export default ISheetView;
//# sourceMappingURL=ISheetView.d.ts.map