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

2 lines
9.0 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/button"),i=require("primereact/ripple"),n=require("primereact/utils");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(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&&c(e,t)}function u(e){return u="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},u(e)}function f(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function y(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?m(Object(i),!0).forEach((function(t){h(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):m(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function b(){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 v=function(r){p(O,e.Component);var c,u,m,v,k,C=(c=O,u=b(),function(){var e,t=d(c);if(u){var i=d(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return f(this,e)});function O(e){var t;return s(this,O),(t=C.call(this,e)).state={visible:!1},t.onClick=t.onClick.bind(a(t)),t.onItemClick=t.onItemClick.bind(a(t)),t}return m=O,v=[{key:"isVisible",value:function(){return this.props.onVisibleChange?this.props.visible:this.state.visible}},{key:"show",value:function(){this.props.onVisibleChange?this.props.onVisibleChange(!0):this.setState({visible:!0}),this.props.onShow&&this.props.onShow()}},{key:"hide",value:function(){this.props.onVisibleChange?this.props.onVisibleChange(!1):this.setState({visible:!1}),this.props.onHide&&this.props.onHide()}},{key:"onClick",value:function(e){this.isVisible()?this.hide():this.show(),this.props.onClick&&this.props.onClick(e),this.isItemClicked=!0}},{key:"onItemClick",value:function(e,t){t.command&&t.command({originalEvent:e,item:t}),this.hide(),this.isItemClicked=!0,e.preventDefault()}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.isVisible()&&e.isOutsideClicked(t)&&e.hide(),e.isItemClicked=!1},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.container.isSameNode(e.target)||this.container.contains(e.target)||this.isItemClicked)}},{key:"calculateTransitionDelay",value:function(e){var t=this.props.model.length;return(this.isVisible()?e:t-e-1)*this.props.transitionDelay}},{key:"calculatePointStyle",value:function(e){var t=this.props.type;if("linear"!==t){var i=this.props.model.length,n=this.props.radius||20*i;if("circle"===t){var r=2*Math.PI/i;return{left:"calc(".concat(n*Math.cos(r*e),"px + var(--item-diff-x, 0px))"),top:"calc(".concat(n*Math.sin(r*e),"px + var(--item-diff-y, 0px))")}}if("semi-circle"===t){var o=this.props.direction,s=Math.PI/(i-1),l="calc(".concat(n*Math.cos(s*e),"px + var(--item-diff-x, 0px))"),a="calc(".concat(n*Math.sin(s*e),"px + var(--item-diff-y, 0px))");if("up"===o)return{left:l,bottom:a};if("down"===o)return{left:l,top:a};if("left"===o)return{right:a,top:l};if("right"===o)return{left:a,top:l}}else if("quarter-circle"===t){var c=this.props.direction,p=Math.PI/(2*(i-1)),u="calc(".concat(n*Math.cos(p*e),"px + var(--item-diff-x, 0px))"),f="calc(".concat(n*Math.sin(p*e),"px + var(--item-diff-y, 0px))");if("up-left"===c)return{right:u,bottom:f};if("up-right"===c)return{left:u,bottom:f};if("down-left"===c)return{right:f,top:u};if("down-right"===c)return{left:f,top:u}}}return{}}},{key:"getItemStyle",value:function(e){var t=this.calculateTransitionDelay(e),i=this.calculatePointStyle(e);return y({transitionDelay:"".concat(t,"ms")},i)}},{key:"componentDidMount",value:function(){if("linear"!==this.props.type){var e=n.DomHandler.findSingle(this.container,".p-speeddial-button"),t=n.DomHandler.findSingle(this.list,".p-speeddial-item");if(e&&t){var i=Math.abs(e.offsetWidth-t.offsetWidth),r=Math.abs(e.offsetHeight-t.offsetHeight);this.list.style.setProperty("--item-diff-x","".concat(i/2,"px")),this.list.style.setProperty("--item-diff-y","".concat(r/2,"px"))}}this.props.hideOnClickOutside&&this.bindDocumentClickListener()}},{key:"componentWillUnmount",value:function(){this.props.hideOnClickOutside&&this.unbindDocumentClickListener()}},{key:"renderItem",value:function(e,t){var r=this,s=this.getItemStyle(t),l=e.icon,a=e.label,c=e.template,p=e.url,u=e.target,f=n.classNames("p-speeddial-action",{"p-disabled":e.disabled}),d=n.classNames("p-speeddial-action-icon",l),h=o.default.createElement("a",{href:p||"#",role:"menuitem",className:f,target:u,"data-pr-tooltip":a,onClick:function(t){return r.onItemClick(t,e)}},l&&o.default.createElement("span",{className:d}),o.default.createElement(i.Ripple,null));if(c){var m={onClick:function(t){return r.onItemClick(t,e)},className:f,iconClassName:d,element:h,props:this.props,visible:this.isVisible()};h=n.ObjectUtils.getJSXElement(c,e,m)}return o.default.createElement("li",{key:t,className:"p-speeddial-item",style:s,role:"none"},h)}},{key:"renderItems",value:function(){var e=this;return this.props.model?this.props.model.map((function(t,i){return e.renderItem(t,i)})):null}},{key:"renderList",value:function(){var e=this,t=this.renderItems();return o.default.createElement("ul",{ref:function(t){return e.list=t},className:"p-speeddial-list",role:"menu"},t)}},{key:"renderButton",value:function(){var e,i=this,r=this.isVisible(),s=n.classNames("p-speeddial-button p-button-rounded",{"p-speeddial-rotate":this.props.rotateAnimation&&!this.props.hideIcon},this.props.buttonClassName),l=n.classNames((h(e={},"".concat(this.props.showIcon),!r&&!!this.props.showIcon||!this.props.hideIcon),h(e,"".concat(this.props.hideIcon),r&&!!this.props.hideIcon),e)),a=o.default.createElement(t.Button,{type:"button",style:this.props.buttonStyle,className:s,icon:l,onClick:this.onClick,disabled:this.props.disabled});return this.props.buttonTemplate?n.ObjectUtils.getJSXElement(this.props.buttonTemplate,{onClick:function(e){return i.onClick(e)},className:s,iconClassName:l,element:a,props:this.props,visible:r}):a}},{key:"renderMask",value:function(){if(this.props.mask){var e=this.isVisible(),t=n.classNames("p-speeddial-mask",{"p-speeddial-mask-visible":e},this.props.maskClassName);return o.default.createElement("div",{className:t,style:this.props.maskStyle})}return null}},{key:"render",value:function(){var e,t=this,i=n.classNames("p-speeddial p-component p-speeddial-".concat(this.props.type),(h(e={},"p-speeddial-direction-".concat(this.props.direction),"circle"!==this.props.type),h(e,"p-speeddial-opened",this.isVisible()),h(e,"p-disabled",this.props.disabled),e),this.props.className),r=this.renderButton(),s=this.renderList(),l=this.renderMask();return o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:i,style:this.props.style},r,s),l)}}],v&&l(m.prototype,v),k&&l(m,k),Object.defineProperty(m,"prototype",{writable:!1}),O}();h(v,"defaultProps",{id:null,model:null,visible:!1,style:null,className:null,direction:"up",transitionDelay:30,type:"linear",radius:0,mask:!1,disabled:!1,hideOnClickOutside:!0,buttonStyle:null,buttonClassName:null,buttonTemplate:null,maskStyle:null,maskClassName:null,showIcon:"pi pi-plus",hideIcon:null,rotateAnimation:!0,onVisibleChange:null,onClick:null,onShow:null,onHide:null}),exports.SpeedDial=v;