Comments (3)
Its better to use index.d.ts approach since you don't have to change existing files if you do not want. But even if you implement new .ts files, I think it would be better to create index.d.ts file.
from vue-dndrop.
Hi everyone, I currently use this library in a project and I would like to contribute by adding typescript support. Do you want me to work on this? If yes, would it rather be by replacing every .js with .ts or by adding an index.d.ts?
Thanks for your repository.
This would be very helpful. The library seems more intuitive than others I've found and my projects are in TS.
from vue-dndrop.
I created @types/vue-dndrop/index.d.ts
in the src
directory of my project.
/// <reference types='vue' />
declare module 'vue-dndrop' {
import type {
AllowedComponentProps,
ComponentCustomProps,
ComponentOptionsMixin,
DefineComponent,
NativeElements,
PropType,
VNodeProps,
} from 'vue'
type WithTemplateSlots<T, S> = T & {
new (): {
$slots: S
}
}
export type DragResult = {
isSource: boolean
payload: unknown
willAcceptDrop: boolean
}
export type DropResult = {
addedIndex: number | null
element: HTMLElement
payload: unknown
removedIndex: number | null
}
export type DropNotAllowedResult = {
payload: unknown
container: object
}
export type Tag =
| keyof NativeElements
| { [K in keyof NativeElements]: { value: K; props: NativeElements[K] } }[keyof NativeElements]
export type ContainerProps = {
orientation?: 'horizontal' | 'vertical'
behaviour?: 'move' | 'copy' | 'drop-zone' | 'contain'
tag?: Tag
groupName?: string
lockAxis?: 'x' | 'y'
dragHandleSelector?: string
nonDragAreaSelector?: string
dragBeginDelay?: number
animationDuration?: number
autoScrollEnabled?: boolean
dragClass?: string
dropClass?: string
removeOnDropOut?: boolean
dropPlaceholder?: boolean | Record<string, any>
fireRelatedEventsOnly?: boolean
getChildPayload?: (index: number) => unknown
shouldAcceptDrop?: (sourceContainerOptions: object, payload: unknown) => boolean
shouldAnimateDrop?: (sourceContainerOptions: object, payload: unknown) => boolean
getGhostParent?: () => HTMLElement
}
export type ContainerEmits = {
dragStart?: (dragResult: DragResult) => void
dragEnd?: (dragResult: DragResult) => void
dragEnter?: () => void
dragLeave?: () => void
dropReady?: (dropResult: DropResult) => void
drop?: (dropResult: DropResult) => void
dropNotAllowed?: (dropNotAllowedResult: DropNotAllowedResult) => void
}
export const Container: WithTemplateSlots<
DefineComponent<
{ [K in keyof ContainerProps]-?: { type: PropType<ContainerProps[K]> } },
{},
unknown,
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
ContainerEmits,
string,
VNodeProps & AllowedComponentProps & ComponentCustomProps,
Readonly<ContainerProps> & { [K in keyof ContainerEmits as `on${Capitalize<K>}`]?: ContainerEmits[K] },
{},
{}
>,
Readonly<{ default(): any }>
>
export type DraggableProps = {
dragNotAllowed?: boolean
tag?: Tag
}
export const Draggable: WithTemplateSlots<
DefineComponent<
{ [K in keyof DraggableProps]-?: { type: PropType<DraggableProps[K]> } },
{},
unknown,
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
VNodeProps & AllowedComponentProps & ComponentCustomProps,
Readonly<DraggableProps>,
{},
{}
>,
Readonly<{ default(): any }>
>
}
from vue-dndrop.
Related Issues (20)
- Drag to select HOT 1
- Custom ghost element HOT 2
- Nesting question HOT 2
- No Animation HOT 2
- Fix with scale transform
- npm package for Vue 3.x does not include utils HOT 2
- Getting the Container that a Draggable was Dragged into.
- Contextmenu on table row HOT 1
- Drag works only for first time on mobile (touch) device HOT 11
- drag-enter event is emitted only once
- Behaviour prop is not reactive.
- Drag&Drop multiple lines HOT 2
- TypeError Cannot read properties of null (reading 'addedIndex') HOT 1
- issue with drag-class / styling ghost emelent HOT 2
- Evento de click no card HOT 2
- Drop on mouse position in drop-zone, not a senter of dragged item
- The 'drag-enter' event doesn't fire If the group names are different.
- drop-not-allowed event does not fire.
- When draggable item is halfway moved, droppable area disappears HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-dndrop.