"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),o=require("primereact/ripple"),n=require("primereact/button");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var o=0;oe.length)&&(t=e.length);for(var o=0,n=new Array(t);o=0;r--){var i=t.ObjectUtils.findIndexInList(o[r],n,this.props.dataKey);if(i===n.length-1)break;var s=n[i+1];n[i+1]=n[i],n[i]=s}this.props.onReorder&&this.props.onReorder({originalEvent:e,value:n,direction:"down"}),this.movedDown=!0}}},{key:"moveBottom",value:function(e){var o=this.props.selection;if(o&&o.length){for(var n=E(this.props.list),r=o.length-1;r>=0;r--){var i=t.ObjectUtils.findIndexInList(o[r],n,this.props.dataKey);if(i===n.length-1)break;var s=n.splice(i,1)[0];n.push(s)}this.props.onReorder&&this.props.onReorder({originalEvent:e,value:n,direction:"bottom"})}}},{key:"render",value:function(){var e=!this.props.selection.length,o=t.classNames("p-picklist-buttons",this.props.className);return i.default.createElement("div",{className:o},i.default.createElement(n.Button,{disabled:e,type:"button",icon:"pi pi-angle-up",onClick:this.moveUp}),i.default.createElement(n.Button,{disabled:e,type:"button",icon:"pi pi-angle-double-up",onClick:this.moveTop}),i.default.createElement(n.Button,{disabled:e,type:"button",icon:"pi pi-angle-down",onClick:this.moveDown}),i.default.createElement(n.Button,{disabled:e,type:"button",icon:"pi pi-angle-double-down",onClick:this.moveBottom}))}}]),h}();function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var N=function(o){u(h,e.Component);var r,l,p=(r=h,l=j(),function(){var e,t=d(r);if(l){var o=d(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return f(this,e)});function h(e){var t;return s(this,h),(t=p.call(this,e)).moveRight=t.moveRight.bind(c(t)),t.moveAllRight=t.moveAllRight.bind(c(t)),t.moveLeft=t.moveLeft.bind(c(t)),t.moveAllLeft=t.moveAllLeft.bind(c(t)),t}return a(h,[{key:"moveRight",value:function(e){var o=this.props.sourceSelection;if(t.ObjectUtils.isNotEmpty(o)){for(var n=E(this.props.target),r=E(this.props.source),i=0;i1&&void 0!==arguments[1]?arguments[1]:1,n=e.getElementsByClassName("p-highlight");t.ObjectUtils.isNotEmpty(n)&&t.DomHandler.scrollInView(e,-1===o?n[0]:n[n.length-1])}},{key:"onSelectionChange",value:function(e,o,n){n?n(e):this.setState(v({},o,e.value)),t.ObjectUtils.isNotEmpty(this.state.sourceSelection)&&"targetSelection"===o?this.setState({sourceSelection:[]}):t.ObjectUtils.isNotEmpty(this.state.targetSelection)&&"sourceSelection"===o&&this.setState({targetSelection:[]})}},{key:"componentDidUpdate",value:function(){this.reorderedListElement&&(this.handleScrollPosition(this.reorderedListElement,this.reorderDirection),this.reorderedListElement=null,this.reorderDirection=null)}},{key:"render",value:function(){var e=this,o=t.classNames("p-picklist p-component",this.props.className),n=this.getSourceSelection(),r=this.getTargetSelection();return i.default.createElement("div",{id:this.props.id,className:o,style:this.props.style},this.props.showSourceControls&&i.default.createElement(K,{list:this.props.source,selection:n,onReorder:this.onSourceReorder,className:"p-picklist-source-controls",dataKey:this.props.dataKey}),i.default.createElement(I,{ref:function(t){return e.sourceListElement=t},list:this.props.source,selection:n,onSelectionChange:function(t){return e.onSelectionChange(t,"sourceSelection",e.props.onSourceSelectionChange)},itemTemplate:this.props.itemTemplate,header:this.props.sourceHeader,style:this.props.sourceStyle,className:"p-picklist-source-wrapper",listClassName:"p-picklist-source",metaKeySelection:this.props.metaKeySelection,tabIndex:this.props.tabIndex,dataKey:this.props.dataKey}),i.default.createElement(N,{onTransfer:this.onTransfer,source:this.props.source,target:this.props.target,sourceSelection:n,targetSelection:r,dataKey:this.props.dataKey}),i.default.createElement(I,{ref:function(t){return e.targetListElement=t},list:this.props.target,selection:r,onSelectionChange:function(t){return e.onSelectionChange(t,"targetSelection",e.props.onTargetSelectionChange)},itemTemplate:this.props.itemTemplate,header:this.props.targetHeader,style:this.props.targetStyle,className:"p-picklist-target-wrapper",listClassName:"p-picklist-target",metaKeySelection:this.props.metaKeySelection,tabIndex:this.props.tabIndex,dataKey:this.props.dataKey}),this.props.showTargetControls&&i.default.createElement(K,{list:this.props.target,selection:r,onReorder:this.onTargetReorder,className:"p-picklist-target-controls",dataKey:this.props.dataKey}))}}]),p}();v(D,"defaultProps",{id:null,source:null,target:null,sourceHeader:null,targetHeader:null,style:null,className:null,sourceStyle:null,targetStyle:null,sourceSelection:null,targetSelection:null,showSourceControls:!0,showTargetControls:!0,metaKeySelection:!0,tabIndex:0,dataKey:null,itemTemplate:null,onChange:null,onMoveToSource:null,onMoveAllToSource:null,onMoveToTarget:null,onMoveAllToTarget:null,onSourceSelectionChange:null,onTargetSelectionChange:null}),exports.PickList=D;