@gemboss/ui 0.71.0 → 0.74.0

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +398 -2
  2. package/README.md +185 -2
  3. package/catalog/editor.html +1 -1
  4. package/catalog/index.html +50 -50
  5. package/gemboss-ui.css +4 -4
  6. package/package.json +17 -1
  7. package/parts/components.css +3 -3
  8. package/parts/core.css +1 -1
  9. package/parts/shell.css +2 -2
  10. package/src/GemMark.tsx +9 -2
  11. package/src/app-nav.css +1 -1
  12. package/src/assistant/chat-cards.tsx +118 -19
  13. package/src/assistant/chat.tsx +97 -12
  14. package/src/assistant/figures.tsx +119 -0
  15. package/src/assistant/gallery.tsx +67 -0
  16. package/src/assistant/host.tsx +29 -15
  17. package/src/assistant/ideas.tsx +90 -0
  18. package/src/assistant/index.ts +8 -1
  19. package/src/assistant/plus.tsx +61 -0
  20. package/src/assistant-chat.css +1 -1
  21. package/src/assistant-figures.css +1 -0
  22. package/src/assistant-plus.css +1 -0
  23. package/src/assistant.css +1 -1
  24. package/src/auth.tsx +7 -3
  25. package/src/board-move.ts +2 -1
  26. package/src/brand-gem.tsx +10 -2
  27. package/src/brand.tsx +6 -3
  28. package/src/chat-cards-drawn.css +1 -0
  29. package/src/chat-cards-float.css +1 -0
  30. package/src/chat-cards.css +1 -1
  31. package/src/chat-composer-menus.css +1 -1
  32. package/src/chat-composer.css +1 -1
  33. package/src/chat-shortcuts.css +1 -0
  34. package/src/chat-voice.css +1 -1
  35. package/src/chat.css +1 -1
  36. package/src/chips-drawn.css +1 -0
  37. package/src/collections.tsx +4 -2
  38. package/src/dialog.css +1 -1
  39. package/src/editor/choice-cards.tsx +8 -5
  40. package/src/editor/controls.tsx +8 -5
  41. package/src/editor/field-control.tsx +8 -3
  42. package/src/editor/field-frame.tsx +5 -3
  43. package/src/editor/field-spec.ts +12 -3
  44. package/src/editor/index.ts +2 -0
  45. package/src/editor/inspector-frame.tsx +3 -2
  46. package/src/editor/media-words.ts +21 -0
  47. package/src/editor-empty.css +1 -1
  48. package/src/editor-inspector-frame.css +1 -1
  49. package/src/editor-media.css +1 -1
  50. package/src/editor.css +1 -1
  51. package/src/email-canvas.css +1 -0
  52. package/src/email-card.tsx +44 -0
  53. package/src/email-editor/canvas.tsx +109 -0
  54. package/src/email-editor/editor.tsx +45 -4
  55. package/src/email-editor/index.ts +2 -1
  56. package/src/email-editor/model.ts +9 -1
  57. package/src/email-parts.css +1 -0
  58. package/src/email-parts.tsx +81 -0
  59. package/src/email-thumb.css +1 -0
  60. package/src/email-thumb.tsx +206 -0
  61. package/src/flow-strip.css +1 -0
  62. package/src/flow-strip.tsx +50 -0
  63. package/src/gemboss-field-drawn.css +1 -0
  64. package/src/index.ts +15 -2
  65. package/src/kit-plain.css +1 -1
  66. package/src/kit-plain.js +1 -1
  67. package/src/list-page.tsx +6 -3
  68. package/src/media-card.css +1 -0
  69. package/src/menu-layer.ts +2 -0
  70. package/src/menu-select.css +1 -1
  71. package/src/menu.css +1 -1
  72. package/src/metrics.css +1 -0
  73. package/src/metrics.tsx +59 -0
  74. package/src/picture-actions.css +1 -0
  75. package/src/picture-actions.tsx +23 -0
  76. package/src/reader-dialog.css +1 -1
  77. package/src/segmented.tsx +6 -0
  78. package/src/services.ts +17 -0
  79. package/src/settings-dialog.css +1 -1
  80. package/src/sheet.css +1 -1
  81. package/src/shell.css +1 -1
  82. package/src/shell.tsx +9 -2
  83. package/src/site.tsx +3 -3
  84. package/src/stat-tile.css +1 -0
  85. package/src/stat-tile.tsx +39 -0
  86. package/src/ui.css +1 -1
@@ -27,6 +27,8 @@
27
27
  import "../chat.css";
28
28
  import "../assistant-chat.css";
29
29
  import "../chat-cards.css";
30
+ import "../chat-cards-float.css"; // the waiting question over the thread: stuck to its foot, frosted, capped (15/11/2026), its own entry
31
+ import "../chat-cards-drawn.css"; // a CTA and a page card's Open under a thumb drawn at their mouse size (15/11/2026), its own entry
30
32
  import React, { useEffect, useRef, useState, type ReactNode } from "react";
31
33
  import { Icon, type IconName } from "../icons";
32
34
  import { copyText } from "./engine";
@@ -123,14 +125,31 @@ export interface ChatChoicesProps<T extends ChatChoiceItem> {
123
125
  hintOf?: (option: T, index: number) => ReactNode;
124
126
  /** The pill on the recommended choice (default "Gem's pick"). */
125
127
  pickLabel?: string;
126
- /** The poll's last row, the way out when none fits: "Something else · Type it below"; pressing it puts the person in the box. A poll
127
- * only (a chip row is two words; the box is right under it). Absent: no row. */
128
- other?: { onPick: () => void; label?: string; hint?: string };
128
+ /** The way out when none fits: "Something else". Given for the question waiting over the box, and then ALWAYS drawn: the poll's last
129
+ * row ("Something else · Type it below"), or the last chip of a chip row (14/11/2026, Chris: "các lựa chọn luôn phải có Something
130
+ * else"). Pressing it calls `onPick` (the surface puts the person in the box); `hint` is that row's line. Under `pick: "many"` it is a
131
+ * tick of its own whose row holds a field (`placeholder`), so the words go with the ticks in one answer: `onPick` and `hint` are not
132
+ * used there. Absent: no way out drawn (the choices under an answer in the thread). */
133
+ other?: { onPick: () => void; label?: string; hint?: string; placeholder?: string };
134
+ /** How the waiting question is answered (14/11/2026, Chris: one answer is a radio, several are tick boxes, and a tick can come with
135
+ * words of one's own). "one": a round mark on each row, and a press answers, as without `pick`. "many" (with `onSend`): a square
136
+ * mark, a press ticks, and Send answers with every tick and the words typed under Something else; every choice is a row then (a
137
+ * chip cannot hold a tick). Absent: the choices under an answer in the thread, no marks. */
138
+ pick?: "one" | "many";
139
+ /** `pick: "many"`: the ticked choices in the order offered, and the words typed under Something else ("" when none). Called once per
140
+ * question: a second Send or Enter before the surface turns `busy` does nothing. A new question is told by its choices' words, so a
141
+ * surface that can ask the same choices twice in a row keys the component by its question (GemChat keys it by the message). */
142
+ onSend?: (picked: T[], other: string) => void;
143
+ /** `pick: "many"`: the button (default "Send") and the count beside it (default "2 picked"). */
144
+ sendLabel?: string;
145
+ pickedLabel?: (n: number) => string;
129
146
  }
130
147
 
131
148
  /** The answer's choices (the board's 05 and 06). Pressing one is the surface's: it sends it, or does what the choice says. */
132
- export function ChatChoices<T extends ChatChoiceItem>({ options, onChoose, busy, rich, pictureOf, hintOf, pickLabel = "Gem's pick", other }: ChatChoicesProps<T>) {
149
+ export function ChatChoices<T extends ChatChoiceItem>(props: ChatChoicesProps<T>) {
150
+ const { options, onChoose, busy, rich, pictureOf, hintOf, pickLabel = "Gem's pick", other, pick, onSend } = props;
133
151
  if (!options.length) return null;
152
+ if (pick === "many" && onSend) return <PickMany {...props} onSend={onSend} />;
134
153
  const isCard = rich ?? isRich;
135
154
  const poll = options.some(isCard);
136
155
  if (!poll) {
@@ -139,30 +158,26 @@ export function ChatChoices<T extends ChatChoiceItem>({ options, onChoose, busy,
139
158
  {options.map((o, i) => (
140
159
  <button key={i} type="button" className="gemboss-ec-chip" disabled={busy} onClick={() => onChoose(o)}>{labelOf(o)}</button>
141
160
  ))}
161
+ {other ? <button type="button" className="gemboss-ec-chip gemboss-ec-chip-other" disabled={busy} onClick={other.onPick}>{other.label ?? "Something else"}</button> : null}
142
162
  </div>
143
163
  );
144
164
  }
165
+ // A waiting question's poll marks every row, so a chip among the cards becomes a row too: a mark on some rows only reads as two kinds.
166
+ const mark = pick ? <span className="gemboss-ec-opt-mark" aria-hidden="true" /> : null;
145
167
  return (
146
- <div className="gemboss-ec-poll">
168
+ <div className="gemboss-ec-poll" data-pick={pick}>
147
169
  {options.map((o, i) => {
148
- if (!isCard(o)) return <button key={i} type="button" className="gemboss-ec-chip" disabled={busy} onClick={() => onChoose(o)}>{labelOf(o)}</button>;
149
- const c: ChatChoiceItem = o;
150
- const picture = pictureOf?.(o, i) ?? (typeof c === "string" ? null : c.picture);
151
- const hint = hintOf?.(o, i) ?? (typeof c === "string" ? null : c.hint);
152
- const pick = typeof c !== "string" && c.recommended;
170
+ if (!pick && !isCard(o)) return <button key={i} type="button" className="gemboss-ec-chip" disabled={busy} onClick={() => onChoose(o)}>{labelOf(o)}</button>;
153
171
  return (
154
172
  <button key={i} type="button" className="gemboss-ec-opt" disabled={busy} onClick={() => onChoose(o)}>
155
- {picture ? <span className="gemboss-ec-opt-pic" aria-hidden="true">{picture}</span> : null}
156
- <span className="gemboss-ec-opt-col">
157
- <span className="gemboss-ec-opt-label">{labelOf(c)}</span>
158
- {hint ? <span className="gemboss-ec-opt-hint">{hint}</span> : null}
159
- </span>
160
- {pick ? <span className="gemboss-ec-opt-rec">{pickLabel}</span> : null}
173
+ {mark}
174
+ <OptionBody option={o} index={i} pictureOf={pictureOf} hintOf={hintOf} pickLabel={pickLabel} />
161
175
  </button>
162
176
  );
163
177
  })}
164
178
  {other ? (
165
179
  <button type="button" className="gemboss-ec-opt gemboss-ec-opt-other" disabled={busy} onClick={other.onPick}>
180
+ {mark}
166
181
  <span className="gemboss-ec-opt-col">
167
182
  <span className="gemboss-ec-opt-label">{other.label ?? "Something else"}</span>
168
183
  <span className="gemboss-ec-opt-hint">{other.hint ?? "Type it below"}</span>
@@ -173,17 +188,101 @@ export function ChatChoices<T extends ChatChoiceItem>({ options, onChoose, busy,
173
188
  );
174
189
  }
175
190
 
191
+ /** A row's picture, words, line under them and Gem's pick: the same in a pressed row and a ticked one. */
192
+ function OptionBody<T extends ChatChoiceItem>({ option, index, pictureOf, hintOf, pickLabel }: {
193
+ option: T; index: number; pictureOf?: (option: T, index: number) => ReactNode; hintOf?: (option: T, index: number) => ReactNode; pickLabel: string;
194
+ }) {
195
+ const c: ChatChoiceItem = option;
196
+ const picture = pictureOf?.(option, index) ?? (typeof c === "string" ? null : c.picture);
197
+ const hint = hintOf?.(option, index) ?? (typeof c === "string" ? null : c.hint);
198
+ return (
199
+ <>
200
+ {picture ? <span className="gemboss-ec-opt-pic" aria-hidden="true">{picture}</span> : null}
201
+ <span className="gemboss-ec-opt-col">
202
+ <span className="gemboss-ec-opt-label">{labelOf(c)}</span>
203
+ {hint ? <span className="gemboss-ec-opt-hint">{hint}</span> : null}
204
+ </span>
205
+ {typeof c !== "string" && c.recommended ? <span className="gemboss-ec-opt-rec">{pickLabel}</span> : null}
206
+ </>
207
+ );
208
+ }
209
+
210
+ /** Nothing ticked, for the question these choices are (a new question starts empty). */
211
+ const freshPicks = (sig: string) => ({ sig, on: [] as number[], otherOn: false, text: "" });
212
+
213
+ /**
214
+ * `pick: "many"`: real tick boxes behind their rows (the keyboard and a screen reader get check boxes, Space ticks), Something else a
215
+ * tick whose row opens a field, and Send with the count. Enter in the field sends. A new question (other choices) starts empty.
216
+ */
217
+ function PickMany<T extends ChatChoiceItem>({ options, busy, pictureOf, hintOf, pickLabel = "Gem's pick", other, onSend, sendLabel = "Send",
218
+ pickedLabel = (n: number) => `${n} picked` }: ChatChoicesProps<T> & { onSend: (picked: T[], other: string) => void }) {
219
+ const sig = options.map(labelOf).join("\n");
220
+ const [held, setHeld] = useState(() => freshPicks(sig));
221
+ // React's "adjust state when a prop changes": the ticks of the last question never carry over to the next.
222
+ if (held.sig !== sig) setHeld(freshPicks(sig));
223
+ const s = held.sig === sig ? held : freshPicks(sig);
224
+ const field = useRef<HTMLInputElement>(null);
225
+ useEffect(() => { if (s.otherOn) field.current?.focus(); }, [s.otherOn]);
226
+ // The question this component already answered: a double press, or Enter then Send, before the surface turns `busy`, sends once.
227
+ const sentFor = useRef<string | null>(null);
228
+ const words = s.otherOn ? s.text.trim() : "";
229
+ const count = s.on.length + (words ? 1 : 0);
230
+ const send = () => {
231
+ if (busy || !count || sentFor.current === sig) return;
232
+ sentFor.current = sig;
233
+ onSend(s.on.map((i) => options[i]!), words);
234
+ };
235
+ const tick = (i: number) => setHeld({ ...s, on: s.on.includes(i) ? s.on.filter((x) => x !== i) : [...s.on, i].sort((a, b) => a - b) });
236
+ const box = (checked: boolean, onChange: () => void) => (
237
+ <>
238
+ <input type="checkbox" className="gemboss-ec-opt-input" checked={checked} disabled={busy} onChange={onChange} />
239
+ <span className="gemboss-ec-opt-mark" aria-hidden="true"><Icon name="check" size={14} /></span>
240
+ </>
241
+ );
242
+ return (
243
+ <div className="gemboss-ec-poll" data-pick="many">
244
+ {options.map((o, i) => (
245
+ <label key={i} className="gemboss-ec-opt">
246
+ {box(s.on.includes(i), () => tick(i))}
247
+ <OptionBody option={o} index={i} pictureOf={pictureOf} hintOf={hintOf} pickLabel={pickLabel} />
248
+ </label>
249
+ ))}
250
+ {other ? (
251
+ <label className="gemboss-ec-opt gemboss-ec-opt-other">
252
+ {box(s.otherOn, () => setHeld({ ...s, otherOn: !s.otherOn }))}
253
+ <span className="gemboss-ec-opt-col">
254
+ <span className="gemboss-ec-opt-label">{other.label ?? "Something else"}</span>
255
+ {/* The field stays while it holds words, ticked or not: a press on the row's caption unticks it (it is the box's label), and
256
+ the words must not vanish with the tick. Typing ticks it again. */}
257
+ {s.otherOn || s.text ? (
258
+ <input ref={field} type="text" className="gemboss-field gemboss-ec-opt-field" value={s.text} disabled={busy}
259
+ aria-label={other.label ?? "Something else"} placeholder={other.placeholder ?? "Say it in your words"}
260
+ onChange={(e) => setHeld({ ...s, text: e.target.value, otherOn: s.otherOn || e.target.value.trim() !== "" })}
261
+ onKeyDown={(e) => { if (e.key === "Enter" && !e.nativeEvent.isComposing) { e.preventDefault(); send(); } }} />
262
+ ) : <span className="gemboss-ec-opt-hint">Type your own</span>}
263
+ </span>
264
+ </label>
265
+ ) : null}
266
+ <div className="gemboss-ec-poll-foot">
267
+ <span className="gemboss-ec-poll-count" aria-live="polite">{count ? pickedLabel(count) : ""}</span>
268
+ <button type="button" className="ui-btn ui-btn--primary" disabled={busy || !count} onClick={send}>{sendLabel}</button>
269
+ </div>
270
+ </div>
271
+ );
272
+ }
273
+
176
274
  // ── The question waiting on the person ─────────────────────────────────────────────────────────────────────────────────────
177
275
 
178
276
  /**
179
277
  * The last answer's question, over the message box while it waits (the board's 07): a line that says so, what it is about (ChatThing),
180
278
  * the question in bold, then the choices the surface puts in it (ChatChoices). Its look is the kit's `.gemboss-ec-decide`
181
- * (assistant-chat.css, 0.49).
279
+ * (assistant-chat.css, 0.49): Gem's iris since 14/11/2026, so it stands out from the thread above it. `how` follows the line, quieter:
280
+ * "Pick one" or "Pick any", as the choices are answered (ChatChoices `pick`).
182
281
  */
183
- export function ChatDecide({ label, thing, question, children }: { label: string; thing?: ReactNode; question?: ReactNode; children?: ReactNode }) {
282
+ export function ChatDecide({ label, how, thing, question, children }: { label: string; how?: ReactNode; thing?: ReactNode; question?: ReactNode; children?: ReactNode }) {
184
283
  return (
185
284
  <div className="gemboss-ec-decide" role="group" aria-label={label}>
186
- <span className="gemboss-ec-decide-label">{label}</span>
285
+ <span className="gemboss-ec-decide-label">{label}{how ? <span className="gemboss-ec-decide-how">{how}</span> : null}</span>
187
286
  {thing}
188
287
  {question ? <b className="gb-chat-question">{question}</b> : null}
189
288
  {children}
@@ -25,6 +25,7 @@ import "../chat.css";
25
25
  import "../chat-composer.css";
26
26
  import "../chat-voice.css"; // the composer's microphone (`voice`), its own entry: the bundle chat-composer.css sits in is frozen
27
27
  import "../chat-composer-menus.css"; // "+" and ✦ and the line over the box they speak on (0.70.0), its own entry for the same reason
28
+ import "../chat-shortcuts.css"; // the "/" list (`shortcuts`), its own entry: chat-composer-menus.css is at its ceiling
28
29
  import "../assistant-chat.css";
29
30
  import "../assistant-engine.css"; // BridgeNotice and the engine chip's density rules (engine.tsx brings it too)
30
31
  import React, {
@@ -751,11 +752,31 @@ export interface ChatComposerProps {
751
752
  status?: ReactNode;
752
753
  maxLength?: number;
753
754
  rows?: number;
755
+ /** Two rows however short the words (13/11/2026, Chris on New's describe box: "cao 2 dòng cho input cho sướng"): the text over the
756
+ * toolbar where it has a lead ("+" or chips), and two lines tall unless `rows` says otherwise. With an empty lead it stands beside
757
+ * send as every bare box does, still two lines tall (no surface draws one: the rule for it cost the dashboard's first load). For a
758
+ * box whose job is the words; a chat's box keeps one row while they fit (`composerRows`). */
759
+ stacked?: boolean;
754
760
  disabled?: boolean;
755
761
  textareaRef?: RefObject<HTMLTextAreaElement | null>;
756
762
  onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
757
763
  onPaste?: ClipboardEventHandler<HTMLTextAreaElement>;
758
764
  className?: string;
765
+ /** Questions "/" offers (Gem Plus slice 4, 13/11/2026): typing "/" lists them over the text box, filtered by what follows it; ↑/↓
766
+ * and Enter or Tab (or a press) put one in the box to edit or send, Escape closes the list. Absent: "/" is a character. */
767
+ shortcuts?: ChatShortcut[];
768
+ /** The list's name for a screen reader. */
769
+ shortcutsLabel?: string;
770
+ }
771
+
772
+ /** A question the "/" list offers: its words on the list, and what goes in the box (often the same). */
773
+ export interface ChatShortcut { label: string; prompt: string; sub?: string }
774
+
775
+ /** The questions a "/" in `value` asks for: what follows the slash filters by words; a line break or a second slash ends it. */
776
+ export function shortcutMatches(value: string, shortcuts: readonly ChatShortcut[] | undefined, max = 12): ChatShortcut[] {
777
+ if (!shortcuts?.length || !value.startsWith("/") || value.includes("\n")) return [];
778
+ const words = value.slice(1).trim().toLowerCase().split(/\s+/).filter(Boolean);
779
+ return shortcuts.filter((s) => { const hay = `${s.label} ${s.sub ?? ""}`.toLowerCase(); return words.every((w) => hay.includes(w)); }).slice(0, max);
759
780
  }
760
781
 
761
782
  /**
@@ -764,6 +785,15 @@ export interface ChatComposerProps {
764
785
  * review #916). The send button keeps `type="submit"` because chat.css draws it by that; outside a form it submits nothing.
765
786
  */
766
787
  export function ChatComposer(p: ChatComposerProps) {
788
+ // THE "/" LIST (`shortcuts`): open while the box starts with "/" and something matches, unless Escape closed it at this very text.
789
+ const slashId = useId();
790
+ const [slashActive, setSlashActive] = useState(0);
791
+ const [slashClosedAt, setSlashClosedAt] = useState<string | null>(null);
792
+ const slashMatches = slashClosedAt === p.value ? [] : shortcutMatches(p.value, p.shortcuts);
793
+ const slashOpen = slashMatches.length > 0;
794
+ const slashAt = Math.min(slashActive, Math.max(0, slashMatches.length - 1));
795
+ // A new text: the first question is the active one again, and an Escape at another text no longer holds the list shut.
796
+ const slashTyped = (next: string) => { if (slashActive) setSlashActive(0); if (slashClosedAt !== null && slashClosedAt !== next) setSlashClosedAt(null); };
767
797
  const L = useLabels();
768
798
  const own = useRef<HTMLTextAreaElement | null>(null);
769
799
  const ref = p.textareaRef ?? own;
@@ -807,8 +837,15 @@ export function ChatComposer(p: ChatComposerProps) {
807
837
  mo.observe(lead, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-label", "title", "aria-label"] });
808
838
  restart();
809
839
  let live = true;
810
- void document.fonts?.ready.then(() => { if (live) restart(); });
811
- return () => { live = false; ro?.disconnect(); mo.disconnect(); };
840
+ // A web font landing changes every chip's width: step again from full (`loadingdone` too, as the rows below).
841
+ const fonts = typeof document === "undefined" ? undefined : document.fonts;
842
+ fonts?.addEventListener?.("loadingdone", restart);
843
+ void fonts?.ready.then(() => { if (live) restart(); });
844
+ // A stylesheet that lands late steps the density again too (review of #7456): a chip narrowed to its mark while its CSS was missing
845
+ // gets its words back even when the row count stays the same.
846
+ const onSheet = (e: Event) => { const t = e.target as { tagName?: string; rel?: string } | null; if (t?.tagName === "LINK" && /\bstylesheet\b/i.test(t.rel ?? "")) restart(); };
847
+ document.addEventListener("load", onSheet, true);
848
+ return () => { live = false; ro?.disconnect(); mo.disconnect(); fonts?.removeEventListener?.("loadingdone", restart); document.removeEventListener("load", onSheet, true); };
812
849
  }, []);
813
850
 
814
851
  // Grow from one line to the box's max-height (chat.css: 84px), then scroll inside. Hidden (a closed tab): skip, the
@@ -832,7 +869,7 @@ export function ChatComposer(p: ChatComposerProps) {
832
869
  // field is narrower than "Ask Gem…" (34px at 320 under a finger), so the first word would bring one row and the second take it
833
870
  // away (review of #7350 asked; kept).
834
871
  const kept = !force && ((was === "2" && now.startsWith(prev)) || (was === "1" && now !== "" && prev.startsWith(now))) ? was : null;
835
- const rows = !box ? null : kept ?? composerRows(box, el, p.shortPlaceholder);
872
+ const rows = !box ? null : p.stacked ? "2" : kept ?? composerRows(box, el, p.shortPlaceholder);
836
873
  // The density steps were measured on the other layout: step again from full on this one (a chip has more room on two rows).
837
874
  if (box && (box.dataset.rows ?? null) !== rows) {
838
875
  if (rows) box.dataset.rows = rows; else delete box.dataset.rows;
@@ -846,18 +883,34 @@ export function ChatComposer(p: ChatComposerProps) {
846
883
  el.style.overflowY = want > max ? "auto" : "hidden";
847
884
  if (p.shortPlaceholder && p.placeholder) setPlaceholderFits(textWidth(p.placeholder, cs) <= fieldWidth(el, cs));
848
885
  };
849
- useBeforePaint(() => { fitRef.current(); }, [p.value, p.placeholder, p.shortPlaceholder]);
850
- // Once, not on every key: a new width, or a change in the lead ("+" arrived, a chip narrowed to its mark), decides again.
886
+ useBeforePaint(() => { fitRef.current(); }, [p.value, p.placeholder, p.shortPlaceholder, p.stacked]);
887
+ // Once, not on every key: a new width, a change in the lead ("+" arrived, a chip narrowed to its mark), or a web font landing decides
888
+ // again. THE FONT (13/11/2026, gemboss #7382): the lead's chips and the short placeholder were measured in the fallback font, which on
889
+ // Linux (DejaVu) is wider than Inter; a box that chose two rows then kept them once Inter had left room for one, since nothing it
890
+ // watches changes size on two rows (the text box is the row's whole width there). `loadingdone`, not only `ready`: a face asked for
891
+ // after the first paint (a bold label) lands later.
851
892
  useEffect(() => {
852
893
  const el = ref.current;
853
894
  if (!el || typeof ResizeObserver === "undefined") return undefined;
854
895
  let width = el.clientWidth;
855
- const ro = new ResizeObserver(() => { if (el.clientWidth === width) return; width = el.clientWidth; fitRef.current(true); });
896
+ const refit = () => fitRef.current(true);
897
+ const ro = new ResizeObserver(() => { if (el.clientWidth === width) return; width = el.clientWidth; refit(); });
856
898
  ro.observe(el);
857
899
  const lead = boxRef.current?.querySelector(".gemboss-ec-toolbar-lead");
858
- const mo = lead ? new MutationObserver(() => fitRef.current(true)) : null;
900
+ const mo = lead ? new MutationObserver(refit) : null;
859
901
  mo?.observe(lead!, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-label", "title", "aria-label"] });
860
- return () => { ro.disconnect(); mo?.disconnect(); };
902
+ const fonts = typeof document === "undefined" ? undefined : document.fonts;
903
+ fonts?.addEventListener?.("loadingdone", refit);
904
+ let live = true;
905
+ void fonts?.ready.then(() => { if (live) refit(); });
906
+ // A STYLESHEET THAT LANDS AFTER THE FIRST MEASURE (13/11/2026): the Assistant's CSS chunk can load after the box first decided, and
907
+ // without the one-row rules (assistant-chat.css `[data-rows="1"]`) the toolbar sits under the text, so the box chose two rows with
908
+ // room for one and kept them: nothing it watches changes size when those rules arrive. The admin's composer gate read it as "an
909
+ // empty box with room for its words is two rows" on six PRs in a day; a rig that served those rules 1.2 s late reproduced it 12/12.
910
+ // `load` does not bubble: caught on its way down (capture).
911
+ const onSheet = (e: Event) => { const t = e.target as { tagName?: string; rel?: string } | null; if (t?.tagName === "LINK" && /\bstylesheet\b/i.test(t.rel ?? "")) refit(); };
912
+ document.addEventListener("load", onSheet, true);
913
+ return () => { live = false; ro.disconnect(); mo?.disconnect(); fonts?.removeEventListener?.("loadingdone", refit); document.removeEventListener("load", onSheet, true); };
861
914
  }, [ref]);
862
915
 
863
916
  // What is sent is what the box shows: a session still listening stops first, so nothing lands after the message left.
@@ -881,7 +934,8 @@ export function ChatComposer(p: ChatComposerProps) {
881
934
 
882
935
  return (
883
936
  <DensityContext.Provider value={density}>
884
- <div ref={boxRef} className={cx("gemboss-ec-input", p.className)} data-density={density}>
937
+ {/* `data-stacked`: two rows on purpose (`stacked`), so a gate reading the box can tell it from a box that wrapped. */}
938
+ <div ref={boxRef} className={cx("gemboss-ec-input", p.className)} data-density={density} data-stacked={p.stacked ? "" : undefined}>
885
939
  {p.top}
886
940
  {voice.supported ? (
887
941
  // Always there once the mic is, its words changed: a screen reader hears "Listening" arrive (a live region mounted
@@ -897,10 +951,26 @@ export function ChatComposer(p: ChatComposerProps) {
897
951
  {addNote ?? (aiProblem ? <span className="gemboss-ec-addnote-problem">{aiProblem}</span> : "")}
898
952
  </p>
899
953
  ) : null}
954
+ {slashOpen ? (
955
+ <ul className="gemboss-ec-slash" role="listbox" id={slashId} aria-label={p.shortcutsLabel ?? "Questions to ask"}>
956
+ {slashMatches.map((s, i) => (
957
+ // mousedown, not click: the text box keeps its focus (and the list its place) while the pick lands.
958
+ <li key={s.label} id={`${slashId}-${i}`} role="option" aria-selected={i === slashAt} className="gemboss-ec-slash__item"
959
+ onMouseDown={(e) => { e.preventDefault(); slashTyped(s.prompt); p.onChange(s.prompt); }}>
960
+ <span className="gemboss-ec-slash__label">{s.label}</span>
961
+ {s.sub ? <span className="gemboss-ec-slash__sub">{s.sub}</span> : null}
962
+ </li>
963
+ ))}
964
+ </ul>
965
+ ) : null}
966
+ {/* The active question, said: a text box is no combobox (a textarea takes no such role), so the list's ↑/↓ are announced here. */}
967
+ {p.shortcuts?.length ? (
968
+ <span className="ui-sr-only" aria-live="polite">{slashOpen ? `${slashMatches[slashAt].label}, ${slashAt + 1} of ${slashMatches.length}. Enter puts it in the box.` : ""}</span>
969
+ ) : null}
900
970
  <textarea
901
971
  ref={ref as Ref<HTMLTextAreaElement>}
902
972
  value={p.value}
903
- rows={p.rows ?? 1}
973
+ rows={p.rows ?? (p.stacked ? 2 : 1)}
904
974
  maxLength={p.maxLength}
905
975
  disabled={p.disabled}
906
976
  autoFocus={p.autoFocus}
@@ -910,9 +980,22 @@ export function ChatComposer(p: ChatComposerProps) {
910
980
  // admin's composer gate reads it to tell that from a box that wrapped for nothing.
911
981
  data-short-placeholder={p.shortPlaceholder}
912
982
  // The seller typing while it listens stops it at once (their edit is the box; nothing more lands in it).
913
- onChange={(e) => { cancelVoice(); if (addNote) setAddNote(null); if (aiProblem) setProblemRead(aiProblem); p.onChange(e.target.value); }}
983
+ onChange={(e) => { cancelVoice(); if (addNote) setAddNote(null); if (aiProblem) setProblemRead(aiProblem); slashTyped(e.target.value); p.onChange(e.target.value); }}
914
984
  onPaste={p.onPaste}
985
+ aria-autocomplete={p.shortcuts?.length ? "list" : undefined}
986
+ aria-controls={slashOpen ? slashId : undefined}
987
+ aria-activedescendant={slashOpen ? `${slashId}-${slashAt}` : undefined}
915
988
  onKeyDown={(e) => {
989
+ // The "/" list first: its keys never reach the host or send.
990
+ if (slashOpen && !e.nativeEvent.isComposing) {
991
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
992
+ e.preventDefault();
993
+ setSlashActive((slashAt + (e.key === "ArrowDown" ? 1 : slashMatches.length - 1)) % slashMatches.length);
994
+ return;
995
+ }
996
+ if ((e.key === "Enter" && !e.shiftKey) || e.key === "Tab") { e.preventDefault(); slashTyped(slashMatches[slashAt].prompt); p.onChange(slashMatches[slashAt].prompt); return; }
997
+ if (e.key === "Escape") { e.preventDefault(); setSlashClosedAt(p.value); return; }
998
+ }
916
999
  p.onKeyDown?.(e);
917
1000
  if (e.defaultPrevented) return;
918
1001
  // Not mid-composition: Enter there picks the IME's candidate (Vietnamese Telex, Chinese pinyin), it does not send.
@@ -1033,6 +1116,8 @@ export interface AssistantChatProps extends Omit<ChatMarkdownProps, "text"> {
1033
1116
  draft?: string;
1034
1117
  onDraftChange?: (v: string) => void;
1035
1118
  placeholder?: string;
1119
+ /** ChatComposer's: the words in the empty box when `placeholder` does not fit its field (a ✦ or a chip in the lead takes room). */
1120
+ shortPlaceholder?: ChatComposerProps["shortPlaceholder"];
1036
1121
  inputLabel?: string;
1037
1122
  /** The empty state: an assistant bubble with what to ask, then the starters. */
1038
1123
  intro?: ReactNode;
@@ -1165,7 +1250,7 @@ export function AssistantChat(p: AssistantChatProps) {
1165
1250
  <ChatComposer
1166
1251
  value={draft} onChange={setDraft} onSend={send}
1167
1252
  busy={p.busy} onStop={p.onStop} sendWhileBusy={p.sendWhileBusy}
1168
- placeholder={p.placeholder} label={p.inputLabel} maxLength={p.maxLength}
1253
+ placeholder={p.placeholder} shortPlaceholder={p.shortPlaceholder} label={p.inputLabel} maxLength={p.maxLength}
1169
1254
  add={p.add} ai={p.ai} leading={p.engine} tools={p.tools} voice={p.voice} top={p.composerTop} status={p.composerStatus}
1170
1255
  textareaRef={inputRef} onKeyDown={p.onComposerKeyDown} onPaste={p.onComposerPaste}
1171
1256
  />
@@ -0,0 +1,119 @@
1
+ "use client";
2
+
3
+ /**
4
+ * FIGURES UNDER AN ANSWER (13/11/2026, Gem Plus slice 2; Gem Plus boards, artifact DmPeQEJDAZXdiTxzmFv5UL, "stats, chart, source line").
5
+ * A chat answer that rests on numbers shows them drawn, under the words, with the line that says where they come from: the answer
6
+ * names one or two, the figures carry the rest. Drawn from the report's own vocabulary (report-charts.css `ui-barlist`, ui.css
7
+ * `ui-metrics`), so a report built later from the same figures looks the same.
8
+ *
9
+ * Shares only: every number here is a percentage, and each figure says its base as the surface words it ("from 100+ brands"). The
10
+ * component draws what it is given and adds nothing: no total, no date. The surface's words come in `labels` (English by default).
11
+ */
12
+ import "../report-charts.css";
13
+ import "../assistant-figures.css";
14
+ import React from "react";
15
+
16
+ export interface ChatFigureRow {
17
+ key: string;
18
+ label: string;
19
+ /** Two shares to compare: the group's (drawn as the bar) and everyone's (said beside it). */
20
+ proven?: number;
21
+ all?: number;
22
+ /** One share (drawn as the bar). */
23
+ share?: number;
24
+ }
25
+
26
+ export interface ChatFigure {
27
+ id: string;
28
+ title: string;
29
+ /** What the figure measures, said under its title. */
30
+ sub?: string;
31
+ /** The base as the surface says it ("100+"). */
32
+ brands: string;
33
+ /** One headline share, drawn as a number. */
34
+ value?: number;
35
+ rows: ChatFigureRow[];
36
+ }
37
+
38
+ export interface ChatFiguresLabels {
39
+ /** The base, under each title: "from 100+ brands". */
40
+ from: (brands: string) => string;
41
+ /** Beside a compared row: "all pages 31%". */
42
+ vsAll: (all: string) => string;
43
+ /** The region's name for a screen reader. */
44
+ region: string;
45
+ }
46
+
47
+ export const CHAT_FIGURES_LABELS: ChatFiguresLabels = {
48
+ from: (brands) => `from ${brands} brands`,
49
+ vsAll: (all) => `all pages ${all}`,
50
+ region: "Figures",
51
+ };
52
+
53
+ /** 24.1 → "24%", 7.5 → "7.5%", 0.4 → "0.4%": whole numbers from 10 up, one decimal below. */
54
+ export function figurePct(n: number): string {
55
+ if (!Number.isFinite(n)) return "";
56
+ const shown = n >= 10 ? Math.round(n) : Math.round(n * 10) / 10;
57
+ return `${shown}%`;
58
+ }
59
+
60
+ const bar = (n: number): React.CSSProperties => ({ ["--v" as string]: Math.max(0, Math.min(1, n / 100)) } as React.CSSProperties);
61
+
62
+ export function ChatFigures({ figures, title, source, labels }: {
63
+ figures: ChatFigure[];
64
+ /** Above the figures: what they are about ("Skincare & beauty"). */
65
+ title?: string;
66
+ /** Under them: where they come from. */
67
+ source?: string;
68
+ labels?: Partial<ChatFiguresLabels>;
69
+ }) {
70
+ const L = { ...CHAT_FIGURES_LABELS, ...labels };
71
+ if (figures.length === 0) return null;
72
+ return (
73
+ <section className="gb-chat-figures" aria-label={title ? `${L.region}: ${title}` : L.region}>
74
+ {title ? <p className="gb-chat-figures__head">{title}</p> : null}
75
+ {figures.map((f) => {
76
+ const said = [f.sub, L.from(f.brands)].filter(Boolean).join(" · ");
77
+ return (
78
+ <figure className="gb-chat-figure" key={f.id} data-figure={f.id}>
79
+ {f.value !== undefined ? (
80
+ <>
81
+ <div className="ui-metrics">
82
+ <div className="ui-metric">
83
+ <span className="ui-metric__val">{figurePct(f.value)}</span>
84
+ <span className="ui-metric__lbl">{f.title}</span>
85
+ </div>
86
+ </div>
87
+ <figcaption className="ui-muted">{said}</figcaption>
88
+ </>
89
+ ) : (
90
+ <figcaption className="gb-chat-figure__cap">
91
+ <span className="gb-chat-figure__title">{f.title}</span>
92
+ <span className="ui-muted">{said}</span>
93
+ </figcaption>
94
+ )}
95
+ {f.rows.length > 0 ? (
96
+ <ol className="ui-barlist">
97
+ {f.rows.map((r) => {
98
+ const n = r.proven ?? r.share;
99
+ if (n === undefined) return null;
100
+ return (
101
+ <li key={r.key}>
102
+ <span className="ui-barlist__label">{r.label}</span>
103
+ <span className="ui-barlist__val">
104
+ {figurePct(n)}
105
+ {r.all !== undefined ? <span className="ui-barlist__share">{L.vsAll(figurePct(r.all))}</span> : null}
106
+ </span>
107
+ <span className="ui-barlist__bar" style={bar(n)} aria-hidden />
108
+ </li>
109
+ );
110
+ })}
111
+ </ol>
112
+ ) : null}
113
+ </figure>
114
+ );
115
+ })}
116
+ {source ? <p className="gb-chat-figures__source ui-muted">{source}</p> : null}
117
+ </section>
118
+ );
119
+ }
@@ -0,0 +1,67 @@
1
+ "use client";
2
+
3
+ /**
4
+ * REAL PAGES UNDER AN ANSWER (13/11/2026, Gem Plus slice 3; boards artifact DmPeQEJDAZXdiTxzmFv5UL, "a strip of real pages, Use this
5
+ * layout"). Pictures to choose by, two to a row, each with its label, a line of what it shows, and one button that takes the seller
6
+ * to build their own page from it (the surface's link: `onUse(href)`, and a real link for a new tab).
7
+ *
8
+ * The component shows what it is given: the surface decides what a card may say (the admin never says whose page it is). The frame is
9
+ * assistant-figures.css's, the entry of the blocks drawn under an answer.
10
+ */
11
+ import "../assistant-figures.css";
12
+ import React from "react";
13
+
14
+ export interface ChatGalleryPage {
15
+ label: string;
16
+ /** What it shows ("Advertorial · 3 ads seen in the last 30 days"). */
17
+ meta?: string;
18
+ thumb_url: string;
19
+ /** Where "Use this layout" goes. */
20
+ href: string;
21
+ }
22
+
23
+ export interface ChatGalleryLabels {
24
+ /** The button. */
25
+ use: string;
26
+ /** The region's name for a screen reader. */
27
+ region: string;
28
+ }
29
+
30
+ export const CHAT_GALLERY_LABELS: ChatGalleryLabels = { use: "Use this layout", region: "Real pages" };
31
+
32
+ export function ChatPageGallery({ title, pages, onUse, labels }: {
33
+ title?: string;
34
+ pages: ChatGalleryPage[];
35
+ /** A press on "Use this layout": the surface navigates (a modified click opens the link in a new tab instead). */
36
+ onUse: (href: string) => void;
37
+ labels?: Partial<ChatGalleryLabels>;
38
+ }) {
39
+ const L = { ...CHAT_GALLERY_LABELS, ...labels };
40
+ if (pages.length === 0) return null;
41
+ return (
42
+ <section className="gb-chat-gallery" aria-label={title ? `${L.region}: ${title}` : L.region}>
43
+ {title ? <p className="gb-chat-figures__head">{title}</p> : null}
44
+ <ul className="gb-chat-gallery__grid">
45
+ {pages.map((p) => (
46
+ <li className="gb-chat-gallery__card" key={p.href}>
47
+ {/* eslint-disable-next-line @next/next/no-img-element -- a picture the surface signed, not a build asset */}
48
+ <img className="gb-chat-gallery__thumb" src={p.thumb_url} alt={p.label} loading="lazy" decoding="async" />
49
+ <span className="gb-chat-gallery__label">{p.label}</span>
50
+ {p.meta ? <span className="gb-chat-gallery__meta ui-muted">{p.meta}</span> : null}
51
+ <a
52
+ className="ui-btn gb-chat-gallery__use"
53
+ href={p.href}
54
+ onClick={(e) => {
55
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;
56
+ e.preventDefault();
57
+ onUse(p.href);
58
+ }}
59
+ >
60
+ {L.use}
61
+ </a>
62
+ </li>
63
+ ))}
64
+ </ul>
65
+ </section>
66
+ );
67
+ }