strata-react 1.0.6 → 1.0.9

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
@@ -134,6 +134,9 @@ function KilnRoom() {
134
134
  | Overlays | `Dialog`, `DialogProps`, `AlertDialog`, `Popover`, `Tooltip` | React Aria underneath. A dialog always has a title and, via `actions`'s close render prop, a way out; `closable={false}` while work cannot stop; `placement="end"` is a sheet. `AlertDialog` is the only confirm: required verb on the confirm button, Cancel focused first, no outside dismiss, stays open with the reason when an async confirm fails. `Popover` needs a `label`. `Tooltip` opens on hover and focus and `IconButton` uses it. All portal onto the `layer-*` stacking utilities |
135
135
  | Value controls | `NumberField`, `Slider`, `ColorField` | Set a number or colour precisely, inside `Field`. `NumberField` and `Slider` are React Aria's; the number field runs with `commitBehavior="validate"`, so a typed value outside `min`/`max` is kept on screen, explained in the `Field` ("Enter a value from 0% to 500%.") and never passed to `onChange`. A value that is not known is `null` and shows an en dash, never 0 or NaN. Digits and decimal mark follow `locale`. The unit sits inside the control, and in the slider's spoken value when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). Arrows step, Home/End jump to the limits; `Slider editable` adds a number field. `ColorField`: platform picker, typed hex that is normalised, app suggestions, and a contrast note against `against`. No motion on value changes |
136
136
  | Notices and progress | `Alert`, `toast`, `StrataToastRegion`, `useClientWork`, `JobStatus` | Three weights. A `toast` confirms finished work and goes by itself (5 s plus 40 ms a character, 8 s minimum with an action, paused under the pointer or focus, always dismissable); it has no danger tone, because an error a person must act on is an inline `Alert` with its recovery as `action` (`announce` makes it `role="alert"` only when it answers something the person just did). `StrataToastRegion` goes once at the app root. `useClientWork` runs browser work with progress, cancel (aborts its `signal`, ends `cancelled`, never `failed`) and a double-start guard; `JobStatus` shows it exactly as it shows a server job, with `onCancel`, `cancelled` and `onDismiss` |
137
+ | Timeline | `Timeline`, `useTimelineZoom`, `TimelineZoomControls`, `noOverlap` | Items with a start and a length in lanes on a zoomable time axis, for media edits, bookings, rotas and plans. The timeline draws and the app decides: every move, trim, lane change, selection and current-time change is reported (`onItemChange`, `onSelect`, `onPositionChange`) and the app applies it; `validate` refuses a change with a reason shown in words while it is made. One tab stop for the items; arrows move between them, Ctrl+arrows nudge and change lane, Alt+arrows trim, the current time is its own slider, `+` `-` `0` zoom, and each change is announced ("run-02.mp4 moved to 0:13"). The ruler picks steps people write on a scale so labels never collide. Only items near the view are rendered |
138
+ | Sortable list | `SortableList` | Reorder a list and move items between lists, by pointer and by keyboard. React Aria's `GridList` with `useDragAndDrop` (no `@dnd-kit`): a grip per row is the drag handle, so clicking a row selects it and its own actions still work; Enter on the grip picks up, arrows and Tab choose a position or list, Enter drops, Escape cancels, with React Aria's screen-reader announcements. Items carry a kind (`getKind`); a list takes the kinds in `accepts` and says why it refuses another (`refuses`, shown with an icon while that kind is dragged over it). The list never changes the data: `onReorder` and `onInsert` report the move and the app applies it, undoably |
139
+ | File intake | `FileButton`, `FileDropZone`, `FileOutcomes`, `MissingFile`, `useFileIntake` | Pick or drop local files, then one outcome per file. `FileButton` is React Aria's `FileTrigger` behind a real named button (the keyboard and phone route); `FileDropZone` is its `DropZone` and says what it takes while a drag is over it. `useFileIntake({ accept, acceptLabel, process })` judges each file after the drop, so a wrong one is named with its reason (type, `maxBytes`, your `check`), runs your own `process` per file (a throw becomes `Failed` with its message and a retry), and never blocks the rest. `FileOutcomes` draws the rows and announces one summary per batch. `MissingFile` is a status word and a "Relink" that opens the picker for that item. Nothing assumes a server |
137
140
  | Inspector | `Inspector`, `InspectorSection`, `PropertyRow`, `PropertyList` | Properties of the selected thing. `Inspector` is a labelled region with the selection's name as its heading and the empty state (`empty`, required) when `title` is `null`; `selectionKey` gives a new selection fresh controls and keeps focus in the panel. `InspectorSection` is React Aria's `Disclosure` with the body mounted only while open; open and closed are remembered under `storageKey` (storage that throws just means defaults). `PropertyRow` is a `Field` with a "Reset <label>" that shows only while `modified`. `PropertyList` is a `dl`: missing values print an en dash heard as "Not known", units follow a non-breaking space, long values truncate with the whole value in a tooltip |
138
141
  | Feedback | `UndoBar`, `useUndoable`, `Done` | Undo before confirm; the hook owns which rows are out of view (`isRemoved`), a failed commit brings the row back with Try again in the same bar, and `flush()` commits before a dependent action; `Done` is the one celebration, and it must say what happens next |
139
142
  | Helpers | `cn`, `format`, `createFormat`, `NBSP` | `cn` knows `type-*`; all numbers and dates through `Intl`; `format.integer(n)`, `.decimal(n)`, `.percent(n)` are callable and keep Intl's methods; `format.bytes(n, unit?)` writes sizes in decimal units (`byteUnit` shares one unit across figures); `format.date(at)` ("8 Nov 2026") and `format.dateTime(at)` ("8 Nov 2026, 06:05"), like `clock`, `day` and `shortDay`, take a Date, ISO string or epoch ms; `format.ago(at, now?)` ("3 weeks ago"), `format.compact(n)` ("1.2k", and `count(n, one, many, { compact: true })`), `format.runningTime(seconds)` ("1:02:09") and `format.share(n)` ("<1%" for a part that rounds to 0); every number and date formatter prints the placeholder (`format.missing`, an en dash) for `null` or `undefined`; `createFormat(locale, { timeZone, missing })` fixes the zone and the placeholder; units and counts join with a non-breaking space |
@@ -0,0 +1,40 @@
1
+ import { FileIntake } from '../lib/file-intake';
2
+ import { IconComponent } from '../lib/icon';
3
+ import { ButtonProps } from './button';
4
+ import * as React from "react";
5
+ /** The picker as a button. `children` is its visible name ("Add files"); `accept` narrows what the dialog shows. */
6
+ export declare function FileButton({ accept, multiple, onFiles, icon: Icon, children, ...props }: Omit<ButtonProps, "onChange" | "children"> & {
7
+ /** What the dialog offers: extensions (`.gpx`), exact types or families (`video/*`). */
8
+ accept: readonly string[];
9
+ multiple?: boolean;
10
+ /** Called with the files chosen. Not called when the dialog is cancelled. */
11
+ onFiles: (files: File[]) => void;
12
+ icon?: IconComponent;
13
+ children: string;
14
+ }): React.JSX.Element;
15
+ /** A region that takes dropped files and offers the picker as its keyboard alternative. */
16
+ export declare function FileDropZone({ onFiles, acceptLabel, title, disabled, children, className, }: {
17
+ onFiles: (files: File[]) => void;
18
+ /** What it takes, in words ("a video, an audio file or a GPX track"). Shown while a drag is over it. */
19
+ acceptLabel: string;
20
+ /** The resting prompt ("Drag files here"). */
21
+ title: string;
22
+ disabled?: boolean;
23
+ /** The `FileButton` (required in practice: it is how a keyboard or phone gets files in). */
24
+ children?: React.ReactNode;
25
+ className?: string;
26
+ }): React.JSX.Element;
27
+ /** One row per file offered: its name, a status word, and for a rejected or failed file the reason and (for failed) a retry. Announces a summary politely when a batch finishes. */
28
+ export declare function FileOutcomes({ intake, className }: {
29
+ intake: FileIntake;
30
+ className?: string;
31
+ }): React.JSX.Element;
32
+ /** A saved item whose file is gone: the item's name, a "File missing" status (a word and an icon) and a "Relink" button that opens the picker for this one item. */
33
+ export declare function MissingFile({ name, accept, onRelink, className, }: {
34
+ /** The item's name as the person knows it ("run-02.mp4"). */
35
+ name: string;
36
+ accept: readonly string[];
37
+ /** Called with the file the person chose to stand in for it. */
38
+ onRelink: (file: File) => void;
39
+ className?: string;
40
+ }): React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ /** Where a drop landed, relative to the item with `key`. */
3
+ export type DropTarget = {
4
+ key: string;
5
+ position: "before" | "after" | "on";
6
+ } | {
7
+ key: null;
8
+ position: "root";
9
+ };
10
+ export type SortableListProps<T> = {
11
+ /** Names the list ("Tracks"). Required. */
12
+ label: string;
13
+ items: readonly T[];
14
+ getKey: (item: T) => string;
15
+ /** The item's name for a screen reader, typeahead and announcements ("Picked up Moonbeam bowl"). */
16
+ getLabel: (item: T) => string;
17
+ /** The row's content, beside the grip. Plain text and marks; actions go in `renderActions`. */
18
+ children: (item: T) => React.ReactNode;
19
+ /** Controls for the row (a `RowAction`), outside the row's selection target. */
20
+ renderActions?: (item: T) => React.ReactNode;
21
+ /** Shown when the list is empty, and "Drop here" while something is dragged over it. */
22
+ empty: React.ReactNode;
23
+ /** The item was moved within this list: `keys` now sit at `target`. */
24
+ onReorder: (keys: string[], target: DropTarget) => void;
25
+ /** An item of another list was dropped here. The app finds it by id and moves it. Needs `accepts`. */
26
+ onInsert?: (ids: string[], target: DropTarget) => void;
27
+ /** What an item is, for deciding which lists take it. Default: every item is "item". */
28
+ getKind?: (item: T) => string;
29
+ /** Kinds this list takes from other lists. Default none: it only reorders. */
30
+ accepts?: readonly string[];
31
+ /** Why a kind is refused, in the product's words, shown while one is dragged over: `{ text: "Tracks take video and audio, not text clips." }`. React Aria cannot list what is being dragged, only ask about a kind, so name the kinds that exist. */
32
+ refuses?: Readonly<Record<string, string>>;
33
+ selectionMode?: "none" | "single" | "multiple";
34
+ selectedKeys?: ReadonlySet<string>;
35
+ onSelectionChange?: (keys: Set<string>) => void;
36
+ className?: string;
37
+ };
38
+ /** A list that reorders by drag and by keyboard, and takes items from other lists by kind. It reports what was asked and never changes the data itself. */
39
+ export declare function SortableList<T>({ label, items, getKey, getLabel, children, renderActions, empty, onReorder, onInsert, getKind, accepts, refuses, selectionMode, selectedKeys, onSelectionChange, className, }: SortableListProps<T>): React.JSX.Element;
@@ -0,0 +1,98 @@
1
+ import * as React from "react";
2
+ export type TimelineItem = {
3
+ id: string;
4
+ /** The lane's id. */
5
+ lane: string;
6
+ start: number;
7
+ length: number;
8
+ /** The item's name, in the item and for a screen reader. */
9
+ label: string;
10
+ /** What kind of thing it is (video, audio, booking). Shown as a word and a colour stripe, never colour alone. */
11
+ kind?: string;
12
+ };
13
+ export type TimelineLane = {
14
+ id: string;
15
+ label: string;
16
+ /** The app's controls for the lane (mute, lock, delete). Drawn in the lane's header, at the left. */
17
+ header?: React.ReactNode;
18
+ };
19
+ export type TimelineMarker = {
20
+ id: string;
21
+ time: number;
22
+ label: string;
23
+ };
24
+ /** What a move or trim would produce. */
25
+ export type TimelineChange = {
26
+ start: number;
27
+ length: number;
28
+ lane: string;
29
+ };
30
+ export type TimelineProps = {
31
+ /** Names the timeline for a screen reader ("Firing schedule"). */
32
+ label: string;
33
+ lanes: readonly TimelineLane[];
34
+ items: readonly TimelineItem[];
35
+ /** The axis runs from this time. Default 0. */
36
+ from?: number;
37
+ /** ... to this time. */
38
+ to: number;
39
+ /** Pixels per unit of time. Controlled with `onZoomChange`. */
40
+ zoom: number;
41
+ onZoomChange?: (zoom: number) => void;
42
+ /** The current time, drawn as a rule across the lanes and set by the slider on the ruler. */
43
+ position?: number;
44
+ onPositionChange?: (time: number) => void;
45
+ /** Keep the current time in view as it advances. */
46
+ follow?: boolean;
47
+ markers?: readonly TimelineMarker[];
48
+ selectedIds?: ReadonlySet<string>;
49
+ /** The selection changed: `ids` is the whole new selection. */
50
+ onSelect?: (ids: string[]) => void;
51
+ /** The item was moved, trimmed or put in another lane. Not called for a change `validate` refused. */
52
+ onItemChange?: (id: string, next: TimelineChange) => void;
53
+ /** The person asked to remove the selection (Delete). The app does it, undoably. */
54
+ onDelete?: (ids: string[]) => void;
55
+ /** A reason a change cannot be made, in the product's words, or `null`. Called while dragging, so keep it cheap. */
56
+ validate?: (id: string, next: TimelineChange) => string | null;
57
+ /** Extra times items snap to, besides the edges of other items, markers and the current time. */
58
+ snapPoints?: readonly number[];
59
+ /** Turn snapping off. Default on. */
60
+ snap?: boolean;
61
+ /** One keyboard step, in time units. Default 1. */
62
+ step?: number;
63
+ /** Smallest an item may be, in time units. Default `step`. */
64
+ minLength?: number;
65
+ /** Draws an item's content (a strip of thumbnails, a waveform). Default: the label and kind. */
66
+ renderItem?: (item: TimelineItem, state: {
67
+ selected: boolean;
68
+ width: number;
69
+ }) => React.ReactNode;
70
+ /** A time as words ("0:14", "13:30"). Default `m:ss`, with tenths on the ruler when zoomed far in. Also labels the ruler when given, so a schedule in hours reads as clock times. */
71
+ formatTime?: (time: number) => string;
72
+ /** Shown instead of the lanes' area when there are no lanes. */
73
+ empty?: React.ReactNode;
74
+ className?: string;
75
+ };
76
+ /** Zoom state for a timeline: `zoomIn`, `zoomOut`, and `fit` to a viewport width. Pass `zoom` and `setZoom` as the timeline's `zoom` and `onZoomChange`. */
77
+ export declare function useTimelineZoom({ initial, min, max }?: {
78
+ initial?: number;
79
+ min?: number;
80
+ max?: number;
81
+ }): {
82
+ zoom: number;
83
+ setZoom: (z: number) => void;
84
+ zoomIn: () => void;
85
+ zoomOut: () => void;
86
+ /** Zoom so `duration` fills `viewportWidth` pixels. */
87
+ fit: (viewportWidth: number, duration: number) => void;
88
+ };
89
+ /** Zoom in, zoom out and fit, as named icon buttons for a timeline's toolbar. */
90
+ export declare function TimelineZoomControls({ zoom }: {
91
+ zoom: Pick<ReturnType<typeof useTimelineZoom>, "zoomIn" | "zoomOut"> & {
92
+ fit: () => void;
93
+ };
94
+ }): React.JSX.Element;
95
+ /** A rule that refuses an item overlapping another in its lane, for `validate`: names the item in the way. */
96
+ export declare function noOverlap(items: readonly TimelineItem[]): (id: string, next: TimelineChange) => string | null;
97
+ /** Items placed on a zoomable time axis in lanes, with a current-time rule and markers. Reports every move, trim, selection and time change; the app applies them. Keyboard-complete, and only the items near the view are rendered. */
98
+ export declare function Timeline({ label, lanes, items, from, to, zoom, onZoomChange, position, onPositionChange, follow, markers, selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints, snap, step, minLength, renderItem, formatTime, empty, className, }: TimelineProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -34,6 +34,11 @@ export { useClientWork, type ClientWork, type WorkContext, type WorkPhase } from
34
34
  export { JobStatus, type JobStatusProps, type JobFailure, type JobWords } from './components/job-status';
35
35
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
36
36
  export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
37
+ export { Timeline, TimelineZoomControls, useTimelineZoom, noOverlap, type TimelineProps, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelineChange } from './components/timeline';
38
+ export { tickStep, ticksBetween, tickLabel } from './lib/timeline';
39
+ export { SortableList, type SortableListProps, type DropTarget } from './components/sortable-list';
40
+ export { FileButton, FileDropZone, FileOutcomes, MissingFile } from './components/file-intake';
41
+ export { useFileIntake, matchesAccept, type FileIntake, type FileIntakeOptions, type FileOutcome } from './lib/file-intake';
37
42
  export { Inspector, InspectorSection, PropertyRow, PropertyList, type InspectorProps, type InspectorSectionProps, type PropertyRowProps, type Property, type PropertyListProps } from './components/inspector';
38
43
  export { Disclosure, useExpanded, type DisclosureProps, type DisclosureOpenProps, type Expanded, type ExpandedOptions } from './components/disclosure';
39
44
  export { BulkBar, useSelection, type InitialSelection } from './components/selection';