import{defineComponent as x,ref as E,computed as N,createVNode as s}from"vue";import f from"../../../_util/KeyCode.mjs";import P from"../../../_util/classNames.mjs";const h=x({compatConfig:{MODE:3},name:"TabNode",props:{id:{type:String},prefixCls:{type:String},tab:{type:Object},active:{type:Boolean},closable:{type:Boolean},editable:{type:Object},onClick:{type:Function},onResize:{type:Function},renderWrapper:{type:Function},removeAriaLabel:{type:String},onFocus:{type:Function}},emits:["click","resize","remove","focus"],setup(t,{expose:y,attrs:v}){const d=E();function i(o){t.tab?.disabled||t.onClick(o)}y({domRef:d});function C(o){o.preventDefault(),o.stopPropagation(),t.editable.onEdit("remove",{key:t.tab?.key,event:o})}const b=N(()=>t.editable&&t.closable!==!1&&!t.tab?.disabled);return()=>{const{prefixCls:o,id:n,active:u,tab:{key:l,tab:r,disabled:c,closeIcon:k},renderWrapper:p,removeAriaLabel:$,editable:g,onFocus:F}=t,a=`${o}-tab`,m=s("div",{key:l,ref:d,class:P(a,{[`${a}-with-remove`]:b.value,[`${a}-active`]:u,[`${a}-disabled`]:c}),style:v.style,onClick:i},[s("div",{role:"tab","aria-selected":u,id:n&&`${n}-tab-${l}`,class:`${a}-btn`,"aria-controls":n&&`${n}-panel-${l}`,"aria-disabled":c,tabindex:c?null:0,onClick:e=>{e.stopPropagation(),i(e)},onKeydown:e=>{[f.SPACE,f.ENTER].includes(e.which)&&(e.preventDefault(),i(e))},onFocus:F},[typeof r=="function"?r():r]),b.value&&s("button",{type:"button","aria-label":$||"remove",tabindex:0,class:`${a}-remove`,onClick:e=>{e.stopPropagation(),C(e)}},[k?.()||g.removeIcon?.()||"×"])]);return p?p(m):m}}});export{h as default};
