/
kan64
/
spreadsheet-lab
Обзор
Документация
Войти
/
kan64
/
spreadsheet-lab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
client/src/types/types.ts
144 строки
5 KB
Anton Kravchenkov
feat: fix
30 мар 2026, 23:14
30 мар 2026, 23:14
b5f409e
Код
Авторство
О чём код?
export interface CellBorder { color: string; style?: 'solid' | 'dashed' | 'dotted'; width?: number; } export interface CellStyle { bold?: boolean; italic?: boolean; underline?: boolean; strikethrough?: boolean; color?: string; backgroundColor?: string; fontSize?: number; textAlign?: 'left' | 'center' | 'right'; verticalAlign?: 'top' | 'middle' | 'bottom'; textOrientation?: 'horizontal' | 'vertical'; format?: 'general' | 'number' | 'currency' | 'percent' | 'date'; wrapText?: boolean; borderTop?: CellBorder; borderRight?: CellBorder; borderBottom?: CellBorder; borderLeft?: CellBorder; } export type BorderSide = 'borderTop' | 'borderRight' | 'borderBottom' | 'borderLeft'; export interface TextRun { text: string; bold?: boolean; italic?: boolean; underline?: boolean; strikethrough?: boolean; color?: string; fontSize?: number; link?: string; } export interface CellData { value: string; formula?: string; computedValue?: string | number; style?: CellStyle; link?: string; richText?: TextRun[]; } export interface CellPosition { row: number; col: number; } export interface CellRange { start: CellPosition; end: CellPosition; } export interface SheetData { id: string; name: string; cells: Record<string, CellData>; columnWidths: Record<number, number>; rowHeights: Record<number, number>; mergedCells: CellRange[]; frozenRows: number; frozenCols: number; } export interface SpreadsheetState { sheets: SheetData[]; activeSheetId: string; selectedCell: CellPosition | null; selectedRange: CellRange | null; isEditing: boolean; editValue: string; clipboard: { range: CellRange | null; cells: Record<string, CellData>; mergedCells: CellRange[]; isCut: boolean; } | null; } export type SpreadsheetAction = | { type: 'SET_CELL_VALUE'; row: number; col: number; value: string } | { type: 'SET_CELL_STYLE'; range: CellRange; style: Partial<CellStyle> } | { type: 'SELECT_CELL'; position: CellPosition } | { type: 'SELECT_RANGE'; range: CellRange } | { type: 'START_EDITING'; value?: string } | { type: 'UPDATE_EDIT_VALUE'; value: string } | { type: 'STOP_EDITING'; save: boolean; richText?: TextRun[]; finalValue?: string } | { type: 'SET_COLUMN_WIDTH'; col: number; width: number } | { type: 'SET_COLUMNS_WIDTH'; cols: number[]; width: number } | { type: 'SET_ROW_HEIGHT'; row: number; height: number } | { type: 'ADD_SHEET' } | { type: 'REMOVE_SHEET'; sheetId: string } | { type: 'RENAME_SHEET'; sheetId: string; name: string } | { type: 'SET_ACTIVE_SHEET'; sheetId: string } | { type: 'COPY'; isCut: boolean } | { type: 'PASTE' } | { type: 'CLEAR_CLIPBOARD' } | { type: 'CLEAR_SELECTION' } | { type: 'CLEAR_SELECTION_AND_CLIPBOARD' } | { type: 'DELETE_CELL_CONTENT' } | { type: 'INSERT_ROW'; row: number } | { type: 'INSERT_COLUMN'; col: number } | { type: 'DELETE_ROW'; row: number } | { type: 'DELETE_COLUMN'; col: number } | { type: 'PASTE_ROWS'; row: number; direction: 'above' | 'below' } | { type: 'SET_CELL_LINK'; row: number; col: number; url: string | undefined; text?: string } | { type: 'MERGE_CELLS'; range: CellRange } | { type: 'UNMERGE_CELLS'; range: CellRange } | { type: 'SET_FROZEN_ROWS'; count: number } | { type: 'SET_FROZEN_COLS'; count: number } | { type: 'REORDER_SHEETS'; fromIndex: number; toIndex: number } | { type: 'RESTORE_STATE'; state: SpreadsheetState } | { type: 'APPLY_REMOTE_CELL'; tabId: string; row: number; col: number; value: string; style?: CellStyle | null; richText?: TextRun[] } | { type: 'APPLY_REMOTE_LAYOUT'; layout: { tabs?: { id: string; name: string; order: number }[]; tabLayouts?: Record<string, { mergedCells?: CellRange[]; columnWidths?: Record<string, number>; rowHeights?: Record<string, number>; frozenRows?: number; frozenCols?: number }> } } | { type: 'APPLY_REMOTE_INSERT_ROW'; tabId: string; row: number } | { type: 'APPLY_REMOTE_DELETE_ROW'; tabId: string; row: number } | { type: 'APPLY_REMOTE_INSERT_COLUMN'; tabId: string; col: number } | { type: 'APPLY_REMOTE_DELETE_COLUMN'; tabId: string; col: number } | { type: 'APPLY_REMOTE_PASTE_ROWS'; tabId: string; insertAt: number; numRows: number; cells: Array<{ rowIndex: number; colIndex: number; value: string; style?: CellStyle | null; richText?: TextRun[] }> } | { type: 'LOAD_CELLS_RANGE'; tabId: string; cells: Array<{ rowIndex: number; colIndex: number; value: string; style?: CellStyle; richText?: TextRun[] }> } | { type: 'FILL_DATES'; sourceRow: number; sourceCol: number; fillRange: CellRange }; export interface SpreadsheetFile { id: string; name: string; createdAt: string; updatedAt: string; sheets: SheetData[]; activeSheetId: string; } export const DEFAULT_COL_WIDTH = 100; export const DEFAULT_ROW_HEIGHT = 28; export const ROW_HEADER_WIDTH = 50; export const COL_HEADER_HEIGHT = 28; export const TOTAL_ROWS = 1000; /** Базовое число столбцов; в GridCanvas при скролле вправо добавляются «виртуальные» столбцы */ export const TOTAL_COLS = 26; /** Максимальное число столбцов сетки (A… + расширение вправо) */ export const MAX_TOTAL_COLS = 16384;