BHXyHhK1.js
1.69 KB
import{a as b}from"./3laQJA1P.js";import{d as y,aA as I,L as g,ap as F,o as w,k as K,w as l,f as S,g as r,P as h,x as C,s as u,ak as T}from"./BtEn9SvP.js";import{i as k,g as q,w as x,f as B}from"./DYcig7R4.js";var R=y({__name:"RovingFocusItem",props:{tabStopId:{type:String,required:!1},focusable:{type:Boolean,required:!1,default:!0},active:{type:Boolean,required:!1},allowShiftKey:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(d){const n=d,a=k(),f=b(),i=u(()=>n.tabStopId||f),c=u(()=>a.currentTabStopId.value===i.value),{getItems:p,CollectionItem:m}=I();g(()=>{n.focusable&&a.onFocusableItemAdd()}),F(()=>{n.focusable&&a.onFocusableItemRemove()});function v(e){if(e.key==="Tab"&&e.shiftKey){a.onItemShiftTab();return}if(e.target!==e.currentTarget)return;const t=q(e,a.orientation.value,a.dir.value);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||!n.allowShiftKey&&e.shiftKey)return;e.preventDefault();let o=[...p().map(s=>s.ref).filter(s=>s.dataset.disabled!=="")];if(t==="last")o.reverse();else if(t==="prev"||t==="next"){t==="prev"&&o.reverse();const s=o.indexOf(e.currentTarget);o=a.loop.value?x(o,s+1):o.slice(s+1)}T(()=>B(o))}}return(e,t)=>(w(),K(r(m),null,{default:l(()=>[S(r(h),{tabindex:c.value?0:-1,"data-orientation":r(a).orientation.value,"data-active":e.active?"":void 0,"data-disabled":e.focusable?void 0:"",as:e.as,"as-child":e.asChild,onMousedown:t[0]||(t[0]=o=>{e.focusable?r(a).onItemFocus(i.value):o.preventDefault()}),onFocus:t[1]||(t[1]=o=>r(a).onItemFocus(i.value)),onKeydown:v},{default:l(()=>[C(e.$slots,"default")]),_:3},8,["tabindex","data-orientation","data-active","data-disabled","as","as-child"])]),_:3}))}}),M=R;export{M as R};