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

2 lines
5.2 KiB
JavaScript

import t,{createRef as e,Component as o}from"react";import{classNames as n}from"primereact/utils";import{tip as r}from"primereact/tooltip";function i(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 s(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 u(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 c(t){return c="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},c(t)}function a(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function h(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 n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function b(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){h(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 d(){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(l){u(g,o);var c,h,y,v,m,O=(c=g,h=d(),function(){var t,e=f(c);if(h){var o=f(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return a(this,t)});function g(t){var o;return i(this,g),(o=O.call(this,t)).state={focused:!1},o.onClick=o.onClick.bind(s(o)),o.onFocus=o.onFocus.bind(s(o)),o.onBlur=o.onBlur.bind(s(o)),o.inputRef=e(o.props.inputRef),o}return y=g,(v=[{key:"onClick",value:function(t){this.props.disabled||(this.toggle(t),this.inputRef.current.focus())}},{key:"toggle",value:function(t){var e;null==this.props.value?e=!0:!0===this.props.value?e=!1:!1===this.props.value&&(e=null),this.props.onChange&&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(){this.setState({focused:!0})}},{key:"onBlur",value:function(){this.setState({focused:!1})}},{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.props.disabled&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(t){t.tooltip===this.props.tooltip&&t.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(b({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=r({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=this,o=n("p-tristatecheckbox p-checkbox p-component",this.props.className),r=n("p-checkbox-box",{"p-highlight":(this.props.value||!this.props.value)&&null!==this.props.value,"p-disabled":this.props.disabled,"p-focus":this.state.focused}),i=n("p-checkbox-icon p-c",{"pi pi-check":!0===this.props.value,"pi pi-times":!1===this.props.value});return t.createElement("div",{ref:function(t){return e.element=t},id:this.props.id,className:o,style:this.props.style,onClick:this.onClick},t.createElement("div",{className:"p-hidden-accessible"},t.createElement("input",{ref:this.inputRef,type:"checkbox","aria-labelledby":this.props.ariaLabelledBy,id:this.props.inputId,name:this.props.name,onFocus:this.onFocus,onBlur:this.onBlur,disabled:this.props.disabled,defaultChecked:this.props.value})),t.createElement("div",{className:r,ref:function(t){return e.box=t},role:"checkbox","aria-checked":!0===this.props.value},t.createElement("span",{className:i})))}}])&&p(y.prototype,v),m&&p(y,m),Object.defineProperty(y,"prototype",{writable:!1}),g}();h(v,"defaultProps",{id:null,inputRef:null,inputId:null,value:null,name:null,style:null,className:null,disabled:!1,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null});export{v as TriStateCheckbox};