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

2 lines
11 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.contextmenu=function(e,t,n,i,r,o,s){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(t),a=u(s);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(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 f(e,t,n){return t&&m(e.prototype,t),n&&m(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 p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(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&&p(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 b(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 y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e){var t=L();return function(){var n,i=y(e);if(t){var r=y(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return b(this,n)}}function L(){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){h(o,e);var t=k(o);function o(e){var n;return c(this,o),(n=t.call(this,e)).state={activeItem:null},n.onEnter=n.onEnter.bind(d(n)),n.submenuRef=l.default.createRef(),n}return f(o,[{key:"onItemMouseEnter",value:function(e,t){t.disabled?e.preventDefault():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.props.onLeafClick(e))}},{key:"position",value:function(){var e=this.submenuRef.current.parentElement,t=n.DomHandler.getOffset(this.submenuRef.current.parentElement),i=n.DomHandler.getViewport(),r=this.submenuRef.current.offsetParent?this.submenuRef.current.offsetWidth:n.DomHandler.getHiddenElementOuterWidth(this.submenuRef.current),o=n.DomHandler.getOuterWidth(e.children[0]);this.submenuRef.current.style.top="0px",this.submenuRef.current.style.left=parseInt(t.left,10)+o+r>i.width-n.DomHandler.calculateScrollbarWidth()?-1*r+"px":o+"px"}},{key:"onEnter",value:function(){this.position()}},{key:"isActive",value:function(){return this.props.root||!this.props.resetMenu}},{key:"componentDidUpdate",value:function(){this.isActive()&&this.position()}},{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(o,{model:e.items,resetMenu:e!==this.state.activeItem,onLeafClick:this.props.onLeafClick}):null}},{key:"renderMenuitem",value:function(e,t){var i=this,o=this.state.activeItem===e,s=n.classNames("p-menuitem",{"p-menuitem-active":o},e.className),u=n.classNames("p-menuitem-link",{"p-disabled":e.disabled}),a=n.classNames("p-menuitem-icon",e.icon),c="p-submenu-icon pi pi-angle-right",m=e.icon&&l.default.createElement("span",{className:a}),f=e.label&&l.default.createElement("span",{className:"p-menuitem-text"},e.label),d=e.items&&l.default.createElement("span",{className:c}),p=this.renderSubmenu(e),h=l.default.createElement("a",{href:e.url||"#",className:u,target:e.target,onClick:function(n){return i.onItemClick(n,e,t)},role:"menuitem","aria-haspopup":null!=e.items,"aria-disabled":e.disabled},m,f,d,l.default.createElement(r.Ripple,null));e.template&&(h=n.ObjectUtils.getJSXElement(e.template,e,{onClick:function(n){return i.onItemClick(n,e,t)},className:u,labelClassName:"p-menuitem-text",iconClassName:a,submenuIconClassName:c,element:h,props:this.props,active:o}));return l.default.createElement("li",{key:e.label+"_"+t,role:"none",className:s,style:e.style,onMouseEnter:function(t){return i.onItemMouseEnter(t,e)}},h,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=n.classNames({"p-submenu-list":!this.props.root}),t=this.renderMenu(),r=this.isActive();return l.default.createElement(i.CSSTransition,{nodeRef:this.submenuRef,classNames:"p-contextmenusub",in:r,timeout:{enter:0,exit:0},unmountOnExit:!0,onEnter:this.onEnter},l.default.createElement("ul",{ref:this.submenuRef,className:e},t))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return!0===e.resetMenu?{activeItem:null}:null}}]),o}(t.Component);E(C,"defaultProps",{model:null,root:!1,className:null,resetMenu:!1,onLeafClick:null});var x=function(e){h(r,e);var t=k(r);function r(e){var n;return c(this,r),(n=t.call(this,e)).state={visible:!1,reshow:!1,resetMenu:!1},n.onMenuClick=n.onMenuClick.bind(d(n)),n.onLeafClick=n.onLeafClick.bind(d(n)),n.onMenuMouseEnter=n.onMenuMouseEnter.bind(d(n)),n.onEnter=n.onEnter.bind(d(n)),n.onEntered=n.onEntered.bind(d(n)),n.onExit=n.onExit.bind(d(n)),n.onExited=n.onExited.bind(d(n)),n.menuRef=l.default.createRef(),n}return f(r,[{key:"onMenuClick",value:function(){this.setState({resetMenu:!1})}},{key:"onMenuMouseEnter",value:function(){this.setState({resetMenu:!1})}},{key:"show",value:function(e){var t=this;e instanceof Event||e.persist(),e.stopPropagation(),e.preventDefault(),this.currentEvent=e,this.state.visible?this.setState({reshow:!0}):this.setState({visible:!0},(function(){t.props.onShow&&t.props.onShow(t.currentEvent)}))}},{key:"hide",value:function(e){var t=this;e instanceof Event||e.persist(),this.currentEvent=e,this.setState({visible:!1,reshow:!1},(function(){t.props.onHide&&t.props.onHide(t.currentEvent)}))}},{key:"onEnter",value:function(){this.props.autoZIndex&&n.ZIndexUtils.set("menu",this.menuRef.current,a.default.autoZIndex,this.props.baseZIndex||a.default.zIndex.menu),this.position(this.currentEvent)}},{key:"onEntered",value:function(){this.bindDocumentListeners()}},{key:"onExit",value:function(){this.currentEvent=null,this.unbindDocumentListeners()}},{key:"onExited",value:function(){n.ZIndexUtils.clear(this.menuRef.current)}},{key:"position",value:function(e){if(e){var t=e.pageX+1,i=e.pageY+1,r=this.menuRef.current.offsetParent?this.menuRef.current.offsetWidth:n.DomHandler.getHiddenElementOuterWidth(this.menuRef.current),o=this.menuRef.current.offsetParent?this.menuRef.current.offsetHeight:n.DomHandler.getHiddenElementOuterHeight(this.menuRef.current),s=n.DomHandler.getViewport();t+r-document.body.scrollLeft>s.width&&(t-=r),i+o-document.body.scrollTop>s.height&&(i-=o),t<document.body.scrollLeft&&(t=document.body.scrollLeft),i<document.body.scrollTop&&(i=document.body.scrollTop),this.menuRef.current.style.left=t+"px",this.menuRef.current.style.top=i+"px"}}},{key:"onLeafClick",value:function(e){this.setState({resetMenu:!0}),this.hide(e),e.stopPropagation()}},{key:"isOutsideClicked",value:function(e){return this.menuRef&&this.menuRef.current&&!(this.menuRef.current.isSameNode(e.target)||this.menuRef.current.contains(e.target))}},{key:"bindDocumentListeners",value:function(){this.bindDocumentResizeListener(),this.bindDocumentClickListener()}},{key:"unbindDocumentListeners",value:function(){this.unbindDocumentResizeListener(),this.unbindDocumentClickListener()}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.isOutsideClicked(t)&&2!==t.button&&(e.hide(t),e.setState({resetMenu:!0}))},document.addEventListener("click",this.documentClickListener))}},{key:"bindDocumentContextMenuListener",value:function(){var e=this;this.documentContextMenuListener||(this.documentContextMenuListener=function(t){e.show(t)},document.addEventListener("contextmenu",this.documentContextMenuListener))}},{key:"bindDocumentResizeListener",value:function(){var e=this;this.documentResizeListener||(this.documentResizeListener=function(t){e.state.visible&&!n.DomHandler.isTouchDevice()&&e.hide(t)},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"unbindDocumentContextMenuListener",value:function(){this.documentContextMenuListener&&(document.removeEventListener("contextmenu",this.documentContextMenuListener),this.documentContextMenuListener=null)}},{key:"unbindDocumentResizeListener",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"componentDidMount",value:function(){this.props.global&&this.bindDocumentContextMenuListener()}},{key:"componentDidUpdate",value:function(e,t){var n=this;if(this.state.visible&&(t.reshow!==this.state.reshow||e.model!==this.props.model)){var i=this.currentEvent;this.setState({visible:!1,reshow:!1,rePosition:!1,resetMenu:!0},(function(){return n.show(i)}))}}},{key:"componentWillUnmount",value:function(){this.unbindDocumentListeners(),this.unbindDocumentContextMenuListener(),n.ZIndexUtils.clear(this.menuRef.current)}},{key:"renderContextMenu",value:function(){var e=n.classNames("p-contextmenu p-component",this.props.className);return l.default.createElement(i.CSSTransition,{nodeRef:this.menuRef,classNames:"p-contextmenu",in:this.state.visible,timeout:{enter:250,exit:0},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExit:this.onExit,onExited:this.onExited},l.default.createElement("div",{ref:this.menuRef,id:this.props.id,className:e,style:this.props.style,onClick:this.onMenuClick,onMouseEnter:this.onMenuMouseEnter},l.default.createElement(C,{model:this.props.model,root:!0,resetMenu:this.state.resetMenu,onLeafClick:this.onLeafClick})))}},{key:"render",value:function(){var e=this.renderContextMenu();return l.default.createElement(o.Portal,{element:e,appendTo:this.props.appendTo})}}]),r}(t.Component);return E(x,"defaultProps",{id:null,model:null,style:null,className:null,global:!1,autoZIndex:!0,baseZIndex:0,appendTo:null,transitionOptions:null,onShow:null,onHide:null}),e.ContextMenu=x,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.csstransition,primereact.ripple,primereact.portal,primereact.api);