nxt-sortablejs
Version:
Angular sortablejs bindings.
67 lines (62 loc) • 3.16 kB
TypeScript
import * as i0 from '@angular/core';
import { OnChanges, OnDestroy, AfterViewInit, EventEmitter, ElementRef, NgZone, Renderer2, SimpleChange, ModuleWithProviders } from '@angular/core';
import { AbstractControl, FormArray } from '@angular/forms';
import Sortable, { Options } from 'sortablejs';
/** @internal */
declare class SortablejsService {
transfer?: (items: any[]) => void;
static ɵfac: i0.ɵɵFactoryDeclaration<SortablejsService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<SortablejsService>;
}
type SortableData<T> = [T] extends [AbstractControl] ? (FormArray<T> | T[]) : T[];
type CloneFunction<T> = (item: T) => T;
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>;
}
declare class SortablejsModule {
static forRoot(globalOptions: Options): ModuleWithProviders<SortablejsModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<SortablejsModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<SortablejsModule, [typeof SortablejsDirective], never, [typeof SortablejsDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<SortablejsModule>;
}
export { SortablejsDirective, SortablejsModule };
export type { CloneFunction, SortableData };