strata-react 2.1.18 → 2.1.20
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 -0
- package/dist/index.d.ts +113 -2
- package/dist/index.js +455 -4
- package/dist/index.js.map +1 -1
- package/dist/{microphone-xGKxcK6p.d.ts → microphone-DWh4OaMH.d.ts} +2 -2
- package/dist/testing.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8797,7 +8797,7 @@ const tidy = (n) => Math.round(n * 1e6) / 1e6;
|
|
|
8797
8797
|
// src/components/timeline.tsx
|
|
8798
8798
|
const EDGE_PX = 8;
|
|
8799
8799
|
const DRAG_THRESHOLD = 3;
|
|
8800
|
-
const defaultFormat = (t) => tickLabel(t, 1);
|
|
8800
|
+
const defaultFormat$1 = (t) => tickLabel(t, 1);
|
|
8801
8801
|
/** Zoom state for a timeline: `zoomIn`, `zoomOut`, and `fit` to a viewport width. Pass `zoom` and `setZoom` as the timeline's `zoom` and `onZoomChange`. */
|
|
8802
8802
|
function useTimelineZoom({ initial = 20, min = .5, max = 400 } = {}) {
|
|
8803
8803
|
const [zoom, set] = React.useState(initial);
|
|
@@ -8846,7 +8846,7 @@ function noOverlap(items) {
|
|
|
8846
8846
|
};
|
|
8847
8847
|
}
|
|
8848
8848
|
/** Items placed on a zoomable time axis in lanes, with a current-time rule and markers. Reports every move, trim, selection and time change; the app applies them. Keyboard-complete, and only the items near the view are rendered. */
|
|
8849
|
-
function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, kindColours, laneRows = 1, dropTypes, dropLength, onDrop, validateDrop, formatTime = defaultFormat, empty, className }) {
|
|
8849
|
+
function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, markers = [], selectedIds, onSelect, onItemChange, onDelete, validate, snapPoints = [], snap = true, step = 1, minLength, renderItem, kindColours, laneRows = 1, dropTypes, dropLength, onDrop, validateDrop, formatTime = defaultFormat$1, empty, className }) {
|
|
8850
8850
|
const min = minLength ?? step;
|
|
8851
8851
|
const scroller = React.useRef(null);
|
|
8852
8852
|
const laneRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
@@ -9300,7 +9300,7 @@ function Timeline({ label, lanes, items, from = 0, to, zoom, onZoomChange, posit
|
|
|
9300
9300
|
borderLeftWidth: last ? 0 : 1,
|
|
9301
9301
|
paddingRight: last ? 4 : 0
|
|
9302
9302
|
},
|
|
9303
|
-
children: formatTime === defaultFormat ? tickLabel(t, stepSize) : formatTime(t)
|
|
9303
|
+
children: formatTime === defaultFormat$1 ? tickLabel(t, stepSize) : formatTime(t)
|
|
9304
9304
|
}, t);
|
|
9305
9305
|
}),
|
|
9306
9306
|
markers.map((m) => /* @__PURE__ */ jsx("button", {
|
|
@@ -9485,6 +9485,360 @@ function LaneRow({ label, register, types, onHover, onLeave, onDropItems, childr
|
|
|
9485
9485
|
});
|
|
9486
9486
|
}
|
|
9487
9487
|
|
|
9488
|
+
// src/lib/speaker-turns.ts
|
|
9489
|
+
/** The speaker of a stretch nobody could make out: kept, not scored (strata-python `speakers.UNCLEAR`). */
|
|
9490
|
+
const UNCLEAR = "?";
|
|
9491
|
+
const byTime = (a, b) => a.start - b.start || a.end - b.end || a.id.localeCompare(b.id);
|
|
9492
|
+
const sorted = (turns) => [...turns].sort(byTime);
|
|
9493
|
+
const nameOf = (speaker) => speaker === "?" ? "unclear" : speaker;
|
|
9494
|
+
/** An id not yet in `turns`: `base`, else `base-2`, `base-3`… */
|
|
9495
|
+
function freshId(turns, base) {
|
|
9496
|
+
const taken = new Set(turns.map((t) => t.id));
|
|
9497
|
+
if (!taken.has(base)) return base;
|
|
9498
|
+
let n = 2;
|
|
9499
|
+
while (taken.has(`${base}-${n}`)) n++;
|
|
9500
|
+
return `${base}-${n}`;
|
|
9501
|
+
}
|
|
9502
|
+
/** The voices in order of first speech (the unclear stretches last), as a person reads down the lanes. */
|
|
9503
|
+
function voicesOf(turns) {
|
|
9504
|
+
const first = /* @__PURE__ */ new Map();
|
|
9505
|
+
for (const t of turns) if (t.speaker !== "?") first.set(t.speaker, Math.min(first.get(t.speaker) ?? Infinity, t.start));
|
|
9506
|
+
return [...first.entries()].sort((a, b) => a[1] - b[1] || a[0].localeCompare(b[0])).map(([s]) => s);
|
|
9507
|
+
}
|
|
9508
|
+
/** A name for a new voice that is not taken: "Voice 3" when two are named. */
|
|
9509
|
+
function newVoiceName(turns, word = "Voice") {
|
|
9510
|
+
const taken = new Set(turns.map((t) => t.speaker));
|
|
9511
|
+
let n = voicesOf(turns).length + 1;
|
|
9512
|
+
while (taken.has(`${word} ${n}`)) n++;
|
|
9513
|
+
return `${word} ${n}`;
|
|
9514
|
+
}
|
|
9515
|
+
/** The turns that cover `time` (a turn holds its start, not its end), latest start first. */
|
|
9516
|
+
function turnsAt(turns, time) {
|
|
9517
|
+
return turns.filter((t) => t.start <= time && time < t.end).sort((a, b) => b.start - a.start);
|
|
9518
|
+
}
|
|
9519
|
+
/** Cut the turn in two at `time`; the second half gets a fresh id. Nothing to do when `time` is not inside it. */
|
|
9520
|
+
function splitTurn(turns, id, time, format) {
|
|
9521
|
+
const t = turns.find((x) => x.id === id);
|
|
9522
|
+
if (!t || time <= t.start || time >= t.end) return null;
|
|
9523
|
+
const rest = {
|
|
9524
|
+
...t,
|
|
9525
|
+
id: freshId(turns, `${t.id}b`),
|
|
9526
|
+
start: time
|
|
9527
|
+
};
|
|
9528
|
+
return {
|
|
9529
|
+
turns: sorted(turns.flatMap((x) => x.id === id ? [{
|
|
9530
|
+
...x,
|
|
9531
|
+
end: time
|
|
9532
|
+
}, rest] : [x])),
|
|
9533
|
+
step: `Split ${nameOf(t.speaker)} at ${format(time)}`
|
|
9534
|
+
};
|
|
9535
|
+
}
|
|
9536
|
+
/** Give the turns to `speaker` (an existing voice, a new one, or `UNCLEAR`). */
|
|
9537
|
+
function assignTurns(turns, ids, speaker) {
|
|
9538
|
+
const chosen = new Set(ids);
|
|
9539
|
+
const moving = turns.filter((t) => chosen.has(t.id) && t.speaker !== speaker);
|
|
9540
|
+
if (!moving.length) return null;
|
|
9541
|
+
const what = moving.length === 1 ? "turn" : `${moving.length} turns`;
|
|
9542
|
+
return {
|
|
9543
|
+
turns: sorted(turns.map((t) => chosen.has(t.id) ? {
|
|
9544
|
+
...t,
|
|
9545
|
+
speaker
|
|
9546
|
+
} : t)),
|
|
9547
|
+
step: speaker === "?" ? `Marked ${what} unclear` : `Gave ${what} to ${speaker}`
|
|
9548
|
+
};
|
|
9549
|
+
}
|
|
9550
|
+
/** Join the turn with the next turn of the same voice: one turn from the first's start to the later end. */
|
|
9551
|
+
function mergeWithNext(turns, id) {
|
|
9552
|
+
const t = turns.find((x) => x.id === id);
|
|
9553
|
+
if (!t) return null;
|
|
9554
|
+
const next = sorted(turns.filter((x) => x.speaker === t.speaker && x.id !== id && x.start >= t.start))[0];
|
|
9555
|
+
if (!next) return null;
|
|
9556
|
+
return {
|
|
9557
|
+
turns: sorted(turns.filter((x) => x.id !== next.id).map((x) => x.id === id ? {
|
|
9558
|
+
...x,
|
|
9559
|
+
end: Math.max(x.end, next.end)
|
|
9560
|
+
} : x)),
|
|
9561
|
+
step: `Joined two turns of ${nameOf(t.speaker)}`
|
|
9562
|
+
};
|
|
9563
|
+
}
|
|
9564
|
+
/** Move the turn's start or end to `time`; refused (null) where it would leave the turn with no length. */
|
|
9565
|
+
function setEdge(turns, id, edge, time, format) {
|
|
9566
|
+
const t = turns.find((x) => x.id === id);
|
|
9567
|
+
if (!t || (edge === "start" ? time >= t.end : time <= t.start) || t[edge] === time) return null;
|
|
9568
|
+
return {
|
|
9569
|
+
turns: sorted(turns.map((x) => x.id === id ? {
|
|
9570
|
+
...x,
|
|
9571
|
+
[edge]: time
|
|
9572
|
+
} : x)),
|
|
9573
|
+
step: `${nameOf(t.speaker)}'s turn ${edge === "start" ? "starts" : "ends"} at ${format(time)}`
|
|
9574
|
+
};
|
|
9575
|
+
}
|
|
9576
|
+
/** Rename a voice in every turn; joining two voices is renaming one to the other's name. */
|
|
9577
|
+
function renameVoice(turns, from, to) {
|
|
9578
|
+
const name = to.trim();
|
|
9579
|
+
if (!name || name === from || !turns.some((t) => t.speaker === from)) return null;
|
|
9580
|
+
const joined = turns.some((t) => t.speaker === name);
|
|
9581
|
+
return {
|
|
9582
|
+
turns: sorted(turns.map((t) => t.speaker === from ? {
|
|
9583
|
+
...t,
|
|
9584
|
+
speaker: name
|
|
9585
|
+
} : t)),
|
|
9586
|
+
step: joined ? `Joined ${from} into ${name}` : `Renamed ${from} to ${name}`
|
|
9587
|
+
};
|
|
9588
|
+
}
|
|
9589
|
+
/** Take the turns out. */
|
|
9590
|
+
function removeTurns(turns, ids) {
|
|
9591
|
+
const gone = new Set(ids);
|
|
9592
|
+
const n = turns.filter((t) => gone.has(t.id)).length;
|
|
9593
|
+
if (!n) return null;
|
|
9594
|
+
return {
|
|
9595
|
+
turns: turns.filter((t) => !gone.has(t.id)),
|
|
9596
|
+
step: n === 1 ? "Removed a turn" : `Removed ${n} turns`
|
|
9597
|
+
};
|
|
9598
|
+
}
|
|
9599
|
+
/** Add copies of other turns (another answer's) under `speaker`, or under their own speaker's name when none is given. */
|
|
9600
|
+
function copyTurns(turns, from, speaker) {
|
|
9601
|
+
if (!from.length) return null;
|
|
9602
|
+
const out = [...turns];
|
|
9603
|
+
for (const t of from) out.push({
|
|
9604
|
+
...t,
|
|
9605
|
+
id: freshId(out, `${t.id}c`),
|
|
9606
|
+
speaker: speaker ?? t.speaker
|
|
9607
|
+
});
|
|
9608
|
+
return {
|
|
9609
|
+
turns: sorted(out),
|
|
9610
|
+
step: from.length === 1 ? "Copied a turn" : `Copied ${from.length} turns`
|
|
9611
|
+
};
|
|
9612
|
+
}
|
|
9613
|
+
|
|
9614
|
+
// src/components/speaker-timeline.tsx
|
|
9615
|
+
const voiceLane = (name) => `v:${name}`;
|
|
9616
|
+
const UNCLEAR_LANE = "u";
|
|
9617
|
+
const refLane = (ref) => `r:${ref}`;
|
|
9618
|
+
const ownItem = (turn) => `t:${turn}`;
|
|
9619
|
+
const refItem = (ref, turn) => `r:${ref.length}:${ref}:${turn}`;
|
|
9620
|
+
const isOwnItem = (id) => id.startsWith("t:");
|
|
9621
|
+
const turnOf = (id) => id.slice(2);
|
|
9622
|
+
const laneOf = (speaker) => speaker === "?" ? UNCLEAR_LANE : voiceLane(speaker);
|
|
9623
|
+
const speakerOf = (lane) => lane === UNCLEAR_LANE ? "?" : lane.startsWith("v:") ? lane.slice(2) : null;
|
|
9624
|
+
const defaultFormat = (t) => {
|
|
9625
|
+
const s = Math.max(0, Math.round(t * 10) / 10);
|
|
9626
|
+
const m = Math.floor(s / 60);
|
|
9627
|
+
const sec = s - m * 60;
|
|
9628
|
+
return `${m}:${Number.isInteger(sec) ? String(sec).padStart(2, "0") : sec.toFixed(1).padStart(4, "0")}`;
|
|
9629
|
+
};
|
|
9630
|
+
/** Correct who spoke when: the person's turns as a lane per voice, other answers read-only beneath, and keys to split at the playhead, give turns to a voice, join, mark unclear and copy. Reports each edit with its name; the app holds the turns. */
|
|
9631
|
+
function SpeakerTimeline({ label, turns, onChange, references = [], from = 0, to, zoom, onZoomChange, position, onPositionChange, follow, selectedIds, onSelect, unclearLabel = "Unclear", legend = true, formatTime = defaultFormat, className }) {
|
|
9632
|
+
const region = React.useRef(null);
|
|
9633
|
+
const [ownSelection, setOwnSelection] = React.useState(/* @__PURE__ */ new Set());
|
|
9634
|
+
const outside = selectedIds ?? ownSelection;
|
|
9635
|
+
const turnIds = new Set(turns.map((t) => t.id));
|
|
9636
|
+
const selected = new Set([...outside].map((id) => turnIds.has(id) ? ownItem(id) : id));
|
|
9637
|
+
const select = (ids) => {
|
|
9638
|
+
const out = ids.map((id) => isOwnItem(id) ? turnOf(id) : id);
|
|
9639
|
+
if (!selectedIds) setOwnSelection(new Set(out));
|
|
9640
|
+
onSelect?.(out);
|
|
9641
|
+
};
|
|
9642
|
+
const voices = voicesOf(turns);
|
|
9643
|
+
const refocus = React.useRef(null);
|
|
9644
|
+
React.useEffect(() => {
|
|
9645
|
+
const id = refocus.current;
|
|
9646
|
+
refocus.current = null;
|
|
9647
|
+
if (id) region.current?.querySelector(`[data-item="${CSS.escape(ownItem(id))}"]`)?.focus();
|
|
9648
|
+
}, [turns]);
|
|
9649
|
+
const apply = (edit, focus) => {
|
|
9650
|
+
if (!edit) return;
|
|
9651
|
+
refocus.current = focus ?? null;
|
|
9652
|
+
onChange(edit);
|
|
9653
|
+
};
|
|
9654
|
+
const [renaming, setRenaming] = React.useState(null);
|
|
9655
|
+
const [name, setName] = React.useState("");
|
|
9656
|
+
const rename = (from) => {
|
|
9657
|
+
apply(renameVoice(turns, from, name));
|
|
9658
|
+
setRenaming(null);
|
|
9659
|
+
};
|
|
9660
|
+
const lanes = [
|
|
9661
|
+
...voices.map((v, i) => ({
|
|
9662
|
+
id: voiceLane(v),
|
|
9663
|
+
label: v,
|
|
9664
|
+
header: /* @__PURE__ */ jsxs("span", {
|
|
9665
|
+
className: "flex items-center gap-1",
|
|
9666
|
+
children: [i < 9 && /* @__PURE__ */ jsx("kbd", {
|
|
9667
|
+
"aria-hidden": true,
|
|
9668
|
+
className: "type-caption text-muted-foreground",
|
|
9669
|
+
children: i + 1
|
|
9670
|
+
}), /* @__PURE__ */ jsx(Popover, {
|
|
9671
|
+
label: `Rename ${v}`,
|
|
9672
|
+
size: "sm",
|
|
9673
|
+
open: renaming === v,
|
|
9674
|
+
onOpenChange: (open) => {
|
|
9675
|
+
setRenaming(open ? v : null);
|
|
9676
|
+
setName(v);
|
|
9677
|
+
},
|
|
9678
|
+
trigger: /* @__PURE__ */ jsx(IconButton, {
|
|
9679
|
+
icon: Pencil,
|
|
9680
|
+
size: "sm",
|
|
9681
|
+
label: `Rename ${v}`
|
|
9682
|
+
}),
|
|
9683
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
9684
|
+
className: "grid gap-2",
|
|
9685
|
+
onSubmit: (e) => {
|
|
9686
|
+
e.preventDefault();
|
|
9687
|
+
rename(v);
|
|
9688
|
+
},
|
|
9689
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
9690
|
+
label: "Name",
|
|
9691
|
+
hint: "A name already in use joins the two voices.",
|
|
9692
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
9693
|
+
value: name,
|
|
9694
|
+
onChange: (e) => setName(e.target.value),
|
|
9695
|
+
autoFocus: true
|
|
9696
|
+
})
|
|
9697
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9698
|
+
type: "submit",
|
|
9699
|
+
children: "Rename"
|
|
9700
|
+
})]
|
|
9701
|
+
})
|
|
9702
|
+
})]
|
|
9703
|
+
})
|
|
9704
|
+
})),
|
|
9705
|
+
{
|
|
9706
|
+
id: UNCLEAR_LANE,
|
|
9707
|
+
label: unclearLabel
|
|
9708
|
+
},
|
|
9709
|
+
...references.map((r) => ({
|
|
9710
|
+
id: refLane(r.id),
|
|
9711
|
+
label: r.label
|
|
9712
|
+
}))
|
|
9713
|
+
];
|
|
9714
|
+
const items = [...turns.map((t) => ({
|
|
9715
|
+
id: ownItem(t.id),
|
|
9716
|
+
lane: laneOf(t.speaker),
|
|
9717
|
+
start: t.start,
|
|
9718
|
+
length: t.end - t.start,
|
|
9719
|
+
label: t.speaker === "?" ? unclearLabel : t.speaker
|
|
9720
|
+
})), ...references.flatMap((r) => r.turns.map((t) => ({
|
|
9721
|
+
id: refItem(r.id, t.id),
|
|
9722
|
+
lane: refLane(r.id),
|
|
9723
|
+
start: t.start,
|
|
9724
|
+
length: t.end - t.start,
|
|
9725
|
+
label: `${r.label}: ${t.speaker}`,
|
|
9726
|
+
kind: t.speaker
|
|
9727
|
+
})))];
|
|
9728
|
+
const own = (ids) => [...ids].filter(isOwnItem).map(turnOf);
|
|
9729
|
+
const refTurns = new Map(references.flatMap((r) => r.turns.map((t) => [refItem(r.id, t.id), t])));
|
|
9730
|
+
const fromRefs = (ids) => [...ids].flatMap((id) => refTurns.get(id) ?? []);
|
|
9731
|
+
const readOnly = "Another answer is read-only: choose its turns and press C to copy them into the voices above.";
|
|
9732
|
+
const validate = (item, next) => !isOwnItem(item) || speakerOf(next.lane) === null ? readOnly : null;
|
|
9733
|
+
const onItemChange = (item, next) => {
|
|
9734
|
+
const id = turnOf(item);
|
|
9735
|
+
const t = turns.find((x) => x.id === id);
|
|
9736
|
+
const to = speakerOf(next.lane);
|
|
9737
|
+
if (!isOwnItem(item) || !t || to === null) return;
|
|
9738
|
+
if (to !== t.speaker) {
|
|
9739
|
+
const moved = turns.map((x) => x.id === id ? {
|
|
9740
|
+
...x,
|
|
9741
|
+
start: next.start,
|
|
9742
|
+
end: next.start + next.length
|
|
9743
|
+
} : x);
|
|
9744
|
+
return apply(assignTurns(moved, [id], to), id);
|
|
9745
|
+
}
|
|
9746
|
+
const end = next.start + next.length;
|
|
9747
|
+
const what = t.speaker === "?" ? unclearLabel : `${t.speaker}'s turn`;
|
|
9748
|
+
onChange({
|
|
9749
|
+
turns: turns.map((x) => x.id === id ? {
|
|
9750
|
+
...x,
|
|
9751
|
+
start: next.start,
|
|
9752
|
+
end
|
|
9753
|
+
} : x).sort((a, b) => a.start - b.start),
|
|
9754
|
+
step: next.length === t.end - t.start ? `Moved ${what} to ${formatTime(next.start)}` : `Trimmed ${what}`
|
|
9755
|
+
});
|
|
9756
|
+
};
|
|
9757
|
+
const chosen = own(selected);
|
|
9758
|
+
const one = chosen.length === 1 ? chosen[0] : null;
|
|
9759
|
+
const focused = () => {
|
|
9760
|
+
const at = document.activeElement?.closest("[data-item]")?.dataset.item;
|
|
9761
|
+
return at && isOwnItem(at) && chosen.includes(turnOf(at)) ? turnOf(at) : one;
|
|
9762
|
+
};
|
|
9763
|
+
const atPlayhead = turnsAt(turns, position)[0]?.id ?? null;
|
|
9764
|
+
const shortcuts = [
|
|
9765
|
+
{
|
|
9766
|
+
keys: ["s"],
|
|
9767
|
+
label: "Split at the playhead",
|
|
9768
|
+
run: () => apply(splitTurn(turns, one ?? atPlayhead ?? "", position, formatTime))
|
|
9769
|
+
},
|
|
9770
|
+
...voices.slice(0, 9).map((v, i) => ({
|
|
9771
|
+
keys: [String(i + 1)],
|
|
9772
|
+
label: `Give to ${v}`,
|
|
9773
|
+
id: `voice-${i + 1}`,
|
|
9774
|
+
run: () => apply(assignTurns(turns, chosen, v), focused()),
|
|
9775
|
+
disabled: !chosen.length
|
|
9776
|
+
})),
|
|
9777
|
+
{
|
|
9778
|
+
keys: ["n"],
|
|
9779
|
+
label: "Give to a new voice",
|
|
9780
|
+
run: () => apply(assignTurns(turns, chosen, newVoiceName(turns)), focused()),
|
|
9781
|
+
disabled: !chosen.length
|
|
9782
|
+
},
|
|
9783
|
+
{
|
|
9784
|
+
keys: ["u"],
|
|
9785
|
+
label: `Mark ${unclearLabel.toLowerCase()}`,
|
|
9786
|
+
run: () => apply(assignTurns(turns, chosen, "?"), focused()),
|
|
9787
|
+
disabled: !chosen.length
|
|
9788
|
+
},
|
|
9789
|
+
{
|
|
9790
|
+
keys: ["m"],
|
|
9791
|
+
label: "Join with the voice's next turn",
|
|
9792
|
+
run: () => one && apply(mergeWithNext(turns, one)),
|
|
9793
|
+
disabled: !one
|
|
9794
|
+
},
|
|
9795
|
+
{
|
|
9796
|
+
keys: ["["],
|
|
9797
|
+
label: "Start at the playhead",
|
|
9798
|
+
run: () => one && apply(setEdge(turns, one, "start", position, formatTime)),
|
|
9799
|
+
disabled: !one
|
|
9800
|
+
},
|
|
9801
|
+
{
|
|
9802
|
+
keys: ["]"],
|
|
9803
|
+
label: "End at the playhead",
|
|
9804
|
+
run: () => one && apply(setEdge(turns, one, "end", position, formatTime)),
|
|
9805
|
+
disabled: !one
|
|
9806
|
+
},
|
|
9807
|
+
{
|
|
9808
|
+
keys: ["c"],
|
|
9809
|
+
label: "Copy into the voices",
|
|
9810
|
+
run: () => apply(copyTurns(turns, fromRefs(selected))),
|
|
9811
|
+
disabled: !fromRefs(selected).length
|
|
9812
|
+
}
|
|
9813
|
+
];
|
|
9814
|
+
useHotkeys(shortcuts, { within: region });
|
|
9815
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
9816
|
+
ref: region,
|
|
9817
|
+
className: cn("grid min-w-0 gap-2", className),
|
|
9818
|
+
children: [/* @__PURE__ */ jsx(Timeline, {
|
|
9819
|
+
label,
|
|
9820
|
+
lanes,
|
|
9821
|
+
items,
|
|
9822
|
+
from,
|
|
9823
|
+
to,
|
|
9824
|
+
zoom,
|
|
9825
|
+
onZoomChange,
|
|
9826
|
+
position,
|
|
9827
|
+
onPositionChange,
|
|
9828
|
+
follow,
|
|
9829
|
+
selectedIds: selected,
|
|
9830
|
+
onSelect: select,
|
|
9831
|
+
onItemChange,
|
|
9832
|
+
onDelete: (ids) => apply(removeTurns(turns, own(ids))),
|
|
9833
|
+
validate,
|
|
9834
|
+
step: .1,
|
|
9835
|
+
minLength: .1,
|
|
9836
|
+
snap: false,
|
|
9837
|
+
formatTime
|
|
9838
|
+
}), legend && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })]
|
|
9839
|
+
});
|
|
9840
|
+
}
|
|
9841
|
+
|
|
9488
9842
|
// src/components/sortable-list.tsx
|
|
9489
9843
|
const KIND = "strata-kind/";
|
|
9490
9844
|
const ID = "strata-item/id";
|
|
@@ -25777,5 +26131,102 @@ function TurnArrow({ facing, turn, label, className }) {
|
|
|
25777
26131
|
});
|
|
25778
26132
|
}
|
|
25779
26133
|
|
|
25780
|
-
|
|
26134
|
+
// src/components/partial-date-field.tsx
|
|
26135
|
+
const PARTIAL_DATE_RE = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;
|
|
26136
|
+
/** Parse and validate a partial ISO date (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`), checking calendar month and day limits. */
|
|
26137
|
+
function parsePartialDate(raw, circa = false) {
|
|
26138
|
+
const trimmed = raw.trim();
|
|
26139
|
+
if (!trimmed) return {
|
|
26140
|
+
ok: true,
|
|
26141
|
+
value: null
|
|
26142
|
+
};
|
|
26143
|
+
const m = PARTIAL_DATE_RE.exec(trimmed);
|
|
26144
|
+
if (!m) return {
|
|
26145
|
+
ok: false,
|
|
26146
|
+
error: "Use YYYY, YYYY-MM or YYYY-MM-DD (for example 1985 or 1985-06-15)."
|
|
26147
|
+
};
|
|
26148
|
+
const year = Number(m[1]);
|
|
26149
|
+
if (year < 1 || year > 9999) return {
|
|
26150
|
+
ok: false,
|
|
26151
|
+
error: "Enter a four-digit year between 0001 and 9999."
|
|
26152
|
+
};
|
|
26153
|
+
let inferred = "year";
|
|
26154
|
+
if (m[2] !== void 0) {
|
|
26155
|
+
const month = Number(m[2]);
|
|
26156
|
+
if (month < 1 || month > 12) return {
|
|
26157
|
+
ok: false,
|
|
26158
|
+
error: "Month must be between 01 and 12."
|
|
26159
|
+
};
|
|
26160
|
+
inferred = "month";
|
|
26161
|
+
if (m[3] !== void 0) {
|
|
26162
|
+
const day = Number(m[3]);
|
|
26163
|
+
const check = new Date(Date.UTC(year, month - 1, day));
|
|
26164
|
+
if (check.getUTCFullYear() !== year || check.getUTCMonth() !== month - 1 || check.getUTCDate() !== day) return {
|
|
26165
|
+
ok: false,
|
|
26166
|
+
error: `${trimmed} is not a valid calendar date.`
|
|
26167
|
+
};
|
|
26168
|
+
inferred = "day";
|
|
26169
|
+
}
|
|
26170
|
+
}
|
|
26171
|
+
return {
|
|
26172
|
+
ok: true,
|
|
26173
|
+
value: {
|
|
26174
|
+
date: trimmed,
|
|
26175
|
+
precision: circa ? "circa" : inferred
|
|
26176
|
+
}
|
|
26177
|
+
};
|
|
26178
|
+
}
|
|
26179
|
+
/** Format a partial date for display (prefixes `circa` dates with `c. `). */
|
|
26180
|
+
function formatPartialDate(value) {
|
|
26181
|
+
if (!value) return "";
|
|
26182
|
+
return value.precision === "circa" ? `c. ${value.date}` : value.date;
|
|
26183
|
+
}
|
|
26184
|
+
/** Input for an uncertain or partial ISO date (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`) with an optional approximate toggle. Wrap in `Field`. */
|
|
26185
|
+
function PartialDateField({ value, onChange, placeholder = "YYYY, YYYY-MM or YYYY-MM-DD", allowCirca = true, circaLabel = "Approximate", disabled = false, className }) {
|
|
26186
|
+
const { report } = useFieldControl();
|
|
26187
|
+
const [draft, setDraft] = React.useState(value?.date ?? "");
|
|
26188
|
+
const [circa, setCirca] = React.useState(value?.precision === "circa");
|
|
26189
|
+
React.useEffect(() => {
|
|
26190
|
+
setDraft(value?.date ?? "");
|
|
26191
|
+
setCirca(value?.precision === "circa");
|
|
26192
|
+
report(void 0);
|
|
26193
|
+
}, [
|
|
26194
|
+
value?.date,
|
|
26195
|
+
value?.precision,
|
|
26196
|
+
report
|
|
26197
|
+
]);
|
|
26198
|
+
const commit = (nextDraft, nextCirca, showError) => {
|
|
26199
|
+
const parsed = parsePartialDate(nextDraft, allowCirca && nextCirca);
|
|
26200
|
+
if (parsed.ok) {
|
|
26201
|
+
report(void 0);
|
|
26202
|
+
onChange(parsed.value);
|
|
26203
|
+
} else if (showError) report(parsed.error);
|
|
26204
|
+
};
|
|
26205
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
26206
|
+
className: cn("flex flex-wrap items-center gap-3", className),
|
|
26207
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
26208
|
+
value: draft,
|
|
26209
|
+
disabled,
|
|
26210
|
+
placeholder,
|
|
26211
|
+
inputMode: "numeric",
|
|
26212
|
+
className: "min-w-44 flex-1 tabular-nums",
|
|
26213
|
+
onChange: (e) => {
|
|
26214
|
+
const next = e.target.value;
|
|
26215
|
+
setDraft(next);
|
|
26216
|
+
commit(next, circa, false);
|
|
26217
|
+
},
|
|
26218
|
+
onBlur: () => commit(draft, circa, true)
|
|
26219
|
+
}), allowCirca && /* @__PURE__ */ jsx(Checkbox, {
|
|
26220
|
+
label: circaLabel,
|
|
26221
|
+
checked: circa,
|
|
26222
|
+
disabled,
|
|
26223
|
+
onCheckedChange: (checked) => {
|
|
26224
|
+
setCirca(checked);
|
|
26225
|
+
commit(draft, checked, Boolean(draft.trim()));
|
|
26226
|
+
}
|
|
26227
|
+
})]
|
|
26228
|
+
});
|
|
26229
|
+
}
|
|
26230
|
+
|
|
26231
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, Balance, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CLOCK_FACE_STYLES, CLOCK_STYLES, COINS, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FACINGS, FIT, FRACTION_OUTLINES, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FillLevel, FilmStrip, FolderPicker, FractionShape, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, JsonView, KeysLegend, LEVEL_FLOOR_DB, LengthBar, 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, Money, NBSP, NOTES, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PartialDateField, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SOLID_SHAPES, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, Slider, Solid, SortableList, SpanActions, SpanStrip, SpeakerTimeline, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, TurnArrow, UNCLEAR, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, assignTurns, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, coinOutline, colorSchemeScript, commandShortcut, continues, copyTurns, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, fillWords, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, formatPartialDate, fractionParts, fractionWords, frameAt, freshId, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, jsonBranchPaths, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, mergeWithNext, minutesAt, moneyWords, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, newVoiceName, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parsePartialDate, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, removeTurns, renameVoice, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, setEdge, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, solidWords, sortRows, speak, speechLevel, splitRect, splitTurn, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnWords, turned, turnedSize, turnsAt, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, voicesOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
25781
26232
|
//# sourceMappingURL=index.js.map
|