summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/grid/grid-event.ts
blob: 074b72b956320df541b5572ed063c7b0133835b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { CellAddress, CellValue, GridCell } from '@/components/grid/cell.js';
import { GridState } from '@/components/grid/grid.js';
import { ValidateViolation } from '@/components/grid/cell-validators.js';
import { GridColumn } from '@/components/grid/column.js';
import { GridRow } from '@/components/grid/row.js';

export type GridContext = {
	selectedCell?: GridCell;
	rangedCells: GridCell[];
	rangedRows: GridRow[];
	randedBounds: {
		leftTop: CellAddress;
		rightBottom: CellAddress;
	};
	availableBounds: {
		leftTop: CellAddress;
		rightBottom: CellAddress;
	};
	state: GridState;
	rows: GridRow[];
	columns: GridColumn[];
};

export type GridEvent =
	GridCellValueChangeEvent |
	GridCellValidationEvent
	;

export type GridCellValueChangeEvent = {
	type: 'cell-value-change';
	column: GridColumn;
	row: GridRow;
	oldValue: CellValue;
	newValue: CellValue;
};

export type GridCellValidationEvent = {
	type: 'cell-validation';
	violation?: ValidateViolation;
	all: ValidateViolation[];
};