{"version":3,"file":"NavigationMenuLink.cjs","sources":["../../src/NavigationMenu/NavigationMenuLink.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { PrimitiveProps } from '@/Primitive'\nimport { useForwardExpose } from '@/shared'\nimport { useCollection } from '@/Collection'\n\nexport type NavigationMenuLinkEmits = {\n  /**\n   * Event handler called when the user selects a link (via mouse or keyboard).\n   *\n   * Calling `event.preventDefault` in this handler will prevent the navigation menu from closing when selecting that link.\n   */\n  select: [payload: CustomEvent<{ originalEvent: Event }>]\n}\nexport interface NavigationMenuLinkProps extends PrimitiveProps {\n  /** Used to identify the link as the currently active page. */\n  active?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Primitive } from '@/Primitive'\nimport { EVENT_ROOT_CONTENT_DISMISS, LINK_SELECT } from './utils'\n\nconst props = withDefaults(defineProps<NavigationMenuLinkProps>(), {\n  as: 'a',\n})\n\nconst emits = defineEmits<NavigationMenuLinkEmits>()\n\nconst { CollectionItem } = useCollection({ key: 'NavigationMenu' })\nuseForwardExpose()\n\nasync function handleClick(ev: MouseEvent) {\n  const linkSelectEvent = new CustomEvent(LINK_SELECT, {\n    bubbles: true,\n    cancelable: true,\n    detail: {\n      originalEvent: ev,\n    },\n  })\n  emits('select', linkSelectEvent)\n\n  if (!linkSelectEvent.defaultPrevented && !ev.metaKey) {\n    const rootContentDismissEvent = new CustomEvent(\n      EVENT_ROOT_CONTENT_DISMISS,\n      {\n        bubbles: true,\n        cancelable: true,\n      },\n    )\n    ev.target?.dispatchEvent(rootContentDismissEvent)\n  }\n}\n</script>\n\n<template>\n  <CollectionItem>\n    <Primitive\n      :as=\"as\"\n      :data-active=\"active ? '' : undefined\"\n      :aria-current=\"active ? 'page' : undefined\"\n      :as-child=\"props.asChild\"\n      @click=\"handleClick\"\n    >\n      <slot />\n    </Primitive>\n  </CollectionItem>\n</template>\n"],"names":["useCollection","useForwardExpose","LINK_SELECT","EVENT_ROOT_CONTENT_DISMISS"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAId,IAAA,MAAM,KAAQ,GAAA,MAAA;AAEd,IAAA,MAAM,EAAE,cAAe,EAAA,GAAIA,oCAAc,EAAE,GAAA,EAAK,kBAAkB,CAAA;AAClE,IAAiBC,wCAAA,EAAA;AAEjB,IAAA,eAAe,YAAY,EAAgB,EAAA;AACzC,MAAM,MAAA,eAAA,GAAkB,IAAI,WAAA,CAAYC,gCAAa,EAAA;AAAA,QACnD,OAAS,EAAA,IAAA;AAAA,QACT,UAAY,EAAA,IAAA;AAAA,QACZ,MAAQ,EAAA;AAAA,UACN,aAAe,EAAA;AAAA;AACjB,OACD,CAAA;AACD,MAAA,KAAA,CAAM,UAAU,eAAe,CAAA;AAE/B,MAAA,IAAI,CAAC,eAAA,CAAgB,gBAAoB,IAAA,CAAC,GAAG,OAAS,EAAA;AACpD,QAAA,MAAM,0BAA0B,IAAI,WAAA;AAAA,UAClCC,+CAAA;AAAA,UACA;AAAA,YACE,OAAS,EAAA,IAAA;AAAA,YACT,UAAY,EAAA;AAAA;AACd,SACF;AACA,QAAG,EAAA,CAAA,MAAA,EAAQ,cAAc,uBAAuB,CAAA;AAAA;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;"}