Skip to content

Commit 2bcbca6

Browse files
committed
fix: typescript declarations + extending to events
1 parent 123a6b8 commit 2bcbca6

File tree

1 file changed

+73
-24
lines changed

1 file changed

+73
-24
lines changed

src/vuedraggable.d.ts

+73-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,75 @@
11
declare module 'vuedraggable' {
2-
import Vue from 'vue';
3-
class Draggable extends Vue {
4-
static install(vue: typeof Vue): void;
5-
6-
noTransitionOnDrag: boolean;
7-
8-
element: string;
9-
10-
tag: string;
11-
12-
options: object;
13-
14-
componentData: object;
15-
16-
clone: any;
17-
18-
move: any;
19-
20-
list: any[];
21-
22-
value: any[];
23-
}
24-
25-
export = Draggable;
2+
import Vue, { VueConstructor } from 'vue';
3+
4+
type CombinedVueInstance<
5+
Instance extends Vue,
6+
Data,
7+
Methods,
8+
Computed,
9+
Props
10+
> = Data & Methods & Computed & Props & Instance;
11+
12+
type ExtendedVue<
13+
Instance extends Vue,
14+
Data,
15+
Methods,
16+
Computed,
17+
Props
18+
> = VueConstructor<
19+
CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue
20+
>;
21+
22+
export type DraggedContext<T> = {
23+
index: number;
24+
futureIndex: number;
25+
element: T;
26+
};
27+
28+
export type DropContext<T> = {
29+
index: number;
30+
component: Vue;
31+
element: T;
32+
};
33+
34+
export type Rectangle = {
35+
top: number;
36+
right: number;
37+
bottom: number;
38+
left: number;
39+
width: number;
40+
height: number;
41+
};
42+
43+
export type MoveEvent<T> = {
44+
originalEvent: DragEvent;
45+
dragged: Element;
46+
draggedContext: DraggedContext<T>;
47+
draggedRect: Rectangle;
48+
related: Element;
49+
relatedContext: DropContext<T>;
50+
relatedRect: Rectangle;
51+
from: Element;
52+
to: Element;
53+
willInsertAfter: boolean;
54+
isTrusted: boolean;
55+
};
56+
57+
const draggable: ExtendedVue<
58+
Vue,
59+
{},
60+
{},
61+
{},
62+
{
63+
options: any;
64+
list: any[];
65+
value: any[];
66+
noTransitionOnDrag?: boolean;
67+
clone: any;
68+
tag?: string | null;
69+
move: any;
70+
componentData: any;
71+
}
72+
>;
73+
74+
export default draggable;
2675
}

0 commit comments

Comments
 (0)