2 lines
8.4 KiB
JavaScript
2 lines
8.4 KiB
JavaScript
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/csstransition"),r=require("primereact/overlayservice"),i=require("primereact/portal"),o=require("primereact/api");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(e),a=s(o);function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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 d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(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&&m(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 h(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 d(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function y(){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 b,k,E,x=function(o){p(x,e.Component);var s,m,f,b,k,E=(s=x,m=y(),function(){var e,t=v(s);if(m){var n=v(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return h(this,e)});function x(e){var t;return u(this,x),(t=E.call(this,e)).state={visible:!e.popup},t.onEnter=t.onEnter.bind(d(t)),t.onEntered=t.onEntered.bind(d(t)),t.onExit=t.onExit.bind(d(t)),t.onExited=t.onExited.bind(d(t)),t.onPanelClick=t.onPanelClick.bind(d(t)),t.menuRef=l.default.createRef(),t}return f=x,(b=[{key:"onPanelClick",value:function(e){this.props.popup&&r.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 n=e.nextElementSibling;return n?t.DomHandler.hasClass(n,"p-disabled")||!t.DomHandler.hasClass(n,"p-menuitem")?this.findNextItem(n):n:null}},{key:"findPrevItem",value:function(e){var n=e.previousElementSibling;return n?t.DomHandler.hasClass(n,"p-disabled")||!t.DomHandler.hasClass(n,"p-menuitem")?this.findPrevItem(n):n: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(){t.ZIndexUtils.set("menu",this.menuRef.current,a.default.autoZIndex,this.props.baseZIndex||a.default.zIndex.menu),t.DomHandler.absolutePosition(this.menuRef.current,this.target)}},{key:"onEntered",value:function(){this.bindDocumentListeners(),this.bindScrollListener()}},{key:"onExit",value:function(){this.target=null,this.unbindDocumentListener
|