UNPKG

11.4 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("primeng/button"),require("primeng/api"),require("primeng/dom"),require("primeng/utils")):"function"==typeof define&&define.amd?define("primeng/orderlist",["exports","@angular/core","@angular/common","primeng/button","primeng/api","primeng/dom","primeng/utils"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.orderlist={}),t.ng.core,t.ng.common,t.primeng.button,t.primeng.api,t.primeng.dom,t.primeng.utils)}(this,(function(t,e,i,n,o,r,l){"use strict";var s=this&&this.__decorate||function(t,e,i,n){var o,r=arguments.length,l=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(l=(r<3?o(l):r>3?o(e,i,l):o(e,i))||l);return r>3&&l&&Object.defineProperty(e,i,l),l},a=this&&this.__read||function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)l.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return l},p=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t},u=function(){function t(t){this.el=t,this.metaKeySelection=!0,this.controlsPosition="left",this.filterMatchMode="contains",this.selectionChange=new e.EventEmitter,this.trackBy=function(t,e){return e},this.onReorder=new e.EventEmitter,this.onSelectionChange=new e.EventEmitter,this.onFilterEvent=new e.EventEmitter}return Object.defineProperty(t.prototype,"selection",{get:function(){return this._selection},set:function(t){this._selection=t},enumerable:!0,configurable:!0}),t.prototype.ngAfterContentInit=function(){var t=this;this.templates.forEach((function(e){switch(e.getType()){case"item":default:t.itemTemplate=e.template}}))},t.prototype.ngAfterViewChecked=function(){if(this.movedUp||this.movedDown){var t=r.DomHandler.find(this.listViewChild.nativeElement,"li.ui-state-highlight"),e=void 0;t.length>0&&(e=this.movedUp?t[0]:t[t.length-1],r.DomHandler.scrollInView(this.listViewChild.nativeElement,e)),this.movedUp=!1,this.movedDown=!1}},Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){this._value=t,this.filterValue&&this.filter()},enumerable:!0,configurable:!0}),t.prototype.onItemClick=function(t,e,i){this.itemTouched=!1;var n=l.ObjectUtils.findIndexInList(e,this.selection),o=-1!=n;if(!this.itemTouched&&this.metaKeySelection){var r=t.metaKey||t.ctrlKey||t.shiftKey;o&&r?this._selection=this._selection.filter((function(t,e){return e!==n})):(this._selection=r&&this._selection?p(this._selection):[],l.ObjectUtils.insertIntoOrderedArray(e,i,this._selection,this.value))}else o?this._selection=this._selection.filter((function(t,e){return e!==n})):(this._selection=this._selection?p(this._selection):[],l.ObjectUtils.insertIntoOrderedArray(e,i,this._selection,this.value));this.selectionChange.emit(this._selection),this.onSelectionChange.emit({originalEvent:t,value:this._selection})},t.prototype.onFilterKeyup=function(t){this.filterValue=t.target.value.trim().toLocaleLowerCase(this.filterLocale),this.filter(),this.onFilterEvent.emit({originalEvent:t,value:this.visibleOptions})},t.prototype.filter=function(){var t=this.filterBy.split(",");this.visibleOptions=l.FilterUtils.filter(this.value,t,this.filterValue,this.filterMatchMode,this.filterLocale)},t.prototype.isItemVisible=function(t){if(!this.filterValue||!this.filterValue.trim().length)return!0;for(var e=0;e<this.visibleOptions.length;e++)if(t==this.visibleOptions[e])return!0},t.prototype.onItemTouchEnd=function(t){this.itemTouched=!0},t.prototype.isSelected=function(t){return-1!=l.ObjectUtils.findIndexInList(t,this.selection)},t.prototype.moveUp=function(t){if(this.selection){for(var e=0;e<this.selection.length;e++){var i=this.selection[e],n=l.ObjectUtils.findIndexInList(i,this.value);if(0==n)break;var o=this.value[n],r=this.value[n-1];this.value[n-1]=o,this.value[n]=r}this.movedUp=!0,this.onReorder.emit(t)}},t.prototype.moveTop=function(t){if(this.selection){for(var e=this.selection.length-1;e>=0;e--){var i=this.selection[e],n=l.ObjectUtils.findIndexInList(i,this.value);if(0==n)break;var o=this.value.splice(n,1)[0];this.value.unshift(o)}this.onReorder.emit(t),this.listViewChild.nativeElement.scrollTop=0}},t.prototype.moveDown=function(t){if(this.selection){for(var e=this.selection.length-1;e>=0;e--){var i=this.selection[e],n=l.ObjectUtils.findIndexInList(i,this.value);if(n==this.value.length-1)break;var o=this.value[n],r=this.value[n+1];this.value[n+1]=o,this.value[n]=r}this.movedDown=!0,this.onReorder.emit(t)}},t.prototype.moveBottom=function(t){if(this.selection){for(var e=0;e<this.selection.length;e++){var i=this.selection[e],n=l.ObjectUtils.findIndexInList(i,this.value);if(n==this.value.length-1)break;var o=this.value.splice(n,1)[0];this.value.push(o)}this.onReorder.emit(t),this.listViewChild.nativeElement.scrollTop=this.listViewChild.nativeElement.scrollHeight}},t.prototype.onDragStart=function(t,e){t.dataTransfer.setData("text","b"),t.target.blur(),this.dragging=!0,this.draggedItemIndex=e},t.prototype.onDragOver=function(t,e){this.dragging&&this.draggedItemIndex!==e&&this.draggedItemIndex+1!==e&&(this.dragOverItemIndex=e,t.preventDefault())},t.prototype.onDragLeave=function(t){this.dragOverItemIndex=null},t.prototype.onDrop=function(t,e){var i=this.draggedItemIndex>e?e:0===e?0:e-1;l.ObjectUtils.reorderArray(this.value,this.draggedItemIndex,i),this.dragOverItemIndex=null,this.onReorder.emit(t),t.preventDefault()},t.prototype.onDragEnd=function(t){this.dragging=!1},t.prototype.onListMouseMove=function(t){if(this.dragging){var e=this.listViewChild.nativeElement.getBoundingClientRect().top+document.body.scrollTop,i=e+this.listViewChild.nativeElement.clientHeight-t.pageY,n=t.pageY-e;i<25&&i>0?this.listViewChild.nativeElement.scrollTop+=15:n<25&&n>0&&(this.listViewChild.nativeElement.scrollTop-=15)}},t.prototype.onItemKeydown=function(t,e,i){var n=t.currentTarget;switch(t.which){case 40:var o=this.findNextItem(n);o&&o.focus(),t.preventDefault();break;case 38:var r=this.findPrevItem(n);r&&r.focus(),t.preventDefault();break;case 13:this.onItemClick(t,e,i),t.preventDefault()}},t.prototype.findNextItem=function(t){var e=t.nextElementSibling;return e?!r.DomHandler.hasClass(e,"ui-orderlist-item")||r.DomHandler.isHidden(e)?this.findNextItem(e):e:null},t.prototype.findPrevItem=function(t){var e=t.previousElementSibling;return e?!r.DomHandler.hasClass(e,"ui-orderlist-item")||r.DomHandler.isHidden(e)?this.findPrevItem(e):e:null},t.ctorParameters=function(){return[{type:e.ElementRef}]},s([e.Input()],t.prototype,"header",void 0),s([e.Input()],t.prototype,"style",void 0),s([e.Input()],t.prototype,"styleClass",void 0),s([e.Input()],t.prototype,"listStyle",void 0),s([e.Input()],t.prototype,"responsive",void 0),s([e.Input()],t.prototype,"filterBy",void 0),s([e.Input()],t.prototype,"filterPlaceholder",void 0),s([e.Input()],t.prototype,"filterLocale",void 0),s([e.Input()],t.prototype,"metaKeySelection",void 0),s([e.Input()],t.prototype,"dragdrop",void 0),s([e.Input()],t.prototype,"controlsPosition",void 0),s([e.Input()],t.prototype,"ariaFilterLabel",void 0),s([e.Input()],t.prototype,"filterMatchMode",void 0),s([e.Output()],t.prototype,"selectionChange",void 0),s([e.Input()],t.prototype,"trackBy",void 0),s([e.Output()],t.prototype,"onReorder",void 0),s([e.Output()],t.prototype,"onSelectionChange",void 0),s([e.Output()],t.prototype,"onFilterEvent",void 0),s([e.ViewChild("listelement")],t.prototype,"listViewChild",void 0),s([e.ContentChildren(o.PrimeTemplate)],t.prototype,"templates",void 0),s([e.Input()],t.prototype,"selection",null),s([e.Input()],t.prototype,"value",null),t=s([e.Component({selector:"p-orderList",template:'\n <div [ngClass]="{\'ui-orderlist ui-widget\': true, \'ui-orderlist-controls-left\': controlsPosition === \'left\',\n \'ui-orderlist-controls-right\': controlsPosition === \'right\'}" [ngStyle]="style" [class]="styleClass">\n <div class="ui-orderlist-controls">\n <button type="button" pButton icon="pi pi-angle-up" (click)="moveUp($event)"></button>\n <button type="button" pButton icon="pi pi-angle-double-up" (click)="moveTop($event)"></button>\n <button type="button" pButton icon="pi pi-angle-down" (click)="moveDown($event)"></button>\n <button type="button" pButton icon="pi pi-angle-double-down" (click)="moveBottom($event)"></button>\n </div>\n <div class="ui-orderlist-list-container">\n <div class="ui-orderlist-caption ui-widget-header ui-corner-top" *ngIf="header">{{header}}</div>\n <div class="ui-orderlist-filter-container ui-widget-content" *ngIf="filterBy">\n <input type="text" role="textbox" (keyup)="onFilterKeyup($event)" class="ui-inputtext ui-widget ui-state-default ui-corner-all" [attr.placeholder]="filterPlaceholder" [attr.aria-label]="ariaFilterLabel">\n <span class="ui-orderlist-filter-icon pi pi-search"></span>\n </div>\n <ul #listelement class="ui-widget-content ui-orderlist-list ui-corner-bottom" [ngStyle]="listStyle" (dragover)="onListMouseMove($event)">\n <ng-template ngFor [ngForTrackBy]="trackBy" let-item [ngForOf]="value" let-i="index" let-l="last">\n <li class="ui-orderlist-droppoint" *ngIf="dragdrop && isItemVisible(item)" (dragover)="onDragOver($event, i)" (drop)="onDrop($event, i)" (dragleave)="onDragLeave($event)"\n [ngClass]="{\'ui-orderlist-droppoint-highlight\': (i === dragOverItemIndex)}"></li>\n <li class="ui-orderlist-item" tabindex="0"\n [ngClass]="{\'ui-state-highlight\':isSelected(item)}"\n (click)="onItemClick($event,item,i)" (touchend)="onItemTouchEnd($event)" (keydown)="onItemKeydown($event,item,i)"\n [style.display]="isItemVisible(item) ? \'block\' : \'none\'" role="option" [attr.aria-selected]="isSelected(item)"\n [draggable]="dragdrop" (dragstart)="onDragStart($event, i)" (dragend)="onDragEnd($event)">\n <ng-container *ngTemplateOutlet="itemTemplate; context: {$implicit: item, index: i}"></ng-container>\n </li>\n <li class="ui-orderlist-droppoint" *ngIf="dragdrop && l" (dragover)="onDragOver($event, i + 1)" (drop)="onDrop($event, i + 1)" (dragleave)="onDragLeave($event)"\n [ngClass]="{\'ui-orderlist-droppoint-highlight\': (i + 1 === dragOverItemIndex)}"></li>\n </ng-template>\n </ul>\n </div>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),d=function(){function t(){}return t=s([e.NgModule({imports:[i.CommonModule,n.ButtonModule,o.SharedModule],exports:[u,o.SharedModule],declarations:[u]})],t)}();t.OrderList=u,t.OrderListModule=d,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-orderlist.umd.min.js.map
\No newline at end of file