/
actions.tsx
81 lines (69 loc) · 1.51 KB
/
actions.tsx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { AppState, Data, UiState } from "../types/Config";
export type InsertAction = {
type: "insert";
componentType: string;
destinationIndex: number;
destinationZone: string;
};
export type DuplicateAction = {
type: "duplicate";
sourceIndex: number;
sourceZone: string;
};
export type ReplaceAction = {
type: "replace";
destinationIndex: number;
destinationZone: string;
data: any;
};
export type ReorderAction = {
type: "reorder";
sourceIndex: number;
destinationIndex: number;
destinationZone: string;
};
export type MoveAction = {
type: "move";
sourceIndex: number;
sourceZone: string;
destinationIndex: number;
destinationZone: string;
};
export type RemoveAction = {
type: "remove";
index: number;
zone: string;
};
export type SetUiAction = {
type: "setUi";
ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
};
export type SetDataAction = {
type: "setData";
data: Partial<Data> | ((previous: Data) => Partial<Data>);
};
export type SetAction = {
type: "set";
state: Partial<AppState> | ((previous: AppState) => Partial<AppState>);
};
export type RegisterZoneAction = {
type: "registerZone";
zone: string;
};
export type UnregisterZoneAction = {
type: "unregisterZone";
zone: string;
};
export type PuckAction = { recordHistory?: boolean } & (
| ReorderAction
| InsertAction
| MoveAction
| ReplaceAction
| RemoveAction
| DuplicateAction
| SetAction
| SetDataAction
| SetUiAction
| RegisterZoneAction
| UnregisterZoneAction
);