{"version":3,"file":"ngx-bootstrap-sortable.mjs","sources":["../tmp-esm2022/draggable-item.service.js","../tmp-esm2022/sortable.component.js","../tmp-esm2022/sortable.module.js","../tmp-esm2022/ngx-bootstrap-sortable.js"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport * as i0 from \"@angular/core\";\nexport class DraggableItemService {\n constructor() {\n this.onCapture = new Subject();\n }\n dragStart(item) {\n this.draggableItem = item;\n }\n getItem() {\n return this.draggableItem;\n }\n captureItem(overZoneIndex, newIndex) {\n if (this.draggableItem && this.draggableItem.overZoneIndex !== overZoneIndex) {\n this.draggableItem.lastZoneIndex = this.draggableItem.overZoneIndex;\n this.draggableItem.overZoneIndex = overZoneIndex;\n this.onCapture.next(this.draggableItem);\n this.draggableItem = Object.assign({}, this.draggableItem, {\n overZoneIndex,\n i: newIndex\n });\n }\n return this.draggableItem;\n }\n onCaptureItem() {\n return this.onCapture;\n }\n static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"20.0.2\", ngImport: i0, type: DraggableItemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"20.0.2\", ngImport: i0, type: DraggableItemService, providedIn: 'platform' }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"20.0.2\", ngImport: i0, type: DraggableItemService, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'platform' }]\n }] });\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJhZ2dhYmxlLWl0ZW0uc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9zb3J0YWJsZS9kcmFnZ2FibGUtaXRlbS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRU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FpvbmVJbmRleCA9IHRoaXMuZHJhZ2dhYmxlSXRlbS5vdmVyWm9uZUluZGV4O1xuICAgICAgdGhpcy5kcmFnZ2FibGVJdGVtLm92ZXJab25lSW5kZXggPSBvdmVyWm9uZUluZGV4O1xuICAgICAgdGhpcy5vbkNhcHR1cmUubmV4dCh0aGlzLmRyYWdnYWJsZUl0ZW0pO1xuICAgICAgdGhpcy5kcmFnZ2FibGVJdGVtID0gT2JqZWN0LmFzc2lnbih7fSwgdGhpcy5kcmFnZ2FibGVJdGVtLCB7XG4gICAgICAgIG92ZXJab25lSW5kZXgsXG4gICAgICAgIGk6IG5ld0luZGV4XG4gICAgICB9KTtcbiAgICB9XG5cbiAgICByZXR1cm4gdGhpcy5kcmFnZ2FibGVJdGVtO1xuICB9XG5cbiAgb25DYXB0dXJlSXRlbSgpOiBTdWJqZWN0PERyYWdnYWJsZUl0ZW0+IHtcbiAgICByZXR1cm4gdGhpcy5vbkNhcHR1cmU7XG4gIH1cbn1cbiJdfQ==","import { Component, Input, Output, EventEmitter, forwardRef, TemplateRef } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { DraggableItemService } from './draggable-item.service';\nimport { NgClass, NgStyle, NgIf, NgFor, NgTemplateOutlet } from '@angular/common';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"./draggable-item.service\";\nexport class SortableComponent {\n static { this.globalZoneIndex = 0; }\n get items() {\n return this._items;\n }\n set items(value) {\n this._items = value;\n const out = this.items.map((x) => x.initData);\n this.onChanged(out);\n this.onChange.emit(out);\n }\n constructor(transfer) {\n /** class name for items wrapper */\n this.wrapperClass = '';\n /** style object for items wrapper */\n this.wrapperStyle = {};\n /** class name for item */\n this.itemClass = '';\n /** style object for item */\n this.itemStyle = {};\n /** class name for active item */\n this.itemActiveClass = '';\n /** style object for active item */\n this.itemActiveStyle = {};\n /** class name for placeholder */\n this.placeholderClass = '';\n /** style object for placeholder */\n this.placeholderStyle = {};\n /** placeholder item which will be shown if collection is empty */\n this.placeholderItem = '';\n /** fired on array change (reordering, insert, remove), same as ngModelChange.\n * Returns new items collection as a payload.\n */\n this.onChange = new EventEmitter();\n this.showPlaceholder = false;\n this.activeItem = -1;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.onTouched = Function.prototype;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.onChanged = Function.prototype;\n this._items = [];\n this.transfer = transfer;\n this.currentZoneIndex = SortableComponent.globalZoneIndex++;\n this.transfer\n .onCaptureItem()\n .subscribe((item) => this.onDrop(item));\n }\n onItemDragstart(event, item, i) {\n this.initDragstartEvent(event);\n this.onTouched();\n this.transfer.dragStart({\n event,\n item,\n i,\n initialIndex: i,\n lastZoneIndex: this.currentZoneIndex,\n overZoneIndex: this.currentZoneIndex\n });\n }\n onItemDragover(event, i) {\n if (!this.transfer.getItem()) {\n return;\n }\n event.preventDefault();\n const dragItem = this.transfer.captureItem(this.currentZoneIndex, this.items.length);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let newArray = [];\n if (!dragItem) {\n return;\n }\n if (!this.items.length) {\n newArray = [dragItem.item];\n }\n else if (dragItem.i > i) {\n newArray = [\n ...this.items.slice(0, i),\n dragItem.item,\n ...this.items.slice(i, dragItem.i),\n ...this.items.slice(dragItem.i + 1)\n ];\n }\n else {\n // this.draggedItem.i < i\n newArray = [\n ...this.items.slice(0, dragItem.i),\n ...this.items.slice(dragItem.i + 1, i + 1),\n dragItem.item,\n ...this.items.slice(i + 1)\n ];\n }\n this.items = newArray;\n dragItem.i = i;\n this.activeItem = i;\n this.updatePlaceholderState();\n }\n cancelEvent(event) {\n if (!this.transfer.getItem() || !event) {\n return;\n }\n event.preventDefault();\n }\n onDrop(item) {\n if (item &&\n item.overZoneIndex !== this.currentZoneIndex &&\n item.lastZoneIndex === this.currentZoneIndex) {\n this.items = this.items.filter((x, i) => i !== item.i);\n this.updatePlaceholderState();\n }\n this.resetActiveItem();\n }\n resetActiveItem(event) {\n this.cancelEvent(event);\n this.activeItem = -1;\n }\n registerOnChange(callback) {\n this.onChanged = callback;\n }\n registerOnTouched(callback) {\n this.onTouched = callback;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n writeValue(value) {\n if (value) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.items = value.map((x, i) => ({\n id: i,\n initData: x,\n value: this.fieldName ? x[this.fieldName] : x\n }));\n }\n else {\n this.items = [];\n }\n this.updatePlaceholderState();\n }\n updatePlaceholderState() {\n this.showPlaceholder = !this._items.length;\n }\n getItemStyle(isActive) {\n return isActive\n ? Object.assign({}, this.itemStyle, this.itemActiveStyle)\n : this.itemStyle;\n }\n initDragstartEvent(event) {\n // it is necessary for mozilla\n // data type should be 'Text' instead of 'text/plain' to keep compatibility\n // with IE\n event.dataTransfer?.setData('Text', 'placeholder');\n }\n static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"20.0.2\", ngImport: i0, type: SortableComponent, deps: [{ token: i1.DraggableItemService }], target: i0.ɵɵFactoryTarget.Component }); }\n static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"20.0.2\", type: SortableComponent, isStandalone: true, selector: \"bs-sortable\", inputs: { fieldName: \"fieldName\", wrapperClass: \"wrapperClass\", wrapperStyle: \"wrapperStyle\", itemClass: \"itemClass\", itemStyle: \"itemStyle\", itemActiveClass: \"itemActiveClass\", itemActiveStyle: \"itemActiveStyle\", placeholderClass: \"placeholderClass\", placeholderStyle: \"placeholderStyle\", placeholderItem: \"placeholderItem\", itemTemplate: \"itemTemplate\" }, outputs: { onChange: \"onChange\" }, providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SortableComponent),\n multi: true\n }\n ], exportAs: [\"bs-sortable\"], ngImport: i0, template: `\n