2 lines
5.6 KiB
JavaScript
2 lines
5.6 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),o=require("primereact/tooltip");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(t);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 u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(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&&u(t,e)}function l(t){return l="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},l(t)}function a(t,e){if(e&&("object"===l(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 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 h(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?h(Object(o),!0).forEach((function(e){d(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):h(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function y(){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(n){c(O,t.Component);var u,l,d,h,v,m=(u=O,l=y(),function(){var t,e=f(u);if(l){var o=f(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return a(this,t)});function O(e){var o;return i(this,O),(o=m.call(this,e)).state={},o.onClick=o.onClick.bind(s(o)),o.onFocus=o.onFocus.bind(s(o)),o.onBlur=o.onBlur.bind(s(o)),o.inputRef=t.createRef(o.props.inputRef),o}return d=O,(h=[{key:"select",value:function(t){this.inputRef.current.checked=!0,this.onClick(t)}},{key:"onClick",value:function(t){!this.props.disabled&&this.props.onChange&&(this.props.onChange({originalEvent:t,value:this.props.value,checked:!this.props.checked,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:this.props.value,checked:!this.props.checked}}),this.inputRef.current.checked=!this.props.checked,this.inputRef.current.focus())}},{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.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=o.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var t=this;this.inputRef&&this.inputRef.current&&(this.inputRef.current.checked=this.props.checked);var o=e.classNames("p-radiobutton p-component",{"p-radiobutton-checked":this.props.checked,"p-radiobutton-disabled":this.props.disabled,"p-radiobutton-focused":this.state.focused},this.props.className),n=e.classNames("p-radiobutton-box",{"p-highlight":this.props.checked,"p-disabled":this.props.disabled,"p-focus":this.state.focused});return r.default.createElement("div",{ref:function(e){return t.element=e},id:this.props.id,className:o,style:this.props.style,onClick:this.onClick},r.default.createElement("div",{className:"p-hidden-accessible"},r.default.createElement("input",{ref:this.inputRef,id:this.props.inputId,type:"radio","aria-labelledby":this.props.ariaLabelledBy,name:this.props.name,defaultChecked:this.props.checked,onFocus:this.onFocus,onBlur:this.onBlur,disabled:this.props.disabled,required:this.props.required,tabIndex:this.props.tabIndex})),r.default.createElement("div",{className:n,ref:function(e){t.box=e},role:"radio","aria-checked":this.props.checked},r.default.createElement("div",{className:"p-radiobutton-icon"})))}}])&&p(d.prototype,h),v&&p(d,v),Object.defineProperty(d,"prototype",{writable:!1}),O}();d(v,"defaultProps",{id:null,inputRef:null,inputId:null,name:null,value:null,checked:!1,style:null,className:null,disabled:!1,required:!1,tabIndex:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null}),exports.RadioButton=v;
|