strata-react 1.3.17 → 1.3.19
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 +3 -3
- package/dist/components/box-overlay.d.ts +3 -1
- package/dist/components/boxed-picture.d.ts +34 -0
- package/dist/components/media-contents.d.ts +28 -0
- package/dist/components/media-player.d.ts +6 -1
- package/dist/components/thumbnail.d.ts +4 -1
- package/dist/components/workflow-steps.d.ts +35 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +225 -128
- 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/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";
|
|
@@ -2338,6 +2338,105 @@ function WorkflowSteps({ label, stages, onApprove, onRetry, words, now, classNam
|
|
|
2338
2338
|
})
|
|
2339
2339
|
});
|
|
2340
2340
|
}
|
|
2341
|
+
/** Reduces a run's stages to one state and the stage it is about. `running`: its job is queued or running. */
|
|
2342
|
+
function summariseWorkflow(stages, { running = false } = {}) {
|
|
2343
|
+
const total = stages.length;
|
|
2344
|
+
const done = stages.filter((s) => s.state === "done").length;
|
|
2345
|
+
const at = (state, find) => {
|
|
2346
|
+
const i = stages.findIndex(find);
|
|
2347
|
+
return i < 0 ? null : {
|
|
2348
|
+
state,
|
|
2349
|
+
stage: stages[i],
|
|
2350
|
+
step: i + 1,
|
|
2351
|
+
done,
|
|
2352
|
+
total
|
|
2353
|
+
};
|
|
2354
|
+
};
|
|
2355
|
+
if (running) return at("running", (s) => s.state !== "done") ?? {
|
|
2356
|
+
state: "running",
|
|
2357
|
+
done,
|
|
2358
|
+
total
|
|
2359
|
+
};
|
|
2360
|
+
return at("failed", (s) => s.state === "failed") ?? at("waiting", (s) => s.state === "waiting") ?? at("stale", (s) => s.state === "stale") ?? (done === total ? {
|
|
2361
|
+
state: "done",
|
|
2362
|
+
done,
|
|
2363
|
+
total
|
|
2364
|
+
} : done === 0 ? {
|
|
2365
|
+
state: "ready",
|
|
2366
|
+
done,
|
|
2367
|
+
total
|
|
2368
|
+
} : {
|
|
2369
|
+
state: "partial",
|
|
2370
|
+
done,
|
|
2371
|
+
total
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
var SUMMARY_LOOKS = {
|
|
2375
|
+
running: {
|
|
2376
|
+
tone: "info",
|
|
2377
|
+
icon: Clock,
|
|
2378
|
+
word: (w) => w.running
|
|
2379
|
+
},
|
|
2380
|
+
failed: {
|
|
2381
|
+
tone: "danger",
|
|
2382
|
+
icon: CircleAlert,
|
|
2383
|
+
word: (w) => w.failed
|
|
2384
|
+
},
|
|
2385
|
+
waiting: {
|
|
2386
|
+
tone: "info",
|
|
2387
|
+
icon: Eye,
|
|
2388
|
+
word: (w) => w.waiting
|
|
2389
|
+
},
|
|
2390
|
+
stale: {
|
|
2391
|
+
tone: "warning",
|
|
2392
|
+
icon: RotateCcw,
|
|
2393
|
+
word: (w) => w.stale
|
|
2394
|
+
},
|
|
2395
|
+
done: {
|
|
2396
|
+
tone: "success",
|
|
2397
|
+
icon: Check,
|
|
2398
|
+
word: (w) => w.done
|
|
2399
|
+
},
|
|
2400
|
+
partial: {
|
|
2401
|
+
tone: "neutral",
|
|
2402
|
+
icon: CircleDashed,
|
|
2403
|
+
word: (w) => w.partial
|
|
2404
|
+
},
|
|
2405
|
+
ready: {
|
|
2406
|
+
tone: "neutral",
|
|
2407
|
+
icon: CircleDashed,
|
|
2408
|
+
word: (w) => w.ready
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2411
|
+
/** The sentence beside the word: which stage, and how far through. */
|
|
2412
|
+
function describeWorkflowSummary(s) {
|
|
2413
|
+
if (s.state === "running") return s.stage ? `${s.stage.title}, step ${s.step} of ${s.total}` : null;
|
|
2414
|
+
if (s.state === "partial") return `${s.done} of ${format.count(s.total, "step")} done`;
|
|
2415
|
+
return s.stage && s.state !== "done" && s.state !== "ready" ? s.stage.title : null;
|
|
2416
|
+
}
|
|
2417
|
+
/** A subject's run through a strata-python pipeline in a few words, for a list of subjects: running (on which step), failed (which), waiting for review (which gate), out of date, part done, or done. */
|
|
2418
|
+
function WorkflowSummary({ stages, running, words, className }) {
|
|
2419
|
+
const summary = summariseWorkflow(stages, { running });
|
|
2420
|
+
const look = SUMMARY_LOOKS[summary.state];
|
|
2421
|
+
const detail = describeWorkflowSummary(summary);
|
|
2422
|
+
const all = {
|
|
2423
|
+
...DEFAULT_WORDS,
|
|
2424
|
+
running: "Running",
|
|
2425
|
+
partial: "Part done",
|
|
2426
|
+
...words
|
|
2427
|
+
};
|
|
2428
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2429
|
+
className: cn("inline-flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", className),
|
|
2430
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
2431
|
+
tone: look.tone,
|
|
2432
|
+
icon: look.icon,
|
|
2433
|
+
children: look.word(all)
|
|
2434
|
+
}), detail && /* @__PURE__ */ jsx("span", {
|
|
2435
|
+
className: "type-body-sm text-muted-foreground",
|
|
2436
|
+
children: detail
|
|
2437
|
+
})]
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2341
2440
|
// src/lib/breakpoint.ts
|
|
2342
2441
|
var DEFAULTS = {
|
|
2343
2442
|
sm: "40rem",
|
|
@@ -3350,6 +3449,59 @@ function FilmStrip({ label, frames, span, time, onSeek, aspect = "4/3", frameWid
|
|
|
3350
3449
|
})
|
|
3351
3450
|
});
|
|
3352
3451
|
}
|
|
3452
|
+
// src/components/media-contents.tsx
|
|
3453
|
+
/** The index of the item whose span holds `time`, or -1. */
|
|
3454
|
+
function currentItem(items, time) {
|
|
3455
|
+
if (time === void 0) return -1;
|
|
3456
|
+
return items.findIndex((it) => time >= it.start && time < it.end);
|
|
3457
|
+
}
|
|
3458
|
+
/** One media file's chapters as a list of contents beside its player: the one playing marked, and pressing one plays from its start. */
|
|
3459
|
+
function MediaContents({ label, items, time, onSeek, onSelect, className }) {
|
|
3460
|
+
const current = currentItem(items, time);
|
|
3461
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
3462
|
+
"aria-label": label,
|
|
3463
|
+
className: cn("grid min-w-0 gap-0", className),
|
|
3464
|
+
children: items.map((item, i) => /* @__PURE__ */ jsx(ContentsRow, {
|
|
3465
|
+
item,
|
|
3466
|
+
current: i === current,
|
|
3467
|
+
onSeek,
|
|
3468
|
+
onSelect
|
|
3469
|
+
}, item.id))
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
var ContentsRow = React.memo(function ContentsRow({ item, current, onSeek, onSelect }) {
|
|
3473
|
+
const from = format.runningTime(item.start);
|
|
3474
|
+
return /* @__PURE__ */ jsx("li", {
|
|
3475
|
+
"aria-current": current ? "time" : void 0,
|
|
3476
|
+
"data-current": current ? "" : void 0,
|
|
3477
|
+
children: /* @__PURE__ */ jsxs(Button$1, {
|
|
3478
|
+
"aria-label": `Play ${item.title}, from ${from}`,
|
|
3479
|
+
onPress: () => {
|
|
3480
|
+
onSeek(item.start);
|
|
3481
|
+
onSelect?.(item.id);
|
|
3482
|
+
},
|
|
3483
|
+
className: cn("grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3 gap-y-0.5 border-l-2 border-transparent px-3 py-2 text-left transition-state hover:bg-muted", current && "border-primary bg-accent hover:bg-accent"),
|
|
3484
|
+
children: [
|
|
3485
|
+
/* @__PURE__ */ jsx("span", {
|
|
3486
|
+
className: "type-label text-foreground",
|
|
3487
|
+
children: item.title
|
|
3488
|
+
}),
|
|
3489
|
+
/* @__PURE__ */ jsx("span", {
|
|
3490
|
+
className: "type-body-sm tabular-nums text-muted-foreground whitespace-nowrap",
|
|
3491
|
+
children: from
|
|
3492
|
+
}),
|
|
3493
|
+
item.detail ? /* @__PURE__ */ jsx("span", {
|
|
3494
|
+
className: "type-caption text-muted-foreground",
|
|
3495
|
+
children: item.detail
|
|
3496
|
+
}) : /* @__PURE__ */ jsx("span", {}),
|
|
3497
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3498
|
+
className: "type-caption tabular-nums text-muted-foreground whitespace-nowrap",
|
|
3499
|
+
children: [format.runningTime(item.end - item.start), " long"]
|
|
3500
|
+
})
|
|
3501
|
+
]
|
|
3502
|
+
})
|
|
3503
|
+
});
|
|
3504
|
+
});
|
|
3353
3505
|
// src/components/fullscreen-frame.tsx
|
|
3354
3506
|
/** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
|
|
3355
3507
|
function canFullscreen() {
|
|
@@ -4776,7 +4928,7 @@ function useCoarsePointer() {
|
|
|
4776
4928
|
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
4777
4929
|
* parts and `useMediaElement` directly.
|
|
4778
4930
|
*/
|
|
4779
|
-
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
|
|
4931
|
+
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
|
|
4780
4932
|
const list = React.useMemo(() => sources ?? (src ? [{
|
|
4781
4933
|
src,
|
|
4782
4934
|
title: label
|
|
@@ -5284,7 +5436,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5284
5436
|
}] : offsets ? list.map((s, i) => ({
|
|
5285
5437
|
time: offsets[i],
|
|
5286
5438
|
label: s.title
|
|
5287
|
-
})).slice(1) : [],
|
|
5439
|
+
})).slice(1) : !bound && marks || [],
|
|
5288
5440
|
step: JUMP,
|
|
5289
5441
|
bigStep: 60,
|
|
5290
5442
|
label: `Seek in ${label}`
|
|
@@ -9028,90 +9180,6 @@ function TileBox({ label }) {
|
|
|
9028
9180
|
})
|
|
9029
9181
|
});
|
|
9030
9182
|
}
|
|
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
9183
|
// src/components/compare-parts.tsx
|
|
9116
9184
|
var VIEWPORT_HEIGHT = "max(16rem, calc(100svh - 14rem))";
|
|
9117
9185
|
/** 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 +17685,6 @@ function BookViewer({ label, pages, index, onIndexChange, missing, layout = "spr
|
|
|
17617
17685
|
]
|
|
17618
17686
|
});
|
|
17619
17687
|
}
|
|
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
17688
|
// src/components/box-overlay.tsx
|
|
17658
17689
|
/** Holds the active and pointed box for a `BoxOverlay` and the `BoxList` beside it. */
|
|
17659
17690
|
function useBoxes(initial = null) {
|
|
@@ -17692,7 +17723,7 @@ var FILL = {
|
|
|
17692
17723
|
danger: "var(--danger-subtle)"
|
|
17693
17724
|
};
|
|
17694
17725
|
/** 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 }) {
|
|
17726
|
+
function BoxOverlay({ label, of, boxes, state, onChoose, fillLit = true }) {
|
|
17696
17727
|
const order = React.useMemo(() => readingOrder(boxes), [boxes]);
|
|
17697
17728
|
const byId = React.useMemo(() => new Map(boxes.map((b) => [b.id, b])), [boxes]);
|
|
17698
17729
|
const group = React.useRef(null);
|
|
@@ -17729,6 +17760,7 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
|
|
|
17729
17760
|
const tone = b.tone ?? "neutral";
|
|
17730
17761
|
const on = id === state.active;
|
|
17731
17762
|
const lit = on || id === state.pointed;
|
|
17763
|
+
const filled = lit && fillLit;
|
|
17732
17764
|
const repeat = n >= order.length;
|
|
17733
17765
|
return /* @__PURE__ */ jsx("rect", {
|
|
17734
17766
|
"data-box-id": id,
|
|
@@ -17741,8 +17773,8 @@ function BoxOverlay({ label, of, boxes, state, onChoose }) {
|
|
|
17741
17773
|
y: b.y,
|
|
17742
17774
|
width: b.w,
|
|
17743
17775
|
height: b.h,
|
|
17744
|
-
fill:
|
|
17745
|
-
fillOpacity:
|
|
17776
|
+
fill: filled ? FILL[tone] : "none",
|
|
17777
|
+
fillOpacity: filled ? .25 : void 0,
|
|
17746
17778
|
stroke: STROKE[tone],
|
|
17747
17779
|
strokeWidth: on ? 3 : 1.5,
|
|
17748
17780
|
strokeOpacity: lit || tone !== "neutral" ? 1 : .55,
|
|
@@ -17796,6 +17828,71 @@ function BoxList({ label, boxes, state, renderBox, className }) {
|
|
|
17796
17828
|
})
|
|
17797
17829
|
});
|
|
17798
17830
|
}
|
|
17831
|
+
// src/components/boxed-picture.tsx
|
|
17832
|
+
/** 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`. */
|
|
17833
|
+
function BoxedPicture({ label, src, alt, missing, of, boxes, state, boxesLabel, zoom = true, margin = .75, maxHeight = "70svh", onChoose, className }) {
|
|
17834
|
+
const view = useViewport();
|
|
17835
|
+
const frame = React.useRef(null);
|
|
17836
|
+
const { setViewport } = view;
|
|
17837
|
+
const box = state.active ? boxes.find((b) => b.id === state.active) : void 0;
|
|
17838
|
+
const [size, setSize] = React.useState(null);
|
|
17839
|
+
React.useLayoutEffect(() => {
|
|
17840
|
+
const el = frame.current;
|
|
17841
|
+
if (!el) return;
|
|
17842
|
+
const read = () => {
|
|
17843
|
+
const r = el.getBoundingClientRect();
|
|
17844
|
+
setSize((was) => was && was.width === r.width && was.height === r.height ? was : {
|
|
17845
|
+
width: r.width,
|
|
17846
|
+
height: r.height
|
|
17847
|
+
});
|
|
17848
|
+
};
|
|
17849
|
+
read();
|
|
17850
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
17851
|
+
const ro = new ResizeObserver(read);
|
|
17852
|
+
ro.observe(el);
|
|
17853
|
+
return () => ro.disconnect();
|
|
17854
|
+
}, []);
|
|
17855
|
+
React.useLayoutEffect(() => {
|
|
17856
|
+
if (!zoom) return setViewport(FIT);
|
|
17857
|
+
if (box && size && size.width > 0 && size.height > 0) setViewport(zoomToBox(box, of, size, margin));
|
|
17858
|
+
}, [
|
|
17859
|
+
zoom,
|
|
17860
|
+
box?.id,
|
|
17861
|
+
box?.x,
|
|
17862
|
+
box?.y,
|
|
17863
|
+
box?.w,
|
|
17864
|
+
box?.h,
|
|
17865
|
+
of.w,
|
|
17866
|
+
of.h,
|
|
17867
|
+
margin,
|
|
17868
|
+
size,
|
|
17869
|
+
setViewport
|
|
17870
|
+
]);
|
|
17871
|
+
return /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
17872
|
+
ref: frame,
|
|
17873
|
+
label,
|
|
17874
|
+
aspect: of.w / of.h,
|
|
17875
|
+
maxHeight,
|
|
17876
|
+
className,
|
|
17877
|
+
...view,
|
|
17878
|
+
children: [/* @__PURE__ */ jsx(Thumbnail, {
|
|
17879
|
+
src,
|
|
17880
|
+
alt,
|
|
17881
|
+
missing,
|
|
17882
|
+
aspect: of.w / of.h,
|
|
17883
|
+
fit: "contain",
|
|
17884
|
+
eager: true,
|
|
17885
|
+
className: "size-full rounded-none"
|
|
17886
|
+
}), /* @__PURE__ */ jsx(BoxOverlay, {
|
|
17887
|
+
label: boxesLabel,
|
|
17888
|
+
of,
|
|
17889
|
+
boxes,
|
|
17890
|
+
state,
|
|
17891
|
+
onChoose,
|
|
17892
|
+
fillLit: false
|
|
17893
|
+
})]
|
|
17894
|
+
});
|
|
17895
|
+
}
|
|
17799
17896
|
// src/lib/sequence.ts
|
|
17800
17897
|
var EPS = 1e-9;
|
|
17801
17898
|
/** The grid point nearest to `time`, or `time` itself when there is no grid. */
|
|
@@ -18705,6 +18802,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
18705
18802
|
]
|
|
18706
18803
|
});
|
|
18707
18804
|
}
|
|
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 };
|
|
18805
|
+
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, MediaContents, 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, WorkflowSummary, 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, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, 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, summariseWorkflow, 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
18806
|
|
|
18710
18807
|
//# sourceMappingURL=index.js.map
|