kutlugsahin / vue-smooth-dnd

Vue wrapper components for smooth-dnd
MIT License
1.73k stars 250 forks source link

Typescript Definition files #44

Open nootn opened 6 years ago

nootn commented 6 years ago

Hi, do you have any plans to include Typescript Definition files in vue-smooth-dnd (and smooth-dnd would also need one)?

If not, I might investigate creating them, if I did that would you accept a pull request?

soyersoyer commented 5 years ago

My vue-smooth-dnd.d.ts file:

declare module 'vue-smooth-dnd' {
    import Vue from 'vue';

    type Payload = any;

    interface DropResult {
        removedIndex: number;
        addedIndex: number;
        payload: Payload;
        element: Element;
    }

    interface DragEvent {
        isSource: boolean;
        payload: Payload;
        willAcceptDrop: boolean;
    }

    interface NodeDescription {
        value: string;
        props: Vue.VNodeData;
    }

    interface ContainerProps {
        orientation?: string;
        behaviour?: string;
        tag?: string | NodeDescription;
        groupName?: string;
        lockAxis?: string;
        dragHandleSelector?: string;
        nonDragAreaSelector?: string;
        dragBeginDelay?: number;
        animationDuration?: number;
        autoScrollEnabled?: boolean;
        dragClass?: string;
        dropClass?: string;
        removeOnDropOut?: boolean;
        getChildPayload?: (index: number) => Payload;
        shouldAnimateDrop?: (sourceContainerOptions: ContainerProps, payload: Payload) => boolean;
        shouldAcceptDrop?: (sourceContainerOptions: ContainerProps, payload: Payload) => boolean;
        getGhostParent: () => Element;
        onDragStart?: (dragEvent: DragEvent) => void;
        onDragEnd?: (dragEvent: DragEvent) => void;
        onDrop?: (dropResult: DropResult) => void;
        onDragEnter?: () => void;
        onDragLeave?: () => void;
        onDropReady?: (dropResult: DropResult) => void;
    }

    class Container extends Vue {
        props: ContainerProps
    }

    class Draggable extends Vue {
        props: {
            tag?: string | NodeDescription;
        }
    }
}
mesqueeb commented 4 years ago

I needed this! Thanks so much!!

mahdiprog commented 3 years ago

very useful

li-jingxuan commented 3 years ago

I need it very much, thank you very much