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

2 lines
5.9 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.inputswitch=function(t,e,o,n){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=r(e);function u(){return u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},u.apply(this,arguments)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function p(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 l(t,e){return l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},l(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&&l(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 y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},y(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 b(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 v(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?b(Object(o),!0).forEach((function(e){d(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):b(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 O=function(t){a(g,t);var r,l,f,d,b,O=(r=g,l=m(),function(){var t,e=y(r);if(l){var o=y(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return h(this,t)});function g(t){var o;return s(this,g),(o=O.call(this,t)).state={focused:!1},o.onClick=o.onClick.bind(c(o)),o.toggle=o.toggle.bind(c(o)),o.onFocus=o.onFocus.bind(c(o)),o.onBlur=o.onBlur.bind(c(o)),o.onKeyDown=o.onKeyDown.bind(c(o)),o.inputRef=e.createRef(o.props.inputRef),o}return f=g,(d=[{key:"onClick",value:function(t){this.props.disabled||(this.toggle(t),this.inputRef.current.focus(),t.preventDefault())}},{key:"toggle",value:function(t){if(this.props.onChange){var e=this.isChecked()?this.props.falseValue:this.props.trueValue;this.props.onChange({originalEvent:t,value:e,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:e}})}}},{key:"onFocus",value:function(t){var e=this,o=t;this.setState({focused:!0},(function(){e.props.onFocus&&e.props.onFocus(o)}))}},{key:"onBlur",value:function(t){var e=this,o=t;this.setState({focused:!1},(function(){e.props.onBlur&&e.props.onBlur(o)}))}},{key:"onKeyDown",value:function(t){"Enter"===t.key&&this.onClick(t)}},{key:"updateInputRef",value:function(){var t=this.props.inputRef;t&&("function"==typeof t?t(this.inputRef.current):t.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),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(v({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:"isChecked",value:function(){return this.props.checked===this.props.trueValue}},{key:"render",value:function(){var t=this,e=this.isChecked(),n=o.classNames("p-inputswitch p-component",{"p-inputswitch-checked":e,"p-disabled":this.props.disabled,"p-inputswitch-focus":this.state.focused},this.props.className),r=o.ObjectUtils.findDiffKeys(this.props,g.defaultProps);return i.default.createElement("div",u({ref:function(e){return t.container=e},id:this.props.id,className:n,style:this.props.style,onClick:this.onClick,role:"checkbox","aria-checked":e},r),i.default.createElement("div",{className:"p-hidden-accessible"},i.default.createElement("input",{ref:this.inputRef,type:"checkbox",id:this.props.inputId,name:this.props.name,checked:e,onChange:this.toggle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,disabled:this.props.disabled,role:"switch","aria-checked":e,"aria-labelledby":this.props.ariaLabelledBy})),i.default.createElement("span",{className:"p-inputswitch-slider"}))}}])&&p(f.prototype,d),b&&p(f,b),Object.defineProperty(f,"prototype",{writable:!1}),g}(e.Component);return d(O,"defaultProps",{id:null,inputRef:null,style:null,className:null,inputId:null,name:null,checked:!1,trueValue:!0,falseValue:!1,disabled:!1,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null,onFocus:null,onBlur:null}),t.InputSwitch=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({},React,primereact.utils,primereact.tooltip);