strata-react 1.0.42 → 1.0.43
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 +1 -1
- package/UPGRADING.md +5 -0
- package/dist/components/book-viewer.d.ts +50 -0
- package/dist/components/box-overlay.d.ts +42 -0
- package/dist/components/conversation.d.ts +3 -1
- package/dist/components/lightbox.d.ts +28 -1
- package/dist/components/line-chart.d.ts +7 -1
- package/dist/components/region-editor.d.ts +14 -2
- package/dist/components/selectable-grid.d.ts +2 -4
- package/dist/components/tile-grid.d.ts +57 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1150 -205
- package/dist/index.js.map +1 -1
- package/dist/lib/book.d.ts +25 -0
- package/dist/lib/boxes.d.ts +32 -0
- package/dist/lib/region.d.ts +18 -0
- package/dist/{run-DEf1Vh0x.js → run-DE65qInG.js} +22 -2
- package/dist/run-DE65qInG.js.map +1 -0
- package/dist/visual/serve.d.ts +2 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/run-DEf1Vh0x.js.map +0 -1
package/README.md
CHANGED
|
@@ -174,7 +174,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
174
174
|
| Streams | `MediaPlayer attach`/`growing`, `useAttachedSource`, `attachHls` (`strata-react/hls`) | A source the element cannot play is attached by an engine; a source still being made says so, shows what exists as ready, and waits at its end without ending |
|
|
175
175
|
| 360 | `PanoramaViewer` (`strata-react/panorama`), `project`, `unproject`, `describeView` | A 360 picture or video as a controlled window (yaw, pitch, field of view), drag, wheel, pinch and keys, an overlay in the picture's coordinates, said in words, a flat fallback with no WebGL2 |
|
|
176
176
|
| Conversation | `Conversation`, `Composer`, `RichText`; `matchEntities`, `parseRichText` | A question-and-answer thread: answers stream, finish or fail in place (Try again), one polite announcement per finished answer, following only while at the bottom (Jump to latest); a composer that sends on Enter and is disabled with its reason while answering (Stop); a safe text subset (bold, code, lists, http links, never HTML) whose known ids, longest first and whole words only, become buttons |
|
|
177
|
-
| Pictures from a set | `Lightbox`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40", zoom and 1:1, details beside it, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); named windows drawn and moved on a picture by pointer, keys and numbers, with aspect and bounds held, and a from/to move with a Watch preview |
|
|
177
|
+
| Pictures from a set | `Lightbox` (`useLightboxUrl`), `BookViewer` (`useBookUrl`), `TileGrid`, `BoxOverlay`/`BoxList`/`useBoxes`, `RegionEditor`; `moveRect`, `resizeRect`, `lerpRect`, `turnedSize`, `turnRect`, `readingOrder`, `zoomToBox`, `findPage` | A picture opened from a grid in a full-size `Dialog` (previous/next, arrow keys, "3 of 40" or a position like "Page 22 (12) of 44", zoom and 1:1, details beside it, an overlay and actions for the item, a thumbnail strip, `?view=` in the URL, neighbours preloaded, a `missing` sentence, Compare ticked hand-off); a scanned book read inline as spreads or single pages with printed and scan names, go-to, `?page=` and a strip with badges; a grid of picture tiles that link (`TileGrid`, with `TileGridSkeleton`); read-only boxes on a picture linked to a list beside it; `RegionEditor` also turns the picture by an angle (the windows turn with it) and edits a spread's gutter; named windows drawn and moved on a picture by pointer, keys and numbers, with aspect and bounds held, and a from/to move with a Watch preview |
|
|
178
178
|
| Sequences | `SequenceTimeline`; `snapToGrid`, `stepOnGrid`, `settleCut` | A gapless strip of windows whose cuts are sliders: dragged or stepped along a beat grid inside the room the app gives, the refusal said in words, both windows' new lengths announced; Shift+click chooses a run |
|
|
179
179
|
| Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (a hook per open node; skeleton, Try again and empty rows; always virtualised); `choices` (from `useChoices`) chooses several: a checkbox per row, Shift ranges, a parent drawn mixed from what has loaded under it (ticking a branch never opened reads and opens it and chooses everything under it), "Select all shown", and rows the choice implies marked "Included because of …" in words and a server folder chooser on it: breadcrumb that is also editable text, Up, recents, New folder with the server's refusal on the field, Choose this folder; a `Folder` may carry a `badge` and `tone` ("project", as words), `canChoose` gives the reason the button is disabled beside it, `chooseLabel` names it, `onOpen` can answer `"choose"` to take a folder at once instead of entering it, and the listing may return a `footer` under the tree |
|
|
180
180
|
| Marking text | `MarkableText`, `Mark`, `MarkSummary`; `rangeBetween` | Select words by drag, Shift+click and Shift+arrows (ids in document order, so it holds across virtualised rows), apply the app's marks from a bar or single-key chords, marks drawn by role, pattern and text, summarised and announced |
|
package/UPGRADING.md
CHANGED
|
@@ -11,6 +11,11 @@ time. While the version is 0.x, any release may break.
|
|
|
11
11
|
|
|
12
12
|
Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
|
|
13
13
|
|
|
14
|
+
## After v1.0.42 (2026-11-14)
|
|
15
|
+
|
|
16
|
+
- `strata-visual` serves an app build's `index.html` with `<base href="/">` (the target's `base`) added when the page has no base tag, as python-app-template's server does, so a build with `base: './'` finds its assets on a nested route; drop a `visual` Vite mode that injected the tag yourself (it is left alone if the page already has one).
|
|
17
|
+
- A shot now fails when a script or stylesheet request returns 4xx/5xx or HTML. A route that used to write an empty baseline because its assets never loaded fails now: fix the build or the server, then run `test:visual:update` and look at the diff.
|
|
18
|
+
|
|
14
19
|
## After v1.0.40 (2026-11-13 to 2026-11-14)
|
|
15
20
|
|
|
16
21
|
- Two `StrataToastRegion`s mounted at once no longer draw every toast twice: the first mounted draws and a second draws nothing (and warns in development, naming `renderRoutes(..., { toasts: false })`). A test that worked around the doubling with `findAllByText` can use `findByText`; an app with a region in a layout and another in a page loses the page's.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** One page of the book. */
|
|
3
|
+
export type BookPage = {
|
|
4
|
+
id: string;
|
|
5
|
+
src: string;
|
|
6
|
+
/** What the page shows, for assistive technology: "Page 22 of the Punch book". Required. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Its position in the scan, as a person counts: "22". */
|
|
9
|
+
scan: string;
|
|
10
|
+
/** What is printed on it: "12", "iv", or a running head. Pages with none have only their scan position. */
|
|
11
|
+
printed?: string;
|
|
12
|
+
/** A small picture for the strip. Default `src`. */
|
|
13
|
+
thumb?: string;
|
|
14
|
+
/** Its natural size in pixels, for 1:1 and the frame's shape. */
|
|
15
|
+
natural?: readonly [number, number];
|
|
16
|
+
};
|
|
17
|
+
export type BookViewerProps = {
|
|
18
|
+
/** Names the book: "The Play of Punch and Judy". */
|
|
19
|
+
label: string;
|
|
20
|
+
pages: readonly BookPage[];
|
|
21
|
+
/** The page being read (any page of a spread), as an index into `pages`. */
|
|
22
|
+
index: number;
|
|
23
|
+
onIndexChange: (index: number) => void;
|
|
24
|
+
/** What shows in place of a page that did not load, in words. Required. */
|
|
25
|
+
missing: string;
|
|
26
|
+
/** `"spread"` (default) shows facing pages when there is room; `"single"` always one. */
|
|
27
|
+
layout?: "spread" | "single";
|
|
28
|
+
/** Beside the pages (under them when narrow): the pages shown, for the transcript pane. */
|
|
29
|
+
side?: (shown: readonly BookPage[]) => React.ReactNode;
|
|
30
|
+
sideLabel?: string;
|
|
31
|
+
/** In the corner of a page's thumbnail: a `Status` ("Look") for the pages that need a look. */
|
|
32
|
+
badge?: (page: BookPage) => React.ReactNode;
|
|
33
|
+
/** A layer inside a page's zoomable frame, in the page's own pixels (`natural` once known): a `BoxOverlay`. */
|
|
34
|
+
overlay?: (page: BookPage, natural: readonly [number, number] | null) => React.ReactNode;
|
|
35
|
+
/** The thumbnail strip under the pages. Default true. */
|
|
36
|
+
strip?: boolean;
|
|
37
|
+
/** Width over height of a page before it loads. Default 2:3. */
|
|
38
|
+
aspect?: number;
|
|
39
|
+
/** What a page is called: "Page" (default), or "Leaf", "Folio". */
|
|
40
|
+
word?: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
};
|
|
43
|
+
/** What `useBookUrl` returns: the `index` and `onIndexChange` a `BookViewer` takes. */
|
|
44
|
+
export type BookUrl = Pick<BookViewerProps, "index" | "onIndexChange">;
|
|
45
|
+
/** Keeps the page being read in the URL (`?page=22`, the 1-based position in the scan): a link or a reload opens it, and turning pages replaces the entry so Back leaves the book. */
|
|
46
|
+
export declare function useBookUrl(count: number, { param }?: {
|
|
47
|
+
param?: string;
|
|
48
|
+
}): BookUrl;
|
|
49
|
+
/** A scanned book read as a book: facing pages (the first alone on the right) or one page, printed and scan names with a go-to that takes either, arrows, Page Up/Down, Home/End and a click on a page's outer half, the position in the URL and in words, a thumbnail strip with badges, an optional text pane. */
|
|
50
|
+
export declare function BookViewer({ label, pages, index, onIndexChange, missing, layout, side, sideLabel, badge, overlay, strip, aspect, word, className }: BookViewerProps): React.JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PictureBox } from '../lib/boxes';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/** Where the last choice was made, so the other part can follow it (focus moves to the list only when the picture chose). */
|
|
4
|
+
export type BoxSource = "list" | "picture";
|
|
5
|
+
/** The state `BoxOverlay` and `BoxList` share. */
|
|
6
|
+
export type BoxesState = {
|
|
7
|
+
/** The chosen box's id. */
|
|
8
|
+
active: string | null;
|
|
9
|
+
/** The box under the pointer or being tabbed to, in either part. */
|
|
10
|
+
pointed: string | null;
|
|
11
|
+
source: BoxSource | null;
|
|
12
|
+
choose: (id: string | null, from?: BoxSource) => void;
|
|
13
|
+
point: (id: string | null) => void;
|
|
14
|
+
};
|
|
15
|
+
/** Holds the active and pointed box for a `BoxOverlay` and the `BoxList` beside it. */
|
|
16
|
+
export declare function useBoxes(initial?: string | null): BoxesState;
|
|
17
|
+
export type BoxOverlayProps = {
|
|
18
|
+
/** Names the layer: "Lines the reader found". */
|
|
19
|
+
label: string;
|
|
20
|
+
/** The picture's size in pixels; the boxes are in these units. */
|
|
21
|
+
of: {
|
|
22
|
+
w: number;
|
|
23
|
+
h: number;
|
|
24
|
+
};
|
|
25
|
+
boxes: readonly PictureBox[];
|
|
26
|
+
state: BoxesState;
|
|
27
|
+
/** A box was chosen (a click, Enter or Space): zoom to it, scroll a text pane. The state already holds it. */
|
|
28
|
+
onChoose?: (box: PictureBox) => void;
|
|
29
|
+
};
|
|
30
|
+
/** Read-only boxes drawn as one SVG layer over a picture, inside `ViewportFrame` so they zoom with it: outline by tone, hover and choice shared with a `BoxList`, one tab stop with arrows in reading order. */
|
|
31
|
+
export declare function BoxOverlay({ label, of, boxes, state, onChoose }: BoxOverlayProps): React.JSX.Element;
|
|
32
|
+
export type BoxListProps = {
|
|
33
|
+
/** Names the list: "Lines on this page". */
|
|
34
|
+
label: string;
|
|
35
|
+
boxes: readonly PictureBox[];
|
|
36
|
+
state: BoxesState;
|
|
37
|
+
/** What each line shows. Default: the box's label. */
|
|
38
|
+
renderBox?: (box: PictureBox) => React.ReactNode;
|
|
39
|
+
className?: string;
|
|
40
|
+
};
|
|
41
|
+
/** The list beside a `BoxOverlay`, in the same reading order: choosing a line marks its box, pointing at one lights it, and choosing a box in the picture scrolls the list to its line and focuses it. */
|
|
42
|
+
export declare function BoxList({ label, boxes, state, renderBox, className }: BoxListProps): React.JSX.Element;
|
|
@@ -61,7 +61,9 @@ export type ComposerProps = {
|
|
|
61
61
|
/** Questions to start from; each is a button that sends. */
|
|
62
62
|
suggestions?: readonly string[];
|
|
63
63
|
sendLabel?: string;
|
|
64
|
+
/** The box cannot be used yet, and why, in the app's words: "The footage is still being indexed." Disables the box, send and suggestions; shown under the box. */
|
|
65
|
+
disabled?: string;
|
|
64
66
|
className?: string;
|
|
65
67
|
};
|
|
66
68
|
/** The box a question is typed in: Enter sends, Shift+Enter is a new line, disabled with its reason while answering (and Stop), suggestions as buttons. */
|
|
67
|
-
export declare function Composer({ label, onSend, answering, onStop, answeringReason, suggestions, sendLabel, className }: ComposerProps): React.JSX.Element;
|
|
69
|
+
export declare function Composer({ label, onSend, answering, onStop, answeringReason, suggestions, sendLabel, disabled, className }: ComposerProps): React.JSX.Element;
|
|
@@ -8,6 +8,10 @@ export type LightboxItem = {
|
|
|
8
8
|
label: string;
|
|
9
9
|
/** Its natural size in pixels, for 1:1. */
|
|
10
10
|
natural?: readonly [number, number];
|
|
11
|
+
/** Where it sits in the set, in the set's own words: "Page 22 (12)". Read as "Page 22 (12) of 44"; default is its number. */
|
|
12
|
+
position?: string;
|
|
13
|
+
/** A small picture for the thumbnail strip. Default `src`. */
|
|
14
|
+
thumb?: string;
|
|
11
15
|
};
|
|
12
16
|
export type LightboxProps = {
|
|
13
17
|
/** The dialog's title: "Photos of firing f-0412". Required. */
|
|
@@ -29,6 +33,29 @@ export type LightboxProps = {
|
|
|
29
33
|
onCompare?: (ids: readonly string[]) => void;
|
|
30
34
|
/** Width over height of the frame before the picture loads. Default 3:2. */
|
|
31
35
|
aspect?: number;
|
|
36
|
+
/** A layer inside the zoomable frame that zooms with the picture, in the picture's own pixels (`natural` once it is known): a `BoxOverlay`. */
|
|
37
|
+
overlay?: (item: LightboxItem, natural: readonly [number, number] | null) => React.ReactNode;
|
|
38
|
+
/** The current item's own buttons, beside the position. */
|
|
39
|
+
actions?: (item: LightboxItem) => React.ReactNode;
|
|
40
|
+
/** A thumbnail strip along the bottom, for a large set. */
|
|
41
|
+
strip?: boolean;
|
|
32
42
|
};
|
|
43
|
+
/** What `useLightboxUrl` returns: the props a `Lightbox` takes for what is open, plus `show` for the grid that opens it. */
|
|
44
|
+
export type LightboxUrl = Pick<LightboxProps, "open" | "index" | "onIndexChange" | "onOpenChange"> & {
|
|
45
|
+
/** Opens the lightbox on this item (a grid tile's press); an entry in the history, so Back closes it. */
|
|
46
|
+
show: (id: string) => void;
|
|
47
|
+
};
|
|
48
|
+
/** Keeps the open picture in the URL (`?view=<id>`): a link or a reload opens it, Back closes it, and stepping between pictures replaces the entry. */
|
|
49
|
+
export declare function useLightboxUrl(items: readonly LightboxItem[], { param }?: {
|
|
50
|
+
param?: string;
|
|
51
|
+
}): LightboxUrl;
|
|
52
|
+
export declare function useNarrow(): boolean;
|
|
33
53
|
/** A picture from a set in a full-size dialog: previous/next and arrow keys, "3 of 40", zoom and pan, details beside it, neighbours preloaded, a `missing` sentence for one that fails, and a Compare ticked hand-off. Focus returns to the tile that opened it. */
|
|
34
|
-
export declare function Lightbox({ title, items, index, onIndexChange, open, onOpenChange, missing, details, detailsLabel, ticked, onCompare, aspect }: LightboxProps): React.JSX.Element;
|
|
54
|
+
export declare function Lightbox({ title, items, index, onIndexChange, open, onOpenChange, missing, details, detailsLabel, ticked, onCompare, aspect, overlay, actions, strip }: LightboxProps): React.JSX.Element;
|
|
55
|
+
export declare function ThumbnailStrip({ items, at, onPick, badge, label }: {
|
|
56
|
+
items: readonly LightboxItem[];
|
|
57
|
+
at: number;
|
|
58
|
+
onPick: (i: number) => void;
|
|
59
|
+
badge?: (item: LightboxItem) => React.ReactNode;
|
|
60
|
+
label?: string;
|
|
61
|
+
}): React.JSX.Element;
|
|
@@ -33,6 +33,12 @@ export type LineChartProps = {
|
|
|
33
33
|
below: number;
|
|
34
34
|
label: string;
|
|
35
35
|
};
|
|
36
|
+
/** The lowest and highest value each reading stands for, by index into `series` (a downsampled track keeps its extremes). Drawn as a pale area behind the line, included in the y-axis, said in the readout and the table. `label` names it in the key: "Lowest to highest in each stretch". */
|
|
37
|
+
range?: {
|
|
38
|
+
low: readonly number[];
|
|
39
|
+
high: readonly number[];
|
|
40
|
+
label: string;
|
|
41
|
+
};
|
|
36
42
|
formatX: (x: number) => string;
|
|
37
43
|
/** What x is, as the screen-reader table's first column heading: "Distance", "Day". Default "Time". */
|
|
38
44
|
xLabel?: string;
|
|
@@ -131,7 +137,7 @@ export declare function valueAt(series: readonly Point[], x: number): number;
|
|
|
131
137
|
*/
|
|
132
138
|
export declare function fitTicks(ticks: number[], scale: (x: number) => number, widthOf: (t: number) => number, gap?: number): number[];
|
|
133
139
|
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
134
|
-
export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, xDomain, xAxis, yScale: yMode, yInvert, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height, className, }: LineChartProps): React.JSX.Element;
|
|
140
|
+
export declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, xDomain, xAxis, yScale: yMode, yInvert, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, range, height, className, }: LineChartProps): React.JSX.Element;
|
|
135
141
|
/** One chart of a `LineChartGroup`: the props that differ per chart. The group owns the x axis, the cursor, `current` and `onPick`. */
|
|
136
142
|
export type GroupedChart = Omit<LineChartProps, "formatX" | "xLabel" | "xTicks" | "xDomain" | "xAxis" | "current" | "onPick" | "cursor" | "readout" | "label"> & {
|
|
137
143
|
/** Names this chart in the group's reading and its own accessible name. Default `seriesLabel`. */
|
|
@@ -35,7 +35,7 @@ export type RegionEditorProps = {
|
|
|
35
35
|
/** A drag on the empty picture draws a new window and calls this with it; the app adds it. Without it nothing can be drawn. */
|
|
36
36
|
onDraw?: (rect: Rect) => void;
|
|
37
37
|
/** "move": the first window is the start and the second the end; draws a line between them and a Watch button. */
|
|
38
|
-
mode?: "single" | "move";
|
|
38
|
+
mode?: "single" | "move" | "spread";
|
|
39
39
|
/** Called as Watch plays, with the rectangle at `t` (0 to 1) and `t`. Also drawn by the editor. */
|
|
40
40
|
onPreview?: (rect: Rect, t: number) => void;
|
|
41
41
|
/** How long Watch takes, in milliseconds. Default 1500. */
|
|
@@ -47,9 +47,21 @@ export type RegionEditorProps = {
|
|
|
47
47
|
unit?: string;
|
|
48
48
|
/** The windows as they began; with it a Reset appears while they differ. */
|
|
49
49
|
defaults?: readonly EditableRegion[];
|
|
50
|
+
/** The picture is turned by this many degrees (clockwise, -180 to 180): drawn turned on a canvas that holds it, and every window is in that canvas's units. Default 0. */
|
|
51
|
+
angle?: number;
|
|
52
|
+
/** Shows the turn control (a fine slider, quarter turns, Level) and receives the new angle; the windows are turned with the picture through `onChange` in the same step. Needs `angle`. */
|
|
53
|
+
onAngleChange?: (angle: number) => void;
|
|
54
|
+
/** Level lines across the picture, to line text up against while turning. */
|
|
55
|
+
guide?: boolean;
|
|
56
|
+
/** `mode="spread"`: the words for one window, and for each half. Default "Page", "Left page", "Right page". */
|
|
57
|
+
spreadLabels?: {
|
|
58
|
+
one: string;
|
|
59
|
+
left: string;
|
|
60
|
+
right: string;
|
|
61
|
+
};
|
|
50
62
|
className?: string;
|
|
51
63
|
};
|
|
52
64
|
/** A window said in words. */
|
|
53
65
|
export declare const describeRegion: (r: EditableRegion) => string;
|
|
54
66
|
/** Draw and move one or two named windows on a picture, with pointer, keyboard and numbers kept in step; aspect and bounds hold through all three; two windows make a from/to move with a Watch preview. */
|
|
55
|
-
export declare function RegionEditor({ label, children, size, regions, onChange, selectedId, onSelectedChange, aspect, min, bounds, step, onDraw, mode, onPreview, duration, easing, fields, unit, defaults, className, }: RegionEditorProps): React.JSX.Element;
|
|
67
|
+
export declare function RegionEditor({ label, children, size, regions, onChange, selectedId, onSelectedChange, aspect, min, bounds, step, onDraw, mode, onPreview, duration, easing, fields, unit, defaults, angle, onAngleChange, guide, spreadLabels, className, }: RegionEditorProps): React.JSX.Element;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { RowSelection } from './data-table';
|
|
2
|
+
import { TileAspect, TileSize } from './tile-grid';
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
export type TileAspect = "square" | "portrait" | "landscape";
|
|
5
|
-
/** Smallest tile width: `sm` 96px (dense crops), `md` 144px, `lg` 192px. Tiles grow to fill the row. */
|
|
6
|
-
export type TileSize = "sm" | "md" | "lg";
|
|
4
|
+
export type { TileAspect, TileSize };
|
|
7
5
|
export type SelectableGridProps<T> = {
|
|
8
6
|
/** Names the grid of tiles. */
|
|
9
7
|
label: string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Size } from 'react-stately';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/** The frame each picture is drawn in. */
|
|
4
|
+
export type TileAspect = "square" | "portrait" | "landscape";
|
|
5
|
+
/** Smallest tile width: `sm` 96px (dense crops), `md` 144px, `lg` 192px. Tiles grow to fill the row. */
|
|
6
|
+
export type TileSize = "sm" | "md" | "lg";
|
|
7
|
+
export declare const minWidth: Record<TileSize, number>;
|
|
8
|
+
export declare const aspectClass: Record<TileAspect, string>;
|
|
9
|
+
/** `GridLayout` options for tiles of this size and aspect: they grow from the minimum width to fill the row, and each row is as tall as its tallest tile as measured. */
|
|
10
|
+
export declare function tileLayoutOptions(tileSize: TileSize, aspect: TileAspect): {
|
|
11
|
+
minItemSize: Size;
|
|
12
|
+
minSpace: Size;
|
|
13
|
+
};
|
|
14
|
+
type TileGridBase<T> = {
|
|
15
|
+
/** Names the grid of tiles: "Pages of the Punch book". */
|
|
16
|
+
label: string;
|
|
17
|
+
items: T[];
|
|
18
|
+
itemKey: (item: T) => string;
|
|
19
|
+
/** The tile's name for assistive technology, one sentence: "Page 14, 4, 368 words, needs a look". */
|
|
20
|
+
itemLabel: (item: T) => string;
|
|
21
|
+
/** The picture, drawn to fill a frame of `aspect`. An `<img className="size-full object-cover">` or a `Thumbnail`. */
|
|
22
|
+
renderImage: (item: T) => React.ReactNode;
|
|
23
|
+
/** One line under the picture: the name ("Page 14, 4"). Truncated. */
|
|
24
|
+
caption?: (item: T) => React.ReactNode;
|
|
25
|
+
/** A quieter line under the caption: "368 words", "blank". Truncated. */
|
|
26
|
+
detail?: (item: T) => React.ReactNode;
|
|
27
|
+
/** In the picture's top right corner: a `Status` ("Look"). Return `null` for a tile with nothing to say. */
|
|
28
|
+
badge?: (item: T) => React.ReactNode;
|
|
29
|
+
/** Default `square`. `portrait` is 3:4, `landscape` 4:3. */
|
|
30
|
+
aspect?: TileAspect;
|
|
31
|
+
/** Default `md`. */
|
|
32
|
+
tileSize?: TileSize;
|
|
33
|
+
/** Tile count from which only the visible rows of tiles render. Default 100. */
|
|
34
|
+
virtualizeFrom?: number;
|
|
35
|
+
/** Height of the scroll region once virtualised, in px. Default 480. */
|
|
36
|
+
maxHeight?: number;
|
|
37
|
+
className?: string;
|
|
38
|
+
};
|
|
39
|
+
/** A tile always does something: it is a link (`href`: a route in the app or a URL) or an action, never neither. */
|
|
40
|
+
export type TileGridProps<T> = TileGridBase<T> & ({
|
|
41
|
+
/** Where a tile goes: a route path in this app (client navigation, the router's basename applied) or a full URL. */
|
|
42
|
+
href: (item: T) => string;
|
|
43
|
+
onAction?: (item: T) => void;
|
|
44
|
+
} | {
|
|
45
|
+
href?: undefined;
|
|
46
|
+
onAction: (item: T) => void;
|
|
47
|
+
});
|
|
48
|
+
/** A grid of picture tiles that open something: a labelled list of links (or actions), two-dimensional arrow keys, a caption, a detail line and a corner badge on each, virtualised from `virtualizeFrom` tiles. No selection: use `SelectableGrid` for that. */
|
|
49
|
+
export declare function TileGrid<T>({ label, items, itemKey, itemLabel, renderImage, caption, detail, badge, href, onAction, aspect, tileSize, virtualizeFrom, maxHeight, className, }: TileGridProps<T>): React.JSX.Element;
|
|
50
|
+
/** The loading shape of a `TileGrid`: `count` picture boxes in the same grid at the same sizes, for a `DataView` skeleton, so nothing moves when the tiles arrive. */
|
|
51
|
+
export declare function TileGridSkeleton({ count, aspect, tileSize, className }: {
|
|
52
|
+
count?: number;
|
|
53
|
+
aspect?: TileAspect;
|
|
54
|
+
tileSize?: TileSize;
|
|
55
|
+
className?: string;
|
|
56
|
+
}): React.JSX.Element;
|
|
57
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { Disclosure, useExpanded, type DisclosureProps, type DisclosureOpenProps
|
|
|
54
54
|
export { BulkBar, useSelection, useChoices, type InitialSelection, type Choices, type ChoiceCounts } from './components/selection';
|
|
55
55
|
export type { Implies } from './lib/choice';
|
|
56
56
|
export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
|
|
57
|
+
export { TileGrid, TileGridSkeleton, type TileGridProps } from './components/tile-grid';
|
|
57
58
|
export { VirtualList } from './components/virtual-list';
|
|
58
59
|
export { InfiniteList, LoadMore, type InfiniteListProps, type LoadMoreProps } from './components/infinite-list';
|
|
59
60
|
export { LineChart, LineChartGroup, logScale, valueAt, type ChartMark, type ChartSpan, type GroupedChart, type LineChartGroupProps, type LineChartProps, type Point, type SpanTone, type YScale } from './components/line-chart';
|
|
@@ -89,9 +90,13 @@ export { useHistory, useHistoryState, type History, type HistoryOptions, type Hi
|
|
|
89
90
|
export { useAutoSave, useLeaveGuard, SaveStatus, type AutoSave, type AutoSaveOptions, type SaveState } from './components/save';
|
|
90
91
|
export { RichText, Conversation, Composer, type RichTextProps, type ConversationProps, type ConversationTurn, type ComposerProps } from './components/conversation';
|
|
91
92
|
export { parseRichText, parseInline, matchEntities, safeHref, plainText, type EntityMatch, type EntityMatcher, type Block as RichBlock, type Inline as RichInline } from './lib/rich-text';
|
|
92
|
-
export { Lightbox, type LightboxProps, type LightboxItem } from './components/lightbox';
|
|
93
|
+
export { Lightbox, useLightboxUrl, type LightboxProps, type LightboxItem, type LightboxUrl } from './components/lightbox';
|
|
93
94
|
export { RegionEditor, describeRegion, type RegionEditorProps, type EditableRegion, type RegionTone } from './components/region-editor';
|
|
94
|
-
export {
|
|
95
|
+
export { BookViewer, useBookUrl, type BookPage, type BookUrl, type BookViewerProps } from './components/book-viewer';
|
|
96
|
+
export { findPage, pageName, sayPosition, viewOf, viewsOf, type PageNames } from './lib/book';
|
|
97
|
+
export { BoxOverlay, BoxList, useBoxes, type BoxOverlayProps, type BoxListProps, type BoxesState, type BoxSource } from './components/box-overlay';
|
|
98
|
+
export { readingOrder, zoomToBox, type PictureBox, type BoxTone } from './lib/boxes';
|
|
99
|
+
export { moveRect, resizeRect, fitRect, drawRect, lerpRect, ease, turnedSize, turnRect, normaliseAngle, splitRect, joinRects, gutterOf, moveGutter, type Rect, type Handle, type RectLimits, type Easing } from './lib/region';
|
|
95
100
|
export { SequenceTimeline, type SequenceTimelineProps, type SequenceItem, type CutRoom, type CutChange } from './components/sequence-timeline';
|
|
96
101
|
export { snapToGrid, stepOnGrid, gridPoints, clampToRoom, settleCut, type Grid, type CutLimit } from './lib/sequence';
|
|
97
102
|
export { Tree, type TreeProps, type TreeNodeState } from './components/tree';
|