import { computed } from "vue"; //#region src/shared/date/useSegmentNavigation.ts function useSegmentNavigation({ segmentElements, currentFocusedElement, dir, segmentAttributes }) { const currentSegmentIndex = computed(() => Array.from(segmentElements.value).findIndex((el) => segmentAttributes.every((attribute) => el.getAttribute(attribute) === currentFocusedElement.value?.getAttribute(attribute)))); const nextFocusableSegment = computed(() => { const sign = dir.value === "rtl" ? -1 : 1; const nextCondition = sign < 0 ? currentSegmentIndex.value < 0 : currentSegmentIndex.value > segmentElements.value.size - 1; if (nextCondition) return null; const segmentToFocus = Array.from(segmentElements.value)[currentSegmentIndex.value + sign]; return segmentToFocus; }); const prevFocusableSegment = computed(() => { const sign = dir.value === "rtl" ? -1 : 1; const prevCondition = sign > 0 ? currentSegmentIndex.value < 0 : currentSegmentIndex.value > segmentElements.value.size - 1; if (prevCondition) return null; const segmentToFocus = Array.from(segmentElements.value)[currentSegmentIndex.value - sign]; return segmentToFocus; }); function focusNext() { Array.from(segmentElements.value)[currentSegmentIndex.value + 1]?.focus(); } return { currentSegmentIndex, nextFocusableSegment, prevFocusableSegment, focusNext }; } //#endregion export { useSegmentNavigation }; //# sourceMappingURL=useSegmentNavigation.js.map