import { ChevronUpDownIcon } from '@heroicons/react/24/outline'; import { PropsWithChildren, useContext, useState } from 'react'; import { Button as ButtonBase, Collection, Popover, SelectStateContext, TreeItemProps, UNSTABLE_Tree as Tree, UNSTABLE_TreeItem as TreeItem, UNSTABLE_TreeItemContent as TreeItemContent, } from 'react-aria-components'; import { useAsyncList } from 'react-stately'; import { ChevronRightIcon } from '@heroicons/react/20/solid'; import clsx from 'clsx'; import { SelectedValueContext, TreeSelect, SelectValue } from '@/components/TreeSelect'; import { Button, Label } from '@/components/common'; import { loadItemChildren } from './documents'; function TreeNode({ id, children, hasChildren, ...props }: PropsWithChildren) { const selectState = useContext(SelectStateContext); const selectedValue = useContext(SelectedValueContext); const [isExpanded, setExpanded] = useState(false); const itemsList = useAsyncList({ load: async () => { const items = await loadItemChildren(id as string); return { items }; }, }); return ( {({ level }) => ( { setExpanded((s) => !s); }, slot: 'chevron', } : { onPress: () => { selectedValue?.setValue(props.textValue); selectState.setSelectedKey(id as any); selectState.close(); }, }} >
{hasChildren && ( )} {children}
)} {(item: any) => ( {item.name} )} ); } export default function FilePicker() { const rootList = useAsyncList({ load: async () => { const items = await loadItemChildren('1'); return { items }; }, }); return ( console.log(k)}> {(item) => ( {item.name} )} ); }