-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
154 lines (125 loc) · 3.94 KB
/
index.d.ts
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import Roact from "@rbxts/roact";
import "@rbxts/types";
export as namespace RoactDnD;
export = RoactDnD;
interface StatefulComponent<P> extends Roact.RenderablePropsClass<P> {}
interface FunctionalComponent<P> {
(props: P): Roact.Element | undefined;
}
interface DragSourceWrapper<P> {
new (props: P): {
render(): Roact.Element | undefined;
};
}
interface DragTargetWrapper<P> {
new (props: P): {
render(): Roact.Element | undefined;
};
}
type DropId = string | number | symbol;
interface IDragDropHandler<DropIdTypes, T extends Instance> {
DropId: DropIdTypes;
Ref?: (rbx: T | undefined) => void;
}
interface IDropTarget<T extends GuiObject>
extends IDragDropHandler<DropId | Array<DropId>, T> {
/**
* An event that's called when a `DragSource` is successfully dropped onto this target
* @param targetData the data of the drag target that was dropped
*/
TargetDropped: (targetData: unknown) => void;
/**
* Controls whether or not items can be dropped on this target
* @param targetData The target data of the dropping item
*/
CanDrop?: (targetData: unknown) => boolean;
/**
* Called when an item hovers over a component
* @param targetData The target data of the hovering item
* @param component The target component of the hovering item
*/
TargetHover?: (targetData: unknown, component: Instance) => boolean;
/**
* The priority of this `DropTarget`.
*
* A target with a higher priority will be chosen if there are multiple `DropTarget`s in the same area.
*/
TargetPriority?: number;
}
interface IDragSource<T extends GuiObject> extends IDragDropHandler<DropId, T> {
/** The data that will be sent to the `DropTarget` if this `DragSource` successfully drops on this target */
TargetData: unknown;
/**
* Controls whether or not this item can be dragged
* @param targetData The target data of this item
*/
CanDrag?: (targetData: unknown) => boolean;
/**
* Called when the drag begins
*/
DragBegin?: () => void;
/**
* Called when the drag ends
*/
DragEnd?: (hasDropTarget: boolean) => void;
OnDragging?: () => void;
/**
* Will render the dragging as a modal (useful for having it on top of everything!)
*/
IsDragModal?: boolean;
/**
* How the dragging is constrained
*
* `None` - There is no limit to where it can be dragged
*
* `Viewport` - The instance can only be dragged within the viewport itself
*
* `ViewportIgnoreInset` - The instance can be dragged within the viewport as well as the inset area of the topbar
*/
DragConstraint?: "ViewportIgnoreInset" | "Viewport" | "None";
/**
* If true, will reset the position of the DragTarget's instance when dragging stops
*/
DropResetsPosition?: boolean;
}
interface Action<A = any> {
type: A;
}
declare namespace RoactDnD {
class DragDropContext {
constructor(options?: unknown); // TODO: Options, eventually
static Default: DragDropContext;
public dispatch(action: Action): void;
}
interface DragDropProviderProps {
context?: DragDropContext;
}
class DragDropProvider extends Roact.Component<DragDropProviderProps> {
constructor(props: DragDropProviderProps);
public render(): Roact.Element;
}
// export function createDragSource<P, A extends unknown>(
// innerComponent: keyof CreatableInstances, // StatefulComponent<P>,
// options?: IDraggableOptions
// ): DragSourceWrapper<P>;
// export function createDragTarget<P, A extends unknown>(
// innerComponent: keyof CreatableInstances, // StatefulComponent<P>,
// onDragEnd: (data: A) => void,
// options?: IDraggableOptions
// ): DragTargetWrapper<P>;
class DragFrame extends Roact.Component<
IDragSource<Frame> & Roact.JsxObject<Frame>
> {
public render(): Roact.Element;
}
class DropFrame extends Roact.Component<
IDropTarget<Frame> & Roact.JsxObject<Frame>
> {
public render(): Roact.Element;
}
class DragImageButton extends Roact.Component<
IDragSource<ImageButton> & Roact.JsxObject<ImageButton>
> {
public render(): Roact.Element;
}
}