2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/ripple"),i=require("primereact/csstransition"),r=require("primereact/overlayservice"),o=require("primereact/portal"),s=require("primereact/api");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(e),a=l(s);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(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 m(e,t,n){return t&&p(e.prototype,t),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(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 h(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 v(e){return v="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},v(e)}function y(e,t){if(t&&("object"===v(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 b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(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 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 C=function(i){h(l,e.Component);var r,o,s=(r=l,o=E(),function(){var e,t=b(r);if(o){var n=b(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return y(this,e)});function l(e){var t;return c(this,l),(t=s.call(this,e)).state={activeItem:null},t.onLeafClick=t.onLeafClick.bind(d(t)),t.onChildItemKeyDown=t.onChildItemKeyDown.bind(d(t)),t}return m(l,[{key:"componentDidUpdate",value:function(e){e.parentActive&&!this.props.parentActive&&this.setState({activeItem:null}),this.props.parentActive&&!this.props.root&&this.position()}},{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:"componentWillUnmount",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"position",value:function(){if(this.element){var e=this.element.parentElement,n=t.DomHandler.getOffset(e),i=t.DomHandler.getViewport(),r=this.element.offsetParent?this.element.offsetWidth:t.DomHandler.getHiddenElementOuterWidth(this.element),o=t.DomHandler.getOuterWidth(e.children[0]);parseInt(n.left,10)+o+r>i.width-t.DomHandler.calculateScrollbarWidth()&&t.DomHandler.addClass(this.element,"p-submenu-list-flipped")}}},{key:"onItemMouseEnter",value:function(e,t){t.disabled?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}),this.props.root&&t.items&&this.setState(this.state.activeItem&&t===this.state.activeItem?{activeItem:null}:{activeItem:t}),t.items||this.onLeafClick())}},{key:"onItemKeyDown",value:
|