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

2 lines
6.0 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),o=require("primereact/tooltip");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e);function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(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&&u(e,t)}function l(e){return l="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},l(e)}function a(e,t){if(t&&("object"===l(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function h(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function d(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function y(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?d(Object(o),!0).forEach((function(t){h(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):d(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,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(n){c(m,e.Component);var u,l,h,d,v,k=(u=m,l=b(),function(){var e,t=f(u);if(l){var o=f(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return a(this,e)});function m(t){var o;return i(this,m),(o=k.call(this,t)).state={focused:!1},o.onClick=o.onClick.bind(p(o)),o.onFocus=o.onFocus.bind(p(o)),o.onBlur=o.onBlur.bind(p(o)),o.onKeyDown=o.onKeyDown.bind(p(o)),o.inputRef=e.createRef(o.props.inputRef),o}return h=m,(d=[{key:"onClick",value:function(e){if(!this.props.disabled&&!this.props.readOnly&&this.props.onChange){var t=this.isChecked()?this.props.falseValue:this.props.trueValue;this.props.onChange({originalEvent:e,value:this.props.value,checked:t,stopPropagation:function(){},preventDefault:function(){},target:{type:"checkbox",name:this.props.name,id:this.props.id,value:this.props.value,checked:t}}),this.inputRef.current.checked=!this.isChecked(),this.inputRef.current.focus(),e.preventDefault()}}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.props.tooltip&&this.renderTooltip()}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"componentDidUpdate",value:function(e){this.inputRef.current.checked=this.isChecked(),e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(y({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"onFocus",value:function(){this.setState({focused:!0})}},{key:"onBlur",value:function(){this.setState({focused:!1})}},{key:"onKeyDown",value:function(e){"Enter"===e.key&&(this.onClick(e),e.preventDefault())}},{key:"renderTooltip",value:function(){this.tooltip=o.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"isChecked",value:function(){return this.props.checked===this.props.trueValue}},{key:"render",value:function(){var e=this,o=this.isChecked(),n=t.classNames("p-checkbox p-component",{"p-checkbox-checked":o,"p-checkbox-disabled":this.props.disabled,"p-checkbox-focused":this.state.focused},this.props.className),i=t.classNames("p-checkbox-box",{"p-highlight":o,"p-disabled":this.props.disabled,"p-focus":this.state.focused}),s=o&&this.props.icon;return r.default.createElement("div",{ref:function(t){return e.element=t},id:this.props.id,className:n,style:this.props.style,onClick:this.onClick,onContextMenu:this.props.onContextMenu,onMouseDown:this.props.onMouseDown},r.default.createElement("div",{className:"p-hidden-accessible"},r.default.createElement("input",{ref:this.inputRef,type:"checkbox","aria-labelledby":this.props.ariaLabelledBy,id:this.props.inputId,name:this.props.name,tabIndex:this.props.tabIndex,defaultChecked:o,onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,disabled:this.props.disabled,readOnly:this.props.readOnly,required:this.props.required})),r.default.createElement("div",{className:i,ref:function(t){return e.box=t},role:"checkbox","aria-checked":o},t.IconUtils.getJSXIcon(s,{className:"p-checkbox-icon p-c"},{props:this.props,checked:o})))}}])&&s(h.prototype,d),v&&s(h,v),Object.defineProperty(h,"prototype",{writable:!1}),m}();h(v,"defaultProps",{id:null,inputRef:null,inputId:null,value:null,name:null,checked:!1,trueValue:!0,falseValue:!1,style:null,className:null,disabled:!1,required:!1,readOnly:!1,tabIndex:null,icon:"pi pi-check",tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null,onMouseDown:null,onContextMenu:null}),exports.Checkbox=v;