summaryrefslogtreecommitdiff
path: root/apps/web/src/selection/types.ts
blob: a797d6c042a64584ddcbd31a6d8d3a4731a4c95a (plain) (blame)
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
export interface SelectionState {
	selectedIds: string[];
	anchorId: string | null;
}

export interface BoxSelectionSnapshot<TId = string> {
	initialSelectedIds: TId[];
	initialAnchorId: TId | null;
}

export interface SelectionBoxBounds {
	left: number;
	top: number;
	width: number;
	height: number;
}

export interface BoxSelectionChange<TId = string>
	extends BoxSelectionSnapshot<TId> {
	intersectedIds: TId[];
	isAdditive: boolean;
}

export type ResolveIntersections<TId = string> = ({
	startPos,
	currentPos,
}: {
	startPos: { x: number; y: number };
	currentPos: { x: number; y: number };
}) => TId[];

export interface SelectableSurfaceProps {
	orderedIds: string[];
	children: React.ReactNode;
	className?: string;
	ariaLabel?: string;
	revealId?: string | null;
	onRevealComplete?: () => void;
	onSelectionChange?: (state: SelectionState) => void;
}

export interface SelectableItemProps
	extends React.HTMLAttributes<HTMLDivElement> {
	id: string;
	children: React.ReactNode;
}