@miadi/stateloom-canvas 0.1.9 → 0.1.10

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.
@@ -59,6 +59,8 @@ export interface MarkComposerProps {
59
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;
60
60
  export interface MarkThreadProps {
61
61
  mark: Mark;
62
+ /** Play the linked narration, when the host has it for this reply. */
63
+ playReply?: (reply: NonNullable<Mark["replies"]>[number]) => (() => void) | undefined;
62
64
  /** Its number on the board. */
63
65
  number?: number;
64
66
  onReply?: (text: string) => void;
@@ -80,7 +82,7 @@ export interface MarkThreadProps {
80
82
  className?: string;
81
83
  style?: CSSProperties;
82
84
  }
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;
85
+ export declare function MarkThread({ mark, playReply, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy, error, note, labels, theme, className, style, }: MarkThreadProps): import("react").JSX.Element;
84
86
  export interface MarksPanelProps {
85
87
  marks: readonly Mark[];
86
88
  selected?: string | null;
package/dist/MarkCards.js CHANGED
@@ -25,7 +25,7 @@ import { useEffect, useRef, useState } from "react";
25
25
  import { MARK_KINDS, lastWordOf } from "@miadi/stateloom-protocol";
26
26
  import { themeStyle } from "./theme.js";
27
27
  import { elementName, markPlace } from "./names.js";
28
- import { CloseIcon, MicIcon } from "./icons.js";
28
+ import { CloseIcon, MicIcon, PlayIcon } from "./icons.js";
29
29
  const KIND_LABEL = {
30
30
  comment: "Comment",
31
31
  question: "Question",
@@ -111,7 +111,7 @@ export function MarkComposer({ elements, region, author, onAuthorChange, onSubmi
111
111
  onCancel();
112
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 })] }));
113
113
  }
114
- export function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy = false, error, note, labels, theme, className, style, }) {
114
+ export function MarkThread({ mark, playReply, number, onReply, onResolve, onReopen, onRemove, onClose, listener, busy = false, error, note, labels, theme, className, style, }) {
115
115
  const [reply, setReply] = useState("");
116
116
  const { listening, toggle } = useListening(listener, setReply);
117
117
  const send = (e) => {
@@ -123,7 +123,10 @@ export function MarkThread({ mark, number, onReply, onResolve, onReopen, onRemov
123
123
  onReply?.(reply.trim());
124
124
  setReply("");
125
125
  };
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"
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) => {
127
+ const play = r.author.role === "agent" ? playReply?.(r) : undefined;
128
+ return (_jsxs("li", { className: `slc-stage-said slc-stage-said--${r.author.role}`, children: [_jsxs("div", { className: "slc-stage-card-row", children: [_jsx("span", { className: "slc-stage-said-who", children: r.author.name }), play && (_jsx("button", { type: "button", className: "slc-stage-btn slc-stage-btn--quiet", onClick: play, "aria-label": `Play reply from ${r.author.name}`, title: `Play reply from ${r.author.name}`, children: _jsx(PlayIcon, {}) }))] }), _jsx("span", { className: "slc-stage-said-text", children: r.text })] }, i));
129
+ })] }), 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"
127
130
  ? onReopen && (_jsx("button", { type: "button", className: "slc-stage-btn", onClick: onReopen, children: "Reopen" }))
128
131
  : 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 })] }));
129
132
  }
@@ -27,6 +27,7 @@ export interface StageCaptionProps {
27
27
  } | null;
28
28
  playing?: boolean;
29
29
  speaking?: boolean;
30
+ playbackError?: string | null;
30
31
  /** The canvas's voice is on. Absent: no voice button. */
31
32
  voice?: boolean;
32
33
  onToggleVoice?: () => void;
@@ -51,5 +52,5 @@ export interface StageCaptionProps {
51
52
  className?: string;
52
53
  style?: CSSProperties;
53
54
  }
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;
55
+ export declare function StageCaption({ shown, playing, speaking, playbackError, voice, onToggleVoice, onPlay, onPause, onNext, onPrev, onGoto, onClose, onAnswer, held, theme, className, style, }: StageCaptionProps): import("react").JSX.Element | null;
55
56
  export default StageCaption;
@@ -3,7 +3,7 @@ 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, held = null, theme, className, style, }) {
6
+ export function StageCaption({ shown, playing = false, speaking = false, playbackError, 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;
@@ -12,7 +12,7 @@ export function StageCaption({ shown, playing = false, speaking = false, voice,
12
12
  const heading = step.title || title || "";
13
13
  const place = [inTour ? `${index + 1} / ${count}` : "", step.title ? title : ""].filter(Boolean).join(" · ");
14
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" }))] })] }));
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 }), playbackError && _jsx("div", { className: "slc-stage-card-error", role: "status", children: playbackError }), 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" }))] })] }));
16
16
  }
17
17
  export default StageCaption;
18
18
  //# sourceMappingURL=StageCaption.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/stateloom-canvas",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "The reusable SMDF design surface: a pannable, zoomable, drillable React SVG canvas with routed edges, settled labels and a navigation HUD",
5
5
  "repository": {
6
6
  "type": "git",