import * as React from 'react'; import { Point } from './point'; import { Selection } from './selection'; import { Model } from './engine'; import { PointRange } from './point-range'; import { Matrix } from './matrix'; /** The base type of cell data in Spreadsheet */ export type CellBase = { /** Whether the cell should not be editable */ readOnly?: boolean; /** Class to be given for the cell element */ className?: string; /** The value of the cell */ value: Value; style?: React.CSSProperties | undefined; type?: boolean; inputType?: InputType; contextDisable?: Record; /** Custom component to render when the cell is edited, if not defined would default to the component defined for the Spreadsheet */ DataEditor?: DataEditorComponent>; /** Custom component to render when the cell is viewed, if not defined would default to the component defined for the Spreadsheet */ DataViewer?: DataViewerComponent>; }; type InputType = { type: 'dropDown' | 'text' | 'file'; options?: { disable: boolean; label: string; name: string; value: string; color: string; }[]; inputProps?: {}; }; /** * A cell with it's coordinates * @deprecated the component does not use cell descriptors anymore. Instead it passes cell point and cell value explicitly. */ export type CellDescriptor = { /** The cell's data */ data: Cell | undefined; } & Point; /** The spreadsheet's write mode */ export type Mode = 'view' | 'edit'; /** Dimensions of an element */ export type Dimensions = { /** The element's width in pixels */ width: number; /** The element's height in pixels */ height: number; /** The distance of the element from it's container top border in pixels */ top: number; /** The distance of the element from it's container left border in pixels */ left: number; }; export type StoreState = { model: Model; selected: Selection; copied: PointRange | null; hasPasted: boolean; cut: boolean; autoFill: { open: boolean; cellValue: Cell; }; active: Point | null; mode: Mode; rowDimensions: rowDimensions; columnDimensions: columnDimensions; dragging: boolean; lastChanged: Point | null; lastCommit: null | CellChange[]; selectedRow: null | number; selectedColumn: null | number; formattedStyle: formattedStyle; editable: boolean; ctrl: boolean; }; export type rowDimensions = Record | undefined>; export type columnDimensions = Record | undefined>; export type formattedStyle = { open: boolean; style: undefined | React.CSSProperties; }; export type CellChange = { prevCell: Cell | null; nextCell: Cell | null; }; /** Type of Spreadsheet Cell component props */ export type CellComponentProps = { /** The row of the cell */ row: number; /** The column of the cell */ column: number; /** The DataViewer component to be used by the cell */ DataViewer: DataViewerComponent; /** Whether the cell is selected */ selected: boolean; /** Whether the cell is active */ active: boolean; /** Whether the cell is copied */ copied: boolean; /** Whether the user is dragging */ dragging: boolean; /** The mode of the cell */ mode: Mode; /** The data of the cell */ data: Cell | undefined; /** The evaluated data of the cell */ evaluatedData: Cell | undefined; /** Select the cell at the given point */ select: (point: Point) => void; /** Activate the cell at the given point */ activate: (point: Point) => void; /** Set the dimensions of the cell at the given point with the given dimensions */ setCellDimensions: (point: Point, dimensions: Dimensions) => void; /** Set data of the cell */ setCellData: (cell: Cell) => void; /**Indicates whether the cell is editable.*/ editable?: boolean; }; /** Type of the Spreadsheet Cell component */ export type CellComponent = React.ComponentType>; type DataComponentProps = { /** The rendered cell by the component */ cell: Cell | undefined; } & Point; /** Type of the Spreadsheet DataViewer component props */ export type DataViewerProps = DataComponentProps & { /** Set data of the cell */ setCellData: (cell: Cell) => void; evaluatedCell: Cell | undefined; inputValue: () => React.ReactNode; active: boolean; editable?: boolean; }; /** Type of the Spreadsheet DataViewer component */ export type DataViewerComponent = React.ComponentType>; /** Type of the Spreadsheet DataEditor component props */ export type DataEditorProps = DataComponentProps & { /** Callback to be called when the cell's value is changed */ onChange: (cell: Cell) => void; /** Callback to be called when edit mode should be exited */ exitEditMode: () => void; }; /** Type of the Spreadsheet DataEditor component */ export type DataEditorComponent = React.ComponentType>; /** Type of the Spreadsheet Table component props */ export type TableProps = React.PropsWithChildren<{ /** Number of columns the table should render */ columns: number; /** Whether column indicators are hidden */ hideColumnIndicators?: boolean | null; useTableRef: (ref: React.RefObject) => void; }>; /** Type of the Spreadsheet Table component */ export type TableComponent = React.ComponentType; /** Type of the Spreadsheet Row component props */ export type RowProps = React.PropsWithChildren<{ /** The row index of the table */ row: number; }>; /** Type of the Row component */ export type RowComponent = React.ComponentType; /** Type of the Spreadsheet HeaderRow component props */ export type HeaderRowProps = React.PropsWithChildren<{}>; /** Type of the HeaderRow component */ export type HeaderRowComponent = React.ComponentType; export type VisibleRange = { start: number; end: number; }; export type FullRange = { start: { row: number; column: number; }; end: { row: number; column: number; }; }; /** Type of the Spreadsheet RowIndicator component props */ export type RowIndicatorProps = { /** The row the indicator indicates */ row: number; /** A custom label for the indicator as provided in rowLabels */ label?: React.ReactNode | null; /** Whether the entire row is selected */ selected: boolean; /** Callback to be called when the row is selected */ onSelect: (row: number, extend: boolean) => void; setContextMenu: React.Dispatch>; deleteRow: (_row?: number) => void; addRowTop: (_row?: number) => void; addRowBottom: (_row?: number) => void; rowContextEnable: boolean; cell?: CellBase; selectedRow?: number; maxRowLimit: number; disableDeleteOption: boolean; contextMenu: ContextMenuState; setVisibleRange: React.Dispatch>; scrollToRow: (_row: number, _visibleRange: VisibleRange) => void; }; export type ContextMenuState = { open: boolean; contextType: 'sheet' | 'column' | 'row' | 'cell' | null; options: optionsType[]; }; type optionsType = { label: string; value: string; iconName: string; action: () => void; disableTooltip: string; visible: boolean; disable: boolean; }; /** Type of the RowIndicator component */ export type RowIndicatorComponent = React.ComponentType; /** Type of the Spreadsheet ColumnIndicator component props */ export type ColumnIndicatorProps = { /** The column the indicator indicates */ column: number; minimumColumnWidth: number; /** A custom label for the indicator as provided in columnLabels */ label?: React.ReactNode | null; /** Whether the entire column in selected */ selected: boolean; /** Whether the entire column in Fixed */ fixed?: boolean; /** Callback to be called when the column is selected */ onSelect: (column: number, extend: boolean) => void; setContextMenu: React.Dispatch>; deleteColumn: (_col?: number) => void; addColumnLeft: (columnWidth: number, _col?: number) => void; addColumnRight: (columnWidth: number, _col?: number) => void; columnContextEnable: boolean; cell?: CellBase; selectedColumn?: number; maxColLimit: number; disableDeleteOption: boolean; contextMenu: ContextMenuState; onAddColumn?: (_columnIndex: number, _isLeft: boolean) => void; onDeleteColumn?: (_columnIndex: number) => void; scrollToColumn: (_column: number) => void; }; /** Type of the ColumnIndicator component */ export type ColumnIndicatorComponent = React.ComponentType; /** Type of the Spreadsheet CornerIndicator component props */ export type CornerIndicatorProps = { /** Whether the entire table is selected */ selected: boolean; /** Callback to select the entire table */ onSelect: () => void; }; /** Type of the CornerIndicator component */ export type CornerIndicatorComponent = React.ComponentType; export type CommitChanges = Array<{ prevCell: Cell | null; nextCell: Cell | null; }>; export type CreateFormulaParser = (data: Matrix) => void; export type AttachmentApi = { createdBy?: string; modifiedBy?: string; createdByUname?: string; modifiedByUname?: string; createdOn?: string; modifiedOn?: string; state?: string; searchKey?: string; parentId?: string; sourceId?: string; inputAction?: string; id: string; name: string; projectId?: string; folder?: boolean; executionOrder?: number; imported?: boolean; }; export {};