@uipath/apollo-wind 0.10.0 → 0.11.0-pr295.af4e744

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.
Files changed (187) hide show
  1. package/dist/components/custom/canvas-studio.cjs +133 -0
  2. package/dist/components/custom/canvas-studio.d.ts +99 -0
  3. package/dist/components/custom/canvas-studio.js +93 -0
  4. package/dist/components/custom/canvas.cjs +44 -0
  5. package/dist/components/custom/canvas.d.ts +14 -0
  6. package/dist/components/custom/canvas.js +10 -0
  7. package/dist/components/custom/chat-composer.cjs +105 -0
  8. package/dist/components/custom/chat-composer.d.ts +15 -0
  9. package/dist/components/custom/chat-composer.js +71 -0
  10. package/dist/components/custom/chat-first-experience.cjs +87 -0
  11. package/dist/components/custom/chat-first-experience.d.ts +24 -0
  12. package/dist/components/custom/chat-first-experience.js +53 -0
  13. package/dist/components/custom/chat-prompt-suggestions.cjs +49 -0
  14. package/dist/components/custom/chat-prompt-suggestions.d.ts +18 -0
  15. package/dist/components/custom/chat-prompt-suggestions.js +15 -0
  16. package/dist/components/custom/chat-steps-view.cjs +308 -0
  17. package/dist/components/custom/chat-steps-view.d.ts +38 -0
  18. package/dist/components/custom/chat-steps-view.js +274 -0
  19. package/dist/components/custom/flow-node.cjs +76 -0
  20. package/dist/components/custom/flow-node.d.ts +20 -0
  21. package/dist/components/custom/flow-node.js +42 -0
  22. package/dist/components/custom/flow-properties-bar.cjs +103 -0
  23. package/dist/components/custom/flow-properties-bar.d.ts +21 -0
  24. package/dist/components/custom/flow-properties-bar.js +69 -0
  25. package/dist/components/custom/flow-properties-expanded.cjs +328 -0
  26. package/dist/components/custom/flow-properties-expanded.d.ts +21 -0
  27. package/dist/components/custom/flow-properties-expanded.js +294 -0
  28. package/dist/components/custom/flow-properties-simple.cjs +364 -0
  29. package/dist/components/custom/flow-properties-simple.d.ts +62 -0
  30. package/dist/components/custom/flow-properties-simple.js +330 -0
  31. package/dist/components/custom/flow-properties.cjs +56 -0
  32. package/dist/components/custom/flow-properties.d.ts +28 -0
  33. package/dist/components/custom/flow-properties.js +22 -0
  34. package/dist/components/custom/global-header.cjs +422 -0
  35. package/dist/components/custom/global-header.d.ts +38 -0
  36. package/dist/components/custom/global-header.js +388 -0
  37. package/dist/components/custom/grid-maestro.cjs +62 -0
  38. package/dist/components/custom/grid-maestro.d.ts +19 -0
  39. package/dist/components/custom/grid-maestro.js +22 -0
  40. package/dist/components/custom/page-header.cjs +92 -0
  41. package/dist/components/custom/page-header.d.ts +43 -0
  42. package/dist/components/custom/page-header.js +58 -0
  43. package/dist/components/custom/panel-delegate.cjs +285 -0
  44. package/dist/components/custom/panel-delegate.d.ts +34 -0
  45. package/dist/components/custom/panel-delegate.js +251 -0
  46. package/dist/components/custom/panel-flow.cjs +262 -0
  47. package/dist/components/custom/panel-flow.d.ts +38 -0
  48. package/dist/components/custom/panel-flow.js +225 -0
  49. package/dist/components/custom/panel-maestro.cjs +74 -0
  50. package/dist/components/custom/panel-maestro.d.ts +30 -0
  51. package/dist/components/custom/panel-maestro.js +40 -0
  52. package/dist/components/custom/panel-studio.cjs +122 -0
  53. package/dist/components/custom/panel-studio.d.ts +48 -0
  54. package/dist/components/custom/panel-studio.js +85 -0
  55. package/dist/components/custom/toolbar-canvas.cjs +124 -0
  56. package/dist/components/custom/toolbar-canvas.d.ts +15 -0
  57. package/dist/components/custom/toolbar-canvas.js +90 -0
  58. package/dist/components/custom/toolbar-view.cjs +121 -0
  59. package/dist/components/custom/toolbar-view.d.ts +14 -0
  60. package/dist/components/custom/toolbar-view.js +87 -0
  61. package/dist/components/custom/viewport-guard.cjs +92 -0
  62. package/dist/components/custom/viewport-guard.d.ts +23 -0
  63. package/dist/components/custom/viewport-guard.js +55 -0
  64. package/dist/components/forms/field-renderer.cjs +3 -1
  65. package/dist/components/forms/field-renderer.js +3 -1
  66. package/dist/components/forms/form-designer.cjs +13 -2
  67. package/dist/components/forms/form-designer.js +13 -2
  68. package/dist/components/forms/rules-engine.d.ts +1 -1
  69. package/dist/components/ui/breadcrumb.cjs +1 -2
  70. package/dist/components/ui/breadcrumb.js +1 -2
  71. package/dist/components/ui/button-group.cjs +5 -3
  72. package/dist/components/ui/button-group.d.ts +2 -2
  73. package/dist/components/ui/button-group.js +5 -3
  74. package/dist/components/ui/button.cjs +3 -3
  75. package/dist/components/ui/button.js +3 -3
  76. package/dist/components/ui/chart.cjs +223 -0
  77. package/dist/components/ui/chart.d.ts +40 -0
  78. package/dist/components/ui/chart.js +174 -0
  79. package/dist/components/ui/code-block.cjs +258 -0
  80. package/dist/components/ui/code-block.d.ts +48 -0
  81. package/dist/components/ui/code-block.js +207 -0
  82. package/dist/components/ui/data-table.cjs +22 -4
  83. package/dist/components/ui/data-table.d.ts +5 -2
  84. package/dist/components/ui/data-table.js +23 -5
  85. package/dist/components/ui/editable-cell.cjs +3 -10
  86. package/dist/components/ui/editable-cell.js +3 -10
  87. package/dist/components/ui/empty-state.cjs +17 -6
  88. package/dist/components/ui/empty-state.d.ts +7 -0
  89. package/dist/components/ui/empty-state.js +17 -6
  90. package/dist/components/ui/file-upload.cjs +8 -0
  91. package/dist/components/ui/file-upload.js +8 -0
  92. package/dist/components/ui/index.cjs +289 -149
  93. package/dist/components/ui/index.d.ts +2 -3
  94. package/dist/components/ui/index.js +2 -3
  95. package/dist/components/ui/multi-select.cjs +3 -10
  96. package/dist/components/ui/multi-select.js +3 -10
  97. package/dist/components/ui/pagination.cjs +0 -1
  98. package/dist/components/ui/pagination.js +0 -1
  99. package/dist/components/ui/resizable.d.ts +1 -1
  100. package/dist/components/ui/tree-view.cjs +1117 -0
  101. package/dist/components/ui/tree-view.d.ts +95 -0
  102. package/dist/components/ui/tree-view.js +1083 -0
  103. package/dist/foundation/Future/colors.cjs +92 -0
  104. package/dist/foundation/Future/colors.d.ts +132 -0
  105. package/dist/foundation/Future/colors.js +43 -0
  106. package/dist/foundation/Future/radius.cjs +46 -0
  107. package/dist/foundation/Future/radius.d.ts +33 -0
  108. package/dist/foundation/Future/radius.js +12 -0
  109. package/dist/foundation/Future/responsive.cjs +49 -0
  110. package/dist/foundation/Future/responsive.d.ts +40 -0
  111. package/dist/foundation/Future/responsive.js +12 -0
  112. package/dist/foundation/Future/shadows.cjs +48 -0
  113. package/dist/foundation/Future/shadows.d.ts +29 -0
  114. package/dist/foundation/Future/shadows.js +11 -0
  115. package/dist/foundation/Future/spacing.cjs +71 -0
  116. package/dist/foundation/Future/spacing.d.ts +80 -0
  117. package/dist/foundation/Future/spacing.js +31 -0
  118. package/dist/foundation/Future/strokes.cjs +59 -0
  119. package/dist/foundation/Future/strokes.d.ts +49 -0
  120. package/dist/foundation/Future/strokes.js +19 -0
  121. package/dist/foundation/Future/types.cjs +18 -0
  122. package/dist/foundation/Future/types.d.ts +25 -0
  123. package/dist/foundation/Future/types.js +0 -0
  124. package/dist/foundation/Future/typography.cjs +79 -0
  125. package/dist/foundation/Future/typography.d.ts +86 -0
  126. package/dist/foundation/Future/typography.js +33 -0
  127. package/dist/index.cjs +131 -221
  128. package/dist/index.d.ts +4 -3
  129. package/dist/index.js +3 -4
  130. package/dist/src/foundation/Future/themes.css +279 -0
  131. package/dist/styles.css +1941 -605
  132. package/dist/tailwind.css +874 -87
  133. package/dist/templates/Admin/settings-admin.d.ts +5 -0
  134. package/dist/templates/Admin/template-admin.d.ts +86 -0
  135. package/dist/templates/Delegate/template-delegate.d.ts +26 -0
  136. package/dist/templates/EmptyErrors/error-components.d.ts +3 -0
  137. package/dist/templates/Experiments/ideas-AnimatedGradientText.d.ts +23 -0
  138. package/dist/templates/Flow/template-flow.d.ts +57 -0
  139. package/dist/templates/Maestro/template-maestro.d.ts +52 -0
  140. package/dist/templates/Studio/template-studio.d.ts +102 -0
  141. package/dist/templates/{vscode-example.d.ts → VisualStudio/shell.d.ts} +1 -1
  142. package/package.json +12 -1
  143. package/dist/components/ui/menubar.cjs +0 -210
  144. package/dist/components/ui/menubar.d.ts +0 -28
  145. package/dist/components/ui/menubar.js +0 -131
  146. package/dist/components/ui/navigation-menu.cjs +0 -122
  147. package/dist/components/ui/navigation-menu.d.ts +0 -12
  148. package/dist/components/ui/navigation-menu.js +0 -64
  149. package/dist/examples/admin-layout-example.cjs +0 -490
  150. package/dist/examples/admin-layout-example.d.ts +0 -92
  151. package/dist/examples/admin-layout-example.js +0 -411
  152. package/dist/examples/app-shell-example.cjs +0 -452
  153. package/dist/examples/app-shell-example.d.ts +0 -52
  154. package/dist/examples/app-shell-example.js +0 -418
  155. package/dist/examples/dashboard-example.cjs +0 -590
  156. package/dist/examples/dashboard-example.d.ts +0 -11
  157. package/dist/examples/dashboard-example.js +0 -556
  158. package/dist/examples/data-management-example.cjs +0 -584
  159. package/dist/examples/data-management-example.d.ts +0 -1
  160. package/dist/examples/data-management-example.js +0 -550
  161. package/dist/examples/flow-editor-layout-example.cjs +0 -309
  162. package/dist/examples/flow-editor-layout-example.d.ts +0 -22
  163. package/dist/examples/flow-editor-layout-example.js +0 -269
  164. package/dist/examples/flow-start-example.cjs +0 -467
  165. package/dist/examples/flow-start-example.d.ts +0 -30
  166. package/dist/examples/flow-start-example.js +0 -433
  167. package/dist/examples/form-builder-example.cjs +0 -674
  168. package/dist/examples/form-builder-example.js +0 -640
  169. package/dist/examples/new-project-example.cjs +0 -550
  170. package/dist/examples/new-project-example.d.ts +0 -30
  171. package/dist/examples/new-project-example.js +0 -516
  172. package/dist/examples/settings-example.cjs +0 -864
  173. package/dist/examples/settings-example.d.ts +0 -1
  174. package/dist/examples/settings-example.js +0 -830
  175. package/dist/examples/vscode-example.cjs +0 -340
  176. package/dist/examples/vscode-example.d.ts +0 -80
  177. package/dist/examples/vscode-example.js +0 -270
  178. package/dist/templates/admin-layout-example.d.ts +0 -92
  179. package/dist/templates/app-shell-example.d.ts +0 -52
  180. package/dist/templates/dashboard-example.d.ts +0 -11
  181. package/dist/templates/data-management-example.d.ts +0 -1
  182. package/dist/templates/flow-editor-layout-example.d.ts +0 -22
  183. package/dist/templates/flow-start-example.d.ts +0 -30
  184. package/dist/templates/form-builder-example.d.ts +0 -1
  185. package/dist/templates/new-project-example.d.ts +0 -30
  186. package/dist/templates/settings-example.d.ts +0 -1
  187. /package/dist/{examples → templates/Forms}/form-builder-example.d.ts +0 -0
@@ -0,0 +1,1083 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import { Button } from "./button.js";
5
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible.js";
6
+ import { Box, ChevronRight, Folder, Info, MoreHorizontal, Search, X } from "lucide-react";
7
+ import { AnimatePresence, motion } from "framer-motion";
8
+ import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "./context-menu.js";
9
+ import { HoverCard, HoverCardContent, HoverCardTrigger } from "./hover-card.js";
10
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./dropdown-menu.js";
11
+ import { Badge } from "./badge.js";
12
+ import { cn } from "../../lib/index.js";
13
+ import { Input } from "./input.js";
14
+ import { Checkbox } from "./checkbox.js";
15
+ const buildItemMap = (items)=>{
16
+ const map = new Map();
17
+ const processItem = (item)=>{
18
+ map.set(item.id, item);
19
+ item.children?.forEach(processItem);
20
+ };
21
+ items.forEach(processItem);
22
+ return map;
23
+ };
24
+ const getCheckState = (item, itemMap)=>{
25
+ const originalItem = itemMap.get(item.id);
26
+ if (!originalItem) return "unchecked";
27
+ if (!originalItem.children || 0 === originalItem.children.length) return originalItem.checked ? "checked" : "unchecked";
28
+ let checkedCount = 0;
29
+ let indeterminateCount = 0;
30
+ originalItem.children.forEach((child)=>{
31
+ const childState = getCheckState(child, itemMap);
32
+ if ("checked" === childState) checkedCount++;
33
+ if ("indeterminate" === childState) indeterminateCount++;
34
+ });
35
+ const totalChildren = originalItem.children.length;
36
+ if (checkedCount === totalChildren) return "checked";
37
+ if (checkedCount > 0 || indeterminateCount > 0) return "indeterminate";
38
+ return "unchecked";
39
+ };
40
+ const defaultIconMap = {
41
+ file: /*#__PURE__*/ jsx(Box, {
42
+ className: "h-4 w-4 text-red-600"
43
+ }),
44
+ folder: /*#__PURE__*/ jsx(Folder, {
45
+ className: "h-4 w-4 text-primary/80"
46
+ })
47
+ };
48
+ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expandedIds, onToggleExpand, selectionMode, getIcon, onAction, onAccessChange, allItems, showAccessRights, showSelectionCheckboxes, itemMap, iconMap = defaultIconMap, menuItems, getSelectedItems }) {
49
+ const isOpen = expandedIds.has(item.id);
50
+ const isSelected = selectedIds.has(item.id);
51
+ const isDisabled = true === item.disabled;
52
+ const itemRef = useRef(null);
53
+ const [selectionStyle, setSelectionStyle] = useState("");
54
+ const getVisibleItems = useCallback((items)=>{
55
+ let visibleItems = [];
56
+ items.forEach((item)=>{
57
+ visibleItems.push(item);
58
+ if (item.children && expandedIds.has(item.id)) visibleItems = [
59
+ ...visibleItems,
60
+ ...getVisibleItems(item.children)
61
+ ];
62
+ });
63
+ return visibleItems;
64
+ }, [
65
+ expandedIds
66
+ ]);
67
+ useEffect(()=>{
68
+ if (!isSelected) return void setSelectionStyle("");
69
+ const visibleItems = getVisibleItems(allItems);
70
+ const currentIndex = visibleItems.findIndex((i)=>i.id === item.id);
71
+ const prevItem = visibleItems[currentIndex - 1];
72
+ const nextItem = visibleItems[currentIndex + 1];
73
+ const isPrevSelected = prevItem && selectedIds.has(prevItem.id);
74
+ const isNextSelected = nextItem && selectedIds.has(nextItem.id);
75
+ const roundTop = !isPrevSelected;
76
+ const roundBottom = !isNextSelected;
77
+ setSelectionStyle(`${roundTop ? "rounded-t-md" : ""} ${roundBottom ? "rounded-b-md" : ""}`);
78
+ }, [
79
+ isSelected,
80
+ selectedIds,
81
+ expandedIds,
82
+ item.id,
83
+ getVisibleItems,
84
+ allItems
85
+ ]);
86
+ const handleClick = (e)=>{
87
+ e.stopPropagation();
88
+ e.preventDefault();
89
+ if (isDisabled || "none" === selectionMode) return;
90
+ let newSelection = new Set(selectedIds);
91
+ if (!itemRef.current) return;
92
+ if ("single" === selectionMode) {
93
+ newSelection = new Set([
94
+ item.id
95
+ ]);
96
+ lastSelectedId.current = item.id;
97
+ onSelect(newSelection);
98
+ if (item.children && isSelected) onToggleExpand(item.id, !isOpen);
99
+ return;
100
+ }
101
+ if (e.shiftKey && null !== lastSelectedId.current) {
102
+ const items = Array.from(document.querySelectorAll("[data-tree-item]"));
103
+ const lastIndex = items.findIndex((el)=>el.getAttribute("data-id") === lastSelectedId.current);
104
+ const currentIndex = items.findIndex((el)=>el === itemRef.current);
105
+ const [start, end] = [
106
+ Math.min(lastIndex, currentIndex),
107
+ Math.max(lastIndex, currentIndex)
108
+ ];
109
+ items.slice(start, end + 1).forEach((el)=>{
110
+ const id = el.getAttribute("data-id");
111
+ const isDisabledEl = "true" === el.getAttribute("data-disabled");
112
+ const parentFolderClosed = el.closest('[data-folder-closed="true"]');
113
+ const isClosedFolder = "true" === el.getAttribute("data-folder-closed");
114
+ if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
115
+ });
116
+ } else if (e.ctrlKey || e.metaKey) if (newSelection.has(item.id)) newSelection.delete(item.id);
117
+ else newSelection.add(item.id);
118
+ else {
119
+ newSelection = new Set([
120
+ item.id
121
+ ]);
122
+ if (item.children && isSelected) onToggleExpand(item.id, !isOpen);
123
+ }
124
+ lastSelectedId.current = item.id;
125
+ onSelect(newSelection);
126
+ };
127
+ const handleAccessClick = (e)=>{
128
+ e.stopPropagation();
129
+ if (onAccessChange) {
130
+ const currentState = getCheckState(item, itemMap);
131
+ const newChecked = "checked" !== currentState;
132
+ onAccessChange(item, newChecked);
133
+ }
134
+ };
135
+ const renderIcon = ()=>{
136
+ if (getIcon) return getIcon(item, depth);
137
+ return iconMap[item.type] || iconMap.folder || defaultIconMap.folder;
138
+ };
139
+ const getItemPath = (item, items)=>{
140
+ const path = [
141
+ item.name
142
+ ];
143
+ const findParent = (currentItem, allItems)=>{
144
+ for (const potentialParent of allItems){
145
+ if (potentialParent.children?.some((child)=>child.id === currentItem.id)) {
146
+ path.unshift(potentialParent.name);
147
+ findParent(potentialParent, allItems);
148
+ break;
149
+ }
150
+ if (potentialParent.children) findParent(currentItem, potentialParent.children);
151
+ }
152
+ };
153
+ findParent(item, items);
154
+ return path.join(" → ");
155
+ };
156
+ const getSelectedChildrenCount = (item)=>{
157
+ let count = 0;
158
+ if (!item.children) return 0;
159
+ item.children.forEach((child)=>{
160
+ if (selectedIds.has(child.id)) count++;
161
+ if (child.children) count += getSelectedChildrenCount(child);
162
+ });
163
+ return count;
164
+ };
165
+ const selectedCount = item.children && !isOpen && getSelectedChildrenCount(item) || null;
166
+ return /*#__PURE__*/ jsxs(ContextMenu, {
167
+ children: [
168
+ /*#__PURE__*/ jsx(ContextMenuTrigger, {
169
+ children: /*#__PURE__*/ jsxs("div", {
170
+ children: [
171
+ /*#__PURE__*/ jsx("div", {
172
+ ref: itemRef,
173
+ role: "treeitem",
174
+ "aria-expanded": item.children ? isOpen : void 0,
175
+ "aria-selected": isSelected && "none" !== selectionMode,
176
+ "aria-disabled": isDisabled,
177
+ tabIndex: 0,
178
+ "data-tree-item": true,
179
+ "data-id": item.id,
180
+ "data-depth": depth,
181
+ "data-folder-closed": item.children && !isOpen,
182
+ "data-disabled": isDisabled,
183
+ className: `select-none rounded-md px-1 ${isDisabled ? "cursor-not-allowed opacity-50 text-muted-foreground" : `cursor-pointer ${isSelected && "none" !== selectionMode ? `bg-accent ${selectionStyle}` : "text-foreground hover:bg-muted/50"}`}`,
184
+ style: {
185
+ paddingLeft: `${20 * depth}px`
186
+ },
187
+ onClick: handleClick,
188
+ onKeyDown: (e)=>{
189
+ if ('Enter' === e.key || ' ' === e.key) {
190
+ e.preventDefault();
191
+ handleClick(e);
192
+ }
193
+ },
194
+ children: /*#__PURE__*/ jsx("div", {
195
+ className: "flex items-center h-8 min-w-0",
196
+ children: item.children ? /*#__PURE__*/ jsxs("div", {
197
+ className: "flex items-center gap-2 flex-1 min-w-0 group",
198
+ children: [
199
+ /*#__PURE__*/ jsx(Collapsible, {
200
+ open: isOpen,
201
+ onOpenChange: (open)=>onToggleExpand(item.id, open),
202
+ children: /*#__PURE__*/ jsx(CollapsibleTrigger, {
203
+ asChild: true,
204
+ onClick: (e)=>e.stopPropagation(),
205
+ children: /*#__PURE__*/ jsx(Button, {
206
+ variant: "ghost",
207
+ size: "icon",
208
+ className: "h-6 w-6",
209
+ children: /*#__PURE__*/ jsx(motion.div, {
210
+ initial: false,
211
+ animate: {
212
+ rotate: isOpen ? 90 : 0
213
+ },
214
+ transition: {
215
+ duration: 0.1
216
+ },
217
+ children: /*#__PURE__*/ jsx(ChevronRight, {
218
+ className: "h-4 w-4"
219
+ })
220
+ })
221
+ })
222
+ })
223
+ }),
224
+ showAccessRights && /*#__PURE__*/ jsxs("button", {
225
+ type: "button",
226
+ className: "relative flex items-center justify-center w-4 h-4 cursor-pointer hover:opacity-80 bg-transparent border-0 p-0",
227
+ onClick: handleAccessClick,
228
+ "aria-label": `Toggle access for ${item.name}`,
229
+ children: [
230
+ "checked" === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
231
+ className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
232
+ children: /*#__PURE__*/ jsx("svg", {
233
+ className: "h-3 w-3 text-primary-foreground",
234
+ fill: "none",
235
+ viewBox: "0 0 24 24",
236
+ stroke: "currentColor",
237
+ children: /*#__PURE__*/ jsx("path", {
238
+ strokeLinecap: "round",
239
+ strokeLinejoin: "round",
240
+ strokeWidth: 2,
241
+ d: "M5 13l4 4L19 7"
242
+ })
243
+ })
244
+ }),
245
+ "unchecked" === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
246
+ className: "w-4 h-4 border rounded border-input"
247
+ }),
248
+ "indeterminate" === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
249
+ className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
250
+ children: /*#__PURE__*/ jsx("div", {
251
+ className: "h-0.5 w-2 bg-primary-foreground"
252
+ })
253
+ })
254
+ ]
255
+ }),
256
+ renderIcon(),
257
+ /*#__PURE__*/ jsx("span", {
258
+ className: "flex-1 min-w-0 truncate",
259
+ children: item.name
260
+ }),
261
+ item.badge && /*#__PURE__*/ jsx("span", {
262
+ className: "shrink-0 ml-1",
263
+ children: item.badge
264
+ }),
265
+ item.meta && /*#__PURE__*/ jsx("span", {
266
+ className: "text-xs text-muted-foreground shrink-0 ml-1 truncate max-w-[6rem]",
267
+ children: item.meta
268
+ }),
269
+ null !== selectedCount && selectedCount > 0 && /*#__PURE__*/ jsxs(Badge, {
270
+ variant: "secondary",
271
+ className: "shrink-0 mr-1 bg-blue-100 hover:bg-blue-100",
272
+ children: [
273
+ selectedCount,
274
+ " selected"
275
+ ]
276
+ }),
277
+ (item.actions?.length ?? 0) > 0 ? /*#__PURE__*/ jsxs(DropdownMenu, {
278
+ children: [
279
+ /*#__PURE__*/ jsx(DropdownMenuTrigger, {
280
+ asChild: true,
281
+ children: /*#__PURE__*/ jsx(Button, {
282
+ variant: "ghost",
283
+ size: "icon",
284
+ className: "h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",
285
+ onClick: (e)=>e.stopPropagation(),
286
+ children: /*#__PURE__*/ jsx(MoreHorizontal, {
287
+ className: "h-4 w-4 text-muted-foreground"
288
+ })
289
+ })
290
+ }),
291
+ /*#__PURE__*/ jsxs(DropdownMenuContent, {
292
+ align: "end",
293
+ className: "w-48",
294
+ children: [
295
+ item.actions?.map((action)=>/*#__PURE__*/ jsxs(DropdownMenuItem, {
296
+ disabled: isDisabled,
297
+ onClick: (e)=>{
298
+ e.stopPropagation();
299
+ action.onClick(item);
300
+ },
301
+ children: [
302
+ action.icon,
303
+ action.label ?? action.id
304
+ ]
305
+ }, action.id)),
306
+ /*#__PURE__*/ jsxs(DropdownMenuSub, {
307
+ children: [
308
+ /*#__PURE__*/ jsx(DropdownMenuSubTrigger, {
309
+ children: "View details"
310
+ }),
311
+ /*#__PURE__*/ jsx(DropdownMenuSubContent, {
312
+ className: "w-64 p-3",
313
+ children: /*#__PURE__*/ jsxs("div", {
314
+ className: "space-y-2 text-sm",
315
+ children: [
316
+ /*#__PURE__*/ jsx("h4", {
317
+ className: "font-semibold",
318
+ children: item.name
319
+ }),
320
+ /*#__PURE__*/ jsxs("div", {
321
+ className: "text-muted-foreground space-y-1",
322
+ children: [
323
+ /*#__PURE__*/ jsxs("div", {
324
+ children: [
325
+ /*#__PURE__*/ jsx("span", {
326
+ className: "font-medium",
327
+ children: "Type:"
328
+ }),
329
+ " ",
330
+ item.type.charAt(0).toUpperCase() + item.type.slice(1).replace("_", " ")
331
+ ]
332
+ }),
333
+ /*#__PURE__*/ jsxs("div", {
334
+ children: [
335
+ /*#__PURE__*/ jsx("span", {
336
+ className: "font-medium",
337
+ children: "ID:"
338
+ }),
339
+ " ",
340
+ item.id
341
+ ]
342
+ }),
343
+ /*#__PURE__*/ jsxs("div", {
344
+ children: [
345
+ /*#__PURE__*/ jsx("span", {
346
+ className: "font-medium",
347
+ children: "Location:"
348
+ }),
349
+ " ",
350
+ getItemPath(item, allItems)
351
+ ]
352
+ }),
353
+ /*#__PURE__*/ jsxs("div", {
354
+ children: [
355
+ /*#__PURE__*/ jsx("span", {
356
+ className: "font-medium",
357
+ children: "Items:"
358
+ }),
359
+ " ",
360
+ item.children?.length ?? 0,
361
+ " direct items"
362
+ ]
363
+ })
364
+ ]
365
+ })
366
+ ]
367
+ })
368
+ })
369
+ ]
370
+ })
371
+ ]
372
+ })
373
+ ]
374
+ }) : /*#__PURE__*/ jsxs(HoverCard, {
375
+ children: [
376
+ /*#__PURE__*/ jsx(HoverCardTrigger, {
377
+ asChild: true,
378
+ children: /*#__PURE__*/ jsx(Button, {
379
+ variant: "ghost",
380
+ size: "icon",
381
+ className: "h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
382
+ onClick: (e)=>e.stopPropagation(),
383
+ children: /*#__PURE__*/ jsx(Info, {
384
+ className: "h-4 w-4 text-muted-foreground"
385
+ })
386
+ })
387
+ }),
388
+ /*#__PURE__*/ jsx(HoverCardContent, {
389
+ className: "w-80",
390
+ children: /*#__PURE__*/ jsxs("div", {
391
+ className: "space-y-2",
392
+ children: [
393
+ /*#__PURE__*/ jsx("h4", {
394
+ className: "text-sm font-semibold",
395
+ children: item.name
396
+ }),
397
+ /*#__PURE__*/ jsxs("div", {
398
+ className: "text-sm text-muted-foreground space-y-1",
399
+ children: [
400
+ /*#__PURE__*/ jsxs("div", {
401
+ children: [
402
+ /*#__PURE__*/ jsx("span", {
403
+ className: "font-medium",
404
+ children: "Type:"
405
+ }),
406
+ " ",
407
+ item.type.charAt(0).toUpperCase() + item.type.slice(1).replace("_", " ")
408
+ ]
409
+ }),
410
+ /*#__PURE__*/ jsxs("div", {
411
+ children: [
412
+ /*#__PURE__*/ jsx("span", {
413
+ className: "font-medium",
414
+ children: "ID:"
415
+ }),
416
+ " ",
417
+ item.id
418
+ ]
419
+ }),
420
+ /*#__PURE__*/ jsxs("div", {
421
+ children: [
422
+ /*#__PURE__*/ jsx("span", {
423
+ className: "font-medium",
424
+ children: "Location:"
425
+ }),
426
+ " ",
427
+ getItemPath(item, allItems)
428
+ ]
429
+ }),
430
+ /*#__PURE__*/ jsxs("div", {
431
+ children: [
432
+ /*#__PURE__*/ jsx("span", {
433
+ className: "font-medium",
434
+ children: "Items:"
435
+ }),
436
+ " ",
437
+ item.children?.length ?? 0,
438
+ " direct items"
439
+ ]
440
+ })
441
+ ]
442
+ })
443
+ ]
444
+ })
445
+ })
446
+ ]
447
+ })
448
+ ]
449
+ }) : /*#__PURE__*/ jsxs("div", {
450
+ className: "flex items-center gap-2 flex-1 min-w-0 pl-8 group",
451
+ children: [
452
+ showSelectionCheckboxes && !item.children && !isDisabled && /*#__PURE__*/ jsx(Checkbox, {
453
+ checked: isSelected,
454
+ onCheckedChange: (checked)=>{
455
+ if ("none" === selectionMode) return;
456
+ const newSelection = "single" === selectionMode ? new Set(checked ? [
457
+ item.id
458
+ ] : []) : new Set(selectedIds);
459
+ if ("multiple" === selectionMode) if (checked) newSelection.add(item.id);
460
+ else newSelection.delete(item.id);
461
+ lastSelectedId.current = item.id;
462
+ onSelect(newSelection);
463
+ },
464
+ onClick: (e)=>e.stopPropagation(),
465
+ "aria-label": `Select ${item.name}`
466
+ }),
467
+ showAccessRights && /*#__PURE__*/ jsx("button", {
468
+ type: "button",
469
+ className: "relative flex items-center justify-center w-4 h-4 cursor-pointer hover:opacity-80 bg-transparent border-0 p-0",
470
+ onClick: handleAccessClick,
471
+ "aria-label": `Toggle access for ${item.name}`,
472
+ children: item.checked ? /*#__PURE__*/ jsx("div", {
473
+ className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
474
+ children: /*#__PURE__*/ jsx("svg", {
475
+ className: "h-3 w-3 text-primary-foreground",
476
+ fill: "none",
477
+ viewBox: "0 0 24 24",
478
+ stroke: "currentColor",
479
+ children: /*#__PURE__*/ jsx("path", {
480
+ strokeLinecap: "round",
481
+ strokeLinejoin: "round",
482
+ strokeWidth: 2,
483
+ d: "M5 13l4 4L19 7"
484
+ })
485
+ })
486
+ }) : /*#__PURE__*/ jsx("div", {
487
+ className: "w-4 h-4 border rounded border-input"
488
+ })
489
+ }),
490
+ renderIcon(),
491
+ /*#__PURE__*/ jsx("span", {
492
+ className: "flex-1 min-w-0 truncate",
493
+ children: item.name
494
+ }),
495
+ item.badge && /*#__PURE__*/ jsx("span", {
496
+ className: "shrink-0 ml-1",
497
+ children: item.badge
498
+ }),
499
+ item.meta && /*#__PURE__*/ jsx("span", {
500
+ className: "text-xs text-muted-foreground shrink-0 ml-1 truncate max-w-[6rem]",
501
+ children: item.meta
502
+ }),
503
+ (item.actions?.length ?? 0) > 0 ? /*#__PURE__*/ jsxs(DropdownMenu, {
504
+ children: [
505
+ /*#__PURE__*/ jsx(DropdownMenuTrigger, {
506
+ asChild: true,
507
+ children: /*#__PURE__*/ jsx(Button, {
508
+ variant: "ghost",
509
+ size: "icon",
510
+ className: "h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",
511
+ onClick: (e)=>e.stopPropagation(),
512
+ children: /*#__PURE__*/ jsx(MoreHorizontal, {
513
+ className: "h-4 w-4 text-muted-foreground"
514
+ })
515
+ })
516
+ }),
517
+ /*#__PURE__*/ jsxs(DropdownMenuContent, {
518
+ align: "end",
519
+ className: "w-48",
520
+ children: [
521
+ item.actions?.map((action)=>/*#__PURE__*/ jsxs(DropdownMenuItem, {
522
+ disabled: isDisabled,
523
+ onClick: (e)=>{
524
+ e.stopPropagation();
525
+ action.onClick(item);
526
+ },
527
+ children: [
528
+ action.icon,
529
+ action.label ?? action.id
530
+ ]
531
+ }, action.id)),
532
+ /*#__PURE__*/ jsxs(DropdownMenuSub, {
533
+ children: [
534
+ /*#__PURE__*/ jsx(DropdownMenuSubTrigger, {
535
+ children: "View details"
536
+ }),
537
+ /*#__PURE__*/ jsx(DropdownMenuSubContent, {
538
+ className: "w-64 p-3",
539
+ children: /*#__PURE__*/ jsxs("div", {
540
+ className: "space-y-2 text-sm",
541
+ children: [
542
+ /*#__PURE__*/ jsx("h4", {
543
+ className: "font-semibold",
544
+ children: item.name
545
+ }),
546
+ /*#__PURE__*/ jsxs("div", {
547
+ className: "text-muted-foreground space-y-1",
548
+ children: [
549
+ /*#__PURE__*/ jsxs("div", {
550
+ children: [
551
+ /*#__PURE__*/ jsx("span", {
552
+ className: "font-medium",
553
+ children: "Type:"
554
+ }),
555
+ " ",
556
+ item.type.charAt(0).toUpperCase() + item.type.slice(1).replace("_", " ")
557
+ ]
558
+ }),
559
+ /*#__PURE__*/ jsxs("div", {
560
+ children: [
561
+ /*#__PURE__*/ jsx("span", {
562
+ className: "font-medium",
563
+ children: "ID:"
564
+ }),
565
+ " ",
566
+ item.id
567
+ ]
568
+ }),
569
+ /*#__PURE__*/ jsxs("div", {
570
+ children: [
571
+ /*#__PURE__*/ jsx("span", {
572
+ className: "font-medium",
573
+ children: "Location:"
574
+ }),
575
+ " ",
576
+ getItemPath(item, allItems)
577
+ ]
578
+ })
579
+ ]
580
+ })
581
+ ]
582
+ })
583
+ })
584
+ ]
585
+ })
586
+ ]
587
+ })
588
+ ]
589
+ }) : /*#__PURE__*/ jsxs(HoverCard, {
590
+ children: [
591
+ /*#__PURE__*/ jsx(HoverCardTrigger, {
592
+ asChild: true,
593
+ children: /*#__PURE__*/ jsx(Button, {
594
+ variant: "ghost",
595
+ size: "icon",
596
+ className: "h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
597
+ onClick: (e)=>e.stopPropagation(),
598
+ children: /*#__PURE__*/ jsx(Info, {
599
+ className: "h-4 w-4 text-muted-foreground"
600
+ })
601
+ })
602
+ }),
603
+ /*#__PURE__*/ jsx(HoverCardContent, {
604
+ className: "w-80",
605
+ children: /*#__PURE__*/ jsxs("div", {
606
+ className: "space-y-2",
607
+ children: [
608
+ /*#__PURE__*/ jsx("h4", {
609
+ className: "text-sm font-semibold",
610
+ children: item.name
611
+ }),
612
+ /*#__PURE__*/ jsxs("div", {
613
+ className: "text-sm text-muted-foreground space-y-1",
614
+ children: [
615
+ /*#__PURE__*/ jsxs("div", {
616
+ children: [
617
+ /*#__PURE__*/ jsx("span", {
618
+ className: "font-medium",
619
+ children: "Type:"
620
+ }),
621
+ " ",
622
+ item.type.charAt(0).toUpperCase() + item.type.slice(1).replace("_", " ")
623
+ ]
624
+ }),
625
+ /*#__PURE__*/ jsxs("div", {
626
+ children: [
627
+ /*#__PURE__*/ jsx("span", {
628
+ className: "font-medium",
629
+ children: "ID:"
630
+ }),
631
+ " ",
632
+ item.id
633
+ ]
634
+ }),
635
+ /*#__PURE__*/ jsxs("div", {
636
+ children: [
637
+ /*#__PURE__*/ jsx("span", {
638
+ className: "font-medium",
639
+ children: "Location:"
640
+ }),
641
+ " ",
642
+ getItemPath(item, allItems)
643
+ ]
644
+ })
645
+ ]
646
+ })
647
+ ]
648
+ })
649
+ })
650
+ ]
651
+ })
652
+ ]
653
+ })
654
+ })
655
+ }),
656
+ item.children && /*#__PURE__*/ jsx(Collapsible, {
657
+ open: isOpen,
658
+ onOpenChange: (open)=>onToggleExpand(item.id, open),
659
+ children: /*#__PURE__*/ jsx(AnimatePresence, {
660
+ initial: false,
661
+ children: isOpen && /*#__PURE__*/ jsx(CollapsibleContent, {
662
+ forceMount: true,
663
+ asChild: true,
664
+ children: /*#__PURE__*/ jsx(motion.div, {
665
+ initial: {
666
+ height: 0,
667
+ opacity: 0
668
+ },
669
+ animate: {
670
+ height: "auto",
671
+ opacity: 1
672
+ },
673
+ exit: {
674
+ height: 0,
675
+ opacity: 0
676
+ },
677
+ transition: {
678
+ duration: 0.05
679
+ },
680
+ children: item.children?.map((child)=>/*#__PURE__*/ jsx(TreeItem, {
681
+ item: child,
682
+ depth: depth + 1,
683
+ selectedIds: selectedIds,
684
+ lastSelectedId: lastSelectedId,
685
+ onSelect: onSelect,
686
+ expandedIds: expandedIds,
687
+ onToggleExpand: onToggleExpand,
688
+ selectionMode: selectionMode,
689
+ getIcon: getIcon,
690
+ onAction: onAction,
691
+ onAccessChange: onAccessChange,
692
+ allItems: allItems,
693
+ showAccessRights: showAccessRights,
694
+ showSelectionCheckboxes: showSelectionCheckboxes,
695
+ itemMap: itemMap,
696
+ iconMap: iconMap,
697
+ menuItems: menuItems,
698
+ getSelectedItems: getSelectedItems
699
+ }, child.id))
700
+ })
701
+ })
702
+ })
703
+ })
704
+ ]
705
+ })
706
+ }),
707
+ /*#__PURE__*/ jsx(ContextMenuContent, {
708
+ className: "w-64",
709
+ children: menuItems?.map((menuItem)=>/*#__PURE__*/ jsxs(ContextMenuItem, {
710
+ onClick: ()=>{
711
+ const items = selectedIds.has(item.id) ? getSelectedItems() : [
712
+ item
713
+ ];
714
+ menuItem.action(items);
715
+ },
716
+ children: [
717
+ menuItem.icon && /*#__PURE__*/ jsx("span", {
718
+ className: "mr-2 h-4 w-4",
719
+ children: menuItem.icon
720
+ }),
721
+ menuItem.label
722
+ ]
723
+ }, menuItem.id))
724
+ })
725
+ ]
726
+ });
727
+ }
728
+ function TreeView({ className, containerClassName, checkboxLabels = {
729
+ check: "Check",
730
+ uncheck: "Uncheck"
731
+ }, data, iconMap, searchPlaceholder = "Search...", selectionText = "selected", showExpandAll = true, showCheckboxes = false, showSelectionCheckboxes = false, selectionMode = "multiple", title, getIcon, onSelectionChange, onAction, onCheckChange, menuItems }) {
732
+ const [currentMousePos, setCurrentMousePos] = useState(0);
733
+ const [dragStart, setDragStart] = useState(null);
734
+ const [dragStartPosition, setDragStartPosition] = useState(null);
735
+ const [expandedIds, setExpandedIds] = useState(new Set());
736
+ const [isDragging, setIsDragging] = useState(false);
737
+ const [selectedIds, setSelectedIds] = useState(new Set());
738
+ const [searchQuery, setSearchQuery] = useState("");
739
+ const dragRef = useRef(null);
740
+ const lastSelectedId = useRef(null);
741
+ const treeRef = useRef(null);
742
+ const DRAG_THRESHOLD = 10;
743
+ const itemMap = useMemo(()=>buildItemMap(data), [
744
+ data
745
+ ]);
746
+ const { filteredData, searchExpandedIds } = useMemo(()=>{
747
+ if (!searchQuery.trim()) return {
748
+ filteredData: data,
749
+ searchExpandedIds: new Set()
750
+ };
751
+ const searchLower = searchQuery.toLowerCase();
752
+ const newExpandedIds = new Set();
753
+ const itemMatches = (item)=>{
754
+ const nameMatches = item.name.toLowerCase().includes(searchLower);
755
+ if (nameMatches) return true;
756
+ if (item.children) return item.children.some((child)=>itemMatches(child));
757
+ return false;
758
+ };
759
+ const filterTree = (items)=>items.map((item)=>{
760
+ if (!item.children) return itemMatches(item) ? item : null;
761
+ const filteredChildren = filterTree(item.children);
762
+ if (filteredChildren.length > 0 || itemMatches(item)) {
763
+ if (item.children) newExpandedIds.add(item.id);
764
+ return {
765
+ ...item,
766
+ children: filteredChildren
767
+ };
768
+ }
769
+ return null;
770
+ }).filter((item)=>null !== item);
771
+ return {
772
+ filteredData: filterTree(data),
773
+ searchExpandedIds: newExpandedIds
774
+ };
775
+ }, [
776
+ data,
777
+ searchQuery
778
+ ]);
779
+ useEffect(()=>{
780
+ if (searchQuery.trim()) setExpandedIds((prev)=>new Set([
781
+ ...prev,
782
+ ...searchExpandedIds
783
+ ]));
784
+ }, [
785
+ searchExpandedIds,
786
+ searchQuery
787
+ ]);
788
+ useEffect(()=>{
789
+ const handleClickAway = (e)=>{
790
+ const target = e.target;
791
+ const clickedInside = treeRef.current && treeRef.current.contains(target) || dragRef.current && dragRef.current.contains(target) || target.closest('[role="menu"]') || target.closest("[data-radix-popper-content-wrapper]");
792
+ if (!clickedInside) {
793
+ setSelectedIds(new Set());
794
+ lastSelectedId.current = null;
795
+ }
796
+ };
797
+ document.addEventListener("mousedown", handleClickAway);
798
+ return ()=>document.removeEventListener("mousedown", handleClickAway);
799
+ }, []);
800
+ const getAllFolderIds = (items)=>{
801
+ let ids = [];
802
+ items.forEach((item)=>{
803
+ if (item.children) {
804
+ ids.push(item.id);
805
+ ids = [
806
+ ...ids,
807
+ ...getAllFolderIds(item.children)
808
+ ];
809
+ }
810
+ });
811
+ return ids;
812
+ };
813
+ const handleExpandAll = ()=>{
814
+ setExpandedIds(new Set(getAllFolderIds(data)));
815
+ };
816
+ const handleCollapseAll = ()=>{
817
+ setExpandedIds(new Set());
818
+ };
819
+ const handleToggleExpand = (id, isOpen)=>{
820
+ const newExpandedIds = new Set(expandedIds);
821
+ if (isOpen) newExpandedIds.add(id);
822
+ else newExpandedIds.delete(id);
823
+ setExpandedIds(newExpandedIds);
824
+ };
825
+ const getSelectedItems = useCallback(()=>{
826
+ const items = [];
827
+ const processItem = (item)=>{
828
+ if (selectedIds.has(item.id)) items.push(item);
829
+ item.children?.forEach(processItem);
830
+ };
831
+ data.forEach(processItem);
832
+ return items;
833
+ }, [
834
+ selectedIds,
835
+ data
836
+ ]);
837
+ const getEffectiveSelectedItems = useCallback(()=>{
838
+ const selectedItems = getSelectedItems();
839
+ const selectedIdsSet = new Set(selectedItems.map((item)=>item.id));
840
+ return selectedItems.filter((item)=>{
841
+ if (!item.children) return true;
842
+ const hasSelectedChildren = item.children.some((child)=>selectedIdsSet.has(child.id));
843
+ return !hasSelectedChildren;
844
+ });
845
+ }, [
846
+ getSelectedItems
847
+ ]);
848
+ const handleMouseDown = useCallback((e)=>{
849
+ if (0 !== e.button || e.target.closest("button")) return;
850
+ setDragStartPosition({
851
+ x: e.clientX,
852
+ y: e.clientY
853
+ });
854
+ }, []);
855
+ const handleMouseMove = useCallback((e)=>{
856
+ if ("none" === selectionMode) return;
857
+ if (!(1 & e.buttons)) {
858
+ setIsDragging(false);
859
+ setDragStart(null);
860
+ setDragStartPosition(null);
861
+ return;
862
+ }
863
+ if (!dragStartPosition) return;
864
+ const deltaX = e.clientX - dragStartPosition.x;
865
+ const deltaY = e.clientY - dragStartPosition.y;
866
+ const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
867
+ if (!isDragging) {
868
+ if (distance > DRAG_THRESHOLD) {
869
+ setIsDragging(true);
870
+ setDragStart(dragStartPosition.y);
871
+ if (!e.shiftKey && !e.ctrlKey) {
872
+ setSelectedIds(new Set());
873
+ lastSelectedId.current = null;
874
+ }
875
+ }
876
+ return;
877
+ }
878
+ if (!dragRef.current) return;
879
+ const items = Array.from(dragRef.current.querySelectorAll("[data-tree-item]"));
880
+ const startY = dragStart;
881
+ const currentY = e.clientY;
882
+ const [selectionStart, selectionEnd] = [
883
+ Math.min(startY || 0, currentY),
884
+ Math.max(startY || 0, currentY)
885
+ ];
886
+ const newSelection = new Set(e.shiftKey || e.ctrlKey ? Array.from(selectedIds) : []);
887
+ items.forEach((item)=>{
888
+ const rect = item.getBoundingClientRect();
889
+ const itemTop = rect.top;
890
+ const itemBottom = rect.top + rect.height;
891
+ if (itemBottom >= selectionStart && itemTop <= selectionEnd) {
892
+ const id = item.getAttribute("data-id");
893
+ const isDisabledEl = "true" === item.getAttribute("data-disabled");
894
+ const isClosedFolder = "true" === item.getAttribute("data-folder-closed");
895
+ const parentFolderClosed = item.closest('[data-folder-closed="true"]');
896
+ if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
897
+ }
898
+ });
899
+ setSelectedIds(newSelection);
900
+ setCurrentMousePos(e.clientY);
901
+ }, [
902
+ isDragging,
903
+ dragStart,
904
+ selectedIds,
905
+ dragStartPosition,
906
+ selectionMode
907
+ ]);
908
+ const handleMouseUp = useCallback(()=>{
909
+ setIsDragging(false);
910
+ setDragStart(null);
911
+ setDragStartPosition(null);
912
+ }, []);
913
+ useEffect(()=>{
914
+ if (isDragging) {
915
+ document.addEventListener("mouseup", handleMouseUp);
916
+ document.addEventListener("mouseleave", handleMouseUp);
917
+ }
918
+ return ()=>{
919
+ document.removeEventListener("mouseup", handleMouseUp);
920
+ document.removeEventListener("mouseleave", handleMouseUp);
921
+ };
922
+ }, [
923
+ isDragging,
924
+ handleMouseUp
925
+ ]);
926
+ useEffect(()=>{
927
+ if (onSelectionChange) onSelectionChange(getSelectedItems());
928
+ }, [
929
+ selectedIds,
930
+ onSelectionChange,
931
+ getSelectedItems
932
+ ]);
933
+ return /*#__PURE__*/ jsx("div", {
934
+ className: cn("flex gap-4 min-w-0", containerClassName ? "w-full" : ""),
935
+ children: /*#__PURE__*/ jsxs("div", {
936
+ ref: treeRef,
937
+ className: cn("bg-background rounded-xl border space-y-4 relative shadow-lg flex flex-col min-w-0 overflow-hidden", containerClassName ?? "p-6 max-w-2xl w-[600px]"),
938
+ children: [
939
+ title && /*#__PURE__*/ jsx("div", {
940
+ className: "text-sm font-medium text-foreground shrink-0",
941
+ children: title
942
+ }),
943
+ /*#__PURE__*/ jsxs("div", {
944
+ className: "relative w-full shrink-0",
945
+ children: [
946
+ /*#__PURE__*/ jsx(Search, {
947
+ className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"
948
+ }),
949
+ /*#__PURE__*/ jsx(Input, {
950
+ placeholder: searchPlaceholder,
951
+ value: searchQuery,
952
+ onChange: (e)=>setSearchQuery(e.target.value),
953
+ className: "h-10 w-full pl-9"
954
+ })
955
+ ]
956
+ }),
957
+ /*#__PURE__*/ jsxs("div", {
958
+ className: "flex items-center justify-between gap-2 shrink-0",
959
+ children: [
960
+ /*#__PURE__*/ jsx("div", {
961
+ className: "flex gap-2",
962
+ children: showExpandAll && /*#__PURE__*/ jsxs(Fragment, {
963
+ children: [
964
+ /*#__PURE__*/ jsx(Button, {
965
+ variant: "ghost",
966
+ size: "sm",
967
+ className: "h-6 px-1.5 text-xs",
968
+ onClick: handleExpandAll,
969
+ children: "Expand"
970
+ }),
971
+ /*#__PURE__*/ jsx(Button, {
972
+ variant: "ghost",
973
+ size: "sm",
974
+ className: "h-6 px-1.5 text-xs",
975
+ onClick: handleCollapseAll,
976
+ children: "Collapse"
977
+ })
978
+ ]
979
+ })
980
+ }),
981
+ "none" !== selectionMode && selectedIds.size > 0 ? /*#__PURE__*/ jsxs("div", {
982
+ className: "flex items-center gap-2",
983
+ children: [
984
+ /*#__PURE__*/ jsxs("span", {
985
+ className: "text-xs text-muted-foreground",
986
+ children: [
987
+ selectedIds.size,
988
+ " ",
989
+ selectionText
990
+ ]
991
+ }),
992
+ /*#__PURE__*/ jsxs(Button, {
993
+ variant: "ghost",
994
+ size: "sm",
995
+ className: "h-6 px-1.5 text-xs",
996
+ onClick: ()=>{
997
+ setSelectedIds(new Set());
998
+ lastSelectedId.current = null;
999
+ },
1000
+ children: [
1001
+ /*#__PURE__*/ jsx(X, {
1002
+ className: "h-3 w-3 mr-1"
1003
+ }),
1004
+ "Clear"
1005
+ ]
1006
+ }),
1007
+ showCheckboxes && /*#__PURE__*/ jsxs("div", {
1008
+ className: "flex gap-2",
1009
+ children: [
1010
+ /*#__PURE__*/ jsx(Button, {
1011
+ variant: "ghost",
1012
+ size: "sm",
1013
+ className: "h-8 px-2 text-green-600 hover:text-green-700 hover:bg-green-50",
1014
+ onClick: ()=>{
1015
+ const effectiveItems = getEffectiveSelectedItems();
1016
+ const processItem = (item)=>{
1017
+ onCheckChange?.(item, true);
1018
+ item.children?.forEach(processItem);
1019
+ };
1020
+ effectiveItems.forEach(processItem);
1021
+ },
1022
+ children: checkboxLabels.check
1023
+ }),
1024
+ /*#__PURE__*/ jsx(Button, {
1025
+ variant: "ghost",
1026
+ size: "sm",
1027
+ className: "h-8 px-2 text-red-600 hover:text-red-700 hover:bg-red-50",
1028
+ onClick: ()=>{
1029
+ const effectiveItems = getEffectiveSelectedItems();
1030
+ const processItem = (item)=>{
1031
+ onCheckChange?.(item, false);
1032
+ item.children?.forEach(processItem);
1033
+ };
1034
+ effectiveItems.forEach(processItem);
1035
+ },
1036
+ children: checkboxLabels.uncheck
1037
+ })
1038
+ ]
1039
+ })
1040
+ ]
1041
+ }) : null
1042
+ ]
1043
+ }),
1044
+ /*#__PURE__*/ jsxs("section", {
1045
+ ref: dragRef,
1046
+ "aria-label": "Tree view content",
1047
+ className: cn("rounded-lg relative select-none min-w-0 overflow-x-hidden", className),
1048
+ onMouseDown: handleMouseDown,
1049
+ onMouseMove: handleMouseMove,
1050
+ children: [
1051
+ isDragging && /*#__PURE__*/ jsx("div", {
1052
+ className: "absolute inset-0 bg-blue-500/0 pointer-events-none",
1053
+ style: {
1054
+ top: Math.min(dragStart || 0, null === dragStart ? 0 : currentMousePos),
1055
+ height: Math.abs((dragStart || 0) - (null === dragStart ? 0 : currentMousePos))
1056
+ }
1057
+ }),
1058
+ filteredData.map((item)=>/*#__PURE__*/ jsx(TreeItem, {
1059
+ item: item,
1060
+ selectedIds: selectedIds,
1061
+ lastSelectedId: lastSelectedId,
1062
+ onSelect: setSelectedIds,
1063
+ expandedIds: expandedIds,
1064
+ onToggleExpand: handleToggleExpand,
1065
+ selectionMode: selectionMode,
1066
+ getIcon: getIcon,
1067
+ onAction: onAction,
1068
+ onAccessChange: onCheckChange,
1069
+ allItems: data,
1070
+ showAccessRights: showCheckboxes,
1071
+ showSelectionCheckboxes: showSelectionCheckboxes,
1072
+ itemMap: itemMap,
1073
+ iconMap: iconMap,
1074
+ menuItems: menuItems,
1075
+ getSelectedItems: getSelectedItems
1076
+ }, item.id))
1077
+ ]
1078
+ })
1079
+ ]
1080
+ })
1081
+ });
1082
+ }
1083
+ export { TreeView as default };