!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("angular-dual-listbox",["exports","@angular/core","@angular/common","@angular/forms"],e):e((t=t||self)["angular-dual-listbox"]={},t.ng.core,t.ng.common,t.ng.forms)}(this,function(t,e,i,r){"use strict";var n=function(){function t(t){this._name=t,this.last=null,this.picker="",this.dragStart=!1,this.dragOver=!1,this.pick=[],this.list=[],this.sift=[]}return Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t}(),o=0,a=function(){function t(i){this.differs=i,this.id="dual-list-"+o++,this.key="_id",this.display="_name",this.height="100px",this.filter=!1,this.format=t.DEFAULT_FORMAT,this.sort=!1,this.disabled=!1,this.destinationChange=new e.EventEmitter,this.sorter=function(t,e){return t._namee._name?1:0},this.available=new n(t.AVAILABLE_LIST_NAME),this.confirmed=new n(t.CONFIRMED_LIST_NAME)}return t.prototype.ngOnChanges=function(e){e.filter&&!1===e.filter.currentValue&&(this.clearFilter(this.available),this.clearFilter(this.confirmed)),e.sort&&(!0===e.sort.currentValue&&this.compare===undefined?this.compare=this.sorter:!1===e.sort.currentValue&&(this.compare=undefined)),e.format&&(this.format=e.format.currentValue,"undefined"==typeof this.format.direction&&(this.format.direction=t.LTR),"undefined"==typeof this.format.add&&(this.format.add=t.DEFAULT_FORMAT.add),"undefined"==typeof this.format.remove&&(this.format.remove=t.DEFAULT_FORMAT.remove),"undefined"==typeof this.format.all&&(this.format.all=t.DEFAULT_FORMAT.all),"undefined"==typeof this.format.none&&(this.format.none=t.DEFAULT_FORMAT.none),"undefined"==typeof this.format.draggable&&(this.format.draggable=t.DEFAULT_FORMAT.draggable)),e.source&&(this.available=new n(t.AVAILABLE_LIST_NAME),this.updatedSource(),this.updatedDestination()),e.destination&&(this.confirmed=new n(t.CONFIRMED_LIST_NAME),this.updatedDestination(),this.updatedSource())},t.prototype.ngDoCheck=function(){this.source&&this.buildAvailable(this.source)&&this.onFilter(this.available),this.destination&&this.buildConfirmed(this.destination)&&this.onFilter(this.confirmed)},t.prototype.buildAvailable=function(t){var e=this,i=this.sourceDiffer.diff(t);return!!i&&(i.forEachRemovedItem(function(t){var i=e.findItemIndex(e.available.list,t.item,e.key);-1!==i&&e.available.list.splice(i,1)}),i.forEachAddedItem(function(t){-1===e.findItemIndex(e.available.list,t.item,e.key)&&e.available.list.push({_id:e.makeId(t.item),_name:e.makeName(t.item)})}),this.compare!==undefined&&this.available.list.sort(this.compare),this.available.sift=this.available.list,!0)},t.prototype.buildConfirmed=function(t){var e=this,i=!1,r=this.destinationDiffer.diff(t);return!!r&&(r.forEachRemovedItem(function(t){var r=e.findItemIndex(e.confirmed.list,t.item,e.key);-1!==r&&(e.isItemSelected(e.confirmed.pick,e.confirmed.list[r])||e.selectItem(e.confirmed.pick,e.confirmed.list[r]),e.moveItem(e.confirmed,e.available,e.confirmed.list[r],!1),i=!0)}),r.forEachAddedItem(function(t){var r=e.findItemIndex(e.available.list,t.item,e.key);-1!==r&&(e.isItemSelected(e.available.pick,e.available.list[r])||e.selectItem(e.available.pick,e.available.list[r]),e.moveItem(e.available,e.confirmed,e.available.list[r],!1),i=!0)}),this.compare!==undefined&&this.confirmed.list.sort(this.compare),this.confirmed.sift=this.confirmed.list,i&&this.trueUp(),!0)},t.prototype.updatedSource=function(){this.available.list.length=0,this.available.pick.length=0,this.source!==undefined&&(this.sourceDiffer=this.differs.find(this.source).create(null))},t.prototype.updatedDestination=function(){this.destination!==undefined&&(this.destinationDiffer=this.differs.find(this.destination).create(null))},t.prototype.direction=function(){return this.format.direction===t.LTR},t.prototype.dragEnd=function(t){return void 0===t&&(t=null),t?t.dragStart=!1:(this.available.dragStart=!1,this.confirmed.dragStart=!1),!1},t.prototype.drag=function(t,e,i){this.isItemSelected(i.pick,e)||this.selectItem(i.pick,e),i.dragStart=!0,t.dataTransfer.setData(this.id,e._id)},t.prototype.allowDrop=function(t,e){return t.dataTransfer.types.length&&t.dataTransfer.types[0]===this.id&&(t.preventDefault(),e.dragStart||(e.dragOver=!0)),!1},t.prototype.dragLeave=function(){this.available.dragOver=!1,this.confirmed.dragOver=!1},t.prototype.drop=function(t,e){t.dataTransfer.types.length&&t.dataTransfer.types[0]===this.id&&(t.preventDefault(),this.dragLeave(),this.dragEnd(),e===this.available?this.moveItem(this.available,this.confirmed):this.moveItem(this.confirmed,this.available))},t.prototype.trueUp=function(){for(var t=this,e=!1,i=this.destination.length;(i-=1)>=0;){0===this.confirmed.list.filter(function(e){return"object"==typeof t.destination[i]?e._id===t.destination[i][t.key]:e._id===t.destination[i]}).length&&(this.destination.splice(i,1),e=!0)}for(var r=function(i,r){var o=n.destination.filter(function(e){return"object"==typeof e?e[t.key]===t.confirmed.list[i]._id:e===t.confirmed.list[i]._id});0===o.length&&(o=n.source.filter(function(e){return"object"==typeof e?e[t.key]===t.confirmed.list[i]._id:e===t.confirmed.list[i]._id})).length>0&&(n.destination.push(o[0]),e=!0)},n=this,o=0,a=this.confirmed.list.length;o0},t.prototype.shiftClick=function(t,e,i,r){if(t.shiftKey&&i.last&&!Object.is(r,i.last)){var n=i.sift.indexOf(i.last);if(e>n)for(var o=n+1;o0)for(var r=0,n=i.length;r0},t.prototype.unpick=function(t){for(var e=t.pick.length-1;e>=0;e-=1)-1===t.sift.indexOf(t.pick[e])&&t.pick.splice(e,1)},t.prototype.clearFilter=function(t){t&&(t.picker="",this.onFilter(t))},t.prototype.onFilter=function(t){var e=this;if(t.picker.length>0)try{var i=t.list.filter(function(i){return"[object Object]"===Object.prototype.toString.call(i)?i._name!==undefined?-1!==i._name.toLocaleLowerCase(e.format.locale).indexOf(t.picker.toLocaleLowerCase(e.format.locale)):-1!==JSON.stringify(i).toLocaleLowerCase(e.format.locale).indexOf(t.picker.toLocaleLowerCase(e.format.locale)):-1!==i.toLocaleLowerCase(e.format.locale).indexOf(t.picker.toLocaleLowerCase(e.format.locale))});t.sift=i,this.unpick(t)}catch(r){r instanceof RangeError&&(this.format.locale=undefined),t.sift=t.list}else t.sift=t.list},t.prototype.makeId=function(t){return"object"==typeof t?t[this.key]:t},t.prototype.makeName=function(t,e){void 0===e&&(e="_");var i=this.display;function r(t){switch(Object.prototype.toString.call(t)){case"[object Number]":case"[object String]":return t;default:return t!==undefined?t[i]:"undefined"}}var n="";if(this.display!==undefined)switch(Object.prototype.toString.call(this.display)){case"[object Function]":n=this.display(t);break;case"[object Array]":for(var o=0,a=this.display.length;o0&&(n+=e),-1===this.display[o].indexOf("."))n+=t[this.display[o]];else{var l=this.display[o].split("."),s=t[l[0]];if(s)if(-1!==l[1].indexOf("substring")){var d=l[1].substring(l[1].indexOf("(")+1,l[1].indexOf(")")).split(",");switch(d.length){case 1:n+=s.substring(parseInt(d[0],10));break;case 2:n+=s.substring(parseInt(d[0],10),parseInt(d[1],10));break;default:n+=s}}else n+=s}break;default:n=r(t)}else n=r(t);return n},t.AVAILABLE_LIST_NAME="available",t.CONFIRMED_LIST_NAME="confirmed",t.LTR="left-to-right",t.RTL="right-to-left",t.DEFAULT_FORMAT={add:"Add",remove:"Remove",all:"All",none:"None",direction:t.LTR,draggable:!0,locale:undefined},t.decorators=[{type:e.Component,args:[{selector:"dual-list",template:'
\n\t
\n\t\t\n\n\t\t
\n\t\t\t\n\t\t
\n\n\t\t
\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t
\n\t\t
\n\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\n\t
\n\t\t\n\n\t\t
\n\t\t\t\n\t\t
\n\n\t\t
\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t
\n\t\t
\n\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n
\n',styles:['div.record-picker{overflow-x:hidden;overflow-y:auto;border:1px solid #ddd;border-radius:8px;position:relative;cursor:pointer;scrollbar-base-color:#337ab7;scrollbar-3dlight-color:#337ab7;scrollbar-highlight-color:#337ab7;scrollbar-track-color:#eee;scrollbar-arrow-color:gray;scrollbar-shadow-color:gray;scrollbar-dark-shadow-color:gray}div.record-picker::-webkit-scrollbar{width:12px}div.record-picker::-webkit-scrollbar-button{width:0;height:0}div.record-picker::-webkit-scrollbar-track{background:#eee;box-shadow:0 0 3px #dfdfdf inset;border-top-right-radius:8px;border-bottom-right-radius:8px}div.record-picker::-webkit-scrollbar-thumb{background:#337ab7;border:thin solid gray;border-top-right-radius:8px;border-bottom-right-radius:8px}div.record-picker::-webkit-scrollbar-thumb:hover{background:#286090}.record-picker ul{margin:0;padding:0 0 1px}.record-picker li{border-top:thin solid #ddd;border-bottom:1px solid #ddd;display:block;padding:2px 2px 2px 10px;margin-bottom:-1px;font-size:.85em;cursor:pointer;white-space:nowrap;min-height:16px}.record-picker li:hover{background-color:#f5f5f5}.record-picker li.selected{background-color:#d9edf7}.record-picker li.selected:hover{background-color:#c4e3f3}.record-picker li.disabled{opacity:.5;cursor:default;background-color:inherit}.record-picker li:first-child{border-top-left-radius:8px;border-top-right-radius:8px;border-top:none}.record-picker li:last-child{border-bottom-left-radius:8px;border-bottom-right-radius:8px;border-bottom:none}.record-picker label{cursor:pointer;font-weight:inherit;font-size:14px;padding:4px;margin-bottom:-1px;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.record-picker ul.over{background-color:#d3d3d3}.dual-list{display:flex;flex-direction:row;align-content:flex-start}.dual-list .listbox{width:50%;margin:0}.dual-list .button-bar{margin-top:8px}.point-right::after{content:"\\25B6";padding-left:1em}.point-left::before{content:"\\25C0";padding-right:1em}.dual-list .button-bar button{width:47%}button.btn-block{display:block;width:100%;margin-bottom:8px}.filter{margin-bottom:-2.2em}.filter::after{content:"o";width:40px;color:transparent;font-size:2em;background-image:url(\'data:image/svg+xml;utf8,\');background-repeat:no-repeat;background-position:center center;opacity:.2;top:-36px;left:calc(100% - 21px);position:relative}']}]}],t.ctorParameters=function(){return[{type:e.IterableDiffers}]},t.propDecorators={id:[{type:e.Input}],key:[{type:e.Input}],display:[{type:e.Input}],height:[{type:e.Input}],filter:[{type:e.Input}],format:[{type:e.Input}],sort:[{type:e.Input}],compare:[{type:e.Input}],disabled:[{type:e.Input}],source:[{type:e.Input}],destination:[{type:e.Input}],destinationChange:[{type:e.Output}]},t}(),l=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[i.CommonModule,r.FormsModule],declarations:[a],exports:[a]}]}],t}();t.AngularDualListBoxModule=l,t.BasicList=n,t.DualListComponent=a,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=angular-dual-listbox.umd.min.js.map