@vitavision/workbench 0.2.1 → 0.3.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 CHANGED
@@ -3,9 +3,7 @@
3
3
  The building blocks of a vitavision *studio* app — a tool whose surfaces are all permanent: a
4
4
  navigator, a viewport, an inspector, a timeline. Built on `@vitavision/ui` and its tokens.
5
5
 
6
- In scope by [ADR-0003](../../docs/adrs/0003-workbench-app-shell.md): first built for etendue's
7
- studio (incubated there as `web/packages/workbench`), with the calibration-rs diagnose app as
8
- the expected second consumer.
6
+ Scope: the application shell and its navigation parts, shared by the vitavision studio apps.
9
7
 
10
8
  ```bash
11
9
  bun add @vitavision/workbench @vitavision/ui
@@ -20,18 +18,21 @@ bun add @vitavision/workbench @vitavision/ui
20
18
  | Export | What |
21
19
  |---|---|
22
20
  | `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. |
21
+ | `NavRail`, `NavRailItem` | The workspaces of an app as an icon column for `AppShell`'s `rail` slot, one current (`aria-current="page"`): labels under the icons or in tooltips, count badges, disabled items, and `asChild` to render each item as a router's link. Controlled or not. |
22
+ | `StatusBar` | One 24 px status line for `AppShell`'s `bottom` slot: `ReadoutItem` facts at the `start` and `end`, anything (a `ProgressBar`) between. A named group; a polite `role="status"` with `live`. |
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
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
+ | `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. A per-item `status` (`{ tone, label }`) draws a dot in the thumbnail's corner and is said in the item's name. |
29
+ | `Stepper` | The steps of a gated sequence (Teach, then Find, then Verify): numbered, the current one `aria-current="step"`, done ones checked. A step with a `blockedBy` reason stays focusable but `aria-disabled`, described by its reason (also its tooltip), and cannot be chosen. Row or column; controlled or not. |
29
30
  | `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"`. |
30
31
 
31
32
  The pure logic behind them is exported too and tested without a DOM: `splitSize.ts`
32
33
  (`resolveSize`, `resolveLimits`, `clampSize`), `treeModel.ts` (`visibleRows`, `treeKeyAction`,
33
34
  `ancestorIds`, `parentIds`), `playhead.ts` (`advance`, `clampIndex`, `formatSeconds`),
34
- `dropFiles.ts` (`acceptsFile`, `collectDroppedFiles`).
35
+ `dropFiles.ts` (`acceptsFile`, `collectDroppedFiles`), `stepperModel.ts` (`stepStates`).
35
36
 
36
37
  ### Playback without re-rendering the app
37
38
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { MeasureTone, ToastOptions, ToastRecord, ToastStore, ToastTone, Toaster, ToasterProps, createToastStore, defaultToastStore, toast } from "@vitavision/ui";
2
- import { ReactNode } from "react";
1
+ import { MeasureTone, ReadoutItem, ToastOptions, ToastRecord, ToastStore, ToastTone, Toaster, ToasterProps, Tone, createToastStore, defaultToastStore, toast } from "@vitavision/ui";
2
+ import { ReactElement, ReactNode } from "react";
3
3
  //#region src/components/splitSize.d.ts
4
4
  /**
5
5
  * A pane size: CSS pixels as a number, or a share of the split's length as a percentage
@@ -66,7 +66,8 @@ interface AppShellProps {
66
66
  header?: ReactNode;
67
67
  /**
68
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`.
69
+ * workspaces, such as a `NavRail`. It takes its content's width and is a `<nav>` named by
70
+ * `railLabel`.
70
71
  */
71
72
  rail?: ReactNode;
72
73
  /** Names the rail's landmark (`<nav>`). Defaults to "Workspaces". */
@@ -77,7 +78,7 @@ interface AppShellProps {
77
78
  main: ReactNode;
78
79
  /** The panel right of the main surface — an inspector. */
79
80
  right?: ReactNode;
80
- /** The strip along the bottom, across the whole width — a `PlaybackBar`, a status line. */
81
+ /** The strip along the bottom, across the whole width — a `PlaybackBar`, a `StatusBar`. */
81
82
  bottom?: ReactNode;
82
83
  /** Names the left panel's landmark (`<aside>`). Defaults to "Navigator". */
83
84
  leftLabel?: string | undefined;
@@ -107,6 +108,103 @@ interface AppShellProps {
107
108
  */
108
109
  export declare function AppShell({ header, rail, railLabel, left, main, right, bottom, leftLabel, rightLabel, leftSize, rightSize, storageKey, className }: AppShellProps): import("react").JSX.Element;
109
110
  //#endregion
111
+ //#region src/components/StatusBar.d.ts
112
+ /** Props of `StatusBar`. */
113
+ interface StatusBarProps {
114
+ /** The facts at the left end, in order. Items whose `value` is `null` or `undefined` are skipped. */
115
+ start?: ReadoutItem[] | undefined;
116
+ /** The facts at the right end, in order. Items whose `value` is `null` or `undefined` are skipped. */
117
+ end?: ReadoutItem[] | undefined;
118
+ /** Drawn between the two ends, e.g. a `ProgressBar` while an operation runs. */
119
+ children?: ReactNode;
120
+ /** Names the bar. Defaults to "Status". */
121
+ "aria-label"?: string | undefined;
122
+ /**
123
+ * Announce changes to the bar's content politely (`role="status"`) instead of leaving it a
124
+ * plain named group. Defaults to false.
125
+ */
126
+ live?: boolean | undefined;
127
+ /** Merged with the bar's own classes through `cn`. */
128
+ className?: string | undefined;
129
+ }
130
+ /**
131
+ * One 24 px line of facts for `AppShell`'s `bottom` slot: a `ReadoutStrip` of `start` items at
132
+ * the left end, one of `end` items at the right end, and `children` between them.
133
+ *
134
+ * It is a `role="group"` named by `aria-label` ("Status"). With `live` it is a
135
+ * `role="status"` instead (a polite live region, and `data-live`), so a screen reader
136
+ * announces what changes in it: use that for facts worth hearing when they change (an
137
+ * operation finished), not for ones that change many times a second. The line does not wrap;
138
+ * keep it to a few short facts.
139
+ */
140
+ export declare function StatusBar({ start, end, children, "aria-label": ariaLabel, live, className }: StatusBarProps): import("react").JSX.Element;
141
+ //#endregion
142
+ //#region src/components/NavRail.d.ts
143
+ /** How a `NavRail` shows its items' labels. */
144
+ type NavRailLabels = "visible" | "tooltip";
145
+ /** Props of `NavRail`. */
146
+ interface NavRailProps {
147
+ /** The current item's `value`, or `null` for none. Leave undefined to let the rail keep it. */
148
+ value?: string | null | undefined;
149
+ /** The current item at first, when the rail keeps it (`value` undefined). */
150
+ defaultValue?: string | undefined;
151
+ /** Called with an item's `value` when a person chooses an item other than the current one. */
152
+ onValueChange?: ((value: string) => void) | undefined;
153
+ /**
154
+ * `"visible"` (the default) sets each label under its icon; `"tooltip"` draws icon-only
155
+ * buttons and shows the label in a tooltip on hover or focus.
156
+ */
157
+ labels?: NavRailLabels | undefined;
158
+ /** The `NavRailItem`s, in order. */
159
+ children: ReactNode;
160
+ /** Merged with the list's own classes through `cn`. */
161
+ className?: string | undefined;
162
+ }
163
+ /** Props of `NavRailItem`. */
164
+ interface NavRailItemProps {
165
+ /** Identifies the item to the rail's `value`. Unique within the rail. */
166
+ value: string;
167
+ /** The item's name: its text under the icon, or its tooltip and accessible name. */
168
+ label: string;
169
+ /** The item's icon, decorative (`aria-hidden`): the label carries the meaning. */
170
+ icon: ReactNode;
171
+ /**
172
+ * A mark on the icon's corner: a number is drawn as a count (over 99 as "99+"), anything
173
+ * else as given. It describes the item (`aria-describedby`); it is not part of its name.
174
+ */
175
+ badge?: ReactNode | number;
176
+ /** Shown but not choosable. A link item gets `aria-disabled` and its clicks are cancelled. */
177
+ disabled?: boolean | undefined;
178
+ /**
179
+ * Render onto the one child element — a router's `<Link to="…" />` or an `<a href>` —
180
+ * instead of a `<button>`. Give the child without content: the icon and label become its
181
+ * children. Its own `className` is kept beside the item's, and its own `onClick` runs first;
182
+ * calling `event.preventDefault()` there keeps the item from being chosen.
183
+ */
184
+ asChild?: boolean | undefined;
185
+ /** With `asChild`, the one element to render as. */
186
+ children?: ReactElement | undefined;
187
+ /** Merged with the item's own classes through `cn`. */
188
+ className?: string | undefined;
189
+ }
190
+ /**
191
+ * A vertical rail of workspaces: `NavRailItem`s as a list of buttons (or the app's links, via
192
+ * `asChild`), one of them current. Controlled with `value` and `onValueChange`, or kept by the
193
+ * rail from `defaultValue`.
194
+ *
195
+ * The current item carries `aria-current="page"` and `data-state="active"` (the others
196
+ * `"inactive"`). Every item is its own Tab stop. The rail is a plain list with no landmark of
197
+ * its own: `AppShell`'s `rail` slot is already a named `<nav>`, so elsewhere wrap it in a
198
+ * `<nav aria-label="…">`.
199
+ */
200
+ export declare function NavRail({ value, defaultValue, onValueChange, labels, children, className }: NavRailProps): import("react").JSX.Element;
201
+ /**
202
+ * One workspace of a `NavRail`: an icon over its label, or an icon-only button with the label
203
+ * in a tooltip (the rail's `labels`). A `<button>` by default; with `asChild`, the one child
204
+ * element (the app's link) takes the item's look, `aria-current` and click.
205
+ */
206
+ export declare function NavRailItem({ value, label, icon, badge, disabled, asChild, children, className }: NavRailItemProps): import("react").JSX.Element;
207
+ //#endregion
110
208
  //#region src/components/SplitPane.d.ts
111
209
  /** Props of `SplitPane`. */
112
210
  interface SplitPaneProps {
@@ -630,6 +728,16 @@ interface DropEntry {
630
728
  export declare function collectDroppedFiles(dataTransfer: Pick<DataTransfer, "files" | "items">): Promise<File[]>;
631
729
  //#endregion
632
730
  //#region src/components/SequenceNavigator.d.ts
731
+ /**
732
+ * A per-item status — "not found" in a batch run, "rejected" by a reviewer — drawn as a dot in
733
+ * the thumbnail's corner and said in words in the item's name.
734
+ */
735
+ interface SequenceItemStatus {
736
+ /** The dot's colour, by meaning; also the item's `data-status`. */
737
+ tone: Tone;
738
+ /** The status in words, appended to the item's name and tooltip: `"frame_0003.bmp, not found"`. */
739
+ label: string;
740
+ }
633
741
  /** One item of a `SequenceNavigator`. */
634
742
  interface SequenceItem {
635
743
  /** Its identity, unique in the sequence. */
@@ -638,6 +746,8 @@ interface SequenceItem {
638
746
  label: string;
639
747
  /** A thumbnail URL, loaded lazily. Without it, the default rendering is the label. */
640
748
  thumbnail?: string | undefined;
749
+ /** A status, drawn as a dot in the thumbnail's corner over any thumbnail rendering. */
750
+ status?: SequenceItemStatus | undefined;
641
751
  }
642
752
  /** Props of `SequenceNavigator`. */
643
753
  interface SequenceNavigatorProps {
@@ -663,8 +773,11 @@ interface SequenceNavigatorProps {
663
773
  * ("3 / 50").
664
774
  *
665
775
  * 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.
776
+ * and is scrolled into view when it changes. An item with a `status` shows a dot in its
777
+ * corner, carries `data-status` (the tone) and is named `"label, status"`. `[` and `]` step
778
+ * from anywhere outside a text field. Thumbnails load lazily, so a capture of thousands of
779
+ * frames opens at once. The strip is as wide as its thumbnails, so previous and next stay
780
+ * beside a short sequence; a long one scrolls.
668
781
  */
669
782
  export declare function SequenceNavigator({ items, value, onValueChange, renderThumbnail, keys, wrap, "aria-label": ariaLabel, className }: SequenceNavigatorProps): import("react").JSX.Element;
670
783
  //#endregion
@@ -681,5 +794,86 @@ export declare function SequenceNavigator({ items, value, onValueChange, renderT
681
794
  */
682
795
  export declare function stepIndex(length: number, index: number, delta: 1 | -1, wrap?: boolean): number | null;
683
796
  //#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 };
797
+ //#region src/components/Stepper.d.ts
798
+ /** One step of a `Stepper`. */
799
+ interface StepperStep {
800
+ /** Its identity, unique among the steps; the stepper's `value`. */
801
+ id: string;
802
+ /** Its name. */
803
+ label: ReactNode;
804
+ /**
805
+ * Why it cannot be entered yet — "Teach a model first". A step with a reason is blocked:
806
+ * shown, focusable and described by the reason, but not choosable.
807
+ */
808
+ blockedBy?: string | undefined;
809
+ /** Marks it done (a check instead of its number). */
810
+ complete?: boolean | undefined;
811
+ }
812
+ /** Props of `Stepper`. */
813
+ interface StepperProps {
814
+ /** The steps, in order. */
815
+ steps: readonly StepperStep[];
816
+ /** The current step's id, or `null` for none. Leave undefined to let the stepper keep it. */
817
+ value?: string | null | undefined;
818
+ /** The current step at first, when the stepper keeps it. Defaults to the first step. */
819
+ defaultValue?: string | undefined;
820
+ /** Called with a step's id when a person chooses a step that is neither current nor blocked. */
821
+ onValueChange?: ((id: string) => void) | undefined;
822
+ /** A row (the default) or a column. */
823
+ orientation?: "horizontal" | "vertical" | undefined;
824
+ /** Names the list of steps. */
825
+ "aria-label": string;
826
+ /** Merged with the list's own classes through `cn`. */
827
+ className?: string | undefined;
828
+ }
829
+ /**
830
+ * The steps of a gated sequence as an ordered list of buttons, numbered, with the current one
831
+ * marked (`aria-current="step"`) and done ones checked. Controlled with `value` and
832
+ * `onValueChange`, or kept by the stepper from `defaultValue`.
833
+ *
834
+ * A step with `blockedBy` is blocked: it keeps its Tab stop but carries `aria-disabled`, its
835
+ * reason is its description (`aria-describedby`) and its tooltip, and choosing it does nothing.
836
+ * Each step carries `data-state` (`current`, `complete`, `blocked` or `upcoming`), and the
837
+ * list `data-orientation`.
838
+ */
839
+ export declare function Stepper({ steps, value, defaultValue, onValueChange, orientation, "aria-label": ariaLabel, className }: StepperProps): import("react").JSX.Element;
840
+ //#endregion
841
+ //#region src/components/stepperModel.d.ts
842
+ /**
843
+ * Where a step stands: `current` (the one a person is on), `blocked` (cannot be entered
844
+ * yet; it says why), `complete` (done) or `upcoming` (not done, and open).
845
+ */
846
+ type StepState = "current" | "complete" | "blocked" | "upcoming";
847
+ /** The part of a step its state depends on. */
848
+ interface StepGate {
849
+ /** Its identity, unique among the steps. */
850
+ id: string;
851
+ /** Why it cannot be entered yet. A step with a non-empty reason is blocked. */
852
+ blockedBy?: string | undefined;
853
+ /** Whether it is done. */
854
+ complete?: boolean | undefined;
855
+ }
856
+ /** One step's state, and whether choosing it would make it current. */
857
+ interface StepView {
858
+ /** The step's id. */
859
+ id: string;
860
+ /** Where the step stands. */
861
+ state: StepState;
862
+ /** True when choosing it makes it current: it is neither blocked nor current already. */
863
+ canActivate: boolean;
864
+ }
865
+ /**
866
+ * Each step's state, in order.
867
+ *
868
+ * The step whose id is `current` is `current`, whatever else is true of it: the app put the
869
+ * person there. Of the others, one with a `blockedBy` reason is `blocked` (even if `complete`:
870
+ * a step can be done and then fall behind a newer gate), then `complete`, then `upcoming`.
871
+ * Only a step that is neither current nor blocked can be activated.
872
+ *
873
+ * @param steps - The steps, in order.
874
+ * @param current - The current step's id, or `null` for none.
875
+ */
876
+ export declare function stepStates(steps: readonly StepGate[], current: string | null): StepView[];
877
+ //#endregion
878
+ export { type AdvanceResult, type AppShellProps, type DropEntry, type FileDropProps, type NavRailItemProps, type NavRailLabels, type NavRailProps, type PaneSize, type PathSource, type PlaybackBarProps, type PlaybackClockOptions, type PlaybackMarker, type Playhead, type SequenceItem, type SequenceItemStatus, type SequenceNavigatorProps, type SidePanelSize, type SizedPane, type SplitLimits, type SplitOrientation, type SplitPaneProps, type StatusBarProps, type StepGate, type StepState, type StepView, type StepperProps, type StepperStep, type ToastOptions, type ToastRecord, type ToastStore, type ToastTone, Toaster, type ToasterProps, type TreeKeyAction, type TreeNode, type TreeRow, type TreeViewProps, createToastStore, defaultToastStore, toast };
685
879
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Button, Kbd, Select, Slider, Toaster, byDensity, cn, createToastStore, defaultToastStore, focusRing, toast, toneColor, useDensity } from "@vitavision/ui";
2
- import { useCallback, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore } from "react";
1
+ import { Button, Kbd, ReadoutStrip, Select, Slider, StatusDot, Toaster, Tooltip, byDensity, cn, createToastStore, defaultToastStore, focusRing, toast, toneColor, useDensity } from "@vitavision/ui";
2
+ import { cloneElement, createContext, isValidElement, use, useCallback, useEffect, useEffectEvent, useId, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, FolderOpen, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from "lucide-react";
4
+ import { Check, ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, FolderOpen, Lock, 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.
@@ -380,6 +380,145 @@ function AppShell({ header, rail, railLabel = "Workspaces", left, main, right, b
380
380
  });
381
381
  }
382
382
  //#endregion
383
+ //#region src/components/StatusBar.tsx
384
+ /**
385
+ * One 24 px line of facts for `AppShell`'s `bottom` slot: a `ReadoutStrip` of `start` items at
386
+ * the left end, one of `end` items at the right end, and `children` between them.
387
+ *
388
+ * It is a `role="group"` named by `aria-label` ("Status"). With `live` it is a
389
+ * `role="status"` instead (a polite live region, and `data-live`), so a screen reader
390
+ * announces what changes in it: use that for facts worth hearing when they change (an
391
+ * operation finished), not for ones that change many times a second. The line does not wrap;
392
+ * keep it to a few short facts.
393
+ */
394
+ function StatusBar({ start, end, children, "aria-label": ariaLabel = "Status", live = false, className }) {
395
+ const hasChildren = children !== void 0 && children !== null && children !== false;
396
+ return /* @__PURE__ */ jsxs("div", {
397
+ role: live ? "status" : "group",
398
+ "aria-label": ariaLabel,
399
+ "aria-live": live ? "polite" : void 0,
400
+ "data-live": live ? "" : void 0,
401
+ className: cn("flex h-6 min-w-0 items-center gap-3 overflow-hidden px-3", className),
402
+ children: [
403
+ start && /* @__PURE__ */ jsx(ReadoutStrip, {
404
+ items: start,
405
+ className: STRIP
406
+ }),
407
+ hasChildren && /* @__PURE__ */ jsx("div", {
408
+ className: "flex min-w-0 flex-1 items-center gap-2",
409
+ children
410
+ }),
411
+ end && /* @__PURE__ */ jsx(ReadoutStrip, {
412
+ items: end,
413
+ className: cn(STRIP, "ml-auto")
414
+ })
415
+ ]
416
+ });
417
+ }
418
+ /** One line: the strip's own wrapping would push the second line out of a 24 px bar. */
419
+ const STRIP = "shrink-0 flex-nowrap whitespace-nowrap";
420
+ //#endregion
421
+ //#region src/components/NavRail.tsx
422
+ const NavRailContext = createContext(null);
423
+ /**
424
+ * A vertical rail of workspaces: `NavRailItem`s as a list of buttons (or the app's links, via
425
+ * `asChild`), one of them current. Controlled with `value` and `onValueChange`, or kept by the
426
+ * rail from `defaultValue`.
427
+ *
428
+ * The current item carries `aria-current="page"` and `data-state="active"` (the others
429
+ * `"inactive"`). Every item is its own Tab stop. The rail is a plain list with no landmark of
430
+ * its own: `AppShell`'s `rail` slot is already a named `<nav>`, so elsewhere wrap it in a
431
+ * `<nav aria-label="…">`.
432
+ */
433
+ function NavRail({ value, defaultValue, onValueChange, labels = "visible", children, className }) {
434
+ const [kept, setKept] = useState(defaultValue ?? null);
435
+ const current = value === void 0 ? kept : value;
436
+ const choose = (next) => {
437
+ if (next === current) return;
438
+ if (value === void 0) setKept(next);
439
+ onValueChange?.(next);
440
+ };
441
+ return /* @__PURE__ */ jsx(NavRailContext, {
442
+ value: {
443
+ value: current,
444
+ labels,
445
+ choose
446
+ },
447
+ children: /* @__PURE__ */ jsx("ul", {
448
+ "data-labels": labels,
449
+ className: cn("flex flex-col items-center gap-1 p-1.5", className),
450
+ children
451
+ })
452
+ });
453
+ }
454
+ /**
455
+ * One workspace of a `NavRail`: an icon over its label, or an icon-only button with the label
456
+ * in a tooltip (the rail's `labels`). A `<button>` by default; with `asChild`, the one child
457
+ * element (the app's link) takes the item's look, `aria-current` and click.
458
+ */
459
+ function NavRailItem({ value, label, icon, badge, disabled = false, asChild = false, children, className }) {
460
+ const rail = use(NavRailContext);
461
+ if (rail === null) throw new Error("NavRailItem must be rendered inside a NavRail.");
462
+ const badgeId = useId();
463
+ const active = rail.value === value;
464
+ const iconOnly = rail.labels === "tooltip";
465
+ const hasBadge = badge !== void 0 && badge !== null && badge !== false;
466
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
467
+ "aria-hidden": true,
468
+ className: "relative grid place-items-center [&>svg]:size-4.5",
469
+ children: [icon, hasBadge && /* @__PURE__ */ jsx("span", {
470
+ id: badgeId,
471
+ "data-badge": "",
472
+ className: cn("absolute -top-1.5 left-[calc(100%-0.375rem)]", typeof badge === "number" && "min-w-4 rounded-full bg-signal px-1 text-center font-mono text-[10px] leading-4 text-signal-fg tabular-nums"),
473
+ children: typeof badge === "number" ? formatCount(badge) : badge
474
+ })]
475
+ }), !iconOnly && /* @__PURE__ */ jsx("span", {
476
+ className: "max-w-full truncate text-[10px] leading-tight",
477
+ children: label
478
+ })] });
479
+ const shared = {
480
+ "aria-current": active ? "page" : void 0,
481
+ "aria-label": iconOnly ? label : void 0,
482
+ "aria-describedby": hasBadge ? badgeId : void 0,
483
+ "data-state": active ? "active" : "inactive",
484
+ "data-disabled": disabled ? "" : void 0
485
+ };
486
+ const classes = cn("relative flex flex-col items-center justify-center gap-0.5 rounded-control text-fg-muted transition-colors", iconOnly ? "size-9" : "w-14 px-1 py-1.5", active ? "bg-signal/12 text-fg [&_svg]:text-signal" : "hover:bg-raised hover:text-fg", disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-fg-muted", focusRing);
487
+ let item;
488
+ if (asChild && isValidElement(children)) {
489
+ const own = children.props;
490
+ item = cloneElement(children, {
491
+ ...shared,
492
+ "aria-disabled": disabled ? true : void 0,
493
+ className: cn(classes, className, own.className),
494
+ onClick: (event) => {
495
+ own.onClick?.(event);
496
+ if (disabled) {
497
+ event.preventDefault();
498
+ return;
499
+ }
500
+ if (!event.defaultPrevented) rail.choose(value);
501
+ },
502
+ children: content
503
+ });
504
+ } else item = /* @__PURE__ */ jsx("button", {
505
+ type: "button",
506
+ ...shared,
507
+ disabled,
508
+ onClick: () => rail.choose(value),
509
+ className: cn(classes, className),
510
+ children: content
511
+ });
512
+ return /* @__PURE__ */ jsx("li", { children: iconOnly ? /* @__PURE__ */ jsx(Tooltip, {
513
+ content: label,
514
+ children: item
515
+ }) : item });
516
+ }
517
+ /** A badge count: up to 99 as is, more as "99+". */
518
+ function formatCount(count) {
519
+ return count > 99 ? "99+" : String(count);
520
+ }
521
+ //#endregion
383
522
  //#region src/components/treeModel.ts
384
523
  /**
385
524
  * The rows a reader can see: every root, and the children of every expanded parent, in
@@ -1389,8 +1528,11 @@ function stepIndex(length, index, delta, wrap = false) {
1389
1528
  * ("3 / 50").
1390
1529
  *
1391
1530
  * 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.
1531
+ * and is scrolled into view when it changes. An item with a `status` shows a dot in its
1532
+ * corner, carries `data-status` (the tone) and is named `"label, status"`. `[` and `]` step
1533
+ * from anywhere outside a text field. Thumbnails load lazily, so a capture of thousands of
1534
+ * frames opens at once. The strip is as wide as its thumbnails, so previous and next stay
1535
+ * beside a short sequence; a long one scrolls.
1394
1536
  */
1395
1537
  function SequenceNavigator({ items, value, onValueChange, renderThumbnail, keys = true, wrap = false, "aria-label": ariaLabel, className }) {
1396
1538
  const index = items.findIndex((item) => item.id === value);
@@ -1437,31 +1579,37 @@ function SequenceNavigator({ items, value, onValueChange, renderThumbnail, keys
1437
1579
  /* @__PURE__ */ jsx("ol", {
1438
1580
  ref: listRef,
1439
1581
  "aria-label": ariaLabel,
1440
- className: "flex min-w-0 flex-1 gap-1 overflow-x-auto py-1",
1582
+ className: "flex min-w-0 scroll-px-1 gap-1 overflow-x-auto p-1",
1441
1583
  children: items.map((item) => {
1442
1584
  const current = item.id === value;
1585
+ const { status } = item;
1586
+ const name = status ? `${item.label}, ${status.label}` : item.label;
1443
1587
  return /* @__PURE__ */ jsx("li", {
1444
1588
  className: "shrink-0",
1445
- children: /* @__PURE__ */ jsx("button", {
1589
+ children: /* @__PURE__ */ jsxs("button", {
1446
1590
  type: "button",
1447
- title: item.label,
1448
- "aria-label": item.label,
1591
+ title: name,
1592
+ "aria-label": name,
1449
1593
  "aria-current": current ? "true" : void 0,
1450
1594
  "data-current": current ? "" : void 0,
1595
+ "data-status": status?.tone,
1451
1596
  onClick: () => {
1452
1597
  if (!current) onValueChange(item.id);
1453
1598
  },
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", {
1599
+ className: cn("relative 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),
1600
+ children: [renderThumbnail ? renderThumbnail(item) : item.thumbnail ? /* @__PURE__ */ jsx("img", {
1456
1601
  src: item.thumbnail,
1457
1602
  alt: "",
1458
1603
  loading: "lazy",
1459
1604
  decoding: "async",
1460
1605
  className: "h-full w-full object-cover"
1461
1606
  }) : /* @__PURE__ */ jsx("span", {
1462
- className: "block truncate px-1 font-mono text-[10px]",
1607
+ className: cn("block truncate px-1 font-mono text-[10px]", status && "pr-3"),
1463
1608
  children: item.label
1464
- })
1609
+ }), status && /* @__PURE__ */ jsx(StatusDot, {
1610
+ tone: status.tone,
1611
+ className: "absolute top-0.5 right-0.5 rounded-full bg-surface p-0.5"
1612
+ })]
1465
1613
  })
1466
1614
  }, item.id);
1467
1615
  })
@@ -1497,6 +1645,104 @@ function isTypingTarget(target) {
1497
1645
  return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable;
1498
1646
  }
1499
1647
  //#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 };
1648
+ //#region src/components/stepperModel.ts
1649
+ /**
1650
+ * Each step's state, in order.
1651
+ *
1652
+ * The step whose id is `current` is `current`, whatever else is true of it: the app put the
1653
+ * person there. Of the others, one with a `blockedBy` reason is `blocked` (even if `complete`:
1654
+ * a step can be done and then fall behind a newer gate), then `complete`, then `upcoming`.
1655
+ * Only a step that is neither current nor blocked can be activated.
1656
+ *
1657
+ * @param steps - The steps, in order.
1658
+ * @param current - The current step's id, or `null` for none.
1659
+ */
1660
+ function stepStates(steps, current) {
1661
+ return steps.map(({ id, blockedBy, complete }) => {
1662
+ const state = id === current ? "current" : blockedBy ? "blocked" : complete ? "complete" : "upcoming";
1663
+ return {
1664
+ id,
1665
+ state,
1666
+ canActivate: state === "complete" || state === "upcoming"
1667
+ };
1668
+ });
1669
+ }
1670
+ //#endregion
1671
+ //#region src/components/Stepper.tsx
1672
+ /**
1673
+ * The steps of a gated sequence as an ordered list of buttons, numbered, with the current one
1674
+ * marked (`aria-current="step"`) and done ones checked. Controlled with `value` and
1675
+ * `onValueChange`, or kept by the stepper from `defaultValue`.
1676
+ *
1677
+ * A step with `blockedBy` is blocked: it keeps its Tab stop but carries `aria-disabled`, its
1678
+ * reason is its description (`aria-describedby`) and its tooltip, and choosing it does nothing.
1679
+ * Each step carries `data-state` (`current`, `complete`, `blocked` or `upcoming`), and the
1680
+ * list `data-orientation`.
1681
+ */
1682
+ function Stepper({ steps, value, defaultValue, onValueChange, orientation = "horizontal", "aria-label": ariaLabel, className }) {
1683
+ const [kept, setKept] = useState(() => defaultValue ?? steps[0]?.id ?? null);
1684
+ const views = stepStates(steps, value === void 0 ? kept : value);
1685
+ const baseId = useId();
1686
+ const vertical = orientation === "vertical";
1687
+ const choose = (id) => {
1688
+ if (value === void 0) setKept(id);
1689
+ onValueChange?.(id);
1690
+ };
1691
+ return /* @__PURE__ */ jsx("ol", {
1692
+ "aria-label": ariaLabel,
1693
+ "data-orientation": orientation,
1694
+ className: cn("flex", vertical ? "flex-col items-start" : "flex-wrap items-center gap-y-1", className),
1695
+ children: steps.map((step, index) => {
1696
+ const view = views[index];
1697
+ if (view === void 0) return null;
1698
+ const { state, canActivate } = view;
1699
+ const blocked = state === "blocked";
1700
+ const reasonId = `${baseId}-${index}-reason`;
1701
+ const button = /* @__PURE__ */ jsxs("button", {
1702
+ type: "button",
1703
+ "aria-current": state === "current" ? "step" : void 0,
1704
+ "aria-disabled": blocked ? true : void 0,
1705
+ "aria-describedby": blocked ? reasonId : void 0,
1706
+ "data-state": state,
1707
+ onClick: () => {
1708
+ if (canActivate) choose(step.id);
1709
+ },
1710
+ className: cn("flex items-center gap-2 rounded-control px-1.5 py-1 text-sm transition-colors", state === "current" ? "font-medium text-fg" : "text-fg-muted", canActivate && "hover:text-fg", blocked && "cursor-not-allowed", focusRing),
1711
+ children: [/* @__PURE__ */ jsx(StepMarker, {
1712
+ state,
1713
+ number: index + 1
1714
+ }), /* @__PURE__ */ jsx("span", { children: step.label })]
1715
+ });
1716
+ return /* @__PURE__ */ jsxs("li", {
1717
+ className: cn("flex", vertical ? "flex-col items-start" : "items-center"),
1718
+ children: [
1719
+ index > 0 && /* @__PURE__ */ jsx("span", {
1720
+ "aria-hidden": true,
1721
+ className: cn("bg-line-strong", vertical ? "ml-4 h-3 w-px" : "mx-1 h-px w-6")
1722
+ }),
1723
+ blocked ? /* @__PURE__ */ jsx(Tooltip, {
1724
+ content: step.blockedBy,
1725
+ children: button
1726
+ }) : button,
1727
+ blocked && /* @__PURE__ */ jsx("span", {
1728
+ id: reasonId,
1729
+ className: "sr-only",
1730
+ children: step.blockedBy
1731
+ })
1732
+ ]
1733
+ }, step.id);
1734
+ })
1735
+ });
1736
+ }
1737
+ /** The step's number in a circle; a check when done, a lock when blocked. Decorative. */
1738
+ function StepMarker({ state, number }) {
1739
+ return /* @__PURE__ */ jsx("span", {
1740
+ "aria-hidden": true,
1741
+ className: cn("grid size-5 shrink-0 place-items-center rounded-full border font-mono text-[11px] tabular-nums [&>svg]:size-3", state === "current" && "border-signal bg-signal text-signal-fg", state === "complete" && "border-signal text-signal", state === "blocked" && "border-line-strong text-fg-muted", state === "upcoming" && "border-line-strong text-fg-muted"),
1742
+ children: state === "complete" ? /* @__PURE__ */ jsx(Check, {}) : state === "blocked" ? /* @__PURE__ */ jsx(Lock, {}) : number
1743
+ });
1744
+ }
1745
+ //#endregion
1746
+ export { AppShell, DEFAULT_SPEEDS, FileDrop, NavRail, NavRailItem, PlaybackBar, SequenceNavigator, SplitPane, StatusBar, Stepper, Toaster, TreeView, acceptsFile, acceptsPath, advance, ancestorIds, clampIndex, clampSize, collectDroppedFiles, createPlayhead, createToastStore, defaultToastStore, formatSeconds, parentIds, resolveLimits, resolveSize, stepIndex, stepStates, toast, treeKeyAction, usePlaybackClock, usePlayhead, usePlayheadTimeline, visibleRows };
1501
1747
 
1502
1748
  //# sourceMappingURL=index.js.map