import{defineComponent as S,createVNode as c}from"vue";import $ from"@ant-design/icons-vue/CloseCircleFilled";import m from"../_util/classNames.mjs";import{getStatusClassNames as A,getMergedStatus as F}from"../_util/statusUtils.mjs";import{anyType as t,tuple as T}from"../_util/type.mjs";import{cloneElement as y}from"../_util/vnode.mjs";import v from"../_util/vue-types/index.mjs";import{FormItemInputContext as N}from"../form/FormItemContext.mjs";import{hasAddon as M}from"./util.mjs";const k=["text","input"],P=S({compatConfig:{MODE:3},name:"ClearableLabeledInput",inheritAttrs:!1,props:{prefixCls:String,inputType:v.oneOf(T("text","input")),value:t(),defaultValue:t(),allowClear:{type:Boolean,default:void 0},element:t(),handleReset:Function,disabled:{type:Boolean,default:void 0},direction:{type:String},size:{type:String},suffix:t(),prefix:t(),addonBefore:t(),addonAfter:t(),readonly:{type:Boolean,default:void 0},focused:{type:Boolean,default:void 0},bordered:{type:Boolean,default:!0},triggerFocus:{type:Function},hidden:Boolean,status:String,hashId:String},setup(r,{slots:d,attrs:l}){const b=N.useInject(),h=e=>{const{value:n,disabled:a,readonly:s,handleReset:i,suffix:u=d.suffix}=r,f=!a&&!s&&n,o=`${e}-clear-icon`;return c($,{onClick:i,onMousedown:p=>p.preventDefault(),class:m({[`${o}-hidden`]:!f,[`${o}-has-suffix`]:!!u},o),role:"button"},null)},x=(e,n)=>{const{value:a,allowClear:s,direction:i,bordered:u,hidden:f,status:o,addonAfter:p=d.addonAfter,addonBefore:C=d.addonBefore,hashId:g}=r,{status:I,hasFeedback:w}=b;if(!s)return y(n,{value:a,disabled:r.disabled});const B=m(`${e}-affix-wrapper`,`${e}-affix-wrapper-textarea-with-clear-btn`,A(`${e}-affix-wrapper`,F(I,o),w),{[`${e}-affix-wrapper-rtl`]:i==="rtl",[`${e}-affix-wrapper-borderless`]:!u,[`${l.class}`]:!M({addonAfter:p,addonBefore:C})&&l.class},g);return c("span",{class:B,style:l.style,hidden:f},[y(n,{style:null,value:a,disabled:r.disabled}),h(e)])};return()=>{const{prefixCls:e,inputType:n,element:a=d.element?.()}=r;return n===k[0]?x(e,a):null}}});export{P as default};
