import{defineComponent as w,ref as s,watch as E,createVNode as d}from"vue";import V from"../_util/classNames.mjs";import W from"../_util/props-util/initDefaultProps.mjs";import F from"../_util/vue-types/index.mjs";const M={prefixCls:String,name:String,id:String,type:String,defaultChecked:{type:[Boolean,Number],default:void 0},checked:{type:[Boolean,Number],default:void 0},disabled:Boolean,tabindex:{type:[Number,String]},readonly:Boolean,autofocus:Boolean,value:F.any,required:Boolean},H=w({compatConfig:{MODE:3},name:"Checkbox",inheritAttrs:!1,props:W(M,{prefixCls:"rc-checkbox",type:"checkbox",defaultChecked:!1}),emits:["click","change"],setup(t,{attrs:i,emit:r,expose:k}){const c=s(t.checked===void 0?t.defaultChecked:t.checked),a=s();E(()=>t.checked,()=>{c.value=t.checked}),k({focus(){a.value?.focus()},blur(){a.value?.blur()}});const o=s(),b=e=>{if(t.disabled)return;t.checked===void 0&&(c.value=e.target.checked),e.shiftKey=o.value;const l={target:{...t,checked:e.target.checked},stopPropagation(){e.stopPropagation()},preventDefault(){e.preventDefault()},nativeEvent:e};t.checked!==void 0&&(a.value.checked=!!t.checked),r("change",l),o.value=!1},m=e=>{r("click",e),o.value=e.shiftKey};return()=>{const{prefixCls:e,name:l,id:p,type:g,disabled:u,readonly:v,tabindex:y,autofocus:C,value:x,required:B,...P}=t,{class:S,onFocus:K,onBlur:N,onKeydown:D,onKeypress:$,onKeyup:A}=i,f={...P,...i},O=Object.keys(f).reduce((h,n)=>((n.startsWith("data-")||n.startsWith("aria-")||n==="role")&&(h[n]=f[n]),h),{}),j=V(e,S,{[`${e}-checked`]:c.value,[`${e}-disabled`]:u}),q={name:l,id:p,type:g,readonly:v,disabled:u,tabindex:y,class:`${e}-input`,checked:!!c.value,autofocus:C,value:x,...O,onChange:b,onClick:m,onFocus:K,onBlur:N,onKeydown:D,onKeypress:$,onKeyup:A,required:B};return d("span",{class:j},[d("input",{ref:a,...q},null),d("span",{class:`${e}-inner`},null)])}}});export{M as checkboxProps,H as default};
