{"version":3,"file":"MenubarRoot.cjs","sources":["../../src/Menubar/MenubarRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Ref } from 'vue'\nimport type { Direction } from '../shared/types'\nimport { createContext, useDirection, useForwardExpose } from '@/shared'\nimport { useCollection } from '@/Collection'\n\nexport interface MenubarRootProps {\n  /** The controlled value of the menu to open. Can be used as `v-model`. */\n  modelValue?: string\n  /** The value of the menu that should be open when initially rendered. Use when you do not need to control the value state. */\n  defaultValue?: string\n  /**\n   * The reading direction of the combobox when applicable.\n   *\n   *  If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode.\n   */\n  dir?: Direction\n  /** When `true`, keyboard navigation will loop from last item to first, and vice versa. */\n  loop?: boolean\n}\nexport type MenubarRootEmits = {\n  /** Event handler called when the value changes. */\n  'update:modelValue': [value: boolean]\n}\n\nexport interface MenubarRootContext {\n  modelValue: Ref<string>\n  dir: Ref<Direction>\n  loop: Ref<boolean>\n  onMenuOpen: (value: string) => void\n  onMenuClose: () => void\n  onMenuToggle: (value: string) => void\n}\n\nexport const [injectMenubarRootContext, provideMenubarRootContext]\n  = createContext<MenubarRootContext>('MenubarRoot')\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { RovingFocusGroup } from '@/RovingFocus'\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<MenubarRootProps>(), {\n  loop: false,\n})\nconst emit = defineEmits<MenubarRootEmits>()\n\ndefineSlots<{\n  default: (props: {\n    /** Current input values */\n    modelValue: typeof modelValue.value\n  }) => any\n}>()\n\nconst { forwardRef } = useForwardExpose()\nconst { CollectionSlot } = useCollection({ key: 'Menubar', isProvider: true })\n\nconst modelValue = useVModel(props, 'modelValue', emit, {\n  defaultValue: props.defaultValue ?? '',\n  passive: (props.modelValue === undefined) as false,\n}) as Ref<string>\n\nconst currentTabStopId = ref<string | null>(null)\n\nconst { dir: propDir, loop } = toRefs(props)\nconst dir = useDirection(propDir)\nprovideMenubarRootContext({\n  modelValue,\n  dir,\n  loop,\n  onMenuOpen: (value) => {\n    modelValue.value = value\n    currentTabStopId.value = value\n  },\n  onMenuClose: () => {\n    modelValue.value = ''\n  },\n  onMenuToggle: (value) => {\n    modelValue.value = modelValue.value ? '' : value\n    // `openMenuOpen` and `onMenuToggle` are called exclusively so we\n    // need to update the id in either case.\n    currentTabStopId.value = value\n  },\n})\n</script>\n\n<template>\n  <CollectionSlot>\n    <RovingFocusGroup\n      v-model:current-tab-stop-id=\"currentTabStopId\"\n      orientation=\"horizontal\"\n      :loop=\"loop\"\n      :dir=\"dir\"\n      as-child\n    >\n      <Primitive\n        :ref=\"forwardRef\"\n        role=\"menubar\"\n      >\n        <slot :model-value=\"modelValue\" />\n      </Primitive>\n    </RovingFocusGroup>\n  </CollectionSlot>\n</template>\n"],"names":["createContext","useForwardExpose","useCollection","useVModel","ref","toRefs","useDirection"],"mappings":";;;;;;;;;;;AAkCO,MAAM,CAAC,wBAAA,EAA0B,yBAAyB,CAAA,GAC7DA,mCAAkC,aAAa;;;;;;;;;;;AASnD,IAAA,MAAM,KAAQ,GAAA,OAAA;AAGd,IAAA,MAAM,IAAO,GAAA,MAAA;AASb,IAAM,MAAA,EAAE,UAAW,EAAA,GAAIC,wCAAiB,EAAA;AACxC,IAAM,MAAA,EAAE,gBAAmB,GAAAC,mCAAA,CAAc,EAAE,GAAK,EAAA,SAAA,EAAW,UAAY,EAAA,IAAA,EAAM,CAAA;AAE7E,IAAA,MAAM,UAAa,GAAAC,cAAA,CAAU,KAAO,EAAA,YAAA,EAAc,IAAM,EAAA;AAAA,MACtD,YAAA,EAAc,MAAM,YAAgB,IAAA,EAAA;AAAA,MACpC,OAAA,EAAU,MAAM,UAAe,KAAA;AAAA,KAChC,CAAA;AAED,IAAM,MAAA,gBAAA,GAAmBC,QAAmB,IAAI,CAAA;AAEhD,IAAA,MAAM,EAAE,GAAK,EAAA,OAAA,EAAS,IAAK,EA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