From eee000a782be0486d5144291047016f07fff93eb Mon Sep 17 00:00:00 2001 From: Wayne Van Son Date: Mon, 16 Dec 2019 22:27:49 +1100 Subject: [PATCH] [sortablejs] adds 5 missing properties in interfaces (#41045) * [sortablejs] create checkPull and checkPut options * [sortablejs] create oldDraggableIndex, newDraggableIndex and pullMode options * [sortablejs] recreate put function again * remove from in pull function * [sortablejs] add plugin class to exports. --- types/sortablejs/index.d.ts | 40 ++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) 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. */