katoikia-app/web-ui/web-react/node_modules/primereact/picklist/picklist.min.js

2 lines
17 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.picklist=function(e,t,o,n,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,o){return t&&a(e.prototype,t),o&&a(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function d(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function m(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},y.apply(this,arguments)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o<t;o++)n[o]=e[o];return n}function b(e){if(Array.isArray(e))return g(e)}function S(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function k(e,t){if(e){if("string"==typeof e)return g(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?g(e,t):void 0}}function E(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e){return b(e)||S(e)||k(e)||E()}function C(){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 w=function(e){h(a,e);var t,r,i=(t=a,r=C(),function(){var e,o=v(t);if(r){var n=v(this).constructor;e=Reflect.construct(o,arguments,n)}else e=o.apply(this,arguments);return d(this,e)});function a(e){var t;return l(this,a),(t=i.call(this,e)).onClick=t.onClick.bind(p(t)),t.onKeyDown=t.onKeyDown.bind(p(t)),t}return c(a,[{key:"onClick",value:function(e){this.props.onClick&&this.props.onClick({originalEvent:e,value:this.props.value})}},{key:"onKeyDown",value:function(e){this.props.onKeyDown&&this.props.onKeyDown({originalEvent:e,value:this.props.value})}},{key:"render",value:function(){var e=this.props.template?this.props.template(this.props.value):this.props.value,t=o.classNames("p-picklist-item",{"p-highlight":this.props.selected},this.props.className);return s.default.createElement("li",{className:t,onClick:this.onClick,onKeyDown:this.onKeyDown,tabIndex:this.props.tabIndex,role:"option","aria-selected":this.props.selected},e,s.default.createElement(n.Ripple,null))}}]),a}(t.Component);function R(){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}}m(w,"defaultProps",{value:null,className:null,template:null,selected:!1,tabIndex:null,onClick:null,onKeyDown:null});var I=function(e){h(i,e);var t,n,r=(t=i,n=R(),function(){var e,o=v(t);if(n){var r=v(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return d(this,e)});function i(e){var t;return l(this,i),(t=r.call(this,e)).onItemClick=t.onItemClick.bind(p(t)),t.onItemKeyDown=t.onItemKeyDown.bind(p(t)),t}return c(i,[{key:"onItemClick",value:function(e){var t=e.originalEvent,n=e.value,r=T(this.props.selection),i=o.ObjectUtils.findIndexInList(n,r,this.props.dataKey),s=-1!==i;if(this.props.metaKeySelection){var l=t.metaKey||t.ctrlKey;s&&l?r.splice(i,1):(l||(r.length=0),r.push(n))}else s?r.splice(i,1):r.push(n);this.props.onSelectionChange&&this.props.onSelectionChange({event:t,value:r})}},{key:"onItemKeyDown",value:function(e){var t=e.originalEvent.currentTarget;switch(e.originalEvent.which){case 40:var o=this.findNextItem(t);o&&o.focus(),e.originalEvent.preventDefault();break;case 38:var n=this.findPrevItem(t);n&&n.focus(),e.originalEvent.preventDefault();break;case 13:this.onItemClick(e),e.originalEvent.preventDefault()}}},{key:"findNextItem",value:function(e){var t=e.nextElementSibling;return t?o.DomHandler.hasClass(t,"p-picklist-item")?t:this.findNextItem(t):null}},{key:"findPrevItem",value:function(e){var t=e.previousElementSibling;return t?o.DomHandler.hasClass(t,"p-picklist-item")?t:this.findPrevItem(t):null}},{key:"isSelected",value:function(e){return-1!==o.ObjectUtils.findIndexInList(e,this.props.selection,this.props.dataKey)}},{key:"render",value:function(){var e=this,t=null,n=null,r=o.classNames("p-picklist-list-wrapper",this.props.className),i=o.classNames("p-picklist-list",this.props.listClassName);return this.props.header&&(t=s.default.createElement("div",{className:"p-picklist-header"},o.ObjectUtils.getJSXElement(this.props.header,this.props))),this.props.list&&(n=this.props.list.map((function(t,o){return s.default.createElement(w,{key:JSON.stringify(t),value:t,template:e.props.itemTemplate,selected:e.isSelected(t),onClick:e.onItemClick,onKeyDown:e.onItemKeyDown,tabIndex:e.props.tabIndex})}))),s.default.createElement("div",{ref:this.props.forwardRef,className:r},t,s.default.createElement("ul",{className:i,style:this.props.style,role:"listbox","aria-multiselectable":!0},n))}}]),i}(t.Component),O=s.default.forwardRef((function(e,t){return s.default.createElement(I,y({forwardRef:t},e))}));function K(){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 j=function(e){h(a,e);var t,n,i=(t=a,n=K(),function(){var e,o=v(t);if(n){var r=v(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return d(this,e)});function a(e){var t;return l(this,a),(t=i.call(this,e)).moveUp=t.moveUp.bind(p(t)),t.moveTop=t.moveTop.bind(p(t)),t.moveDown=t.moveDown.bind(p(t)),t.moveBottom=t.moveBottom.bind(p(t)),t}return c(a,[{key:"moveUp",value:function(e){var t=this.props.selection;if(t&&t.length){for(var n=T(this.props.list),r=0;r<t.length;r++){var i=o.ObjectUtils.findIndexInList(t[r],n,this.props.dataKey);if(0===i)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:"up"})}}},{key:"moveTop",value:function(e){var t=this.props.selection;if(t&&t.length){for(var n=T(this.props.list),r=0;r<t.length;r++){var i=o.ObjectUtils.findIndexInList(t[r],n,this.props.dataKey);if(0===i)break;var s=n.splice(i,1)[0];n.unshift(s)}this.props.onReorder&&this.props.onReorder({originalEvent:e,value:n,direction:"top"})}}},{key:"moveDown",value:function(e){var t=this.props.selection;if(t&&t.length){for(var n=T(this.props.list),r=t.length-1;r>=0;r--){var i=o.ObjectUtils.findIndexInList(t[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 t=this.props.selection;if(t&&t.length){for(var n=T(this.props.list),r=t.length-1;r>=0;r--){var i=o.ObjectUtils.findIndexInList(t[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,t=o.classNames("p-picklist-buttons",this.props.className);return s.default.createElement("div",{className:t},s.default.createElement(r.Button,{disabled:e,type:"button",icon:"pi pi-angle-up",onClick:this.moveUp}),s.default.createElement(r.Button,{disabled:e,type:"button",icon:"pi pi-angle-double-up",onClick:this.moveTop}),s.default.createElement(r.Button,{disabled:e,type:"button",icon:"pi pi-angle-down",onClick:this.moveDown}),s.default.createElement(r.Button,{disabled:e,type:"button",icon:"pi pi-angle-double-down",onClick:this.moveBottom}))}}]),a}(t.Component);function N(){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 x=function(e){h(a,e);var t,n,i=(t=a,n=N(),function(){var e,o=v(t);if(n){var r=v(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return d(this,e)});function a(e){var t;return l(this,a),(t=i.call(this,e)).moveRight=t.moveRight.bind(p(t)),t.moveAllRight=t.moveAllRight.bind(p(t)),t.moveLeft=t.moveLeft.bind(p(t)),t.moveAllLeft=t.moveAllLeft.bind(p(t)),t}return c(a,[{key:"moveRight",value:function(e){var t=this.props.sourceSelection;if(o.ObjectUtils.isNotEmpty(t)){for(var n=T(this.props.target),r=T(this.props.source),i=0;i<t.length;i++){var s=t[i];-1===o.ObjectUtils.findIndexInList(s,n,this.props.dataKey)&&n.push(r.splice(o.ObjectUtils.findIndexInList(s,r,this.props.dataKey),1)[0])}this.props.onTransfer&&this.props.onTransfer({originalEvent:e,source:r,target:n,direction:"toTarget"})}}},{key:"moveAllRight",value:function(e){if(this.props.source){var t=[].concat(T(this.props.target),T(this.props.source));this.props.onTransfer&&this.props.onTransfer({originalEvent:e,source:[],target:t,direction:"allToTarget"})}}},{key:"moveLeft",value:function(e){var t=this.props.targetSelection;if(o.ObjectUtils.isNotEmpty(t)){for(var n=T(this.props.target),r=T(this.props.source),i=0;i<t.length;i++){var s=t[i];-1===o.ObjectUtils.findIndexInList(s,r,this.props.dataKey)&&r.push(n.splice(o.ObjectUtils.findIndexInList(s,n,this.props.dataKey),1)[0])}this.props.onTransfer&&this.props.onTransfer({originalEvent:e,source:r,target:n,direction:"toSource"})}}},{key:"moveAllLeft",value:function(e){if(this.props.source){var t=[].concat(T(this.props.source),T(this.props.target));this.props.onTransfer&&this.props.onTransfer({originalEvent:e,source:t,target:[],direction:"allToSource"})}}},{key:"render",value:function(){var e=o.ObjectUtils.isEmpty(this.props.sourceSelection),t=o.ObjectUtils.isEmpty(this.props.targetSelection),n=o.ObjectUtils.isEmpty(this.props.source),i=o.ObjectUtils.isEmpty(this.props.target),l=o.classNames("p-picklist-buttons p-picklist-transfer-buttons",this.props.className);return s.default.createElement("div",{className:l},s.default.createElement(r.Button,{disabled:e,type:"button",icon:"pi pi-angle-right",onClick:this.moveRight}),s.default.createElement(r.Button,{disabled:n,type:"button",icon:"pi pi-angle-double-right",onClick:this.moveAllRight}),s.default.createElement(r.Button,{disabled:t,type:"button",icon:"pi pi-angle-left",onClick:this.moveLeft}),s.default.createElement(r.Button,{disabled:i,type:"button",icon:"pi pi-angle-double-left",onClick:this.moveAllLeft}))}}]),a}(t.Component);function D(){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 L=function(e){h(i,e);var t,n,r=(t=i,n=D(),function(){var e,o=v(t);if(n){var r=v(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return d(this,e)});function i(e){var t;return l(this,i),(t=r.call(this,e)).state={},t.props.onSourceSelectionChange||(t.state.sourceSelection=[]),t.props.onTargetSelectionChange||(t.state.targetSelection=[]),t.onSourceReorder=t.onSourceReorder.bind(p(t)),t.onTargetReorder=t.onTargetReorder.bind(p(t)),t.onTransfer=t.onTransfer.bind(p(t)),t}return c(i,[{key:"getSourceSelection",value:function(){return this.props.onSourceSelectionChange?this.props.sourceSelection:this.state.sourceSelection}},{key:"getTargetSelection",value:function(){return this.props.onTargetSelectionChange?this.props.targetSelection:this.state.targetSelection}},{key:"onSourceReorder",value:function(e){this.handleChange(e,e.value,this.props.target),this.reorderedListElement=this.sourceListElement,this.reorderDirection=e.direction}},{key:"onTargetReorder",value:function(e){this.handleChange(e,this.props.source,e.value),this.reorderedListElement=this.targetListElement,this.reorderDirection=e.direction}},{key:"handleScrollPosition",value:function(e,t){if(e){var n=o.DomHandler.findSingle(e,".p-picklist-list");switch(t){case"up":this.scrollInView(n,-1);break;case"top":n.scrollTop=0;break;case"down":this.scrollInView(n,1);break;case"bottom":n.scrollTop=n.scrollHeight}}}},{key:"handleChange",value:function(e,t,o){this.props.onChange&&this.props.onChange({originalEvent:e.originalEvent,source:t,target:o})}},{key:"onTransfer",value:function(e){var t=e.originalEvent,o=e.source,n=e.target;switch(e.direction){case"toTarget":this.props.onMoveToTarget&&this.props.onMoveToTarget({originalEvent:t,value:this.getSourceSelection()});break;case"allToTarget":this.props.onMoveAllToTarget&&this.props.onMoveAllToTarget({originalEvent:t,value:this.props.source});break;case"toSource":this.props.onMoveToSource&&this.props.onMoveToSource({originalEvent:t,value:this.getTargetSelection()});break;case"allToSource":this.props.onMoveAllToSource&&this.props.onMoveAllToSource({originalEvent:t,value:this.props.target})}this.onSelectionChange({originalEvent:t,value:[]},"sourceSelection",this.props.onSourceSelectionChange),this.onSelectionChange({originalEvent:t,value:[]},"targetSelection",this.props.onTargetSelectionChange),this.handleChange(e,o,n)}},{key:"scrollInView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e.getElementsByClassName("p-highlight");o.ObjectUtils.isNotEmpty(n)&&o.DomHandler.scrollInView(e,-1===t?n[0]:n[n.length-1])}},{key:"onSelectionChange",value:function(e,t,n){n?n(e):this.setState(m({},t,e.value)),o.ObjectUtils.isNotEmpty(this.state.sourceSelection)&&"targetSelection"===t?this.setState({sourceSelection:[]}):o.ObjectUtils.isNotEmpty(this.state.targetSelection)&&"sourceSelection"===t&&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,t=o.classNames("p-picklist p-component",this.props.className),n=this.getSourceSelection(),r=this.getTargetSelection();return s.default.createElement("div",{id:this.props.id,className:t,style:this.props.style},this.props.showSourceControls&&s.default.createElement(j,{list:this.props.source,selection:n,onReorder:this.onSourceReorder,className:"p-picklist-source-controls",dataKey:this.props.dataKey}),s.default.createElement(O,{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}),s.default.createElement(x,{onTransfer:this.onTransfer,source:this.props.source,target:this.props.target,sourceSelection:n,targetSelection:r,dataKey:this.props.dataKey}),s.default.createElement(O,{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&&s.default.createElement(j,{list:this.props.target,selection:r,onReorder:this.onTargetReorder,className:"p-picklist-target-controls",dataKey:this.props.dataKey}))}}]),i}(t.Component);return m(L,"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}),e.PickList=L,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.button);