2 lines
11 KiB
JavaScript
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
|