@vitavision/workbench 0.1.2 → 0.2.1

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 CHANGED
@@ -19,12 +19,13 @@ bun add @vitavision/workbench @vitavision/ui
19
19
 
20
20
  | Export | What |
21
21
  |---|---|
22
- | `AppShell` | Full-viewport frame: `header`, `left` \| `main` \| `right` (side panels resizable and optionally remembered), `bottom`. Landmarks included. |
22
+ | `AppShell` | Full-viewport frame: `header`, a fixed-width `rail` (an icon nav, `<nav>`), `left` \| `main` \| `right` (side panels resizable and optionally remembered), `bottom`. Landmarks included. |
23
23
  | `SplitPane` | Two panes, horizontal or vertical, with a draggable, keyboard-operable divider (`role="separator"`, WAI-ARIA window splitter). Sizes in px or `%`, min/max, collapsible, controlled or not, `storageKey`. Nests. |
24
24
  | `TreeView` | Data-driven tree (`TreeNode[]` with `icon`/`meta`), WAI-ARIA tree keyboard, controlled selection, controlled or uncontrolled expansion; reveals a selection made elsewhere. |
25
25
  | `PlaybackBar` | Transport for a sampled timeline: step, play/pause, markers, scrubber, `t = k · dt`, speed, loop. |
26
26
  | `createPlayhead`, `usePlayhead`, `usePlaybackClock` | The playback position as an external store, and the real-time clock that drives it. |
27
- | `FileDrop` | Drop zone (or full-window `overlay`) plus an "Open files…" button; `accept` applied to both routes; dropped folders walked. |
27
+ | `FileDrop` | Drop zone (or full-window `overlay`) plus an "Open files…" button; `accept` applied to both routes; dropped folders walked. In a desktop shell, a `pathSource` yields paths to `onPaths` instead of `File`s (see below). |
28
+ | `SequenceNavigator` | The current item of an ordered set (a frame of a capture) as a lazy thumbnail strip with previous/next, the position, and `[` / `]` from anywhere outside a text field. |
28
29
  | `Toaster`, `toast()` | Notifications from anywhere; one `<Toaster />` near the root. **Now lives in `@vitavision/ui`**; re-exported here (same bindings, one default store) so existing imports keep working. Prefer `import { toast } from "@vitavision/ui"`. |
29
30
 
30
31
  The pure logic behind them is exported too and tested without a DOM: `splitSize.ts`
@@ -70,6 +71,39 @@ Every member may be called detached. Only the bar (and anything using `usePlayhe
70
71
  re-renders during playback. The fractional position real-time playback needs lives in the
71
72
  clock, not the store, so a reader never sees a fractional frame.
72
73
 
74
+ ### Desktop shells: paths, not files
75
+
76
+ A Tauri or Electron webview gives paths, not `File`s: its native drops and dialogs report file
77
+ system paths, and an app that opens images by path never wants their bytes in the webview.
78
+ Give `FileDrop` a `pathSource` built on the shell's APIs, and it delivers paths to `onPaths`,
79
+ filtered by `accept` on their extensions. The package stays shell-agnostic. For Tauri 2:
80
+
81
+ ```tsx
82
+ import { getCurrentWebview } from "@tauri-apps/api/webview";
83
+ import { open } from "@tauri-apps/plugin-dialog";
84
+ import type { PathSource } from "@vitavision/workbench";
85
+
86
+ const tauriPaths: PathSource = {
87
+ pick: async ({ multiple, directory }) => {
88
+ const chosen = await open({ multiple, directory });
89
+ return chosen === null ? [] : Array.isArray(chosen) ? chosen : [chosen];
90
+ },
91
+ subscribe: ({ onEnter, onLeave, onDrop }) => {
92
+ let stop = () => {};
93
+ void getCurrentWebview()
94
+ .onDragDropEvent(({ payload }) => {
95
+ if (payload.type === "enter") onEnter();
96
+ else if (payload.type === "leave") onLeave();
97
+ else if (payload.type === "drop") onDrop(payload.paths);
98
+ })
99
+ .then((unlisten) => (stop = unlisten));
100
+ return () => stop();
101
+ },
102
+ };
103
+
104
+ <FileDrop overlay accept="image/*" pathSource={tauriPaths} onPaths={openByPath} />
105
+ ```
106
+
73
107
  ### Scope
74
108
 
75
109
  No routing, no menus, no app state beyond what each component is asked to remember. A page
package/dist/index.d.ts CHANGED
@@ -64,6 +64,13 @@ interface SidePanelSize {
64
64
  interface AppShellProps {
65
65
  /** The top bar: the app's name, the file actions, the theme toggle. */
66
66
  header?: ReactNode;
67
+ /**
68
+ * A fixed-width column at the far left, outside the resizable panels: an icon rail of
69
+ * workspaces. It takes its content's width and is a `<nav>` named by `railLabel`.
70
+ */
71
+ rail?: ReactNode;
72
+ /** Names the rail's landmark (`<nav>`). Defaults to "Workspaces". */
73
+ railLabel?: string | undefined;
67
74
  /** The panel left of the main surface — a navigator such as a `TreeView`. */
68
75
  left?: ReactNode;
69
76
  /** The main surface — the viewport. Always present. */
@@ -89,16 +96,16 @@ interface AppShellProps {
89
96
  className?: string | undefined;
90
97
  }
91
98
  /**
92
- * The full-viewport frame of a studio app: `header` across the top, `left` | `main` |
93
- * `right` in the middle with resizable side panels, `bottom` across the foot. Every slot but
94
- * `main` is optional, and an absent slot takes no space.
99
+ * The full-viewport frame of a studio app: `header` across the top, then `rail` | `left` |
100
+ * `main` | `right` with resizable side panels and a fixed-width rail, and `bottom` across the
101
+ * foot. Every slot but `main` is optional, and an absent slot takes no space.
95
102
  *
96
- * Landmarks: the header is a `<header>`, the main surface a `<main>`, the side panels
97
- * `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main
103
+ * Landmarks: the header is a `<header>`, the rail a `<nav>` named by `railLabel`, the main
104
+ * surface a `<main>`, the side panels `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main
98
105
  * surface by a `SplitPane` divider (drag, or focus it and use the arrow keys). Only the
99
106
  * insides of the panels scroll; the shell itself is fixed to the viewport (`h-dvh`).
100
107
  */
101
- export declare function AppShell({ header, left, main, right, bottom, leftLabel, rightLabel, leftSize, rightSize, storageKey, className }: AppShellProps): import("react").JSX.Element;
108
+ export declare function AppShell({ header, rail, railLabel, left, main, right, bottom, leftLabel, rightLabel, leftSize, rightSize, storageKey, className }: AppShellProps): import("react").JSX.Element;
102
109
  //#endregion
103
110
  //#region src/components/SplitPane.d.ts
104
111
  /** Props of `SplitPane`. */
@@ -484,10 +491,43 @@ interface PlaybackClockOptions {
484
491
  export declare function usePlaybackClock({ playhead, playing, speed, loop, onEnd, maxFrameMs }: PlaybackClockOptions): void;
485
492
  //#endregion
486
493
  //#region src/components/FileDrop.d.ts
494
+ /**
495
+ * Where paths come from in a desktop shell whose native drops and dialogs yield paths, not
496
+ * `File`s (Tauri, Electron). The app implements it over its shell's APIs; the package stays
497
+ * shell-agnostic. See the README for a Tauri implementation.
498
+ */
499
+ interface PathSource {
500
+ /** Opens the native picker; resolves with the chosen paths, `[]` if cancelled. */
501
+ pick: (options: {
502
+ multiple: boolean;
503
+ directory: boolean;
504
+ accept?: string | undefined;
505
+ }) => Promise<string[]>;
506
+ /**
507
+ * Subscribes to native drags of files over the window: `onEnter` and `onLeave` while a drag
508
+ * hovers, `onDrop` with its paths. Returns the unsubscribe. Optional: without it, only the
509
+ * picker offers paths.
510
+ */
511
+ subscribe?: (handlers: {
512
+ onEnter: () => void;
513
+ onLeave: () => void;
514
+ onDrop: (paths: string[]) => void;
515
+ }) => () => void;
516
+ }
487
517
  /** Props of `FileDrop`. */
488
518
  interface FileDropProps {
489
519
  /** Called with the accepted files of a drop or a pick (never with an empty list). */
490
- onFiles: (files: File[]) => void;
520
+ onFiles?: ((files: File[]) => void) | undefined;
521
+ /**
522
+ * The desktop route: paths from `pathSource`'s picker and native drops, filtered by
523
+ * `accept` on their extensions. With a `pathSource`, the picker and drops go through it
524
+ * instead of the browser's `File` route.
525
+ */
526
+ pathSource?: PathSource | undefined;
527
+ /** Called with the accepted paths of a native drop or pick (never with an empty list). */
528
+ onPaths?: ((paths: string[]) => void) | undefined;
529
+ /** Called with the paths `accept` turned away. */
530
+ onRejectPaths?: ((paths: string[]) => void) | undefined;
491
531
  /** Called with the files a drop or a pick brought that `accept` turned away. */
492
532
  onReject?: ((files: File[]) => void) | undefined;
493
533
  /**
@@ -530,8 +570,11 @@ interface FileDropProps {
530
570
  *
531
571
  * Files are filtered by `accept` on both routes (the browser applies it to neither drops nor,
532
572
  * reliably, the picker); the rest go to `onReject`. A dropped folder is walked recursively.
573
+ *
574
+ * In a desktop shell, pass a `pathSource`: the picker and native drops then yield paths to
575
+ * `onPaths`, filtered by `accept` on their extensions, and the browser `File` route is off.
533
576
  */
534
- export declare function FileDrop({ onFiles, onReject, accept, multiple, directory, overlay, disabled, buttonLabel, overlayMessage, children, className }: FileDropProps): import("react").JSX.Element;
577
+ export declare function FileDrop({ onFiles, pathSource, onPaths, onRejectPaths, onReject, accept, multiple, directory, overlay, disabled, buttonLabel, overlayMessage, children, className }: FileDropProps): import("react").JSX.Element;
535
578
  //#endregion
536
579
  //#region src/components/dropFiles.d.ts
537
580
  /**
@@ -547,6 +590,16 @@ export declare function acceptsFile(file: {
547
590
  name: string;
548
591
  type: string;
549
592
  }, accept: string | undefined): boolean;
593
+ /**
594
+ * Whether a path matches an `accept` string, for desktop shells whose native drops and
595
+ * dialogs yield paths rather than `File`s. Extensions match the path's ending; MIME types and
596
+ * wildcards match through the extension of common image, JSON and text formats.
597
+ *
598
+ * @param path - A file path, with either separator.
599
+ * @param accept - The accept string; empty or absent accepts everything.
600
+ * @returns Whether the path is accepted.
601
+ */
602
+ export declare function acceptsPath(path: string, accept: string | undefined): boolean;
550
603
  /** The part of the File and Directory Entries API a drop walk needs (`webkitGetAsEntry`). */
551
604
  interface DropEntry {
552
605
  /** A file (`FileSystemFileEntry`). */
@@ -576,5 +629,57 @@ interface DropEntry {
576
629
  */
577
630
  export declare function collectDroppedFiles(dataTransfer: Pick<DataTransfer, "files" | "items">): Promise<File[]>;
578
631
  //#endregion
579
- export { type AdvanceResult, type AppShellProps, type DropEntry, type FileDropProps, type PaneSize, type PlaybackBarProps, type PlaybackClockOptions, type PlaybackMarker, type Playhead, type SidePanelSize, type SizedPane, type SplitLimits, type SplitOrientation, type SplitPaneProps, type ToastOptions, type ToastRecord, type ToastStore, type ToastTone, Toaster, type ToasterProps, type TreeKeyAction, type TreeNode, type TreeRow, type TreeViewProps, createToastStore, defaultToastStore, toast };
632
+ //#region src/components/SequenceNavigator.d.ts
633
+ /** One item of a `SequenceNavigator`. */
634
+ interface SequenceItem {
635
+ /** Its identity, unique in the sequence. */
636
+ id: string;
637
+ /** Its name: the thumbnail's alt text and tooltip. */
638
+ label: string;
639
+ /** A thumbnail URL, loaded lazily. Without it, the default rendering is the label. */
640
+ thumbnail?: string | undefined;
641
+ }
642
+ /** Props of `SequenceNavigator`. */
643
+ interface SequenceNavigatorProps {
644
+ /** The items, in order. */
645
+ items: readonly SequenceItem[];
646
+ /** The current item's id, or `null` for none. */
647
+ value: string | null;
648
+ /** Called with the id of the item chosen by click, by previous/next, or by `[` / `]`. */
649
+ onValueChange: (id: string) => void;
650
+ /** Draws an item's thumbnail, e.g. one whose URL must be fetched. Defaults to a lazy `<img>`. */
651
+ renderThumbnail?: ((item: SequenceItem) => ReactNode) | undefined;
652
+ /** Step with `[` and `]` from anywhere outside a text field. Defaults to true. */
653
+ keys?: boolean | undefined;
654
+ /** Wrap from the last item to the first. Defaults to false. */
655
+ wrap?: boolean | undefined;
656
+ /** Names the strip (`aria-label`). */
657
+ "aria-label": string;
658
+ /** Merged with the row's own classes through `cn`. */
659
+ className?: string | undefined;
660
+ }
661
+ /**
662
+ * A horizontal strip of thumbnails between previous and next buttons, with the position
663
+ * ("3 / 50").
664
+ *
665
+ * The current thumbnail carries `aria-current="true"` and `data-current`, has an outline,
666
+ * and is scrolled into view when it changes. `[` and `]` step from anywhere outside a text
667
+ * field. Thumbnails load lazily, so a capture of thousands of frames opens at once.
668
+ */
669
+ export declare function SequenceNavigator({ items, value, onValueChange, renderThumbnail, keys, wrap, "aria-label": ariaLabel, className }: SequenceNavigatorProps): import("react").JSX.Element;
670
+ //#endregion
671
+ //#region src/components/sequence.d.ts
672
+ /**
673
+ * The index one step from `index`.
674
+ *
675
+ * @param length - The number of items.
676
+ * @param index - The current index, or -1 for none.
677
+ * @param delta - +1 for next, -1 for previous.
678
+ * @param wrap - Wrap from the last item to the first and back.
679
+ * @returns The next index; the first (or, stepping back, the last) item when there is no
680
+ * current one; the same index at an end without `wrap`; `null` for an empty set.
681
+ */
682
+ export declare function stepIndex(length: number, index: number, delta: 1 | -1, wrap?: boolean): number | null;
683
+ //#endregion
684
+ export { type AdvanceResult, type AppShellProps, type DropEntry, type FileDropProps, type PaneSize, type PathSource, type PlaybackBarProps, type PlaybackClockOptions, type PlaybackMarker, type Playhead, type SequenceItem, type SequenceNavigatorProps, type SidePanelSize, type SizedPane, type SplitLimits, type SplitOrientation, type SplitPaneProps, type ToastOptions, type ToastRecord, type ToastStore, type ToastTone, Toaster, type ToasterProps, type TreeKeyAction, type TreeNode, type TreeRow, type TreeViewProps, createToastStore, defaultToastStore, toast };
580
685
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Button, Select, Slider, Toaster, byDensity, cn, createToastStore, defaultToastStore, focusRing, toast, toneColor, useDensity } from "@vitavision/ui";
1
+ import { Button, Kbd, Select, Slider, Toaster, byDensity, cn, createToastStore, defaultToastStore, focusRing, toast, toneColor, useDensity } from "@vitavision/ui";
2
2
  import { useCallback, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { ChevronFirst, ChevronLast, ChevronRight, FolderOpen, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from "lucide-react";
4
+ import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, FolderOpen, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from "lucide-react";
5
5
  //#region src/components/splitSize.ts
6
6
  /**
7
7
  * A size in pixels.
@@ -304,16 +304,16 @@ const RIGHT_DEFAULTS = {
304
304
  maxSize: "50%"
305
305
  };
306
306
  /**
307
- * The full-viewport frame of a studio app: `header` across the top, `left` | `main` |
308
- * `right` in the middle with resizable side panels, `bottom` across the foot. Every slot but
309
- * `main` is optional, and an absent slot takes no space.
307
+ * The full-viewport frame of a studio app: `header` across the top, then `rail` | `left` |
308
+ * `main` | `right` with resizable side panels and a fixed-width rail, and `bottom` across the
309
+ * foot. Every slot but `main` is optional, and an absent slot takes no space.
310
310
  *
311
- * Landmarks: the header is a `<header>`, the main surface a `<main>`, the side panels
312
- * `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main
311
+ * Landmarks: the header is a `<header>`, the rail a `<nav>` named by `railLabel`, the main
312
+ * surface a `<main>`, the side panels `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main
313
313
  * surface by a `SplitPane` divider (drag, or focus it and use the arrow keys). Only the
314
314
  * insides of the panels scroll; the shell itself is fixed to the viewport (`h-dvh`).
315
315
  */
316
- function AppShell({ header, left, main, right, bottom, leftLabel = "Navigator", rightLabel = "Inspector", leftSize, rightSize, storageKey, className }) {
316
+ function AppShell({ header, rail, railLabel = "Workspaces", left, main, right, bottom, leftLabel = "Navigator", rightLabel = "Inspector", leftSize, rightSize, storageKey, className }) {
317
317
  const leftSizing = {
318
318
  ...LEFT_DEFAULTS,
319
319
  ...leftSize
@@ -324,6 +324,7 @@ function AppShell({ header, left, main, right, bottom, leftLabel = "Navigator",
324
324
  };
325
325
  const hasLeft = left !== void 0 && left !== null && left !== false;
326
326
  const hasRight = right !== void 0 && right !== null && right !== false;
327
+ const hasRail = rail !== void 0 && rail !== null && rail !== false;
327
328
  const mainSurface = /* @__PURE__ */ jsx("main", {
328
329
  className: "relative h-full min-h-0 min-w-0 overflow-hidden",
329
330
  children: main
@@ -357,7 +358,17 @@ function AppShell({ header, left, main, right, bottom, leftLabel = "Navigator",
357
358
  className: "min-w-0 border-b border-line bg-surface",
358
359
  children: header
359
360
  }) : /* @__PURE__ */ jsx("div", { "aria-hidden": true }),
360
- /* @__PURE__ */ jsx("div", {
361
+ hasRail ? /* @__PURE__ */ jsxs("div", {
362
+ className: "flex min-h-0 min-w-0",
363
+ children: [/* @__PURE__ */ jsx("nav", {
364
+ "aria-label": railLabel,
365
+ className: "h-full shrink-0 overflow-y-auto border-r border-line bg-surface",
366
+ children: rail
367
+ }), /* @__PURE__ */ jsx("div", {
368
+ className: "min-h-0 min-w-0 flex-1",
369
+ children: middle
370
+ })]
371
+ }) : /* @__PURE__ */ jsx("div", {
361
372
  className: "min-h-0 min-w-0",
362
373
  children: middle
363
374
  }),
@@ -1088,6 +1099,38 @@ function acceptsFile(file, accept) {
1088
1099
  return type === token;
1089
1100
  });
1090
1101
  }
1102
+ /** MIME types by extension, for matching a bare path against `type/*` and MIME tokens. */
1103
+ const MIME_BY_EXTENSION = {
1104
+ png: "image/png",
1105
+ jpg: "image/jpeg",
1106
+ jpeg: "image/jpeg",
1107
+ bmp: "image/bmp",
1108
+ gif: "image/gif",
1109
+ webp: "image/webp",
1110
+ tif: "image/tiff",
1111
+ tiff: "image/tiff",
1112
+ pgm: "image/x-portable-graymap",
1113
+ json: "application/json",
1114
+ csv: "text/csv",
1115
+ txt: "text/plain"
1116
+ };
1117
+ /**
1118
+ * Whether a path matches an `accept` string, for desktop shells whose native drops and
1119
+ * dialogs yield paths rather than `File`s. Extensions match the path's ending; MIME types and
1120
+ * wildcards match through the extension of common image, JSON and text formats.
1121
+ *
1122
+ * @param path - A file path, with either separator.
1123
+ * @param accept - The accept string; empty or absent accepts everything.
1124
+ * @returns Whether the path is accepted.
1125
+ */
1126
+ function acceptsPath(path, accept) {
1127
+ const name = path.split(/[\\/]/).pop() ?? path;
1128
+ const dot = name.lastIndexOf(".");
1129
+ return acceptsFile({
1130
+ name,
1131
+ type: dot >= 0 ? MIME_BY_EXTENSION[name.slice(dot + 1).toLowerCase()] ?? "" : ""
1132
+ }, accept);
1133
+ }
1091
1134
  /**
1092
1135
  * Split files by `accept`.
1093
1136
  *
@@ -1171,23 +1214,45 @@ function withRelativePath(file, path) {
1171
1214
  *
1172
1215
  * Files are filtered by `accept` on both routes (the browser applies it to neither drops nor,
1173
1216
  * reliably, the picker); the rest go to `onReject`. A dropped folder is walked recursively.
1217
+ *
1218
+ * In a desktop shell, pass a `pathSource`: the picker and native drops then yield paths to
1219
+ * `onPaths`, filtered by `accept` on their extensions, and the browser `File` route is off.
1174
1220
  */
1175
- function FileDrop({ onFiles, onReject, accept, multiple = true, directory = false, overlay = false, disabled = false, buttonLabel, overlayMessage = "Drop to open", children = "Drop files here, or", className }) {
1221
+ function FileDrop({ onFiles, pathSource, onPaths, onRejectPaths, onReject, accept, multiple = true, directory = false, overlay = false, disabled = false, buttonLabel, overlayMessage = "Drop to open", children = "Drop files here, or", className }) {
1176
1222
  const inputRef = useRef(null);
1177
1223
  const depthRef = useRef(0);
1178
1224
  const [dragging, setDragging] = useState(false);
1179
1225
  const label = buttonLabel ?? (directory ? "Open folder…" : "Open files…");
1180
1226
  const deliver = (files) => {
1181
1227
  const { accepted, rejected } = partitionFiles(files, accept);
1182
- if (accepted.length > 0) onFiles(multiple ? accepted : accepted.slice(0, 1));
1228
+ if (accepted.length > 0) onFiles?.(multiple ? accepted : accepted.slice(0, 1));
1183
1229
  if (rejected.length > 0) onReject?.(rejected);
1184
1230
  };
1231
+ const deliverPaths = (paths) => {
1232
+ const accepted = paths.filter((path) => acceptsPath(path, accept));
1233
+ const rejected = paths.filter((path) => !acceptsPath(path, accept));
1234
+ if (accepted.length > 0) onPaths?.(multiple ? accepted : accepted.slice(0, 1));
1235
+ if (rejected.length > 0) onRejectPaths?.(rejected);
1236
+ };
1185
1237
  const deliverRef = useRef(deliver);
1238
+ const deliverPathsRef = useRef(deliverPaths);
1186
1239
  useEffect(() => {
1187
1240
  deliverRef.current = deliver;
1241
+ deliverPathsRef.current = deliverPaths;
1188
1242
  });
1189
1243
  useEffect(() => {
1190
- if (!overlay || disabled) return;
1244
+ if (!pathSource?.subscribe || disabled) return;
1245
+ return pathSource.subscribe({
1246
+ onEnter: () => setDragging(true),
1247
+ onLeave: () => setDragging(false),
1248
+ onDrop: (paths) => {
1249
+ setDragging(false);
1250
+ deliverPathsRef.current(paths);
1251
+ }
1252
+ });
1253
+ }, [pathSource, disabled]);
1254
+ useEffect(() => {
1255
+ if (!overlay || disabled || pathSource) return;
1191
1256
  const onEnter = (event) => {
1192
1257
  if (!carriesFiles(event.dataTransfer)) return;
1193
1258
  depthRef.current += 1;
@@ -1221,7 +1286,11 @@ function FileDrop({ onFiles, onReject, accept, multiple = true, directory = fals
1221
1286
  window.removeEventListener("drop", onDrop);
1222
1287
  depthRef.current = 0;
1223
1288
  };
1224
- }, [overlay, disabled]);
1289
+ }, [
1290
+ overlay,
1291
+ disabled,
1292
+ pathSource
1293
+ ]);
1225
1294
  const onPick = (event) => {
1226
1295
  const files = Array.from(event.currentTarget.files ?? []);
1227
1296
  event.currentTarget.value = "";
@@ -1242,7 +1311,19 @@ function FileDrop({ onFiles, onReject, accept, multiple = true, directory = fals
1242
1311
  }), /* @__PURE__ */ jsx(Button, {
1243
1312
  icon: /* @__PURE__ */ jsx(FolderOpen, {}),
1244
1313
  disabled,
1245
- onClick: () => inputRef.current?.click(),
1314
+ onClick: () => {
1315
+ if (pathSource) {
1316
+ pathSource.pick({
1317
+ multiple: multiple || directory,
1318
+ directory,
1319
+ accept
1320
+ }).then((paths) => {
1321
+ if (paths.length > 0) deliverPathsRef.current(paths);
1322
+ });
1323
+ return;
1324
+ }
1325
+ inputRef.current?.click();
1326
+ },
1246
1327
  className: overlay ? className : void 0,
1247
1328
  children: label
1248
1329
  })] });
@@ -1283,6 +1364,139 @@ function FileDrop({ onFiles, onReject, accept, multiple = true, directory = fals
1283
1364
  });
1284
1365
  }
1285
1366
  //#endregion
1286
- export { AppShell, DEFAULT_SPEEDS, FileDrop, PlaybackBar, SplitPane, Toaster, TreeView, acceptsFile, advance, ancestorIds, clampIndex, clampSize, collectDroppedFiles, createPlayhead, createToastStore, defaultToastStore, formatSeconds, parentIds, resolveLimits, resolveSize, toast, treeKeyAction, usePlaybackClock, usePlayhead, usePlayheadTimeline, visibleRows };
1367
+ //#region src/components/sequence.ts
1368
+ /**
1369
+ * The index one step from `index`.
1370
+ *
1371
+ * @param length - The number of items.
1372
+ * @param index - The current index, or -1 for none.
1373
+ * @param delta - +1 for next, -1 for previous.
1374
+ * @param wrap - Wrap from the last item to the first and back.
1375
+ * @returns The next index; the first (or, stepping back, the last) item when there is no
1376
+ * current one; the same index at an end without `wrap`; `null` for an empty set.
1377
+ */
1378
+ function stepIndex(length, index, delta, wrap = false) {
1379
+ if (length <= 0) return null;
1380
+ if (index < 0 || index >= length) return delta > 0 ? 0 : length - 1;
1381
+ const next = index + delta;
1382
+ if (wrap) return (next + length) % length;
1383
+ return Math.min(length - 1, Math.max(0, next));
1384
+ }
1385
+ //#endregion
1386
+ //#region src/components/SequenceNavigator.tsx
1387
+ /**
1388
+ * A horizontal strip of thumbnails between previous and next buttons, with the position
1389
+ * ("3 / 50").
1390
+ *
1391
+ * The current thumbnail carries `aria-current="true"` and `data-current`, has an outline,
1392
+ * and is scrolled into view when it changes. `[` and `]` step from anywhere outside a text
1393
+ * field. Thumbnails load lazily, so a capture of thousands of frames opens at once.
1394
+ */
1395
+ function SequenceNavigator({ items, value, onValueChange, renderThumbnail, keys = true, wrap = false, "aria-label": ariaLabel, className }) {
1396
+ const index = items.findIndex((item) => item.id === value);
1397
+ const listRef = useRef(null);
1398
+ const step = (delta) => {
1399
+ const next = stepIndex(items.length, index, delta, wrap);
1400
+ const item = next === null ? void 0 : items[next];
1401
+ if (item && item.id !== value) onValueChange(item.id);
1402
+ };
1403
+ const stepRef = useRef(step);
1404
+ useEffect(() => {
1405
+ stepRef.current = step;
1406
+ });
1407
+ useEffect(() => {
1408
+ if (!keys) return;
1409
+ const onKey = (event) => {
1410
+ if (event.metaKey || event.ctrlKey || event.altKey || isTypingTarget(event.target)) return;
1411
+ if (event.key === "[") stepRef.current(-1);
1412
+ else if (event.key === "]") stepRef.current(1);
1413
+ };
1414
+ window.addEventListener("keydown", onKey);
1415
+ return () => window.removeEventListener("keydown", onKey);
1416
+ }, [keys]);
1417
+ useEffect(() => {
1418
+ listRef.current?.querySelector("[data-current]")?.scrollIntoView({
1419
+ block: "nearest",
1420
+ inline: "nearest"
1421
+ });
1422
+ }, [value]);
1423
+ const atStart = !wrap && index <= 0;
1424
+ const atEnd = !wrap && (index < 0 || index >= items.length - 1);
1425
+ return /* @__PURE__ */ jsxs("div", {
1426
+ className: cn("flex min-w-0 items-center gap-1.5", className),
1427
+ children: [
1428
+ /* @__PURE__ */ jsx(Button, {
1429
+ size: "sm",
1430
+ variant: "ghost",
1431
+ icon: /* @__PURE__ */ jsx(ChevronLeft, {}),
1432
+ "aria-label": "Previous",
1433
+ "aria-keyshortcuts": keys ? "[" : void 0,
1434
+ disabled: items.length < 2 || atStart,
1435
+ onClick: () => step(-1)
1436
+ }),
1437
+ /* @__PURE__ */ jsx("ol", {
1438
+ ref: listRef,
1439
+ "aria-label": ariaLabel,
1440
+ className: "flex min-w-0 flex-1 gap-1 overflow-x-auto py-1",
1441
+ children: items.map((item) => {
1442
+ const current = item.id === value;
1443
+ return /* @__PURE__ */ jsx("li", {
1444
+ className: "shrink-0",
1445
+ children: /* @__PURE__ */ jsx("button", {
1446
+ type: "button",
1447
+ title: item.label,
1448
+ "aria-label": item.label,
1449
+ "aria-current": current ? "true" : void 0,
1450
+ "data-current": current ? "" : void 0,
1451
+ onClick: () => {
1452
+ if (!current) onValueChange(item.id);
1453
+ },
1454
+ className: cn("block h-10 w-14 overflow-hidden rounded-control border border-line bg-raised text-fg", "data-current:ring-2 data-current:ring-signal", focusRing),
1455
+ children: renderThumbnail ? renderThumbnail(item) : item.thumbnail ? /* @__PURE__ */ jsx("img", {
1456
+ src: item.thumbnail,
1457
+ alt: "",
1458
+ loading: "lazy",
1459
+ decoding: "async",
1460
+ className: "h-full w-full object-cover"
1461
+ }) : /* @__PURE__ */ jsx("span", {
1462
+ className: "block truncate px-1 font-mono text-[10px]",
1463
+ children: item.label
1464
+ })
1465
+ })
1466
+ }, item.id);
1467
+ })
1468
+ }),
1469
+ /* @__PURE__ */ jsx(Button, {
1470
+ size: "sm",
1471
+ variant: "ghost",
1472
+ icon: /* @__PURE__ */ jsx(ChevronRight, {}),
1473
+ "aria-label": "Next",
1474
+ "aria-keyshortcuts": keys ? "]" : void 0,
1475
+ disabled: items.length < 2 || atEnd,
1476
+ onClick: () => step(1)
1477
+ }),
1478
+ /* @__PURE__ */ jsxs("span", {
1479
+ className: "shrink-0 font-mono text-xs text-fg-muted tabular-nums",
1480
+ children: [
1481
+ index >= 0 ? index + 1 : "–",
1482
+ " / ",
1483
+ items.length
1484
+ ]
1485
+ }),
1486
+ keys && /* @__PURE__ */ jsxs("span", {
1487
+ className: "hidden shrink-0 items-center gap-0.5 text-xs text-fg-muted sm:flex",
1488
+ "aria-hidden": true,
1489
+ children: [/* @__PURE__ */ jsx(Kbd, { children: "[" }), /* @__PURE__ */ jsx(Kbd, { children: "]" })]
1490
+ })
1491
+ ]
1492
+ });
1493
+ }
1494
+ function isTypingTarget(target) {
1495
+ if (!(target instanceof HTMLElement)) return false;
1496
+ const tag = target.tagName;
1497
+ return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable;
1498
+ }
1499
+ //#endregion
1500
+ export { AppShell, DEFAULT_SPEEDS, FileDrop, PlaybackBar, SequenceNavigator, SplitPane, Toaster, TreeView, acceptsFile, acceptsPath, advance, ancestorIds, clampIndex, clampSize, collectDroppedFiles, createPlayhead, createToastStore, defaultToastStore, formatSeconds, parentIds, resolveLimits, resolveSize, stepIndex, toast, treeKeyAction, usePlaybackClock, usePlayhead, usePlayheadTimeline, visibleRows };
1287
1501
 
1288
1502
  //# sourceMappingURL=index.js.map