primeng
Version:
[](https://badge.fury.io/js/primeng) [](https://www.npmjs.com/package/primeng) [
{"version":3,"file":"primeng-picklist.mjs","sources":["../../src/app/components/picklist/picklist.ts","../../src/app/components/picklist/primeng-picklist.ts"],"sourcesContent":["import {\n NgModule,\n Component,\n ElementRef,\n AfterContentInit,\n AfterViewChecked,\n Input,\n Output,\n ContentChildren,\n QueryList,\n TemplateRef,\n EventEmitter,\n ViewChild,\n ChangeDetectionStrategy,\n ViewEncapsulation,\n ChangeDetectorRef,\n Renderer2,\n Inject,\n PLATFORM_ID\n} from '@angular/core';\nimport { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { ButtonModule } from 'primeng/button';\nimport { SharedModule, PrimeTemplate, FilterService } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport { RippleModule } from 'primeng/ripple';\nimport { CdkDragDrop, DragDropModule, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';\nimport { ObjectUtils, UniqueComponentId } from 'primeng/utils';\nimport { AngleDoubleDownIcon } from 'primeng/icons/angledoubledown';\nimport { AngleDoubleLeftIcon } from 'primeng/icons/angledoubleleft';\nimport { AngleDoubleRightIcon } from 'primeng/icons/angledoubleright';\nimport { AngleDoubleUpIcon } from 'primeng/icons/angledoubleup';\nimport { AngleDownIcon } from 'primeng/icons/angledown';\nimport { AngleLeftIcon } from 'primeng/icons/angleleft';\nimport { AngleRightIcon } from 'primeng/icons/angleright';\nimport { AngleUpIcon } from 'primeng/icons/angleup';\nimport { SearchIcon } from 'primeng/icons/search';\nimport { HomeIcon } from 'primeng/icons/home';\n\nexport interface PickListFilterOptions {\n filter?: (value?: any) => void;\n reset?: () => void;\n}\n\n@Component({\n selector: 'p-pickList',\n template: `\n <div [class]=\"styleClass\" [ngStyle]=\"style\" [ngClass]=\"{ 'p-picklist p-component': true, 'p-picklist-striped': stripedRows }\" cdkDropListGroup>\n <div class=\"p-picklist-buttons p-picklist-source-controls\" *ngIf=\"showSourceControls\">\n <button type=\"button\" [attr.aria-label]=\"upButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"sourceMoveDisabled()\" (click)=\"moveUp(sourcelist, source, selectedItemsSource, onSourceReorder, SOURCE_LIST)\">\n <AngleUpIcon *ngIf=\"!moveUpIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveUpIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"topButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"sourceMoveDisabled()\"\n (click)=\"moveTop(sourcelist, source, selectedItemsSource, onSourceReorder, SOURCE_LIST)\"\n >\n <AngleDoubleUpIcon *ngIf=\"!moveTopIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveTopIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"downButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"sourceMoveDisabled()\"\n (click)=\"moveDown(sourcelist, source, selectedItemsSource, onSourceReorder, SOURCE_LIST)\"\n >\n <AngleDownIcon *ngIf=\"!moveDownIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveDownIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"bottomButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"sourceMoveDisabled()\"\n (click)=\"moveBottom(sourcelist, source, selectedItemsSource, onSourceReorder, SOURCE_LIST)\"\n >\n <AngleDoubleDownIcon *ngIf=\"!moveBottomIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveBottomIconTemplate\"></ng-template>\n </button>\n </div>\n <div class=\"p-picklist-list-wrapper p-picklist-source-wrapper\">\n <div class=\"p-picklist-header\" *ngIf=\"sourceHeader || sourceHeaderTemplate\">\n <div class=\"p-picklist-title\" *ngIf=\"!sourceHeaderTemplate\">{{ sourceHeader }}</div>\n <ng-container *ngTemplateOutlet=\"sourceHeaderTemplate\"></ng-container>\n </div>\n <div class=\"p-picklist-filter-container\" *ngIf=\"filterBy && showSourceFilter !== false\">\n <ng-container *ngIf=\"sourceFilterTemplate; else builtInSourceElement\">\n <ng-container *ngTemplateOutlet=\"sourceFilterTemplate; context: { options: sourceFilterOptions }\"></ng-container>\n </ng-container>\n <ng-template #builtInSourceElement>\n <div class=\"p-picklist-filter\">\n <input\n #sourceFilter\n type=\"text\"\n role=\"textbox\"\n (keyup)=\"onFilter($event, SOURCE_LIST)\"\n class=\"p-picklist-filter-input p-inputtext p-component\"\n [disabled]=\"disabled\"\n [attr.placeholder]=\"sourceFilterPlaceholder\"\n [attr.aria-label]=\"ariaSourceFilterLabel\"\n />\n <SearchIcon *ngIf=\"!sourceFilterIconTemplate\" [styleClass]=\"'p-picklist-filter-icon'\"/>\n <span class=\"p-picklist-filter-icon\" *ngIf=\"sourceFilterIconTemplate\">\n <ng-template *ngTemplateOutlet=\"sourceFilterIconTemplate\"></ng-template>\n </span>\n </div>\n </ng-template>\n </div>\n\n <ul #sourcelist class=\"p-picklist-list p-picklist-source\" cdkDropList [cdkDropListData]=\"source\" (cdkDropListDropped)=\"onDrop($event, SOURCE_LIST)\" [ngStyle]=\"sourceStyle\" role=\"listbox\" aria-multiselectable=\"multiple\">\n <ng-template ngFor let-item [ngForOf]=\"source\" [ngForTrackBy]=\"sourceTrackBy || trackBy\" let-i=\"index\" let-l=\"last\">\n <li\n [ngClass]=\"{ 'p-picklist-item': true, 'p-highlight': isSelected(item, selectedItemsSource), 'p-disabled': disabled }\"\n pRipple\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"!dragdrop\"\n (click)=\"onItemClick($event, item, selectedItemsSource, onSourceSelect)\"\n (dblclick)=\"onSourceItemDblClick()\"\n (touchend)=\"onItemTouchEnd()\"\n (keydown)=\"onItemKeydown($event, item, selectedItemsSource, onSourceSelect)\"\n *ngIf=\"isItemVisible(item, SOURCE_LIST)\"\n tabindex=\"0\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(item, selectedItemsSource)\"\n >\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item, index: i }\"></ng-container>\n </li>\n </ng-template>\n <ng-container *ngIf=\"isEmpty(SOURCE_LIST) && (emptyMessageSourceTemplate || emptyFilterMessageSourceTemplate)\">\n <li class=\"p-picklist-empty-message\" *ngIf=\"!filterValueSource || !emptyFilterMessageSourceTemplate\">\n <ng-container *ngTemplateOutlet=\"emptyMessageSourceTemplate\"></ng-container>\n </li>\n <li class=\"p-picklist-empty-message\" *ngIf=\"filterValueSource\">\n <ng-container *ngTemplateOutlet=\"emptyFilterMessageSourceTemplate\"></ng-container>\n </li>\n </ng-container>\n </ul>\n </div>\n <div class=\"p-picklist-buttons p-picklist-transfer-buttons\">\n <button type=\"button\" [attr.aria-label]=\"rightButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"moveRightDisabled()\" (click)=\"moveRight()\">\n <ng-container *ngIf=\"!moveToTargetIconTemplate\">\n <AngleRightIcon *ngIf=\"!viewChanged\"/>\n <AngleDownIcon *ngIf=\"viewChanged\"/>\n </ng-container>\n <ng-template *ngTemplateOutlet=\"moveToTargetIconTemplate; context: { $implicit: viewChanged }\"></ng-template>\n </button>\n <button type=\"button\" [attr.aria-label]=\"allRightButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"moveAllRightDisabled()\" (click)=\"moveAllRight()\">\n <ng-container *ngIf=\"!moveAllToTargetIconTemplate\">\n <AngleDoubleRightIcon *ngIf=\"!viewChanged\"/>\n <AngleDoubleDownIcon *ngIf=\"viewChanged\"/>\n </ng-container>\n <ng-template *ngTemplateOutlet=\"moveAllToTargetIconTemplate; context: { $implicit: viewChanged }\"></ng-template>\n </button>\n <button type=\"button\" [attr.aria-label]=\"leftButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"moveLeftDisabled()\" (click)=\"moveLeft()\">\n <ng-container *ngIf=\"!moveToSourceIconTemplate\">\n <AngleLeftIcon *ngIf=\"!viewChanged\"/>\n <AngleUpIcon *ngIf=\"viewChanged\"/>\n </ng-container>\n <ng-template *ngTemplateOutlet=\"moveToSourceIconTemplate; context: { $implicit: viewChanged }\"></ng-template>\n </button>\n <button type=\"button\" [attr.aria-label]=\"allLeftButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"moveAllLeftDisabled()\" (click)=\"moveAllLeft()\">\n <ng-container *ngIf=\"!moveAllToSourceIconTemplate\">\n <AngleDoubleLeftIcon *ngIf=\"!viewChanged\"/>\n <AngleDoubleUpIcon *ngIf=\"viewChanged\"/>\n </ng-container>\n <ng-template *ngTemplateOutlet=\"moveAllToSourceIconTemplate; context: { $implicit: viewChanged }\"></ng-template>\n </button>\n </div>\n <div class=\"p-picklist-list-wrapper p-picklist-target-wrapper\">\n <div class=\"p-picklist-header\" *ngIf=\"targetHeader || targetHeaderTemplate\">\n <div class=\"p-picklist-title\" *ngIf=\"!targetHeaderTemplate\">{{ targetHeader }}</div>\n <ng-container *ngTemplateOutlet=\"targetHeaderTemplate\"></ng-container>\n </div>\n <div class=\"p-picklist-filter-container\" *ngIf=\"filterBy && showTargetFilter !== false\">\n <ng-container *ngIf=\"targetFilterTemplate; else builtInTargetElement\">\n <ng-container *ngTemplateOutlet=\"targetFilterTemplate; context: { options: targetFilterOptions }\"></ng-container>\n </ng-container>\n <ng-template #builtInTargetElement>\n <div class=\"p-picklist-filter\">\n <input\n #targetFilter\n type=\"text\"\n role=\"textbox\"\n (keyup)=\"onFilter($event, TARGET_LIST)\"\n class=\"p-picklist-filter-input p-inputtext p-component\"\n [disabled]=\"disabled\"\n [attr.placeholder]=\"targetFilterPlaceholder\"\n [attr.aria-label]=\"ariaTargetFilterLabel\"\n />\n <SearchIcon *ngIf=\"!targetFilterIconTemplate\" [styleClass]=\"'p-picklist-filter-icon'\"/>\n <span class=\"p-picklist-filter-icon\" *ngIf=\"targetFilterIconTemplate\">\n <ng-template *ngTemplateOutlet=\"targetFilterIconTemplate\"></ng-template>\n </span>\n </div>\n </ng-template>\n </div>\n <ul #targetlist class=\"p-picklist-list p-picklist-target\" cdkDropList [cdkDropListData]=\"target\" (cdkDropListDropped)=\"onDrop($event, TARGET_LIST)\" [ngStyle]=\"targetStyle\" role=\"listbox\" aria-multiselectable=\"multiple\">\n <ng-template ngFor let-item [ngForOf]=\"target\" [ngForTrackBy]=\"targetTrackBy || trackBy\" let-i=\"index\" let-l=\"last\">\n <li\n [ngClass]=\"{ 'p-picklist-item': true, 'p-highlight': isSelected(item, selectedItemsTarget), 'p-disabled': disabled }\"\n pRipple\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"!dragdrop\"\n (click)=\"onItemClick($event, item, selectedItemsTarget, onTargetSelect)\"\n (dblclick)=\"onTargetItemDblClick()\"\n (touchend)=\"onItemTouchEnd()\"\n (keydown)=\"onItemKeydown($event, item, selectedItemsTarget, onTargetSelect)\"\n *ngIf=\"isItemVisible(item, TARGET_LIST)\"\n tabindex=\"0\"\n role=\"option\"\n [attr.aria-selected]=\"isSelected(item, selectedItemsTarget)\"\n >\n <ng-container *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item, index: i }\"></ng-container>\n </li>\n </ng-template>\n <ng-container *ngIf=\"isEmpty(TARGET_LIST) && (emptyMessageTargetTemplate || emptyFilterMessageTargetTemplate)\">\n <li class=\"p-picklist-empty-message\" *ngIf=\"!filterValueTarget || !emptyFilterMessageTargetTemplate\">\n <ng-container *ngTemplateOutlet=\"emptyMessageTargetTemplate\"></ng-container>\n </li>\n <li class=\"p-picklist-empty-message\" *ngIf=\"filterValueTarget\">\n <ng-container *ngTemplateOutlet=\"emptyFilterMessageTargetTemplate\"></ng-container>\n </li>\n </ng-container>\n </ul>\n </div>\n <div class=\"p-picklist-buttons p-picklist-target-controls\" *ngIf=\"showTargetControls\">\n <button type=\"button\" [attr.aria-label]=\"upButtonAriaLabel\" pButton pRipple class=\"p-button-icon-only\" [disabled]=\"targetMoveDisabled()\" (click)=\"moveUp(targetlist, target, selectedItemsTarget, onTargetReorder, TARGET_LIST)\">\n <AngleUpIcon *ngIf=\"!moveUpIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveUpIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"topButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"targetMoveDisabled()\"\n (click)=\"moveTop(targetlist, target, selectedItemsTarget, onTargetReorder, TARGET_LIST)\"\n >\n <AngleDoubleUpIcon *ngIf=\"!moveTopIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveTopIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"downButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"targetMoveDisabled()\"\n (click)=\"moveDown(targetlist, target, selectedItemsTarget, onTargetReorder, TARGET_LIST)\"\n >\n <AngleDownIcon *ngIf=\"!moveDownIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveDownIconTemplate\"></ng-template>\n </button>\n <button\n type=\"button\"\n [attr.aria-label]=\"bottomButtonAriaLabel\"\n pButton\n pRipple\n class=\"p-button-icon-only\"\n [disabled]=\"targetMoveDisabled()\"\n (click)=\"moveBottom(targetlist, target, selectedItemsTarget, onTargetReorder, TARGET_LIST)\"\n >\n <AngleDoubleDownIcon *ngIf=\"!moveBottomIconTemplate\"/>\n <ng-template *ngTemplateOutlet=\"moveBottomIconTemplate\"></ng-template>\n </button>\n </div>\n </div>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./picklist.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class PickList implements AfterViewChecked, AfterContentInit {\n @Input() source: any[];\n\n @Input() target: any[];\n\n @Input() sourceHeader: string;\n\n @Input() rightButtonAriaLabel: string;\n\n @Input() leftButtonAriaLabel: string;\n\n @Input() allRightButtonAriaLabel: string;\n\n @Input() allLeftButtonAriaLabel: string;\n\n @Input() upButtonAriaLabel: string;\n\n @Input() downButtonAriaLabel: string;\n\n @Input() topButtonAriaLabel: string;\n\n @Input() bottomButtonAriaLabel: string;\n\n @Input() targetHeader: string;\n\n @Input() responsive: boolean;\n\n @Input() filterBy: string;\n\n @Input() filterLocale: string;\n\n @Input() trackBy: Function = (index: number, item: any) => item;\n\n @Input() sourceTrackBy: Function;\n\n @Input() targetTrackBy: Function;\n\n @Input() showSourceFilter: boolean = true;\n\n @Input() showTargetFilter: boolean = true;\n\n @Input() metaKeySelection: boolean = true;\n\n @Input() dragdrop: boolean = false;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() sourceStyle: any;\n\n @Input() targetStyle: any;\n\n @Input() showSourceControls: boolean = true;\n\n @Input() showTargetControls: boolean = true;\n\n @Input() sourceFilterPlaceholder: string;\n\n @Input() targetFilterPlaceholder: string;\n\n @Input() disabled: boolean = false;\n\n @Input() ariaSourceFilterLabel: string;\n\n @Input() ariaTargetFilterLabel: string;\n\n @Input() filterMatchMode: string = 'contains';\n\n @Input() get breakpoint(): string {\n return this._breakpoint;\n }\n\n set breakpoint(value: string) {\n if (value !== this._breakpoint) {\n this._breakpoint = value;\n if (isPlatformBrowser(this.platformId)) {\n this.destroyMedia();\n this.initMedia();\n }\n }\n }\n\n @Input() stripedRows: boolean;\n\n @Input() keepSelection: boolean = false;\n\n @Output() onMoveToSource: EventEmitter<any> = new EventEmitter();\n\n @Output() onMoveAllToSource: EventEmitter<any> = new EventEmitter();\n\n @Output() onMoveAllToTarget: EventEmitter<any> = new EventEmitter();\n\n @Output() onMoveToTarget: EventEmitter<any> = new EventEmitter();\n\n @Output() onSourceReorder: EventEmitter<any> = new EventEmitter();\n\n @Output() onTargetReorder: EventEmitter<any> = new EventEmitter();\n\n @Output() onSourceSelect: EventEmitter<any> = new EventEmitter();\n\n @Output() onTargetSelect: EventEmitter<any> = new EventEmitter();\n\n @Output() onSourceFilter: EventEmitter<any> = new EventEmitter();\n\n @Output() onTargetFilter: EventEmitter<any> = new EventEmitter();\n\n @ViewChild('sourcelist') listViewSourceChild: ElementRef;\n\n @ViewChild('targetlist') listViewTargetChild: ElementRef;\n\n @ViewChild('sourceFilter') sourceFilterViewChild: ElementRef;\n\n @ViewChild('targetFilter') targetFilterViewChild: ElementRef;\n\n @ContentChildren(PrimeTemplate) templates: QueryList<any>;\n\n _breakpoint: string = '960px';\n\n public itemTemplate: TemplateRef<any>;\n\n moveTopIconTemplate: TemplateRef<any>;\n\n moveUpIconTemplate: TemplateRef<any>;\n\n moveDownIconTemplate: TemplateRef<any>;\n\n moveBottomIconTemplate: TemplateRef<any>;\n\n moveToTargetIconTemplate: TemplateRef<any>;\n\n moveAllToTargetIconTemplate: TemplateRef<any>;\n\n moveToSourceIconTemplate: TemplateRef<any>;\n\n moveAllToSourceIconTemplate: TemplateRef<any>;\n\n targetFilterIconTemplate: TemplateRef<any>;\n\n sourceFilterIconTemplate: TemplateRef<any>;\n\n public visibleOptionsSource: any[];\n\n public visibleOptionsTarget: any[];\n\n selectedItemsSource: any[] = [];\n\n selectedItemsTarget: any[] = [];\n\n reorderedListElement: any;\n\n movedUp: boolean;\n\n movedDown: boolean;\n\n itemTouched: boolean;\n\n styleElement: any;\n\n id: string = UniqueComponentId();\n\n filterValueSource: string;\n\n filterValueTarget: string;\n\n fromListType: number;\n\n emptyMessageSourceTemplate: TemplateRef<any>;\n\n emptyFilterMessageSourceTemplate: TemplateRef<any>;\n\n emptyMessageTargetTemplate: TemplateRef<any>;\n\n emptyFilterMessageTargetTemplate: TemplateRef<any>;\n\n sourceHeaderTemplate: TemplateRef<any>;\n\n targetHeaderTemplate: TemplateRef<any>;\n\n sourceFilterTemplate: TemplateRef<any>;\n\n targetFilterTemplate: TemplateRef<any>;\n\n sourceFilterOptions: PickListFilterOptions;\n\n targetFilterOptions: PickListFilterOptions;\n\n readonly SOURCE_LIST = -1;\n\n readonly TARGET_LIST = 1;\n\n window: Window;\n\n media: MediaQueryList | null;\n\n viewChanged: boolean;\n\n mediaChangeListener: VoidFunction | null;\n\n constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private renderer: Renderer2, public el: ElementRef, public cd: ChangeDetectorRef, public filterService: FilterService) {\n this.window = this.document.defaultView as Window;\n }\n\n ngOnInit() {\n if (this.responsive) {\n this.createStyle();\n this.initMedia();\n }\n\n if (this.filterBy) {\n this.sourceFilterOptions = {\n filter: (value) => this.filterSource(value),\n reset: () => this.resetSourceFilter()\n };\n\n this.targetFilterOptions = {\n filter: (value) => this.filterTarget(value),\n reset: () => this.resetTargetFilter()\n };\n }\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch (item.getType()) {\n case 'item':\n this.itemTemplate = item.template;\n break;\n\n case 'sourceHeader':\n this.sourceHeaderTemplate = item.template;\n break;\n\n case 'targetHeader':\n this.targetHeaderTemplate = item.template;\n break;\n\n case 'sourceFilter':\n this.sourceFilterTemplate = item.template;\n break;\n\n case 'targetFilter':\n this.targetFilterTemplate = item.template;\n break;\n\n case 'emptymessagesource':\n this.emptyMessageSourceTemplate = item.template;\n break;\n\n case 'emptyfiltermessagesource':\n this.emptyFilterMessageSourceTemplate = item.template;\n break;\n\n case 'emptymessagetarget':\n this.emptyMessageTargetTemplate = item.template;\n break;\n\n case 'emptyfiltermessagetarget':\n this.emptyFilterMessageTargetTemplate = item.template;\n break;\n\n case 'moveupicon':\n this.moveUpIconTemplate = item.template;\n break;\n\n case 'movetopicon':\n this.moveTopIconTemplate = item.template;\n break;\n\n case 'movedownicon':\n this.moveDownIconTemplate = item.template;\n break;\n\n case 'movebottomicon':\n this.moveBottomIconTemplate = item.template;\n break;\n\n case 'movetotargeticon':\n this.moveToTargetIconTemplate = item.template;\n break;\n\n case 'movealltotargeticon':\n this.moveAllToTargetIconTemplate = item.template;\n break;\n\n case 'movetosourceicon':\n this.moveToSourceIconTemplate = item.template;\n break;\n\n case 'movealltosourceicon':\n this.moveAllToSourceIconTemplate = item.template;\n break;\n\n case 'targetfiltericon':\n this.targetFilterIconTemplate = item.template;\n break;\n\n case 'sourcefiltericon':\n this.sourceFilterIconTemplate = item.template;\n break;\n\n default:\n this.itemTemplate = item.template;\n break;\n }\n });\n }\n\n ngAfterViewChecked() {\n if (this.movedUp || this.movedDown) {\n let listItems = DomHandler.find(this.reorderedListElement, 'li.p-highlight');\n let listItem;\n\n if (this.movedUp) listItem = listItems[0];\n else listItem = listItems[listItems.length - 1];\n\n DomHandler.scrollInView(this.reorderedListElement, listItem);\n this.movedUp = false;\n this.movedDown = false;\n this.reorderedListElement = null;\n }\n }\n\n onItemClick(event, item: any, selectedItems: any[], callback: EventEmitter<any>) {\n if (this.disabled) {\n return;\n }\n\n let index = this.findIndexInSelection(item, selectedItems);\n let selected = index != -1;\n let metaSelection = this.itemTouched ? false : this.metaKeySelection;\n\n if (metaSelection) {\n let metaKey = event.metaKey || event.ctrlKey || event.shiftKey;\n\n if (selected && metaKey) {\n selectedItems.splice(index, 1);\n } else {\n if (!metaKey) {\n selectedItems.length = 0;\n }\n selectedItems.push(item);\n }\n } else {\n if (selected) selectedItems.splice(index, 1);\n else selectedItems.push(item);\n }\n\n callback.emit({ originalEvent: event, items: selectedItems });\n\n this.itemTouched = false;\n }\n\n onSourceItemDblClick() {\n if (this.disabled) {\n return;\n }\n\n this.moveRight();\n }\n\n onTargetItemDblClick() {\n if (this.disabled) {\n return;\n }\n\n this.moveLeft();\n }\n\n onFilter(event: KeyboardEvent, listType: number) {\n let query = (<HTMLInputElement>event.target).value;\n if (listType === this.SOURCE_LIST) this.filterSource(query);\n else if (listType === this.TARGET_LIST) this.filterTarget(query);\n }\n\n filterSource(value: any = '') {\n this.filterValueSource = value.trim().toLocaleLowerCase(this.filterLocale);\n this.filter(this.source, this.SOURCE_LIST);\n }\n\n filterTarget(value: any = '') {\n this.filterValueTarget = value.trim().toLocaleLowerCase(this.filterLocale);\n this.filter(this.target, this.TARGET_LIST);\n }\n\n filter(data: any[], listType: number) {\n let searchFields = this.filterBy.split(',');\n\n if (listType === this.SOURCE_LIST) {\n this.visibleOptionsSource = this.filterService.filter(data, searchFields, this.filterValueSource, this.filterMatchMode, this.filterLocale);\n this.onSourceFilter.emit({ query: this.filterValueSource, value: this.visibleOptionsSource });\n } else if (listType === this.TARGET_LIST) {\n this.visibleOptionsTarget = this.filterService.filter(data, searchFields, this.filterValueTarget, this.filterMatchMode, this.filterLocale);\n this.onTargetFilter.emit({ query: this.filterValueTarget, value: this.visibleOptionsTarget });\n }\n }\n\n isItemVisible(item: any, listType: number): boolean {\n if (listType == this.SOURCE_LIST) return this.isVisibleInList(this.visibleOptionsSource, item, this.filterValueSource);\n else return this.isVisibleInList(this.visibleOptionsTarget, item, this.filterValueTarget);\n }\n\n isEmpty(listType: number) {\n if (listType == this.SOURCE_LIST) return this.filterValueSource ? !this.visibleOptionsSource || this.visibleOptionsSource.length === 0 : !this.source || this.source.length === 0;\n else return this.filterValueTarget ? !this.visibleOptionsTarget || this.visibleOptionsTarget.length === 0 : !this.target || this.target.length === 0;\n }\n\n isVisibleInList(data: any[], item: any, filterValue: string): boolean {\n if (filterValue && filterValue.trim().length) {\n for (let i = 0; i < data.length; i++) {\n if (item == data[i]) {\n return true;\n }\n }\n } else {\n return true;\n }\n }\n\n onItemTouchEnd() {\n if (this.disabled) {\n return;\n }\n\n this.itemTouched = true;\n }\n\n private sortByIndexInList(items: any[], list: any) {\n return items.sort((item1, item2) => ObjectUtils.findIndexInList(item1, list) - ObjectUtils.findIndexInList(item2, list));\n }\n\n moveUp(listElement, list, selectedItems, callback, listType) {\n if (selectedItems && selectedItems.length) {\n selectedItems = this.sortByIndexInList(selectedItems, list);\n for (let i = 0; i < selectedItems.length; i++) {\n let selectedItem = selectedItems[i];\n let selectedItemIndex: number = ObjectUtils.findIndexInList(selectedItem, list);\n\n if (selectedItemIndex != 0) {\n let movedItem = list[selectedItemIndex];\n let temp = list[selectedItemIndex - 1];\n list[selectedItemIndex - 1] = movedItem;\n list[selectedItemIndex] = temp;\n } else {\n break;\n }\n }\n\n if (this.dragdrop && ((this.filterValueSource && listType === this.SOURCE_LIST) || (this.filterValueTarget && listType === this.TARGET_LIST))) this.filter(list, listType);\n\n this.movedUp = true;\n this.reorderedListElement = listElement;\n callback.emit({ items: selectedItems });\n }\n }\n\n moveTop(listElement, list, selectedItems, callback, listType) {\n if (selectedItems && selectedItems.length) {\n selectedItems = this.sortByIndexInList(selectedItems, list);\n for (let i = 0; i < selectedItems.length; i++) {\n let selectedItem = selectedItems[i];\n let selectedItemIndex: number = ObjectUtils.findIndexInList(selectedItem, list);\n\n if (selectedItemIndex != 0) {\n let movedItem = list.splice(selectedItemIndex, 1)[0];\n list.unshift(movedItem);\n } else {\n break;\n }\n }\n\n if (this.dragdrop && ((this.filterValueSource && listType === this.SOURCE_LIST) || (this.filterValueTarget && listType === this.TARGET_LIST))) this.filter(list, listType);\n\n listElement.scrollTop = 0;\n callback.emit({ items: selectedItems });\n }\n }\n\n moveDown(listElement, list, selectedItems, callback, listType) {\n if (selectedItems && selectedItems.length) {\n selectedItems = this.sortByIndexInList(selectedItems, list);\n for (let i = selectedItems.length - 1; i >= 0; i--) {\n let selectedItem = selectedItems[i];\n let selectedItemIndex: number = ObjectUtils.findIndexInList(selectedItem, list);\n\n if (selectedItemIndex != list.length - 1) {\n let movedItem = list[selectedItemIndex];\n let temp = list[selectedItemIndex + 1];\n list[selectedItemIndex + 1] = movedItem;\n list[selectedItemIndex] = temp;\n } else {\n break;\n }\n }\n\n if (this.dragdrop && ((this.filterValueSource && listType === this.SOURCE_LIST) || (this.filterValueTarget && listType === this.TARGET_LIST))) this.filter(list, listType);\n\n this.movedDown = true;\n this.reorderedListElement = listElement;\n callback.emit({ items: selectedItems });\n }\n }\n\n moveBottom(listElement, list, selectedItems, callback, listType) {\n if (selectedItems && selectedItems.length) {\n selectedItems = this.sortByIndexInList(selectedItems, list);\n for (let i = selectedItems.length - 1; i >= 0; i--) {\n let selectedItem = selectedItems[i];\n let selectedItemIndex: number = ObjectUtils.findIndexInList(selectedItem, list);\n\n if (selectedItemIndex != list.length - 1) {\n let movedItem = list.splice(selectedItemIndex, 1)[0];\n list.push(movedItem);\n } else {\n break;\n }\n }\n\n if (this.dragdrop && ((this.filterValueSource && listType === this.SOURCE_LIST) || (this.filterValueTarget && listType === this.TARGET_LIST))) this.filter(list, listType);\n\n listElement.scrollTop = listElement.scrollHeight;\n callback.emit({ items: selectedItems });\n }\n }\n\n moveRight() {\n if (this.selectedItemsSource && this.selectedItemsSource.length) {\n for (let i = 0; i < this.selectedItemsSource.length; i++) {\n let selectedItem = this.selectedItemsSource[i];\n if (ObjectUtils.findIndexInList(selectedItem, this.target) == -1) {\n this.target.push(this.source.splice(ObjectUtils.findIndexInList(selectedItem, this.source), 1)[0]);\n\n if (this.visibleOptionsSource) this.visibleOptionsSource.splice(ObjectUtils.findIndexInList(selectedItem, this.visibleOptionsSource), 1);\n }\n }\n\n this.onMoveToTarget.emit({\n items: this.selectedItemsSource\n });\n\n if (this.keepSelection) {\n this.selectedItemsTarget = [...this.selectedItemsTarget, ...this.selectedItemsSource];\n }\n\n this.selectedItemsSource = [];\n\n if (this.filterValueTarget) {\n this.filter(this.target, this.TARGET_LIST);\n }\n }\n }\n\n moveAllRight() {\n if (this.source) {\n let movedItems = [];\n\n for (let i = 0; i < this.source.length; i++) {\n if (this.isItemVisible(this.source[i], this.SOURCE_LIST)) {\n let removedItem = this.source.splice(i, 1)[0];\n this.target.push(removedItem);\n movedItems.push(removedItem);\n i--;\n }\n }\n\n this.onMoveAllToTarget.emit({\n items: movedItems\n });\n\n if (this.keepSelection) {\n this.selectedItemsTarget = [...this.selectedItemsTarget, ...this.selectedItemsSource];\n }\n\n this.selectedItemsSource = [];\n\n if (this.filterValueTarget) {\n this.filter(this.target, this.TARGET_LIST);\n }\n\n this.visibleOptionsSource = [];\n }\n }\n\n moveLeft() {\n if (this.selectedItemsTarget && this.selectedItemsTarget.length) {\n for (let i = 0; i < this.selectedItemsTarget.length; i++) {\n let selectedItem = this.selectedItemsTarget[i];\n if (ObjectUtils.findIndexInList(selectedItem, this.source) == -1) {\n this.source.push(this.target.splice(ObjectUtils.findIndexInList(selectedItem, this.target), 1)[0]);\n\n if (this.visibleOptionsTarget) this.visibleOptionsTarget.splice(ObjectUtils.findIndexInList(selectedItem, this.visibleOptionsTarget), 1)[0];\n }\n }\n\n this.onMoveToSource.emit({\n items: this.selectedItemsTarget\n });\n\n if (this.keepSelection) {\n this.selectedItemsSource = [...this.selectedItemsSource, ...this.selectedItemsTarget];\n }\n\n this.selectedItemsTarget = [];\n\n if (this.filterValueSource) {\n this.filter(this.source, this.SOURCE_LIST);\n }\n }\n }\n\n moveAllLeft() {\n if (this.target) {\n let movedItems = [];\n\n for (let i = 0; i < this.target.length; i++) {\n if (this.isItemVisible(this.target[i], this.TARGET_LIST)) {\n let removedItem = this.target.splice(i, 1)[0];\n this.source.push(removedItem);\n movedItems.push(removedItem);\n i--;\n }\n }\n\n this.onMoveAllToSource.emit({\n items: movedItems\n });\n\n if (this.keepSelection) {\n this.selectedItemsSource = [...this.selectedItemsSource, ...this.selectedItemsTarget];\n }\n\n this.selectedItemsTarget = [];\n\n if (this.filterValueSource) {\n this.filter(this.source, this.SOURCE_LIST);\n }\n\n this.visibleOptionsTarget = [];\n }\n }\n\n isSelected(item: any, selectedItems: any[]) {\n return this.findIndexInSelection(item, selectedItems) != -1;\n }\n\n findIndexInSelection(item: any, selectedItems: any[]): number {\n return ObjectUtils.findIndexInList(item, selectedItems);\n }\n\n onDrop(event: CdkDragDrop<string[]>, listType: number) {\n let isTransfer = event.previousContainer !== event.container;\n let dropIndexes = this.getDropIndexes(event.previousIndex, event.currentIndex, listType, isTransfer, event.item.data);\n\n if (listType === this.SOURCE_LIST) {\n if (isTransfer) {\n transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);\n let selectedItemIndex = ObjectUtils.findIndexInList(event.item.data, this.selectedItemsTarget);\n\n if (selectedItemIndex != -1) {\n this.selectedItemsTarget.splice(selectedItemIndex, 1);\n\n if (this.keepSelection) {\n this.selectedItemsTarget.push(event.item.data);\n }\n }\n\n if (this.visibleOptionsTarget) this.visibleOptionsTarget.splice(event.previousIndex, 1);\n\n this.onMoveToSource.emit({ items: [event.item.data] });\n } else {\n moveItemInArray(event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);\n this.onSourceReorder.emit({ items: [event.item.data] });\n }\n\n if (this.filterValueSource) {\n this.filter(this.source, this.SOURCE_LIST);\n }\n } else {\n if (isTransfer) {\n transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);\n\n let selectedItemIndex = ObjectUtils.findIndexInList(event.item.data, this.selectedItemsSource);\n\n if (selectedItemIndex != -1) {\n this.selectedItemsSource.splice(selectedItemIndex, 1);\n\n if (this.keepSelection) {\n this.selectedItemsTarget.push(event.item.data);\n }\n }\n\n if (this.visibleOptionsSource) this.visibleOptionsSource.splice(event.previousIndex, 1);\n\n this.onMoveToTarget.emit({ items: [event.item.data] });\n } else {\n moveItemInArray(event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);\n this.onTargetReorder.emit({ items: [event.item.data] });\n }\n\n if (this.filterValueTarget) {\n this.filter(this.target, this.TARGET_LIST);\n }\n }\n }\n\n getDropIndexes(fromIndex, toIndex, droppedList, isTransfer, data) {\n let previousIndex, currentIndex;\n\n if (droppedList === this.SOURCE_LIST) {\n previousIndex = isTransfer ? (this.filterValueTarget ? ObjectUtils.findIndexInList(data, this.target) : fromIndex) : this.filterValueSource ? ObjectUtils.findIndexInList(data, this.source) : fromIndex;\n currentIndex = this.filterValueSource ? this.findFilteredCurrentIndex(this.visibleOptionsSource, toIndex, this.source) : toIndex;\n } else {\n previousIndex = isTransfer ? (this.filterValueSource ? ObjectUtils.findIndexInList(data, this.source) : fromIndex) : this.filterValueTarget ? ObjectUtils.findIndexInList(data, this.target) : fromIndex;\n currentIndex = this.filterValueTarget ? this.findFilteredCurrentIndex(this.visibleOptionsTarget, toIndex, this.target) : toIndex;\n }\n\n return { previousIndex, currentIndex };\n }\n\n findFilteredCurrentIndex(visibleOptions, index, options) {\n if (visibleOptions.length === index) {\n let toIndex = ObjectUtils.findIndexInList(visibleOptions[index - 1], options);\n\n return toIndex + 1;\n } else {\n return ObjectUtils.findIndexInList(visibleOptions[index], options);\n }\n }\n\n resetSourceFilter() {\n this.visibleOptionsSource = null;\n this.filterValueSource = null;\n this.sourceFilterViewChild && ((<HTMLInputElement>this.sourceFilterViewChild.nativeElement).value = '');\n }\n\n resetTargetFilter() {\n this.visibleOptionsTarget = null;\n this.filterValueTarget = null;\n this.targetFilterViewChild && ((<HTMLInputElement>this.targetFilterViewChild.nativeElement).value = '');\n }\n\n resetFilter() {\n this.resetSourceFilter();\n this.resetTargetFilter();\n }\n\n onItemKeydown(event: KeyboardEvent, item: any, selectedItems: any[], callback: EventEmitter<any>) {\n let listItem = <HTMLLIElement>event.currentTarget;\n\n switch (event.which) {\n //down\n case 40:\n var nextItem = this.findNextItem(listItem);\n if (nextItem) {\n nextItem.focus();\n }\n\n event.preventDefault();\n break;\n\n //up\n case 38:\n var prevItem = this.findPrevItem(listItem);\n if (prevItem) {\n prevItem.focus();\n }\n\n event.preventDefault();\n break;\n\n //enter\n case 13:\n this.onItemClick(event, item, selectedItems, callback);\n event.preventDefault();\n break;\n }\n }\n\n findNextItem(item) {\n let nextItem = item.nextElementSibling;\n\n if (nextItem) return !DomHandler.hasClass(nextItem, 'p-picklist-item') || DomHandler.isHidden(nextItem) ? this.findNextItem(nextItem) : nextItem;\n else return null;\n }\n\n findPrevItem(item) {\n let prevItem = item.previousElementSibling;\n\n if (prevItem) return !DomHandler.hasClass(prevItem, 'p-picklist-item') || DomHandler.isHidden(prevItem) ? this.findPrevItem(prevItem) : prevItem;\n else return null;\n }\n\n initMedia() {\n if (isPlatformBrowser(this.platformId)) {\n this.media = this.window.matchMedia(`(max-width: ${this.breakpoint})`);\n this.viewChanged = this.media.matches;\n this.bindMediaChangeListener();\n }\n }\n\n destroyMedia() {\n this.unbindMediaChangeListener();\n }\n\n bindMediaChangeListener() {\n if (this.media && !this.mediaChangeListener) {\n this.mediaChangeListener = this.renderer.listen(this.media, 'change', (event) => {\n this.viewChanged = event.matches;\n this.cd.markForCheck();\n });\n }\n }\n\n unbindMediaChangeListener() {\n if (this.mediaChangeListener) {\n this.mediaChangeListener();\n this.mediaChangeListener = null;\n }\n }\n\n createStyle() {\n if (isPlatformBrowser(this.platformId)) {\n if (!this.styleElement) {\n this.renderer.setAttribute(this.el.nativeElement.children[0], this.id, '');\n this.styleElement = this.renderer.createElement('style');\n this.renderer.setAttribute(this.styleElement, 'type', 'text/css');\n this.renderer.appendChild(this.document.head, this.styleElement);\n\n let innerHTML = `\n @media screen and (max-width: ${this.breakpoint}) {\n .p-picklist[${this.id}] {\n flex-direction: column;\n }\n \n .p-picklist[${this.id}] .p-picklist-buttons {\n padding: var(--content-padding);\n flex-direction: row;\n }\n \n .p-picklist[${this.id}] .p-picklist-buttons .p-button {\n margin-right: var(--inline-spacing);\n margin-bottom: 0;\n }\n \n .p-picklist[${this.id}] .p-picklist-buttons .p-button:last-child {\n margin-right: 0;\n }\n }`;\n\n this.renderer.setProperty(this.styleElement, 'innerHTML', innerHTML);\n }\n }\n }\n\n sourceMoveDisabled() {\n if (this.disabled || !this.selectedItemsSource.length) {\n return true;\n }\n }\n\n targetMoveDisabled() {\n if (this.disabled || !this.selectedItemsTarget.length) {\n return true;\n }\n }\n\n moveRightDisabled() {\n return this.disabled || ObjectUtils.isEmpty(this.selectedItemsSource);\n }\n\n moveLeftDisabled() {\n return this.disabled || ObjectUtils.isEmpty(this.selectedItemsTarget);\n }\n\n moveAllRightDisabled() {\n return this.disabled || ObjectUtils.isEmpty(this.source);\n }\n\n moveAllLeftDisabled() {\n return this.disabled || ObjectUtils.isEmpty(this.target);\n }\n\n destroyStyle() {\n if (this.styleElement) {\n this.renderer.removeChild(this.document.head, this.styleElement);\n this.styleElement = null;\n ``;\n }\n }\n\n ngOnDestroy() {\n this.destroyStyle();\n this.destroyMedia();\n }\n}\n\n@NgModule({\n imports: [CommonModule, ButtonModule, SharedModule, RippleModule, DragDropModule, AngleDoubleDownIcon, AngleDoubleLeftIcon, AngleDoubleRightIcon, AngleDoubleUpIcon, AngleDownIcon, AngleLeftIcon, AngleRightIcon, AngleUpIcon, SearchIcon, HomeIcon],\n exports: [PickList, SharedModule, DragDropModule],\n declarations: [PickList]\n})\nexport class PickListModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MA+Ra,QAAQ,CAAA;IAuMjB,WAAsC,CAAA,QAAkB,EAA+B,UAAe,EAAU,QAAmB,EAAS,EAAc,EAAS,EAAqB,EAAS,aAA4B,EAAA;AAAvL,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;AAA+B,QAAA,IAAU,CAAA,UAAA,GAAV,UAAU,CAAK;AAAU,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAW;AAAS,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAY;AAAS,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAmB;AAAS,QAAA,IAAa,CAAA,aAAA,GAAb,aAAa,CAAe;QAxKpN,IAAO,CAAA,OAAA,GAAa,CAAC,KAAa,EAAE,IAAS,KAAK,IAAI,CAAC;AAMvD,QAAA,IAAgB,CAAA,gBAAA,GAAY,IAAI,CAAC;AAEjC,QAAA,IAAgB,CAAA,gBAAA,GAAY,IAAI,CAAC;AAEjC,QAAA,IAAgB,CAAA,gBAAA,GAAY,IAAI,CAAC;AAEjC,QAAA,IAAQ,CAAA,QAAA,GAAY,KAAK,CAAC;AAU1B,QAAA,IAAkB,CAAA,kBAAA,GAAY,IAAI,CAAC;AAEnC,QAAA,IAAkB,CAAA,kBAAA,GAAY,IAAI,C