Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.lib.components.VMenu.VMenu.mjs.map Maven / Gradle / Ivy
{"version":3,"file":"VMenu.mjs","names":["VDialogTransition","VDefaultsProvider","VOverlay","makeVOverlayProps","forwardRefs","useProxiedModel","useScopeId","computed","inject","mergeProps","nextTick","provide","ref","shallowRef","watch","VMenuSymbol","focusableChildren","focusChild","genericComponent","getNextElement","getUid","isClickInsideElement","omit","propsFactory","useRender","makeVMenuProps","id","String","closeDelay","closeOnContentClick","locationStrategy","openDelay","scrim","scrollStrategy","transition","component","VMenu","name","props","emits","value","setup","_ref","slots","isActive","scopeId","uid","overlay","parent","openChildren","register","unregister","closeParents","e","setTimeout","persistent","contentEl","onFocusIn","before","relatedTarget","after","target","globalTop","document","includes","contains","focusable","focus","val","addEventListener","once","removeEventListener","onClickOutside","onKeydown","disabled","key","HTMLTextAreaElement","HTMLInputElement","closest","preventDefault","nextElement","shiftKey","el","tabIndex","activatorEl","onActivatorKeydown","activatorProps","overlayProps","filterProps","_createVNode","_mergeProps","class","style","$event","activator","default","_len","arguments","length","args","Array","_key","ΨopenChildren"],"sources":["../../../src/components/VMenu/VMenu.tsx"],"sourcesContent":["// Styles\nimport './VMenu.sass'\n\n// Components\nimport { VDialogTransition } from '@/components/transitions'\nimport { VDefaultsProvider } from '@/components/VDefaultsProvider'\nimport { VOverlay } from '@/components/VOverlay'\nimport { makeVOverlayProps } from '@/components/VOverlay/VOverlay'\n\n// Composables\nimport { forwardRefs } from '@/composables/forwardRefs'\nimport { useProxiedModel } from '@/composables/proxiedModel'\nimport { useScopeId } from '@/composables/scopeId'\n\n// Utilities\nimport { computed, inject, mergeProps, nextTick, provide, ref, shallowRef, watch } from 'vue'\nimport { VMenuSymbol } from './shared'\nimport {\n focusableChildren,\n focusChild,\n genericComponent,\n getNextElement,\n getUid,\n isClickInsideElement,\n omit,\n propsFactory,\n useRender,\n} from '@/util'\n\n// Types\nimport type { Component } from 'vue'\nimport type { OverlaySlots } from '@/components/VOverlay/VOverlay'\n\nexport const makeVMenuProps = propsFactory({\n // TODO\n // disableKeys: Boolean,\n id: String,\n\n ...omit(makeVOverlayProps({\n closeDelay: 250,\n closeOnContentClick: true,\n locationStrategy: 'connected' as const,\n openDelay: 300,\n scrim: false,\n scrollStrategy: 'reposition' as const,\n transition: { component: VDialogTransition as Component },\n }), ['absolute']),\n}, 'VMenu')\n\nexport const VMenu = genericComponent()({\n name: 'VMenu',\n\n props: makeVMenuProps(),\n\n emits: {\n 'update:modelValue': (value: boolean) => true,\n },\n\n setup (props, { slots }) {\n const isActive = useProxiedModel(props, 'modelValue')\n const { scopeId } = useScopeId()\n\n const uid = getUid()\n const id = computed(() => props.id || `v-menu-${uid}`)\n\n const overlay = ref()\n\n const parent = inject(VMenuSymbol, null)\n const openChildren = shallowRef(0)\n provide(VMenuSymbol, {\n register () {\n ++openChildren.value\n },\n unregister () {\n --openChildren.value\n },\n closeParents (e) {\n setTimeout(() => {\n if (!openChildren.value &&\n !props.persistent &&\n (e == null || (e && !isClickInsideElement(e, overlay.value!.contentEl!)))\n ) {\n isActive.value = false\n parent?.closeParents()\n }\n }, 40)\n },\n })\n\n async function onFocusIn (e: FocusEvent) {\n const before = e.relatedTarget as HTMLElement | null\n const after = e.target as HTMLElement | null\n\n await nextTick()\n\n if (\n isActive.value &&\n before !== after &&\n overlay.value?.contentEl &&\n // We're the topmost menu\n overlay.value?.globalTop &&\n // It isn't the document or the menu body\n ![document, overlay.value.contentEl].includes(after!) &&\n // It isn't inside the menu body\n !overlay.value.contentEl.contains(after)\n ) {\n const focusable = focusableChildren(overlay.value.contentEl)\n focusable[0]?.focus()\n }\n }\n\n watch(isActive, val => {\n if (val) {\n parent?.register()\n document.addEventListener('focusin', onFocusIn, { once: true })\n } else {\n parent?.unregister()\n document.removeEventListener('focusin', onFocusIn)\n }\n })\n\n function onClickOutside (e: MouseEvent) {\n parent?.closeParents(e)\n }\n\n function onKeydown (e: KeyboardEvent) {\n if (props.disabled) return\n\n if (e.key === 'Tab' || (e.key === 'Enter' && !props.closeOnContentClick)) {\n if (\n e.key === 'Enter' &&\n ((e.target instanceof HTMLTextAreaElement) ||\n (e.target instanceof HTMLInputElement && !!e.target.closest('form')))\n ) return\n if (e.key === 'Enter') e.preventDefault()\n\n const nextElement = getNextElement(\n focusableChildren(overlay.value?.contentEl as Element, false),\n e.shiftKey ? 'prev' : 'next',\n (el: HTMLElement) => el.tabIndex >= 0\n )\n if (!nextElement) {\n isActive.value = false\n overlay.value?.activatorEl?.focus()\n }\n } else if (['Enter', ' '].includes(e.key) && props.closeOnContentClick) {\n isActive.value = false\n parent?.closeParents()\n }\n }\n\n function onActivatorKeydown (e: KeyboardEvent) {\n if (props.disabled) return\n\n const el = overlay.value?.contentEl\n if (el && isActive.value) {\n if (e.key === 'ArrowDown') {\n e.preventDefault()\n focusChild(el, 'next')\n } else if (e.key === 'ArrowUp') {\n e.preventDefault()\n focusChild(el, 'prev')\n }\n } else if (['ArrowDown', 'ArrowUp'].includes(e.key)) {\n isActive.value = true\n e.preventDefault()\n setTimeout(() => setTimeout(() => onActivatorKeydown(e)))\n }\n }\n\n const activatorProps = computed(() =>\n mergeProps({\n 'aria-haspopup': 'menu',\n 'aria-expanded': String(isActive.value),\n 'aria-owns': id.value,\n onKeydown: onActivatorKeydown,\n }, props.activatorProps)\n )\n\n useRender(() => {\n const overlayProps = VOverlay.filterProps(props)\n\n return (\n \n {{\n activator: slots.activator,\n default: (...args) => (\n \n { slots.default?.(...args) }\n \n ),\n }}\n \n )\n })\n\n return forwardRefs({ id, ΨopenChildren: openChildren }, overlay)\n },\n})\n\nexport type VMenu = InstanceType\n"],"mappings":";AAAA;AACA;;AAEA;AAAA,SACSA,iBAAiB;AAAA,SACjBC,iBAAiB;AAAA,SACjBC,QAAQ;AAAA,SACRC,iBAAiB,oCAE1B;AAAA,SACSC,WAAW;AAAA,SACXC,eAAe;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