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

2 lines
12 KiB
JavaScript

import e,{Component as t}from"react";import{Button as n}from"primereact/button";import{classNames as r,ObjectUtils as i,ZIndexUtils as o,DomHandler as l,ConnectedOverlayScrollHandler as s,UniqueComponentId as a}from"primereact/utils";import{CSSTransition as u}from"primereact/csstransition";import{Portal as c}from"primereact/portal";import{tip as p}from"primereact/tooltip";import{OverlayService as f}from"primereact/overlayservice";import h from"primereact/api";function d(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 r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function y(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function k(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&&b(e,t)}function O(e){return O="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},O(e)}function E(e,t){if(t&&("object"===O(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return v(e)}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(){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 L=function(n){k(a,t);var o,l,s=(o=a,l=R(),function(){var e,t=C(o);if(l){var n=C(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return E(this,e)});function a(e){var t;return d(this,a),(t=s.call(this,e)).onClick=t.onClick.bind(v(t)),t}return y(a,[{key:"onClick",value:function(e){this.props.menuitem.command&&this.props.menuitem.command({originalEvent:e,item:this.props.menuitem}),this.props.onItemClick&&this.props.onItemClick(e),e.preventDefault()}},{key:"renderSeparator",value:function(){return e.createElement("li",{className:"p-menu-separator",role:"separator"})}},{key:"renderMenuitem",value:function(){var t=this,n=this.props.menuitem,o=n.icon,l=n.label,s=n.template,a=n.url,u=n.target,c=r("p-menuitem-link",{"p-disabled":n.disabled}),p=r("p-menuitem-icon",o),f=e.createElement("a",{href:a||"#",role:"menuitem",className:c,target:u,onClick:this.onClick},o=o&&e.createElement("span",{className:p}),l=l&&e.createElement("span",{className:"p-menuitem-text"},l));s&&(f=i.getJSXElement(s,this.props.menuitem,{onClick:function(e){return t.onClick(e)},className:c,labelClassName:"p-menuitem-text",iconClassName:p,element:f,props:this.props}));return e.createElement("li",{className:"p-menuitem",role:"none"},f)}},{key:"renderItem",value:function(){return this.props.menuitem.separator?this.renderSeparator():this.renderMenuitem()}},{key:"render",value:function(){return this.renderItem()}}]),a}();function x(){return x=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},x.apply(this,arguments)}function S(){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}}w(L,"defaultProps",{menuitem:null,onItemClick:null});var g=function(n){k(s,t);var i,o,l=(i=s,o=S(),function(){var e,t=C(i);if(o){var n=C(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return E(this,e)});function s(){return d(this,s),l.apply(this,arguments)}return y(s,[{key:"renderElement",value:function(){var t=r("p-menu p-menu-overlay p-component",this.props.menuClassName);return e.createElement(u,{nodeRef:this.props.forwardRef,classNames:"p-connected-overlay",in:this.props.in,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.props.onEnter,onEntered:this.props.onEntered,onExit:this.props.onExit,onExited:this.props.onExited},e.createElement("div",{ref:this.props.forwardRef,className:t,style:this.props.menuStyle,id:this.props.id,onClick:this.onClick},e.createElement("ul",{className:"p-menu-list p-reset",role:"menu"},this.props.children)))}},{key:"render",value:function(){var t=this.renderElement();return e.createElement(c,{element:t,appendTo:this.props.appendTo})}}]),s}();w(g,"defaultProps",{appendTo:null,menuStyle:null,menuClassName:null,id:null,onClick:null});var P=e.forwardRef((function(t,n){return e.createElement(g,x({forwardRef:n},t))}));function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach((function(t){w(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){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 D=function(u){k(O,t);var c,m,b=(c=O,m=I(),function(){var e,t=C(c);if(m){var n=C(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return E(this,e)});function O(t){var n;return d(this,O),(n=b.call(this,t)).state={id:t.id,overlayVisible:!1},n.onDropdownButtonClick=n.onDropdownButtonClick.bind(v(n)),n.onItemClick=n.onItemClick.bind(v(n)),n.onOverlayEnter=n.onOverlayEnter.bind(v(n)),n.onOverlayEntered=n.onOverlayEntered.bind(v(n)),n.onOverlayExit=n.onOverlayExit.bind(v(n)),n.onOverlayExited=n.onOverlayExited.bind(v(n)),n.onPanelClick=n.onPanelClick.bind(v(n)),n.overlayRef=e.createRef(),n}return y(O,[{key:"onPanelClick",value:function(e){f.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"onDropdownButtonClick",value:function(){this.state.overlayVisible?this.hide():this.show()}},{key:"onItemClick",value:function(){this.hide()}},{key:"show",value:function(){this.setState({overlayVisible:!0})}},{key:"hide",value:function(){this.setState({overlayVisible:!1})}},{key:"onOverlayEnter",value:function(){o.set("overlay",this.overlayRef.current,h.autoZIndex,h.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){o.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){l.alignOverlay(this.overlayRef.current,this.defaultButton.parentElement,this.props.appendTo||h.appendTo)}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hide()},document.addEventListener("click",this.documentClickListener))}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new s(this.container,(function(){e.state.overlayVisible&&e.hide()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!l.isTouchDevice()&&e.hide()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"componentDidMount",value:function(){this.state.id||this.setState({id:a()}),this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(j({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),o.clear(this.overlayRef.current)}},{key:"renderTooltip",value:function(){this.tooltip=p({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderItems",value:function(){var t=this;return this.props.model?this.props.model.map((function(n,r){return e.createElement(L,{menuitem:n,key:r,onItemClick:t.onItemClick})})):null}},{key:"render",value:function(){var t=this,o=r("p-splitbutton p-component",this.props.className,{"p-disabled":this.props.disabled}),l=r("p-splitbutton-defaultbutton",this.props.buttonClassName),s=r("p-splitbutton-menubutton",this.props.menuButtonClassName),a=this.renderItems(),u=this.props.buttonTemplate?i.getJSXElement(this.props.buttonTemplate,this.props):null;return e.createElement("div",{id:this.state.id,className:o,style:this.props.style,ref:function(e){return t.container=e}},e.createElement(n,{ref:function(e){return t.defaultButton=e},type:"button",className:l,icon:this.props.icon,label:this.props.label,onClick:this.props.onClick,disabled:this.props.disabled,tabIndex:this.props.tabIndex},u),e.createElement(n,{type:"button",className:s,icon:this.props.dropdownIcon,onClick:this.onDropdownButtonClick,disabled:this.props.disabled,"aria-expanded":this.state.overlayVisible,"aria-haspopup":!0,"aria-owns":this.state.id+"_overlay"}),e.createElement(P,{ref:this.overlayRef,appendTo:this.props.appendTo,id:this.state.id+"_overlay",menuStyle:this.props.menuStyle,menuClassName:this.props.menuClassName,onClick:this.onPanelClick,in:this.state.overlayVisible,onEnter:this.onOverlayEnter,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited,transitionOptions:this.props.transitionOptions},a))}}]),O}();w(D,"defaultProps",{id:null,label:null,icon:null,model:null,disabled:null,style:null,className:null,buttonClassName:null,menuStyle:null,menuClassName:null,menuButtonClassName:null,tabIndex:null,appendTo:null,tooltip:null,tooltipOptions:null,buttonTemplate:null,transitionOptions:null,dropdownIcon:"pi pi-chevron-down",onClick:null,onShow:null,onHide:null});export{D as SplitButton};