@djangocfg/ui-tools 2.1.415 → 2.1.417

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 (140) hide show
  1. package/dist/audio-player/index.cjs +2099 -0
  2. package/dist/audio-player/index.cjs.map +1 -0
  3. package/dist/audio-player/index.css +65 -0
  4. package/dist/audio-player/index.css.map +1 -0
  5. package/dist/audio-player/index.d.cts +174 -0
  6. package/dist/audio-player/index.d.ts +174 -0
  7. package/dist/audio-player/index.mjs +2076 -0
  8. package/dist/audio-player/index.mjs.map +1 -0
  9. package/dist/composer-registry/index.cjs +45 -0
  10. package/dist/composer-registry/index.cjs.map +1 -0
  11. package/dist/composer-registry/index.d.cts +73 -0
  12. package/dist/composer-registry/index.d.ts +73 -0
  13. package/dist/composer-registry/index.mjs +39 -0
  14. package/dist/composer-registry/index.mjs.map +1 -0
  15. package/dist/file-icon/index.d.cts +1 -1
  16. package/dist/file-icon/index.d.ts +1 -1
  17. package/dist/slots-ClRpIzoh.d.cts +88 -0
  18. package/dist/slots-ClRpIzoh.d.ts +88 -0
  19. package/dist/tree/index.cjs +2019 -279
  20. package/dist/tree/index.cjs.map +1 -1
  21. package/dist/tree/index.d.cts +731 -72
  22. package/dist/tree/index.d.ts +731 -72
  23. package/dist/tree/index.mjs +2009 -282
  24. package/dist/tree/index.mjs.map +1 -1
  25. package/package.json +18 -9
  26. package/src/tools/chat/README.md +111 -1
  27. package/src/tools/chat/composer/Composer.tsx +146 -25
  28. package/src/tools/chat/composer/ComposerRichTextarea.tsx +25 -0
  29. package/src/tools/chat/composer/index.ts +22 -0
  30. package/src/tools/chat/composer/slash/README.md +187 -0
  31. package/src/tools/chat/composer/slash/SlashHighlightTextarea.tsx +144 -0
  32. package/src/tools/chat/composer/slash/SlashMenu.tsx +142 -0
  33. package/src/tools/chat/composer/slash/SlashToken.tsx +57 -0
  34. package/src/tools/chat/composer/slash/index.ts +44 -0
  35. package/src/tools/chat/composer/slash/labels.ts +19 -0
  36. package/src/tools/chat/composer/slash/state.ts +168 -0
  37. package/src/tools/chat/composer/slash/types.ts +64 -0
  38. package/src/tools/chat/composer/slash/useSlashCommands.ts +204 -0
  39. package/src/tools/chat/composer/types.ts +8 -0
  40. package/src/tools/chat/context/ChatProvider.tsx +13 -78
  41. package/src/tools/chat/hooks/useAutoFocusOnStreamEnd.ts +12 -15
  42. package/src/tools/chat/hooks/useFocusOnEmptyClick.ts +4 -5
  43. package/src/tools/chat/launcher/header/ChatHeader.tsx +14 -19
  44. package/src/tools/chat/launcher/header/ChatHeaderActionButton.tsx +8 -12
  45. package/src/tools/chat/shell/SuggestedPrompts.tsx +194 -0
  46. package/src/tools/chat/shell/index.ts +6 -0
  47. package/src/tools/data/Listbox/lazy.tsx +1 -1
  48. package/src/tools/data/Masonry/lazy.tsx +1 -1
  49. package/src/tools/data/Timeline/lazy.tsx +1 -1
  50. package/src/tools/data/Tree/FinderTree.tsx +42 -0
  51. package/src/tools/data/Tree/README.md +337 -208
  52. package/src/tools/data/Tree/TreeDndProvider.tsx +137 -0
  53. package/src/tools/data/Tree/TreeRoot.tsx +111 -72
  54. package/src/tools/data/Tree/__tests__/dnd.test.ts +160 -0
  55. package/src/tools/data/Tree/__tests__/keyboard.test.ts +137 -0
  56. package/src/tools/data/Tree/__tests__/renameUtils.test.ts +52 -0
  57. package/src/tools/data/Tree/__tests__/selection.test.ts +227 -0
  58. package/src/tools/data/Tree/components/TreeDropIndicator.tsx +65 -0
  59. package/src/tools/data/Tree/components/TreeEmptyArea.tsx +160 -0
  60. package/src/tools/data/Tree/components/TreeRenameInput.tsx +114 -0
  61. package/src/tools/data/Tree/components/TreeRow.tsx +103 -8
  62. package/src/tools/data/Tree/components/index.ts +6 -0
  63. package/src/tools/data/Tree/context/TreeContext.tsx +223 -363
  64. package/src/tools/data/Tree/context/TreeContextValue.ts +139 -0
  65. package/src/tools/data/Tree/context/async-children/collect-ids.ts +27 -0
  66. package/src/tools/data/Tree/context/async-children/index.ts +8 -0
  67. package/src/tools/data/Tree/context/async-children/use-async-children.ts +157 -0
  68. package/src/tools/data/Tree/context/clipboard/index.ts +4 -0
  69. package/src/tools/data/Tree/context/clipboard/use-clipboard.ts +115 -0
  70. package/src/tools/data/Tree/context/dnd/index.ts +8 -0
  71. package/src/tools/data/Tree/context/dnd/use-dnd.ts +194 -0
  72. package/src/tools/data/Tree/context/expansion/index.ts +4 -0
  73. package/src/tools/data/Tree/context/expansion/use-expansion.ts +55 -0
  74. package/src/tools/data/Tree/context/hooks.ts +68 -1
  75. package/src/tools/data/Tree/context/index.ts +3 -0
  76. package/src/tools/data/Tree/context/menu/builtin-actions.ts +357 -0
  77. package/src/tools/data/Tree/context/menu/index.ts +11 -0
  78. package/src/tools/data/Tree/context/menu/render.tsx +75 -0
  79. package/src/tools/data/Tree/context/menu/use-resolved-menu.ts +141 -0
  80. package/src/tools/data/Tree/context/persist/index.ts +4 -0
  81. package/src/tools/data/Tree/context/persist/use-persist-sync.ts +74 -0
  82. package/src/tools/data/Tree/context/rename/index.ts +4 -0
  83. package/src/tools/data/Tree/context/rename/use-rename.ts +113 -0
  84. package/src/tools/data/Tree/context/selection/index.ts +4 -0
  85. package/src/tools/data/Tree/context/selection/use-selection.ts +146 -0
  86. package/src/tools/data/Tree/context/state/index.ts +6 -0
  87. package/src/tools/data/Tree/context/state/initial.ts +41 -0
  88. package/src/tools/data/Tree/context/state/reducer.ts +76 -0
  89. package/src/tools/data/Tree/context/state/types.ts +46 -0
  90. package/src/tools/data/Tree/data/clipboard.ts +33 -0
  91. package/src/tools/data/Tree/data/dnd.ts +123 -0
  92. package/src/tools/data/Tree/data/finderShortcuts.ts +67 -0
  93. package/src/tools/data/Tree/data/index.ts +19 -0
  94. package/src/tools/data/Tree/data/renameUtils.ts +51 -0
  95. package/src/tools/data/Tree/data/selection.ts +157 -0
  96. package/src/tools/data/Tree/hooks/finder-hotkeys/build-ctx.ts +48 -0
  97. package/src/tools/data/Tree/hooks/finder-hotkeys/index.ts +8 -0
  98. package/src/tools/data/Tree/hooks/finder-hotkeys/use-tree-finder-hotkeys.ts +166 -0
  99. package/src/tools/data/Tree/hooks/index.ts +23 -4
  100. package/src/tools/data/Tree/hooks/keyboard/activation.ts +27 -0
  101. package/src/tools/data/Tree/hooks/keyboard/arrow-nav.ts +26 -0
  102. package/src/tools/data/Tree/hooks/keyboard/expand-collapse.ts +54 -0
  103. package/src/tools/data/Tree/hooks/keyboard/index.ts +10 -0
  104. package/src/tools/data/Tree/hooks/keyboard/types.ts +39 -0
  105. package/src/tools/data/Tree/hooks/keyboard/use-tree-keyboard.ts +196 -0
  106. package/src/tools/data/Tree/hooks/type-ahead/index.ts +5 -0
  107. package/src/tools/data/Tree/hooks/type-ahead/match-prefix.ts +42 -0
  108. package/src/tools/data/Tree/hooks/{useTreeTypeAhead.ts → type-ahead/use-tree-type-ahead.ts} +8 -19
  109. package/src/tools/data/Tree/index.tsx +26 -2
  110. package/src/tools/data/Tree/types/activation.ts +30 -0
  111. package/src/tools/data/Tree/types/adapter.ts +70 -0
  112. package/src/tools/data/Tree/types/index.ts +27 -0
  113. package/src/tools/data/Tree/types/labels.ts +97 -0
  114. package/src/tools/data/Tree/types/loader.ts +9 -0
  115. package/src/tools/data/Tree/types/node.ts +38 -0
  116. package/src/tools/data/Tree/types/root-props.ts +158 -0
  117. package/src/tools/data/Tree/types/selection.ts +3 -0
  118. package/src/tools/data/Tree/types/slots.ts +64 -0
  119. package/src/tools/dev/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/MetaActions.tsx +6 -9
  120. package/src/tools/dev/OpenapiViewer/components/DocsLayout/index.tsx +2 -4
  121. package/src/tools/forms/MarkdownEditor/MarkdownEditor.tsx +85 -0
  122. package/src/tools/forms/MarkdownEditor/index.ts +1 -0
  123. package/src/tools/forms/MarkdownEditor/lazy.tsx +6 -0
  124. package/src/tools/forms/MarkdownEditor/slash/SlashCommandNode.ts +162 -0
  125. package/src/tools/forms/MarkdownEditor/slash/index.ts +4 -0
  126. package/src/tools/forms/MarkdownEditor/slash/syncSlashNode.ts +97 -0
  127. package/src/tools/forms/MarkdownEditor/slash/types.ts +13 -0
  128. package/src/tools/forms/MarkdownEditor/styles.css +18 -0
  129. package/src/tools/input/SpeechRecognition/widgets/VoiceComposerSlot.tsx +11 -12
  130. package/src/tools/integration/ComposerRegistry/index.ts +105 -0
  131. package/src/tools/media/AudioPlayer/Player.tsx +2 -0
  132. package/src/tools/media/AudioPlayer/PlayerShell.tsx +37 -22
  133. package/src/tools/media/AudioPlayer/lazy.tsx +30 -42
  134. package/src/tools/media/AudioPlayer/parts/Controls/IconButton.tsx +10 -11
  135. package/src/tools/media/AudioPlayer/parts/Controls/VolumeControl.tsx +52 -115
  136. package/src/tools/media/AudioPlayer/types.ts +15 -0
  137. package/dist/types-j2vhn4Kv.d.cts +0 -241
  138. package/dist/types-j2vhn4Kv.d.ts +0 -241
  139. package/src/tools/data/Tree/hooks/useTreeKeyboard.ts +0 -171
  140. package/src/tools/data/Tree/types.ts +0 -217
@@ -1,7 +1,322 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { T as TreeRootProps, a as TreeItemId, b as TreeNode, F as FlatRow, c as TreeActivateOptions, d as TreeLabels, R as ResolvedAppearance, e as TreeSelectionMode, f as TreeActivationMode, g as TreeRowSlot, h as TreeContextMenuSlot } from '../types-j2vhn4Kv.cjs';
3
- export { D as DEFAULT_TREE_APPEARANCE, n as DEFAULT_TREE_LABELS, l as TreeAccentIntensity, j as TreeAppearance, p as TreeContextMenuAction, s as TreeContextMenuActionsResolver, q as TreeContextMenuItem, k as TreeDensity, t as TreeLoadChildren, m as TreeRadius, o as TreeRowRenderProps, i as appearanceToStyle, r as resolveAppearance } from '../types-j2vhn4Kv.cjs';
4
2
  import * as react from 'react';
3
+ import { CSSProperties } from 'react';
4
+ import { T as TreeNode, a as TreeItemId, b as TreeRowSlot, c as TreeContextMenuSlot, d as TreeContextMenuActionsResolver, F as FlatRow, e as TreeRowRenderProps, f as TreeContextMenuItem } from '../slots-ClRpIzoh.cjs';
5
+ export { g as TreeContextMenuAction, h as TreeContextMenuActionsContext } from '../slots-ClRpIzoh.cjs';
6
+
7
+ type TreeSelectionMode = 'none' | 'single' | 'multiple';
8
+
9
+ /**
10
+ * How a node becomes "activated" (i.e. opened) on pointer interaction.
11
+ *
12
+ * - `'single-click'` (default): single click activates a leaf immediately;
13
+ * double-click also activates. Folders always toggle on single click.
14
+ * - `'double-click'`: single click only selects + focuses; double-click is
15
+ * required to activate. Mirrors classic file-manager behaviour.
16
+ * - `'single-click-preview'`: VSCode Explorer / Cursor behaviour. Single
17
+ * click activates with `{ preview: true }` (consumer renders a preview
18
+ * tab); double-click activates with `{ preview: false }` (pinned tab).
19
+ *
20
+ * Folders ignore this setting — they always toggle on single click and
21
+ * never call `onActivate`.
22
+ */
23
+ type TreeActivationMode = 'single-click' | 'double-click' | 'single-click-preview';
24
+ interface TreeActivateOptions {
25
+ /**
26
+ * `true` when the activation came from a single click in
27
+ * `'single-click-preview'` mode. `false` for double-click and for
28
+ * non-preview modes. Consumers typically map this to a
29
+ * preview-tab vs pinned-tab distinction.
30
+ */
31
+ preview: boolean;
32
+ }
33
+
34
+ /**
35
+ * Async loader: called the first time a folder is expanded with no inline
36
+ * `children`. Result is cached; concurrent expansions are de-duplicated.
37
+ */
38
+ type TreeLoadChildren<T> = (node: TreeNode<T>) => Promise<TreeNode<T>[]>;
39
+
40
+ interface TreeLabels {
41
+ loading: string;
42
+ empty: string;
43
+ error: string;
44
+ searchPlaceholder: string;
45
+ searchMatches: (count: number) => string;
46
+ ariaLabel: string;
47
+ /** Default context-menu item labels. */
48
+ actionOpen: string;
49
+ actionRename: string;
50
+ actionDuplicate: string;
51
+ actionCut: string;
52
+ actionCopy: string;
53
+ actionPaste: string;
54
+ actionDelete: string;
55
+ actionNewFile: string;
56
+ actionNewFolder: string;
57
+ /** Delete confirmation dialog. */
58
+ confirmDeleteTitle: (count: number) => string;
59
+ confirmDeleteMessage: (names: string[]) => string;
60
+ confirmDeleteOk: string;
61
+ confirmDeleteCancel: string;
62
+ /** New file prompt. */
63
+ newFileTitle: string;
64
+ newFileMessage: string;
65
+ newFilePlaceholder: string;
66
+ newFileDefault: string;
67
+ /** New folder prompt. */
68
+ newFolderTitle: string;
69
+ newFolderMessage: string;
70
+ newFolderPlaceholder: string;
71
+ newFolderDefault: string;
72
+ /** Rename prompt (used when inline rename is unavailable / disabled). */
73
+ renameTitle: string;
74
+ renameMessage: string;
75
+ /** Name validation. */
76
+ invalidNameEmpty: string;
77
+ /** Suffix used by the default `duplicate` flow when the consumer's adapter
78
+ * needs a hint name. Receives the source name. */
79
+ duplicateSuffix: (name: string) => string;
80
+ }
81
+ declare const DEFAULT_TREE_LABELS: TreeLabels;
82
+
83
+ /**
84
+ * Position of a drop / move relative to the target row. `inside` means
85
+ * "drop into this folder"; `before`/`after` are sibling reorder hints.
86
+ */
87
+ type TreeMovePosition = 'before' | 'inside' | 'after';
88
+ /**
89
+ * CRUD adapter. Every method is optional — Tree only surfaces built-in
90
+ * menu items / hotkeys whose adapter method is defined. So an
91
+ * inspection-only tree just passes `{}` (or no adapter) and gets no
92
+ * destructive menu actions.
93
+ *
94
+ * Dialogs (`alert` / `confirm` / `prompt`) are taken from `window.dialog`
95
+ * exposed by `<DialogProvider />` in `@djangocfg/ui-core`. The host app
96
+ * is expected to mount that provider once at the layout level — Tree
97
+ * never re-implements its own dialogs.
98
+ */
99
+ interface TreeAdapter<T = unknown> {
100
+ /** Delete the given nodes. Tree calls `window.dialog.confirm` first. */
101
+ remove?: (nodes: TreeNode<T>[]) => Promise<void>;
102
+ /** Inline rename — node + new name (already non-empty, post-validate). */
103
+ rename?: (node: TreeNode<T>, nextName: string) => Promise<void>;
104
+ /** Create a file under `parent` (null → root). Tree prompts for name. */
105
+ createFile?: (parent: TreeNode<T> | null, name: string) => Promise<void>;
106
+ /** Create a folder under `parent` (null → root). Tree prompts for name. */
107
+ createFolder?: (parent: TreeNode<T> | null, name: string) => Promise<void>;
108
+ /** Duplicate the given nodes in-place. */
109
+ duplicate?: (nodes: TreeNode<T>[]) => Promise<void>;
110
+ /** Move nodes (drag-and-drop, cut+paste). */
111
+ move?: (nodes: TreeNode<T>[], target: TreeNode<T> | null, position: TreeMovePosition) => Promise<void>;
112
+ /** Copy nodes (copy+paste, drop with modifier). */
113
+ copy?: (nodes: TreeNode<T>[], target: TreeNode<T> | null, position: TreeMovePosition) => Promise<void>;
114
+ /**
115
+ * Optional name validator. Return a non-empty string to surface as an
116
+ * error via `window.dialog.alert`. Return `null` to accept.
117
+ */
118
+ validateName?: (name: string, ctx: {
119
+ node?: TreeNode<T>;
120
+ parent?: TreeNode<T> | null;
121
+ }) => string | null;
122
+ }
123
+ /**
124
+ * Built-in action ids. Used by `defaultMenuItems` and the internal
125
+ * built-in action registry. Each id maps 1:1 to an adapter method
126
+ * (plus a few selection helpers).
127
+ */
128
+ type TreeBuiltinAction = 'open' | 'rename' | 'duplicate' | 'cut' | 'copy' | 'paste' | 'delete' | 'new-file' | 'new-folder';
129
+
130
+ type TreeDensity = 'compact' | 'cozy' | 'comfortable';
131
+ type TreeAccentIntensity = 'subtle' | 'default' | 'strong';
132
+ type TreeRadius = 'none' | 'sm' | 'md';
133
+ /**
134
+ * Cosmetic configuration. Every field is optional; missing values fall
135
+ * back to the `cozy` preset (a comfortable VSCode-Explorer-like density).
136
+ *
137
+ * Customize the look without re-implementing slots.
138
+ */
139
+ interface TreeAppearance {
140
+ /** Built-in size preset. Default: `'cozy'`. */
141
+ density?: TreeDensity;
142
+ /** Override row height in px (wins over density). */
143
+ rowHeight?: number;
144
+ /** Override icon + chevron size in px (wins over density). */
145
+ iconSize?: number;
146
+ /** Lucide stroke width for icon + chevron. Default: 1.5. */
147
+ iconStrokeWidth?: number;
148
+ /** Override label font size in px (wins over density). */
149
+ fontSize?: number;
150
+ /** Pixels between chevron / icon / label. Default depends on density. */
151
+ gap?: number;
152
+ /** Pixels between nesting levels. Default: 16. */
153
+ indent?: number;
154
+ /** Hover / selected highlight intensity. Default: `'default'`. */
155
+ accent?: TreeAccentIntensity;
156
+ /** Row corner radius. Default: `'sm'`. */
157
+ radius?: TreeRadius;
158
+ /** Indent-guide line opacity (0..1). Default: 0.4. */
159
+ indentGuideOpacity?: number;
160
+ /**
161
+ * Show a 2px primary-tinted bar on the left of the selected row.
162
+ * Mimics the VSCode active-tab indicator. Default: `true`.
163
+ */
164
+ showActiveIndicator?: boolean;
165
+ }
166
+ interface ResolvedAppearance {
167
+ density: TreeDensity;
168
+ rowHeight: number;
169
+ iconSize: number;
170
+ iconStrokeWidth: number;
171
+ fontSize: number;
172
+ gap: number;
173
+ indent: number;
174
+ accent: TreeAccentIntensity;
175
+ radius: TreeRadius;
176
+ indentGuideOpacity: number;
177
+ showActiveIndicator: boolean;
178
+ }
179
+ declare const DEFAULT_TREE_APPEARANCE: ResolvedAppearance;
180
+ /**
181
+ * Merge a partial appearance with the default + density preset.
182
+ *
183
+ * Explicit numeric overrides (e.g. `rowHeight`) win over the density preset.
184
+ */
185
+ declare function resolveAppearance(input?: TreeAppearance,
186
+ /** Outer `indent` prop (kept on TreeRoot for back-compat). */
187
+ outerIndent?: number): ResolvedAppearance;
188
+ /**
189
+ * Build the `style` object that exposes the resolved appearance to any
190
+ * descendant via CSS variables. Set on `<TreeRoot>`'s outer div.
191
+ */
192
+ declare function appearanceToStyle(a: ResolvedAppearance): CSSProperties;
193
+
194
+ interface TreeRootProps<T> {
195
+ /** Root nodes. Top-level items are rendered directly (no synthetic root). */
196
+ data: TreeNode<T>[];
197
+ /** Returns the human-readable name for a node (used by search/type-ahead). */
198
+ getItemName: (node: TreeNode<T>) => string;
199
+ /** Async loader for folders without inline `children`. */
200
+ loadChildren?: TreeLoadChildren<T>;
201
+ /** Selection behaviour. Default: `'single'`. */
202
+ selectionMode?: TreeSelectionMode;
203
+ /** Pointer activation behaviour. Default: `'single-click'`. */
204
+ activationMode?: TreeActivationMode;
205
+ /** Initially expanded ids. */
206
+ initialExpandedIds?: TreeItemId[];
207
+ /** Initially selected ids. */
208
+ initialSelectedIds?: TreeItemId[];
209
+ /** Pixels of indent per nesting level. Default: 16. (Shortcut for `appearance.indent`.) */
210
+ indent?: number;
211
+ /** Cosmetic configuration: density, sizes, accent intensity, radius. */
212
+ appearance?: TreeAppearance;
213
+ /** Triggered when selection changes. */
214
+ onSelectionChange?: (selectedIds: TreeItemId[]) => void;
215
+ /** Triggered when expanded set changes. */
216
+ onExpansionChange?: (expandedIds: TreeItemId[]) => void;
217
+ /**
218
+ * Triggered when a leaf is activated (Enter / dblclick / click depending
219
+ * on `activationMode`). Folders never call this — they toggle instead.
220
+ */
221
+ onActivate?: (node: TreeNode<T>, opts: TreeActivateOptions) => void;
222
+ /**
223
+ * Optional predicate. Nodes returning `false` (and their descendants) are
224
+ * not rendered and not searchable. Use this to hide dot-files, system
225
+ * entries, or anything else the consumer wants to filter out.
226
+ */
227
+ filterNode?: (node: TreeNode<T>) => boolean;
228
+ /** Show built-in search input. Default: false. */
229
+ enableSearch?: boolean;
230
+ /** Type printable letters to jump to a matching name. Default: true. */
231
+ enableTypeAhead?: boolean;
232
+ /** Render vertical indent guides under expanded folders. Default: false. */
233
+ showIndentGuides?: boolean;
234
+ /**
235
+ * Allow inline rename. When true, F2 starts an inline `<input>`; the
236
+ * value is committed through `adapter.rename`. Requires `adapter.rename`.
237
+ * Default: false.
238
+ */
239
+ enableInlineRename?: boolean;
240
+ /**
241
+ * Enable Finder/Explorer keyboard shortcuts (delete, rename, duplicate,
242
+ * new file/folder, cut/copy/paste). Bindings only fire when the tree
243
+ * container has focus. Individual shortcuts are still gated by the
244
+ * adapter — `⌘⌫` does nothing if `adapter.remove` is undefined.
245
+ * Default: false.
246
+ */
247
+ enableFinderHotkeys?: boolean;
248
+ /**
249
+ * Enable drag-and-drop reorder + move-into-folder. Requires
250
+ * `adapter.move`. Powered by `@dnd-kit/core` — pointer + keyboard
251
+ * sensors, accessible.
252
+ * Default: false.
253
+ */
254
+ enableDnD?: boolean;
255
+ /**
256
+ * Custom drop validation. Returns `true` to allow, `false` to forbid.
257
+ * The default validator rejects self-drops and cycles (dropping a
258
+ * folder into its own descendant). Use this to add domain rules
259
+ * (read-only branches, type matching, …).
260
+ */
261
+ canDrop?: (ctx: {
262
+ source: TreeNode<T>[];
263
+ target: TreeNode<T> | null;
264
+ position: TreeMovePosition;
265
+ }) => boolean;
266
+ /** Custom row renderer. Falls back to the default <TreeRow />. */
267
+ renderRow?: TreeRowSlot<T>;
268
+ /** Replace default folder/file icon. */
269
+ renderIcon?: TreeRowSlot<T>;
270
+ /** Replace default label rendering. */
271
+ renderLabel?: TreeRowSlot<T>;
272
+ /** Right-side actions slot (per row). */
273
+ renderActions?: TreeRowSlot<T>;
274
+ /** Wrap each row in a context menu (right-click). Receives the row meta + trigger element. */
275
+ renderContextMenu?: TreeContextMenuSlot<T>;
276
+ /**
277
+ * Declarative right-click menu — short-form. Pass `(row) => [items]` and the
278
+ * Tree builds a `<ContextMenu>` for you with sensible defaults. Ignored if
279
+ * `renderContextMenu` is also set. Return `null`/`undefined`/`[]` to skip
280
+ * the menu for that row.
281
+ */
282
+ contextMenuActions?: TreeContextMenuActionsResolver<T>;
283
+ /** Override built-in copy in your locale. */
284
+ labels?: Partial<TreeLabels>;
285
+ /** Persist expanded + (optional) selected ids in localStorage under this key. */
286
+ persistKey?: string;
287
+ /** Persist selection alongside expansion. Default: false. */
288
+ persistSelection?: boolean;
289
+ /**
290
+ * CRUD adapter. When set, Tree builds default context-menu items and
291
+ * Finder hotkeys for every method the adapter defines. Methods that
292
+ * are not provided produce no UI — no greyed-out items.
293
+ */
294
+ adapter?: TreeAdapter<T>;
295
+ /**
296
+ * Which built-in actions to expose in the auto-built context menu. If
297
+ * omitted, every action whose adapter method exists is shown.
298
+ *
299
+ * Pass `[]` to suppress the auto-built menu entirely while keeping the
300
+ * adapter for hotkeys / DnD.
301
+ */
302
+ defaultMenuItems?: TreeBuiltinAction[];
303
+ /**
304
+ * Imperative handle for outer code. The provided ref receives a
305
+ * stable handle to `useTreeActions` once Tree mounts. Lets host
306
+ * components trigger `refresh(id)` / `refreshAll()` from outside
307
+ * Tree (e.g. after a transport-level mutation completes).
308
+ */
309
+ actionsRef?: React.MutableRefObject<TreeActionsHandle | null>;
310
+ className?: string;
311
+ style?: CSSProperties;
312
+ }
313
+ /** Subset of `useTreeActions()` exposed via `<TreeRoot actionsRef={…}>`. */
314
+ interface TreeActionsHandle {
315
+ refresh: (id: string) => Promise<void>;
316
+ refreshAll: () => Promise<void>;
317
+ expandAll: () => void;
318
+ collapseAll: () => void;
319
+ }
5
320
 
6
321
  /**
7
322
  * High-level entry point. Wraps Provider + (optional) search bar + content.
@@ -11,33 +326,88 @@ import * as react from 'react';
11
326
  */
12
327
  declare function TreeRoot<T>(props: TreeRootProps<T>): react_jsx_runtime.JSX.Element;
13
328
 
14
- type ChildEntryStatus = 'idle' | 'loading' | 'loaded' | 'error';
15
- interface ChildEntry<T> {
16
- status: ChildEntryStatus;
17
- children: TreeNode<T>[];
18
- error?: string;
19
- }
20
- type ChildCache<T> = Map<TreeItemId, ChildEntry<T>>;
21
- declare const createChildCache: <T>() => ChildCache<T>;
22
329
  /**
23
- * Resolve a node's children for the current render.
330
+ * `<FinderTree>` opinionated Finder/Explorer-style preset.
24
331
  *
25
- * - If the node carries inline `children`, those win (no async fetch).
26
- * - Otherwise we look in the cache.
332
+ * Equivalent to `<TreeRoot>` with multi-selection, double-click activation,
333
+ * inline rename, indent guides, and a cozy appearance turned on. Pass an
334
+ * `adapter` to get the built-in CRUD menu wired to `window.dialog.*`.
27
335
  *
28
- * Returns `null` when nothing is loaded yet (caller may show a skeleton).
336
+ * Override any preset default by simply passing the same prop:
337
+ *
338
+ * ```tsx
339
+ * <FinderTree<FsNode>
340
+ * data={data}
341
+ * getItemName={(n) => n.data.name}
342
+ * adapter={fsAdapter}
343
+ * // override one preset default — everything else stays Finder-y:
344
+ * activationMode="single-click-preview"
345
+ * />
346
+ * ```
29
347
  */
30
- declare const resolveChildren: <T>(cache: ChildCache<T>, node: TreeNode<T>) => {
31
- children: TreeNode<T>[] | null;
32
- status: ChildEntryStatus;
33
- error?: string;
34
- };
348
+ declare function FinderTree<T>(props: TreeRootProps<T>): react_jsx_runtime.JSX.Element;
349
+
350
+ type ClipboardKind = 'cut' | 'copy';
351
+ interface ClipboardEntry {
352
+ kind: ClipboardKind;
353
+ ids: TreeItemId[];
354
+ }
355
+ type ClipboardState = ClipboardEntry | null;
356
+
357
+ interface DropTargetState {
358
+ id: TreeItemId | null;
359
+ position: TreeMovePosition;
360
+ }
361
+ interface UseDndReturn<T> {
362
+ /** True when the host enabled DnD AND adapter.move is defined. */
363
+ active: boolean;
364
+ /** Ids currently being dragged (empty when not dragging). */
365
+ draggingIds: ReadonlySet<TreeItemId>;
366
+ /** Live drop target (`null` when nothing under the pointer). */
367
+ dropTarget: DropTargetState | null;
368
+ /** Called by row sensors on dragstart. */
369
+ beginDrag: (rowId: TreeItemId) => void;
370
+ /**
371
+ * Called on dragover. `null` clears the indicator. Tree already
372
+ * filters self/cycle drops via `defaultCanDrop` — the row component
373
+ * decides the position from pointer geometry first.
374
+ */
375
+ setDropTarget: (target: DropTargetState | null) => void;
376
+ /** Commit drop — calls `adapter.move` and resets transient state. */
377
+ commitDrop: () => Promise<void>;
378
+ /** Cancel without committing (Esc, drop outside). */
379
+ cancelDrag: () => void;
380
+ /**
381
+ * Validate a candidate drop in real time. Combines `defaultCanDrop`
382
+ * with the consumer's `canDrop`. Used by the row component to
383
+ * suppress the indicator on invalid hovers.
384
+ */
385
+ isAllowedDrop: (target: TreeNode<T> | null, position: TreeMovePosition) => boolean;
386
+ }
387
+
388
+ /**
389
+ * Click selection — derives next `{selected, anchor, focused}` from a
390
+ * pointer event's modifier keys. `rows` is the current flat view (used
391
+ * for shift-range computation).
392
+ */
393
+ interface ClickModifiers {
394
+ shift: boolean;
395
+ meta: boolean;
396
+ }
35
397
 
36
398
  interface TreeContextValue<T> {
37
399
  expanded: ReadonlySet<TreeItemId>;
38
400
  selected: ReadonlySet<TreeItemId>;
401
+ /** Anchor for shift-range. `null` when nothing has been clicked yet. */
402
+ anchor: TreeItemId | null;
39
403
  focused: TreeItemId | null;
40
404
  query: string;
405
+ /** Id of the row currently in inline-rename mode (or `null`). */
406
+ renamingId: TreeItemId | null;
407
+ /** Is inline rename allowed by the host? */
408
+ inlineRenameEnabled: boolean;
409
+ /** Tree-local clipboard (cut / copy) — P5. `null` when empty. */
410
+ clipboard: ClipboardState;
41
411
  flatRows: FlatRow<T>[];
42
412
  /** Search-matching node ids (subset of all flatRows). */
43
413
  matchingIds: ReadonlySet<TreeItemId>;
@@ -49,8 +419,44 @@ interface TreeContextValue<T> {
49
419
  select: (id: TreeItemId) => void;
50
420
  setSelectedIds: (ids: TreeItemId[]) => void;
51
421
  clearSelection: () => void;
422
+ /**
423
+ * Finder/Explorer-style click selection. Reads modifier keys from the
424
+ * passed event and decides between replace / toggle / range / union.
425
+ */
426
+ clickSelect: (id: TreeItemId, mods: ClickModifiers) => void;
427
+ /**
428
+ * Move-focus with optional range-extend (shift+arrows).
429
+ */
430
+ moveSelect: (id: TreeItemId, opts: {
431
+ extend: boolean;
432
+ }) => void;
433
+ /** Select every currently visible row (mod+a). */
434
+ selectAll: () => void;
52
435
  setFocus: (id: TreeItemId | null) => void;
53
436
  setQuery: (q: string) => void;
437
+ /** Put the given ids on Tree's clipboard as `cut`. */
438
+ cutToClipboard: (ids: TreeItemId[]) => void;
439
+ /** Put the given ids on Tree's clipboard as `copy`. */
440
+ copyToClipboard: (ids: TreeItemId[]) => void;
441
+ /**
442
+ * Apply clipboard onto `target` (a row, or `null` for the root). Cut →
443
+ * `adapter.move`; copy → `adapter.copy`. After a successful cut+paste
444
+ * the clipboard is cleared. No-op when clipboard is empty or the
445
+ * matching adapter method is undefined.
446
+ */
447
+ pasteFromClipboard: (target: TreeNode<T> | null, position?: TreeMovePosition) => Promise<void>;
448
+ /** Clear the clipboard without pasting. */
449
+ clearClipboard: () => void;
450
+ /** Begin inline rename on the given row. */
451
+ startRename: (id: TreeItemId) => void;
452
+ /** Cancel inline rename without committing. */
453
+ cancelRename: () => void;
454
+ /**
455
+ * Commit inline rename. Tree calls `adapter.rename` and then clears
456
+ * the renaming state. On validation failure surfaces an error via
457
+ * `window.dialog.alert` and keeps the input open.
458
+ */
459
+ commitRename: (id: TreeItemId, nextName: string) => Promise<boolean>;
54
460
  refresh: (id: TreeItemId) => Promise<void>;
55
461
  refreshAll: () => Promise<void>;
56
462
  activate: (node: TreeNode<T>, opts?: TreeActivateOptions) => void;
@@ -68,20 +474,155 @@ interface TreeContextValue<T> {
68
474
  renderLabel?: TreeRowSlot<T>;
69
475
  renderActions?: TreeRowSlot<T>;
70
476
  renderContextMenu?: TreeContextMenuSlot<T>;
477
+ /** CRUD adapter (P2). May be undefined — Tree still renders normally. */
478
+ adapter?: TreeAdapter<T>;
479
+ /**
480
+ * Final, merged declarative menu resolver. Combines built-in adapter
481
+ * actions (filtered by `defaultMenuItems`) with the consumer's
482
+ * `contextMenuActions` resolver, and injects the current
483
+ * `selectedNodes` before delegating.
484
+ */
485
+ resolvedContextMenuActions?: (row: TreeRowRenderProps<T>) => TreeContextMenuItem<T>[] | null | undefined;
486
+ /**
487
+ * Imperative lookup for any node currently known to Tree (root +
488
+ * cached async children).
489
+ */
490
+ getNodeById: (id: TreeItemId) => TreeNode<T> | undefined;
491
+ /**
492
+ * Drag-and-drop state and handlers (P6). `dnd.active` is `false`
493
+ * when the host didn't enable DnD or `adapter.move` is missing — in
494
+ * that case `TreeRow` skips all drag setup.
495
+ */
496
+ dnd: UseDndReturn<T>;
497
+ }
498
+
499
+ type ChildEntryStatus = 'idle' | 'loading' | 'loaded' | 'error';
500
+ interface ChildEntry<T> {
501
+ status: ChildEntryStatus;
502
+ children: TreeNode<T>[];
503
+ error?: string;
71
504
  }
505
+ type ChildCache<T> = Map<TreeItemId, ChildEntry<T>>;
506
+ declare const createChildCache: <T>() => ChildCache<T>;
507
+ /**
508
+ * Resolve a node's children for the current render.
509
+ *
510
+ * - If the node carries inline `children`, those win (no async fetch).
511
+ * - Otherwise we look in the cache.
512
+ *
513
+ * Returns `null` when nothing is loaded yet (caller may show a skeleton).
514
+ */
515
+ declare const resolveChildren: <T>(cache: ChildCache<T>, node: TreeNode<T>) => {
516
+ children: TreeNode<T>[] | null;
517
+ status: ChildEntryStatus;
518
+ error?: string;
519
+ };
520
+
72
521
  declare function useTreeContext<T>(): TreeContextValue<T>;
73
- interface TreeProviderProps<T> extends Pick<TreeRootProps<T>, 'data' | 'getItemName' | 'loadChildren' | 'selectionMode' | 'activationMode' | 'initialExpandedIds' | 'initialSelectedIds' | 'indent' | 'appearance' | 'onSelectionChange' | 'onExpansionChange' | 'onActivate' | 'filterNode' | 'enableSearch' | 'showIndentGuides' | 'renderIcon' | 'renderLabel' | 'renderActions' | 'renderContextMenu' | 'labels' | 'persistKey' | 'persistSelection'> {
522
+ interface TreeProviderProps<T> extends Pick<TreeRootProps<T>, 'data' | 'getItemName' | 'loadChildren' | 'selectionMode' | 'activationMode' | 'initialExpandedIds' | 'initialSelectedIds' | 'indent' | 'appearance' | 'onSelectionChange' | 'onExpansionChange' | 'onActivate' | 'filterNode' | 'enableSearch' | 'showIndentGuides' | 'renderIcon' | 'renderLabel' | 'renderActions' | 'renderContextMenu' | 'contextMenuActions' | 'labels' | 'persistKey' | 'persistSelection' | 'adapter' | 'defaultMenuItems' | 'enableInlineRename' | 'enableDnD' | 'canDrop'> {
74
523
  children: react.ReactNode;
75
524
  }
76
525
  declare function TreeProvider<T>(props: TreeProviderProps<T>): react_jsx_runtime.JSX.Element;
77
526
 
527
+ interface FlattenInput<T> {
528
+ roots: TreeNode<T>[];
529
+ expandedIds: ReadonlySet<TreeItemId>;
530
+ cache: ChildCache<T>;
531
+ /** Optional predicate. Nodes returning `false` (and their descendants) are excluded. */
532
+ filterNode?: (node: TreeNode<T>) => boolean;
533
+ }
534
+ /**
535
+ * Walk the tree top-to-bottom and produce a flat list of visible rows.
536
+ *
537
+ * Visibility rule: a child row appears only when every ancestor is in
538
+ * `expandedIds`. The output is ordered exactly as it should render,
539
+ * which keeps keyboard navigation (next/prev row) trivial.
540
+ */
541
+ declare function flattenTree<T>({ roots, expandedIds, cache, filterNode, }: FlattenInput<T>): FlatRow<T>[];
542
+
543
+ interface PersistedTreeState {
544
+ expandedItems: TreeItemId[];
545
+ selectedItems: TreeItemId[];
546
+ }
547
+ declare function loadTreeState(key: string): PersistedTreeState | null;
548
+ declare function saveTreeState(key: string, state: PersistedTreeState): void;
549
+ declare function clearTreeState(key: string): void;
550
+
551
+ interface DemoNode {
552
+ name: string;
553
+ }
554
+ /**
555
+ * Build a deterministic synthetic tree for stories and tests.
556
+ *
557
+ * @example
558
+ * const data = createDemoTree({ depth: 4, breadth: 3 });
559
+ * <TreeRoot data={data} getItemName={(n) => n.data.name} />
560
+ */
561
+ declare function createDemoTree({ depth, breadth, rootPrefix, }?: {
562
+ depth?: number;
563
+ breadth?: number;
564
+ rootPrefix?: string;
565
+ }): TreeNode<DemoNode>[];
566
+
567
+ interface SplitName {
568
+ base: string;
569
+ ext: string;
570
+ }
571
+ declare function splitFileName(name: string): SplitName;
572
+ /**
573
+ * Returns the `[selectionStart, selectionEnd]` pair to use on focus of an
574
+ * `<input>` so only the base name is highlighted (Finder behaviour).
575
+ *
576
+ * Folders pass `isFolder=true` to skip extension detection and select
577
+ * the entire name — folders don't have file extensions semantically.
578
+ */
579
+ declare function autoSelectRange(name: string, isFolder: boolean): [number, number];
580
+
581
+ interface DropZoneInput {
582
+ /** Pointer Y in viewport coordinates. */
583
+ pointerY: number;
584
+ /** Row bounding box (`getBoundingClientRect()`). */
585
+ rowRect: {
586
+ top: number;
587
+ bottom: number;
588
+ height: number;
589
+ };
590
+ /** Folders accept `inside` drops; leaves only reorder via before/after. */
591
+ isFolder: boolean;
592
+ }
593
+ /**
594
+ * Translate pointer geometry into a drop position relative to the row.
595
+ *
596
+ * For folders the row is split into three zones (top third / middle /
597
+ * bottom third). For leaves it's split in half (before / after).
598
+ */
599
+ declare function resolveDropZone(input: DropZoneInput): TreeMovePosition;
600
+ interface CanDropInput<T> {
601
+ /** Nodes being dragged. */
602
+ source: TreeNode<T>[];
603
+ /** Row under the pointer (`null` = root drop zone). */
604
+ target: TreeNode<T> | null;
605
+ /** Resolved drop position. */
606
+ position: TreeMovePosition;
607
+ /** Tree's id→node lookup, used to walk descendants. */
608
+ getNodeById: (id: TreeItemId) => TreeNode<T> | undefined;
609
+ }
610
+ declare function defaultCanDrop<T>(input: CanDropInput<T>): boolean;
611
+ declare const TREE_DND_MIME = "application/x-djangocfg-tree";
612
+
78
613
  declare function useTreeLabels(): TreeLabels;
79
614
  declare function useTreeRows<T>(): FlatRow<T>[];
80
615
  declare function useTreeSelection<T>(): {
81
616
  selectedIds: string[];
617
+ anchor: string;
82
618
  select: (id: TreeItemId) => void;
83
619
  setSelectedIds: (ids: TreeItemId[]) => void;
84
620
  clear: () => void;
621
+ clickSelect: (id: TreeItemId, mods: ClickModifiers) => void;
622
+ moveSelect: (id: TreeItemId, opts: {
623
+ extend: boolean;
624
+ }) => void;
625
+ selectAll: () => void;
85
626
  isSelected: (id: TreeItemId) => boolean;
86
627
  };
87
628
  declare function useTreeExpansion<T>(): {
@@ -104,6 +645,24 @@ declare function useTreeSearch<T>(): {
104
645
  matchingIds: ReadonlySet<string>;
105
646
  matchCount: number;
106
647
  };
648
+ declare function useTreeDnd<T>(): UseDndReturn<T>;
649
+ declare function useTreeClipboard<T>(): {
650
+ clipboard: ClipboardEntry;
651
+ isCut: (id: TreeItemId) => boolean;
652
+ cut: (ids: TreeItemId[]) => void;
653
+ copy: (ids: TreeItemId[]) => void;
654
+ paste: (target: TreeNode<T>, position?: TreeMovePosition) => Promise<void>;
655
+ clear: () => void;
656
+ };
657
+ declare function useTreeRename<T>(): {
658
+ /** True when the host allowed inline rename AND the adapter exposes `rename`. */
659
+ enabled: boolean;
660
+ /** Currently renaming id, or `null`. */
661
+ renamingId: string;
662
+ startRename: (id: TreeItemId) => void;
663
+ cancelRename: () => void;
664
+ commitRename: (id: TreeItemId, nextName: string) => Promise<boolean>;
665
+ };
107
666
  declare function useTreeActions<T>(): {
108
667
  expand: (id: TreeItemId) => void;
109
668
  collapse: (id: TreeItemId) => void;
@@ -115,6 +674,53 @@ declare function useTreeActions<T>(): {
115
674
  activate: (node: TreeNode<T>, opts?: TreeActivateOptions) => void;
116
675
  };
117
676
 
677
+ interface UseTreeKeyboardOptions<T> {
678
+ rows: FlatRow<T>[];
679
+ focusedId: TreeItemId | null;
680
+ enabled?: boolean;
681
+ /**
682
+ * `true` when `selectionMode === 'multiple'` — enables shift-extend on
683
+ * arrow keys, Home / End, and `Cmd/Ctrl+A` select-all. Without it the
684
+ * shift-modifier just moves focus.
685
+ */
686
+ multiSelect?: boolean;
687
+ /**
688
+ * Move focus to `id`. When `extend` is true and multi-select is enabled,
689
+ * the consumer should extend the selection range from anchor through id.
690
+ */
691
+ onFocus: (id: TreeItemId, opts: {
692
+ extend: boolean;
693
+ }) => void;
694
+ onSelect: (id: TreeItemId) => void;
695
+ onActivate: (id: TreeItemId) => void;
696
+ onExpand: (id: TreeItemId) => void;
697
+ onCollapse: (id: TreeItemId) => void;
698
+ onClearSelection: () => void;
699
+ /** Cmd/Ctrl+A — select all visible rows. Ignored if multiSelect is false. */
700
+ onSelectAll?: () => void;
701
+ }
702
+ interface UseTreeKeyboardReturn {
703
+ /** Attach to the tree container. Hotkeys only fire when focus is inside. */
704
+ ref: (instance: HTMLElement | null) => void;
705
+ }
706
+
707
+ /**
708
+ * Standard tree keyboard navigation, scoped to the container ref.
709
+ *
710
+ * - ↑ / ↓ : prev / next visible row (Shift extends range)
711
+ * - Home / End : first / last visible row (Shift extends range)
712
+ * - → / ← : expand-or-jump-to-child / collapse-or-jump-to-parent
713
+ * - Enter / Space : activate (folder → toggle, leaf → onActivate)
714
+ * - Esc : clear selection
715
+ * - Cmd/Ctrl + A : select all (multi-select only)
716
+ *
717
+ * Pure decision-making lives in the sibling helpers (`arrow-nav.ts`,
718
+ * `expand-collapse.ts`, `activation.ts`) so it's unit-testable without
719
+ * a DOM. This file only wires up `useHotkey` bindings and dispatches
720
+ * the helper outcomes back to the consumer's callbacks.
721
+ */
722
+ declare function useTreeKeyboard<T>({ rows, focusedId, enabled, multiSelect, onFocus, onSelect, onActivate, onExpand, onCollapse, onClearSelection, onSelectAll, }: UseTreeKeyboardOptions<T>): UseTreeKeyboardReturn;
723
+
118
724
  interface UseTreeTypeAheadOptions<T> {
119
725
  /** Visible flat rows in render order. */
120
726
  rows: FlatRow<T>[];
@@ -136,35 +742,66 @@ interface UseTreeTypeAheadOptions<T> {
136
742
  */
137
743
  declare function useTreeTypeAhead<T>({ rows, getItemName, containerRef, onMatch, enabled, }: UseTreeTypeAheadOptions<T>): void;
138
744
 
139
- interface UseTreeKeyboardOptions<T> {
140
- rows: FlatRow<T>[];
141
- focusedId: TreeItemId | null;
142
- enabled?: boolean;
143
- onFocus: (id: TreeItemId) => void;
144
- onSelect: (id: TreeItemId) => void;
145
- onActivate: (id: TreeItemId) => void;
146
- onExpand: (id: TreeItemId) => void;
147
- onCollapse: (id: TreeItemId) => void;
148
- onClearSelection: () => void;
745
+ interface BuiltinActionContext<T> {
746
+ adapter: TreeAdapter<T>;
747
+ labels: TreeLabels;
748
+ /** Currently selected nodes (full objects, resolved from ids). */
749
+ selectedNodes: TreeNode<T>[];
750
+ /** Row the user right-clicked / triggered the action on. May be null
751
+ * for empty-area actions (paste / new file / new folder at root). */
752
+ targetNode: TreeNode<T> | null;
753
+ /** Returns the human-readable name for a node (uses `getItemName`). */
754
+ getName: (node: TreeNode<T>) => string;
755
+ /** Imperative: start inline rename on this id (no-op if disabled). */
756
+ startInlineRename?: (id: TreeItemId) => void;
757
+ /** Clipboard hooks (P5). Provided by Tree's context; pure forwarding. */
758
+ clipboard?: {
759
+ /** Current clipboard kind, if any (so we can hide "Paste" when empty). */
760
+ hasItems: boolean;
761
+ cut: (ids: TreeItemId[]) => void;
762
+ copy: (ids: TreeItemId[]) => void;
763
+ paste: () => void | Promise<void>;
764
+ };
149
765
  }
150
- interface UseTreeKeyboardReturn {
151
- /** Attach to the tree container. Hotkeys only fire when focus is inside. */
766
+
767
+ interface UseTreeFinderHotkeysOptions<T> {
768
+ /** Off by default — Tree opt-ins via `enableFinderHotkeys`. */
769
+ enabled: boolean;
770
+ /** Adapter — used both for action availability and dispatch. */
771
+ adapter?: TreeAdapter<T>;
772
+ /** Labels (passed through into adapter action context for dialogs). */
773
+ labels: TreeLabels;
774
+ /** Live selection (set of ids). */
775
+ selected: ReadonlySet<TreeItemId>;
776
+ /** Live focused id (used as "target" for new-file/new-folder actions). */
777
+ focused: TreeItemId | null;
778
+ /** Id → node lookup. */
779
+ getNodeById: (id: TreeItemId) => TreeNode<T> | undefined;
780
+ /** Display name resolver. */
781
+ getItemName: (node: TreeNode<T>) => string;
782
+ /** Open inline rename on the row (P3). Falls back to a prompt otherwise. */
783
+ startInlineRename?: (id: TreeItemId) => void;
784
+ /** Clipboard bindings (P5). When undefined, ⌘C/X/V are no-ops. */
785
+ clipboard?: BuiltinActionContext<T>['clipboard'];
786
+ /** Whether typing is currently in inline-rename input — pauses bindings. */
787
+ paused?: boolean;
788
+ }
789
+ interface UseTreeFinderHotkeysReturn {
790
+ /** Attach to the tree container ref so hotkeys only fire when it has focus. */
152
791
  ref: (instance: HTMLElement | null) => void;
153
792
  }
154
793
  /**
155
- * Standard tree keyboard navigation, scoped to the container ref.
794
+ * Wire the platform-aware Finder/Explorer shortcuts to the built-in
795
+ * adapter actions. Bindings are scoped to the container ref via
796
+ * `useHotkey`, so they don't leak to the rest of the page.
156
797
  *
157
- * - / : prev / next visible row
158
- * - Home / End : first / last visible row
159
- * - : expand folder; if already expanded, jump to first child
160
- * - : collapse folder; if already collapsed (or leaf), jump to parent
161
- * - Enter / Space : activate (folder => toggle, leaf => onActivate)
162
- * - Esc : clear selection
163
- *
164
- * Built on `useHotkey` (react-hotkeys-hook) — focus gating is automatic; no
165
- * manual `addEventListener` or `data-scope` juggling.
798
+ * Each shortcut is bound by an explicit `useHotkey` call (no `.map(useHotkey)`
799
+ * loop, so the rules-of-hooks lint passes cleanly). The handler routes
800
+ * through `runBuiltinAction`, which silently no-ops when the adapter
801
+ * doesn't expose the matching method so a Tree with `adapter = { remove }`
802
+ * only effectively reacts to ⌘⌫ / Delete.
166
803
  */
167
- declare function useTreeKeyboard<T>({ rows, focusedId, enabled, onFocus, onSelect, onActivate, onExpand, onCollapse, onClearSelection, }: UseTreeKeyboardOptions<T>): UseTreeKeyboardReturn;
804
+ declare function useTreeFinderHotkeys<T>(opts: UseTreeFinderHotkeysOptions<T>): UseTreeFinderHotkeysReturn;
168
805
 
169
806
  interface TreeChevronProps {
170
807
  isExpanded: boolean;
@@ -273,44 +910,66 @@ interface TreeIndentGuidesProps {
273
910
  */
274
911
  declare function TreeIndentGuides({ level, indent }: TreeIndentGuidesProps): react_jsx_runtime.JSX.Element;
275
912
 
276
- interface FlattenInput<T> {
277
- roots: TreeNode<T>[];
278
- expandedIds: ReadonlySet<TreeItemId>;
279
- cache: ChildCache<T>;
280
- /** Optional predicate. Nodes returning `false` (and their descendants) are excluded. */
281
- filterNode?: (node: TreeNode<T>) => boolean;
913
+ interface TreeRenameInputProps {
914
+ initialValue: string;
915
+ isFolder: boolean;
916
+ /** Called with the new (trimmed) name when the user presses Enter / blurs. */
917
+ onCommit: (nextName: string) => void | Promise<unknown>;
918
+ /** Called when the user presses Escape. */
919
+ onCancel: () => void;
920
+ className?: string;
282
921
  }
283
922
  /**
284
- * Walk the tree top-to-bottom and produce a flat list of visible rows.
923
+ * Inline rename input rendered in place of `<TreeLabel>` while a row is
924
+ * being renamed. Mounts focused with the *base* portion of the name
925
+ * pre-selected (Finder behaviour — `foo.txt` selects `foo`).
285
926
  *
286
- * Visibility rule: a child row appears only when every ancestor is in
287
- * `expandedIds`. The output is ordered exactly as it should render,
288
- * which keeps keyboard navigation (next/prev row) trivial.
927
+ * Behaviour:
928
+ * - Enter → commit
929
+ * - Escape → cancel (no adapter call)
930
+ * - blur → commit (matches Finder; intentional even for empty
931
+ * names — the host validates and re-opens on error)
932
+ * - all other keys are stopped from bubbling so Tree's container
933
+ * hotkeys (↑↓ delete F2 etc.) don't fire while typing.
289
934
  */
290
- declare function flattenTree<T>({ roots, expandedIds, cache, filterNode, }: FlattenInput<T>): FlatRow<T>[];
935
+ declare function TreeRenameInput({ initialValue, isFolder, onCommit, onCancel, className, }: TreeRenameInputProps): react_jsx_runtime.JSX.Element;
291
936
 
292
- interface PersistedTreeState {
293
- expandedItems: TreeItemId[];
294
- selectedItems: TreeItemId[];
937
+ interface TreeDropIndicatorProps {
938
+ position: TreeMovePosition;
939
+ /** Indent in pixels — keeps the line aligned with the row's text. */
940
+ indent: number;
941
+ /** Render a "rejected" style (red wash) when the drop is forbidden. */
942
+ invalid?: boolean;
295
943
  }
296
- declare function loadTreeState(key: string): PersistedTreeState | null;
297
- declare function saveTreeState(key: string, state: PersistedTreeState): void;
298
- declare function clearTreeState(key: string): void;
944
+ /**
945
+ * Visual hint for an in-progress drag-and-drop. Three modes:
946
+ *
947
+ * - `before` / `after` → a 2px horizontal line above / below the row
948
+ * - `inside` → a translucent primary wash filling the row
949
+ *
950
+ * Indents the line by the row's depth so it visually aligns with the
951
+ * target's content (rather than running edge-to-edge).
952
+ *
953
+ * Positioned absolutely — the parent `TreeRow` provides `position: relative`.
954
+ */
955
+ declare function TreeDropIndicator({ position, indent, invalid, }: TreeDropIndicatorProps): react_jsx_runtime.JSX.Element;
299
956
 
300
- interface DemoNode {
301
- name: string;
957
+ interface TreeEmptyAreaProps {
958
+ className?: string;
302
959
  }
303
960
  /**
304
- * Build a deterministic synthetic tree for stories and tests.
961
+ * Fills the remaining vertical space below `<TreeContent>` so the user
962
+ * can right-click "into nothing" to get a Finder/Explorer-style empty
963
+ * area menu (paste / new file / new folder at root), and so DnD has a
964
+ * root drop target.
305
965
  *
306
- * @example
307
- * const data = createDemoTree({ depth: 4, breadth: 3 });
308
- * <TreeRoot data={data} getItemName={(n) => n.data.name} />
966
+ * Built-in actions are derived the same way as for rows — through
967
+ * `buildDefaultMenuItems`, with `targetNode = null` (root) and
968
+ * `selectedNodes = []` (nothing under the right-click). Items whose
969
+ * `available()` predicate fails are simply skipped, so a tree without
970
+ * `adapter.createFile/Folder` and without a clipboard payload shows
971
+ * no menu at all.
309
972
  */
310
- declare function createDemoTree({ depth, breadth, rootPrefix, }?: {
311
- depth?: number;
312
- breadth?: number;
313
- rootPrefix?: string;
314
- }): TreeNode<DemoNode>[];
973
+ declare function TreeEmptyArea({ className }: TreeEmptyAreaProps): react_jsx_runtime.JSX.Element;
315
974
 
316
- export { type ChildCache, type ChildEntry, type ChildEntryStatus, type DemoNode, FlatRow, type FlattenInput, type PersistedTreeState, ResolvedAppearance, TreeRoot as Tree, TreeActivateOptions, TreeActivationMode, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuSlot, type TreeContextValue, TreeEmpty, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, TreeLabels, TreeNode, TreeProvider, type TreeProviderProps, TreeRoot, TreeRootProps, TreeRow, type TreeRowProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, flattenTree, loadTreeState, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
975
+ export { type ChildCache, type ChildEntry, type ChildEntryStatus, DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, type DemoNode, FinderTree, FlatRow, type FlattenInput, type PersistedTreeState, type ResolvedAppearance, TREE_DND_MIME, TreeRoot as Tree, type TreeAccentIntensity, type TreeActionsHandle, type TreeActivateOptions, type TreeActivationMode, type TreeAdapter, type TreeAppearance, type TreeBuiltinAction, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuActionsResolver, TreeContextMenuItem, TreeContextMenuSlot, type TreeContextValue, type TreeDensity, TreeDropIndicator, type TreeDropIndicatorProps, TreeEmpty, TreeEmptyArea, type TreeEmptyAreaProps, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, type TreeLabels, type TreeLoadChildren, type TreeMovePosition, TreeNode, TreeProvider, type TreeProviderProps, type TreeRadius, TreeRenameInput, type TreeRenameInputProps, TreeRoot, type TreeRootProps, TreeRow, type TreeRowProps, TreeRowRenderProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, type TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeFinderHotkeysOptions, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, appearanceToStyle, autoSelectRange, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, defaultCanDrop, flattenTree, loadTreeState, resolveAppearance, resolveChildren, resolveDropZone, saveTreeState, splitFileName, useTreeActions, useTreeClipboard, useTreeContext, useTreeDnd, useTreeExpansion, useTreeFinderHotkeys, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRename, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };