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

2 lines
20 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.cascadeselect=function(e,t,n,i,o,r,l,s){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=a(t),u=a(s);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function d(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function y(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&&v(e,t)}function b(e){return b="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},b(e)}function m(e,t){if(t&&("object"===b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function O(e){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},O(e)}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw r}}}}function g(e,t){if(e){if("string"==typeof e)return w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function E(){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){y(l,e);var t,i,r=(t=l,i=E(),function(){var e,n=O(t);if(i){var o=O(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return m(this,e)});function l(e){var t;return c(this,l),(t=r.call(this,e)).state={activeOption:null},t.onOptionSelect=t.onOptionSelect.bind(f(t)),t.onOptionGroupSelect=t.onOptionGroupSelect.bind(f(t)),t}return d(l,[{key:"componentDidMount",value:function(){if(this.props.selectionPath&&this.props.options&&!this.props.dirty){var e,t=S(this.props.options);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(this.props.selectionPath.includes(n)){this.setState({activeOption:n});break}}}catch(e){t.e(e)}finally{t.f()}}this.props.root||this.position()}},{key:"componentDidUpdate",value:function(e){e.parentActive!==this.props.parentActive&&this.setState({activeOption:null})}},{key:"position",value:function(){var e=this.element.parentElement,t=n.DomHandler.getOffset(e),i=n.DomHandler.getViewport(),o=this.element.offsetParent?this.element.offsetWidth:n.DomHandler.getHiddenElementOuterWidth(this.element),r=n.DomHandler.getOuterWidth(e.children[0]);parseInt(t.left,10)+r+o>i.width-n.DomHandler.calculateScrollbarWidth()&&(this.element.style.left="-100%")}},{key:"onOptionSelect",value:function(e){this.props.onOptionSelect&&this.props.onOptionSelect(e)}},{key:"onKeyDown",value:function(e,t){var n=e.currentTarget.parentElement;switch(e.key){case"Down":case"ArrowDown":var i=this.findNextItem(n);i&&i.children[0].focus();break;case"Up":case"ArrowUp":var o=this.findPrevItem(n);o&&o.children[0].focus();break;case"Right":case"ArrowRight":this.isOptionGroup(t)&&(this.state.activeOption===t?n.children[1].children[0].children[0].focus():this.setState({activeOption:t}));break;case"Left":case"ArrowLeft":this.setState({activeOption:null});var r=e.currentTarget.parentElement.parentElement.previousElementSibling;r&&r.focus();break;case"Enter":this.onOptionClick(e,t);break;case"Tab":case"Escape":this.props.onPanelHide&&(this.props.onPanelHide(),e.preventDefault())}e.preventDefault()}},{key:"findNextItem",value:function(e){var t=e.nextElementSibling;return t?n.DomHandler.hasClass(t,"p-disabled")||!n.DomHandler.hasClass(t,"p-cascadeselect-item")?this.findNextItem(t):t:null}},{key:"findPrevItem",value:function(e){var t=e.previousElementSibling;return t?n.DomHandler.hasClass(t,"p-disabled")||!n.DomHandler.hasClass(t,"p-cascadeselect-item")?this.findPrevItem(t):t:null}},{key:"onOptionClick",value:function(e,t){this.isOptionGroup(t)?(this.setState({activeOption:this.state.activeOption===t?null:t}),this.props.onOptionGroupSelect&&this.props.onOptionGroupSelect({originalEvent:e,value:t})):this.props.onOptionSelect&&this.props.onOptionSelect({originalEvent:e,value:this.getOptionValue(t)})}},{key:"onOptionGroupSelect",value:function(e){this.props.onOptionGroupSelect&&this.props.onOptionGroupSelect(e)}},{key:"getOptionLabel",value:function(e){return this.props.optionLabel?n.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e}},{key:"getOptionValue",value:function(e){return this.props.optionValue?n.ObjectUtils.resolveFieldData(e,this.props.optionValue):e}},{key:"getOptionGroupLabel",value:function(e){return this.props.optionGroupLabel?n.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel):null}},{key:"getOptionGroupChildren",value:function(e){return n.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren[this.props.level])}},{key:"isOptionGroup",value:function(e){return Object.prototype.hasOwnProperty.call(e,this.props.optionGroupChildren[this.props.level])}},{key:"getOptionLabelToRender",value:function(e){return this.isOptionGroup(e)?this.getOptionGroupLabel(e):this.getOptionLabel(e)}},{key:"renderSubmenu",value:function(e){return this.isOptionGroup(e)&&this.state.activeOption===e?p.default.createElement(l,{options:this.getOptionGroupChildren(e),className:"p-cascadeselect-sublist",selectionPath:this.props.selectionPath,optionLabel:this.props.optionLabel,optionValue:this.props.optionValue,level:this.props.level+1,onOptionSelect:this.onOptionSelect,onOptionGroupSelect:this.onOptionGroupSelect,parentActive:this.state.activeOption===e,optionGroupLabel:this.props.optionGroupLabel,optionGroupChildren:this.props.optionGroupChildren,dirty:this.props.dirty,template:this.props.template,onPanelHide:this.props.onPanelHide}):null}},{key:"renderOption",value:function(e,t){var i=this,r=n.classNames("p-cascadeselect-item",{"p-cascadeselect-item-group":this.isOptionGroup(e),"p-cascadeselect-item-active p-highlight":this.state.activeOption===e},e.className),l=this.renderSubmenu(e),s=this.props.template?n.ObjectUtils.getJSXElement(this.props.template,this.getOptionValue(e)):p.default.createElement("span",{className:"p-cascadeselect-item-text"},this.getOptionLabelToRender(e)),a=this.isOptionGroup(e)&&p.default.createElement("span",{className:"p-cascadeselect-group-icon pi pi-angle-right"});return p.default.createElement("li",{key:this.getOptionLabelToRender(e)+"_"+t,className:r,style:e.style,role:"none"},p.default.createElement("div",{className:"p-cascadeselect-item-content",onClick:function(t){return i.onOptionClick(t,e)},tabIndex:0,onKeyDown:function(t){return i.onKeyDown(t,e)}},s,a,p.default.createElement(o.Ripple,null)),l)}},{key:"renderMenu",value:function(){var e=this;return this.props.options?this.props.options.map((function(t,n){return e.renderOption(t,n)})):null}},{key:"render",value:function(){var e=this,t=n.classNames("p-cascadeselect-panel p-cascadeselect-items",this.props.className),i=this.renderMenu();return p.default.createElement("ul",{ref:function(t){return e.element=t},className:t,role:"listbox","aria-orientation":"horizontal"},i)}}]),l}(t.Component);function C(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=G(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw r}}}}function G(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function I(){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}}k(L,"defaultProps",{options:null,selectionPath:!1,className:null,optionLabel:null,optionValue:null,level:null,optionGroupLabel:null,optionGroupChildren:null,parentActive:null,dirty:null,root:null,template:null,onOptionSelect:null,onOptionGroupSelect:null});var P=function(e){y(h,e);var o,s,a=(o=h,s=I(),function(){var e,t=O(o);if(s){var n=O(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return m(this,e)});function h(e){var n;return c(this,h),(n=a.call(this,e)).state={focused:!1,overlayVisible:!1},n.dirty=!1,n.selectionPath=null,n.overlayRef=t.createRef(),n.inputRef=t.createRef(n.props.inputRef),n.hide=n.hide.bind(f(n)),n.onClick=n.onClick.bind(f(n)),n.onInputFocus=n.onInputFocus.bind(f(n)),n.onInputBlur=n.onInputBlur.bind(f(n)),n.onInputKeyDown=n.onInputKeyDown.bind(f(n)),n.onOverlayEnter=n.onOverlayEnter.bind(f(n)),n.onOverlayEntered=n.onOverlayEntered.bind(f(n)),n.onOverlayExit=n.onOverlayExit.bind(f(n)),n.onOverlayExited=n.onOverlayExited.bind(f(n)),n.onOptionSelect=n.onOptionSelect.bind(f(n)),n.onOptionGroupSelect=n.onOptionGroupSelect.bind(f(n)),n.onPanelClick=n.onPanelClick.bind(f(n)),n}return d(h,[{key:"onOptionSelect",value:function(e){this.props.onChange&&this.props.onChange({originalEvent:e,value:e.value}),this.updateSelectionPath(),this.hide(),this.inputRef.current.focus()}},{key:"onOptionGroupSelect",value:function(e){this.dirty=!0,this.props.onGroupChange&&this.props.onGroupChange(e)}},{key:"getOptionLabel",value:function(e){return this.props.optionLabel?n.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e}},{key:"getOptionValue",value:function(e){return this.props.optionValue?n.ObjectUtils.resolveFieldData(e,this.props.optionValue):e}},{key:"getOptionGroupChildren",value:function(e,t){return n.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren[t])}},{key:"isOptionGroup",value:function(e,t){return Object.prototype.hasOwnProperty.call(e,this.props.optionGroupChildren[t])}},{key:"updateSelectionPath",value:function(){var e;if(null!=this.props.value&&this.props.options){var t,n=C(this.props.options);try{for(n.s();!(t=n.n()).done;){if(e=this.findModelOptionInGroup(t.value,0))break}}catch(e){n.e(e)}finally{n.f()}}this.selectionPath=e}},{key:"findModelOptionInGroup",value:function(e,t){if(this.isOptionGroup(e,t)){var i,o,r=C(this.getOptionGroupChildren(e,t));try{for(r.s();!(o=r.n()).done;){if(i=this.findModelOptionInGroup(o.value,t+1))return i.unshift(e),i}}catch(e){r.e(e)}finally{r.f()}}else if(n.ObjectUtils.equals(this.props.value,this.getOptionValue(e),this.props.dataKey))return[e];return null}},{key:"onClick",value:function(e){if(!this.props.disabled){var t=this.overlayRef?this.overlayRef.current:null;t&&t.contains(e.target)||(this.inputRef.current.focus(),this.state.overlayVisible?this.hide():this.show())}}},{key:"onInputFocus",value:function(){this.setState({focused:!0})}},{key:"onInputBlur",value:function(){this.setState({focused:!1})}},{key:"onInputKeyDown",value:function(e){switch(e.which){case 40:this.state.overlayVisible?n.DomHandler.findSingle(this.overlayRef.current,".p-cascadeselect-item").children[0].focus():e.altKey&&this.props.options&&this.props.options.length&&this.show(),e.preventDefault();break;case 32:this.state.overlayVisible?this.hide():this.show(),e.preventDefault();break;case 9:this.hide()}}},{key:"onPanelClick",value:function(e){r.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"show",value:function(){this.props.onBeforeShow&&this.props.onBeforeShow(),this.setState({overlayVisible:!0})}},{key:"hide",value:function(){var e=this;this.props.onBeforeHide&&this.props.onBeforeHide(),this.setState({overlayVisible:!1},(function(){e.inputRef.current.focus()}))}},{key:"onOverlayEnter",value:function(){n.ZIndexUtils.set("overlay",this.overlayRef.current,u.default.autoZIndex,u.default.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntered",value:function(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.dirty=!1}},{key:"onOverlayExited",value:function(){n.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){n.DomHandler.alignOverlay(this.overlayRef.current,this.label.parentElement,this.props.appendTo||u.default.appendTo)}},{key:"bindOutsideClickListener",value:function(){var e=this;this.outsideClickListener||(this.outsideClickListener=function(t){e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hide()},document.addEventListener("click",this.outsideClickListener))}},{key:"unbindOutsideClickListener",value:function(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new n.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hide()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!n.DomHandler.isTouchDevice()&&e.hide()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.container.isSameNode(e.target)||this.container.contains(e.target)||this.overlayRef&&this.overlayRef.current.contains(e.target))}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.updateSelectionPath()}},{key:"componentWillUnmount",value:function(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),n.ZIndexUtils.clear(this.overlayRef.current)}},{key:"componentDidUpdate",value:function(e){e.value!==this.props.value&&this.updateSelectionPath()}},{key:"renderKeyboardHelper",value:function(){var e=this.props.value?this.getOptionLabel(this.props.value):null;return p.default.createElement("div",{className:"p-hidden-accessible"},p.default.createElement("input",{ref:this.inputRef,type:"text",id:this.props.inputId,name:this.props.name,defaultValue:e,readOnly:!0,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onKeyDown:this.onInputKeyDown,tabIndex:this.props.tabIndex,"aria-haspopup":"listbox","aria-labelledby":this.props.ariaLabelledBy}))}},{key:"renderLabel",value:function(){var e=this,t=this.props.value?this.getOptionLabel(this.props.value):this.props.placeholder||"p-emptylabel",i=n.classNames("p-cascadeselect-label ",{"p-placeholder":t===this.props.placeholder,"p-cascadeselect-label-empty":!this.props.value&&"p-emptylabel"===t});return p.default.createElement("span",{ref:function(t){return e.label=t},className:i},t)}},{key:"renderDropdownIcon",value:function(){var e=n.classNames("p-cascadeselect-trigger-icon",this.props.dropdownIcon);return p.default.createElement("div",{className:"p-cascadeselect-trigger",role:"button","aria-haspopup":"listbox","aria-expanded":this.state.overlayVisible},p.default.createElement("span",{className:e}))}},{key:"renderOverlay",value:function(){return p.default.createElement(l.Portal,{element:p.default.createElement(i.CSSTransition,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},p.default.createElement("div",{ref:this.overlayRef,className:"p-cascadeselect-panel p-component",onClick:this.onPanelClick},p.default.createElement("div",{className:"p-cascadeselect-items-wrapper"},p.default.createElement(L,{options:this.props.options,selectionPath:this.selectionPath,className:"p-cascadeselect-items",optionLabel:this.props.optionLabel,optionValue:this.props.optionValue,level:0,optionGroupLabel:this.props.optionGroupLabel,optionGroupChildren:this.props.optionGroupChildren,onOptionSelect:this.onOptionSelect,onOptionGroupSelect:this.onOptionGroupSelect,root:!0,template:this.props.itemTemplate,onPanelHide:this.hide})))),appendTo:this.props.appendTo})}},{key:"renderElement",value:function(){var e=this,t=n.classNames("p-cascadeselect p-component p-inputwrapper",this.props.className,{"p-disabled":this.props.disabled,"p-focus":this.state.focused,"p-inputwrapper-filled":this.props.value,"p-inputwrapper-focus":this.state.focused||this.state.overlayVisible}),i=this.renderKeyboardHelper(),o=this.renderLabel(),r=this.renderDropdownIcon(),l=this.renderOverlay();return p.default.createElement("div",{id:this.props.id,ref:function(t){return e.container=t},className:t,style:this.props.style,onClick:this.onClick},i,o,r,l)}},{key:"render",value:function(){return this.renderElement()}}]),h}(t.Component);return k(P,"defaultProps",{id:null,inputRef:null,style:null,className:null,value:null,name:null,options:null,optionLabel:null,optionValue:null,optionGroupLabel:null,optionGroupChildren:null,placeholder:null,itemTemplate:null,disabled:!1,dataKey:null,inputId:null,tabIndex:null,ariaLabelledBy:null,appendTo:null,transitionOptions:null,dropdownIcon:"pi pi-chevron-down",onChange:null,onGroupChange:null,onBeforeShow:null,onBeforeHide:null,onShow:null,onHide:null}),e.CascadeSelect=P,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.csstransition,primereact.ripple,primereact.overlayservice,primereact.portal,primereact.api);