import * as React from 'react'; import { useMemo } from 'react'; import { useTreeEnvironment } from '../controlledEnvironment/ControlledTreeEnvironment'; import { defaultLiveDescriptors } from './defaultLiveDescriptors'; import { useTree } from './Tree'; import { useDragAndDrop } from '../drag/DragAndDropProvider'; import { resolveLiveDescriptor } from './resolveLiveDescriptor'; import { useKeyboardBindings } from '../hotkeys/useKeyboardBindings'; const LiveWrapper = ({ children, live, }: { children: string; live: 'off' | 'assertive' | 'polite'; // eslint-disable-next-line react/no-danger }) =>
; export const LiveDescription: React.FC = () => { const env = useTreeEnvironment(); const tree = useTree(); const dnd = useDragAndDrop(); const keys = useKeyboardBindings(); const descriptors = useMemo( () => env.liveDescriptors ?? defaultLiveDescriptors, [env.liveDescriptors] ); const MainWrapper = tree.renderers.renderLiveDescriptorContainer; if (tree.treeInformation.isRenaming) { return ( {resolveLiveDescriptor( descriptors.renamingItem, env, dnd, tree, keys )} ); } if (tree.treeInformation.isSearching) { return ( {resolveLiveDescriptor(descriptors.searching, env, dnd, tree, keys)} ); } if (tree.treeInformation.isProgrammaticallyDragging) { return ( {resolveLiveDescriptor( descriptors.programmaticallyDragging, env, dnd, tree, keys )} {resolveLiveDescriptor( descriptors.programmaticallyDraggingTarget, env, dnd, tree, keys )} ); } return ( {resolveLiveDescriptor(descriptors.introduction, env, dnd, tree, keys)} ); };