strata-react 1.0.7 → 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 +2 -0
- package/dist/components/sortable-list.d.ts +39 -0
- package/dist/components/timeline.d.ts +98 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +787 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/timeline.d.ts +14 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -134,6 +134,8 @@ 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 |
|
|
137
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 |
|
|
138
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 |
|
|
139
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 |
|
|
@@ -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,9 @@ 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';
|
|
37
40
|
export { FileButton, FileDropZone, FileOutcomes, MissingFile } from './components/file-intake';
|
|
38
41
|
export { useFileIntake, matchesAccept, type FileIntake, type FileIntakeOptions, type FileOutcome } from './lib/file-intake';
|
|
39
42
|
export { Inspector, InspectorSection, PropertyRow, PropertyList, type InspectorProps, type InspectorSectionProps, type PropertyRowProps, type Property, type PropertyListProps } from './components/inspector';
|