@aiquants/directory-tree 3.12.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -15
- package/dist/DirectoryTree.d.ts +1 -1
- package/dist/DirectoryTreeGrid.d.ts +7 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1245 -1083
- package/dist/labels.d.ts +4 -0
- package/dist/rowReveal.d.ts +5 -0
- package/dist/styles/directory-tree.standalone.css +1 -1
- package/dist/tabStop.d.ts +20 -0
- package/dist/types.d.ts +29 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ This package requires the following peer dependencies:
|
|
|
33
33
|
npm install react react-dom @aiquants/virtualscroll
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
`@aiquants/virtualscroll` must be 3.
|
|
36
|
+
`@aiquants/virtualscroll` must be 3.11.3 or later: it supplies the `locale` / `labels` chrome catalog, the pill-aware `scrollToIndex(index, { align: "nearest" })` that reveals focused rows, and the edge pills that hide while the pane rests at their edge (so the first and last rows are never left under a pill).
|
|
37
37
|
|
|
38
38
|
## Quick Start
|
|
39
39
|
|
|
@@ -125,6 +125,7 @@ The main component for rendering the directory tree.
|
|
|
125
125
|
| `selection` | `object` | Yes | Configuration for item selection |
|
|
126
126
|
| `visual` | `object` | No | Visual customization options |
|
|
127
127
|
| `virtualScroll` | `DirectoryTreeVirtualScrollOptions` | No | Pass-through options for the underlying VirtualScroll component |
|
|
128
|
+
| `ref` | `Ref<DirectoryTreeHandle>` | No | Receives the tree's imperative scroll handle. See [Scroll handle](#scroll-handle-ref) |
|
|
128
129
|
| `locale` | `DirectoryTreeLocale` (`"en"` \| `"ja"`) | No | UI chrome language (default `"en"`). See [Localization](#localization) |
|
|
129
130
|
| `labels` | `DirectoryTreeLabelOverrides` | No | Per-key overrides over the catalog of `locale`. See [Localization](#localization) |
|
|
130
131
|
|
|
@@ -145,7 +146,8 @@ The main component for rendering the directory tree.
|
|
|
145
146
|
| Prop | Type | Required | Default | Description |
|
|
146
147
|
| --- | --- | --- | --- | --- |
|
|
147
148
|
| `onEntryClick` | `(event: DirectoryTreeClickEvent) => void` | Yes | - | Callback function triggered when an entry is clicked |
|
|
148
|
-
| `selectedPath` | `string \| null` | No | - | The currently selected file path |
|
|
149
|
+
| `selectedPath` | `string \| null` | No | - | The currently selected file path (highlighted with `data-entry-selected`). In classic mode the selected row is also where the tree's Tab stop starts (grid rows are each a Tab stop) — see [Keyboard and focus](#keyboard-and-focus) |
|
|
150
|
+
| `currentPath` | `string \| null` | No | - | The entry the host shows as current (for example the open document). Its row carries `aria-current="page"` in every selection mode, so assistive technology can tell the shown entry from the selected set in multiple selection. The tree draws no style for it; style `[aria-current="page"]` yourself |
|
|
149
151
|
| `mode` | `'none' \| 'single' \| 'multiple'` | No | `'none'` | Selection mode for items |
|
|
150
152
|
| `selectedItems` | `Set<string>` | No | - | Set of paths for currently selected items |
|
|
151
153
|
| `onSelectionChange` | `(entry: DirectoryEntry, isSelected: boolean) => void` | No | - | Callback when item selection changes |
|
|
@@ -174,19 +176,43 @@ The main component for rendering the directory tree.
|
|
|
174
176
|
| `directoryNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for directory names |
|
|
175
177
|
| `fileNameClassName` | `string` | No | - | Additional CSS classes specifically for file names |
|
|
176
178
|
| `fileNameStyle` | `React.CSSProperties` | No | - | Additional inline styles specifically for file names |
|
|
179
|
+
| `expandIconClassName` | `string` | No | - | Additional CSS classes for the expand glyph (the chevron drawn in the row when `showTreeLines` is `false`), merged like `nameClassName`: the selected-row colour class still follows it, and a colour class replaces only the light default, so the built-in `dark:text-gray-400` stays unless the class carries a `dark:` colour too |
|
|
180
|
+
| `expandIconStyle` | `React.CSSProperties` | No | - | Inline styles for the expand glyph, applied like `nameStyle` (they win over every class, the selected-row colour included). The glyph is drawn in `currentColor`, so `{ color: "var(--your-token)" }` follows your colour tokens independently of the `dark` class. The canvas glyph drawn with the tree lines takes `lineColor` |
|
|
177
181
|
|
|
178
182
|
### Virtual Scroll Options
|
|
179
183
|
|
|
180
|
-
`virtualScroll` lets you customize the embedded `@aiquants/virtualscroll` instance without re-implementing list rendering. Every option is optional and mirrors the VirtualScroll API.
|
|
184
|
+
`virtualScroll` lets you customize the embedded `@aiquants/virtualscroll` instance without re-implementing list rendering. Every option is optional and mirrors the VirtualScroll API, except the parts the tree owns (listed below).
|
|
181
185
|
|
|
182
|
-
- `overscanCount`: Adjust how many items render beyond the viewport for smoother scrolling (default: `
|
|
186
|
+
- `overscanCount`: Adjust how many items render beyond the viewport for smoother scrolling (default: `15`).
|
|
183
187
|
- `scrollBarOptions`: Configure scrollbar appearance and behavior (width, thumb drag, track click, arrow buttons, tap scroll circle).
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
A host that drives the classic tree from the keyboard can pass `enableArrowButtonTabStops: false` to make the scrollbar and the
|
|
189
|
+
Top/Bottom buttons pointer-only: the tree's own arrow keys, Home and End keep the focused row in view. In grid mode the option
|
|
190
|
+
reaches the vertical scrollbar and the Top/Bottom buttons only; the horizontal scrollbar of the numeric columns keeps its arrow
|
|
191
|
+
buttons as Tab stops, because it is the only keyboard path to the columns scrolled out of view.
|
|
192
|
+
- `behaviorOptions`: Configure scrolling behavior (pointer drag, inertia, wheel speed, overscroll, height reconciliation).
|
|
193
|
+
- `onItemFocus`: Called with the row's index in the flattened list whenever a row (or an element inside it) receives focus. The tree calls it itself, in classic and grid mode.
|
|
194
|
+
- `contentProps`: ARIA / identity attributes for the scroll pane's content element — the element that carries `role="tree"` (classic mode) or the body `role="rowgroup"` (grid mode).
|
|
195
|
+
- `liveRegion`: Opt-in `role="status"` region that announces the visible range (`format` builds the text). It is rendered next to the scroll pane, so in classic mode it stays outside `role="tree"`.
|
|
196
|
+
- `onScrollAdjust`: Called synchronously each time the embedded list moves its scroll position on its own (layout-shift compensation, re-pinning a pending alignment), never for scrolls the user or the host start.
|
|
197
|
+
- `onScroll`, `onRangeChange`, `className`, `background`, `initialScrollIndex`, `initialScrollOffset`, `initialScrollAnchor`: Hook into scroll lifecycle or provide bespoke styling. `background` renders inside the element that carries `role="tree"`, so mark decorative backgrounds `aria-hidden`.
|
|
198
|
+
|
|
199
|
+
These are **not** accepted, because the tree owns them:
|
|
200
|
+
|
|
201
|
+
- The engine's `locale` / `labels`: the one surface for the UI chrome language is the top-level `locale` / `labels`
|
|
202
|
+
of `DirectoryTree`, which also reaches the row kind words and the grid-mode horizontal scrollbar. See
|
|
203
|
+
[Localization](#localization).
|
|
204
|
+
- `ref`: use the tree's own handle ([Scroll handle](#scroll-handle-ref)).
|
|
205
|
+
- `onWheelHorizontal`, `onPanHorizontal`, `horizontalKeyInputs`, `horizontalKeyStep`: the tree owns the horizontal axis.
|
|
206
|
+
- `behaviorOptions.enableKeyboardNavigation` and `behaviorOptions.enableEscapeRowReturn`: the tree's rows own the
|
|
207
|
+
keyboard (see [Keyboard and focus](#keyboard-and-focus)); the tree always turns the engine's row navigation off,
|
|
208
|
+
because its row wrappers would otherwise be focusable elements between `role="tree"` and the treeitems.
|
|
209
|
+
- `contentProps.role`, `contentProps["aria-label"]`, `contentProps["aria-labelledby"]` and
|
|
210
|
+
`contentProps["aria-multiselectable"]`: the tree's name comes from `visual.ariaLabel` / `visual.ariaLabelledBy`
|
|
211
|
+
and its multiselection from `selection.mode`.
|
|
212
|
+
|
|
213
|
+
Writing one of them in an object literal typed as `DirectoryTreeVirtualScrollOptions` is a type error. A value that
|
|
214
|
+
reaches the tree any other way (a variable of a wider type, an object built by a generic helper or a spread, a
|
|
215
|
+
JavaScript caller) compiles, and the tree ignores it at runtime.
|
|
190
216
|
|
|
191
217
|
Example:
|
|
192
218
|
|
|
@@ -208,6 +234,80 @@ Example:
|
|
|
208
234
|
/>;
|
|
209
235
|
```
|
|
210
236
|
|
|
237
|
+
### Keyboard and focus
|
|
238
|
+
|
|
239
|
+
The classic tree follows the WAI-ARIA tree pattern with a roving tabindex: it always has exactly one Tab stop.
|
|
240
|
+
|
|
241
|
+
- **Where Tab enters**: the row that last received focus — while it still holds focus, or while the selection has not
|
|
242
|
+
changed since it received focus — else the selected row (`selection.selectedPath`), else the first row. A candidate
|
|
243
|
+
inside a collapsed folder is skipped. So Tab enters a tree on its selected row, and once focus has left the tree, any
|
|
244
|
+
selection change moves the Tab stop to the selected row — also a change that later comes back to the path the
|
|
245
|
+
selection had when the row received focus.
|
|
246
|
+
- **Focus makes the Tab stop**: a row that receives focus — by the tree's keys, a script or a pointer, or through an
|
|
247
|
+
element inside the row — becomes the single Tab stop. A row holding focus stays the Tab stop even if the selection
|
|
248
|
+
changes meanwhile, so Shift+Tab from it leaves the tree. A row keeps holding focus while the window or browser tab is
|
|
249
|
+
inactive (it is still the page's focused element).
|
|
250
|
+
- **Keys**: `ArrowDown` / `ArrowUp` move between visible rows, `Home` / `End` jump to either end, `ArrowRight` opens a
|
|
251
|
+
collapsed folder or moves to its first child (an open folder without child rows keeps the focus), `ArrowLeft` closes
|
|
252
|
+
an open folder or moves to the parent, `Enter` and `Space` activate the row once per press (the auto-repeat of a held
|
|
253
|
+
key only has its default action prevented, so a held key never flips a folder or a gathered entry back and forth).
|
|
254
|
+
Grid rows activate on `Enter` with the same rule.
|
|
255
|
+
- **Keys with Alt, Ctrl or ⌘ are not the tree's**: an arrow key, `Home` or `End` held with Alt, Ctrl or Meta (⌘) is
|
|
256
|
+
neither handled nor has its default action prevented, so the browser's history keys (Alt+Left / Alt+Right,
|
|
257
|
+
⌘+Left / ⌘+Right) and a host's own shortcuts on them (for example Alt+Shift+Arrow) work while a row has focus.
|
|
258
|
+
Shift alone does not change a key.
|
|
259
|
+
- **The focused row is wholly in view**: a row that receives focus — moved there by the tree's keys, entered with Tab,
|
|
260
|
+
or focused by a script — is brought wholly into the window through the virtual list's reveal
|
|
261
|
+
(`scrollToIndex(index, { align: "nearest" })` of `@aiquants/virtualscroll`): the least scroll, and none when the row
|
|
262
|
+
already lies wholly inside, whether it was rendered beyond the window's edge or not rendered at all. While a Top/Bottom
|
|
263
|
+
button (`virtualScroll.scrollBarOptions.enableScrollToTopBottomButtons`) shows, the edge it covers does not count as
|
|
264
|
+
window, so the row lands clear of the button at any text size. A row a pointer press lands on is never scrolled, even when part of it
|
|
265
|
+
is under a button or beyond the window's edge: a press never shifts the row under the pointer, so both clicks of a
|
|
266
|
+
double-click hit the same row. A row that gets focus back because the window or browser tab became active again is not
|
|
267
|
+
scrolled: focus never left it, and the browser does not scroll there either.
|
|
268
|
+
- **Rows outside the render window**: when the Tab stop row is virtualized away, a visually hidden stand-in Tab stop
|
|
269
|
+
(`data-directory-tree-tab-stop`, outside `role="tree"`) takes its place in the Tab order; when it receives focus it
|
|
270
|
+
scrolls the Tab stop row into view and hands the focus to it. A host that hands focus to the tree by selector should
|
|
271
|
+
look for `[role="tree"] [role="treeitem"][tabindex="0"]` and then `[data-directory-tree-tab-stop]`. The stand-in
|
|
272
|
+
appears in the render that follows the one where the Tab stop row left the render window (the tree measures that
|
|
273
|
+
in its own layout effect), so look it up after that commit, not in a layout effect of the same commit.
|
|
274
|
+
|
|
275
|
+
The element that carries `role="tree"` (with the tree's name and `aria-multiselectable`) is the scroll pane's
|
|
276
|
+
content element, which owns only the rows: the scrollbar, the Top/Bottom buttons and the live region
|
|
277
|
+
(`virtualScroll.liveRegion`) stay outside the tree, and the wrappers between the tree and its rows carry no role,
|
|
278
|
+
tabindex or ARIA attribute. The root container has no role; target it through `visual.className`.
|
|
279
|
+
|
|
280
|
+
Grid mode (`grid`) differs: every grid row is a Tab stop and the rows have no arrow-key navigation, and
|
|
281
|
+
`role="treegrid"` sits on the root container, so the vertical and horizontal scrollbars and the live region are inside
|
|
282
|
+
the treegrid.
|
|
283
|
+
|
|
284
|
+
### Scroll handle (`ref`)
|
|
285
|
+
|
|
286
|
+
`ref` receives a `DirectoryTreeHandle`. Rows are addressed by their index in the flattened list (the rows the tree
|
|
287
|
+
shows, in display order — what `onRangeChange`, `onItemFocus` and `getScrollAnchor` report) or by
|
|
288
|
+
`DirectoryEntry.absolutePath`. No method moves the focus.
|
|
289
|
+
|
|
290
|
+
| Method | Description |
|
|
291
|
+
| --- | --- |
|
|
292
|
+
| `scrollToIndex(index, { align? })` | Scrolls the row into view. `align` is `"top"` (default), `"bottom"` or `"center"` (as VirtualScroll's `scrollToIndex`, against the window itself), or `"nearest"` (the reveal a row gets when it receives focus by key, Tab or script: the least scroll that brings the row wholly into the window clear of a visible Top/Bottom button, none when it already lies wholly inside). A non-integer or out-of-range index, or an unknown `align`, throws a `RangeError` |
|
|
293
|
+
| `scrollToPath(path, { align? })` | Same, by absolute path. Returns `false` (and does nothing) when the path is not in the flattened list — an unknown path, or an entry inside a collapsed folder |
|
|
294
|
+
| `getScrollAnchor()` | The first visible row as `{ index, offsetPx }`, to restore exactly through `virtualScroll.initialScrollAnchor` on the next mount; `null` for an empty tree |
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
import { useRef } from 'react';
|
|
298
|
+
import { DirectoryTree, type DirectoryTreeHandle } from '@aiquants/directory-tree';
|
|
299
|
+
|
|
300
|
+
const tree = useRef<DirectoryTreeHandle>(null);
|
|
301
|
+
|
|
302
|
+
// Bring the shown document's row into view without moving the focus
|
|
303
|
+
tree.current?.scrollToPath(currentPath, { align: 'nearest' });
|
|
304
|
+
|
|
305
|
+
<DirectoryTree ref={tree} {...commonProps} selection={{ ...selection, currentPath }} />;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
The embedded VirtualScroll's own handle is not exposed (`virtualScroll.ref` is a type error): the tree's handle
|
|
309
|
+
addresses rows of the flattened list and leaves the axes the tree owns alone.
|
|
310
|
+
|
|
211
311
|
### useDirectoryTreeState Hook
|
|
212
312
|
|
|
213
313
|
A hook for managing directory tree state with localStorage persistence.
|
|
@@ -323,6 +423,22 @@ You can customize the appearance by passing custom classes or inline styles for
|
|
|
323
423
|
/>
|
|
324
424
|
```
|
|
325
425
|
|
|
426
|
+
The expand glyph drawn in the row (when `showTreeLines` is `false`) takes `expandIconClassName` /
|
|
427
|
+
`expandIconStyle` the same way. To make its colour follow your own theme rather than the `dark` class, pass a colour
|
|
428
|
+
token through `expandIconStyle`: an inline style wins over every class, the built-in `dark:` colour included.
|
|
429
|
+
|
|
430
|
+
```tsx
|
|
431
|
+
<DirectoryTree
|
|
432
|
+
visual={{ showTreeLines: false, expandIconStyle: { color: "var(--app-tree-glyph)" } }}
|
|
433
|
+
// ... other props
|
|
434
|
+
/>
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
`expandIconClassName` is merged into the built-in classes like `nameClassName`, so a colour class on its own replaces
|
|
438
|
+
only the light default (`text-gray-500`): the built-in `dark:text-gray-400` stays and wins under your `dark` class.
|
|
439
|
+
To set the colour with a class, give its `dark:` variant as well, for example
|
|
440
|
+
`"text-(--app-tree-glyph) dark:text-(--app-tree-glyph)"`.
|
|
441
|
+
|
|
326
442
|
Alternatively, you can customize components inside the container using global CSS classes:
|
|
327
443
|
|
|
328
444
|
```css
|
|
@@ -490,9 +606,10 @@ const { toggle, isExpanded, expandMultiple, collapseMultiple } = useDirectoryTre
|
|
|
490
606
|
|
|
491
607
|
## Localization
|
|
492
608
|
|
|
493
|
-
`DirectoryTree` renders
|
|
494
|
-
accessible name (`"src (directory)"`, `"package.json (file)"`) and the
|
|
495
|
-
`@aiquants/virtualscroll` (
|
|
609
|
+
`DirectoryTree` renders its own UI chrome strings: the kind word of each classic-mode row's
|
|
610
|
+
accessible name (`"src (directory)"`, `"package.json (file)"`) and the chrome strings of the embedded
|
|
611
|
+
`@aiquants/virtualscroll` (every key of its `VIRTUAL_SCROLL_LABEL_KEYS`, such as the scrollbar arrow labels,
|
|
612
|
+
scroll-to-edge pills and empty state). They come from a built-in
|
|
496
613
|
catalog in English (`"en"`, the default) and Japanese (`"ja"`). Entry names, column headers / footers and the
|
|
497
614
|
tree's own accessible name (`visual.ariaLabel`) are your content and are never translated.
|
|
498
615
|
|
|
@@ -515,7 +632,9 @@ tree's own accessible name (`visual.ariaLabel`) are your content and are never t
|
|
|
515
632
|
| `scrollToBottom` | `Bottom` | `末尾へ` | Scroll-to-bottom pill (same option) |
|
|
516
633
|
| `noItems` | `No items` | `項目がありません` | Empty state when `entries` is `[]` |
|
|
517
634
|
|
|
518
|
-
The
|
|
635
|
+
The engine rows are `VIRTUAL_SCROLL_LABEL_CATALOGS` of `@aiquants/virtualscroll`, reused by value. The table lists the
|
|
636
|
+
engine keys every supported engine version has; any further key of the installed engine's `VIRTUAL_SCROLL_LABEL_KEYS` is
|
|
637
|
+
accepted, validated and forwarded the same way. Grid-mode
|
|
519
638
|
rows carry no row-level accessible name (their cells name them), so the kind words apply to classic mode only.
|
|
520
639
|
|
|
521
640
|
- **Default**: omitting `locale` is identical to `locale="en"`, and the `en` catalog is the historical English
|
|
@@ -528,7 +647,7 @@ rows carry no row-level accessible name (their cells name them), so the kind wor
|
|
|
528
647
|
`undefined` value keeps the catalog value, and every present value must be a string with non-whitespace
|
|
529
648
|
content. The result is frozen. The engine keys are validated by the engine's `resolveVirtualScrollLabels`
|
|
530
649
|
(`[virtualscroll]` messages), the own keys by the package (`[directory-tree]` messages).
|
|
531
|
-
- **Forwarding**: `locale` and the
|
|
650
|
+
- **Forwarding**: `locale` and the engine keys reach both the embedded `VirtualScroll` and the grid-mode
|
|
532
651
|
horizontal `ScrollBar`. An inline `labels={{…}}` object is fine: the forwarded engine labels keep their identity
|
|
533
652
|
while the strings are unchanged, so the virtualized body is not re-rendered.
|
|
534
653
|
|
package/dist/DirectoryTree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { directoryTreeClasses } from "./entryRendering.tsx";
|
|
2
2
|
import { DirectoryTreeProps, TreeLineGeometry, TreeLineItemInfo } from "./types.ts";
|
|
3
3
|
export declare const buildTreeLineGeometry: (items: TreeLineItemInfo[], itemHeights: number[], itemOffsets: number[], segmentWidth: number, includeGlyphs: boolean, glyphSizeOverride?: number) => TreeLineGeometry;
|
|
4
|
-
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
4
|
+
export declare const DirectoryTree: ({ entries, expansion: { toggle, isExpanded, expandMultiple, collapseMultiple, isPending, alwaysExpanded, doubleClickAction }, selection: { onEntryClick, selectedPath, currentPath, mode: selectionMode, selectedItems, onSelectionChange }, visual: { className, style, ariaLabel, ariaLabelledBy, lineColor, showTreeLines, showExpandIcons, showDirectoryIcons, showFileIcons, iconOverrides, expandIconSize, itemHeight, removeRootIndent, highlightStyles, entryClassName, entryStyle, nameClassName, nameStyle, directoryNameClassName, directoryNameStyle, fileNameClassName, fileNameStyle, expandIconClassName, expandIconStyle, }, virtualScroll: virtualScrollOptions, grid, sort, locale, labels, ref, }: DirectoryTreeProps) => import("react").JSX.Element;
|
|
5
5
|
export { directoryTreeClasses };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
1
2
|
import { DirectoryEntry, DirectoryTreeColumn, DirectoryTreeIconOverrides, HighlightStyles } from "./types.ts";
|
|
2
3
|
export type GridRowVisual = {
|
|
3
4
|
iconOverrides?: DirectoryTreeIconOverrides;
|
|
@@ -10,6 +11,8 @@ export type GridRowVisual = {
|
|
|
10
11
|
fontSize?: number | string;
|
|
11
12
|
indentSize?: number;
|
|
12
13
|
highlightStyles?: HighlightStyles;
|
|
14
|
+
expandIconClassName?: string;
|
|
15
|
+
expandIconStyle?: CSSProperties;
|
|
13
16
|
};
|
|
14
17
|
export declare const isEntryExpanded: (entry: DirectoryEntry, isDirOpen: (path: string) => boolean) => boolean;
|
|
15
18
|
export type DirectoryTreeGridRowProps = {
|
|
@@ -18,6 +21,9 @@ export type DirectoryTreeGridRowProps = {
|
|
|
18
21
|
positionInSet: number;
|
|
19
22
|
setSize: number;
|
|
20
23
|
rowIndex: number;
|
|
24
|
+
flatIndex: number;
|
|
25
|
+
onRowFocus: (index: number, path: string, row: HTMLElement) => void;
|
|
26
|
+
onRowBlur: (path: string, row: HTMLElement) => void;
|
|
21
27
|
isSelectedForAria: boolean;
|
|
22
28
|
rowHeight: number;
|
|
23
29
|
isDirOpen: (path: string) => boolean;
|
|
@@ -28,6 +34,7 @@ export type DirectoryTreeGridRowProps = {
|
|
|
28
34
|
rowClassName?: string | ((entry: DirectoryEntry) => string);
|
|
29
35
|
selection: {
|
|
30
36
|
selectedPath: string | null;
|
|
37
|
+
currentPath: string | null;
|
|
31
38
|
mode?: "none" | "single" | "multiple";
|
|
32
39
|
selectedItems?: Set<string>;
|
|
33
40
|
onEntryClick: (event: import("./types.ts").DirectoryTreeClickEvent) => void;
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),pe=require("@aiquants/virtualscroll"),M=require("tailwind-merge"),O=require("@phosphor-icons/react");function Gr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const fe=Gr(l);var at={exports:{}},ze={};var ur;function Vr(){if(ur)return ze;ur=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,s,c){var i=null;if(c!==void 0&&(i=""+c),s.key!==void 0&&(i=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:e,type:n,key:i,ref:s!==void 0?s:null,props:c}}return ze.Fragment=t,ze.jsx=r,ze.jsxs=r,ze}var Ye={};var dr;function Ur(){return dr||(dr=1,process.env.NODE_ENV!=="production"&&(function(){function e(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===J?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case v:return"Fragment";case $:return"Profiler";case R:return"StrictMode";case W:return"Suspense";case F:return"SuspenseList";case ae:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case h:return"Portal";case C:return o.displayName||"Context";case x:return(o._context.displayName||"Context")+".Consumer";case y:var p=o.render;return o=o.displayName,o||(o=p.displayName||p.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case _:return p=o.displayName||null,p!==null?p:e(o.type)||"Memo";case U:p=o._payload,o=o._init;try{return e(o(p))}catch{}}return null}function t(o){return""+o}function r(o){try{t(o);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),t(o)}}function n(o){if(o===v)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===U)return"<...>";try{var p=e(o);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function s(){var o=Z.A;return o===null?null:o.getOwner()}function c(){return Error("react-stack-top-frame")}function i(o){if(ne.call(o,"key")){var p=Object.getOwnPropertyDescriptor(o,"key").get;if(p&&p.isReactWarning)return!1}return o.key!==void 0}function f(o,p){function w(){me||(me=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}w.isReactWarning=!0,Object.defineProperty(o,"key",{get:w,configurable:!0})}function j(){var o=e(this.type);return le[o]||(le[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function S(o,p,w,T,se,ie){var A=w.ref;return o={$$typeof:N,type:o,key:p,props:w,_owner:T},(A!==void 0?A:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:j}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function m(o,p,w,T,se,ie){var A=p.children;if(A!==void 0)if(T)if(te(A)){for(T=0;T<A.length;T++)b(A[T]);Object.freeze&&Object.freeze(A)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(A);if(ne.call(p,"key")){A=e(o);var Q=Object.keys(p).filter(function(ue){return ue!=="key"});T=0<Q.length?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}",P[A+T]||(Q=0<Q.length?"{"+Q.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,A,L,ae,L),P[L+A]=!0)}if(L=null,T!==void 0&&(s(T),L=""+T),i(b)&&(s(b.key),L=""+b.key),"key"in b){T={};for(var k in b)k!=="key"&&(T[k]=b[k])}else T=b;return L&&f(T,typeof a=="function"?a.displayName||a.name||"Unknown":a),x(a,L,T,n(),se,ce)}function h(a){v(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===te&&(a._payload.status==="fulfilled"?v(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function v(a){return typeof a=="object"&&a!==null&&a.$$typeof===j}var w=l,j=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),E=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),B=Symbol.for("react.client.reference"),re=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,N=Array.isArray,z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(a){return a()}};var M,V={},de=w.react_stack_bottom_frame.bind(w,c)(),fe=z(r(c)),P={};Me.Fragment=y,Me.jsx=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!1,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)},Me.jsxs=function(a,b,T){var A=1e4>re.recentlyCreatedOwnerStacks++;return d(a,b,T,!0,A?Error("react-stack-top-frame"):de,A?z(r(a)):fe)}})()),Me}var Yt;function vr(){return Yt||(Yt=1,process.env.NODE_ENV==="production"?Ye.exports=gr():Ye.exports=xr()),Ye.exports}var u=vr();function wr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const Er=ie.forwardRef(wr);function Sr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const kr=ie.forwardRef(Sr);function Rr({title:e,titleId:t,...s},r){return ie.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},s),e?ie.createElement("title",{id:t},e):null,ie.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const jr=ie.forwardRef(Rr),ze=18,Ve=12,zt=8,$={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:D.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:D.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:D.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:D.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:D.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:D.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:D.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:D.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:D.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},ve=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},Xt=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:r,expandIconSize:n})=>{const c=n?{width:n,height:n}:void 0,i=n?"":"h-4 w-4";return!(s&&e)||r?u.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?u.jsx(Er,{className:i,style:c}):u.jsx(kr,{className:i,style:c})},at=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const r=e.map(n=>at(n,t)).filter(Boolean);return r.length?r:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},Ir=(e,t,s)=>{const r=(t||(s?ve(s):"")).toLowerCase(),n=(e||"").toLowerCase();if(n&&n!=="application/octet-stream"){if(n==="text/markdown"||n==="text/x-markdown")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="application/pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(n.includes("excel")||n.includes("spreadsheet")||n.includes("google-apps.spreadsheet"))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n==="text/csv"||n==="text/tab-separated-values")return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(n.includes("word")||n.includes("msword")||n.includes("wordprocessingml")||n.includes("google-apps.document")||n==="application/rtf")return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(n.includes("powerpoint")||n.includes("presentation")||n.includes("google-apps.presentation"))return u.jsx(F.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(n.startsWith("image/"))return u.jsx(F.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(n.startsWith("audio/"))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(n.startsWith("video/"))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(n.includes("zip")||n.includes("tar")||n.includes("compressed")||n.includes("archive"))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(n==="application/json"||n.includes("javascript")||n.includes("typescript")||n.includes("xml")||n.startsWith("text/html")||n.startsWith("text/css")||n.includes("x-python")||n.includes("x-sh")||n.includes("x-go")||n.includes("x-rust"))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(n.startsWith("text/"))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(r){if(r==="md"||r==="markdown"||r==="mdx")return u.jsx(F.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="pdf")return u.jsx(F.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(r))return u.jsx(F.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(r))return u.jsx(F.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(r))return u.jsx(F.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(r))return u.jsx(F.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(r))return u.jsx(F.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"].includes(r))return u.jsx(F.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(r))return u.jsx(F.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(r))return u.jsx(F.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(r))return u.jsx(F.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(r))return u.jsx(F.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return u.jsx(F.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Jt=(e,t)=>{const{entry:s,isDirectory:r,isExpanded:n,extension:c,mimeType:i}=e;let f;const R=i||s.mimeType;return s.icon!==void 0?f=s.icon:r?f=n&&t?.directoryExpanded||t?.directory||u.jsx(jr,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||Ir(R,c,s.name),at(typeof f=="function"?f(e):f,s.absolutePath)},Cr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,r])=>[`data-${Cr(s)}`,String(r)]))},Nr=500,Zt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:r,selectionMode:n,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:R})=>{const x=l.useRef(null);return l.useEffect(()=>()=>{x.current&&window.clearTimeout(x.current)},[]),l.useCallback(d=>{d.stopPropagation(),n!=="none"&&!t&&c&&c(e,!r);let h=!1;i({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{h=!0}}),!(!t||h)&&(x.current?(window.clearTimeout(x.current),x.current=null,R(e)):x.current=window.setTimeout(()=>{f(e.absolutePath),x.current=null},Nr))},[t,e,s,R,f,i,n,c,r])},Qt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Vt=(e,t)=>e.children!==void 0&&t(e.absolutePath),er=(e,t)=>({width:e,gridTemplateColumns:t}),tr=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:r,rowIndex:n,isSelectedForAria:c,rowHeight:i,isDirOpen:f,columns:R,numericTemplate:x,numericTotal:d,nameWidth:h,rowClassName:v,selection:{onEntryClick:w,selectedPath:j,mode:m="none",selectedItems:y,onSelectionChange:S},expansion:{toggleDirectory:C,onToggleDirectoryRecursive:I},visual:{iconOverrides:E,showExpandIcons:p=!0,showDirectoryIcons:W=!0,showFileIcons:_=!0,useCanvasExpandIcons:H=!1,expandIconSize:te,indentSize:J=Ve,highlightStyles:B}})=>{const[re,ne]=l.useState(!1),N=e.children!==void 0,z=N&&f(e.absolutePath),M=e.absolutePath===j,V=!N&&!!y?.has(e.absolutePath),de=N?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath),fe=Zt({entry:e,isDirectory:N,isExpanded:z,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:w,toggleDirectory:C,onToggleDirectoryRecursive:I}),P=re?B?.hoverClassName!==void 0?B.hoverClassName:$.entryHover:"",a=(()=>{if(N){if(M)return B?.directorySelectedClassName!==void 0?B.directorySelectedClassName:$.entrySelected}else if(M||V)return B?.itemSelectedClassName!==void 0?B.itemSelectedClassName:D.twMerge(M&&$.entrySelected,V&&$.entryItemSelected);return""})(),b=typeof v=="function"?v(e):v,T=D.twMerge("dt-grid-row cursor-pointer select-none",P,a,b,e.className),A=D.twMerge($.expandIcon,(M||V)&&$.expandIconSelected),se=D.twMerge($.typeIcon,(M||V)&&$.typeIconSelected),ce=D.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&$.nameDirectory,(M||V)&&$.nameSelected),L=Xt({isDirectory:N,isExpanded:z,showExpandIcons:p,useCanvasExpandIcons:H,expandIconSize:te}),ae=(N?W:_)?Jt({entry:e,isDirectory:N,isExpanded:z,isSelected:M,isItemSelected:V,extension:de,mimeType:e.mimeType},E):null,k={indentLevel:t,isDirectory:N,isExpanded:z},[U,...q]=R,Z=U?.render?U.render(e,k):e.label??e.name,we={...re?B?.hoverStyle:{},...N&&M?B?.directorySelectedStyle:{},...!N&&(M||V)?B?.itemSelectedStyle:{}};return u.jsxs("div",{className:T,style:{height:i,...we,...e.style},role:"row","aria-expanded":N?z:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":r,"aria-rowindex":n,"aria-selected":m==="none"?void 0:c,...qt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(z):void 0,"data-entry-selected":M?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:fe,onMouseEnter:()=>ne(!0),onMouseLeave:()=>ne(!1),onKeyDown:Q=>Q.key==="Enter"&&fe(Q),tabIndex:0,children:[u.jsxs("div",{className:D.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:h,paddingLeft:Math.max(0,t*J)},children:[(p||H)&&u.jsx("span",{className:A,children:L}),(N?W:_)&&u.jsx("span",{className:se,children:ae}),u.jsx("span",{className:ce,children:Z})]}),q.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(d,x),children:q.map(Q=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(Q.align),Q.className),role:"gridcell",children:Q.render?Q.render(e,k):null},Q.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Vt(e.entry,e.isDirOpen),r=Vt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===r&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});tr.displayName="DirectoryTreeGridRow";const rr=({kind:e,columns:t,numericTemplate:s,numericTotal:r,nameWidth:n,scrollBarWidth:c,className:i,nameContent:f,renderCell:R})=>{const[,...x]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",h=e==="header"?"dt-grid-header":"dt-grid-footer",v=e==="header"?"columnheader":"gridcell";return u.jsxs("div",{className:D.twMerge(h,"text-gray-600 dark:text-gray-300",i),role:"row",children:[u.jsx("div",{className:D.twMerge(d,"px-1",t[0]?.className),role:v,style:{width:n},children:f}),x.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:er(r,s),children:x.map(w=>u.jsx("div",{className:D.twMerge("dt-grid-cell",Qt(w.align),w.className),role:v,children:R(w)},w.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},Tr=({columns:e,className:t,...s})=>u.jsx(rr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:r=>r.header??null,...s}),Gt=(e,t)=>typeof e=="function"?e(t):e??null,_r=({columns:e,allEntries:t,className:s,...r})=>u.jsx(rr,{kind:"footer",columns:e,className:s,nameContent:Gt(e[0]?.footer,t),renderCell:n=>Gt(n.footer,t),...r}),Ar=240,nr=96,sr=12,ot=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},Mr=e=>e.slice(1).map(t=>`${ot(t,nr)}px`).join(" "),Lr=({measuredWidth:e,columns:t,scrollBarWidth:s=sr})=>{const r=ot(t[0],Ar),n=t.slice(1).reduce((R,x)=>R+ot(x,nr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-r-Math.max(0,s)),f=Math.max(0,n-i);return{nameWidth:r,numericTotal:n,numericVisible:i,maxHScroll:f}},st=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,Pr=e=>{const t=[],s=r=>{for(const n of r)t.push(n),n.children&&n.children.length>0&&s(n.children)};return s(e),t},ar=["entryKindDirectory","entryKindFile"],lt=[...ue.VIRTUAL_SCROLL_LABEL_KEYS,...ar],it=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),or=Object.freeze({en:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...it.en}),ja:Object.freeze({...ue.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...it.ja})}),Ut=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Or=e=>{const t={};let s=!1;for(const r of ue.VIRTUAL_SCROLL_LABEL_KEYS){const n=Object.hasOwn(e,r)?e[r]:void 0;n!==void 0&&(t[r]=n,s=!0)}return s?t:void 0},lr=(e,t)=>{const s=ue.resolveVirtualScrollLocale(e);if(t===void 0)return or[s];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${Ut(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const i of Object.keys(t))if(!lt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${lt.join(", ")}`);const c={...ue.resolveVirtualScrollLabels(s,Or(t)),...it[s]};for(const i of ar){const f=Object.hasOwn(t,i)?t[i]:void 0;if(f!==void 0){if(typeof f!="string"||f.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${Ut(f)}`);c[i]=f}}return Object.freeze(c)},Dr=e=>{const t={};for(const s of ue.VIRTUAL_SCROLL_LABEL_KEYS)t[s]=e[s];return Object.freeze(t)},Fr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},$r=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const r=Fr(t,s),n=e[r];return n?{path:n.entry.absolutePath,offsetInViewport:s-t[r]}:null},Hr=(e,t,s)=>{if(t.length===0||s.length!==t.length+1)return null;for(let r=0;r<t.length;r++)if(t[r].entry.absolutePath===e.path)return Math.max(0,s[r]+e.offsetInViewport);return null},Wr=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Br=(e,t,s)=>{const r=[];for(let n=t;n<s;n++){const c=e[n];if(!(!c||c.length===0))for(const i of c)r.push(i)}return r},Yr=(e,t,s,r)=>{const n=Math.max(1,Math.floor(t*r)),c=Math.max(1,Math.floor(s*r));(e.width!==n||e.height!==c)&&(e.width=n,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${s}px`&&(i.height=`${s}px`)},zr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const r of t)e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2);e.stroke()},Vr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let r=s[1];r.length===3&&(r=r.split("").map(f=>f+f).join(""));const n=Number.parseInt(r.slice(0,2),16),c=Number.parseInt(r.slice(2,4),16),i=Number.parseInt(r.slice(4,6),16);return`rgba(${n}, ${c}, ${i}, ${t})`},Gr=(e,t,s,r)=>{if(t.length===0)return;const n=Vr(s,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,R=e.lineCap,x=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const h=r??d.size,v=Math.max(0,h/2),w=Math.max(1,Math.round(h*.08)),j=Math.max(1,Math.round(h*.14)),m=Math.max(0,v-w*.8),y=Math.max(0,m*.55);n&&(e.fillStyle=n,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=w,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,v-w*.3),0,Math.PI*2),e.stroke(),e.lineWidth=j,e.beginPath(),e.moveTo(d.centerX-y,d.centerY),e.lineTo(d.centerX+y,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-y),e.lineTo(d.centerX,d.centerY+y),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=f,e.lineCap=R,e.lineJoin=x},ir=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w})=>{const j=l.useRef(null),m=l.useRef(null),y=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w}),S=l.useCallback(()=>{m.current=null;const I=j.current;if(!I)return;const E=I.getContext("2d");if(!E)return;const p=y.current;if(p.width<=0||p.viewportHeight<=0){E.clearRect(0,0,I.width,I.height);return}const W=Number.isFinite(p.devicePixelRatio??NaN)?p.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Yr(I,p.width,p.viewportHeight,W);const _=p.segmentsByItem.length,H=typeof p.renderStartIndex=="number"&&Number.isFinite(p.renderStartIndex)?Math.max(0,Math.floor(p.renderStartIndex)):Math.max(0,Math.floor(p.scrollPosition/p.itemHeight)),te=Math.min(_,Math.ceil((p.scrollPosition+p.viewportHeight)/p.itemHeight)),J=(()=>{if(typeof p.renderEndIndex=="number"&&Number.isFinite(p.renderEndIndex)){const N=Math.floor(p.renderEndIndex);return Math.max(Math.min(_,N+1),H)}return Math.max(te,H)})(),B=(()=>{if(typeof p.lookaheadEndIndex=="number"&&Number.isFinite(p.lookaheadEndIndex)){const N=Math.floor(p.lookaheadEndIndex),z=Math.min(_,N+1);return Math.max(z,J)}return Math.max(te,J)})(),re=Wr(p.segmentsByItem,H,B),ne=Br(p.glyphsByItem,H,B);E.save(),E.scale(W,W),E.clearRect(0,0,p.width,p.viewportHeight),E.translate(0,-p.scrollPosition),E.strokeStyle=p.color,zr(E,re,p.strokeWidth),Gr(E,ne,p.expandGlyphColor??p.color,p.expandGlyphSize),E.restore()},[]),C=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{y.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:r,viewportHeight:n,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:R,renderEndIndex:x,lookaheadEndIndex:d,devicePixelRatio:h,expandGlyphColor:v,expandGlyphSize:w},C()},[e,t,s,r,n,c,i,f,R,x,d,h,v,w,C]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),u.jsx("canvas",{ref:j,className:"pointer-events-none absolute top-0 left-0 z-0"})});ir.displayName="TreeLineCanvas";const Ur={msOverflowStyle:"none",scrollbarWidth:"none"},Kr=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},Xr=e=>{const t=l.useRef(null),s=t.current;return s!==null&&ue.VIRTUAL_SCROLL_LABEL_KEYS.every(r=>s[r]===e[r])?s:(t.current=e,e)},Jr=(e,t,s,r,n)=>{const c=[],i=[];let f=0;const R=(x,d,h)=>{const v=n?[...x].sort(n):x;for(let w=0;w<v.length;w++){const j=v[w],m=w===v.length-1,y=[...h,m],S=j.children!==void 0,C=S&&t(j.absolutePath,j.relativePath);let I=d,E=y,p=h;r&&(I=d-1,E=y.slice(1),p=h.slice(1)),c.push({entry:j,indentLevel:I,depth:d,positionInSet:w+1,setSize:v.length,parentIsLast:E}),s&&(I>f&&(f=I),i.push({id:j.absolutePath,name:j.name,absolutePath:j.absolutePath,indentLevel:I,isLastChild:m,isDirectory:S,isExpanded:C,ancestorIsLast:[...p],hideLines:r&&d===0})),S&&C&&j.children&&R(j.children,d+1,y)}};return R(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},Kt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let r=0,n=s-1,c=0;for(;r<=n;){const i=r+n>>>1;e[i]<=t?(c=i,r=i+1):n=i-1}return c},qr=(e,t,s,r,n,c)=>{const i=r?.renderStart??Math.max(0,Kt(c,n)),f=t>0?Kt(c,n+t)+s:i+s,R=e>0?Math.min(e-1,Math.max(i,f)):i,x=r?.renderEnd??R,d=e>0?Math.min(e-1,x+s):x;return{renderStart:i,renderEnd:x,lookaheadEnd:d}},Zr=(e,t,s,r,n,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),R=d=>n?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(r*.9,d*.7)):0,x=3;for(let d=0;d<e.length;d++){const h=e[d];if(h.hideLines)continue;const v=[],w=t[d]??0,j=s[d]??0,m=j+w/2,y=R(w),S=y>0?y/2+2:r/1.5;for(let E=0;E<h.indentLevel;E++){if(h.ancestorIsLast[E]??!1)continue;let W=!1;for(let _=d;_<e.length;_++){const H=e[_];if(H.indentLevel>E&&H.ancestorIsLast.length>E&&!H.ancestorIsLast[E]){W=!0;break}if(_>d&&H.indentLevel===E)break}if(W){const _=E*r+r/2+x;v.push({key:`${h.id}-ancestor-${E}`,x1:_,y1:j,x2:_,y2:j+w,itemIndex:d})}}const C=h.indentLevel*r,I=C+r/2+x;if(h.isDirectory?v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m-S,itemIndex:d}):v.push({key:`${h.id}-connector-top`,x1:I,y1:j,x2:I,y2:m,itemIndex:d}),!h.isDirectory&&h.isLastChild&&v.push({key:`${h.id}-connector-horizontal`,x1:I,y1:m,x2:C+r+x,y2:m,itemIndex:d}),h.isLastChild||(h.isDirectory?v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m+S,x2:I,y2:j+w,itemIndex:d}):v.push({key:`${h.id}-connector-bottom`,x1:I,y1:m,x2:I,y2:j+w,itemIndex:d})),i[d]=v,n&&h.isDirectory){const E=y,p=I,W=m;f[d]=[{key:`${h.id}-glyph`,itemIndex:d,centerX:p,centerY:W,size:E,isExpanded:h.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},ct=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:r,setSize:n,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:j,renderChildren:m=!0,expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E="none",selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H=!0,showDirectoryIcons:te=!0,showFileIcons:J=!0,useCanvasExpandIcons:B=!1,expandIconSize:re,typeIconSize:ne,fontSize:N,indentSize:z=Ve,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}})=>{const[se,ce]=l.useState(null),[L,ae]=l.useState(!1),k=e.children!==void 0,U=k&&w(e.absolutePath),q=e.absolutePath===I,Z=!k&&p?.has(e.absolutePath),we=k?void 0:ve(e.name)||ve(e.relativePath)||ve(e.absolutePath);l.useEffect(()=>{ce(U&&e.children?e.children:null)},[U,e.children]);const Q=Zt({entry:e,isDirectory:k,isExpanded:U,isItemSelected:!!Z,selectionMode:E,onSelectionChange:W,onEntryClick:C,toggleDirectory:y,onToggleDirectoryRecursive:S}),Ge=L?M?.hoverClassName!==void 0?M.hoverClassName:$.entryHover:"",Ie=(()=>{if(k){if(q)return M?.directorySelectedClassName!==void 0?M.directorySelectedClassName:$.entrySelected}else if(q||Z)return M?.itemSelectedClassName!==void 0?M.itemSelectedClassName:D.twMerge(q&&$.entrySelected,Z&&$.entryItemSelected);return""})(),Le=D.twMerge($.entry,Ge,Ie,V,e.className),Ue=D.twMerge($.expandIcon,(q||Z)&&$.expandIconSelected),Ce=D.twMerge($.typeIcon,(q||Z)&&$.typeIconSelected),Ne=D.twMerge($.name,fe,k&&$.nameDirectory,k&&a,!k&&T,(q||Z)&&$.nameSelected),Pe=Xt({isDirectory:k,isExpanded:U,showExpandIcons:H,useCanvasExpandIcons:B,expandIconSize:re}),Ke=(k?te:J)?Jt({entry:e,isDirectory:k,isExpanded:U,isSelected:q,isItemSelected:!!Z,extension:we,mimeType:e.mimeType},_):null,Ee={...L?M?.hoverStyle:{},...k&&q?M?.directorySelectedStyle:{},...!k&&(q||Z)?M?.itemSelectedStyle:{}},Oe=qt(e.data),De=ne?{width:ne,height:ne}:void 0,Te=N?{fontSize:typeof N=="number"?`${N}px`:N}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:Le,style:{paddingLeft:`${Math.max(0,t*z)}px`,transform:t<0?`translateX(${t*z}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*z)}px)`:void 0,height:`${d}px`,...Te,...Ee,...de,...e.style},...Oe,"data-entry-type":k?"directory":"file","data-entry-expanded":k?String(U):void 0,"data-entry-selected":q?"true":void 0,"data-entry-item-selected":Z?"true":void 0,onClick:Q,onMouseEnter:()=>ae(!0),onMouseLeave:()=>ae(!1),ref:oe=>R(i,oe),onKeyDown:oe=>{if(oe.key==="Enter"||oe.key===" "){oe.preventDefault(),Q(oe);return}x(oe,i)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":k?U:void 0,"aria-level":s+1,"aria-posinset":r,"aria-setsize":n,"aria-selected":E==="none"?void 0:c,"aria-label":`${e.name} (${k?h:v})`,children:[(H||B)&&u.jsx("span",{className:Ue,children:Pe}),(k?te:J)&&u.jsx("span",{className:Ce,style:De,children:Ke}),u.jsx("span",{className:Ne,style:{...Te,...P,...k?b:A},"data-entry-type":k?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),U&&se&&m&&u.jsx("fieldset",{children:se.map((oe,_e)=>u.jsx(ct,{entry:oe,indentLevel:t+1,depth:s+1,positionInSet:_e+1,setSize:se.length,isSelectedForAria:!!p?.has(oe.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:R,onNavigationKeyDown:x,rowHeight:d,entryKindDirectory:h,entryKindFile:v,isDirOpen:w,parentIsLast:[...j,_e===se.length-1],expansion:{toggleDirectory:y,onToggleDirectoryRecursive:S},selection:{onEntryClick:C,selectedPath:I,mode:E,selectedItems:p,onSelectionChange:W},visual:{iconOverrides:_,showExpandIcons:H,showDirectoryIcons:te,showFileIcons:J,useCanvasExpandIcons:B,expandIconSize:re,highlightStyles:M,entryClassName:V,entryStyle:de,nameClassName:fe,nameStyle:P,directoryNameClassName:a,directoryNameStyle:b,fileNameClassName:T,fileNameStyle:A}},oe.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,r=t.entry.children!==void 0,n=s&&e.isDirOpen(e.entry.absolutePath),c=r&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&n===c&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,f)=>i===t.parentIsLast[f])});ct.displayName="DirectoryEntryItem";const cr=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...cr(s)));return t},Qr=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:r,collapseMultiple:n,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:R,selectedPath:x,mode:d="none",selectedItems:h,onSelectionChange:v},visual:{className:w,style:j,ariaLabel:m,ariaLabelledBy:y,lineColor:S="#A0AEC0",showTreeLines:C=!0,showExpandIcons:I=!0,showDirectoryIcons:E=!0,showFileIcons:p=!0,iconOverrides:W,expandIconSize:_,itemHeight:H=ze,removeRootIndent:te=!1,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}={},virtualScroll:fe,grid:P,sort:a,locale:b,labels:T})=>{const A=ue.resolveVirtualScrollLocale(b),se=l.useMemo(()=>lr(b,T),[b,T]),ce=Xr(Dr(se)),{entryKindDirectory:L,entryKindFile:ae}=se,k=P!==void 0,[U,q]=l.useState(!1),Z=l.useRef(null),we=l.useRef(null),Q=l.useRef(null),[Ge,Ie]=l.useState(0),[Le,Ue]=l.useState(0),[Ce,Ne]=l.useState(0),[Pe,Ke]=l.useState(null),{overscanCount:Ee=15,className:Oe,background:De,onScroll:Te,onRangeChange:oe,initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,callbackThrottleMs:dt=5,contentInsets:ft,onItemFocus:mt,viewportHeightOverride:le,scrollBarOptions:Xe,behaviorOptions:ht,preserveScrollAnchor:pt=!1,getItemKey:ur,testId:yt,contentProps:Je}=fe??{},bt=l.useMemo(()=>k?{role:"rowgroup",...Je}:Je,[k,Je]),[Fe,gt]=l.useState(typeof Se=="number"?Se:0),qe=l.useRef(typeof Se=="number"?Se:0),xt=l.useCallback((o,g)=>{qe.current=o,gt(o),Te?.(o,g)},[Te]),vt=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:O}=o;Ke(Y=>Y&&Y.renderStart===g&&Y.renderEnd===O?Y:{renderStart:g,renderEnd:O}),oe?.(o)},[oe]);l.useEffect(()=>{q(!0),Kr()},[]),l.useEffect(()=>{const o=Z.current,g=k?we.current:o,O=()=>{if(o){const G=o.clientWidth;Ue(X=>Math.abs(X-G)>1?G:X)}if(typeof le=="number")Ie(G=>Math.abs(G-le)>1?le:G);else if(g){const G=g.clientHeight;Ie(X=>Math.abs(X-G)>1?G:X)}};if(!(o||g))return Ie(0);O();const Y=new ResizeObserver(O);return o&&Y.observe(o),g&&g!==o&&Y.observe(g),()=>Y.disconnect()},[le,k]);const ke=typeof le=="number"?le:Ge,me=l.useCallback(o=>i||(U?s(o):!1),[U,s,i]),wt=D.twMerge($.container,c&&$.containerPending,w),Et=l.useMemo(()=>({...Ur,...j??{},...typeof le=="number"?{height:le,minHeight:le}:{}}),[j,le]),Ze=l.useCallback((o,g)=>{const O=[o.absolutePath,...cr(o)],Y=g||f;if(O.every(he=>me(he)))return n(O);if(O.every(he=>!me(he))||Y==="recursive")return r(O);if(Y==="toggle")return n(O);console.warn(`[DirectoryTree] Unknown double click action: ${Y}. No action taken.`)},[me,r,n,f]),St=k?!1:te,{flatItems:be,lineItems:Qe,maxIndent:kt}=l.useMemo(()=>Jr(e,me,C,St,a),[e,me,C,St,a]),K=l.useMemo(()=>be.map((o,g)=>{const O=typeof H=="function"?H(o.entry,g):H;return{...o,rowHeight:Number.isFinite(O)&&O>0?O:ze}}),[be,H]),pe=l.useMemo(()=>K.map(o=>o.rowHeight),[K]),ge=l.useMemo(()=>{const o=new Array(pe.length+1);o[0]=0;for(let g=0;g<pe.length;g++)o[g+1]=o[g]+pe[g];return o},[pe]),Rt=l.useCallback(o=>K[o]?.rowHeight??ze,[K]),dr=l.useCallback(o=>K[o]?.entry.absolutePath??o,[K]),jt=ur??dr,It=l.useRef(be);It.current=be;const Ct=l.useRef(me);Ct.current=me;const et=l.useRef(t);et.current=t;const[Nt,Tt]=l.useState(0),tt=l.useRef(new Map),rt=l.useRef(null),_t=l.useCallback((o,g)=>{g?(tt.current.set(o,g),rt.current===o&&(rt.current=null,g.focus())):tt.current.delete(o)},[]),xe=l.useCallback(o=>{Tt(o);const g=tt.current.get(o);if(g){g.focus();return}rt.current=o,Q.current?.scrollToIndex(o)},[]);l.useEffect(()=>{Tt(o=>be.length===0?0:Math.min(o,be.length-1))},[be.length]);const At=l.useCallback((o,g)=>{const O=It.current,Y=O.length-1;if(Y<0)return;const G=O[g],X=G?.entry.children!==void 0,he=X&&Ct.current(G.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),xe(Math.min(g+1,Y));break;case"ArrowUp":o.preventDefault(),xe(Math.max(g-1,0));break;case"Home":o.preventDefault(),xe(0);break;case"End":o.preventDefault(),xe(Y);break;case"ArrowRight":o.preventDefault(),X&&!he?et.current(G.entry.absolutePath):X&&g<Y&&xe(g+1);break;case"ArrowLeft":{if(o.preventDefault(),X&&he){et.current(G.entry.absolutePath);break}const yr=G?.depth??0;for(let Be=g-1;Be>=0;Be--)if(O[Be].depth<yr){xe(Be);break}break}}},[xe]),$e=l.useMemo(()=>!C||Qe.length===0?{segmentsByItem:[],glyphsByItem:[]}:Zr(Qe,pe,ge,Ve,C,_??zt),[Qe,pe,ge,C,_]),He=l.useMemo(()=>!C||e.length===0?0:(kt+2)*Ve,[e.length,kt,C]),{renderStart:Mt,renderEnd:Lt,lookaheadEnd:Pt}=l.useMemo(()=>qr(K.length,ke,Ee,Pe,Fe,ge),[K.length,ke,Ee,Pe,Fe,ge]),nt=l.useMemo(()=>!C||He<=0||ke<=0||$e.segmentsByItem.length===0?null:u.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:u.jsx("div",{className:"absolute top-0 left-0",style:{width:He,height:ke},children:u.jsx(ir,{segmentsByItem:$e.segmentsByItem,glyphsByItem:$e.glyphsByItem,itemHeight:pe[0]??ze,width:He,viewportHeight:ke,scrollPosition:Fe,color:S,expandGlyphColor:S,expandGlyphSize:_??zt,renderStartIndex:Mt,renderEndIndex:Lt,lookaheadEndIndex:Pt})})}),[He,ke,Mt,Lt,Pt,Fe,$e,S,C,_,pe]),Ot=l.useCallback(o=>K[o],[K]),Dt=l.useRef(null);l.useLayoutEffect(()=>{const o=Dt.current;if(Dt.current={items:K,offsets:ge},!pt||!o||o.items===K)return;const g=Q.current,O=g?.getScrollPosition(),Y=typeof O=="number"&&O>=0?O:qe.current,G=$r(o.items,o.offsets,Y);if(!G)return;const X=Hr(G,K,ge);if(X===null||Math.abs(X-Y)<1)return;const he=g?g.scrollTo(X):X;qe.current=he,gt(he)},[K,ge,pt]);const ye=P?.columns,Re=P?.scrollBarWidth??Xe?.width??sr,ee=l.useMemo(()=>ye?Lr({measuredWidth:Le,columns:ye,scrollBarWidth:Re}):null,[ye,Le,Re]),We=l.useMemo(()=>ye?Mr(ye):"",[ye]),fr=l.useMemo(()=>P?.showFooter&&ye?Pr(e):[],[P?.showFooter,ye,e]),je=ee?.maxHScroll??0;l.useEffect(()=>{Ne(o=>st(o,je))},[je]);const Ft=l.useCallback(o=>Ne(g=>st(g+o,je)),[je]),$t=l.useMemo(()=>({iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J}),[W,I,E,p,C,_,J]),Ht=l.useMemo(()=>u.jsx(ue.VirtualScroll,{ref:Q,itemCount:K.length,getItem:Ot,getItemHeight:Rt,getItemKey:jt,testId:yt,contentProps:bt,locale:A,labels:ce,viewportSize:typeof le=="number"?le:void 0,overscanCount:Ee,onScroll:xt,onRangeChange:vt,className:Oe,onWheelHorizontal:k?Ft:void 0,background:u.jsxs(u.Fragment,{children:[k&&ee?u.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:ee.nameWidth},"aria-hidden":"true",children:nt}):nt,De]}),initialScrollIndex:_e,initialScrollOffset:Se,initialScrollAnchor:ut,onItemFocus:mt,callbackThrottleMs:dt,contentInsets:ft,scrollBarOptions:Xe,behaviorOptions:ht,children:(o,g)=>o?k&&P&&ee?u.jsx(tr,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!h?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:me,columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},visual:$t},o.entry.absolutePath):u.jsx(ct,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!h?.has(o.entry.absolutePath),flatIndex:g,isActive:g===Nt,registerRowRef:_t,onNavigationKeyDown:At,rowHeight:o.rowHeight,entryKindDirectory:L,entryKindFile:ae,isDirOpen:me,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Ze},selection:{onEntryClick:R,selectedPath:x??null,mode:d,selectedItems:h,onSelectionChange:v},visual:{iconOverrides:W,showExpandIcons:I,showDirectoryIcons:E,showFileIcons:p,useCanvasExpandIcons:C,expandIconSize:_,highlightStyles:J,entryClassName:B,entryStyle:re,nameClassName:ne,nameStyle:N,directoryNameClassName:z,directoryNameStyle:M,fileNameClassName:V,fileNameStyle:de}},o.entry.absolutePath):null}),[K.length,Ot,Rt,jt,yt,bt,A,ce,L,ae,Nt,_t,At,le,Ee,xt,vt,Oe,k,Ft,ee,nt,De,_e,Se,ut,mt,dt,ft,Xe,ht,P,We,me,R,x,d,h,v,t,Ze,$t,W,I,E,p,C,_,J,B,re,ne,N,z,M,V,de]);if(!(P&&ee))return u.jsx("div",{ref:Z,className:wt,style:Et,role:"tree","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,children:Ht});const mr=P.showHeader??!0,hr=P.showFooter??!1,pr={...Et,"--dt-hscroll":`${Ce}px`};return u.jsxs("div",{ref:Z,className:D.twMerge(wt,"dt-grid"),style:pr,role:"treegrid","aria-label":y?void 0:m,"aria-labelledby":y,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":K.length+(P.showHeader??!0?1:0),children:[mr&&u.jsx("div",{role:"rowgroup",children:u.jsx(Tr,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,className:P.headerClassName})}),u.jsx("div",{ref:we,className:"dt-grid-body",children:Ht}),je>0&&u.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ee.nameWidth},"aria-hidden":"true"}),u.jsx(ue.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:Ce,scrollBarWidth:Re,locale:A,labels:ce,onScroll:o=>{const g=typeof o=="function"?o(Ce):o,O=st(g,je);return Ne(O),O}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Re},"aria-hidden":"true"})]}),hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(_r,{columns:P.columns,numericTemplate:We,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Re,allEntries:fr,className:P.footerClassName})})]})},en=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,r]=l.useTransition(),[n,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const y=JSON.parse(m);return new Set(y)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),i=l.useCallback(m=>{r(()=>{c(y=>{const S=new Set(y);return m(S),S})})},[]),f=l.useCallback((m,y)=>{i(S=>{for(const C of m)y(S,C)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(n)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[n,t]);const R=l.useCallback(m=>{f([m],(y,S)=>{y.has(S)?y.delete(S):y.add(S)})},[f]),x=l.useCallback(m=>{f([m],(y,S)=>{y.add(S)})},[f]),d=l.useCallback(m=>{f([m],(y,S)=>{y.delete(S)})},[f]),h=l.useCallback(m=>{f(m,(y,S)=>{y.delete(S)})},[f]),v=l.useCallback(m=>{f(m,(y,S)=>{y.add(S)})},[f]),w=l.useCallback(()=>{i(m=>{m.clear()})},[i]),j=l.useCallback(m=>n.has(m),[n]);return{expanded:n,toggle:R,expand:x,collapse:d,collapseMultiple:h,expandMultiple:v,collapseAll:w,isExpanded:j,isPending:s}};exports.DIRECTORY_TREE_LABEL_CATALOGS=or;exports.DIRECTORY_TREE_LABEL_KEYS=lt;exports.DirectoryTree=Qr;exports.directoryTreeClasses=$;exports.resolveDirectoryTreeLabels=lr;exports.useDirectoryTreeState=en;
|
|
6
|
+
<%s key={someKey} {...props} />`,T,A,Q,A),P[A+T]=!0)}if(A=null,w!==void 0&&(r(w),A=""+w),i(p)&&(r(p.key),A=""+p.key),"key"in p){w={};for(var he in p)he!=="key"&&(w[he]=p[he])}else w=p;return A&&f(w,typeof o=="function"?o.displayName||o.name||"Unknown":o),S(o,A,w,s(),se,ie)}function b(o){k(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===U&&(o._payload.status==="fulfilled"?k(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function k(o){return typeof o=="object"&&o!==null&&o.$$typeof===N}var E=l,N=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),C=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),Z=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,te=Array.isArray,B=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(o){return o()}};var me,le={},ce=E.react_stack_bottom_frame.bind(E,c)(),Y=B(n(c)),P={};Ye.Fragment=v,Ye.jsx=function(o,p,w){var T=1e4>Z.recentlyCreatedOwnerStacks++;return m(o,p,w,!1,T?Error("react-stack-top-frame"):ce,T?B(n(o)):Y)},Ye.jsxs=function(o,p,w){var T=1e4>Z.recentlyCreatedOwnerStacks++;return m(o,p,w,!0,T?Error("react-stack-top-frame"):ce,T?B(n(o)):Y)}})()),Ye}var fr;function Kr(){return fr||(fr=1,process.env.NODE_ENV==="production"?at.exports=Vr():at.exports=Ur()),at.exports}var u=Kr();function Xr({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const Jr=fe.forwardRef(Xr);function qr({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Zr=fe.forwardRef(qr);function Qr({title:e,titleId:t,...r},n){return fe.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?fe.createElement("title",{id:t},e):null,fe.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const en=fe.forwardRef(Qr),lt=18,ct=12,mr=8,D={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:M.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:M.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:M.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:M.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:M.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:M.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:M.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:M.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:M.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},je=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,r=t.lastIndexOf(".");return r<=0?"":t.slice(r+1).toLowerCase()},xr=({isDirectory:e,isExpanded:t,showExpandIcons:r,useCanvasExpandIcons:n,expandIconSize:s})=>{const c=s?{width:s,height:s}:void 0,i=s?"":"h-4 w-4";return!(r&&e)||n?u.jsx("span",{className:i,style:c,"aria-hidden":"true"}):t?u.jsx(Jr,{className:i,style:c}):u.jsx(Zr,{className:i,style:c})},Ct=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(s=>Ct(s,t)).filter(Boolean);return n.length?n:null}const r=e.type;if(r&&r.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},tn=(e,t,r)=>{const n=(t||(r?je(r):"")).toLowerCase(),s=(e||"").toLowerCase();if(s&&s!=="application/octet-stream"){if(s==="text/markdown"||s==="text/x-markdown")return u.jsx(O.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(s==="application/pdf")return u.jsx(O.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(s.includes("excel")||s.includes("spreadsheet")||s.includes("google-apps.spreadsheet"))return u.jsx(O.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(s==="text/csv"||s==="text/tab-separated-values")return u.jsx(O.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(s.includes("word")||s.includes("msword")||s.includes("wordprocessingml")||s.includes("google-apps.document")||s==="application/rtf")return u.jsx(O.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(s.includes("powerpoint")||s.includes("presentation")||s.includes("google-apps.presentation"))return u.jsx(O.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(s.startsWith("image/"))return u.jsx(O.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(s.startsWith("audio/"))return u.jsx(O.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(s.startsWith("video/"))return u.jsx(O.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(s.includes("zip")||s.includes("tar")||s.includes("compressed")||s.includes("archive"))return u.jsx(O.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(s==="application/json"||s.includes("javascript")||s.includes("typescript")||s.includes("xml")||s.startsWith("text/html")||s.startsWith("text/css")||s.includes("x-python")||s.includes("x-sh")||s.includes("x-go")||s.includes("x-rust"))return u.jsx(O.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(s.startsWith("text/"))return u.jsx(O.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return u.jsx(O.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return u.jsx(O.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return u.jsx(O.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return u.jsx(O.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return u.jsx(O.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return u.jsx(O.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(n))return u.jsx(O.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"].includes(n))return u.jsx(O.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return u.jsx(O.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return u.jsx(O.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return u.jsx(O.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return u.jsx(O.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return u.jsx(O.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Sr=(e,t)=>{const{entry:r,isDirectory:n,isExpanded:s,extension:c,mimeType:i}=e;let f;const j=i||r.mimeType;return r.icon!==void 0?f=r.icon:n?f=s&&t?.directoryExpanded||t?.directory||u.jsx(en,{className:"h-4 w-4"}):c&&t?.fileByExtension?.[c]?f=t.fileByExtension[c]:f=t?.file||tn(j,c,r.name),Ct(typeof f=="function"?f(e):f,r.absolutePath)},rn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Er=e=>{if(!e)return;const t=Object.entries(e).filter(([,r])=>r!=null);if(t.length!==0)return Object.fromEntries(t.map(([r,n])=>[`data-${rn(r)}`,String(n)]))},nn=500,kr=({entry:e,isDirectory:t,isExpanded:r,isItemSelected:n,selectionMode:s,onSelectionChange:c,onEntryClick:i,toggleDirectory:f,onToggleDirectoryRecursive:j})=>{const S=l.useRef(null);return l.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]),l.useCallback(m=>{m.stopPropagation(),s!=="none"&&!t&&c&&c(e,!n);let b=!1;i({entry:e,isDirectory:t,isExpanded:r,preventDefault:()=>{b=!0}}),!(!t||b)&&(S.current?(window.clearTimeout(S.current),S.current=null,j(e)):S.current=window.setTimeout(()=>{f(e.absolutePath),S.current=null},nn))},[t,e,r,j,f,i,s,c,n])},Rr=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",hr=(e,t)=>e.children!==void 0&&t(e.absolutePath),Cr=(e,t)=>({width:e,gridTemplateColumns:t}),Ir=l.memo(({entry:e,indentLevel:t,positionInSet:r,setSize:n,rowIndex:s,flatIndex:c,onRowFocus:i,onRowBlur:f,isSelectedForAria:j,rowHeight:S,isDirOpen:m,columns:b,numericTemplate:k,numericTotal:E,nameWidth:N,rowClassName:h,selection:{onEntryClick:v,selectedPath:R,currentPath:$,mode:x="none",selectedItems:C,onSelectionChange:y},expansion:{toggleDirectory:W,onToggleDirectoryRecursive:F},visual:{iconOverrides:_,showExpandIcons:U=!0,showDirectoryIcons:ae=!0,showFileIcons:J=!0,useCanvasExpandIcons:Z=!1,expandIconSize:ne,indentSize:te=ct,highlightStyles:B,expandIconClassName:me,expandIconStyle:le}})=>{const[ce,Y]=l.useState(!1),P=e.children!==void 0,o=P&&m(e.absolutePath),p=e.absolutePath===R,w=e.absolutePath===$,T=!P&&!!C?.has(e.absolutePath),se=P?void 0:je(e.name)||je(e.relativePath)||je(e.absolutePath),ie=kr({entry:e,isDirectory:P,isExpanded:o,isItemSelected:T,selectionMode:x,onSelectionChange:y,onEntryClick:v,toggleDirectory:W,onToggleDirectoryRecursive:F}),A=ce?B?.hoverClassName!==void 0?B.hoverClassName:D.entryHover:"",Q=(()=>{if(P){if(p)return B?.directorySelectedClassName!==void 0?B.directorySelectedClassName:D.entrySelected}else if(p||T)return B?.itemSelectedClassName!==void 0?B.itemSelectedClassName:M.twMerge(p&&D.entrySelected,T&&D.entryItemSelected);return""})(),he=typeof h=="function"?h(e):h,ue=M.twMerge("dt-grid-row cursor-pointer select-none",A,Q,he,e.className),Te=M.twMerge(D.expandIcon,me,(p||T)&&D.expandIconSelected),Ee=M.twMerge(D.typeIcon,(p||T)&&D.typeIconSelected),re=M.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",P&&D.nameDirectory,(p||T)&&D.nameSelected),L=xr({isDirectory:P,isExpanded:o,showExpandIcons:U,useCanvasExpandIcons:Z,expandIconSize:ne}),de=(P?ae:J)?Sr({entry:e,isDirectory:P,isExpanded:o,isSelected:p,isItemSelected:T,extension:se,mimeType:e.mimeType},_):null,K={indentLevel:t,isDirectory:P,isExpanded:o},[ve,...V]=b,Oe=ve?.render?ve.render(e,K):e.label??e.name,ke={...ce?B?.hoverStyle:{},...P&&p?B?.directorySelectedStyle:{},...!P&&(p||T)?B?.itemSelectedStyle:{}};return u.jsxs("div",{className:ue,style:{height:S,...ke,...e.style},role:"row","aria-expanded":P?o:void 0,"aria-level":t+1,"aria-posinset":r,"aria-setsize":n,"aria-rowindex":s,"aria-selected":x==="none"?void 0:j,"aria-current":w?"page":void 0,...Er(e.data),"data-entry-type":P?"directory":"file","data-entry-expanded":P?String(o):void 0,"data-entry-selected":p?"true":void 0,"data-entry-item-selected":T?"true":void 0,onClick:ie,onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),onFocus:z=>i(c,e.absolutePath,z.currentTarget),onBlur:z=>f(e.absolutePath,z.currentTarget),onKeyDown:z=>{if(z.key==="Enter"){if(z.repeat){z.preventDefault();return}ie(z)}},tabIndex:0,children:[u.jsxs("div",{className:M.twMerge("dt-grid-name-cell",ve?.className),role:"gridcell",style:{width:N,paddingLeft:Math.max(0,t*te)},children:[(U||Z)&&u.jsx("span",{className:Te,style:le,children:L}),(P?ae:J)&&u.jsx("span",{className:Ee,children:de}),u.jsx("span",{className:re,children:Oe})]}),V.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:Cr(E,k),children:V.map(z=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(z.align),z.className),role:"gridcell",children:z.render?z.render(e,K):null},z.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const r=hr(e.entry,e.isDirOpen),n=hr(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.flatIndex===t.flatIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&r===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Ir.displayName="DirectoryTreeGridRow";const jr=({kind:e,columns:t,numericTemplate:r,numericTotal:n,nameWidth:s,scrollBarWidth:c,className:i,nameContent:f,renderCell:j})=>{const[,...S]=t,m=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",b=e==="header"?"dt-grid-header":"dt-grid-footer",k=e==="header"?"columnheader":"gridcell";return u.jsxs("div",{className:M.twMerge(b,"text-gray-600 dark:text-gray-300",i),role:"row",children:[u.jsx("div",{className:M.twMerge(m,"px-1",t[0]?.className),role:k,style:{width:s},children:f}),S.length>0&&u.jsx("div",{className:"dt-grid-numeric-viewport",children:u.jsx("div",{className:"dt-grid-numeric-track",style:Cr(n,r),children:S.map(E=>u.jsx("div",{className:M.twMerge("dt-grid-cell",Rr(E.align),E.className),role:k,children:j(E)},E.key))})}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:c},"aria-hidden":"true"})]})},sn=({columns:e,className:t,...r})=>u.jsx(jr,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...r}),pr=(e,t)=>typeof e=="function"?e(t):e??null,on=({columns:e,allEntries:t,className:r,...n})=>u.jsx(jr,{kind:"footer",columns:e,className:r,nameContent:pr(e[0]?.footer,t),renderCell:s=>pr(s.footer,t),...n}),an=240,Tr=96,Nr=12,It=(e,t)=>{const r=e?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:t},ln=e=>e.slice(1).map(t=>`${It(t,Tr)}px`).join(" "),cn=({measuredWidth:e,columns:t,scrollBarWidth:r=Nr})=>{const n=It(t[0],an),s=t.slice(1).reduce((j,S)=>j+It(S,Tr),0),c=Number.isFinite(e)&&e>0?e:0,i=Math.max(0,c-n-Math.max(0,r)),f=Math.max(0,s-i);return{nameWidth:n,numericTotal:s,numericVisible:i,maxHScroll:f}},Rt=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,un=e=>{const t=[],r=n=>{for(const s of n)t.push(s),s.children&&s.children.length>0&&r(s.children)};return r(e),t},Pr=["entryKindDirectory","entryKindFile"],jt=[...pe.VIRTUAL_SCROLL_LABEL_KEYS,...Pr],Tt=Object.freeze({en:Object.freeze({entryKindDirectory:"directory",entryKindFile:"file"}),ja:Object.freeze({entryKindDirectory:"ディレクトリ",entryKindFile:"ファイル"})}),_r=Object.freeze({en:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Tt.en}),ja:Object.freeze({...pe.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Tt.ja})}),br=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,dn=e=>{const t={};let r=!1;for(const n of pe.VIRTUAL_SCROLL_LABEL_KEYS){const s=Object.hasOwn(e,n)?e[n]:void 0;s!==void 0&&(t[n]=s,r=!0)}return r?t:void 0},Ar=(e,t)=>{const r=pe.resolveVirtualScrollLocale(e);if(t===void 0)return _r[r];if(t===null||typeof t!="object")throw new RangeError(`[directory-tree] labels must be an object; got ${br(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[directory-tree] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);for(const i of Object.keys(t))if(!jt.includes(i))throw new RangeError(`[directory-tree] labels.${i} is not a known label key; expected one of ${jt.join(", ")}`);const c={...pe.resolveVirtualScrollLabels(r,dn(t)),...Tt[r]};for(const i of Pr){const f=Object.hasOwn(t,i)?t[i]:void 0;if(f!==void 0){if(typeof f!="string"||f.trim()==="")throw new RangeError(`[directory-tree] labels.${i} must be a non-blank string; got ${br(f)}`);c[i]=f}}return Object.freeze(c)},fn=e=>{const t={};for(const r of pe.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},mn=()=>{let e=null;return{mark:t=>{const r=t.composedPath();e=r,setTimeout(()=>{e===r&&(e=null)},0)},landedOn:t=>e?.includes(t)===!0}},hn=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,s=r-1,c=0;for(;n<=s;){const i=n+s>>>1;e[i]<=t?(c=i,n=i+1):s=i-1}return c},pn=(e,t,r)=>{if(r<=0||e.length===0||t.length!==e.length+1)return null;const n=hn(t,r),s=e[n];return s?{path:s.entry.absolutePath,offsetInViewport:r-t[n]}:null},bn=(e,t,r)=>{if(t.length===0||r.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,r[n]+e.offsetInViewport);return null},yn=(e,t,r)=>{const n=[];for(let s=t;s<r;s++){const c=e[s];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},gn=(e,t,r)=>{const n=[];for(let s=t;s<r;s++){const c=e[s];if(!(!c||c.length===0))for(const i of c)n.push(i)}return n},wn=(e,t,r,n)=>{const s=Math.max(1,Math.floor(t*n)),c=Math.max(1,Math.floor(r*n));(e.width!==s||e.height!==c)&&(e.width=s,e.height=c);const i=e.style;i.width!==`${t}px`&&(i.width=`${t}px`),i.height!==`${r}px`&&(i.height=`${r}px`)},vn=(e,t,r)=>{e.lineWidth=r,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},xn=(e,t)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!r)return null;let n=r[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const s=Number.parseInt(n.slice(0,2),16),c=Number.parseInt(n.slice(2,4),16),i=Number.parseInt(n.slice(4,6),16);return`rgba(${s}, ${c}, ${i}, ${t})`},Sn=(e,t,r,n)=>{if(t.length===0)return;const s=xn(r,.14),c=e.strokeStyle,i=e.fillStyle,f=e.lineWidth,j=e.lineCap,S=e.lineJoin;e.strokeStyle=r,e.lineCap="round",e.lineJoin="round";for(const m of t){const b=n??m.size,k=Math.max(0,b/2),E=Math.max(1,Math.round(b*.08)),N=Math.max(1,Math.round(b*.14)),h=Math.max(0,k-E*.8),v=Math.max(0,h*.55);s&&(e.fillStyle=s,e.beginPath(),e.arc(m.centerX,m.centerY,h,0,Math.PI*2),e.fill()),e.lineWidth=E,e.beginPath(),e.arc(m.centerX,m.centerY,Math.max(0,k-E*.3),0,Math.PI*2),e.stroke(),e.lineWidth=N,e.beginPath(),e.moveTo(m.centerX-v,m.centerY),e.lineTo(m.centerX+v,m.centerY),e.stroke(),m.isExpanded||(e.beginPath(),e.moveTo(m.centerX,m.centerY-v),e.lineTo(m.centerX,m.centerY+v),e.stroke())}e.strokeStyle=c,e.fillStyle=i,e.lineWidth=f,e.lineCap=j,e.lineJoin=S},Mr=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i="#a0aec0",strokeWidth:f=1,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E})=>{const N=l.useRef(null),h=l.useRef(null),v=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E}),R=l.useCallback(()=>{h.current=null;const x=N.current;if(!x)return;const C=x.getContext("2d");if(!C)return;const y=v.current;if(y.width<=0||y.viewportHeight<=0){C.clearRect(0,0,x.width,x.height);return}const W=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;wn(x,y.width,y.viewportHeight,W);const F=y.segmentsByItem.length,_=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),U=Math.min(F,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ae=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const te=Math.floor(y.renderEndIndex);return Math.max(Math.min(F,te+1),_)}return Math.max(U,_)})(),J=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const te=Math.floor(y.lookaheadEndIndex),B=Math.min(F,te+1);return Math.max(B,ae)}return Math.max(U,ae)})(),Z=yn(y.segmentsByItem,_,J),ne=gn(y.glyphsByItem,_,J);C.save(),C.scale(W,W),C.clearRect(0,0,y.width,y.viewportHeight),C.translate(0,-y.scrollPosition),C.strokeStyle=y.color,vn(C,Z,y.strokeWidth),Sn(C,ne,y.expandGlyphColor??y.color,y.expandGlyphSize),C.restore()},[]),$=l.useCallback(()=>{h.current===null&&(h.current=window.requestAnimationFrame(R))},[R]);return l.useEffect(()=>{v.current={segmentsByItem:e,glyphsByItem:t,itemHeight:r,width:n,viewportHeight:s,scrollPosition:c,color:i,strokeWidth:f,renderStartIndex:j,renderEndIndex:S,lookaheadEndIndex:m,devicePixelRatio:b,expandGlyphColor:k,expandGlyphSize:E},$()},[e,t,r,n,s,c,i,f,j,S,m,b,k,E,$]),l.useEffect(()=>()=>{h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),u.jsx("canvas",{ref:N,className:"pointer-events-none absolute top-0 left-0 z-0"})});Mr.displayName="TreeLineCanvas";const En=e=>{const t=new Map;for(let r=0;r<e.length;r++){const n=e[r].entry.absolutePath;t.has(n)||t.set(n,r)}return t},yr=(e,t)=>e.selectedPath===t?e:{selectedPath:t,selectionGeneration:e.selectionGeneration+1,anchor:e.anchor},kn=(e,t)=>({...e,anchor:{path:t,selectionGeneration:e.selectionGeneration,focused:!0}}),Rn=(e,t)=>{const{anchor:r,selectionGeneration:n,selectedPath:s}=t;if(r!==null&&(r.focused||r.selectionGeneration===n)){const c=e.get(r.path);if(c!==void 0)return c}if(s!==null){const c=e.get(s);if(c!==void 0)return c}return 0},Cn={msOverflowStyle:"none",scrollbarWidth:"none"},In=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},jn=e=>{const t=l.useRef(null),r=t.current;return r!==null&&pe.VIRTUAL_SCROLL_LABEL_KEYS.every(n=>r[n]===e[n])?r:(t.current=e,e)},gr=new Set(["top","bottom","center","nearest"]),wr=e=>{const t=e?.align;if(t===void 0)return"top";if(!gr.has(t))throw new RangeError(`[directory-tree] Unsupported scroll alignment ${JSON.stringify(t)}; expected one of ${[...gr].join(", ")}.`);return t},Tn={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},Nn=(e,t,r,n,s)=>{const c=[],i=[];let f=0;const j=(S,m,b)=>{const k=s?[...S].sort(s):S;for(let E=0;E<k.length;E++){const N=k[E],h=E===k.length-1,v=[...b,h],R=N.children!==void 0,$=R&&t(N.absolutePath,N.relativePath);let x=m,C=v,y=b;n&&(x=m-1,C=v.slice(1),y=b.slice(1)),c.push({entry:N,indentLevel:x,depth:m,positionInSet:E+1,setSize:k.length,parentIsLast:C}),r&&(x>f&&(f=x),i.push({id:N.absolutePath,name:N.name,absolutePath:N.absolutePath,indentLevel:x,isLastChild:h,isDirectory:R,isExpanded:$,ancestorIsLast:[...y],hideLines:n&&m===0})),R&&$&&N.children&&j(N.children,m+1,v)}};return j(e,0,[]),{flatItems:c,lineItems:i,maxIndent:f}},vr=(e,t)=>{const r=e.length-1;if(r<=0)return 0;let n=0,s=r-1,c=0;for(;n<=s;){const i=n+s>>>1;e[i]<=t?(c=i,n=i+1):s=i-1}return c},Pn=(e,t,r,n,s,c)=>{const i=n?.renderStart??Math.max(0,vr(c,s)),f=t>0?vr(c,s+t)+r:i+r,j=e>0?Math.min(e-1,Math.max(i,f)):i,S=n?.renderEnd??j,m=e>0?Math.min(e-1,S+r):S;return{renderStart:i,renderEnd:S,lookaheadEnd:m}},_n=(e,t,r,n,s,c)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const i=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),j=m=>s?typeof c=="number"&&Number.isFinite(c)&&c>0?c:Math.max(8,Math.min(n*.9,m*.7)):0,S=3;for(let m=0;m<e.length;m++){const b=e[m];if(b.hideLines)continue;const k=[],E=t[m]??0,N=r[m]??0,h=N+E/2,v=j(E),R=v>0?v/2+2:n/1.5;for(let C=0;C<b.indentLevel;C++){if(b.ancestorIsLast[C]??!1)continue;let W=!1;for(let F=m;F<e.length;F++){const _=e[F];if(_.indentLevel>C&&_.ancestorIsLast.length>C&&!_.ancestorIsLast[C]){W=!0;break}if(F>m&&_.indentLevel===C)break}if(W){const F=C*n+n/2+S;k.push({key:`${b.id}-ancestor-${C}`,x1:F,y1:N,x2:F,y2:N+E,itemIndex:m})}}const $=b.indentLevel*n,x=$+n/2+S;if(b.isDirectory?k.push({key:`${b.id}-connector-top`,x1:x,y1:N,x2:x,y2:h-R,itemIndex:m}):k.push({key:`${b.id}-connector-top`,x1:x,y1:N,x2:x,y2:h,itemIndex:m}),!b.isDirectory&&b.isLastChild&&k.push({key:`${b.id}-connector-horizontal`,x1:x,y1:h,x2:$+n+S,y2:h,itemIndex:m}),b.isLastChild||(b.isDirectory?k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h+R,x2:x,y2:N+E,itemIndex:m}):k.push({key:`${b.id}-connector-bottom`,x1:x,y1:h,x2:x,y2:N+E,itemIndex:m})),i[m]=k,s&&b.isDirectory){const C=v,y=x,W=h;f[m]=[{key:`${b.id}-glyph`,itemIndex:m,centerX:y,centerY:W,size:C,isExpanded:b.isExpanded}]}}return{segmentsByItem:i,glyphsByItem:f}},Nt=l.memo(({entry:e,indentLevel:t,depth:r,positionInSet:n,setSize:s,isSelectedForAria:c,flatIndex:i,isActive:f,registerRowRef:j,onNavigationKeyDown:S,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:E,entryKindFile:N,isDirOpen:h,parentIsLast:v,renderChildren:R=!0,expansion:{toggleDirectory:$,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:y,currentPath:W,mode:F="none",selectedItems:_,onSelectionChange:U},visual:{iconOverrides:ae,showExpandIcons:J=!0,showDirectoryIcons:Z=!0,showFileIcons:ne=!0,useCanvasExpandIcons:te=!1,expandIconSize:B,typeIconSize:me,fontSize:le,indentSize:ce=ct,highlightStyles:Y,entryClassName:P,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:he}})=>{const[ue,Te]=l.useState(null),[Ee,re]=l.useState(!1),L=e.children!==void 0,de=L&&h(e.absolutePath),K=e.absolutePath===y,ve=e.absolutePath===W,V=!L&&_?.has(e.absolutePath),Oe=l.useCallback(G=>j(i,G),[j,i]),ke=L?void 0:je(e.name)||je(e.relativePath)||je(e.absolutePath);l.useEffect(()=>{Te(de&&e.children?e.children:null)},[de,e.children]);const z=kr({entry:e,isDirectory:L,isExpanded:de,isItemSelected:!!V,selectionMode:F,onSelectionChange:U,onEntryClick:C,toggleDirectory:$,onToggleDirectoryRecursive:x}),it=Ee?Y?.hoverClassName!==void 0?Y.hoverClassName:D.entryHover:"",De=(()=>{if(L){if(K)return Y?.directorySelectedClassName!==void 0?Y.directorySelectedClassName:D.entrySelected}else if(K||V)return Y?.itemSelectedClassName!==void 0?Y.itemSelectedClassName:M.twMerge(K&&D.entrySelected,V&&D.entryItemSelected);return""})(),Fe=M.twMerge(D.entry,it,De,P,e.className),Ge=M.twMerge(D.expandIcon,Q,(K||V)&&D.expandIconSelected),ut=M.twMerge(D.typeIcon,(K||V)&&D.typeIconSelected),Ne=M.twMerge(D.name,p,L&&D.nameDirectory,L&&T,!L&&ie,(K||V)&&D.nameSelected),Ve=xr({isDirectory:L,isExpanded:de,showExpandIcons:J,useCanvasExpandIcons:te,expandIconSize:B}),Ue=(L?Z:ne)?Sr({entry:e,isDirectory:L,isExpanded:de,isSelected:K,isItemSelected:!!V,extension:ke,mimeType:e.mimeType},ae):null,Ke={...Ee?Y?.hoverStyle:{},...L&&K?Y?.directorySelectedStyle:{},...!L&&(K||V)?Y?.itemSelectedStyle:{}},Xe=Er(e.data),Je=me?{width:me,height:me}:void 0,$e=le?{fontSize:typeof le=="number"?`${le}px`:le}:void 0;return u.jsxs(l.Fragment,{children:[u.jsxs("div",{className:Fe,style:{paddingLeft:`${Math.max(0,t*ce)}px`,transform:t<0?`translateX(${t*ce}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*ce)}px)`:void 0,height:`${k}px`,...$e,...Ke,...o,...e.style},...Xe,"data-entry-type":L?"directory":"file","data-entry-expanded":L?String(de):void 0,"data-entry-selected":K?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:z,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!1),onFocus:G=>m(i,e.absolutePath,G.currentTarget),onBlur:G=>b(e.absolutePath,G.currentTarget),ref:Oe,onKeyDown:G=>{if(G.key==="Enter"||G.key===" "){G.preventDefault(),G.repeat||z(G);return}S(G,i)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":L?de:void 0,"aria-level":r+1,"aria-posinset":n,"aria-setsize":s,"aria-selected":F==="none"?void 0:c,"aria-current":ve?"page":void 0,"aria-label":`${e.name} (${L?E:N})`,children:[(J||te)&&u.jsx("span",{className:Ge,style:he,children:Ve}),(L?Z:ne)&&u.jsx("span",{className:ut,style:Je,children:Ue}),u.jsx("span",{className:Ne,style:{...$e,...w,...L?se:A},"data-entry-type":L?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),de&&ue&&R&&u.jsx("fieldset",{children:ue.map((G,ye)=>u.jsx(Nt,{entry:G,indentLevel:t+1,depth:r+1,positionInSet:ye+1,setSize:ue.length,isSelectedForAria:!!_?.has(G.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:j,onNavigationKeyDown:S,onRowFocus:m,onRowBlur:b,rowHeight:k,entryKindDirectory:E,entryKindFile:N,isDirOpen:h,parentIsLast:[...v,ye===ue.length-1],expansion:{toggleDirectory:$,onToggleDirectoryRecursive:x},selection:{onEntryClick:C,selectedPath:y,currentPath:W,mode:F,selectedItems:_,onSelectionChange:U},visual:{iconOverrides:ae,showExpandIcons:J,showDirectoryIcons:Z,showFileIcons:ne,useCanvasExpandIcons:te,expandIconSize:B,highlightStyles:Y,entryClassName:P,entryStyle:o,nameClassName:p,nameStyle:w,directoryNameClassName:T,directoryNameStyle:se,fileNameClassName:ie,fileNameStyle:A,expandIconClassName:Q,expandIconStyle:he}},G.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const r=e.entry.children!==void 0,n=t.entry.children!==void 0,s=r&&e.isDirOpen(e.entry.absolutePath),c=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&e.entryKindDirectory===t.entryKindDirectory&&e.entryKindFile===t.entryKindFile&&s===c&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.currentPath===t.selection.currentPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.visual.expandIconClassName===t.visual.expandIconClassName&&e.visual.expandIconStyle===t.visual.expandIconStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((i,f)=>i===t.parentIsLast[f])});Nt.displayName="DirectoryEntryItem";const Lr=e=>{const t=[];if(e.children)for(const r of e.children)r.type==="directory"&&(t.push(r.absolutePath),t.push(...Lr(r)));return t},An=({entries:e,expansion:{toggle:t,isExpanded:r,expandMultiple:n,collapseMultiple:s,isPending:c,alwaysExpanded:i=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:j,selectedPath:S,currentPath:m,mode:b="none",selectedItems:k,onSelectionChange:E},visual:{className:N,style:h,ariaLabel:v,ariaLabelledBy:R,lineColor:$="#A0AEC0",showTreeLines:x=!0,showExpandIcons:C=!0,showDirectoryIcons:y=!0,showFileIcons:W=!0,iconOverrides:F,expandIconSize:_,itemHeight:U=lt,removeRootIndent:ae=!1,highlightStyles:J,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:B,directoryNameClassName:me,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:P,expandIconStyle:o}={},virtualScroll:p,grid:w,sort:T,locale:se,labels:ie,ref:A})=>{const Q=pe.resolveVirtualScrollLocale(se),he=l.useMemo(()=>Ar(se,ie),[se,ie]),ue=jn(fn(he)),{entryKindDirectory:Te,entryKindFile:Ee}=he,re=w!==void 0,[L,de]=l.useState(!1),K=l.useRef(null),ve=l.useRef(null),V=l.useRef(null),[Oe,ke]=l.useState(0),[z,it]=l.useState(0),[De,Fe]=l.useState(0),[Ge,ut]=l.useState(null),{overscanCount:Ne=15,className:Ve,background:Ue,onScroll:Ke,onRangeChange:Xe,onScrollAdjust:Je,liveRegion:$e,initialScrollIndex:G,initialScrollOffset:ye,initialScrollAnchor:Pt,callbackThrottleMs:_t=5,contentInsets:At,onItemFocus:Mt,viewportHeightOverride:oe,scrollBarOptions:dt,behaviorOptions:Lt,preserveScrollAnchor:Ot=!1,getItemKey:Or,testId:Dt,contentProps:ft}=p??{},Ft=l.useMemo(()=>re?{...ft,role:"rowgroup"}:{...ft,role:"tree","aria-label":R?void 0:v,"aria-labelledby":R,"aria-multiselectable":b==="multiple"?!0:void 0},[re,ft,v,R,b]),$t=l.useMemo(()=>({...Lt,enableKeyboardNavigation:!1}),[Lt]),[qe,Bt]=l.useState(typeof ye=="number"?ye:0),mt=l.useRef(typeof ye=="number"?ye:0),Ht=l.useCallback((a,d)=>{mt.current=a,Bt(a),Ke?.(a,d)},[Ke]),Wt=l.useCallback(a=>{const{renderingStartIndex:d,renderingEndIndex:g}=a;ut(I=>I&&I.renderStart===d&&I.renderEnd===g?I:{renderStart:d,renderEnd:g}),Xe?.(a)},[Xe]);l.useEffect(()=>{de(!0),In()},[]),l.useEffect(()=>{const a=K.current,d=re?ve.current:a,g=()=>{if(a){const H=a.clientWidth;it(q=>Math.abs(q-H)>1?H:q)}if(typeof oe=="number")ke(H=>Math.abs(H-oe)>1?oe:H);else if(d){const H=d.clientHeight;ke(q=>Math.abs(q-H)>1?H:q)}};if(!(a||d))return ke(0);g();const I=new ResizeObserver(g);return a&&I.observe(a),d&&d!==a&&I.observe(d),()=>I.disconnect()},[oe,re]);const Pe=typeof oe=="number"?oe:Oe,be=l.useCallback(a=>i||(L?r(a):!1),[L,r,i]),zt=M.twMerge(D.container,c&&D.containerPending,N),Yt=l.useMemo(()=>({...Cn,...h??{},...typeof oe=="number"?{height:oe,minHeight:oe}:{}}),[h,oe]),ht=l.useCallback((a,d)=>{const g=[a.absolutePath,...Lr(a)],I=d||f;if(g.every(we=>be(we)))return s(g);if(g.every(we=>!be(we))||I==="recursive")return n(g);if(I==="toggle")return s(g);console.warn(`[DirectoryTree] Unknown double click action: ${I}. No action taken.`)},[be,n,s,f]),Gt=re?!1:ae,{flatItems:Re,lineItems:pt,maxIndent:Vt}=l.useMemo(()=>Nn(e,be,x,Gt,T),[e,be,x,Gt,T]),X=l.useMemo(()=>Re.map((a,d)=>{const g=typeof U=="function"?U(a.entry,d):U;return{...a,rowHeight:Number.isFinite(g)&&g>0?g:lt}}),[Re,U]),xe=l.useMemo(()=>X.map(a=>a.rowHeight),[X]),Ce=l.useMemo(()=>{const a=new Array(xe.length+1);a[0]=0;for(let d=0;d<xe.length;d++)a[d+1]=a[d]+xe[d];return a},[xe]),Ut=l.useCallback(a=>X[a]?.rowHeight??lt,[X]),Dr=l.useCallback(a=>X[a]?.entry.absolutePath??a,[X]),Kt=Or??Dr,_e=S??null,bt=m??null,[Xt,Be]=l.useState(()=>({selectedPath:_e,selectionGeneration:0,anchor:null})),yt=yr(Xt,_e);yt!==Xt&&Be(a=>yr(a,_e));const Ze=l.useMemo(()=>En(Re),[Re]),Ae=l.useMemo(()=>Rn(Ze,yt),[Ze,yt]),He=l.useRef(new Map),Qe=l.useRef(null),[et]=l.useState(mn),We=l.useRef(null),[Fr,Jt]=l.useState(!0),gt=l.useRef(Re);gt.current=Re;const qt=l.useRef(be);qt.current=be;const wt=l.useRef(t);wt.current=t;const Zt=l.useRef(Ze);Zt.current=Ze;const vt=l.useRef(Ae);vt.current=Ae;const Qt=l.useRef(Mt);Qt.current=Mt;const Ie=l.useCallback(a=>{const d=V.current;return!d||d.getViewportSize()<=0?!1:(d.scrollToIndex(a,{align:"nearest"}),!0)},[]),ge=l.useCallback(a=>{const d=He.current.get(a);if(d===void 0){We.current=a,Ie(a)||(We.current=null);return}We.current=null,Ie(a),d.focus({preventScroll:!0})},[Ie]),er=l.useCallback((a,d)=>{if(d)He.current.set(a,d),We.current===a?(We.current=null,d.focus({preventScroll:!0})):d.contains(d.ownerDocument.activeElement)&&Be(g=>g.anchor===null?g:{...g,anchor:{...g.anchor,focused:!0}});else{const g=He.current.get(a);He.current.delete(a),g?.contains(g.ownerDocument.activeElement)&&Be(I=>I.anchor===null?I:{...I,anchor:{...I.anchor,focused:!1}})}a===vt.current&&Jt(d!==null)},[]);l.useLayoutEffect(()=>{Jt(He.current.has(Ae))},[Ae]);const xt=l.useCallback((a,d,g)=>{const I=Qe.current===g;Qe.current=null,I||(Be(H=>kn(H,d)),et.landedOn(g)||Ie(a)),Qt.current?.(a)},[Ie,et]),tt=l.useCallback(a=>et.mark(a.nativeEvent),[et]),St=l.useCallback((a,d)=>{const{ownerDocument:g}=d;if(!g.hasFocus()&&d.contains(g.activeElement)){Qe.current=d;return}Qe.current=null,Be(I=>I.anchor!==null&&I.anchor.path===a?{...I,anchor:{...I.anchor,focused:!1}}:I)},[]),$r=l.useCallback(()=>ge(vt.current),[ge]),Et=l.useCallback((a,d)=>{const g=wr(d),I=gt.current.length;if(!Number.isInteger(a)||a<0||a>=I)throw new RangeError(`[directory-tree] scrollToIndex: ${String(a)} is not a row index (${I===0?"the tree has no rows":`expected an integer in 0..${String(I-1)}`}).`);if(g==="nearest"){Ie(a);return}V.current?.scrollToIndex(a,{align:g})},[Ie]);l.useImperativeHandle(A,()=>({scrollToIndex:Et,scrollToPath:(a,d)=>{wr(d);const g=Zt.current.get(a);return g===void 0?!1:(Et(g,d),!0)},getScrollAnchor:()=>V.current?.getScrollAnchor()??null}),[Et]);const tr=l.useCallback((a,d)=>{if(a.altKey||a.ctrlKey||a.metaKey)return;const g=gt.current,I=g.length-1;if(I<0)return;const H=g[d],q=H?.entry.children!==void 0,we=q&&qt.current(H.entry.absolutePath);switch(a.key){case"ArrowDown":a.preventDefault(),ge(Math.min(d+1,I));break;case"ArrowUp":a.preventDefault(),ge(Math.max(d-1,0));break;case"Home":a.preventDefault(),ge(0);break;case"End":a.preventDefault(),ge(I);break;case"ArrowRight":a.preventDefault(),q&&!we?wt.current(H.entry.absolutePath):q&&d<I&&g[d+1].depth>H.depth&&ge(d+1);break;case"ArrowLeft":{if(a.preventDefault(),q&&we){wt.current(H.entry.absolutePath);break}const Yr=H?.depth??0;for(let ot=d-1;ot>=0;ot--)if(g[ot].depth<Yr){ge(ot);break}break}}},[ge]),rt=l.useMemo(()=>!x||pt.length===0?{segmentsByItem:[],glyphsByItem:[]}:_n(pt,xe,Ce,ct,x,_??mr),[pt,xe,Ce,x,_]),nt=l.useMemo(()=>!x||e.length===0?0:(Vt+2)*ct,[e.length,Vt,x]),{renderStart:rr,renderEnd:nr,lookaheadEnd:sr}=l.useMemo(()=>Pn(X.length,Pe,Ne,Ge,qe,Ce),[X.length,Pe,Ne,Ge,qe,Ce]),kt=l.useMemo(()=>!x||nt<=0||Pe<=0||rt.segmentsByItem.length===0?null:u.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:u.jsx("div",{className:"absolute top-0 left-0",style:{width:nt,height:Pe},children:u.jsx(Mr,{segmentsByItem:rt.segmentsByItem,glyphsByItem:rt.glyphsByItem,itemHeight:xe[0]??lt,width:nt,viewportHeight:Pe,scrollPosition:qe,color:$,expandGlyphColor:$,expandGlyphSize:_??mr,renderStartIndex:rr,renderEndIndex:nr,lookaheadEndIndex:sr})})}),[nt,Pe,rr,nr,sr,qe,rt,$,x,_,xe]),or=l.useCallback(a=>X[a],[X]),ar=l.useRef(null);l.useLayoutEffect(()=>{const a=ar.current;if(ar.current={items:X,offsets:Ce},!Ot||!a||a.items===X)return;const d=V.current,g=d?.getScrollPosition(),I=typeof g=="number"&&g>=0?g:mt.current,H=pn(a.items,a.offsets,I);if(!H)return;const q=bn(H,X,Ce);if(q===null||Math.abs(q-I)<1)return;const we=d?d.scrollTo(q):q;mt.current=we,Bt(we)},[X,Ce,Ot]);const Se=w?.columns,Me=w?.scrollBarWidth??dt?.width??Nr,ee=l.useMemo(()=>Se?cn({measuredWidth:z,columns:Se,scrollBarWidth:Me}):null,[Se,z,Me]),st=l.useMemo(()=>Se?ln(Se):"",[Se]),Br=l.useMemo(()=>w?.showFooter&&Se?un(e):[],[w?.showFooter,Se,e]),Le=ee?.maxHScroll??0;l.useEffect(()=>{Fe(a=>Rt(a,Le))},[Le]);const lr=l.useCallback(a=>Fe(d=>Rt(d+a,Le)),[Le]),cr=l.useMemo(()=>({iconOverrides:F,showExpandIcons:C,showDirectoryIcons:y,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:_,highlightStyles:J,expandIconClassName:P,expandIconStyle:o}),[F,C,y,W,x,_,J,P,o]),ir=l.useMemo(()=>u.jsx(pe.VirtualScroll,{ref:V,itemCount:X.length,getItem:or,getItemHeight:Ut,getItemKey:Kt,testId:Dt,contentProps:Ft,locale:Q,labels:ue,viewportSize:typeof oe=="number"?oe:void 0,overscanCount:Ne,onScroll:Ht,onRangeChange:Wt,onScrollAdjust:Je,liveRegion:$e,className:Ve,onWheelHorizontal:re?lr:void 0,background:u.jsxs(u.Fragment,{children:[re&&ee?u.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:ee.nameWidth},"aria-hidden":"true",children:kt}):kt,Ue]}),initialScrollIndex:G,initialScrollOffset:ye,initialScrollAnchor:Pt,callbackThrottleMs:_t,contentInsets:At,scrollBarOptions:dt,behaviorOptions:$t,children:(a,d)=>a?re&&w&&ee?u.jsx(Ir,{entry:a.entry,indentLevel:a.indentLevel,positionInSet:a.positionInSet,setSize:a.setSize,rowIndex:d+(w.showHeader??!0?2:1),flatIndex:d,onRowFocus:xt,onRowBlur:St,isSelectedForAria:!!k?.has(a.entry.absolutePath),rowHeight:a.rowHeight,isDirOpen:be,columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,rowClassName:w.rowClassName,selection:{onEntryClick:j,selectedPath:_e,currentPath:bt,mode:b,selectedItems:k,onSelectionChange:E},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},visual:cr},a.entry.absolutePath):u.jsx(Nt,{entry:a.entry,indentLevel:a.indentLevel,depth:a.depth,positionInSet:a.positionInSet,setSize:a.setSize,isSelectedForAria:!!k?.has(a.entry.absolutePath),flatIndex:d,isActive:d===Ae,registerRowRef:er,onNavigationKeyDown:tr,onRowFocus:xt,onRowBlur:St,rowHeight:a.rowHeight,entryKindDirectory:Te,entryKindFile:Ee,isDirOpen:be,parentIsLast:a.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:ht},selection:{onEntryClick:j,selectedPath:_e,currentPath:bt,mode:b,selectedItems:k,onSelectionChange:E},visual:{iconOverrides:F,showExpandIcons:C,showDirectoryIcons:y,showFileIcons:W,useCanvasExpandIcons:x,expandIconSize:_,highlightStyles:J,entryClassName:Z,entryStyle:ne,nameClassName:te,nameStyle:B,directoryNameClassName:me,directoryNameStyle:le,fileNameClassName:ce,fileNameStyle:Y,expandIconClassName:P,expandIconStyle:o}},a.entry.absolutePath):null}),[X.length,or,Ut,Kt,Dt,Ft,Q,ue,Te,Ee,Ae,er,tr,xt,St,oe,Ne,Ht,Wt,Je,$e,Ve,re,lr,ee,kt,Ue,G,ye,Pt,_t,At,dt,$t,w,st,be,j,_e,bt,b,k,E,t,ht,cr,F,C,y,W,x,_,J,Z,ne,te,B,me,le,ce,Y,P,o]);if(!(w&&ee))return u.jsxs("div",{ref:K,className:zt,style:Yt,onPointerDownCapture:tt,onMouseDownCapture:tt,children:[Re.length>0&&!Fr&&u.jsx("span",{tabIndex:0,"data-directory-tree-tab-stop":"",style:Tn,onFocus:$r}),ir]});const Hr=w.showHeader??!0,Wr=w.showFooter??!1,zr={...Yt,"--dt-hscroll":`${De}px`};return u.jsxs("div",{ref:K,className:M.twMerge(zt,"dt-grid"),style:zr,role:"treegrid","aria-label":R?void 0:v,"aria-labelledby":R,"aria-multiselectable":b==="multiple"?!0:void 0,"aria-rowcount":X.length+(w.showHeader??!0?1:0),onPointerDownCapture:tt,onMouseDownCapture:tt,children:[Hr&&u.jsx("div",{role:"rowgroup",children:u.jsx(sn,{columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,className:w.headerClassName})}),u.jsx("div",{ref:ve,className:"dt-grid-body",children:ir}),Le>0&&u.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:ee.nameWidth},"aria-hidden":"true"}),u.jsx(pe.ScrollBar,{horizontal:!0,contentSize:ee.numericTotal,viewportSize:ee.numericVisible,scrollPosition:De,scrollBarWidth:Me,locale:Q,labels:ue,onScroll:a=>{const d=typeof a=="function"?a(De):a,g=Rt(d,Le);return Fe(g),g}}),u.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Me},"aria-hidden":"true"})]}),Wr&&u.jsx("div",{role:"rowgroup",children:u.jsx(on,{columns:w.columns,numericTemplate:st,numericTotal:ee.numericTotal,nameWidth:ee.nameWidth,scrollBarWidth:Me,allEntries:Br,className:w.footerClassName})})]})},Mn=({initialExpanded:e=new Set,storageKey:t}={})=>{const[r,n]=l.useTransition(),[s,c]=l.useState(()=>{if(typeof window<"u"&&t)try{const h=window.localStorage.getItem(t);if(h){const v=JSON.parse(h);return new Set(v)}}catch(h){console.error("[useDirectoryTreeState] Error reading from localStorage",h)}return e}),i=l.useCallback(h=>{n(()=>{c(v=>{const R=new Set(v);return h(R),R})})},[]),f=l.useCallback((h,v)=>{i(R=>{for(const $ of h)v(R,$)})},[i]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(s)))}catch(h){console.warn(`Error setting localStorage key "${t}":`,h)}},[s,t]);const j=l.useCallback(h=>{f([h],(v,R)=>{v.has(R)?v.delete(R):v.add(R)})},[f]),S=l.useCallback(h=>{f([h],(v,R)=>{v.add(R)})},[f]),m=l.useCallback(h=>{f([h],(v,R)=>{v.delete(R)})},[f]),b=l.useCallback(h=>{f(h,(v,R)=>{v.delete(R)})},[f]),k=l.useCallback(h=>{f(h,(v,R)=>{v.add(R)})},[f]),E=l.useCallback(()=>{i(h=>{h.clear()})},[i]),N=l.useCallback(h=>s.has(h),[s]);return{expanded:s,toggle:j,expand:S,collapse:m,collapseMultiple:b,expandMultiple:k,collapseAll:E,isExpanded:N,isPending:r}};exports.DIRECTORY_TREE_LABEL_CATALOGS=_r;exports.DIRECTORY_TREE_LABEL_KEYS=jt;exports.DirectoryTree=An;exports.directoryTreeClasses=D;exports.resolveDirectoryTreeLabels=Ar;exports.useDirectoryTreeState=Mn;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DirectoryTree, directoryTreeClasses } from "./DirectoryTree.tsx";
|
|
2
2
|
export { DIRECTORY_TREE_LABEL_CATALOGS, DIRECTORY_TREE_LABEL_KEYS, type DirectoryTreeLabelOverrides, type DirectoryTreeLabels, type DirectoryTreeLocale, resolveDirectoryTreeLabels } from "./labels.ts";
|
|
3
|
-
export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
|
|
3
|
+
export type { DirectoryEntry, DirectoryEntryComparator, DirectoryEntryItemProps, DirectoryTreeClickEvent, DirectoryTreeColumn, DirectoryTreeGrid, DirectoryTreeHandle, DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, DirectoryTreeIconRenderer, DirectoryTreeProps, DirectoryTreeScrollAlign, DirectoryTreeScrollOptions, DirectoryTreeState, DirectoryTreeVirtualScrollOptions, HighlightStyles, ItemHeight, TreeLineItemInfo, TreeLineProps, UseDirectoryTreeStateProps, } from "./types.ts";
|
|
4
4
|
export { useDirectoryTreeState } from "./useDirectoryTreeState.ts";
|