strata-react 1.3.17 → 1.3.18
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/dist/components/box-overlay.d.ts +3 -1
- package/dist/components/boxed-picture.d.ts +34 -0
- package/dist/components/thumbnail.d.ts +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +71 -126
- package/dist/index.js.map +1 -1
- package/dist/lib/boxes.d.ts +23 -0
- package/dist/{microphone-Cu1u5Yml.js → microphone-B5ITwm4G.js} +154 -4
- package/dist/microphone-B5ITwm4G.js.map +1 -0
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/microphone-Cu1u5Yml.js.map +0 -1
package/README.md
CHANGED
|
@@ -218,7 +218,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
218
218
|
| 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 |
|
|
219
219
|
| 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 |
|
|
220
220
|
| 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); answers can carry pictures (`images`, labelled, lazy, linked to full size) that stay visible beside the collapsed "looked up"; 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 |
|
|
221
|
-
| 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 |
|
|
221
|
+
| Pictures from a set | `Lightbox` (`useLightboxUrl`), `BookViewer` (`useBookUrl`), `TileGrid`, `BoxOverlay`/`BoxList`/`useBoxes`, `BoxedPicture`, `RegionEditor`; `regionStyle`, `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, and the picture opened zoomed to one of them (a face in its photo, `BoxedPicture`); one box of a picture shown on its own in a `Thumbnail` (`region`); `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 |
|
|
222
222
|
| 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 |
|
|
223
223
|
| Browsing | `Tree`, `FolderPicker` | A hierarchy that loads as it opens (`current` + `onCurrentChange` is the row in view beside the ticked ones, `count` and `badge` per row, `sortChildren`, `reveal` of a deep link, `resolveBranch` so ticking a year says "2019 and its 91 folders" without opening them; 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 |
|
|
224
224
|
| 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 |
|
|
@@ -26,9 +26,11 @@ export type BoxOverlayProps = {
|
|
|
26
26
|
state: BoxesState;
|
|
27
27
|
/** A box was chosen (a click, Enter or Space): zoom to it, scroll a text pane. The state already holds it. */
|
|
28
28
|
onChoose?: (box: PictureBox) => void;
|
|
29
|
+
/** Fill the pointed or chosen box with its tone's subtle colour. Default `true` (a line of text stays readable under it); `false` for what the box is about to be looked at, such as a face, which only a heavier outline marks. */
|
|
30
|
+
fillLit?: boolean;
|
|
29
31
|
};
|
|
30
32
|
/** 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;
|
|
33
|
+
export declare function BoxOverlay({ label, of, boxes, state, onChoose, fillLit }: BoxOverlayProps): React.JSX.Element;
|
|
32
34
|
export type BoxListProps = {
|
|
33
35
|
/** Names the list: "Lines on this page". */
|
|
34
36
|
label: string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BoxesState } from './box-overlay';
|
|
2
|
+
import { PictureBox } from '../lib/boxes';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type BoxedPictureProps = {
|
|
5
|
+
/** Names the frame: "Photo 2026-03-14 09:12". */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The picture; `null` when there is none (the boxes still show, on the `missing` words). */
|
|
8
|
+
src: string | readonly string[] | null;
|
|
9
|
+
/** What the picture shows, or `""` when `label` says it. */
|
|
10
|
+
alt: string;
|
|
11
|
+
/** The words when the picture cannot be shown: "Photo not kept". */
|
|
12
|
+
missing: string;
|
|
13
|
+
/** The picture's size in pixels; the boxes are in these units. */
|
|
14
|
+
of: {
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
};
|
|
18
|
+
boxes: readonly PictureBox[];
|
|
19
|
+
/** From `useBoxes`, shared with a `BoxList` if there is one; its `active` box is the one opened on. */
|
|
20
|
+
state: BoxesState;
|
|
21
|
+
/** Names the layer of boxes: "Faces in this photo". */
|
|
22
|
+
boxesLabel: string;
|
|
23
|
+
/** Zoom to the chosen box when it is chosen and when the picture opens on one. Default `true`. */
|
|
24
|
+
zoom?: boolean;
|
|
25
|
+
/** How much of the box's size to leave around it when zoomed, on every side. Default 0.75 (a face with its hair, shoulders and something of who is beside it). */
|
|
26
|
+
margin?: number;
|
|
27
|
+
/** The tallest the frame may be, as a CSS length. Default `"70svh"`. */
|
|
28
|
+
maxHeight?: string;
|
|
29
|
+
/** A box was chosen in the picture. */
|
|
30
|
+
onChoose?: (box: PictureBox) => void;
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
33
|
+
/** A picture with its boxes drawn on it, opened zoomed to the chosen one (a face in its photo): `ViewportFrame` + `BoxOverlay` + `zoomToBox`, with the picture's missing state. Pair it with a `BoxList` through one `useBoxes`. */
|
|
34
|
+
export declare function BoxedPicture({ label, src, alt, missing, of, boxes, state, boxesLabel, zoom, margin, maxHeight, onChoose, className }: BoxedPictureProps): React.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PictureRegion } from '../lib/boxes';
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
/** Forgets which pictures `Thumbnail` has loaded, so a test that checks the loading state starts from nothing. `renderWithStrata` and `renderRoutes` call it. */
|
|
3
4
|
export declare function forgetLoadedThumbnails(): void;
|
|
@@ -25,6 +26,8 @@ export type ThumbnailProps = {
|
|
|
25
26
|
onLoad?: (image: HTMLImageElement, index: number) => boolean | void;
|
|
26
27
|
/** Called once when the thumbnail ends in its missing state after a request failed or was rejected, never for a record with no source. */
|
|
27
28
|
onMissing?: () => void;
|
|
29
|
+
/** Show one box of the picture, filling the thumbnail (a face from a photo): the picture's size, the box in its pixels and `pad`, how many times the box the crop is (default 1.6). `fit` does not apply. */
|
|
30
|
+
region?: PictureRegion;
|
|
28
31
|
/** Overlays drawn above the image in the same box (a running time, a "Saved" badge), in place whether the image has loaded, failed or is missing. */
|
|
29
32
|
children?: React.ReactNode;
|
|
30
33
|
} & ({
|
|
@@ -39,7 +42,7 @@ export type ThumbnailProps = {
|
|
|
39
42
|
fallback: React.ReactNode;
|
|
40
43
|
});
|
|
41
44
|
/** A box of fixed aspect ratio for a remote image: a skeleton until it loads, the `missing` words (or a `fallback`) if it cannot, a request only when it nears the screen, and `children` overlaid in its corners. `alt` and `missing` or `fallback` are required. */
|
|
42
|
-
export declare function Thumbnail({ src, alt, missing, aspect, fit, srcSet, sizes, eager, rootMargin, className, fallback, onLoad, onMissing, children, }: ThumbnailProps): React.JSX.Element;
|
|
45
|
+
export declare function Thumbnail({ src, alt, missing, aspect, fit, srcSet, sizes, eager, rootMargin, className, fallback, onLoad, onMissing, region, children, }: ThumbnailProps): React.JSX.Element;
|
|
43
46
|
/** The loading shape of a `Thumbnail`, for a `DataView` skeleton: the same box and aspect ratio, so nothing moves when the list arrives. */
|
|
44
47
|
export declare function ThumbnailSkeleton({ aspect, className }: {
|
|
45
48
|
aspect?: AspectRatio;
|
package/dist/index.d.ts
CHANGED
|
@@ -120,8 +120,9 @@ export { Lightbox, useLightboxUrl, type LightboxProps, type LightboxItem, type L
|
|
|
120
120
|
export { RegionEditor, describeRegion, type RegionEditorProps, type EditableRegion, type RegionTone } from './components/region-editor';
|
|
121
121
|
export { BookViewer, useBookUrl, type BookPage, type BookUrl, type BookViewerProps } from './components/book-viewer';
|
|
122
122
|
export { findPage, pageName, sayPosition, viewOf, viewsOf, type PageNames } from './lib/book';
|
|
123
|
+
export { BoxedPicture, type BoxedPictureProps } from './components/boxed-picture';
|
|
123
124
|
export { BoxOverlay, BoxList, useBoxes, type BoxOverlayProps, type BoxListProps, type BoxesState, type BoxSource } from './components/box-overlay';
|
|
124
|
-
export { readingOrder, zoomToBox, type PictureBox, type BoxTone } from './lib/boxes';
|
|
125
|
+
export { readingOrder, zoomToBox, regionStyle, type PictureBox, type BoxTone, type PictureRegion } from './lib/boxes';
|
|
125
126
|
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';
|
|
126
127
|
export { SequenceTimeline, type SequenceTimelineProps, type SequenceItem, type CutRoom, type CutChange } from './components/sequence-timeline';
|
|
127
128
|
export { snapToGrid, stepOnGrid, gridPoints, clampToRoom, settleCut, type Grid, type CutLimit } from './lib/sequence';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as typeSteps, a as Textarea, c as useSearchParam, d as MISSING, f as NBSP, g as cn, h as toDate, i as NativeSelect, l as Tooltip, m as format, n as Field, o as useFieldControl, p as createFormat, r as Input, s as controlHeight, t as ChoiceGroup, u as KeyText } from "./field-t4Hoer0d.js";
|
|
2
2
|
import { a as fieldErrorsOf, c as IconButton, d as isDev, f as useInView, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-jep2voNI.js";
|
|
3
|
-
import { C as usePoll, S as
|
|
3
|
+
import { A as StrataQueryProvider, C as toast, D as LoadError, E as EmptyState, F as useLoad, I as usePoll, L as overlaySurface, M as fetchJson, N as staleOf, O as Skeleton, P as toLoad, S as StrataToastRegion, T as DataView$1, _ as clampViewport, a as useMicrophone, b as viewportTransform, d as zoomToBox, f as FIT, g as boxViewport, h as actualPixelsScale, i as explainMicrophoneError, j as createQueryClient, k as StaleNotice, l as readingOrder, m as MIN_SCALE, n as MicrophoneError, o as Thumbnail, p as MAX_SCALE, r as browserMicrophone, s as ThumbnailSkeleton, t as MicrophoneContext, u as regionStyle, v as frameBoxToShares, w as toastTimeout, x as zoomAt, y as regionShares } from "./microphone-B5ITwm4G.js";
|
|
4
4
|
import { a as useAsyncAction, c as KeysLegend, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-DB5l5Qe2.js";
|
|
5
5
|
import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
|
|
6
6
|
import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-DXacprlw.js";
|
|
@@ -9028,90 +9028,6 @@ function TileBox({ label }) {
|
|
|
9028
9028
|
})
|
|
9029
9029
|
});
|
|
9030
9030
|
}
|
|
9031
|
-
// src/lib/viewport.ts
|
|
9032
|
-
/** The picture fitted in its frame, not panned. */
|
|
9033
|
-
var FIT = {
|
|
9034
|
-
scale: 1,
|
|
9035
|
-
x: 0,
|
|
9036
|
-
y: 0
|
|
9037
|
-
};
|
|
9038
|
-
/** The least zoom: the whole picture fitted. */
|
|
9039
|
-
var MIN_SCALE = 1;
|
|
9040
|
-
/** The most zoom, 32 times the fit. */
|
|
9041
|
-
var MAX_SCALE = 32;
|
|
9042
|
-
/** Keeps the picture from being dragged out of its frame: at most half the extra width or height past each edge. */
|
|
9043
|
-
function clampViewport(v, frame) {
|
|
9044
|
-
const scale = Math.min(32, Math.max(1, v.scale));
|
|
9045
|
-
if (scale === 1) return FIT;
|
|
9046
|
-
const mx = (scale - 1) * frame.width / 2;
|
|
9047
|
-
const my = (scale - 1) * frame.height / 2;
|
|
9048
|
-
return {
|
|
9049
|
-
scale,
|
|
9050
|
-
x: Math.min(mx, Math.max(-mx, v.x)),
|
|
9051
|
-
y: Math.min(my, Math.max(-my, v.y))
|
|
9052
|
-
};
|
|
9053
|
-
}
|
|
9054
|
-
/** A new scale with the point under `at` (pixels from the frame's centre) staying under it. */
|
|
9055
|
-
function zoomAt(v, nextScale, at, frame) {
|
|
9056
|
-
const scale = Math.min(32, Math.max(1, nextScale));
|
|
9057
|
-
const k = scale / v.scale;
|
|
9058
|
-
return clampViewport({
|
|
9059
|
-
scale,
|
|
9060
|
-
x: at.x - k * (at.x - v.x),
|
|
9061
|
-
y: at.y - k * (at.y - v.y)
|
|
9062
|
-
}, frame);
|
|
9063
|
-
}
|
|
9064
|
-
/** The scale at which the picture's own pixels are drawn one to one: its natural width over the width it is fitted at. */
|
|
9065
|
-
function actualPixelsScale(naturalWidth, fittedWidth) {
|
|
9066
|
-
if (!naturalWidth || !fittedWidth) return 1;
|
|
9067
|
-
return Math.min(32, Math.max(1, naturalWidth / fittedWidth));
|
|
9068
|
-
}
|
|
9069
|
-
/** The CSS transform for a viewport. */
|
|
9070
|
-
function viewportTransform(v) {
|
|
9071
|
-
return `translate(${v.x}px, ${v.y}px) scale(${v.scale})`;
|
|
9072
|
-
}
|
|
9073
|
-
/** A region as shares of the frame, so it lands on the same part of every candidate whatever its pixel size. */
|
|
9074
|
-
function regionShares(region) {
|
|
9075
|
-
const [x, y, w, h] = region.box;
|
|
9076
|
-
if (!region.of) return [
|
|
9077
|
-
x,
|
|
9078
|
-
y,
|
|
9079
|
-
w,
|
|
9080
|
-
h
|
|
9081
|
-
];
|
|
9082
|
-
const [ow, oh] = region.of;
|
|
9083
|
-
return [
|
|
9084
|
-
x / ow,
|
|
9085
|
-
y / oh,
|
|
9086
|
-
w / ow,
|
|
9087
|
-
h / oh
|
|
9088
|
-
];
|
|
9089
|
-
}
|
|
9090
|
-
/** The viewport that fills the frame with a box (as much of it as fits, centred): the scale that fits the box, the offset that puts its centre at the frame's centre. */
|
|
9091
|
-
function boxViewport(box, frame) {
|
|
9092
|
-
const [x, y, w, h] = box;
|
|
9093
|
-
const scale = Math.min(32, Math.max(1, Math.min(1 / Math.max(w, 1e-6), 1 / Math.max(h, 1e-6))));
|
|
9094
|
-
return clampViewport({
|
|
9095
|
-
scale,
|
|
9096
|
-
x: -scale * (x + w / 2 - .5) * frame.width,
|
|
9097
|
-
y: -scale * (y + h / 2 - .5) * frame.height
|
|
9098
|
-
}, frame);
|
|
9099
|
-
}
|
|
9100
|
-
/** A rectangle drawn on the frame (pixels from its top left) as shares of the picture under the viewport now. */
|
|
9101
|
-
function frameBoxToShares(rect, v, frame) {
|
|
9102
|
-
const toShare = (p, offset, size) => size ? (p - size / 2 - offset) / v.scale / size + .5 : 0;
|
|
9103
|
-
const clamp = (n) => Math.min(1, Math.max(0, n));
|
|
9104
|
-
const xa = clamp(toShare(Math.min(rect.x0, rect.x1), v.x, frame.width));
|
|
9105
|
-
const xb = clamp(toShare(Math.max(rect.x0, rect.x1), v.x, frame.width));
|
|
9106
|
-
const ya = clamp(toShare(Math.min(rect.y0, rect.y1), v.y, frame.height));
|
|
9107
|
-
const yb = clamp(toShare(Math.max(rect.y0, rect.y1), v.y, frame.height));
|
|
9108
|
-
return [
|
|
9109
|
-
xa,
|
|
9110
|
-
ya,
|
|
9111
|
-
xb - xa,
|
|
9112
|
-
yb - ya
|
|
9113
|
-
];
|
|
9114
|
-
}
|
|
9115
9031
|
// src/components/compare-parts.tsx
|
|
9116
9032
|
var VIEWPORT_HEIGHT = "max(16rem, calc(100svh - 14rem))";
|
|
9117
9033
|
/** The tallest each row of frames may be so that all of `chrome` and `rows` rows fit in `space` pixels. Pure, so it is tested without a layout. */
|
|
@@ -17617,43 +17533,6 @@ function BookViewer({ label, pages, index, onIndexChange, missing, layout = "spr
|
|
|
17617
17533
|
]
|
|
17618
17534
|
});
|
|
17619
17535
|
}
|
|
17620
|
-
// src/lib/boxes.ts
|
|
17621
|
-
/**
|
|
17622
|
-
* The boxes in reading order: top to bottom in rows, left to right within a row. A box joins the
|
|
17623
|
-
* row above when its centre falls inside that row's first box vertically, so lines of text that
|
|
17624
|
-
* wobble a few pixels still read in order and two columns read row by row, not column by column.
|
|
17625
|
-
* Returns ids, so a caller keeps its own objects.
|
|
17626
|
-
*/
|
|
17627
|
-
function readingOrder(boxes) {
|
|
17628
|
-
const byTop = [...boxes].sort((a, b) => a.y + a.h / 2 - (b.y + b.h / 2) || a.x - b.x);
|
|
17629
|
-
const rows = [];
|
|
17630
|
-
for (const box of byTop) {
|
|
17631
|
-
const row = rows[rows.length - 1];
|
|
17632
|
-
const centre = box.y + box.h / 2;
|
|
17633
|
-
if (row && centre >= row[0].y && centre <= row[0].y + row[0].h) row.push(box);
|
|
17634
|
-
else rows.push([box]);
|
|
17635
|
-
}
|
|
17636
|
-
return rows.flatMap((row) => row.sort((a, b) => a.x - b.x).map((b) => b.id));
|
|
17637
|
-
}
|
|
17638
|
-
/**
|
|
17639
|
-
* The viewport that fills a frame with one box of the picture. The picture sits in the frame the way
|
|
17640
|
-
* `object-fit: contain` puts it (a frame of another shape leaves bars), which is also how
|
|
17641
|
-
* `BoxOverlay` draws it, so the same numbers agree. `margin` is the share of the box added on every
|
|
17642
|
-
* side so the box is not touching the frame (default 0.25).
|
|
17643
|
-
*/
|
|
17644
|
-
function zoomToBox(box, of, frame, margin = .25) {
|
|
17645
|
-
const s = Math.min(frame.width / of.w, frame.height / of.h);
|
|
17646
|
-
const ox = (frame.width - of.w * s) / 2;
|
|
17647
|
-
const oy = (frame.height - of.h * s) / 2;
|
|
17648
|
-
const mx = box.w * margin;
|
|
17649
|
-
const my = box.h * margin;
|
|
17650
|
-
return boxViewport([
|
|
17651
|
-
(ox + (box.x - mx) * s) / frame.width,
|
|
17652
|
-
(oy + (box.y - my) * s) / frame.height,
|
|
17653
|
-
(box.w + 2 * mx) * s / frame.width,
|
|
17654
|
-
(box.h + 2 * my) * s / frame.height
|
|
17655
|
-
], frame);
|
|
17656
|
-
}
|
|
17657
17536
|
// src/components/box-overlay.tsx
|
|
17658
17537
|
/** Holds the active and pointed box for a `BoxOverlay` and the `BoxList` beside it. */
|
|
17659
17538
|
function useBoxes(initial = null) {
|
|
@@ -17692,7 +17571,7 @@ var FILL = {
|
|
|
17692
17571
|
danger: "var(--danger-subtle)"
|
|
17693
17572
|
};
|
|
17694
17573
|
/** 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. */
|
|
17695
|
-
function BoxOverlay({ label, of, boxes, state, onChoose }) {
|
|
17574
|
+
function BoxOverlay({ label, of, boxes, state, onChoose, fillLit = true }) {
|
|
17696
17575
|
const order = React.useMemo(() => readingOrder(boxes), [boxes]);
|
|
17697
17576
|
const byId = React.useMemo(() => new Map(boxes.map((b) => [b.id, b])), [boxes]);
|
|
17698
17577
|
const group = React.useRef(null);
|
|
@@ -17729,6 +17608,7 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
|
|
|
17729
17608
|
const tone = b.tone ?? "neutral";
|
|
17730
17609
|
const on = id === state.active;
|
|
17731
17610
|
const lit = on || id === state.pointed;
|
|
17611
|
+
const filled = lit && fillLit;
|
|
17732
17612
|
const repeat = n >= order.length;
|
|
17733
17613
|
return /* @__PURE__ */ jsx("rect", {
|
|
17734
17614
|
"data-box-id": id,
|
|
@@ -17741,8 +17621,8 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
|
|
|
17741
17621
|
y: b.y,
|
|
17742
17622
|
width: b.w,
|
|
17743
17623
|
height: b.h,
|
|
17744
|
-
fill:
|
|
17745
|
-
fillOpacity:
|
|
17624
|
+
fill: filled ? FILL[tone] : "none",
|
|
17625
|
+
fillOpacity: filled ? .25 : void 0,
|
|
17746
17626
|
stroke: STROKE[tone],
|
|
17747
17627
|
strokeWidth: on ? 3 : 1.5,
|
|
17748
17628
|
strokeOpacity: lit || tone !== "neutral" ? 1 : .55,
|
|
@@ -17796,6 +17676,71 @@ function BoxList({ label, boxes, state, renderBox, className }) {
|
|
|
17796
17676
|
})
|
|
17797
17677
|
});
|
|
17798
17678
|
}
|
|
17679
|
+
// src/components/boxed-picture.tsx
|
|
17680
|
+
/** A picture with its boxes drawn on it, opened zoomed to the chosen one (a face in its photo): `ViewportFrame` + `BoxOverlay` + `zoomToBox`, with the picture's missing state. Pair it with a `BoxList` through one `useBoxes`. */
|
|
17681
|
+
function BoxedPicture({ label, src, alt, missing, of, boxes, state, boxesLabel, zoom = true, margin = .75, maxHeight = "70svh", onChoose, className }) {
|
|
17682
|
+
const view = useViewport();
|
|
17683
|
+
const frame = React.useRef(null);
|
|
17684
|
+
const { setViewport } = view;
|
|
17685
|
+
const box = state.active ? boxes.find((b) => b.id === state.active) : void 0;
|
|
17686
|
+
const [size, setSize] = React.useState(null);
|
|
17687
|
+
React.useLayoutEffect(() => {
|
|
17688
|
+
const el = frame.current;
|
|
17689
|
+
if (!el) return;
|
|
17690
|
+
const read = () => {
|
|
17691
|
+
const r = el.getBoundingClientRect();
|
|
17692
|
+
setSize((was) => was && was.width === r.width && was.height === r.height ? was : {
|
|
17693
|
+
width: r.width,
|
|
17694
|
+
height: r.height
|
|
17695
|
+
});
|
|
17696
|
+
};
|
|
17697
|
+
read();
|
|
17698
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
17699
|
+
const ro = new ResizeObserver(read);
|
|
17700
|
+
ro.observe(el);
|
|
17701
|
+
return () => ro.disconnect();
|
|
17702
|
+
}, []);
|
|
17703
|
+
React.useLayoutEffect(() => {
|
|
17704
|
+
if (!zoom) return setViewport(FIT);
|
|
17705
|
+
if (box && size && size.width > 0 && size.height > 0) setViewport(zoomToBox(box, of, size, margin));
|
|
17706
|
+
}, [
|
|
17707
|
+
zoom,
|
|
17708
|
+
box?.id,
|
|
17709
|
+
box?.x,
|
|
17710
|
+
box?.y,
|
|
17711
|
+
box?.w,
|
|
17712
|
+
box?.h,
|
|
17713
|
+
of.w,
|
|
17714
|
+
of.h,
|
|
17715
|
+
margin,
|
|
17716
|
+
size,
|
|
17717
|
+
setViewport
|
|
17718
|
+
]);
|
|
17719
|
+
return /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
17720
|
+
ref: frame,
|
|
17721
|
+
label,
|
|
17722
|
+
aspect: of.w / of.h,
|
|
17723
|
+
maxHeight,
|
|
17724
|
+
className,
|
|
17725
|
+
...view,
|
|
17726
|
+
children: [/* @__PURE__ */ jsx(Thumbnail, {
|
|
17727
|
+
src,
|
|
17728
|
+
alt,
|
|
17729
|
+
missing,
|
|
17730
|
+
aspect: of.w / of.h,
|
|
17731
|
+
fit: "contain",
|
|
17732
|
+
eager: true,
|
|
17733
|
+
className: "size-full rounded-none"
|
|
17734
|
+
}), /* @__PURE__ */ jsx(BoxOverlay, {
|
|
17735
|
+
label: boxesLabel,
|
|
17736
|
+
of,
|
|
17737
|
+
boxes,
|
|
17738
|
+
state,
|
|
17739
|
+
onChoose,
|
|
17740
|
+
fillLit: false
|
|
17741
|
+
})]
|
|
17742
|
+
});
|
|
17743
|
+
}
|
|
17799
17744
|
// src/lib/sequence.ts
|
|
17800
17745
|
var EPS = 1e-9;
|
|
17801
17746
|
/** The grid point nearest to `time`, or `time` itself when there is no grid. */
|
|
@@ -18705,6 +18650,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
18705
18650
|
]
|
|
18706
18651
|
});
|
|
18707
18652
|
}
|
|
18708
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, ButtonLink, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, Workspace, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
18653
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, Workspace, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
18709
18654
|
|
|
18710
18655
|
//# sourceMappingURL=index.js.map
|