@particle-academy/react-fancy 1.9.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/icons.cjs +14 -0
- package/dist/icons.cjs.map +1 -0
- package/dist/icons.d.cts +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +3 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.cjs +273 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +238 -39
- package/dist/index.js.map +1 -1
- package/docs/TreeNav.md +35 -0
- package/package.json +11 -1
- package/dist/styles.d.cts +0 -2
- package/dist/styles.d.ts +0 -2
package/dist/index.d.cts
CHANGED
|
@@ -490,6 +490,23 @@ interface IconSet {
|
|
|
490
490
|
}> | null;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
/**
|
|
494
|
+
* Register individual icon components by their kebab-case name.
|
|
495
|
+
*
|
|
496
|
+
* ```tsx
|
|
497
|
+
* import { registerIcons } from "@particle-academy/react-fancy";
|
|
498
|
+
* import { Home, Settings, Mail } from "lucide-react";
|
|
499
|
+
*
|
|
500
|
+
* registerIcons({ Home, Settings, Mail });
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* Icons are registered into the default "lucide" icon set and resolved
|
|
504
|
+
* by the `<Icon name="home" />` component using kebab-case names.
|
|
505
|
+
*/
|
|
506
|
+
declare function registerIcons(icons: Record<string, ComponentType<{
|
|
507
|
+
className?: string;
|
|
508
|
+
size?: number;
|
|
509
|
+
}>>): void;
|
|
493
510
|
declare function registerIconSet(name: string, set: IconSet): void;
|
|
494
511
|
declare function configureIcons(options: {
|
|
495
512
|
defaultSet?: string;
|
|
@@ -2076,6 +2093,13 @@ interface TreeNodeData {
|
|
|
2076
2093
|
/** Whether the node is disabled */
|
|
2077
2094
|
disabled?: boolean;
|
|
2078
2095
|
}
|
|
2096
|
+
/** Where the dragged node will land relative to the drop target */
|
|
2097
|
+
type DropPosition = "before" | "after" | "inside";
|
|
2098
|
+
interface DragState {
|
|
2099
|
+
draggedNodeId: string | null;
|
|
2100
|
+
dropTargetId: string | null;
|
|
2101
|
+
dropPosition: DropPosition | null;
|
|
2102
|
+
}
|
|
2079
2103
|
interface TreeNavProps {
|
|
2080
2104
|
/** Tree data */
|
|
2081
2105
|
nodes: TreeNodeData[];
|
|
@@ -2085,6 +2109,10 @@ interface TreeNavProps {
|
|
|
2085
2109
|
onSelect?: (id: string, node: TreeNodeData) => void;
|
|
2086
2110
|
/** Callback when a node is right-clicked */
|
|
2087
2111
|
onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
|
|
2112
|
+
/** Enable drag-and-drop reordering (default: false) */
|
|
2113
|
+
draggable?: boolean;
|
|
2114
|
+
/** Callback when a node is moved via drag and drop */
|
|
2115
|
+
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2088
2116
|
/** Controlled expanded node IDs */
|
|
2089
2117
|
expandedIds?: string[];
|
|
2090
2118
|
/** Default expanded node IDs (uncontrolled) */
|
|
@@ -2108,6 +2136,12 @@ interface TreeNavContextValue {
|
|
|
2108
2136
|
toggle: (id: string) => void;
|
|
2109
2137
|
indentSize: number;
|
|
2110
2138
|
showIcons: boolean;
|
|
2139
|
+
draggable: boolean;
|
|
2140
|
+
dragState: DragState;
|
|
2141
|
+
setDragState: (state: DragState) => void;
|
|
2142
|
+
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2143
|
+
nodes: TreeNodeData[];
|
|
2144
|
+
expandNode: (id: string) => void;
|
|
2111
2145
|
}
|
|
2112
2146
|
interface TreeNodeProps {
|
|
2113
2147
|
node: TreeNodeData;
|
|
@@ -2120,7 +2154,7 @@ declare namespace TreeNode {
|
|
|
2120
2154
|
var displayName: string;
|
|
2121
2155
|
}
|
|
2122
2156
|
|
|
2123
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2157
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2124
2158
|
declare namespace TreeNavRoot {
|
|
2125
2159
|
var displayName: string;
|
|
2126
2160
|
}
|
|
@@ -2196,4 +2230,4 @@ declare function find(char: string): {
|
|
|
2196
2230
|
category: string;
|
|
2197
2231
|
} | undefined;
|
|
2198
2232
|
|
|
2199
|
-
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Canvas, type CanvasContextValue, type CanvasControlsProps, type CanvasEdgeProps, type CanvasMinimapProps, type CanvasNodeProps, type CanvasProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, DatePicker, type DatePickerProps, type DateRange, Diagram, type DiagramContextValue, type DiagramEntityData, type DiagramEntityProps, type DiagramFieldData, type DiagramFieldProps, type DiagramProps, type DiagramRelationData, type DiagramRelationProps, type DiagramSchema, type DiagramToolbarProps, type DiagramType, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_DATA, EMOJI_ENTRIES, type EdgeAnchor, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiProps, EmojiSelect, type EmojiSelectProps, type ExportFormat, Field, type FieldProps, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, Kanban, type KanbanCardProps, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, RadioGroup, type RadioGroupProps, type RelationType, type RenderExtension, type RenderExtensionProps, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, Slider, type SliderProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, type ViewportState, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
2233
|
+
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Canvas, type CanvasContextValue, type CanvasControlsProps, type CanvasEdgeProps, type CanvasMinimapProps, type CanvasNodeProps, type CanvasProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, DatePicker, type DatePickerProps, type DateRange, Diagram, type DiagramContextValue, type DiagramEntityData, type DiagramEntityProps, type DiagramFieldData, type DiagramFieldProps, type DiagramProps, type DiagramRelationData, type DiagramRelationProps, type DiagramSchema, type DiagramToolbarProps, type DiagramType, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_DATA, EMOJI_ENTRIES, type EdgeAnchor, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiProps, EmojiSelect, type EmojiSelectProps, type ExportFormat, Field, type FieldProps, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, Kanban, type KanbanCardProps, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, RadioGroup, type RadioGroupProps, type RelationType, type RenderExtension, type RenderExtensionProps, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, Slider, type SliderProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, type ViewportState, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
package/dist/index.d.ts
CHANGED
|
@@ -490,6 +490,23 @@ interface IconSet {
|
|
|
490
490
|
}> | null;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
/**
|
|
494
|
+
* Register individual icon components by their kebab-case name.
|
|
495
|
+
*
|
|
496
|
+
* ```tsx
|
|
497
|
+
* import { registerIcons } from "@particle-academy/react-fancy";
|
|
498
|
+
* import { Home, Settings, Mail } from "lucide-react";
|
|
499
|
+
*
|
|
500
|
+
* registerIcons({ Home, Settings, Mail });
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* Icons are registered into the default "lucide" icon set and resolved
|
|
504
|
+
* by the `<Icon name="home" />` component using kebab-case names.
|
|
505
|
+
*/
|
|
506
|
+
declare function registerIcons(icons: Record<string, ComponentType<{
|
|
507
|
+
className?: string;
|
|
508
|
+
size?: number;
|
|
509
|
+
}>>): void;
|
|
493
510
|
declare function registerIconSet(name: string, set: IconSet): void;
|
|
494
511
|
declare function configureIcons(options: {
|
|
495
512
|
defaultSet?: string;
|
|
@@ -2076,6 +2093,13 @@ interface TreeNodeData {
|
|
|
2076
2093
|
/** Whether the node is disabled */
|
|
2077
2094
|
disabled?: boolean;
|
|
2078
2095
|
}
|
|
2096
|
+
/** Where the dragged node will land relative to the drop target */
|
|
2097
|
+
type DropPosition = "before" | "after" | "inside";
|
|
2098
|
+
interface DragState {
|
|
2099
|
+
draggedNodeId: string | null;
|
|
2100
|
+
dropTargetId: string | null;
|
|
2101
|
+
dropPosition: DropPosition | null;
|
|
2102
|
+
}
|
|
2079
2103
|
interface TreeNavProps {
|
|
2080
2104
|
/** Tree data */
|
|
2081
2105
|
nodes: TreeNodeData[];
|
|
@@ -2085,6 +2109,10 @@ interface TreeNavProps {
|
|
|
2085
2109
|
onSelect?: (id: string, node: TreeNodeData) => void;
|
|
2086
2110
|
/** Callback when a node is right-clicked */
|
|
2087
2111
|
onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
|
|
2112
|
+
/** Enable drag-and-drop reordering (default: false) */
|
|
2113
|
+
draggable?: boolean;
|
|
2114
|
+
/** Callback when a node is moved via drag and drop */
|
|
2115
|
+
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2088
2116
|
/** Controlled expanded node IDs */
|
|
2089
2117
|
expandedIds?: string[];
|
|
2090
2118
|
/** Default expanded node IDs (uncontrolled) */
|
|
@@ -2108,6 +2136,12 @@ interface TreeNavContextValue {
|
|
|
2108
2136
|
toggle: (id: string) => void;
|
|
2109
2137
|
indentSize: number;
|
|
2110
2138
|
showIcons: boolean;
|
|
2139
|
+
draggable: boolean;
|
|
2140
|
+
dragState: DragState;
|
|
2141
|
+
setDragState: (state: DragState) => void;
|
|
2142
|
+
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
2143
|
+
nodes: TreeNodeData[];
|
|
2144
|
+
expandNode: (id: string) => void;
|
|
2111
2145
|
}
|
|
2112
2146
|
interface TreeNodeProps {
|
|
2113
2147
|
node: TreeNodeData;
|
|
@@ -2120,7 +2154,7 @@ declare namespace TreeNode {
|
|
|
2120
2154
|
var displayName: string;
|
|
2121
2155
|
}
|
|
2122
2156
|
|
|
2123
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2157
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
|
|
2124
2158
|
declare namespace TreeNavRoot {
|
|
2125
2159
|
var displayName: string;
|
|
2126
2160
|
}
|
|
@@ -2196,4 +2230,4 @@ declare function find(char: string): {
|
|
|
2196
2230
|
category: string;
|
|
2197
2231
|
} | undefined;
|
|
2198
2232
|
|
|
2199
|
-
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Canvas, type CanvasContextValue, type CanvasControlsProps, type CanvasEdgeProps, type CanvasMinimapProps, type CanvasNodeProps, type CanvasProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, DatePicker, type DatePickerProps, type DateRange, Diagram, type DiagramContextValue, type DiagramEntityData, type DiagramEntityProps, type DiagramFieldData, type DiagramFieldProps, type DiagramProps, type DiagramRelationData, type DiagramRelationProps, type DiagramSchema, type DiagramToolbarProps, type DiagramType, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_DATA, EMOJI_ENTRIES, type EdgeAnchor, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiProps, EmojiSelect, type EmojiSelectProps, type ExportFormat, Field, type FieldProps, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, Kanban, type KanbanCardProps, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, RadioGroup, type RadioGroupProps, type RelationType, type RenderExtension, type RenderExtensionProps, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, Slider, type SliderProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, type ViewportState, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
2233
|
+
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Canvas, type CanvasContextValue, type CanvasControlsProps, type CanvasEdgeProps, type CanvasMinimapProps, type CanvasNodeProps, type CanvasProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, DatePicker, type DatePickerProps, type DateRange, Diagram, type DiagramContextValue, type DiagramEntityData, type DiagramEntityProps, type DiagramFieldData, type DiagramFieldProps, type DiagramProps, type DiagramRelationData, type DiagramRelationProps, type DiagramSchema, type DiagramToolbarProps, type DiagramType, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_DATA, EMOJI_ENTRIES, type EdgeAnchor, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiProps, EmojiSelect, type EmojiSelectProps, type ExportFormat, Field, type FieldProps, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, Kanban, type KanbanCardProps, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, RadioGroup, type RadioGroupProps, type RelationType, type RenderExtension, type RenderExtensionProps, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, Slider, type SliderProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, type ViewportState, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { forwardRef, useId, useRef, useEffect, useState, useCallback, createContext, Children, isValidElement, useMemo, cloneElement, useLayoutEffect, useContext, Fragment as Fragment$1 } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
|
-
import * as LucideIcons from 'lucide-react';
|
|
5
|
-
import { X, ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Search, Menu, File, Upload, PanelLeftOpen, PanelLeftClose, ZoomIn, ZoomOut, RotateCcw, Maximize, Check, XCircle, AlertTriangle, Info } from 'lucide-react';
|
|
6
4
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
7
5
|
import { createPortal } from 'react-dom';
|
|
6
|
+
import { X, ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Search, Menu, File, Upload, PanelLeftOpen, PanelLeftClose, ZoomIn, ZoomOut, RotateCcw, Maximize, Check, XCircle, AlertTriangle, Info } from 'lucide-react';
|
|
8
7
|
import { marked } from 'marked';
|
|
9
8
|
|
|
10
9
|
// src/components/Action/Action.tsx
|
|
@@ -885,22 +884,31 @@ function search(query) {
|
|
|
885
884
|
function find(char) {
|
|
886
885
|
return EMOJI_ENTRIES.find((e) => e.char === char);
|
|
887
886
|
}
|
|
887
|
+
|
|
888
|
+
// src/components/Icon/icon-config.ts
|
|
888
889
|
var registry = /* @__PURE__ */ new Map();
|
|
889
890
|
var defaultSetName = "lucide";
|
|
890
891
|
function kebabToPascal(str) {
|
|
891
892
|
return str.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
892
893
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
894
|
+
function registerIcons(icons) {
|
|
895
|
+
let set = registry.get("lucide");
|
|
896
|
+
if (!set) {
|
|
897
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
898
|
+
set = {
|
|
899
|
+
resolve: (name) => {
|
|
900
|
+
const pascal = kebabToPascal(name);
|
|
901
|
+
return map2.get(pascal) ?? null;
|
|
902
|
+
},
|
|
903
|
+
_map: map2
|
|
904
|
+
};
|
|
905
|
+
registry.set("lucide", set);
|
|
901
906
|
}
|
|
902
|
-
|
|
903
|
-
|
|
907
|
+
const map = set._map;
|
|
908
|
+
for (const [key, component] of Object.entries(icons)) {
|
|
909
|
+
map.set(key, component);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
904
912
|
function registerIconSet(name, set) {
|
|
905
913
|
registry.set(name, set);
|
|
906
914
|
}
|
|
@@ -10254,12 +10262,67 @@ function ChevronIcon({ open }) {
|
|
|
10254
10262
|
}
|
|
10255
10263
|
);
|
|
10256
10264
|
}
|
|
10265
|
+
function isDescendantOf(nodes, ancestorId, targetId) {
|
|
10266
|
+
function findNode(haystack, id) {
|
|
10267
|
+
for (const n of haystack) {
|
|
10268
|
+
if (n.id === id) return n;
|
|
10269
|
+
if (n.children) {
|
|
10270
|
+
const found = findNode(n.children, id);
|
|
10271
|
+
if (found) return found;
|
|
10272
|
+
}
|
|
10273
|
+
}
|
|
10274
|
+
return void 0;
|
|
10275
|
+
}
|
|
10276
|
+
function hasDescendant(node, id) {
|
|
10277
|
+
if (!node.children) return false;
|
|
10278
|
+
for (const child of node.children) {
|
|
10279
|
+
if (child.id === id) return true;
|
|
10280
|
+
if (hasDescendant(child, id)) return true;
|
|
10281
|
+
}
|
|
10282
|
+
return false;
|
|
10283
|
+
}
|
|
10284
|
+
const ancestor = findNode(nodes, ancestorId);
|
|
10285
|
+
return ancestor ? hasDescendant(ancestor, targetId) : false;
|
|
10286
|
+
}
|
|
10287
|
+
function computeDropPosition(e, isFolder) {
|
|
10288
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
10289
|
+
const offsetY = e.clientY - rect.top;
|
|
10290
|
+
const third = rect.height / 3;
|
|
10291
|
+
if (offsetY < third) return "before";
|
|
10292
|
+
if (offsetY > third * 2) return "after";
|
|
10293
|
+
return isFolder ? "inside" : "after";
|
|
10294
|
+
}
|
|
10257
10295
|
function TreeNode({ node, depth }) {
|
|
10258
|
-
const {
|
|
10296
|
+
const {
|
|
10297
|
+
selectedId,
|
|
10298
|
+
onSelect,
|
|
10299
|
+
onNodeContextMenu,
|
|
10300
|
+
expandedIds,
|
|
10301
|
+
toggle,
|
|
10302
|
+
indentSize,
|
|
10303
|
+
showIcons,
|
|
10304
|
+
draggable,
|
|
10305
|
+
dragState,
|
|
10306
|
+
setDragState,
|
|
10307
|
+
onNodeMove,
|
|
10308
|
+
nodes,
|
|
10309
|
+
expandNode
|
|
10310
|
+
} = useTreeNav();
|
|
10259
10311
|
const isFolder = node.type === "folder" || node.children && node.children.length > 0;
|
|
10260
10312
|
const isExpanded = expandedIds.includes(node.id);
|
|
10261
10313
|
const isSelected = selectedId === node.id;
|
|
10262
10314
|
const paddingLeft = depth * indentSize + 4;
|
|
10315
|
+
const isDragging = dragState.draggedNodeId === node.id;
|
|
10316
|
+
const isDropTarget = dragState.dropTargetId === node.id;
|
|
10317
|
+
const dropPosition = isDropTarget ? dragState.dropPosition : null;
|
|
10318
|
+
const autoExpandTimer = useRef(null);
|
|
10319
|
+
const clearAutoExpand = useCallback(() => {
|
|
10320
|
+
if (autoExpandTimer.current) {
|
|
10321
|
+
clearTimeout(autoExpandTimer.current);
|
|
10322
|
+
autoExpandTimer.current = null;
|
|
10323
|
+
}
|
|
10324
|
+
}, []);
|
|
10325
|
+
useEffect(() => clearAutoExpand, [clearAutoExpand]);
|
|
10263
10326
|
const handleClick = () => {
|
|
10264
10327
|
if (node.disabled) return;
|
|
10265
10328
|
if (isFolder) {
|
|
@@ -10273,30 +10336,116 @@ function TreeNode({ node, depth }) {
|
|
|
10273
10336
|
onNodeContextMenu(e, node);
|
|
10274
10337
|
}
|
|
10275
10338
|
};
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10339
|
+
const handleDragStart = useCallback((e) => {
|
|
10340
|
+
e.dataTransfer.setData("text/plain", node.id);
|
|
10341
|
+
e.dataTransfer.effectAllowed = "move";
|
|
10342
|
+
requestAnimationFrame(() => {
|
|
10343
|
+
setDragState({ draggedNodeId: node.id, dropTargetId: null, dropPosition: null });
|
|
10344
|
+
});
|
|
10345
|
+
}, [node.id, setDragState]);
|
|
10346
|
+
const handleDragEnd = useCallback(() => {
|
|
10347
|
+
clearAutoExpand();
|
|
10348
|
+
setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });
|
|
10349
|
+
}, [clearAutoExpand, setDragState]);
|
|
10350
|
+
const handleDragOver = useCallback((e) => {
|
|
10351
|
+
if (!dragState.draggedNodeId) return;
|
|
10352
|
+
const sourceId = dragState.draggedNodeId;
|
|
10353
|
+
if (sourceId === node.id) return;
|
|
10354
|
+
if (isDescendantOf(nodes, sourceId, node.id)) return;
|
|
10355
|
+
e.preventDefault();
|
|
10356
|
+
e.stopPropagation();
|
|
10357
|
+
e.dataTransfer.dropEffect = "move";
|
|
10358
|
+
const position = computeDropPosition(e, !!isFolder);
|
|
10359
|
+
if (isFolder && !isExpanded && position === "inside") {
|
|
10360
|
+
if (!autoExpandTimer.current) {
|
|
10361
|
+
autoExpandTimer.current = setTimeout(() => {
|
|
10362
|
+
expandNode(node.id);
|
|
10363
|
+
autoExpandTimer.current = null;
|
|
10364
|
+
}, 500);
|
|
10296
10365
|
}
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10366
|
+
} else {
|
|
10367
|
+
clearAutoExpand();
|
|
10368
|
+
}
|
|
10369
|
+
if (dragState.dropTargetId !== node.id || dragState.dropPosition !== position) {
|
|
10370
|
+
setDragState({ draggedNodeId: sourceId, dropTargetId: node.id, dropPosition: position });
|
|
10371
|
+
}
|
|
10372
|
+
}, [dragState, node.id, isFolder, isExpanded, nodes, setDragState, expandNode, clearAutoExpand]);
|
|
10373
|
+
const handleDragLeave = useCallback((e) => {
|
|
10374
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
10375
|
+
clearAutoExpand();
|
|
10376
|
+
if (dragState.dropTargetId === node.id) {
|
|
10377
|
+
setDragState({ ...dragState, dropTargetId: null, dropPosition: null });
|
|
10378
|
+
}
|
|
10379
|
+
}
|
|
10380
|
+
}, [dragState, node.id, setDragState, clearAutoExpand]);
|
|
10381
|
+
const handleDrop = useCallback((e) => {
|
|
10382
|
+
e.preventDefault();
|
|
10383
|
+
e.stopPropagation();
|
|
10384
|
+
clearAutoExpand();
|
|
10385
|
+
const sourceId = dragState.draggedNodeId;
|
|
10386
|
+
const position = dragState.dropPosition;
|
|
10387
|
+
if (!sourceId || !position) return;
|
|
10388
|
+
if (sourceId === node.id) return;
|
|
10389
|
+
if (isDescendantOf(nodes, sourceId, node.id)) return;
|
|
10390
|
+
onNodeMove?.(sourceId, node.id, position);
|
|
10391
|
+
setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });
|
|
10392
|
+
}, [dragState, node.id, nodes, onNodeMove, setDragState, clearAutoExpand]);
|
|
10393
|
+
const canDrag = draggable && !node.disabled;
|
|
10394
|
+
return /* @__PURE__ */ jsxs(
|
|
10395
|
+
"div",
|
|
10396
|
+
{
|
|
10397
|
+
"data-react-fancy-tree-node": "",
|
|
10398
|
+
onDragOver: draggable ? handleDragOver : void 0,
|
|
10399
|
+
onDragLeave: draggable ? handleDragLeave : void 0,
|
|
10400
|
+
onDrop: draggable ? handleDrop : void 0,
|
|
10401
|
+
children: [
|
|
10402
|
+
isDropTarget && dropPosition === "before" && /* @__PURE__ */ jsx(
|
|
10403
|
+
"div",
|
|
10404
|
+
{
|
|
10405
|
+
"data-react-fancy-tree-drop-indicator": "before",
|
|
10406
|
+
className: "pointer-events-none h-0.5 rounded-full bg-blue-500",
|
|
10407
|
+
style: { marginLeft: paddingLeft }
|
|
10408
|
+
}
|
|
10409
|
+
),
|
|
10410
|
+
/* @__PURE__ */ jsxs(
|
|
10411
|
+
"button",
|
|
10412
|
+
{
|
|
10413
|
+
type: "button",
|
|
10414
|
+
draggable: canDrag,
|
|
10415
|
+
onDragStart: canDrag ? handleDragStart : void 0,
|
|
10416
|
+
onDragEnd: canDrag ? handleDragEnd : void 0,
|
|
10417
|
+
onClick: handleClick,
|
|
10418
|
+
onContextMenu: handleContextMenu,
|
|
10419
|
+
disabled: node.disabled,
|
|
10420
|
+
className: cn(
|
|
10421
|
+
"flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors",
|
|
10422
|
+
isSelected ? "bg-blue-500/15 text-blue-600 dark:text-blue-400" : "text-zinc-700 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800",
|
|
10423
|
+
node.disabled && "pointer-events-none opacity-40",
|
|
10424
|
+
isDragging && "opacity-50",
|
|
10425
|
+
canDrag && "cursor-grab active:cursor-grabbing",
|
|
10426
|
+
isDropTarget && dropPosition === "inside" && "bg-blue-500/10 ring-1 ring-blue-500/30 ring-inset"
|
|
10427
|
+
),
|
|
10428
|
+
style: { paddingLeft },
|
|
10429
|
+
children: [
|
|
10430
|
+
isFolder && /* @__PURE__ */ jsx(ChevronIcon, { open: isExpanded }),
|
|
10431
|
+
!isFolder && /* @__PURE__ */ jsx("span", { className: "w-3.5 shrink-0" }),
|
|
10432
|
+
showIcons && (node.icon ?? (isFolder ? /* @__PURE__ */ jsx(FolderIcon, { open: isExpanded }) : /* @__PURE__ */ jsx(FileIcon, { ext: node.ext ?? node.label.split(".").pop() }))),
|
|
10433
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: node.label })
|
|
10434
|
+
]
|
|
10435
|
+
}
|
|
10436
|
+
),
|
|
10437
|
+
isDropTarget && dropPosition === "after" && /* @__PURE__ */ jsx(
|
|
10438
|
+
"div",
|
|
10439
|
+
{
|
|
10440
|
+
"data-react-fancy-tree-drop-indicator": "after",
|
|
10441
|
+
className: "pointer-events-none h-0.5 rounded-full bg-blue-500",
|
|
10442
|
+
style: { marginLeft: paddingLeft }
|
|
10443
|
+
}
|
|
10444
|
+
),
|
|
10445
|
+
isFolder && isExpanded && node.children && /* @__PURE__ */ jsx("div", { "data-react-fancy-tree-node-children": "", children: node.children.map((child) => /* @__PURE__ */ jsx(TreeNode, { node: child, depth: depth + 1 }, child.id)) })
|
|
10446
|
+
]
|
|
10447
|
+
}
|
|
10448
|
+
);
|
|
10300
10449
|
}
|
|
10301
10450
|
TreeNode.displayName = "TreeNode";
|
|
10302
10451
|
function collectFolderIds(nodes) {
|
|
@@ -10309,11 +10458,18 @@ function collectFolderIds(nodes) {
|
|
|
10309
10458
|
}
|
|
10310
10459
|
return ids;
|
|
10311
10460
|
}
|
|
10461
|
+
var EMPTY_DRAG_STATE = {
|
|
10462
|
+
draggedNodeId: null,
|
|
10463
|
+
dropTargetId: null,
|
|
10464
|
+
dropPosition: null
|
|
10465
|
+
};
|
|
10312
10466
|
function TreeNavRoot({
|
|
10313
10467
|
nodes,
|
|
10314
10468
|
selectedId,
|
|
10315
10469
|
onSelect,
|
|
10316
10470
|
onNodeContextMenu,
|
|
10471
|
+
draggable = false,
|
|
10472
|
+
onNodeMove,
|
|
10317
10473
|
expandedIds: controlledExpanded,
|
|
10318
10474
|
defaultExpandedIds,
|
|
10319
10475
|
onExpandedChange,
|
|
@@ -10339,15 +10495,58 @@ function TreeNavRoot({
|
|
|
10339
10495
|
},
|
|
10340
10496
|
[expandedIds, isControlled, onExpandedChange]
|
|
10341
10497
|
);
|
|
10498
|
+
const expandNode = useCallback(
|
|
10499
|
+
(id) => {
|
|
10500
|
+
if (expandedIds.includes(id)) return;
|
|
10501
|
+
const next = [...expandedIds, id];
|
|
10502
|
+
if (!isControlled) {
|
|
10503
|
+
setInternalExpanded(next);
|
|
10504
|
+
}
|
|
10505
|
+
onExpandedChange?.(next);
|
|
10506
|
+
},
|
|
10507
|
+
[expandedIds, isControlled, onExpandedChange]
|
|
10508
|
+
);
|
|
10509
|
+
const [dragState, setDragState] = useState(EMPTY_DRAG_STATE);
|
|
10510
|
+
const handleDragEnd = useCallback(() => {
|
|
10511
|
+
setDragState(EMPTY_DRAG_STATE);
|
|
10512
|
+
}, []);
|
|
10342
10513
|
const ctx = useMemo(
|
|
10343
|
-
() => ({
|
|
10344
|
-
|
|
10514
|
+
() => ({
|
|
10515
|
+
selectedId,
|
|
10516
|
+
onSelect,
|
|
10517
|
+
onNodeContextMenu,
|
|
10518
|
+
expandedIds,
|
|
10519
|
+
toggle,
|
|
10520
|
+
indentSize,
|
|
10521
|
+
showIcons,
|
|
10522
|
+
draggable,
|
|
10523
|
+
dragState,
|
|
10524
|
+
setDragState,
|
|
10525
|
+
onNodeMove,
|
|
10526
|
+
nodes,
|
|
10527
|
+
expandNode
|
|
10528
|
+
}),
|
|
10529
|
+
[
|
|
10530
|
+
selectedId,
|
|
10531
|
+
onSelect,
|
|
10532
|
+
onNodeContextMenu,
|
|
10533
|
+
expandedIds,
|
|
10534
|
+
toggle,
|
|
10535
|
+
indentSize,
|
|
10536
|
+
showIcons,
|
|
10537
|
+
draggable,
|
|
10538
|
+
dragState,
|
|
10539
|
+
onNodeMove,
|
|
10540
|
+
nodes,
|
|
10541
|
+
expandNode
|
|
10542
|
+
]
|
|
10345
10543
|
);
|
|
10346
10544
|
return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
10347
10545
|
"nav",
|
|
10348
10546
|
{
|
|
10349
10547
|
"data-react-fancy-tree-nav": "",
|
|
10350
10548
|
className: cn("flex flex-col gap-0.5 py-1 text-sm", className),
|
|
10549
|
+
onDragEnd: draggable ? handleDragEnd : void 0,
|
|
10351
10550
|
children: nodes.map((node) => /* @__PURE__ */ jsx(TreeNode, { node, depth: 0 }, node.id))
|
|
10352
10551
|
}
|
|
10353
10552
|
) });
|
|
@@ -10357,6 +10556,6 @@ var TreeNav = Object.assign(TreeNavRoot, {
|
|
|
10357
10556
|
Node: TreeNode
|
|
10358
10557
|
});
|
|
10359
10558
|
|
|
10360
|
-
export { Accordion, Action, Autocomplete, Avatar, Badge, Brand, Breadcrumbs, Calendar, Callout, Canvas, Card, Carousel, Chart, Checkbox, CheckboxGroup, ColorPicker, Command, Composer, ContentRenderer, ContextMenu, DatePicker, Diagram, Dropdown, EMOJI_DATA, EMOJI_ENTRIES, Editor, Emoji, EmojiSelect, Field, FileUpload, Heading, Icon, Input, Kanban, Menu2 as Menu, MobileMenu, Modal, MultiSwitch, Navbar, OtpInput, Pagination, Pillbox, Popover, Portal, Profile, Progress, RadioGroup, Select, Separator, Sidebar, Skeleton, Slider, Switch, Table, Tabs, Text, Textarea, TimePicker, Timeline, Toast, Tooltip, TreeNav, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId11 as useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
10559
|
+
export { Accordion, Action, Autocomplete, Avatar, Badge, Brand, Breadcrumbs, Calendar, Callout, Canvas, Card, Carousel, Chart, Checkbox, CheckboxGroup, ColorPicker, Command, Composer, ContentRenderer, ContextMenu, DatePicker, Diagram, Dropdown, EMOJI_DATA, EMOJI_ENTRIES, Editor, Emoji, EmojiSelect, Field, FileUpload, Heading, Icon, Input, Kanban, Menu2 as Menu, MobileMenu, Modal, MultiSwitch, Navbar, OtpInput, Pagination, Pillbox, Popover, Portal, Profile, Progress, RadioGroup, Select, Separator, Sidebar, Skeleton, Slider, Switch, Table, Tabs, Text, Textarea, TimePicker, Timeline, Toast, Tooltip, TreeNav, cn, configureIcons, find, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, search, useAccordion, useAnimation, useCanvas, useCarousel, useCommand, useContextMenu, useControllableState, useDiagram, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId11 as useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
10361
10560
|
//# sourceMappingURL=index.js.map
|
|
10362
10561
|
//# sourceMappingURL=index.js.map
|