UNPKG

@ark-ui/react

Version:

A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.

24 lines (21 loc) 700 B
'use client'; import * as menu from '@zag-js/menu'; import { useMachine, normalizeProps } from '@zag-js/react'; import { useId } from 'react'; import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js'; import { useLocaleContext } from '../../providers/locale/use-locale-context.js'; const useMenu = (props) => { const id = useId(); const { getRootNode } = useEnvironmentContext(); const { dir } = useLocaleContext(); const machineProps = { id, dir, getRootNode, ...props }; const service = useMachine(menu.machine, machineProps); const api = menu.connect(service, normalizeProps); return { api, service }; }; export { useMenu };