@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
61 lines (58 loc) • 2.25 kB
JavaScript
import { defineComponent, mergeDefaults, onMounted, computed, renderSlot } from 'vue';
import { RenderStrategyPropsProvider } from '../../utils/use-render-strategy.js';
import { useForwardExpose } from '../../utils/use-forward-expose.js';
import { useMenu } from './use-menu.js';
import { useMenuContext, MenuProvider } from './use-menu-context.js';
import { useMenuMachineContext, MenuMachineProvider } from './use-menu-machine-context.js';
import { MenuTriggerItemProvider } from './use-menu-trigger-item-context.js';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "menu-root",
props: /* @__PURE__ */ mergeDefaults({
anchorPoint: {},
"aria-label": {},
closeOnSelect: { type: Boolean },
composite: { type: Boolean },
defaultHighlightedValue: {},
defaultOpen: { type: Boolean },
highlightedValue: {},
id: {},
ids: {},
loopFocus: { type: Boolean },
navigate: { type: Function },
open: { type: Boolean },
positioning: {},
typeahead: { type: Boolean },
lazyMount: { type: Boolean },
unmountOnExit: { type: Boolean },
asChild: { type: Boolean }
}, {
closeOnSelect: void 0,
composite: void 0,
defaultOpen: void 0,
loopFocus: void 0,
open: void 0,
typeahead: void 0
}),
emits: ["escapeKeyDown", "focusOutside", "highlightChange", "interactOutside", "openChange", "pointerDownOutside", "select", "update:open", "update:highlightedValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const { api, machine } = useMenu(props, emits);
const parentApi = useMenuContext();
const parentMachine = useMenuMachineContext();
onMounted(() => {
if (!parentMachine) return;
parentApi.value.setChild(machine);
api.value.setParent(parentMachine);
});
MenuTriggerItemProvider(computed(() => parentApi.value.getTriggerItemProps(api.value)));
MenuMachineProvider(machine);
MenuProvider(api);
RenderStrategyPropsProvider(computed(() => ({ lazyMount: props.lazyMount, unmountOnExit: props.unmountOnExit })));
useForwardExpose();
return (_ctx, _cache) => {
return renderSlot(_ctx.$slots, "default");
};
}
});
export { _sfc_main as default };