{"version":3,"file":"RovingFocusItem-KJzjmg06.js","sources":["../../node_modules/reka-ui/dist/RovingFocus/RovingFocusItem.js"],"sourcesContent":["import { defineComponent, computed, onMounted, onUnmounted, openBlock, createBlock, unref, withCtx, createVNode, renderSlot, nextTick } from 'vue';\nimport { g as getFocusIntent, w as wrapArray, f as focusFirst } from './utils.js';\nimport { u as useCollection } from '../Collection/Collection.js';\nimport { i as injectRovingFocusGroupContext } from './RovingFocusGroup.js';\nimport { u as useId } from '../shared/useId.js';\nimport { P as Primitive } from '../Primitive/Primitive.js';\n\nconst _sfc_main = /* @__PURE__ */ defineComponent({\n __name: \"RovingFocusItem\",\n props: {\n tabStopId: {},\n focusable: { type: Boolean, default: true },\n active: { type: Boolean, default: true },\n allowShiftKey: { type: Boolean },\n asChild: { type: Boolean },\n as: { default: \"span\" }\n },\n setup(__props) {\n const props = __props;\n const context = injectRovingFocusGroupContext();\n const randomId = useId();\n const id = computed(() => props.tabStopId || randomId);\n const isCurrentTabStop = computed(\n () => context.currentTabStopId.value === id.value\n );\n const { getItems, CollectionItem } = useCollection();\n onMounted(() => {\n if (props.focusable)\n context.onFocusableItemAdd();\n });\n onUnmounted(() => {\n if (props.focusable)\n context.onFocusableItemRemove();\n });\n function handleKeydown(event) {\n if (event.key === \"Tab\" && event.shiftKey) {\n context.onItemShiftTab();\n return;\n }\n if (event.target !== event.currentTarget)\n return;\n const focusIntent = getFocusIntent(\n event,\n context.orientation.value,\n context.dir.value\n );\n if (focusIntent !== undefined) {\n if (event.metaKey || event.ctrlKey || event.altKey || (props.allowShiftKey ? false : event.shiftKey))\n return;\n event.preventDefault();\n let candidateNodes = [...getItems().map((i) => i.ref).filter((i) => i.dataset.disabled !== \"\")];\n if (focusIntent === \"last\") {\n candidateNodes.reverse();\n } else if (focusIntent === \"prev\" || focusIntent === \"next\") {\n if (focusIntent === \"prev\")\n candidateNodes.reverse();\n const currentIndex = candidateNodes.indexOf(\n event.currentTarget\n );\n candidateNodes = context.loop.value ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);\n }\n nextTick(() => focusFirst(candidateNodes));\n }\n }\n return (_ctx, _cache) => {\n return openBlock(), createBlock(unref(CollectionItem), null, {\n default: withCtx(() => [\n createVNode(unref(Primitive), {\n tabindex: isCurrentTabStop.value ? 0 : -1,\n \"data-orientation\": unref(context).orientation.value,\n \"data-active\": _ctx.active,\n \"data-disabled\": !_ctx.focusable ? \"\" : undefined,\n as: _ctx.as,\n \"as-child\": _ctx.asChild,\n onMousedown: _cache[0] || (_cache[0] = (event) => {\n if (!_ctx.focusable) event.preventDefault();\n else unref(context).onItemFocus(id.value);\n }),\n onFocus: _cache[1] || (_cache[1] = ($event) => unref(context).onItemFocus(id.value)),\n onKeydown: handleKeydown\n }, {\n default: withCtx(() => [\n renderSlot(_ctx.$slots, \"default\")\n ]),\n _: 3\n }, 8, [\"tabindex\", \"data-orientation\", \"data-active\", \"data-disabled\", \"as\", \"as-child\"])\n ]),\n _: 3\n });\n };\n }\n});\n\nexport { _sfc_main as _ };\n//# sourceMappingURL=RovingFocusItem.js.map\n"],"names":["_sfc_main","defineComponent","__props","props","context","injectRovingFocusGroupContext","randomId","useId","id","computed","isCurrentTabStop","getItems","CollectionItem","useCollection","onMounted","onUnmounted","handleKeydown","event","focusIntent","getFocusIntent","candidateNodes","i","currentIndex","wrapArray","nextTick","focusFirst","_ctx","_cache","openBlock","createBlock","unref","withCtx","createVNode","Primitive","$event","renderSlot"],"mappings":"iNAOK,MAACA,EAA4BC,EAAgB,CAChD,OAAQ,kBACR,MAAO,CACL,UAAW,CAAE,EACb,UAAW,CAAE,KAAM,QAAS,QAAS,EAAM,EAC3C,OAAQ,CAAE,KAAM,QAAS,QAAS,EAAM,EACxC,cAAe,CAAE,KAAM,OAAS,EAChC,QAAS,CAAE,KAAM,OAAS,EAC1B,GAAI,CAAE,QAAS,MAAM,CACtB,EACD,MAAMC,EAAS,CACb,MAAMC,EAAQD,EACRE,EAAUC,EAA+B,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