feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
@@ -0,0 +1,6 @@
import { _default } from "./src/roving-focus-group.vue.js";
import { _default as _default$1 } from "./src/roving-focus-item.vue.js";
import { COLLECTION_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY } from "./src/roving-focus-group.js";
import { ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, RovingFocusGroupItemInjectionContext, RovingGroupInjectionContext } from "./src/tokens.js";
import { focusFirst, getFocusIntent, reorderArray } from "./src/utils.js";
export { _default as ElRovingFocusGroup, _default as default, _default$1 as ElRovingFocusItem, COLLECTION_INJECTION_KEY as ROVING_FOCUS_COLLECTION_INJECTION_KEY, ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY as ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY, RovingFocusGroupItemInjectionContext, RovingGroupInjectionContext, focusFirst, getFocusIntent, reorderArray };
@@ -0,0 +1,12 @@
import { ROVING_FOCUS_COLLECTION_INJECTION_KEY as COLLECTION_INJECTION_KEY, ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY as COLLECTION_ITEM_INJECTION_KEY } from "./src/roving-focus-group.mjs";
import { ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY } from "./src/tokens.mjs";
import { focusFirst, getFocusIntent, reorderArray } from "./src/utils.mjs";
import roving_focus_group_default from "./src/roving-focus-group2.mjs";
import roving_focus_item_default from "./src/roving-focus-item.mjs";
//#region ../../packages/components/roving-focus-group/index.ts
var roving_focus_group_default$1 = roving_focus_group_default;
//#endregion
export { roving_focus_group_default as ElRovingFocusGroup, roving_focus_item_default as ElRovingFocusItem, COLLECTION_INJECTION_KEY as ROVING_FOCUS_COLLECTION_INJECTION_KEY, ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY as ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY, roving_focus_group_default$1 as default, focusFirst, getFocusIntent, reorderArray };
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","names":["ElRovingFocusGroup"],"sources":["../../../../../packages/components/roving-focus-group/index.ts"],"sourcesContent":["// This component is ported from https://github.com/radix-ui/primitives/tree/main/packages/react/roving-focus\n// with some modification for Vue\nimport ElRovingFocusGroup from './src/roving-focus-group.vue'\nimport ElRovingFocusItem from './src/roving-focus-item.vue'\n\nexport { ElRovingFocusGroup, ElRovingFocusItem }\n\nexport * from './src/tokens'\nexport * from './src/utils'\n\nexport {\n ROVING_FOCUS_COLLECTION_INJECTION_KEY,\n ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY,\n} from './src/roving-focus-group'\n\nexport default ElRovingFocusGroup\n"],"mappings":";;;;;;;AAeA,mCAAeA"}
@@ -0,0 +1,13 @@
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.mjs";
import roving_focus_group_impl_vue_vue_type_script_lang_default from "./roving-focus-group-impl.vue_vue_type_script_lang.mjs";
import { renderSlot } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group-impl.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return renderSlot(_ctx.$slots, "default");
}
var roving_focus_group_impl_default = /* @__PURE__ */ _plugin_vue_export_helper_default(roving_focus_group_impl_vue_vue_type_script_lang_default, [["render", _sfc_render]]);
//#endregion
export { roving_focus_group_impl_default as default };
//# sourceMappingURL=roving-focus-group-impl.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,116 @@
import { composeEventHandlers } from "../../../utils/dom/event.mjs";
import { ROVING_FOCUS_COLLECTION_INJECTION_KEY as COLLECTION_INJECTION_KEY, rovingFocusGroupProps } from "./roving-focus-group.mjs";
import { ROVING_FOCUS_GROUP_INJECTION_KEY } from "./tokens.mjs";
import { focusFirst, getFocusIntent, reorderArray } from "./utils.mjs";
import { useEventListener } from "@vueuse/core";
import { computed, defineComponent, inject, nextTick, provide, readonly, ref, toRef, unref, watch } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group-impl.vue?vue&type=script&lang.ts
const CURRENT_TAB_ID_CHANGE_EVT = "currentTabIdChange";
const ENTRY_FOCUS_EVT = "rovingFocusGroup.entryFocus";
const EVT_OPTS = {
bubbles: false,
cancelable: true
};
var roving_focus_group_impl_vue_vue_type_script_lang_default = defineComponent({
name: "ElRovingFocusGroupImpl",
inheritAttrs: false,
props: rovingFocusGroupProps,
emits: [CURRENT_TAB_ID_CHANGE_EVT, "entryFocus"],
setup(props, { emit }) {
const currentTabbedId = ref((props.currentTabId || props.defaultCurrentTabId) ?? null);
const isBackingOut = ref(false);
const isClickFocus = ref(false);
const rovingFocusGroupRef = ref();
const { getItems } = inject(COLLECTION_INJECTION_KEY, void 0);
const rovingFocusGroupRootStyle = computed(() => {
return [{ outline: "none" }, props.style];
});
const onItemFocus = (tabbedId) => {
emit(CURRENT_TAB_ID_CHANGE_EVT, tabbedId);
};
const onItemShiftTab = () => {
isBackingOut.value = true;
};
const onMousedown = composeEventHandlers((e) => {
props.onMousedown?.(e);
}, () => {
isClickFocus.value = true;
});
const onFocus = composeEventHandlers((e) => {
props.onFocus?.(e);
}, (e) => {
const isKeyboardFocus = !unref(isClickFocus);
const { target, currentTarget } = e;
if (target === currentTarget && isKeyboardFocus && !unref(isBackingOut)) {
const entryFocusEvt = new Event(ENTRY_FOCUS_EVT, EVT_OPTS);
currentTarget?.dispatchEvent(entryFocusEvt);
if (!entryFocusEvt.defaultPrevented) {
const items = getItems().filter((item) => item.focusable);
focusFirst([
items.find((item) => item.active),
items.find((item) => item.id === unref(currentTabbedId)),
...items
].filter(Boolean).map((item) => item.ref));
}
}
isClickFocus.value = false;
});
const onBlur = composeEventHandlers((e) => {
props.onBlur?.(e);
}, () => {
isBackingOut.value = false;
});
const handleEntryFocus = (...args) => {
emit("entryFocus", ...args);
};
const onKeydown = (e) => {
const focusIntent = getFocusIntent(e);
if (focusIntent) {
e.preventDefault();
let elements = getItems().filter((item) => item.focusable).map((item) => item.ref);
switch (focusIntent) {
case "last":
elements.reverse();
break;
case "prev":
case "next": {
if (focusIntent === "prev") elements.reverse();
const currentIdx = elements.indexOf(e.currentTarget);
elements = props.loop ? reorderArray(elements, currentIdx + 1) : elements.slice(currentIdx + 1);
break;
}
default: break;
}
nextTick(() => {
focusFirst(elements);
});
}
};
provide(ROVING_FOCUS_GROUP_INJECTION_KEY, {
currentTabbedId: readonly(currentTabbedId),
loop: toRef(props, "loop"),
tabIndex: computed(() => {
return unref(isBackingOut) ? -1 : 0;
}),
rovingFocusGroupRef,
rovingFocusGroupRootStyle,
orientation: toRef(props, "orientation"),
dir: toRef(props, "dir"),
onItemFocus,
onItemShiftTab,
onBlur,
onFocus,
onMousedown,
onKeydown
});
watch(() => props.currentTabId, (val) => {
currentTabbedId.value = val ?? null;
});
useEventListener(rovingFocusGroupRef, ENTRY_FOCUS_EVT, handleEntryFocus);
}
});
//#endregion
export { roving_focus_group_impl_vue_vue_type_script_lang_default as default };
//# sourceMappingURL=roving-focus-group-impl.vue_vue_type_script_lang.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,70 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import "../../../utils/index.js";
import { ElCollectionInjectionContext, ElCollectionItemInjectionContext } from "../../collection/src/tokens.js";
import "../../collection/index.js";
import * as vue from "vue";
import { ExtractPropTypes, ExtractPublicPropTypes, StyleValue } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group.d.ts
declare const rovingFocusGroupProps: {
style: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string | false | vue.CSSProperties | StyleValue[]) | (() => StyleValue) | (((new (...args: any[]) => string | false | vue.CSSProperties | StyleValue[]) | (() => StyleValue)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
currentTabId: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string) | (() => string | null) | (((new (...args: any[]) => string) | (() => string | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
defaultCurrentTabId: StringConstructor;
loop: BooleanConstructor;
dir: EpPropFinalized<StringConstructor, string, unknown, string, boolean>;
orientation: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined) | (((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
onBlur: FunctionConstructor;
onFocus: FunctionConstructor;
onMousedown: FunctionConstructor;
};
type ElRovingFocusGroupProps = ExtractPropTypes<typeof rovingFocusGroupProps>;
declare const ElCollection: {
new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & {
name: string;
setup(): void;
}, ElCollectionItem: {
new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & {
name: string;
setup(_: unknown, {
attrs
}: vue.SetupContext): void;
}, COLLECTION_INJECTION_KEY: vue.InjectionKey<ElCollectionInjectionContext>, COLLECTION_ITEM_INJECTION_KEY: vue.InjectionKey<ElCollectionItemInjectionContext>;
//#endregion
export { COLLECTION_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY, ElRovingFocusGroupProps };
@@ -0,0 +1,28 @@
import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
import { createCollectionWithScope } from "../../collection/src/collection.mjs";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group.ts
const rovingFocusGroupProps = buildProps({
style: { type: definePropType([
String,
Array,
Object
]) },
currentTabId: { type: definePropType(String) },
defaultCurrentTabId: String,
loop: Boolean,
dir: {
type: String,
values: ["ltr", "rtl"],
default: "ltr"
},
orientation: { type: definePropType(String) },
onBlur: Function,
onFocus: Function,
onMousedown: Function
});
const { ElCollection, ElCollectionItem, COLLECTION_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY } = createCollectionWithScope("RovingFocusGroup");
//#endregion
export { ElCollection, ElCollectionItem, COLLECTION_INJECTION_KEY as ROVING_FOCUS_COLLECTION_INJECTION_KEY, COLLECTION_ITEM_INJECTION_KEY as ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY, rovingFocusGroupProps };
//# sourceMappingURL=roving-focus-group.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"roving-focus-group.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/roving-focus-group.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\nimport { createCollectionWithScope } from '@element-plus/components/collection'\n\nimport type {\n ExtractPropTypes,\n ExtractPublicPropTypes,\n HTMLAttributes,\n StyleValue,\n} from 'vue'\n\nexport const rovingFocusGroupProps = buildProps({\n style: { type: definePropType<StyleValue>([String, Array, Object]) },\n currentTabId: {\n type: definePropType<string | null>(String),\n },\n defaultCurrentTabId: String,\n loop: Boolean,\n dir: {\n type: String, // left for direction support\n values: ['ltr', 'rtl'],\n default: 'ltr',\n },\n orientation: {\n // left for orientation support\n type: definePropType<HTMLAttributes['aria-orientation']>(String),\n },\n\n onBlur: Function,\n onFocus: Function,\n onMousedown: Function,\n})\n\nexport type ElRovingFocusGroupProps = ExtractPropTypes<\n typeof rovingFocusGroupProps\n>\n\nexport type ElRovingFocusGroupPropsPublic = ExtractPublicPropTypes<\n typeof rovingFocusGroupProps\n>\n\nconst {\n ElCollection,\n ElCollectionItem,\n COLLECTION_INJECTION_KEY,\n COLLECTION_ITEM_INJECTION_KEY,\n} = createCollectionWithScope('RovingFocusGroup')\n\nexport {\n ElCollection,\n ElCollectionItem,\n COLLECTION_INJECTION_KEY as ROVING_FOCUS_COLLECTION_INJECTION_KEY,\n COLLECTION_ITEM_INJECTION_KEY as ROVING_FOCUS_ITEM_COLLECTION_INJECTION_KEY,\n}\n"],"mappings":";;;;AAUA,MAAa,wBAAwB,WAAW;CAC9C,OAAO,EAAE,MAAM,eAA2B;EAAC;EAAQ;EAAO;EAAO,CAAC,EAAE;CACpE,cAAc,EACZ,MAAM,eAA8B,OAAO,EAC5C;CACD,qBAAqB;CACrB,MAAM;CACN,KAAK;EACH,MAAM;EACN,QAAQ,CAAC,OAAO,MAAM;EACtB,SAAS;EACV;CACD,aAAa,EAEX,MAAM,eAAmD,OAAO,EACjE;CAED,QAAQ;CACR,SAAS;CACT,aAAa;CACd,CAAC;AAUF,MAAM,EACJ,cACA,kBACA,0BACA,kCACE,0BAA0B,mBAAmB"}
@@ -0,0 +1,83 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import "../../../utils/index.js";
import * as vue from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group.vue.d.ts
declare const _default: typeof __VLS_export;
declare const __VLS_export: vue.DefineComponent<{}, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {
ElFocusGroupCollection: {
new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & {
name: string;
setup(): void;
};
ElRovingFocusGroupImpl: vue.DefineComponent<vue.ExtractPropTypes<{
style: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string | false | vue.CSSProperties | vue.StyleValue[]) | (() => vue.StyleValue) | (((new (...args: any[]) => string | false | vue.CSSProperties | vue.StyleValue[]) | (() => vue.StyleValue)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
currentTabId: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string) | (() => string | null) | (((new (...args: any[]) => string) | (() => string | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
defaultCurrentTabId: StringConstructor;
loop: BooleanConstructor;
dir: EpPropFinalized<StringConstructor, string, unknown, string, boolean>;
orientation: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined) | (((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
onBlur: FunctionConstructor;
onFocus: FunctionConstructor;
onMousedown: FunctionConstructor;
}>, void, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("currentTabIdChange" | "entryFocus")[], "currentTabIdChange" | "entryFocus", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
style: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string | false | vue.CSSProperties | vue.StyleValue[]) | (() => vue.StyleValue) | (((new (...args: any[]) => string | false | vue.CSSProperties | vue.StyleValue[]) | (() => vue.StyleValue)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
currentTabId: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string) | (() => string | null) | (((new (...args: any[]) => string) | (() => string | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
defaultCurrentTabId: StringConstructor;
loop: BooleanConstructor;
dir: EpPropFinalized<StringConstructor, string, unknown, string, boolean>;
orientation: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined) | (((new (...args: any[]) => "horizontal" | "vertical") | (() => "horizontal" | "vertical" | undefined)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
onBlur: FunctionConstructor;
onFocus: FunctionConstructor;
onMousedown: FunctionConstructor;
}>> & Readonly<{
onCurrentTabIdChange?: ((...args: any[]) => any) | undefined;
onEntryFocus?: ((...args: any[]) => any) | undefined;
}>, {
loop: boolean;
dir: string;
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { _default };
@@ -0,0 +1,16 @@
import { ElCollection } from "./roving-focus-group.mjs";
import roving_focus_group_impl_default from "./roving-focus-group-impl.mjs";
import { defineComponent } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group.vue?vue&type=script&lang.ts
var roving_focus_group_vue_vue_type_script_lang_default = defineComponent({
name: "ElRovingFocusGroup",
components: {
ElFocusGroupCollection: ElCollection,
ElRovingFocusGroupImpl: roving_focus_group_impl_default
}
});
//#endregion
export { roving_focus_group_vue_vue_type_script_lang_default as default };
//# sourceMappingURL=roving-focus-group.vue_vue_type_script_lang.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"roving-focus-group.vue_vue_type_script_lang.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/roving-focus-group.vue"],"sourcesContent":["<template>\n <el-focus-group-collection>\n <el-roving-focus-group-impl v-bind=\"$attrs\">\n <slot />\n </el-roving-focus-group-impl>\n </el-focus-group-collection>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport ElRovingFocusGroupImpl from './roving-focus-group-impl.vue'\nimport { ElCollection as ElFocusGroupCollection } from './roving-focus-group'\n\nexport default defineComponent({\n name: 'ElRovingFocusGroup',\n components: {\n ElFocusGroupCollection,\n ElRovingFocusGroupImpl,\n },\n})\n</script>\n"],"mappings":";;;;;AAaA,0DAAe,gBAAgB;CAC7B,MAAM;CACN,YAAY;EACV;EACA;EACD;CACF,CAAA"}
@@ -0,0 +1,21 @@
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.mjs";
import roving_focus_group_vue_vue_type_script_lang_default from "./roving-focus-group.vue_vue_type_script_lang.mjs";
import { createBlock, createVNode, guardReactiveProps, normalizeProps, openBlock, renderSlot, resolveComponent, withCtx } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-group.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_el_roving_focus_group_impl = resolveComponent("el-roving-focus-group-impl");
const _component_el_focus_group_collection = resolveComponent("el-focus-group-collection");
return openBlock(), createBlock(_component_el_focus_group_collection, null, {
default: withCtx(() => [createVNode(_component_el_roving_focus_group_impl, normalizeProps(guardReactiveProps(_ctx.$attrs)), {
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
_: 3
}, 16)]),
_: 3
});
}
var roving_focus_group_default = /* @__PURE__ */ _plugin_vue_export_helper_default(roving_focus_group_vue_vue_type_script_lang_default, [["render", _sfc_render]]);
//#endregion
export { roving_focus_group_default as default };
//# sourceMappingURL=roving-focus-group2.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"roving-focus-group2.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/roving-focus-group.vue"],"sourcesContent":["<template>\n <el-focus-group-collection>\n <el-roving-focus-group-impl v-bind=\"$attrs\">\n <slot />\n </el-roving-focus-group-impl>\n </el-focus-group-collection>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\nimport ElRovingFocusGroupImpl from './roving-focus-group-impl.vue'\nimport { ElCollection as ElFocusGroupCollection } from './roving-focus-group'\n\nexport default defineComponent({\n name: 'ElRovingFocusGroup',\n components: {\n ElFocusGroupCollection,\n ElRovingFocusGroupImpl,\n },\n})\n</script>\n"],"mappings":";;;;;;;;qBACE,YAI4B,sCAAA,MAAA;EAAA,SAAA,cADG,CAF7B,YAE6B,uCAAA,eAAA,mBAFO,KAAA,OAAM,CAAA,EAAA;GAAA,SAAA,cAChC,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
@@ -0,0 +1,25 @@
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.mjs";
import roving_focus_item_vue_vue_type_script_lang_default from "./roving-focus-item.vue_vue_type_script_lang.mjs";
import { createBlock, openBlock, renderSlot, resolveComponent, withCtx } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-item.vue
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_el_roving_focus_collection_item = resolveComponent("el-roving-focus-collection-item");
return openBlock(), createBlock(_component_el_roving_focus_collection_item, {
id: _ctx.id,
focusable: _ctx.focusable,
active: _ctx.active
}, {
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
_: 3
}, 8, [
"id",
"focusable",
"active"
]);
}
var roving_focus_item_default = /* @__PURE__ */ _plugin_vue_export_helper_default(roving_focus_item_vue_vue_type_script_lang_default, [["render", _sfc_render]]);
//#endregion
export { roving_focus_item_default as default };
//# sourceMappingURL=roving-focus-item.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"roving-focus-item.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/roving-focus-item.vue"],"sourcesContent":["<template>\n <el-roving-focus-collection-item\n :id=\"id\"\n :focusable=\"focusable\"\n :active=\"active\"\n >\n <slot />\n </el-roving-focus-collection-item>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, provide, ref, unref } from 'vue'\nimport { useId } from '@element-plus/hooks'\nimport { composeEventHandlers, getEventCode } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { ElCollectionItem as ElRovingFocusCollectionItem } from './roving-focus-group'\nimport {\n ROVING_FOCUS_GROUP_INJECTION_KEY,\n ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY,\n} from './tokens'\n\nexport default defineComponent({\n components: {\n ElRovingFocusCollectionItem,\n },\n props: {\n focusable: {\n type: Boolean,\n default: true,\n },\n active: Boolean,\n },\n emits: ['mousedown', 'focus', 'keydown'],\n setup(props, { emit }) {\n const { currentTabbedId, onItemFocus, onItemShiftTab, onKeydown } = inject(\n ROVING_FOCUS_GROUP_INJECTION_KEY,\n undefined\n )!\n\n const id = useId()\n const rovingFocusGroupItemRef = ref<HTMLElement>()\n\n const handleMousedown = composeEventHandlers(\n (e: Event) => {\n emit('mousedown', e)\n },\n (e) => {\n if (!props.focusable) {\n e.preventDefault()\n } else {\n onItemFocus(unref(id))\n }\n }\n )\n\n const handleFocus = composeEventHandlers(\n (e: Event) => {\n emit('focus', e)\n },\n () => {\n onItemFocus(unref(id))\n }\n )\n\n const handleKeydown = composeEventHandlers(\n (e: Event) => {\n emit('keydown', e)\n },\n (e) => {\n const { shiftKey, target, currentTarget } = e as KeyboardEvent\n const code = getEventCode(e as KeyboardEvent)\n\n if (code === EVENT_CODE.tab && shiftKey) {\n onItemShiftTab()\n return\n }\n if (target !== currentTarget) return\n onKeydown(e as KeyboardEvent)\n }\n )\n\n const isCurrentTab = computed(() => currentTabbedId.value === unref(id))\n\n provide(ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, {\n rovingFocusGroupItemRef,\n tabIndex: computed(() => (unref(isCurrentTab) ? 0 : -1)),\n handleMousedown,\n handleFocus,\n handleKeydown,\n })\n\n return {\n id,\n handleKeydown,\n handleFocus,\n handleMousedown,\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;qBACE,YAMkC,4CAAA;EAL/B,IAAI,KAAA;EACJ,WAAW,KAAA;EACX,QAAQ,KAAA;EAAA,EAAA;yBAED,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
@@ -0,0 +1,50 @@
import * as vue from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-item.vue.d.ts
declare const _default: typeof __VLS_export;
declare const __VLS_export: vue.DefineComponent<vue.ExtractPropTypes<{
focusable: {
type: BooleanConstructor;
default: boolean;
};
active: BooleanConstructor;
}>, {
id: vue.Ref<string, string>;
handleKeydown: (event: Event) => void;
handleFocus: (event: Event) => void;
handleMousedown: (event: Event) => void;
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("focus" | "keydown" | "mousedown")[], "focus" | "keydown" | "mousedown", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
focusable: {
type: BooleanConstructor;
default: boolean;
};
active: BooleanConstructor;
}>> & Readonly<{
onFocus?: ((...args: any[]) => any) | undefined;
onKeydown?: ((...args: any[]) => any) | undefined;
onMousedown?: ((...args: any[]) => any) | undefined;
}>, {
active: boolean;
focusable: boolean;
}, {}, {
ElRovingFocusCollectionItem: {
new (...args: any[]): vue.CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.PublicProps, {}, true, {}, {}, vue.GlobalComponents, vue.GlobalDirectives, string, {}, any, vue.ComponentProvideOptions, {
P: {};
B: {};
D: {};
C: {};
M: {};
Defaults: {};
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & vue.ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}, vue.GlobalComponents, vue.GlobalDirectives, string, vue.ComponentProvideOptions> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & {
name: string;
setup(_: unknown, {
attrs
}: vue.SetupContext): void;
};
}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { _default };
@@ -0,0 +1,68 @@
import { EVENT_CODE } from "../../../constants/aria.mjs";
import { composeEventHandlers, getEventCode } from "../../../utils/dom/event.mjs";
import { useId } from "../../../hooks/use-id/index.mjs";
import { ElCollectionItem } from "./roving-focus-group.mjs";
import { ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY } from "./tokens.mjs";
import { computed, defineComponent, inject, provide, ref, unref } from "vue";
//#region ../../packages/components/roving-focus-group/src/roving-focus-item.vue?vue&type=script&lang.ts
var roving_focus_item_vue_vue_type_script_lang_default = defineComponent({
components: { ElRovingFocusCollectionItem: ElCollectionItem },
props: {
focusable: {
type: Boolean,
default: true
},
active: Boolean
},
emits: [
"mousedown",
"focus",
"keydown"
],
setup(props, { emit }) {
const { currentTabbedId, onItemFocus, onItemShiftTab, onKeydown } = inject(ROVING_FOCUS_GROUP_INJECTION_KEY, void 0);
const id = useId();
const rovingFocusGroupItemRef = ref();
const handleMousedown = composeEventHandlers((e) => {
emit("mousedown", e);
}, (e) => {
if (!props.focusable) e.preventDefault();
else onItemFocus(unref(id));
});
const handleFocus = composeEventHandlers((e) => {
emit("focus", e);
}, () => {
onItemFocus(unref(id));
});
const handleKeydown = composeEventHandlers((e) => {
emit("keydown", e);
}, (e) => {
const { shiftKey, target, currentTarget } = e;
if (getEventCode(e) === EVENT_CODE.tab && shiftKey) {
onItemShiftTab();
return;
}
if (target !== currentTarget) return;
onKeydown(e);
});
const isCurrentTab = computed(() => currentTabbedId.value === unref(id));
provide(ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, {
rovingFocusGroupItemRef,
tabIndex: computed(() => unref(isCurrentTab) ? 0 : -1),
handleMousedown,
handleFocus,
handleKeydown
});
return {
id,
handleKeydown,
handleFocus,
handleMousedown
};
}
});
//#endregion
export { roving_focus_item_vue_vue_type_script_lang_default as default };
//# sourceMappingURL=roving-focus-item.vue_vue_type_script_lang.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"roving-focus-item.vue_vue_type_script_lang.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/roving-focus-item.vue"],"sourcesContent":["<template>\n <el-roving-focus-collection-item\n :id=\"id\"\n :focusable=\"focusable\"\n :active=\"active\"\n >\n <slot />\n </el-roving-focus-collection-item>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, inject, provide, ref, unref } from 'vue'\nimport { useId } from '@element-plus/hooks'\nimport { composeEventHandlers, getEventCode } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { ElCollectionItem as ElRovingFocusCollectionItem } from './roving-focus-group'\nimport {\n ROVING_FOCUS_GROUP_INJECTION_KEY,\n ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY,\n} from './tokens'\n\nexport default defineComponent({\n components: {\n ElRovingFocusCollectionItem,\n },\n props: {\n focusable: {\n type: Boolean,\n default: true,\n },\n active: Boolean,\n },\n emits: ['mousedown', 'focus', 'keydown'],\n setup(props, { emit }) {\n const { currentTabbedId, onItemFocus, onItemShiftTab, onKeydown } = inject(\n ROVING_FOCUS_GROUP_INJECTION_KEY,\n undefined\n )!\n\n const id = useId()\n const rovingFocusGroupItemRef = ref<HTMLElement>()\n\n const handleMousedown = composeEventHandlers(\n (e: Event) => {\n emit('mousedown', e)\n },\n (e) => {\n if (!props.focusable) {\n e.preventDefault()\n } else {\n onItemFocus(unref(id))\n }\n }\n )\n\n const handleFocus = composeEventHandlers(\n (e: Event) => {\n emit('focus', e)\n },\n () => {\n onItemFocus(unref(id))\n }\n )\n\n const handleKeydown = composeEventHandlers(\n (e: Event) => {\n emit('keydown', e)\n },\n (e) => {\n const { shiftKey, target, currentTarget } = e as KeyboardEvent\n const code = getEventCode(e as KeyboardEvent)\n\n if (code === EVENT_CODE.tab && shiftKey) {\n onItemShiftTab()\n return\n }\n if (target !== currentTarget) return\n onKeydown(e as KeyboardEvent)\n }\n )\n\n const isCurrentTab = computed(() => currentTabbedId.value === unref(id))\n\n provide(ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, {\n rovingFocusGroupItemRef,\n tabIndex: computed(() => (unref(isCurrentTab) ? 0 : -1)),\n handleMousedown,\n handleFocus,\n handleKeydown,\n })\n\n return {\n id,\n handleKeydown,\n handleFocus,\n handleMousedown,\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;;AAqBA,yDAAe,gBAAgB;CAC7B,YAAY,EACV,+CACD;CACD,OAAO;EACL,WAAW;GACT,MAAM;GACN,SAAS;GACV;EACD,QAAQ;EACT;CACD,OAAO;EAAC;EAAa;EAAS;EAAU;CACxC,MAAM,OAAO,EAAE,QAAQ;EACrB,MAAM,EAAE,iBAAiB,aAAa,gBAAgB,cAAc,OAClE,kCACA,OACD;EAED,MAAM,KAAK,OAAM;EACjB,MAAM,0BAA0B,KAAiB;EAEjD,MAAM,kBAAkB,sBACrB,MAAa;AACZ,QAAK,aAAa,EAAC;MAEpB,MAAM;AACL,OAAI,CAAC,MAAM,UACT,GAAE,gBAAe;OAEjB,aAAY,MAAM,GAAG,CAAA;IAG3B;EAEA,MAAM,cAAc,sBACjB,MAAa;AACZ,QAAK,SAAS,EAAC;WAEX;AACJ,eAAY,MAAM,GAAG,CAAA;IAEzB;EAEA,MAAM,gBAAgB,sBACnB,MAAa;AACZ,QAAK,WAAW,EAAC;MAElB,MAAM;GACL,MAAM,EAAE,UAAU,QAAQ,kBAAkB;AAG5C,OAFa,aAAa,EAAkB,KAE/B,WAAW,OAAO,UAAU;AACvC,oBAAe;AACf;;AAEF,OAAI,WAAW,cAAe;AAC9B,aAAU,EAAkB;IAEhC;EAEA,MAAM,eAAe,eAAe,gBAAgB,UAAU,MAAM,GAAG,CAAA;AAEvE,UAAQ,uCAAuC;GAC7C;GACA,UAAU,eAAgB,MAAM,aAAY,GAAI,IAAI,GAAI;GACxD;GACA;GACA;GACD,CAAA;AAED,SAAO;GACL;GACA;GACA;GACA;GACF;;CAEH,CAAA"}
@@ -0,0 +1,31 @@
import { ElRovingFocusGroupProps } from "./roving-focus-group.js";
import { InjectionKey, Ref, StyleValue } from "vue";
//#region ../../packages/components/roving-focus-group/src/tokens.d.ts
type EventHandler<T = Event> = (e: T) => void;
type RovingGroupInjectionContext = {
currentTabbedId: Ref<string | null>;
dir: Ref<ElRovingFocusGroupProps['dir']>;
loop: Ref<ElRovingFocusGroupProps['loop']>;
orientation: Ref<ElRovingFocusGroupProps['orientation']>;
tabIndex: Ref<number>;
rovingFocusGroupRef: Ref<HTMLElement | undefined>;
rovingFocusGroupRootStyle: Ref<StyleValue>;
onBlur: EventHandler;
onFocus: EventHandler<FocusEvent>;
onMousedown: EventHandler;
onItemFocus: (id: string) => void;
onItemShiftTab: () => void;
onKeydown: EventHandler<KeyboardEvent>;
};
type RovingFocusGroupItemInjectionContext = {
rovingFocusGroupItemRef: Ref<HTMLElement | undefined>;
tabIndex: Ref<number>;
handleMousedown: EventHandler;
handleFocus: EventHandler;
handleKeydown: EventHandler;
};
declare const ROVING_FOCUS_GROUP_INJECTION_KEY: InjectionKey<RovingGroupInjectionContext>;
declare const ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY: InjectionKey<RovingFocusGroupItemInjectionContext>;
//#endregion
export { ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY, RovingFocusGroupItemInjectionContext, RovingGroupInjectionContext };
@@ -0,0 +1,7 @@
//#region ../../packages/components/roving-focus-group/src/tokens.ts
const ROVING_FOCUS_GROUP_INJECTION_KEY = Symbol("elRovingFocusGroup");
const ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY = Symbol("elRovingFocusGroupItem");
//#endregion
export { ROVING_FOCUS_GROUP_INJECTION_KEY, ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY };
//# sourceMappingURL=tokens.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"tokens.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/tokens.ts"],"sourcesContent":["import type { InjectionKey, Ref, StyleValue } from 'vue'\nimport type { ElRovingFocusGroupProps } from './roving-focus-group'\n\ntype EventHandler<T = Event> = (e: T) => void\n\nexport type RovingGroupInjectionContext = {\n currentTabbedId: Ref<string | null>\n dir: Ref<ElRovingFocusGroupProps['dir']>\n loop: Ref<ElRovingFocusGroupProps['loop']>\n orientation: Ref<ElRovingFocusGroupProps['orientation']>\n tabIndex: Ref<number>\n rovingFocusGroupRef: Ref<HTMLElement | undefined>\n rovingFocusGroupRootStyle: Ref<StyleValue>\n onBlur: EventHandler\n onFocus: EventHandler<FocusEvent>\n onMousedown: EventHandler\n onItemFocus: (id: string) => void\n onItemShiftTab: () => void\n onKeydown: EventHandler<KeyboardEvent>\n}\n\nexport type RovingFocusGroupItemInjectionContext = {\n rovingFocusGroupItemRef: Ref<HTMLElement | undefined>\n tabIndex: Ref<number>\n handleMousedown: EventHandler\n handleFocus: EventHandler\n handleKeydown: EventHandler\n}\n\nexport const ROVING_FOCUS_GROUP_INJECTION_KEY: InjectionKey<RovingGroupInjectionContext> =\n Symbol('elRovingFocusGroup')\n\nexport const ROVING_FOCUS_GROUP_ITEM_INJECTION_KEY: InjectionKey<RovingFocusGroupItemInjectionContext> =\n Symbol('elRovingFocusGroupItem')\n"],"mappings":";AA6BA,MAAa,mCACX,OAAO,qBAAqB;AAE9B,MAAa,wCACX,OAAO,yBAAyB"}
@@ -0,0 +1,11 @@
import { HTMLAttributes } from "vue";
//#region ../../packages/components/roving-focus-group/src/utils.d.ts
type Orientation = HTMLAttributes['aria-orientation'];
type Direction = 'ltr' | 'rtl';
type FocusIntent = 'first' | 'last' | 'prev' | 'next';
declare const getFocusIntent: (event: KeyboardEvent, orientation?: Orientation, dir?: Direction) => FocusIntent | undefined;
declare const reorderArray: <T>(array: T[], atIdx: number) => T[];
declare const focusFirst: (elements: HTMLElement[]) => void;
//#endregion
export { focusFirst, getFocusIntent, reorderArray };
@@ -0,0 +1,43 @@
import { EVENT_CODE } from "../../../constants/aria.mjs";
import { getEventCode } from "../../../utils/dom/event.mjs";
//#region ../../packages/components/roving-focus-group/src/utils.ts
const MAP_KEY_TO_FOCUS_INTENT = {
ArrowLeft: "prev",
ArrowUp: "prev",
ArrowRight: "next",
ArrowDown: "next",
PageUp: "first",
Home: "first",
PageDown: "last",
End: "last"
};
const getDirectionAwareKey = (key, dir) => {
if (dir !== "rtl") return key;
switch (key) {
case EVENT_CODE.right: return EVENT_CODE.left;
case EVENT_CODE.left: return EVENT_CODE.right;
default: return key;
}
};
const getFocusIntent = (event, orientation, dir) => {
const key = getDirectionAwareKey(getEventCode(event), dir);
if (orientation === "vertical" && [EVENT_CODE.left, EVENT_CODE.right].includes(key)) return void 0;
if (orientation === "horizontal" && [EVENT_CODE.up, EVENT_CODE.down].includes(key)) return void 0;
return MAP_KEY_TO_FOCUS_INTENT[key];
};
const reorderArray = (array, atIdx) => {
return array.map((_, idx) => array[(idx + atIdx) % array.length]);
};
const focusFirst = (elements) => {
const { activeElement: prevActive } = document;
for (const element of elements) {
if (element === prevActive) return;
element.focus();
if (prevActive !== document.activeElement) return;
}
};
//#endregion
export { focusFirst, getFocusIntent, reorderArray };
//# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../../../../packages/components/roving-focus-group/src/utils.ts"],"sourcesContent":["import { EVENT_CODE } from '@element-plus/constants'\nimport { getEventCode } from '@element-plus/utils'\n\nimport type { HTMLAttributes } from 'vue'\n\ntype Orientation = HTMLAttributes['aria-orientation']\ntype Direction = 'ltr' | 'rtl'\ntype FocusIntent = 'first' | 'last' | 'prev' | 'next'\n\nconst MAP_KEY_TO_FOCUS_INTENT: Record<string, FocusIntent> = {\n ArrowLeft: 'prev',\n ArrowUp: 'prev',\n ArrowRight: 'next',\n ArrowDown: 'next',\n PageUp: 'first',\n Home: 'first',\n PageDown: 'last',\n End: 'last',\n}\n\nconst getDirectionAwareKey = (key: string, dir?: Direction) => {\n if (dir !== 'rtl') return key\n\n switch (key) {\n case EVENT_CODE.right:\n return EVENT_CODE.left\n case EVENT_CODE.left:\n return EVENT_CODE.right\n default:\n return key\n }\n}\n\nexport const getFocusIntent = (\n event: KeyboardEvent,\n orientation?: Orientation,\n dir?: Direction\n) => {\n const code = getEventCode(event)\n const key = getDirectionAwareKey(code, dir)\n if (\n orientation === 'vertical' &&\n [EVENT_CODE.left, EVENT_CODE.right].includes(key)\n )\n return undefined\n if (\n orientation === 'horizontal' &&\n [EVENT_CODE.up, EVENT_CODE.down].includes(key)\n )\n return undefined\n return MAP_KEY_TO_FOCUS_INTENT[key]\n}\n\nexport const reorderArray = <T>(array: T[], atIdx: number) => {\n return array.map((_, idx) => array[(idx + atIdx) % array.length])\n}\n\nexport const focusFirst = (elements: HTMLElement[]) => {\n const { activeElement: prevActive } = document\n\n for (const element of elements) {\n if (element === prevActive) return\n element.focus()\n if (prevActive !== document.activeElement) return\n }\n}\n"],"mappings":";;;;AASA,MAAM,0BAAuD;CAC3D,WAAW;CACX,SAAS;CACT,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,MAAM;CACN,UAAU;CACV,KAAK;CACN;AAED,MAAM,wBAAwB,KAAa,QAAoB;AAC7D,KAAI,QAAQ,MAAO,QAAO;AAE1B,SAAQ,KAAR;EACE,KAAK,WAAW,MACd,QAAO,WAAW;EACpB,KAAK,WAAW,KACd,QAAO,WAAW;EACpB,QACE,QAAO;;;AAIb,MAAa,kBACX,OACA,aACA,QACG;CAEH,MAAM,MAAM,qBADC,aAAa,MAAM,EACO,IAAI;AAC3C,KACE,gBAAgB,cAChB,CAAC,WAAW,MAAM,WAAW,MAAM,CAAC,SAAS,IAAI,CAEjD,QAAO;AACT,KACE,gBAAgB,gBAChB,CAAC,WAAW,IAAI,WAAW,KAAK,CAAC,SAAS,IAAI,CAE9C,QAAO;AACT,QAAO,wBAAwB;;AAGjC,MAAa,gBAAmB,OAAY,UAAkB;AAC5D,QAAO,MAAM,KAAK,GAAG,QAAQ,OAAO,MAAM,SAAS,MAAM,QAAQ;;AAGnE,MAAa,cAAc,aAA4B;CACrD,MAAM,EAAE,eAAe,eAAe;AAEtC,MAAK,MAAM,WAAW,UAAU;AAC9B,MAAI,YAAY,WAAY;AAC5B,UAAQ,OAAO;AACf,MAAI,eAAe,SAAS,cAAe"}