diff --git a/types/sortablejs/index.d.ts b/types/sortablejs/index.d.ts index a364531f24..9d0b53c118 100644 --- a/types/sortablejs/index.d.ts +++ b/types/sortablejs/index.d.ts @@ -36,9 +36,9 @@ declare class Sortable { /** * Mounts a plugin to Sortable * @param sortablePlugin a sortable plugin. - * + * * @example - * + * * Sortable.mount(new MultiDrag(), new AutoScroll()) */ static mount(...sortablePlugins: SortablePlugin[]): void; @@ -95,6 +95,10 @@ declare namespace Sortable { OnSpillOptions, SwapOptions {} + /** + * A class that all plugins inherit from for the sake of types + */ + export class Plugin extends SortablePlugin {} export class MultiDrag extends MultiDragPlugin {} export class AutoScroll extends AutoScrollPlugin {} export class Swap extends SwapPlugin {} @@ -123,6 +127,18 @@ declare namespace Sortable { * list, in which moved element. */ to: HTMLElement; + /** + * Old index within parent, only counting draggable elements + */ + oldDraggableIndex: number | undefined; + /** + * New index within parent, only counting draggable elements + */ + newDraggableIndex: number | undefined; + /** + * Pull mode if dragging into another sortable + */ + pullMode: 'clone' | boolean | undefined; } export interface MoveEvent extends Event { @@ -152,7 +168,25 @@ declare namespace Sortable { /** * whether elements can be added from other lists, or an array of group names from which elements can be taken. */ - put?: ((to: Sortable) => PutResult) | PutResult; + put?: PutResult | ((to: Sortable) => PullResult); + /** + * a canonical version of pull, created by Sortable + */ + checkPull?: ( + sortable: Sortable, + activeSortable: Sortable, + dragEl: HTMLElement, + event: SortableEvent, + ) => boolean | string | Array; + /** + * a canonical version of put, created by Sortable + */ + checkPut?: ( + sortable: Sortable, + activeSortable: Sortable, + dragEl: HTMLElement, + event: SortableEvent, + ) => boolean | string | 'clone' | Array; /** * revert cloned element to initial position after moving to a another list. */