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

2 lines
11 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.menubar=function(e,t,n,r,i){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(t),a=o(i);function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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 c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){return f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},f(e,t)}function p(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&&f(e,t)}function d(e){return d="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},d(e)}function h(e,t){if(t&&("object"===d(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 v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}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 C=function(e){p(a,e);var t,i,o=(t=a,i=k(),function(){var e,n=v(t);if(i){var r=v(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return h(this,e)});function a(e){var t;return u(this,a),(t=o.call(this,e)).state={activeItem:null},t.onLeafClick=t.onLeafClick.bind(m(t)),t.onChildItemKeyDown=t.onChildItemKeyDown.bind(m(t)),t}return c(a,[{key:"getElementRef",value:function(e){return this.element=e,this.props.forwardRef?this.props.forwardRef(e):this.element}},{key:"onItemMouseEnter",value:function(e,t){t.disabled||this.props.mobileActive?e.preventDefault():this.props.root?(this.state.activeItem||this.props.popup)&&this.setState({activeItem:t}):this.setState({activeItem:t})}},{key:"onItemClick",value:function(e,t){t.disabled?e.preventDefault():(t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),t.items?this.setState(this.state.activeItem&&t===this.state.activeItem?{activeItem:null}:{activeItem:t}):this.onLeafClick())}},{key:"onItemKeyDown",value:function(e,t){var n=e.currentTarget.parentElement;switch(e.which){case 40:this.props.root?t.items&&this.expandSubmenu(t,n):this.navigateToNextItem(n),e.preventDefault();break;case 38:this.props.root||this.navigateToPrevItem(n),e.preventDefault();break;case 39:if(this.props.root){var r=this.findNextItem(n);r&&r.children[0].focus()}else t.items&&this.expandSubmenu(t,n);e.preventDefault();break;case 37:this.props.root&&this.navigateToPrevItem(n),e.preventDefault()}this.props.onKeyDown&&this.props.onKeyDown(e,n)}},{key:"onChildItemKeyDown",value:function(e,t){this.props.root?38===e.which&&null==t.previousElementSibling&&this.collapseMenu(t):37===e.which&&this.collapseMenu(t)}},{key:"expandSubmenu",value:function(e,t){this.setState({activeItem:e}),setTimeout((function(){t.children[1].children[0].children[0].focus()}),50)}},{key:"collapseMenu",value:function(e){this.setState({activeItem:null}),e.parentElement.previousElementSibling.focus()}},{key:"navigateToNextItem",value:function(e){var t=this.findNextItem(e);t&&t.children[0].focus()}},{key:"navigateToPrevItem",value:function(e){var t=this.findPrevItem(e);t&&t.children[0].focus()}},{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:"onLeafClick",value:function(){this.setState({activeItem:null}),this.props.onLeafClick&&this.props.onLeafClick()}},{key:"componentDidMount",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.element&&!e.element.contains(t.target)&&e.setState({activeItem:null})},document.addEventListener("click",this.documentClickListener))}},{key:"componentDidUpdate",value:function(e){e.parentActive&&!this.props.parentActive&&this.setState({activeItem:null})}},{key:"componentWillUnmount",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"renderSeparator",value:function(e){return l.default.createElement("li",{key:"separator_"+e,className:"p-menu-separator",role:"separator"})}},{key:"renderSubmenu",value:function(e){return e.items?l.default.createElement(I,{model:e.items,mobileActive:this.props.mobileActive,onLeafClick:this.onLeafClick,onKeyDown:this.onChildItemKeyDown,parentActive:e===this.state.activeItem}):null}},{key:"renderMenuitem",value:function(e,t){var i=this,o=n.classNames("p-menuitem",{"p-menuitem-active":this.state.activeItem===e},e.className),a=n.classNames("p-menuitem-link",{"p-disabled":e.disabled}),u=n.classNames("p-menuitem-icon",e.icon),s=n.classNames("p-submenu-icon pi",{"pi-angle-down":this.props.root,"pi-angle-right":!this.props.root}),c=e.icon&&l.default.createElement("span",{className:u}),m=e.label&&l.default.createElement("span",{className:"p-menuitem-text"},e.label),f=e.items&&l.default.createElement("span",{className:s}),p=this.renderSubmenu(e),d=l.default.createElement("a",{href:e.url||"#",role:"menuitem",className:a,target:e.target,"aria-haspopup":null!=e.items,onClick:function(t){return i.onItemClick(t,e)},onKeyDown:function(t){return i.onItemKeyDown(t,e)}},c,m,f,l.default.createElement(r.Ripple,null));e.template&&(d=n.ObjectUtils.getJSXElement(e.template,e,{onClick:function(t){return i.onItemClick(t,e)},onKeyDown:function(t){return i.onItemKeyDown(t,e)},className:a,labelClassName:"p-menuitem-text",iconClassName:u,submenuIconClassName:s,element:d,props:this.props}));return l.default.createElement("li",{key:e.label+"_"+t,role:"none",className:o,style:e.style,onMouseEnter:function(t){return i.onItemMouseEnter(t,e)}},d,p)}},{key:"renderItem",value:function(e,t){return e.separator?this.renderSeparator(t):this.renderMenuitem(e,t)}},{key:"renderMenu",value:function(){var e=this;return this.props.model?this.props.model.map((function(t,n){return e.renderItem(t,n)})):null}},{key:"render",value:function(){var e=this,t=n.classNames({"p-submenu-list":!this.props.root,"p-menubar-root-list":this.props.root}),r=this.renderMenu();return l.default.createElement("ul",{ref:function(t){return e.getElementRef(t)},className:t,role:this.props.root?"menubar":"menu"},r)}}]),a}(t.Component);b(C,"defaultProps",{model:null,root:!1,className:null,popup:!1,onLeafClick:null,onKeyDown:null,parentActive:!1,mobileActive:!1,forwardRef:null});var I=l.default.forwardRef((function(e,t){return l.default.createElement(C,y({forwardRef:t},e))}));function g(){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 E=function(e){p(o,e);var t,r,i=(t=o,r=g(),function(){var e,n=v(t);if(r){var i=v(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return h(this,e)});function o(e){var t;return u(this,o),(t=i.call(this,e)).state={mobileActive:!1},t.toggle=t.toggle.bind(m(t)),t.onLeafClick=t.onLeafClick.bind(m(t)),t}return c(o,[{key:"toggle",value:function(e){var t=this;e.preventDefault(),this.setState((function(e){return{mobileActive:!e.mobileActive}}),(function(){t.state.mobileActive?(n.ZIndexUtils.set("menu",t.rootmenu,a.default.autoZIndex,a.default.zIndex.menu),t.bindDocumentClickListener()):(t.unbindDocumentClickListener(),n.ZIndexUtils.clear(t.rootmenu))}))}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.state.mobileActive&&e.isOutsideClicked(t)&&e.setState({mobileActive:!1},(function(){e.unbindDocumentClickListener(),n.ZIndexUtils.clear(e.rootmenu)}))},document.addEventListener("click",this.documentClickListener))}},{key:"isOutsideClicked",value:function(e){return this.rootmenu!==e.target&&!this.rootmenu.contains(e.target)&&this.menubutton!==e.target&&!this.menubutton.contains(e.target)}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"onLeafClick",value:function(){var e=this;this.setState({mobileActive:!1},(function(){e.unbindDocumentClickListener(),n.ZIndexUtils.clear(e.rootmenu)}))}},{key:"componentWillUnmount",value:function(){n.ZIndexUtils.clear(this.rootmenu)}},{key:"renderCustomContent",value:function(){return this.props.children?l.default.createElement("div",{className:"p-menubar-custom"},this.props.children):null}},{key:"renderStartContent",value:function(){if(this.props.start){var e=n.ObjectUtils.getJSXElement(this.props.start,this.props);return l.default.createElement("div",{className:"p-menubar-start"},e)}return null}},{key:"renderEndContent",value:function(){if(this.props.end){var e=n.ObjectUtils.getJSXElement(this.props.end,this.props);return l.default.createElement("div",{className:"p-menubar-end"},e)}return null}},{key:"renderMenuButton",value:function(){var e=this;return l.default.createElement("a",{ref:function(t){return e.menubutton=t},href:"#",role:"button",tabIndex:0,className:"p-menubar-button",onClick:this.toggle},l.default.createElement("i",{className:"pi pi-bars"}))}},{key:"render",value:function(){var e=this,t=n.classNames("p-menubar p-component",{"p-menubar-mobile-active":this.state.mobileActive},this.props.className),r=this.renderStartContent(),i=this.renderEndContent(),o=this.renderMenuButton();return l.default.createElement("div",{id:this.props.id,className:t,style:this.props.style},r,o,l.default.createElement(I,{ref:function(t){return e.rootmenu=t},model:this.props.model,root:!0,mobileActive:this.state.mobileActive,onLeafClick:this.onLeafClick}),i)}}]),o}(t.Component);return b(E,"defaultProps",{id:null,model:null,style:null,className:null,start:null,end:null}),e.Menubar=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.api);