UNPKG

nxt-sortablejs

Version:
50 lines (49 loc) 2.51 kB
import { AfterViewInit, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, Renderer2, SimpleChange } from '@angular/core'; import { type AbstractControl, type FormArray } from '@angular/forms'; import Sortable, { Options } from 'sortablejs'; import { SortablejsService } from './sortablejs.service'; import * as i0 from "@angular/core"; export type SortableData<T> = [T] extends [AbstractControl] ? (FormArray<T> | T[]) : T[]; export type CloneFunction<T> = (item: T) => T; export declare class SortablejsDirective<T> implements OnChanges, OnDestroy, AfterViewInit { private readonly globalConfig; private readonly service; private readonly element; private readonly zone; private readonly renderer; /** Input data, can be Array or FormArray */ data?: SortableData<T>; /** * CSS selector for the sortable container * * Mostly required when used with custom components which wrap items in multiple containers. In that case, * this should be the selector for the direct HTML parent of sortable items. */ sortablejsContainer?: string; /** Sortablejs configuration */ config?: Options; /** A function invoked when cloning items from template dataset into target dataset */ cloneFunction?: CloneFunction<T>; /** Initialised a new Sortablejs instance */ readonly init: EventEmitter<Sortable>; private sortableInstance?; constructor(globalConfig: Options | undefined, service: SortablejsService, element: ElementRef, zone: NgZone, renderer: Renderer2); /** @internal */ ngAfterViewInit(): void; /** @internal */ ngOnChanges(changes: { [prop in keyof SortablejsDirective<T>]: SimpleChange; }): void; /** @internal */ ngOnDestroy(): void; private create; private getBindings; private get options(); private get optionsWithoutEvents(); private proxyEvent; private get isCloning(); private clone; private get overridenOptions(); static ɵfac: i0.ɵɵFactoryDeclaration<SortablejsDirective<any>, [{ optional: true; }, null, null, null, null]>; static ɵdir: i0.ɵɵDirectiveDeclaration<SortablejsDirective<any>, "[nxtSortablejs]", never, { "data": { "alias": "nxtSortablejs"; "required": false; }; "sortablejsContainer": { "alias": "sortablejsContainer"; "required": false; }; "config": { "alias": "config"; "required": false; }; "cloneFunction": { "alias": "cloneFunction"; "required": false; }; }, { "init": "init"; }, never, never, false, never>; }