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

2 lines
5.4 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.togglebutton=function(t,e,o,n,r){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var p=i(e);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 n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function a(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&&u(t,e)}function f(t){return f="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},f(t)}function h(t,e){if(e&&("object"===f(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}function y(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function d(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function g(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?d(Object(o),!0).forEach((function(e){y(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):d(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function m(){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 v=function(t){a(v,t);var e,i,u,f,y,d=(e=v,i=m(),function(){var t,o=b(e);if(i){var n=b(this).constructor;t=Reflect.construct(o,arguments,n)}else t=o.apply(this,arguments);return h(this,t)});function v(t){var e;return s(this,v),(e=d.call(this,t)).toggle=e.toggle.bind(c(e)),e.onKeyDown=e.onKeyDown.bind(c(e)),e}return u=v,(f=[{key:"toggle",value:function(t){!this.props.disabled&&this.props.onChange&&this.props.onChange({originalEvent:t,value:!this.props.checked,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:!this.props.checked}})}},{key:"onKeyDown",value:function(t){"Enter"===t.key&&(this.toggle(t),t.preventDefault())}},{key:"hasLabel",value:function(){return this.props.onLabel&&this.props.onLabel.length>0&&this.props.offLabel&&this.props.offLabel.length>0}},{key:"hasIcon",value:function(){return this.props.onIcon&&this.props.onIcon.length>0&&this.props.offIcon&&this.props.offIcon.length>0}},{key:"getLabel",value:function(){return this.hasLabel()?this.props.checked?this.props.onLabel:this.props.offLabel:"&nbsp;"}},{key:"componentDidMount",value:function(){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(g({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=n.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var t=this,e=o.classNames("p-button p-togglebutton p-component",{"p-button-icon-only":this.hasIcon()&&!this.hasLabel(),"p-highlight":this.props.checked,"p-disabled":this.props.disabled},this.props.className),n=null,i=this.hasIcon(),s=this.getLabel(),l=this.props.checked?this.props.onIcon:this.props.offIcon;return i&&(n=o.classNames("p-button-icon p-c",{"p-button-icon-left":"left"===this.props.iconPos&&s,"p-button-icon-right":"right"===this.props.iconPos&&s})),p.default.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:e,style:this.props.style,onClick:this.toggle,onFocus:this.props.onFocus,onBlur:this.props.onBlur,onKeyDown:this.onKeyDown,tabIndex:!this.props.disabled&&this.props.tabIndex,"aria-labelledby":this.props.ariaLabelledBy},i&&o.IconUtils.getJSXIcon(l,{className:n},{props:this.props}),p.default.createElement("span",{className:"p-button-label"},s),p.default.createElement(r.Ripple,null))}}])&&l(u.prototype,f),y&&l(u,y),Object.defineProperty(u,"prototype",{writable:!1}),v}(e.Component);return y(v,"defaultProps",{id:null,onIcon:null,offIcon:null,onLabel:"Yes",offLabel:"No",iconPos:"left",style:null,className:null,checked:!1,tabIndex:0,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null,onFocus:null,onBlur:null}),t.ToggleButton=v,Object.defineProperty(t,"__esModule",{value:!0}),t}({},React,primereact.utils,primereact.tooltip,primereact.ripple);