@ark-ui/react
Version:
A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.
16 lines (13 loc) • 558 B
JavaScript
'use client';
import { trackInteractionModality, getInteractionModality } from '@zag-js/focus-visible';
import { useSyncExternalStore, useCallback } from 'react';
import { useEnvironmentContext } from '../environment/use-environment-context.js';
function useInteractionModality() {
const { getRootNode } = useEnvironmentContext();
return useSyncExternalStore(
useCallback((onChange) => trackInteractionModality({ root: getRootNode(), onChange }), [getRootNode]),
getInteractionModality,
() => null
);
}
export { useInteractionModality };