140 lines
5.3 KiB
JavaScript
140 lines
5.3 KiB
JavaScript
import { Dt as mergeProps, Kn as ref, Nt as onDeactivated, Qn as toRef, U as computed, Ut as provide, Yn as shallowRef, cn as useId, et as createVNode, gn as watch, jt as onBeforeUnmount, xt as inject } from "./vue.runtime.esm-bundler-BvoXUmaf.js";
|
|
import { D as focusChild, F as isClickInsideElement, H as omit, O as focusableChildren, k as getNextElement, l as propsFactory, n as genericComponent } from "./defineComponent-DB6xIcDy.js";
|
|
import { o as VDialogTransition } from "./transitions-DCQ3sjjZ.js";
|
|
import { n as makeVOverlayProps, r as VMenuSymbol, t as VOverlay } from "./VOverlay-BS8OrX3g.js";
|
|
import { t as useRender } from "./useRender-fVtVsZgv.js";
|
|
import { t as useProxiedModel } from "./proxiedModel-DSlSIQ0y.js";
|
|
import { i as useRtl } from "./locale-DDGMqzqb.js";
|
|
import { t as VDefaultsProvider } from "./VDefaultsProvider-C09t4-My.js";
|
|
import { t as useScopeId } from "./scopeId-CyMkmyzM.js";
|
|
import { t as forwardRefs } from "./forwardRefs-CW3d8km7.js";
|
|
import "/Users/thackmaster/Development/routie2/frontend/node_modules/vuetify/lib/components/VMenu/VMenu.css";
|
|
//#region node_modules/vuetify/lib/components/VMenu/VMenu.js
|
|
var makeVMenuProps = propsFactory({
|
|
id: String,
|
|
submenu: Boolean,
|
|
...omit(makeVOverlayProps({
|
|
captureFocus: true,
|
|
closeDelay: 250,
|
|
closeOnContentClick: true,
|
|
locationStrategy: "connected",
|
|
location: void 0,
|
|
openDelay: 300,
|
|
scrim: false,
|
|
scrollStrategy: "reposition",
|
|
transition: { component: VDialogTransition }
|
|
}), ["absolute"])
|
|
}, "VMenu");
|
|
var VMenu = genericComponent()({
|
|
name: "VMenu",
|
|
props: makeVMenuProps(),
|
|
emits: { "update:modelValue": (value) => true },
|
|
setup(props, { slots }) {
|
|
const isActive = useProxiedModel(props, "modelValue");
|
|
const { scopeId } = useScopeId();
|
|
const { isRtl } = useRtl();
|
|
const uid = useId();
|
|
const id = toRef(() => props.id || `v-menu-${uid}`);
|
|
const overlay = ref();
|
|
const parent = inject(VMenuSymbol, null);
|
|
const openChildren = shallowRef(/* @__PURE__ */ new Set());
|
|
provide(VMenuSymbol, {
|
|
register() {
|
|
openChildren.value.add(uid);
|
|
},
|
|
unregister() {
|
|
openChildren.value.delete(uid);
|
|
},
|
|
closeParents(e) {
|
|
setTimeout(() => {
|
|
if (!openChildren.value.size && !props.persistent && (e == null || overlay.value?.contentEl && !isClickInsideElement(e, overlay.value.contentEl))) {
|
|
isActive.value = false;
|
|
parent?.closeParents();
|
|
}
|
|
}, 40);
|
|
}
|
|
});
|
|
onBeforeUnmount(() => parent?.unregister());
|
|
onDeactivated(() => isActive.value = false);
|
|
watch(isActive, (val) => {
|
|
val ? parent?.register() : parent?.unregister();
|
|
}, { immediate: true });
|
|
function onClickOutside(e) {
|
|
parent?.closeParents(e);
|
|
}
|
|
function onKeydown(e) {
|
|
if (props.disabled) return;
|
|
if (e.key === "Tab" || e.key === "Enter" && !props.closeOnContentClick) {
|
|
if (e.key === "Enter" && (e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLInputElement && !!e.target.closest("form"))) return;
|
|
if (e.key === "Enter") e.preventDefault();
|
|
if (!getNextElement(focusableChildren(overlay.value?.contentEl, false), e.shiftKey ? "prev" : "next", (el) => el.tabIndex >= 0) && !props.retainFocus) {
|
|
isActive.value = false;
|
|
overlay.value?.activatorEl?.focus();
|
|
}
|
|
} else if (props.submenu && e.key === (isRtl.value ? "ArrowRight" : "ArrowLeft")) {
|
|
isActive.value = false;
|
|
overlay.value?.activatorEl?.focus();
|
|
}
|
|
}
|
|
function onActivatorKeydown(e) {
|
|
if (props.disabled) return;
|
|
const el = overlay.value?.contentEl;
|
|
if (el && isActive.value) {
|
|
if (e.key === "ArrowDown") {
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
focusChild(el, "next");
|
|
} else if (e.key === "ArrowUp") {
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
focusChild(el, "prev");
|
|
} else if (props.submenu) {
|
|
if (e.key === (isRtl.value ? "ArrowRight" : "ArrowLeft")) isActive.value = false;
|
|
else if (e.key === (isRtl.value ? "ArrowLeft" : "ArrowRight")) {
|
|
e.preventDefault();
|
|
focusChild(el, "first");
|
|
}
|
|
}
|
|
} else if (props.submenu ? e.key === (isRtl.value ? "ArrowLeft" : "ArrowRight") : ["ArrowDown", "ArrowUp"].includes(e.key)) {
|
|
isActive.value = true;
|
|
e.preventDefault();
|
|
setTimeout(() => setTimeout(() => onActivatorKeydown(e)));
|
|
}
|
|
}
|
|
const activatorProps = computed(() => mergeProps({
|
|
"aria-haspopup": "menu",
|
|
"aria-expanded": String(isActive.value),
|
|
"aria-controls": id.value,
|
|
"aria-owns": id.value,
|
|
onKeydown: onActivatorKeydown
|
|
}, props.activatorProps));
|
|
useRender(() => {
|
|
const overlayProps = VOverlay.filterProps(props);
|
|
return createVNode(VOverlay, mergeProps({
|
|
"ref": overlay,
|
|
"id": id.value,
|
|
"class": ["v-menu", props.class],
|
|
"style": props.style
|
|
}, overlayProps, {
|
|
"modelValue": isActive.value,
|
|
"onUpdate:modelValue": ($event) => isActive.value = $event,
|
|
"absolute": true,
|
|
"activatorProps": activatorProps.value,
|
|
"location": props.location ?? (props.submenu ? "end" : "bottom"),
|
|
"onClick:outside": onClickOutside,
|
|
"onKeydown": onKeydown
|
|
}, scopeId), {
|
|
activator: slots.activator,
|
|
default: (...args) => createVNode(VDefaultsProvider, { "root": "VMenu" }, { default: () => [slots.default?.(...args)] })
|
|
});
|
|
});
|
|
return forwardRefs({
|
|
id,
|
|
ΨopenChildren: openChildren
|
|
}, overlay);
|
|
}
|
|
});
|
|
//#endregion
|
|
export { VMenu as t };
|
|
|
|
//# sourceMappingURL=VMenu-DCQFp-2Y.js.map
|