@miadi/stateloom-canvas 0.1.6 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CompanionDock.d.ts +56 -5
- package/dist/CompanionDock.js +35 -11
- package/dist/MarkCards.d.ts +52 -7
- package/dist/MarkCards.js +59 -15
- package/dist/StageCaption.d.ts +22 -6
- package/dist/StageCaption.js +6 -3
- package/dist/StageOverlay.d.ts +17 -2
- package/dist/StageOverlay.js +43 -5
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +11 -6
- package/dist/index.js +17 -3
- package/dist/marksRead.d.ts +12 -0
- package/dist/marksRead.js +64 -0
- package/dist/names.d.ts +48 -0
- package/dist/names.js +90 -0
- package/dist/pins.d.ts +50 -0
- package/dist/pins.js +108 -0
- package/dist/styles.css +236 -22
- package/package.json +4 -2
package/dist/CompanionDock.d.ts
CHANGED
|
@@ -4,9 +4,17 @@
|
|
|
4
4
|
* The phone page's conversation, folded into a corner of the board: one button records a
|
|
5
5
|
* take (Record → Stop & send → Sending…, Send again when a send failed), the line under
|
|
6
6
|
* it says what happened, and the conversation reads newest first — the person's takes
|
|
7
|
-
* (with the drawing they were looking at)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* (with the drawing they were looking at), the companion's replies, each with ▶ to hear
|
|
8
|
+
* it walk the diagram again and a thumb, and the person's marks on the episode's drawings
|
|
9
|
+
* with their threads ("You marked Witnessing on Screenwalk", the words, the companion's
|
|
10
|
+
* answers, whether it waits). A mark has no play button and no thumb; tapping it opens
|
|
11
|
+
* that drawing at that mark (`onOpenMark`). A reply that answers a mark says which.
|
|
12
|
+
*
|
|
13
|
+
* Who is in the room is said in words in the header ("listening", "answering take 12",
|
|
14
|
+
* "away"), never by a coloured dot alone. Closed, it is one round button (`variant:
|
|
15
|
+
* "fab"`) that shows the clock while recording and how many replies are new, or — on a
|
|
16
|
+
* phone, where the host makes it the handle of the sheet at the bottom of the board —
|
|
17
|
+
* a bar across the width (`variant: "bar"`) that says the same in words.
|
|
10
18
|
*
|
|
11
19
|
* Props in, callbacks out: the host holds the recorder, the conversation and the stage
|
|
12
20
|
* (`createTakeRecorder`, `createCompanionThread`, `present` in `@miadi/stateloom-react`).
|
|
@@ -47,11 +55,54 @@ export interface DockReply {
|
|
|
47
55
|
unvoiced?: string;
|
|
48
56
|
feedback?: "up" | "down";
|
|
49
57
|
steps?: DockStep[];
|
|
58
|
+
/** The mark this reply answers, in its thread and in the companion's voice. */
|
|
59
|
+
mark?: {
|
|
60
|
+
id: string;
|
|
61
|
+
doc: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** A person's (or the companion's) mark on one of the episode's drawings, with its thread. */
|
|
65
|
+
export interface DockMark {
|
|
66
|
+
kind: "mark";
|
|
67
|
+
id: string;
|
|
68
|
+
/** The drawing, absolute. */
|
|
69
|
+
doc: string;
|
|
70
|
+
/** Its file name. */
|
|
71
|
+
drawing?: string;
|
|
72
|
+
/** Its own name (settings.name), when it has one. */
|
|
73
|
+
title?: string;
|
|
74
|
+
elements: string[];
|
|
75
|
+
region?: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
width: number;
|
|
79
|
+
height: number;
|
|
80
|
+
};
|
|
81
|
+
text: string;
|
|
82
|
+
author: {
|
|
83
|
+
name: string;
|
|
84
|
+
role: "person" | "agent";
|
|
85
|
+
};
|
|
86
|
+
at: string;
|
|
87
|
+
lastAt?: string;
|
|
88
|
+
status: "open" | "answered" | "resolved";
|
|
89
|
+
replies: {
|
|
90
|
+
author: {
|
|
91
|
+
name: string;
|
|
92
|
+
role: "person" | "agent";
|
|
93
|
+
};
|
|
94
|
+
text: string;
|
|
95
|
+
at: string;
|
|
96
|
+
}[];
|
|
50
97
|
}
|
|
51
|
-
export type DockItem = DockTake | DockReply;
|
|
98
|
+
export type DockItem = DockTake | DockReply | DockMark;
|
|
52
99
|
export interface CompanionDockProps {
|
|
53
100
|
open: boolean;
|
|
54
101
|
onOpenChange: (open: boolean) => void;
|
|
102
|
+
/** Closed: a round button (default), or a bar across the width that names the room in words. */
|
|
103
|
+
variant?: "fab" | "bar";
|
|
104
|
+
/** Open the drawing a mark is on, at that mark's thread. Absent: marks are read, not opened. */
|
|
105
|
+
onOpenMark?: (mark: DockMark) => void;
|
|
55
106
|
/** Who answers. Default "Mia". */
|
|
56
107
|
who?: string;
|
|
57
108
|
episode: string | null;
|
|
@@ -97,5 +148,5 @@ export interface CompanionDockProps {
|
|
|
97
148
|
className?: string;
|
|
98
149
|
style?: CSSProperties;
|
|
99
150
|
}
|
|
100
|
-
export declare function CompanionDock({ open, onOpenChange, who, episode, episodes, onEpisode, presence, recorder, onRecord, items, unheard, playing, playingStep, onPlay, onStop, onFeedback, autoplay, onAutoplay, waiting, notice, error, theme, className, style, }: CompanionDockProps): import("react").JSX.Element;
|
|
151
|
+
export declare function CompanionDock({ open, onOpenChange, variant, onOpenMark, who, episode, episodes, onEpisode, presence, recorder, onRecord, items, unheard, playing, playingStep, onPlay, onStop, onFeedback, autoplay, onAutoplay, waiting, notice, error, theme, className, style, }: CompanionDockProps): import("react").JSX.Element;
|
|
101
152
|
export default CompanionDock;
|
package/dist/CompanionDock.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { themeStyle } from "./theme.js";
|
|
3
|
-
import { CloseIcon, MicIcon, PlayIcon, SpeakerIcon, StopIcon, ThumbDownIcon, ThumbUpIcon } from "./icons.js";
|
|
3
|
+
import { CloseIcon, MicIcon, PinIcon, PlayIcon, SpeakerIcon, StopIcon, ThumbDownIcon, ThumbUpIcon } from "./icons.js";
|
|
4
|
+
import { drawingName, markPlace, markStanding, marksSummary } from "./names.js";
|
|
4
5
|
const clock = (s) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
5
6
|
const when = (iso) => {
|
|
6
7
|
const d = new Date(iso);
|
|
@@ -20,18 +21,28 @@ function litOf(step) {
|
|
|
20
21
|
}
|
|
21
22
|
function presenceLine(who, presence, episode) {
|
|
22
23
|
if (!episode)
|
|
23
|
-
return { text: "Choose the episode you are speaking in.", away: true };
|
|
24
|
+
return { text: "Choose the episode you are speaking in.", word: "no episode", away: true };
|
|
24
25
|
switch (presence?.state) {
|
|
25
26
|
case "listening":
|
|
26
|
-
return { text: `${who} is listening.`, away: false };
|
|
27
|
-
case "answering":
|
|
28
|
-
|
|
27
|
+
return { text: `${who} is listening.`, word: "listening", away: false };
|
|
28
|
+
case "answering": {
|
|
29
|
+
const takes = presence.takes?.length ? ` take ${presence.takes.join(", ")}` : "";
|
|
30
|
+
return { text: `${who} is answering${takes}.`, word: `answering${takes}`, away: false };
|
|
31
|
+
}
|
|
29
32
|
case "answered":
|
|
30
|
-
return { text: `${who} has answered and is getting ready to listen again.`, away: false };
|
|
33
|
+
return { text: `${who} has answered and is getting ready to listen again.`, word: "answered", away: false };
|
|
31
34
|
default:
|
|
32
|
-
return { text: `Nobody is listening yet. A take waits in the episode until ${who} does.`, away: true };
|
|
35
|
+
return { text: `Nobody is listening yet. A take waits in the episode until ${who} does.`, word: "away", away: true };
|
|
33
36
|
}
|
|
34
37
|
}
|
|
38
|
+
/** Who said it, as the conversation names them: the person is "You". */
|
|
39
|
+
const speaker = (author, who) => (author.role === "agent" ? author.name || who : "You");
|
|
40
|
+
const STANDING_TEXT = (who) => ({
|
|
41
|
+
"waits for agent": `waits for ${who}`,
|
|
42
|
+
"waits for you": "waits for you",
|
|
43
|
+
answered: "answered",
|
|
44
|
+
resolved: "resolved",
|
|
45
|
+
});
|
|
35
46
|
const RECORD_LABEL = {
|
|
36
47
|
idle: "● Record",
|
|
37
48
|
starting: "Opening the mic…",
|
|
@@ -39,21 +50,34 @@ const RECORD_LABEL = {
|
|
|
39
50
|
sending: "Sending…",
|
|
40
51
|
retry: "Send again",
|
|
41
52
|
};
|
|
42
|
-
export function CompanionDock({ open, onOpenChange, who = "Mia", episode, episodes, onEpisode, presence, recorder, onRecord, items, unheard = [], playing = null, playingStep = null, onPlay, onStop, onFeedback, autoplay, onAutoplay, waiting, notice, error, theme, className, style, }) {
|
|
53
|
+
export function CompanionDock({ open, onOpenChange, variant = "fab", onOpenMark, who = "Mia", episode, episodes, onEpisode, presence, recorder, onRecord, items, unheard = [], playing = null, playingStep = null, onPlay, onStop, onFeedback, autoplay, onAutoplay, waiting, notice, error, theme, className, style, }) {
|
|
43
54
|
const live = recorder.state === "recording";
|
|
44
55
|
const busy = recorder.state === "starting" || recorder.state === "sending";
|
|
45
56
|
const fresh = unheard.length;
|
|
57
|
+
const line = presenceLine(who, presence, episode);
|
|
58
|
+
if (!open && variant === "bar") {
|
|
59
|
+
return (_jsx("div", { className: `slc-talk slc-talk--bar${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, children: _jsxs("button", { type: "button", className: `slc-talk-bar${live ? " slc-talk-bar--live" : ""}${!live && playing ? " slc-talk-bar--speaking" : ""}`, onClick: () => (live ? onRecord() : onOpenChange(true)), "aria-label": live ? `Stop and send (${clock(recorder.seconds)})` : `Talk with ${who}: ${line.word}${fresh ? `, ${fresh} new` : ""}. Open the conversation`, title: live ? "Stop and send your take" : `Talk with ${who} about what is on the canvas`, children: [live ? _jsx(StopIcon, {}) : playing ? _jsx(SpeakerIcon, {}) : _jsx(MicIcon, {}), _jsx("span", { className: "slc-talk-bar-title", children: live ? "Stop and send" : playing ? `${who} is speaking` : `Talk with ${who}` }), live ? (_jsx("span", { className: "slc-talk-clock", children: clock(recorder.seconds) })) : (!playing && _jsx("span", { className: `slc-talk-state${line.away ? " slc-talk-state--away" : ""}`, children: line.word })), _jsx("span", { className: "slc-stage-spacer" }), !live && fresh > 0 && _jsxs("span", { className: "slc-talk-new", children: [fresh, " new"] })] }) }));
|
|
60
|
+
}
|
|
46
61
|
if (!open) {
|
|
47
62
|
return (_jsx("div", { className: `slc-talk${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, children: _jsxs("button", { type: "button", className: `slc-talk-fab${live ? " slc-talk-fab--live" : ""}${!live && playing ? " slc-talk-fab--speaking" : ""}`, onClick: () => (live ? onRecord() : onOpenChange(true)), "aria-label": live ? `Stop and send (${clock(recorder.seconds)})` : playing ? `${who} is speaking. Open the conversation` : `Talk with ${who}${fresh ? `, ${fresh} new` : ""}`, title: live ? "Stop and send your take" : playing ? `${who} is walking the diagram` : `Talk with ${who} about what is on the canvas`, children: [live ? _jsx("span", { className: "slc-talk-fab-clock", children: clock(recorder.seconds) }) : playing ? _jsx(SpeakerIcon, { size: 24 }) : _jsx(MicIcon, { size: 24 }), !live && fresh > 0 && _jsx("span", { className: "slc-talk-fab-badge", children: fresh })] }) }));
|
|
48
63
|
}
|
|
49
|
-
const line = presenceLine(who, presence, episode);
|
|
50
64
|
const newest = [...items].reverse();
|
|
51
|
-
|
|
65
|
+
const marks = items.filter((i) => i.kind === "mark");
|
|
66
|
+
const marksById = new Map(marks.map((m) => [m.id, m]));
|
|
67
|
+
const saidAny = items.some((i) => i.kind === "take" || i.kind === "reply");
|
|
68
|
+
const standing = STANDING_TEXT(who);
|
|
69
|
+
/** "Witnessing on Screenwalk": what a mark points at, on which drawing. */
|
|
70
|
+
const placeOf = (m) => `${markPlace(m)} on ${drawingName(m.doc ?? m.drawing, m.title)}`;
|
|
71
|
+
return (_jsx("div", { className: `slc-talk slc-talk--open${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, children: _jsxs("section", { className: "slc-talk-panel", "aria-label": `Conversation with ${who}`, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("header", { className: "slc-talk-head", children: [_jsxs("span", { className: "slc-talk-title", children: [_jsx(MicIcon, {}), " Talk with ", who] }), _jsx("span", { className: `slc-talk-state${line.away ? " slc-talk-state--away" : ""}`, title: line.text, children: line.word }), _jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: () => onOpenChange(false), "aria-label": "Close the conversation", children: _jsx(CloseIcon, {}) })] }), episodes?.length && onEpisode ? (_jsxs("select", { className: "slc-stage-input slc-talk-episode", value: episode ?? "", onChange: (e) => onEpisode(e.target.value), disabled: live || busy, "aria-label": "The episode this conversation belongs to", children: [!episode && _jsx("option", { value: "", children: "Choose the episode\u2026" }), episodes.map((ep) => (_jsxs("option", { value: ep.path, children: [ep.number ? `${String(ep.number).padStart(3, "0")} · ` : "", ep.path.replace(/^\d{4}-\d{2}-\d{2}-episode-\d+-/, "")] }, ep.path)))] })) : (_jsx("div", { className: "slc-talk-meta", children: episode ?? "No episode chosen." })), _jsx("div", { className: `slc-talk-meta${line.away ? " slc-talk-meta--away" : ""}`, children: line.text }), _jsxs("button", { type: "button", className: `slc-talk-record${live ? " slc-talk-record--live" : ""}${recorder.state === "retry" ? " slc-talk-record--retry" : ""}`, onClick: onRecord, disabled: busy || !!recorder.unavailable || !episode, title: recorder.unavailable ? `Cannot record: ${recorder.unavailable}` : live ? "Stop and send your take" : "Speak to the episode, about what is on the canvas", children: [RECORD_LABEL[recorder.state], live && _jsx("span", { className: "slc-talk-clock", children: clock(recorder.seconds) })] }), recorder.unavailable && _jsxs("div", { className: "slc-talk-meta slc-talk-meta--error", children: ["Cannot record here: ", recorder.unavailable, "."] }), recorder.message && _jsx("div", { className: `slc-talk-meta${recorder.error ? " slc-talk-meta--error" : ""}`, children: recorder.message }), waiting && _jsxs("div", { className: "slc-talk-meta", children: ["Waiting for ", who, "\u2026 ", clock(waiting.seconds)] }), notice && _jsx("div", { className: "slc-talk-notice", children: notice }), error && _jsx("div", { className: "slc-talk-meta slc-talk-meta--error", children: error }), _jsxs("label", { className: "slc-talk-toggle", children: [_jsx("input", { type: "checkbox", checked: autoplay, onChange: (e) => onAutoplay(e.target.checked) }), "Play ", who, "'s replies on the diagram as they arrive"] }), _jsxs("ol", { className: "slc-talk-thread", children: [newest.length === 0 && (_jsx("li", { className: "slc-stage-empty", children: "Nothing said or marked in this episode yet. Look at a drawing, press Record, and speak, or mark it." })), !saidAny && marks.length > 0 && (_jsxs("li", { className: "slc-stage-empty", children: [marksSummary(marks, who), ". Nothing said by voice yet."] })), newest.map((item) => item.kind === "mark" ? (_jsx("li", { className: `slc-talk-entry slc-talk-entry--mark${markStanding(item) === "waits for agent" ? " slc-talk-entry--waits" : ""}`, children: _jsxs("button", { type: "button", className: "slc-talk-mark", onClick: () => onOpenMark?.(item), disabled: !onOpenMark, title: `Open ${drawingName(item.doc ?? item.drawing, item.title)} at this mark`, children: [_jsxs("span", { className: "slc-talk-who", children: [_jsx(PinIcon, { size: 14 }), _jsxs("span", { className: "slc-talk-mark-head", children: [_jsx("strong", { children: speaker(item.author, who) }), " marked ", placeOf(item)] }), _jsx("span", { children: when(item.at) })] }), _jsx("span", { className: "slc-talk-text", children: item.text }), item.replies.length > 0 && (_jsx("span", { className: "slc-talk-mark-replies", children: item.replies.map((r, i) => (_jsxs("span", { className: `slc-talk-mark-reply slc-talk-mark-reply--${r.author.role}`, children: [_jsxs("span", { className: "slc-talk-mark-by", children: [speaker(r.author, who), r.at ? ` · ${when(r.at)}` : ""] }), _jsx("span", { className: "slc-talk-text", children: r.text })] }, i))) })), _jsx("span", { className: `slc-talk-mark-state${markStanding(item) === "waits for agent" ? " slc-talk-mark-state--waits" : ""}`, children: standing[markStanding(item)] })] }) }, `m${item.id}`)) : item.kind === "take" ? (_jsxs("li", { className: "slc-talk-entry slc-talk-entry--take", children: [_jsxs("div", { className: "slc-talk-who", children: [_jsx("strong", { children: "You" }), _jsxs("span", { children: ["take ", item.take, " \u00B7 ", when(item.at)] })] }), item.canvas?.doc && (_jsxs("div", { className: "slc-talk-canvas", children: ["on ", drawingOf(item.canvas.doc), item.canvas.focus ? ` · ${item.canvas.focus.slice(item.canvas.focus.indexOf(":") + 1)}` : "", item.canvas.step?.title ? ` · during “${item.canvas.step.title}”` : ""] })), _jsx("div", { className: "slc-talk-text", children: item.text || "(no transcript yet)" })] }, `t${item.take}`)) : (_jsxs("li", { className: `slc-talk-entry slc-talk-entry--reply${unheard.includes(item.id) ? " slc-talk-entry--new" : ""}`, children: [_jsxs("div", { className: "slc-talk-who", children: [_jsx("strong", { children: who }), _jsx("span", { children: when(item.at) }), (!item.unvoiced || (item.steps?.length ?? 0) > 0) &&
|
|
52
72
|
(playing === item.id ? (_jsx("button", { type: "button", className: "slc-stage-btn slc-talk-play slc-talk-play--on", onClick: onStop, "aria-label": "Stop", title: "Stop", children: _jsx(StopIcon, {}) })) : (_jsxs("button", { type: "button", className: "slc-stage-btn slc-talk-play", onClick: () => onPlay(item.id), disabled: live, title: item.unvoiced
|
|
53
73
|
? `Walk the diagram with ${who}'s words (no voice)`
|
|
54
74
|
: item.steps?.length
|
|
55
75
|
? `Hear ${who} walk the diagram (${item.steps.length} steps)`
|
|
56
|
-
: `Hear ${who}`, children: [_jsx(PlayIcon, {}), (item.steps?.length ?? 0) > 0 ? _jsxs("span", { children: ["Walk ", item.steps.length, " steps"] }) : null, unheard.includes(item.id) ? _jsx("span", { className: "slc-talk-new", children: "New" }) : null] }))), onFeedback && (_jsx("span", { className: "slc-talk-thumbs", children: ["up", "down"].map((v) => (_jsx("button", { type: "button", className: `slc-talk-thumb${item.feedback === v ? " slc-talk-thumb--on" : ""}`, onClick: () => onFeedback(item.id, item.feedback === v ? "" : v), "aria-label": v === "up" ? "This reply worked" : "This reply missed", children: v === "up" ? _jsx(ThumbUpIcon, { size: 15 }) : _jsx(ThumbDownIcon, { size: 15 }) }, v))) }))] }),
|
|
76
|
+
: `Hear ${who}`, children: [_jsx(PlayIcon, {}), (item.steps?.length ?? 0) > 0 ? _jsxs("span", { children: ["Walk ", item.steps.length, " steps"] }) : null, unheard.includes(item.id) ? _jsx("span", { className: "slc-talk-new", children: "New" }) : null] }))), onFeedback && (_jsx("span", { className: "slc-talk-thumbs", children: ["up", "down"].map((v) => (_jsx("button", { type: "button", className: `slc-talk-thumb${item.feedback === v ? " slc-talk-thumb--on" : ""}`, onClick: () => onFeedback(item.id, item.feedback === v ? "" : v), "aria-label": v === "up" ? "This reply worked" : "This reply missed", children: v === "up" ? _jsx(ThumbUpIcon, { size: 15 }) : _jsx(ThumbDownIcon, { size: 15 }) }, v))) }))] }), item.mark && (_jsxs("button", { type: "button", className: "slc-talk-answers", onClick: () => {
|
|
77
|
+
const m = marksById.get(item.mark.id);
|
|
78
|
+
if (m)
|
|
79
|
+
onOpenMark?.(m);
|
|
80
|
+
}, disabled: !onOpenMark || !marksById.has(item.mark.id), children: [_jsx(PinIcon, { size: 13 }), "answers your mark on ", marksById.has(item.mark.id) ? placeOf(marksById.get(item.mark.id)) : drawingName(item.mark.doc)] })), (item.steps?.length ?? 0) > 0 ? (_jsx("ol", { className: "slc-talk-steps", "aria-label": `${who}'s walk through the diagram`, children: item.steps.map((step, i) => {
|
|
57
81
|
const here = playing === item.id && playingStep === i;
|
|
58
82
|
return (_jsx("li", { children: _jsxs("button", { type: "button", className: `slc-talk-step${here ? " slc-talk-step--here" : ""}`, onClick: () => onPlay(item.id, i), disabled: live, "aria-current": here ? "step" : undefined, title: `Walk from step ${i + 1}`, children: [_jsx("span", { className: "slc-talk-step-n", children: i + 1 }), _jsxs("span", { className: "slc-talk-step-body", children: [(step.title || step.doc) && (_jsxs("span", { className: "slc-talk-step-head", children: [step.title && _jsx("strong", { children: step.title }), (step.doc || litOf(step)) && (_jsx("span", { className: "slc-talk-step-where", children: [drawingOf(step.doc), litOf(step)].filter(Boolean).join(" · ") }))] })), _jsx("span", { className: "slc-talk-step-say", children: step.say })] })] }) }, i));
|
|
59
83
|
}) })) : (_jsx("div", { className: "slc-talk-text", children: item.text })), item.unvoiced && _jsx("div", { className: "slc-talk-meta", children: item.unvoiced })] }, `r${item.id}`)))] })] }) }));
|
package/dist/MarkCards.d.ts
CHANGED
|
@@ -4,17 +4,26 @@
|
|
|
4
4
|
* - `<MarkComposer>`: what was pointed at, and a box to say something about
|
|
5
5
|
* it — typed, or spoken when the host hands it something that listens.
|
|
6
6
|
* - `<MarkThread>`: one mark and its replies; reply, resolve, reopen, remove.
|
|
7
|
-
* - `<MarksPanel>`: every mark on the drawing,
|
|
8
|
-
* button that copies them as a
|
|
7
|
+
* - `<MarksPanel>`: every mark on the drawing, the ones with an agent's word
|
|
8
|
+
* not yet read first (marked "new"), and the button that copies them as a
|
|
9
|
+
* review for an agent.
|
|
10
|
+
* - `<MarkNotice>`: one line near the board's controls when an agent answers
|
|
11
|
+
* ("Mia answered mark 3"); a tap opens that thread. It takes no focus.
|
|
12
|
+
*
|
|
13
|
+
* Elements are named as the person sees them on the board ("Witnessing", "id in
|
|
14
|
+
* WaveCount", "message 8"), never by their focus keys; a host passes `labels`
|
|
15
|
+
* (focus key → words) for what only it can name, such as a message's words.
|
|
9
16
|
*
|
|
10
17
|
* Props in, callbacks out, as the canvases: the host writes the sidecar and
|
|
11
|
-
* tells the hub.
|
|
18
|
+
* tells the hub. A host that knows who will answer says so in `note`: one quiet
|
|
19
|
+
* line under the card ("Mia is listening in episode 412: she answers here"). The listener is any object shaped like
|
|
12
20
|
* `@miadi/stateloom-react`'s `browserDictation()`, so this package needs no
|
|
13
21
|
* socket and no speech code of its own.
|
|
14
22
|
*/
|
|
15
|
-
import { type CSSProperties } from "react";
|
|
23
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
16
24
|
import { type Box, type Mark, type MarkKind } from "@miadi/stateloom-protocol";
|
|
17
25
|
import { type CanvasTheme } from "./theme.js";
|
|
26
|
+
import { type ElementLabels } from "./names.js";
|
|
18
27
|
/** Something that turns speech into words (`browserDictation()`). */
|
|
19
28
|
export interface ListenerLike {
|
|
20
29
|
start(onText: (text: string, final: boolean) => void, onEnd?: (error?: string) => void): void;
|
|
@@ -39,11 +48,15 @@ export interface MarkComposerProps {
|
|
|
39
48
|
busy?: boolean;
|
|
40
49
|
error?: string | null;
|
|
41
50
|
placeholder?: string;
|
|
51
|
+
/** Who will answer the mark, from the host: one quiet line under the card. */
|
|
52
|
+
note?: ReactNode;
|
|
53
|
+
/** Words for elements only the host can name (a message's words), by focus key. */
|
|
54
|
+
labels?: ElementLabels;
|
|
42
55
|
theme?: Partial<CanvasTheme>;
|
|
43
56
|
className?: string;
|
|
44
57
|
style?: CSSProperties;
|
|
45
58
|
}
|
|
46
|
-
export declare function MarkComposer({ elements, region, author, onAuthorChange, onSubmit, onCancel, listener, listenAtOnce, busy, error, placeholder, theme, className, style, }: MarkComposerProps): import("react").JSX.Element;
|
|
59
|
+
export declare function MarkComposer({ elements, region, author, onAuthorChange, onSubmit, onCancel, listener, listenAtOnce, busy, error, placeholder, note, labels, theme, className, style, }: MarkComposerProps): import("react").JSX.Element;
|
|
47
60
|
export interface MarkThreadProps {
|
|
48
61
|
mark: Mark;
|
|
49
62
|
/** Its number on the board. */
|
|
@@ -56,11 +69,18 @@ export interface MarkThreadProps {
|
|
|
56
69
|
listener?: ListenerLike | null;
|
|
57
70
|
busy?: boolean;
|
|
58
71
|
error?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Who will answer, from the host. Shown under the thread only while it waits on an
|
|
74
|
+
* agent: the last word is a person's and the mark is not resolved.
|
|
75
|
+
*/
|
|
76
|
+
note?: ReactNode;
|
|
77
|
+
/** Words for elements only the host can name (a message's words), by focus key. */
|
|
78
|
+
labels?: ElementLabels;
|
|
59
79
|
theme?: Partial<CanvasTheme>;
|
|
60
80
|
className?: string;
|
|
61
81
|
style?: CSSProperties;
|
|
62
82
|
}
|
|
63
|
-
export declare function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy, error, theme, className, style, }: MarkThreadProps): import("react").JSX.Element;
|
|
83
|
+
export declare function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy, error, note, labels, theme, className, style, }: MarkThreadProps): import("react").JSX.Element;
|
|
64
84
|
export interface MarksPanelProps {
|
|
65
85
|
marks: readonly Mark[];
|
|
66
86
|
selected?: string | null;
|
|
@@ -69,8 +89,33 @@ export interface MarksPanelProps {
|
|
|
69
89
|
onCopy?: () => void;
|
|
70
90
|
copied?: boolean;
|
|
71
91
|
onClose?: () => void;
|
|
92
|
+
/** Who will answer the marks, from the host: one quiet line under the list. */
|
|
93
|
+
note?: ReactNode;
|
|
94
|
+
/**
|
|
95
|
+
* Marks with an agent's word not yet opened (their ids): listed first and
|
|
96
|
+
* marked "new". `unreadMarks(marks, read)` from the protocol.
|
|
97
|
+
*/
|
|
98
|
+
unread?: readonly string[];
|
|
99
|
+
/** Words for elements only the host can name (a message's words), by focus key. */
|
|
100
|
+
labels?: ElementLabels;
|
|
72
101
|
theme?: Partial<CanvasTheme>;
|
|
73
102
|
className?: string;
|
|
74
103
|
style?: CSSProperties;
|
|
75
104
|
}
|
|
76
|
-
export declare function MarksPanel({ marks, selected, onSelect, onCopy, copied, onClose, theme, className, style }: MarksPanelProps): import("react").JSX.Element;
|
|
105
|
+
export declare function MarksPanel({ marks, selected, onSelect, onCopy, copied, onClose, note, unread, labels, theme, className, style }: MarksPanelProps): import("react").JSX.Element;
|
|
106
|
+
export interface MarkNoticeProps {
|
|
107
|
+
/** The line: `agentWordText(agentWordIn(envelope))`, e.g. "Mia answered mark 3". */
|
|
108
|
+
children: ReactNode;
|
|
109
|
+
/** Open the thread it speaks of. */
|
|
110
|
+
onOpen: () => void;
|
|
111
|
+
onDismiss?: () => void;
|
|
112
|
+
theme?: Partial<CanvasTheme>;
|
|
113
|
+
className?: string;
|
|
114
|
+
style?: CSSProperties;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* One line that says an agent answered, near the board's controls. A polite
|
|
118
|
+
* live region: read out, never focused, never a card over the board. The host
|
|
119
|
+
* decides how long it stays (a few seconds) and what a tap opens.
|
|
120
|
+
*/
|
|
121
|
+
export declare function MarkNotice({ children, onOpen, onDismiss, theme, className, style }: MarkNoticeProps): import("react").JSX.Element;
|
package/dist/MarkCards.js
CHANGED
|
@@ -5,17 +5,26 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
5
5
|
* - `<MarkComposer>`: what was pointed at, and a box to say something about
|
|
6
6
|
* it — typed, or spoken when the host hands it something that listens.
|
|
7
7
|
* - `<MarkThread>`: one mark and its replies; reply, resolve, reopen, remove.
|
|
8
|
-
* - `<MarksPanel>`: every mark on the drawing,
|
|
9
|
-
* button that copies them as a
|
|
8
|
+
* - `<MarksPanel>`: every mark on the drawing, the ones with an agent's word
|
|
9
|
+
* not yet read first (marked "new"), and the button that copies them as a
|
|
10
|
+
* review for an agent.
|
|
11
|
+
* - `<MarkNotice>`: one line near the board's controls when an agent answers
|
|
12
|
+
* ("Mia answered mark 3"); a tap opens that thread. It takes no focus.
|
|
13
|
+
*
|
|
14
|
+
* Elements are named as the person sees them on the board ("Witnessing", "id in
|
|
15
|
+
* WaveCount", "message 8"), never by their focus keys; a host passes `labels`
|
|
16
|
+
* (focus key → words) for what only it can name, such as a message's words.
|
|
10
17
|
*
|
|
11
18
|
* Props in, callbacks out, as the canvases: the host writes the sidecar and
|
|
12
|
-
* tells the hub.
|
|
19
|
+
* tells the hub. A host that knows who will answer says so in `note`: one quiet
|
|
20
|
+
* line under the card ("Mia is listening in episode 412: she answers here"). The listener is any object shaped like
|
|
13
21
|
* `@miadi/stateloom-react`'s `browserDictation()`, so this package needs no
|
|
14
22
|
* socket and no speech code of its own.
|
|
15
23
|
*/
|
|
16
24
|
import { useEffect, useRef, useState } from "react";
|
|
17
|
-
import { MARK_KINDS,
|
|
25
|
+
import { MARK_KINDS, lastWordOf } from "@miadi/stateloom-protocol";
|
|
18
26
|
import { themeStyle } from "./theme.js";
|
|
27
|
+
import { elementName, markPlace } from "./names.js";
|
|
19
28
|
import { CloseIcon, MicIcon } from "./icons.js";
|
|
20
29
|
const KIND_LABEL = {
|
|
21
30
|
comment: "Comment",
|
|
@@ -41,12 +50,33 @@ function useListening(listener, onText) {
|
|
|
41
50
|
};
|
|
42
51
|
return { listening, toggle };
|
|
43
52
|
}
|
|
44
|
-
function Anchor({ elements, region }) {
|
|
53
|
+
function Anchor({ elements, region, labels }) {
|
|
45
54
|
if (!elements?.length && !region)
|
|
46
55
|
return _jsx("span", { className: "slc-stage-chip slc-stage-chip--quiet", children: "the drawing" });
|
|
47
|
-
|
|
56
|
+
// An entity's attributes are left to the entity when it is marked too.
|
|
57
|
+
const marked = new Set(elements ?? []);
|
|
58
|
+
const shown = (elements ?? []).filter((e) => {
|
|
59
|
+
const owner = /^attribute:([^.]+)\./.exec(e);
|
|
60
|
+
return !owner || !marked.has(`entity:${owner[1]}`);
|
|
61
|
+
});
|
|
62
|
+
return (_jsxs(_Fragment, { children: [shown.map((e) => (_jsx("span", { className: "slc-stage-chip", title: e, children: elementName(e, labels) }, e))), region && !elements?.length && _jsx("span", { className: "slc-stage-chip slc-stage-chip--quiet", children: "an area" })] }));
|
|
63
|
+
}
|
|
64
|
+
/** Who will answer, as the host knows it: one muted line, nothing when the host has nothing to say. */
|
|
65
|
+
function Note({ children }) {
|
|
66
|
+
if (children === undefined || children === null || children === false || children === "")
|
|
67
|
+
return null;
|
|
68
|
+
return (_jsx("div", { className: "slc-stage-card-note", role: "status", children: children }));
|
|
69
|
+
}
|
|
70
|
+
/** A mouse or trackpad: the composer may take focus without raising a keyboard. */
|
|
71
|
+
function finePointer() {
|
|
72
|
+
try {
|
|
73
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(pointer: fine)").matches;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
48
78
|
}
|
|
49
|
-
export function MarkComposer({ elements, region, author, onAuthorChange, onSubmit, onCancel, listener, listenAtOnce = false, busy = false, error, placeholder = "What should the agent know about this?", theme, className, style, }) {
|
|
79
|
+
export function MarkComposer({ elements, region, author, onAuthorChange, onSubmit, onCancel, listener, listenAtOnce = false, busy = false, error, placeholder = "What should the agent know about this?", note, labels, theme, className, style, }) {
|
|
50
80
|
const [text, setText] = useState("");
|
|
51
81
|
const [kind, setKind] = useState("comment");
|
|
52
82
|
const [name, setName] = useState(author);
|
|
@@ -55,7 +85,10 @@ export function MarkComposer({ elements, region, author, onAuthorChange, onSubmi
|
|
|
55
85
|
useEffect(() => {
|
|
56
86
|
if (listenAtOnce && listener)
|
|
57
87
|
toggle("");
|
|
58
|
-
|
|
88
|
+
// On a phone, focusing raises the keyboard over the board before the person
|
|
89
|
+
// asked to type: the box takes focus by itself only under a fine pointer,
|
|
90
|
+
// or when they pressed Answer (by voice, where nothing listens).
|
|
91
|
+
else if (listenAtOnce || finePointer())
|
|
59
92
|
area.current?.focus();
|
|
60
93
|
// Once, when the composer opens.
|
|
61
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -71,14 +104,14 @@ export function MarkComposer({ elements, region, author, onAuthorChange, onSubmi
|
|
|
71
104
|
onAuthorChange?.(signed);
|
|
72
105
|
onSubmit({ text: text.trim(), kind, author: signed });
|
|
73
106
|
};
|
|
74
|
-
return (_jsxs("form", { className: `slc-stage-card slc-stage-composer${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onSubmit: submit, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-anchor", children: [_jsx("span", { className: "slc-stage-card-label", children: "On" }), _jsx(Anchor, { elements: elements, region: region })] }), _jsx("textarea", { ref: area, className: "slc-stage-input slc-stage-textarea", value: text, placeholder: listening ? "Listening…" : placeholder, onChange: (e) => setText(e.target.value), onKeyDown: (e) => {
|
|
107
|
+
return (_jsxs("form", { className: `slc-stage-card slc-stage-composer${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onSubmit: submit, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-anchor", children: [_jsx("span", { className: "slc-stage-card-label", children: "On" }), _jsx(Anchor, { elements: elements, region: region, labels: labels })] }), _jsx("textarea", { ref: area, className: "slc-stage-input slc-stage-textarea", value: text, placeholder: listening ? "Listening…" : placeholder, onChange: (e) => setText(e.target.value), onKeyDown: (e) => {
|
|
75
108
|
if (e.key === "Enter" && (e.metaKey || e.ctrlKey))
|
|
76
109
|
submit();
|
|
77
110
|
if (e.key === "Escape")
|
|
78
111
|
onCancel();
|
|
79
|
-
}, rows: 3 }), !author && (_jsx("input", { className: "slc-stage-input", value: name, placeholder: "Your name (signs your marks)", onChange: (e) => setName(e.target.value) })), _jsxs("div", { className: "slc-stage-card-row", children: [_jsx("select", { className: "slc-stage-input slc-stage-select", value: kind, onChange: (e) => setKind(e.target.value), "aria-label": "Kind of mark", children: MARK_KINDS.map((k) => (_jsx("option", { value: k, children: KIND_LABEL[k] }, k))) }), listener && (_jsx("button", { type: "button", className: `slc-stage-btn${listening ? " slc-stage-btn--live" : ""}`, onClick: () => toggle(text), "aria-pressed": listening, title: listening ? "Stop listening" : "Speak instead of typing", children: _jsx(MicIcon, {}) })), _jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onCancel, children: "Cancel" }), _jsx("button", { type: "submit", className: "slc-stage-btn slc-stage-btn--main", disabled: !text.trim() || busy || (!author && !name.trim()), children: busy ? "Saving…" : "Mark" })] }), error && _jsx("div", { className: "slc-stage-card-error", children: error })] }));
|
|
112
|
+
}, rows: 3 }), !author && (_jsx("input", { className: "slc-stage-input", value: name, placeholder: "Your name (signs your marks)", onChange: (e) => setName(e.target.value) })), _jsxs("div", { className: "slc-stage-card-row", children: [_jsx("select", { className: "slc-stage-input slc-stage-select", value: kind, onChange: (e) => setKind(e.target.value), "aria-label": "Kind of mark", children: MARK_KINDS.map((k) => (_jsx("option", { value: k, children: KIND_LABEL[k] }, k))) }), listener && (_jsx("button", { type: "button", className: `slc-stage-btn${listening ? " slc-stage-btn--live" : ""}`, onClick: () => toggle(text), "aria-pressed": listening, title: listening ? "Stop listening" : "Speak instead of typing", children: _jsx(MicIcon, {}) })), _jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onCancel, children: "Cancel" }), _jsx("button", { type: "submit", className: "slc-stage-btn slc-stage-btn--main", disabled: !text.trim() || busy || (!author && !name.trim()), children: busy ? "Saving…" : "Mark" })] }), _jsx(Note, { children: note }), error && _jsx("div", { className: "slc-stage-card-error", children: error })] }));
|
|
80
113
|
}
|
|
81
|
-
export function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy = false, error, theme, className, style, }) {
|
|
114
|
+
export function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy = false, error, note, labels, theme, className, style, }) {
|
|
82
115
|
const [reply, setReply] = useState("");
|
|
83
116
|
const { listening, toggle } = useListening(listener, setReply);
|
|
84
117
|
const send = (e) => {
|
|
@@ -90,15 +123,26 @@ export function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemov
|
|
|
90
123
|
onReply?.(reply.trim());
|
|
91
124
|
setReply("");
|
|
92
125
|
};
|
|
93
|
-
return (_jsxs("div", { className: `slc-stage-card slc-stage-thread${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-row", children: [number !== undefined && _jsx("span", { className: `slc-stage-pin slc-stage-pin--inline slc-stage-pin--${mark.status === "resolved" ? "resolved" : mark.status}`, children: number }), _jsxs("span", { className: "slc-stage-card-label", children: [KIND_LABEL[mark.kind], " \u00B7 ", mark.status] }), _jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onClose, "aria-label": "Close", children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: "slc-stage-card-anchor", children: _jsx(Anchor, { elements: mark.elements, region: mark.region }) }), _jsxs("ol", { className: "slc-stage-thread-list", children: [_jsxs("li", { className: `slc-stage-said slc-stage-said--${mark.author.role}`, children: [_jsx("span", { className: "slc-stage-said-who", children: mark.author.name }), _jsx("span", { className: "slc-stage-said-text", children: mark.text })] }), (mark.replies ?? []).map((r, i) => (_jsxs("li", { className: `slc-stage-said slc-stage-said--${r.author.role}`, children: [_jsx("span", { className: "slc-stage-said-who", children: r.author.name }), _jsx("span", { className: "slc-stage-said-text", children: r.text })] }, i)))] }), onReply && (_jsxs("form", { className: "slc-stage-card-row", onSubmit: send, children: [_jsx("input", { className: "slc-stage-input slc-stage-grow", value: reply, placeholder: listening ? "Listening…" : "Reply…", onChange: (e) => setReply(e.target.value) }), listener && (_jsx("button", { type: "button", className: `slc-stage-btn${listening ? " slc-stage-btn--live" : ""}`, onClick: () => toggle(reply), "aria-pressed": listening, title: "Speak the reply", children: _jsx(MicIcon, {}) })), _jsx("button", { type: "submit", className: "slc-stage-btn slc-stage-btn--main", disabled: !reply.trim() || busy, children: "Reply" })] })), _jsxs("div", { className: "slc-stage-card-row", children: [mark.status === "resolved"
|
|
126
|
+
return (_jsxs("div", { className: `slc-stage-card slc-stage-thread${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-row", children: [number !== undefined && _jsx("span", { className: `slc-stage-pin slc-stage-pin--inline slc-stage-pin--${mark.status === "resolved" ? "resolved" : mark.status}`, children: number }), _jsxs("span", { className: "slc-stage-card-label", children: [KIND_LABEL[mark.kind], " \u00B7 ", mark.status] }), _jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onClose, "aria-label": "Close", children: _jsx(CloseIcon, {}) })] }), _jsx("div", { className: "slc-stage-card-anchor", children: _jsx(Anchor, { elements: mark.elements, region: mark.region, labels: labels }) }), _jsxs("ol", { className: "slc-stage-thread-list", children: [_jsxs("li", { className: `slc-stage-said slc-stage-said--${mark.author.role}`, children: [_jsx("span", { className: "slc-stage-said-who", children: mark.author.name }), _jsx("span", { className: "slc-stage-said-text", children: mark.text })] }), (mark.replies ?? []).map((r, i) => (_jsxs("li", { className: `slc-stage-said slc-stage-said--${r.author.role}`, children: [_jsx("span", { className: "slc-stage-said-who", children: r.author.name }), _jsx("span", { className: "slc-stage-said-text", children: r.text })] }, i)))] }), mark.status !== "resolved" && lastWordOf(mark) === "person" && _jsx(Note, { children: note }), onReply && (_jsxs("form", { className: "slc-stage-card-row", onSubmit: send, children: [_jsx("input", { className: "slc-stage-input slc-stage-grow", value: reply, placeholder: listening ? "Listening…" : "Reply…", onChange: (e) => setReply(e.target.value) }), listener && (_jsx("button", { type: "button", className: `slc-stage-btn${listening ? " slc-stage-btn--live" : ""}`, onClick: () => toggle(reply), "aria-pressed": listening, title: "Speak the reply", children: _jsx(MicIcon, {}) })), _jsx("button", { type: "submit", className: "slc-stage-btn slc-stage-btn--main", disabled: !reply.trim() || busy, children: "Reply" })] })), _jsxs("div", { className: "slc-stage-card-row", children: [mark.status === "resolved"
|
|
94
127
|
? onReopen && (_jsx("button", { type: "button", className: "slc-stage-btn", onClick: onReopen, children: "Reopen" }))
|
|
95
128
|
: onResolve && (_jsx("button", { type: "button", className: "slc-stage-btn", onClick: onResolve, children: "Resolve" })), _jsx("span", { className: "slc-stage-spacer" }), onRemove && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--danger", onClick: onRemove, children: "Remove" }))] }), error && _jsx("div", { className: "slc-stage-card-error", children: error })] }));
|
|
96
129
|
}
|
|
97
|
-
export function MarksPanel({ marks, selected, onSelect, onCopy, copied, onClose, theme, className, style }) {
|
|
130
|
+
export function MarksPanel({ marks, selected, onSelect, onCopy, copied, onClose, note, unread, labels, theme, className, style }) {
|
|
98
131
|
const [all, setAll] = useState(false);
|
|
132
|
+
const unreadIds = new Set(unread ?? []);
|
|
133
|
+
// Numbered as on the board; the ones with an agent's word not yet read first.
|
|
99
134
|
const numbered = marks.map((m, i) => ({ m, n: i + 1 }));
|
|
100
|
-
const
|
|
135
|
+
const ordered = [...numbered.filter(({ m }) => unreadIds.has(m.id)), ...numbered.filter(({ m }) => !unreadIds.has(m.id))];
|
|
136
|
+
const shown = all ? ordered : ordered.filter(({ m }) => m.status !== "resolved");
|
|
101
137
|
const open = marks.filter((m) => m.status !== "resolved").length;
|
|
102
|
-
return (_jsxs("div", { className: `slc-stage-card slc-stage-panel${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-row", children: [_jsx("span", { className: "slc-stage-card-label", children: "Marks on this drawing" }), _jsx("span", { className: "slc-stage-spacer" }), _jsxs("span", { className: "slc-stage-segment", role: "group", "aria-label": "Which marks to list", children: [_jsxs("button", { type: "button", className: `slc-stage-segment-btn${all ? "" : " slc-stage-segment-btn--on"}`, "aria-pressed": !all, onClick: () => setAll(false), children: ["Open ", open] }), _jsxs("button", { type: "button", className: `slc-stage-segment-btn${all ? " slc-stage-segment-btn--on" : ""}`, "aria-pressed": all, onClick: () => setAll(true), children: ["All ", marks.length] })] }), onClose && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onClose, "aria-label": "Close", children: _jsx(CloseIcon, {}) }))] }), shown.length === 0 && _jsx("div", { className: "slc-stage-empty", children: marks.length ? "Every mark is resolved." : "No marks yet. Turn on marking (✎) and tap or draw around what you mean." }), _jsx("ul", { className: "slc-stage-panel-list", children: shown.map(({ m, n }) => (_jsx("li", { children: _jsxs("button", { type: "button", className: `slc-stage-panel-item${m.id === selected ? " slc-stage-panel-item--selected" : ""}`, onClick: () => onSelect(m.id), children: [_jsx("span", { className: `slc-stage-pin slc-stage-pin--inline slc-stage-pin--${m.status === "resolved" ? "resolved" : m.author.role === "agent" && m.status === "open" ? "question" : m.status}`, children: n }), _jsxs("span", { className: "slc-stage-panel-text", children: [_jsx("span", { className: "slc-stage-panel-said", children: m.text }), _jsxs("span", { className: "slc-stage-panel-meta", children: [m.author.name, " \u00B7 ",
|
|
138
|
+
return (_jsxs("div", { className: `slc-stage-card slc-stage-panel${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "slc-stage-card-row", children: [_jsx("span", { className: "slc-stage-card-label", children: "Marks on this drawing" }), _jsx("span", { className: "slc-stage-spacer" }), _jsxs("span", { className: "slc-stage-segment", role: "group", "aria-label": "Which marks to list", children: [_jsxs("button", { type: "button", className: `slc-stage-segment-btn${all ? "" : " slc-stage-segment-btn--on"}`, "aria-pressed": !all, onClick: () => setAll(false), children: ["Open ", open] }), _jsxs("button", { type: "button", className: `slc-stage-segment-btn${all ? " slc-stage-segment-btn--on" : ""}`, "aria-pressed": all, onClick: () => setAll(true), children: ["All ", marks.length] })] }), onClose && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onClose, "aria-label": "Close", children: _jsx(CloseIcon, {}) }))] }), shown.length === 0 && _jsx("div", { className: "slc-stage-empty", children: marks.length ? "Every mark is resolved." : "No marks yet. Turn on marking (✎) and tap or draw around what you mean." }), _jsx("ul", { className: "slc-stage-panel-list", children: shown.map(({ m, n }) => (_jsx("li", { children: _jsxs("button", { type: "button", className: `slc-stage-panel-item${m.id === selected ? " slc-stage-panel-item--selected" : ""}`, onClick: () => onSelect(m.id), children: [_jsx("span", { className: `slc-stage-pin slc-stage-pin--inline slc-stage-pin--${m.status === "resolved" ? "resolved" : m.author.role === "agent" && m.status === "open" ? "question" : m.status}${unreadIds.has(m.id) ? " slc-stage-pin--new" : ""}`, children: n }), _jsxs("span", { className: "slc-stage-panel-text", children: [_jsx("span", { className: "slc-stage-panel-said", children: m.text }), _jsxs("span", { className: "slc-stage-panel-meta", children: [unreadIds.has(m.id) && _jsx("span", { className: "slc-stage-new", children: "new" }), m.author.name, " \u00B7 ", markPlace(m, labels), m.replies?.length ? ` · ${m.replies.length} repl${m.replies.length === 1 ? "y" : "ies"}` : ""] })] })] }) }, m.id))) }), _jsx(Note, { children: note }), onCopy && (_jsxs("div", { className: "slc-stage-card-row", children: [_jsx("span", { className: "slc-stage-spacer" }), _jsx("button", { type: "button", className: "slc-stage-btn", onClick: onCopy, title: "Copy what is on screen and the waiting marks, to paste into any agent", children: copied ? "Copied" : "Copy for the agent" })] }))] }));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* One line that says an agent answered, near the board's controls. A polite
|
|
142
|
+
* live region: read out, never focused, never a card over the board. The host
|
|
143
|
+
* decides how long it stays (a few seconds) and what a tap opens.
|
|
144
|
+
*/
|
|
145
|
+
export function MarkNotice({ children, onOpen, onDismiss, theme, className, style }) {
|
|
146
|
+
return (_jsxs("div", { className: `slc-stage-notice${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, role: "status", "aria-live": "polite", onPointerDown: (e) => e.stopPropagation(), children: [_jsxs("button", { type: "button", className: "slc-stage-notice-open", onClick: onOpen, title: "Open the thread", children: [_jsx("span", { className: "slc-stage-notice-dot", "aria-hidden": "true" }), _jsx("span", { className: "slc-stage-notice-text", children: children })] }), onDismiss && (_jsx("button", { type: "button", className: "slc-stage-notice-close", onClick: onDismiss, "aria-label": "Dismiss", children: _jsx(CloseIcon, {}) }))] }));
|
|
103
147
|
}
|
|
104
148
|
//# sourceMappingURL=MarkCards.js.map
|
package/dist/StageCaption.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The words of the step on stage, and the buttons that move a tour (Spec 83).
|
|
3
3
|
*
|
|
4
|
-
* A card over the bottom of the board: who is presenting, the
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
7
|
-
*
|
|
8
|
-
* the
|
|
4
|
+
* A card over the bottom of the board: who is presenting, the step's own title
|
|
5
|
+
* as the heading (it may wrap to two lines), the step's place and the tour's
|
|
6
|
+
* name on the line under it, what the agent says, where the tour stands. The
|
|
7
|
+
* controls are the person's: back, play or pause, forward, the voice on or off,
|
|
8
|
+
* answer (the host opens a mark on what is lit), close. Nothing here plays
|
|
9
|
+
* anything; the buttons call the host, which holds the stage session.
|
|
10
|
+
*
|
|
11
|
+
* When the step is about a drawing that is not on the board (`held`: a page
|
|
12
|
+
* opened on another drawing caught up with what the stage holds), the caption
|
|
13
|
+
* says which drawing it is about, its main button opens that drawing and plays
|
|
14
|
+
* ("Open and play"), and Answer is absent — a mark would land on the wrong
|
|
15
|
+
* drawing.
|
|
9
16
|
*/
|
|
10
17
|
import type { CSSProperties } from "react";
|
|
11
18
|
import type { TourStep } from "@miadi/stateloom-protocol";
|
|
@@ -31,9 +38,18 @@ export interface StageCaptionProps {
|
|
|
31
38
|
onClose?: () => void;
|
|
32
39
|
/** Answer what is lit: the host opens a mark on it. Absent: no answer button. */
|
|
33
40
|
onAnswer?: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* The step is about a drawing that is not on the board: its name, and what opens it.
|
|
43
|
+
* The caption names it, its main button says `label` ("Open and play"), and Answer is absent.
|
|
44
|
+
*/
|
|
45
|
+
held?: {
|
|
46
|
+
drawing: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
onOpen: () => void;
|
|
49
|
+
} | null;
|
|
34
50
|
theme?: Partial<CanvasTheme>;
|
|
35
51
|
className?: string;
|
|
36
52
|
style?: CSSProperties;
|
|
37
53
|
}
|
|
38
|
-
export declare function StageCaption({ shown, playing, speaking, voice, onToggleVoice, onPlay, onPause, onNext, onPrev, onGoto, onClose, onAnswer, theme, className, style, }: StageCaptionProps): import("react").JSX.Element | null;
|
|
54
|
+
export declare function StageCaption({ shown, playing, speaking, voice, onToggleVoice, onPlay, onPause, onNext, onPrev, onGoto, onClose, onAnswer, held, theme, className, style, }: StageCaptionProps): import("react").JSX.Element | null;
|
|
39
55
|
export default StageCaption;
|
package/dist/StageCaption.js
CHANGED
|
@@ -3,13 +3,16 @@ import { themeStyle } from "./theme.js";
|
|
|
3
3
|
import { CloseIcon, NextIcon, PauseIcon, PlayIcon, PrevIcon, SpeakerIcon, SpeakerOffIcon } from "./icons.js";
|
|
4
4
|
/** Past this many steps the dots give way to the count alone. */
|
|
5
5
|
const MAX_DOTS = 24;
|
|
6
|
-
export function StageCaption({ shown, playing = false, speaking = false, voice, onToggleVoice, onPlay, onPause, onNext, onPrev, onGoto, onClose, onAnswer, theme, className, style, }) {
|
|
6
|
+
export function StageCaption({ shown, playing = false, speaking = false, voice, onToggleVoice, onPlay, onPause, onNext, onPrev, onGoto, onClose, onAnswer, held = null, theme, className, style, }) {
|
|
7
7
|
if (!shown)
|
|
8
8
|
return null;
|
|
9
9
|
const { step, index, count, title, origin } = shown;
|
|
10
10
|
const inTour = index !== null && count !== null;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// The step's own title is the heading; the tour's name goes beside the count.
|
|
12
|
+
const heading = step.title || title || "";
|
|
13
|
+
const place = [inTour ? `${index + 1} / ${count}` : "", step.title ? title : ""].filter(Boolean).join(" · ");
|
|
14
|
+
const many = inTour && count > 7;
|
|
15
|
+
return (_jsxs("section", { className: `slc-stage-caption${className ? ` ${className}` : ""}`, style: { ...themeStyle(theme), ...style }, role: "region", "aria-label": "What the agent is showing", "aria-live": "polite", children: [_jsxs("header", { className: "slc-stage-caption-head", children: [origin && _jsx("span", { className: "slc-stage-caption-origin", children: origin }), _jsxs("span", { className: "slc-stage-caption-heading", children: [heading && _jsx("span", { className: "slc-stage-caption-title", children: heading }), place && _jsx("span", { className: "slc-stage-caption-count", children: place })] }), speaking && _jsx("span", { className: "slc-stage-caption-speaking", "aria-label": "speaking" }), onClose && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: onClose, "aria-label": "Close", title: "Close", children: _jsx(CloseIcon, {}) }))] }), held && (_jsxs("p", { className: "slc-stage-caption-held", children: ["About ", _jsx("strong", { children: held.drawing }), ", not the drawing open here."] })), _jsx("p", { className: "slc-stage-caption-say", children: step.say }), inTour && count <= MAX_DOTS && count > 1 && (_jsx("nav", { className: `slc-stage-dots${many ? " slc-stage-dots--many" : ""}`, "aria-label": "Steps", children: Array.from({ length: count }, (_, i) => (_jsx("button", { type: "button", className: `slc-stage-dot${i === index ? " slc-stage-dot--current" : i < index ? " slc-stage-dot--seen" : ""}`, onClick: () => onGoto?.(i), "aria-label": `Step ${i + 1}`, "aria-current": i === index ? "step" : undefined }, i))) })), _jsxs("footer", { className: "slc-stage-caption-controls", children: [inTour && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "slc-stage-btn", onClick: onPrev, disabled: index === 0, "aria-label": "Previous step", title: "Previous step", children: _jsx(PrevIcon, {}) }), held ? (_jsxs("button", { type: "button", className: "slc-stage-btn slc-stage-btn--main", onClick: held.onOpen, title: `Open ${held.drawing} and play from this step`, children: [_jsx(PlayIcon, {}), held.label ?? "Open and play"] })) : playing ? (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--main", onClick: onPause, "aria-label": "Pause", title: "Pause", children: _jsx(PauseIcon, {}) })) : (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--main", onClick: onPlay, "aria-label": "Play", title: "Play", children: _jsx(PlayIcon, {}) })), _jsx("button", { type: "button", className: "slc-stage-btn", onClick: onNext, disabled: index === count - 1, "aria-label": "Next step", title: "Next step", children: _jsx(NextIcon, {}) })] })), !inTour && held && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--main", onClick: held.onOpen, title: `Open ${held.drawing}`, children: held.label ?? "Open the drawing" })), _jsx("span", { className: "slc-stage-spacer" }), voice !== undefined && (_jsx("button", { type: "button", className: `slc-stage-btn${voice ? " slc-stage-btn--on" : ""}`, onClick: onToggleVoice, "aria-pressed": voice, title: voice ? "Voice on — the steps are read aloud" : "Voice off — the steps are read on screen", children: voice ? _jsx(SpeakerIcon, {}) : _jsx(SpeakerOffIcon, {}) })), onAnswer && !held && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--answer", onClick: onAnswer, title: "Answer \u2014 mark what is lit and say something about it", children: "Answer" }))] })] }));
|
|
13
16
|
}
|
|
14
17
|
export default StageCaption;
|
|
15
18
|
//# sourceMappingURL=StageCaption.js.map
|
package/dist/StageOverlay.d.ts
CHANGED
|
@@ -10,9 +10,16 @@
|
|
|
10
10
|
* scrim with a hole around each spotlighted element, and each hole is ringed;
|
|
11
11
|
* - **frames** an area the agent names;
|
|
12
12
|
* - **pins** each mark at what it points at, numbered, coloured by whether it
|
|
13
|
-
* waits (open), was answered, or is done — a tap opens its thread;
|
|
13
|
+
* waits (open), was answered, or is done — a tap opens its thread; a mark
|
|
14
|
+
* the host lists in `unread` (an agent's word not yet opened) wears a quiet
|
|
15
|
+
* "new" ring and dot. Every pin stays inside the board, pins that land on one
|
|
16
|
+
* point fan out down its right edge, and none sits under a box the host says
|
|
17
|
+
* to keep clear (`avoid`: the board's own buttons) — `placePins`;
|
|
14
18
|
* - **takes a mark** when the host turns marking on: a tap names the element
|
|
15
19
|
* under it, a drag names the elements inside the area drawn (and the area).
|
|
20
|
+
* A mouse or pen tap on empty board marks a small area there; a finger's tap
|
|
21
|
+
* on empty board does nothing, so a phone's stray touch never makes a mark
|
|
22
|
+
* (a finger's drag still frames an area).
|
|
16
23
|
*
|
|
17
24
|
* Positioned over the canvas by the host (both in one `position: relative`
|
|
18
25
|
* box); it lets every pointer through to the canvas except on its pins and
|
|
@@ -37,6 +44,12 @@ export interface StageOverlayProps {
|
|
|
37
44
|
marks?: readonly Mark[];
|
|
38
45
|
selectedMark?: string | null;
|
|
39
46
|
onSelectMark?: (id: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Marks with an agent's word the person has not opened yet (their ids): the
|
|
49
|
+
* pin wears a quiet "new" ring. `unreadMarks(marks, read)` from the protocol,
|
|
50
|
+
* with `read` from `useMarksRead`.
|
|
51
|
+
*/
|
|
52
|
+
unread?: readonly string[];
|
|
40
53
|
/** Resolved marks keep no pin. Default true. */
|
|
41
54
|
hideResolved?: boolean;
|
|
42
55
|
/** Take the next tap or drag as a mark. */
|
|
@@ -44,11 +57,13 @@ export interface StageOverlayProps {
|
|
|
44
57
|
onDraft?: (draft: MarkDraft) => void;
|
|
45
58
|
/** A mark being written: its elements ringed, its area framed. */
|
|
46
59
|
draft?: MarkDraft | null;
|
|
60
|
+
/** Boxes no pin may cover, in the board's screen coordinates: the host's buttons over the board. */
|
|
61
|
+
avoid?: readonly Box[];
|
|
47
62
|
theme?: Partial<CanvasTheme>;
|
|
48
63
|
className?: string;
|
|
49
64
|
style?: CSSProperties;
|
|
50
65
|
}
|
|
51
66
|
/** Where a mark sits: its elements that are drawn here, else its area. */
|
|
52
67
|
export declare function markAnchor(mark: Pick<Mark, "elements" | "region">, boxes: readonly ElementBox[]): Box | null;
|
|
53
|
-
export declare function StageOverlay({ viewport, boxes, spotlight, region, marks, selectedMark, onSelectMark, hideResolved, marking, onDraft, draft, theme, className, style, }: StageOverlayProps): import("react").JSX.Element;
|
|
68
|
+
export declare function StageOverlay({ viewport, boxes, spotlight, region, marks, selectedMark, onSelectMark, unread, hideResolved, marking, onDraft, draft, avoid, theme, className, style, }: StageOverlayProps): import("react").JSX.Element;
|
|
54
69
|
export default StageOverlay;
|