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

2 lines
6.0 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),o=require("primereact/tooltip"),r=require("primereact/ripple");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=n(t);function p(){return p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t},p.apply(this,arguments)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function a(t,e){return a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},a(t,e)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function b(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function d(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function y(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,r)}return o}function m(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?y(Object(o),!0).forEach((function(e){d(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function g(){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(t){return!1}}var O=function(n){c(P,t.Component);var a,u,f,y,O,v=(a=P,u=g(),function(){var t,e=h(a);if(u){var o=h(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return b(this,t)});function P(e){var o;return s(this,P),(o=v.call(this,e)).elementRef=t.createRef(o.props.forwardRef),o}return f=P,(y=[{key:"updateForwardRef",value:function(){var t=this.props.forwardRef;t&&("function"==typeof t?t(this.elementRef.current):t.current=this.elementRef.current)}},{key:"isDisabled",value:function(){return this.props.disabled||this.props.loading}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(t){t.tooltip===this.props.tooltip&&t.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(m({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=o.tip({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderIcon",value:function(){var t=this.props.loading?this.props.loadingIcon:this.props.icon,o=e.classNames("p-button-icon p-c",{"p-button-loading-icon":this.props.loading,"p-button-icon-left":"left"===this.props.iconPos&&this.props.label,"p-button-icon-right":"right"===this.props.iconPos&&this.props.label,"p-button-icon-top":"top"===this.props.iconPos&&this.props.label,"p-button-icon-bottom":"bottom"===this.props.iconPos&&this.props.label});return e.IconUtils.getJSXIcon(t,{className:o},{props:this.props})}},{key:"renderLabel",value:function(){return this.props.label?i.default.createElement("span",{className:"p-button-label p-c"},this.props.label):!this.props.children&&!this.props.label&&i.default.createElement("span",{className:"p-button-label p-c",dangerouslySetInnerHTML:{__html:"&nbsp;"}})}},{key:"renderBadge",value:function(){if(this.props.badge){var t=e.classNames("p-badge",this.props.badgeClassName);return i.default.createElement("span",{className:t},this.props.badge)}return null}},{key:"render",value:function(){var t=this.isDisabled(),o=e.classNames("p-button p-component",this.props.className,d({"p-button-icon-only":(this.props.icon||this.props.loading&&this.props.loadingIcon)&&!this.props.label,"p-button-vertical":("top"===this.props.iconPos||"bottom"===this.props.iconPos)&&this.props.label,"p-disabled":t,"p-button-loading":this.props.loading,"p-button-loading-label-only":this.props.loading&&!this.props.icon&&this.props.label},"p-button-loading-".concat(this.props.iconPos),this.props.loading&&this.props.loadingIcon&&this.props.label)),n=this.renderIcon(),s=this.renderLabel(),l=this.renderBadge(),a=e.ObjectUtils.findDiffKeys(this.props,P.defaultProps);return i.default.createElement("button",p({ref:this.elementRef},a,{className:o,disabled:t}),n,s,this.props.children,l,i.default.createElement(r.Ripple,null))}}])&&l(f.prototype,y),O&&l(f,O),Object.defineProperty(f,"prototype",{writable:!1}),P}();d(O,"defaultProps",{label:null,icon:null,iconPos:"left",badge:null,badgeClassName:null,tooltip:null,tooltipOptions:null,forwardRef:null,disabled:!1,loading:!1,loadingIcon:"pi pi-spinner pi-spin"}),exports.Button=i.default.forwardRef((function(t,e){return i.default.createElement(O,p({forwardRef:e},t))})),exports.ButtonComponent=O;