Skip to content

Commit

Permalink
fix: typescript declarations + extending to events
Browse files Browse the repository at this point in the history
  • Loading branch information
Keimeno committed Jul 23, 2020
1 parent 123a6b8 commit 2bcbca6
Showing 1 changed file with 73 additions and 24 deletions.
97 changes: 73 additions & 24 deletions src/vuedraggable.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,75 @@
declare module 'vuedraggable' {
import Vue from 'vue';
class Draggable extends Vue {
static install(vue: typeof Vue): void;

noTransitionOnDrag: boolean;

element: string;

tag: string;

options: object;

componentData: object;

clone: any;

move: any;

list: any[];

value: any[];
}

export = Draggable;
import Vue, { VueConstructor } from 'vue';

type CombinedVueInstance<
Instance extends Vue,
Data,
Methods,
Computed,
Props
> = Data & Methods & Computed & Props & Instance;

type ExtendedVue<
Instance extends Vue,
Data,
Methods,
Computed,
Props
> = VueConstructor<
CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue
>;

export type DraggedContext<T> = {
index: number;
futureIndex: number;
element: T;
};

export type DropContext<T> = {
index: number;
component: Vue;
element: T;
};

export type Rectangle = {
top: number;
right: number;
bottom: number;
left: number;
width: number;
height: number;
};

export type MoveEvent<T> = {
originalEvent: DragEvent;
dragged: Element;
draggedContext: DraggedContext<T>;
draggedRect: Rectangle;
related: Element;
relatedContext: DropContext<T>;
relatedRect: Rectangle;
from: Element;
to: Element;
willInsertAfter: boolean;
isTrusted: boolean;
};

const draggable: ExtendedVue<
Vue,
{},
{},
{},
{
options: any;
list: any[];
value: any[];
noTransitionOnDrag?: boolean;
clone: any;
tag?: string | null;
move: any;
componentData: any;
}
>;

export default draggable;
}

0 comments on commit 2bcbca6

Please sign in to comment.