import t,{createRef as e,Component as r}from"react";import{DomHandler as o,classNames as n,ObjectUtils as i}from"primereact/utils";import{KeyFilter as p}from"primereact/keyfilter";import{tip as l}from"primereact/tooltip";function s(){return s=Object.assign||function(t){for(var e=1;e0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&null!=this.elementRef.current.value&&this.elementRef.current.value.toString().length>0}},{key:"onKeyPress",value:function(t){this.props.onKeyPress&&this.props.onKeyPress(t),this.props.keyfilter&&p.onKeyPress(t,this.props.keyfilter,this.props.validateOnly)}},{key:"onInput",value:function(t){var e=!0;this.props.keyfilter&&this.props.validateOnly&&(e=p.validate(t,this.props.keyfilter)),this.props.onInput&&this.props.onInput(t,e),this.props.onChange||(t.target.value.length>0?o.addClass(t.target,"p-filled"):o.removeClass(t.target,"p-filled"))}},{key:"updateForwardRef",value:function(){var t=this.props.forwardRef;t&&("function"==typeof t?t(this.elementRef.current):t.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),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(O({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=l({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=n("p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled()},this.props.className),r=i.findDiffKeys(this.props,R.defaultProps);return t.createElement("input",s({ref:this.elementRef},r,{className:e,onInput:this.onInput,onKeyPress:this.onKeyPress}))}}])&&f(v.prototype,g),w&&f(v,w),Object.defineProperty(v,"prototype",{writable:!1}),R}();m(g,"defaultProps",{keyfilter:null,validateOnly:!1,tooltip:null,tooltipOptions:null,onInput:null,onKeyPress:null,forwardRef:null});var w=t.forwardRef((function(e,r){return t.createElement(g,s({forwardRef:r},e))}));export{w as InputText};