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

2 lines
8.4 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.menu=function(e,t,n,r,i,o,s){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(t),u=l(s);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function f(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&&p(e,t)}function h(e){return h="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},h(e)}function v(e,t){if(t&&("object"===h(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(){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 k,E,w,x=function(e){f(E,e);var t,s,l,p,h,k=(t=E,s=b(),function(){var e,n=y(t);if(s){var r=y(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return v(this,e)});function E(e){var t;return c(this,E),(t=k.call(this,e)).state={visible:!e.popup},t.onEnter=t.onEnter.bind(m(t)),t.onEntered=t.onEntered.bind(m(t)),t.onExit=t.onExit.bind(m(t)),t.onExited=t.onExited.bind(m(t)),t.onPanelClick=t.onPanelClick.bind(m(t)),t.menuRef=a.default.createRef(),t}return l=E,(p=[{key:"onPanelClick",value:function(e){this.props.popup&&i.OverlayService.emit("overlay-click",{originalEvent:e,target:this.target})}},{key:"onItemClick",value:function(e,t){t.disabled?e.preventDefault():(t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),this.props.popup&&this.hide(e))}},{key:"onItemKeyDown",value:function(e,t){var n=e.currentTarget.parentElement;switch(e.which){case 40:var r=this.findNextItem(n);r&&r.children[0].focus(),e.preventDefault();break;case 38:var i=this.findPrevItem(n);i&&i.children[0].focus(),e.preventDefault()}}},{key:"findNextItem",value:function(e){var t=e.nextElementSibling;return t?n.DomHandler.hasClass(t,"p-disabled")||!n.DomHandler.hasClass(t,"p-menuitem")?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-menuitem")?this.findPrevItem(t):t:null}},{key:"toggle",value:function(e){this.props.popup&&(this.state.visible?this.hide(e):this.show(e))}},{key:"show",value:function(e){var t=this;this.target=e.currentTarget;var n=e;this.setState({visible:!0},(function(){t.props.onShow&&t.props.onShow(n)}))}},{key:"hide",value:function(e){var t=this,n=e;this.setState({visible:!1},(function(){t.props.onHide&&t.props.onHide(n)}))}},{key:"onEnter",value:function(){n.ZIndexUtils.set("menu",this.menuRef.current,u.default.autoZIndex,this.props.baseZIndex||u.default.zIndex.menu),n.DomHandler.absolutePosition(this.menuRef.current,this.target)}},{key:"onEntered",value:function(){this.bindDocumentListeners(),this.bindScrollListener()}},{key:"onExit",value:function(){this.target=null,this.unbindDocumentListeners(),this.unbindScrollListener()}},{key:"onExited",value:function(){n.ZIndexUtils.clear(this.menuRef.current)}},{key:"bindDocumentListeners",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.state.visible&&e.isOutsideClicked(t)&&e.hide(t)},document.addEventListener("click",this.documentClickListener)),this.documentResizeListener||(this.documentResizeListener=function(t){e.state.visible&&!n.DomHandler.isTouchDevice()&&e.hide(t)},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null),this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new n.ConnectedOverlayScrollHandler(this.target,(function(t){e.state.visible&&e.hide(t)}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"isOutsideClicked",value:function(e){return this.menuRef&&this.menuRef.current&&!(this.menuRef.current.isSameNode(e.target)||this.menuRef.current.contains(e.target))}},{key:"componentWillUnmount",value:function(){this.unbindDocumentListeners(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),n.ZIndexUtils.clear(this.menuRef.current)}},{key:"renderSubmenu",value:function(e,t){var r=this,i=n.classNames("p-submenu-header",{"p-disabled":e.disabled},e.className),o=e.items.map((function(e,t){return r.renderMenuitem(e,t)}));return a.default.createElement(a.default.Fragment,{key:e.label+"_"+t},a.default.createElement("li",{className:i,style:e.style,role:"presentation","aria-disabled":e.disabled},e.label),o)}},{key:"renderSeparator",value:function(e){return a.default.createElement("li",{key:"separator_"+e,className:"p-menu-separator",role:"separator"})}},{key:"renderMenuitem",value:function(e,t){var r=this,i=n.classNames("p-menuitem",e.className),o=n.classNames("p-menuitem-link",{"p-disabled":e.disabled}),s=n.classNames("p-menuitem-icon",e.icon),l=e.disabled?null:0,u=a.default.createElement("a",{href:e.url||"#",className:o,role:"menuitem",target:e.target,onClick:function(t){return r.onItemClick(t,e)},onKeyDown:function(t){return r.onItemKeyDown(t,e)},tabIndex:l,"aria-disabled":e.disabled},e.icon&&a.default.createElement("span",{className:s}),e.label&&a.default.createElement("span",{className:"p-menuitem-text"},e.label));return e.template&&(u=n.ObjectUtils.getJSXElement(e.template,e,{onClick:function(t){return r.onItemClick(t,e)},onKeyDown:function(t){return r.onItemKeyDown(t,e)},className:o,tabIndex:l,labelClassName:"p-menuitem-text",iconClassName:s,element:u,props:this.props})),a.default.createElement("li",{key:e.label+"_"+t,className:i,style:e.style,role:"none"},u)}},{key:"renderItem",value:function(e,t){return e.separator?this.renderSeparator(t):e.items?this.renderSubmenu(e,t):this.renderMenuitem(e,t)}},{key:"renderMenu",value:function(){var e=this;return this.props.model.map((function(t,n){return e.renderItem(t,n)}))}},{key:"renderElement",value:function(){if(this.props.model){var e=n.classNames("p-menu p-component",this.props.className,{"p-menu-overlay":this.props.popup}),t=this.renderMenu();return a.default.createElement(r.CSSTransition,{nodeRef:this.menuRef,classNames:"p-connected-overlay",in:this.state.visible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExit:this.onExit,onExited:this.onExited},a.default.createElement("div",{ref:this.menuRef,id:this.props.id,className:e,style:this.props.style,onClick:this.onPanelClick},a.default.createElement("ul",{className:"p-menu-list p-reset",role:"menu"},t)))}return null}},{key:"render",value:function(){var e=this.renderElement();return this.props.popup?a.default.createElement(o.Portal,{element:e,appendTo:this.props.appendTo}):e}}])&&d(l.prototype,p),h&&d(l,h),Object.defineProperty(l,"prototype",{writable:!1}),E}(t.Component);return w={id:null,model:null,popup:!1,style:null,className:null,autoZIndex:!0,baseZIndex:0,appendTo:null,transitionOptions:null,onShow:null,onHide:null},(E="defaultProps")in(k=x)?Object.defineProperty(k,E,{value:w,enumerable:!0,configurable:!0,writable:!0}):k[E]=w,e.Menu=x,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.csstransition,primereact.overlayservice,primereact.portal,primereact.api);