@gemboss/ui 0.70.2 → 0.73.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.
- package/CHANGELOG.md +633 -3
- package/README.md +170 -11
- package/catalog/editor.html +1 -1
- package/catalog/index.html +48 -46
- package/gemboss-ui.css +4 -4
- package/package.json +32 -1
- package/parts/components.css +3 -3
- package/parts/core.css +1 -1
- package/parts/shell.css +2 -2
- package/src/app-nav.css +1 -1
- package/src/app-shell.css +1 -1
- package/src/assistant/chat-cards.tsx +118 -19
- package/src/assistant/chat.tsx +209 -22
- package/src/assistant/composer-menus.tsx +7 -2
- package/src/assistant/dock.ts +97 -10
- package/src/assistant/figures.tsx +119 -0
- package/src/assistant/gallery.tsx +67 -0
- package/src/assistant/hold.ts +51 -0
- package/src/assistant/host.tsx +258 -137
- package/src/assistant/ideas.tsx +90 -0
- package/src/assistant/index.ts +12 -3
- package/src/assistant/plus.tsx +61 -0
- package/src/assistant/provider.tsx +121 -24
- package/src/assistant/sessions.tsx +54 -20
- package/src/assistant/window-host.tsx +215 -0
- package/src/assistant/window.ts +120 -0
- package/src/assistant-chat.css +1 -1
- package/src/assistant-figures.css +1 -0
- package/src/assistant-hold.css +1 -0
- package/src/assistant-places.css +1 -0
- package/src/assistant-plain.js +1 -1
- package/src/assistant-plus.css +1 -0
- package/src/assistant-window-plain.js +1 -0
- package/src/assistant-window.css +1 -0
- package/src/assistant.css +1 -1
- package/src/auth-extras.css +1 -1
- package/src/auth-footer.css +1 -1
- package/src/auth-steps.css +1 -1
- package/src/auth.css +1 -1
- package/src/board-move.ts +2 -1
- package/src/chat-attachments.css +1 -1
- package/src/chat-cards-drawn.css +1 -0
- package/src/chat-cards-float.css +1 -0
- package/src/chat-cards.css +1 -1
- package/src/chat-composer-menus.css +1 -1
- package/src/chat-composer.css +1 -1
- package/src/chat-plain.js +6 -6
- package/src/chat-shortcuts.css +1 -0
- package/src/chat-voice.css +1 -1
- package/src/chat.css +1 -1
- package/src/chips-drawn.css +1 -0
- package/src/collections.css +1 -1
- package/src/collections.tsx +4 -2
- package/src/create-shell.css +1 -1
- package/src/dialog.css +1 -1
- package/src/editor/choice-cards.tsx +8 -5
- package/src/editor/controls.tsx +36 -9
- package/src/editor/field-control.tsx +17 -3
- package/src/editor/field-spec.ts +17 -4
- package/src/editor/index.ts +2 -0
- package/src/editor/media-words.ts +21 -0
- package/src/editor-color.css +1 -1
- package/src/editor-empty.css +1 -0
- package/src/editor-insert.css +1 -1
- package/src/editor-inspector-frame.css +1 -1
- package/src/editor-media.css +1 -1
- package/src/editor-picker-grid.css +1 -1
- package/src/editor-picker.css +1 -1
- package/src/editor-popover.css +1 -1
- package/src/editor-repeater.css +1 -1
- package/src/editor-tiles.css +1 -1
- package/src/editor.css +1 -1
- package/src/email-canvas.css +1 -0
- package/src/email-card.tsx +44 -0
- package/src/email-editor/canvas.tsx +109 -0
- package/src/email-editor/editor.tsx +45 -4
- package/src/email-editor/index.ts +2 -1
- package/src/email-editor/model.ts +9 -1
- package/src/email-editor.css +1 -1
- package/src/email-parts.css +1 -0
- package/src/email-parts.tsx +81 -0
- package/src/email-thumb.css +1 -0
- package/src/email-thumb.tsx +206 -0
- package/src/feedback-dialog.css +1 -0
- package/src/feedback-dialog.tsx +122 -0
- package/src/flow-strip.css +1 -0
- package/src/flow-strip.tsx +50 -0
- package/src/gemboss-field-drawn.css +1 -0
- package/src/gemboss-field.css +1 -1
- package/src/gems.css +1 -1
- package/src/icon-frame.tsx +31 -0
- package/src/icons.tsx +9 -9
- package/src/index.ts +12 -0
- package/src/job-card.css +1 -1
- package/src/kit-plain.css +1 -1
- package/src/kit-plain.js +1 -1
- package/src/language-switcher.css +1 -1
- package/src/list-page.css +1 -1
- package/src/list-page.tsx +6 -3
- package/src/list-toolbar.css +1 -1
- package/src/media-card.css +1 -0
- package/src/members.css +1 -1
- package/src/menu-extras.css +1 -1
- package/src/menu-layer.ts +2 -0
- package/src/menu-select.css +1 -1
- package/src/menu.css +1 -1
- package/src/menu.tsx +9 -4
- package/src/narration.css +1 -1
- package/src/pager-extras.css +1 -1
- package/src/pager.css +1 -1
- package/src/picture-actions.css +1 -0
- package/src/picture-actions.tsx +23 -0
- package/src/portal.css +1 -1
- package/src/question-card.css +1 -1
- package/src/rail-fold.css +1 -1
- package/src/reactions.css +1 -1
- package/src/reader-dialog.css +1 -1
- package/src/report-charts.css +1 -1
- package/src/segmented.tsx +6 -0
- package/src/service-switcher.css +1 -1
- package/src/session-rail-plain.js +1 -1
- package/src/settings-dialog.css +1 -1
- package/src/setup-guide.css +1 -1
- package/src/sheet.css +1 -1
- package/src/shell.css +1 -1
- package/src/shell.tsx +9 -2
- package/src/site.css +1 -1
- package/src/skill-card.css +1 -1
- package/src/skill-flow.css +1 -1
- package/src/skill-pages.css +1 -1
- package/src/skill-view.css +1 -1
- package/src/stage-path.css +1 -1
- package/src/stat-tile.css +1 -0
- package/src/stat-tile.tsx +39 -0
- package/src/status-list.css +1 -1
- package/src/team-chat.css +1 -1
- package/src/tray-plain.js +1 -0
- package/src/tray-search.tsx +116 -0
- package/src/tray.css +1 -0
- package/src/tray.tsx +250 -0
- 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
|
|
127
|
-
*
|
|
128
|
-
|
|
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>(
|
|
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
|
-
{
|
|
156
|
-
<
|
|
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}
|
package/src/assistant/chat.tsx
CHANGED
|
@@ -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, {
|
|
@@ -585,11 +586,79 @@ function crowded(box: HTMLElement): boolean {
|
|
|
585
586
|
const bar = box.querySelector<HTMLElement>(".gemboss-ec-toolbar");
|
|
586
587
|
if (lead && lead.scrollWidth > lead.clientWidth + 1) return true;
|
|
587
588
|
if (bar && bar.scrollWidth > bar.clientWidth + 1) return true;
|
|
589
|
+
// One row (composerRows): the lead leaves the words no room. The toolbar has no box of its own there, so this is its overflow.
|
|
590
|
+
if (box.dataset.rows === "1" && cramped(box)) return true;
|
|
588
591
|
for (const l of box.querySelectorAll<HTMLElement>(LABEL_SEL)) if (l.offsetParent !== null && l.scrollWidth > l.clientWidth + 1) return true;
|
|
589
592
|
for (const c of box.querySelectorAll<HTMLElement>(CHIP_SEL)) if (c.offsetParent !== null && c.tagName !== "SELECT" && c.scrollWidth > c.clientWidth + 1) return true;
|
|
590
593
|
return false;
|
|
591
594
|
}
|
|
592
595
|
|
|
596
|
+
/**
|
|
597
|
+
* ONE ROW OR TWO (12/11/2026, Chris: "cả input bên dưới cũng nên là một dòng; nếu viết dài thì nó dãn ra thành 2 dòng"). A box with
|
|
598
|
+
* something in its lead ("+", ✦, a chip) is one row while the words fit on one line: lead, text, tools, send (`data-rows="1"`,
|
|
599
|
+
* assistant-chat.css). Once they need a second line it is two: the text over the toolbar (`data-rows="2"`, the layout before).
|
|
600
|
+
* Only CSS changes between them: the text box is the same element, so the caret, the focus and the selection stay where they are.
|
|
601
|
+
*
|
|
602
|
+
* MEASURED, NOT COUNTED: the words' height in the ONE-ROW layout, against one line's (the box's line-height). Always measured in
|
|
603
|
+
* that layout, set for a moment before paint, so the second row's wider box never decides (that is the feedback that would
|
|
604
|
+
* flicker). HYSTERESIS: on two rows, it goes back only when the words fit one line with 24px to spare, so a word at the edge
|
|
605
|
+
* does not flip it on every key. Empty is one row, unless the box was given a `shortPlaceholder` and even that is wider than the one-row
|
|
606
|
+
* field (13/11/2026: 34px at 320 under a finger, "Ask Gem…" cut): then two rows, where the field is the box's width, as the same width
|
|
607
|
+
* under a mouse already is. A lead that leaves the words no room (under 48px, or pushed onto a line of their own: a wide chip in a
|
|
608
|
+
* narrow box) is two rows. Null: an empty lead, which is one row already (chat-composer.css `:has(lead:empty)`).
|
|
609
|
+
* chat-plain.js measures the same way (`rowsFor`).
|
|
610
|
+
*/
|
|
611
|
+
/** On one row, the words do not share the line with the lead and send (the box wraps, for the full-width rows over it), or have
|
|
612
|
+
* under 48px of it. */
|
|
613
|
+
function cramped(box: HTMLElement): boolean {
|
|
614
|
+
const ta = box.querySelector("textarea");
|
|
615
|
+
if (!ta) return false;
|
|
616
|
+
const t = ta.getBoundingClientRect();
|
|
617
|
+
const beside = (sel: string) => { const r = box.querySelector(sel)?.getBoundingClientRect(); return !r || (r.top < t.bottom && r.bottom > t.top); };
|
|
618
|
+
return ta.clientWidth < 48 || !beside(".gemboss-ec-toolbar-lead") || !beside(".gemboss-ec-toolbar > :is(button[type=submit], .gemboss-ec-stop)");
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export function composerRows(box: HTMLElement, ta: HTMLTextAreaElement, least?: string): "1" | "2" | null {
|
|
622
|
+
if (!box.querySelector(".gemboss-ec-toolbar-lead")?.firstElementChild) return null;
|
|
623
|
+
const was = box.dataset.rows;
|
|
624
|
+
// On one row already: measured as it stands, nothing written (review of #7341: a forced layout on every key). The box is one line
|
|
625
|
+
// tall there, so words that wrap show as a scroll height past it.
|
|
626
|
+
if (was === "1") {
|
|
627
|
+
const cs = getComputedStyle(ta);
|
|
628
|
+
const words = ta.value ? ta.scrollHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) : 0;
|
|
629
|
+
return cramped(box) || unshown(ta, cs, least) || words > (parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.5) * 1.5 ? "2" : "1";
|
|
630
|
+
}
|
|
631
|
+
box.dataset.rows = "1";
|
|
632
|
+
const st = ta.style;
|
|
633
|
+
const keep = [st.height, st.minHeight, st.maxWidth];
|
|
634
|
+
const cs = getComputedStyle(ta);
|
|
635
|
+
const line = parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.5;
|
|
636
|
+
// The room itself, as `cramped`: no 24px kept (an empty box changes rows only on a new width, never as keys go), so the admin's
|
|
637
|
+
// composer gate and the box read the same room (review of #7350).
|
|
638
|
+
const narrow = cramped(box) || unshown(ta, cs, least);
|
|
639
|
+
// Two rows: as wide as one row's text would be, less the 24px that keeps it there.
|
|
640
|
+
if (was === "2") st.maxWidth = `${Math.max(0, ta.clientWidth - 24)}px`;
|
|
641
|
+
st.height = "0px"; st.minHeight = "0px";
|
|
642
|
+
const words = ta.value ? ta.scrollHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom) : 0;
|
|
643
|
+
[st.height, st.minHeight, st.maxWidth] = keep;
|
|
644
|
+
if (was) box.dataset.rows = was; else delete box.dataset.rows;
|
|
645
|
+
return narrow || words > line * 1.5 ? "2" : "1";
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** The field's width for words: the text box less its padding. */
|
|
649
|
+
const fieldWidth = (ta: HTMLTextAreaElement, cs: CSSStyleDeclaration) => ta.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight);
|
|
650
|
+
/** Empty, and `least` (the shortest placeholder it has) is wider than the field: it would show cut. */
|
|
651
|
+
const unshown = (ta: HTMLTextAreaElement, cs: CSSStyleDeclaration, least?: string) => !ta.value && !!least && textWidth(least, cs) > fieldWidth(ta, cs);
|
|
652
|
+
|
|
653
|
+
/** How wide `text` is in `cs`'s font (one canvas, kept). */
|
|
654
|
+
let measureCtx: CanvasRenderingContext2D | null = null;
|
|
655
|
+
function textWidth(text: string, cs: CSSStyleDeclaration): number {
|
|
656
|
+
measureCtx ??= document.createElement("canvas").getContext("2d");
|
|
657
|
+
if (!measureCtx) return 0;
|
|
658
|
+
measureCtx.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
|
|
659
|
+
return measureCtx.measureText(text).width;
|
|
660
|
+
}
|
|
661
|
+
|
|
593
662
|
/** The paperclip every composer draws: one glyph, not 📎 in one chat and an SVG in another. */
|
|
594
663
|
export function PaperclipIcon() {
|
|
595
664
|
return (
|
|
@@ -635,6 +704,9 @@ export interface ChatComposerProps {
|
|
|
635
704
|
* image), an upload still running is not. The text box stays editable either way; `disabled` is for the whole box. */
|
|
636
705
|
canSend?: boolean;
|
|
637
706
|
placeholder?: string;
|
|
707
|
+
/** Said in the box instead of `placeholder` when that one does not fit the field (12/11/2026: "How's my stor" at 390 under a finger):
|
|
708
|
+
* measured against the words' width in the box's own font, so a narrow panel on a desktop gets it too, not by the window's width. */
|
|
709
|
+
shortPlaceholder?: string;
|
|
638
710
|
/** The text box's accessible name (default "Message"). */
|
|
639
711
|
label?: string;
|
|
640
712
|
/**
|
|
@@ -680,11 +752,31 @@ export interface ChatComposerProps {
|
|
|
680
752
|
status?: ReactNode;
|
|
681
753
|
maxLength?: number;
|
|
682
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;
|
|
683
760
|
disabled?: boolean;
|
|
684
761
|
textareaRef?: RefObject<HTMLTextAreaElement | null>;
|
|
685
762
|
onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
686
763
|
onPaste?: ClipboardEventHandler<HTMLTextAreaElement>;
|
|
687
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);
|
|
688
780
|
}
|
|
689
781
|
|
|
690
782
|
/**
|
|
@@ -693,6 +785,15 @@ export interface ChatComposerProps {
|
|
|
693
785
|
* review #916). The send button keeps `type="submit"` because chat.css draws it by that; outside a form it submits nothing.
|
|
694
786
|
*/
|
|
695
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); };
|
|
696
797
|
const L = useLabels();
|
|
697
798
|
const own = useRef<HTMLTextAreaElement | null>(null);
|
|
698
799
|
const ref = p.textareaRef ?? own;
|
|
@@ -736,30 +837,81 @@ export function ChatComposer(p: ChatComposerProps) {
|
|
|
736
837
|
mo.observe(lead, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-label", "title", "aria-label"] });
|
|
737
838
|
restart();
|
|
738
839
|
let live = true;
|
|
739
|
-
|
|
740
|
-
|
|
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); };
|
|
741
849
|
}, []);
|
|
742
850
|
|
|
743
851
|
// Grow from one line to the box's max-height (chat.css: 84px), then scroll inside. Hidden (a closed tab): skip, the
|
|
744
|
-
// observer fits it when it gets a size.
|
|
852
|
+
// observer fits it when it gets a size. Before paint, so the row it picks (`composerRows`) is the first one seen.
|
|
853
|
+
// The words the row was last decided for: on two rows, words that only GREW at the end cannot fit one line again; on one row, words
|
|
854
|
+
// that only SHRANK at the end cannot need two. Anything else (a paste over a selection, an edit in the middle) is measured (review of
|
|
855
|
+
// #7341: a forced layout on every key, and a length alone misread a paste).
|
|
856
|
+
const decided = useRef("");
|
|
857
|
+
// The full placeholder fits the field, measured against the words' width (`shortPlaceholder`).
|
|
858
|
+
const [placeholderFits, setPlaceholderFits] = useState(true);
|
|
859
|
+
const fitRef = useRef<(force?: boolean) => void>(() => {});
|
|
860
|
+
fitRef.current = (force = false) => {
|
|
861
|
+
const el = ref.current;
|
|
862
|
+
if (!el || el.offsetParent === null || el.scrollHeight === 0) return;
|
|
863
|
+
const box = boxRef.current;
|
|
864
|
+
const prev = decided.current, now = el.value;
|
|
865
|
+
decided.current = now;
|
|
866
|
+
const was = box?.dataset.rows;
|
|
867
|
+
// Emptied on one row: measured, the placeholder may not fit there (`shortPlaceholder`). The other way, on purpose: an empty box on
|
|
868
|
+
// two rows because even its short placeholder did not fit one row stays two as words start ("" starts every word). Its one-row
|
|
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
|
|
870
|
+
// away (review of #7350 asked; kept).
|
|
871
|
+
const kept = !force && ((was === "2" && now.startsWith(prev)) || (was === "1" && now !== "" && prev.startsWith(now))) ? was : null;
|
|
872
|
+
const rows = !box ? null : p.stacked ? "2" : kept ?? composerRows(box, el, p.shortPlaceholder);
|
|
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).
|
|
874
|
+
if (box && (box.dataset.rows ?? null) !== rows) {
|
|
875
|
+
if (rows) box.dataset.rows = rows; else delete box.dataset.rows;
|
|
876
|
+
setDensity("full"); setRemeasure((n) => n + 1);
|
|
877
|
+
}
|
|
878
|
+
const cs = getComputedStyle(el);
|
|
879
|
+
const max = parseFloat(cs.maxHeight) || 84;
|
|
880
|
+
el.style.height = "auto";
|
|
881
|
+
const want = el.scrollHeight + (el.offsetHeight - el.clientHeight); // border-box: add the 1px borders back
|
|
882
|
+
el.style.height = `${Math.min(want, max)}px`;
|
|
883
|
+
el.style.overflowY = want > max ? "auto" : "hidden";
|
|
884
|
+
if (p.shortPlaceholder && p.placeholder) setPlaceholderFits(textWidth(p.placeholder, cs) <= fieldWidth(el, cs));
|
|
885
|
+
};
|
|
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.
|
|
745
892
|
useEffect(() => {
|
|
746
893
|
const el = ref.current;
|
|
747
|
-
if (!el) return undefined;
|
|
748
|
-
const fit = () => {
|
|
749
|
-
if (el.offsetParent === null || el.scrollHeight === 0) return;
|
|
750
|
-
const max = parseFloat(getComputedStyle(el).maxHeight) || 84;
|
|
751
|
-
el.style.height = "auto";
|
|
752
|
-
const want = el.scrollHeight + (el.offsetHeight - el.clientHeight); // border-box: add the 1px borders back
|
|
753
|
-
el.style.height = `${Math.min(want, max)}px`;
|
|
754
|
-
el.style.overflowY = want > max ? "auto" : "hidden";
|
|
755
|
-
};
|
|
756
|
-
fit();
|
|
757
|
-
if (typeof ResizeObserver === "undefined") return undefined;
|
|
894
|
+
if (!el || typeof ResizeObserver === "undefined") return undefined;
|
|
758
895
|
let width = el.clientWidth;
|
|
759
|
-
const
|
|
896
|
+
const refit = () => fitRef.current(true);
|
|
897
|
+
const ro = new ResizeObserver(() => { if (el.clientWidth === width) return; width = el.clientWidth; refit(); });
|
|
760
898
|
ro.observe(el);
|
|
761
|
-
|
|
762
|
-
|
|
899
|
+
const lead = boxRef.current?.querySelector(".gemboss-ec-toolbar-lead");
|
|
900
|
+
const mo = lead ? new MutationObserver(refit) : null;
|
|
901
|
+
mo?.observe(lead!, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-label", "title", "aria-label"] });
|
|
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); };
|
|
914
|
+
}, [ref]);
|
|
763
915
|
|
|
764
916
|
// What is sent is what the box shows: a session still listening stops first, so nothing lands after the message left.
|
|
765
917
|
const send = () => { if (canSend) { cancelVoice(); p.onSend(p.value); } };
|
|
@@ -782,7 +934,8 @@ export function ChatComposer(p: ChatComposerProps) {
|
|
|
782
934
|
|
|
783
935
|
return (
|
|
784
936
|
<DensityContext.Provider value={density}>
|
|
785
|
-
|
|
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}>
|
|
786
939
|
{p.top}
|
|
787
940
|
{voice.supported ? (
|
|
788
941
|
// Always there once the mic is, its words changed: a screen reader hears "Listening" arrive (a live region mounted
|
|
@@ -798,19 +951,51 @@ export function ChatComposer(p: ChatComposerProps) {
|
|
|
798
951
|
{addNote ?? (aiProblem ? <span className="gemboss-ec-addnote-problem">{aiProblem}</span> : "")}
|
|
799
952
|
</p>
|
|
800
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}
|
|
801
970
|
<textarea
|
|
802
971
|
ref={ref as Ref<HTMLTextAreaElement>}
|
|
803
972
|
value={p.value}
|
|
804
|
-
rows={p.rows ?? 1}
|
|
973
|
+
rows={p.rows ?? (p.stacked ? 2 : 1)}
|
|
805
974
|
maxLength={p.maxLength}
|
|
806
975
|
disabled={p.disabled}
|
|
807
976
|
autoFocus={p.autoFocus}
|
|
808
977
|
aria-label={p.label ?? L.message}
|
|
809
|
-
placeholder={p.placeholder}
|
|
978
|
+
placeholder={p.shortPlaceholder && !placeholderFits ? p.shortPlaceholder : p.placeholder}
|
|
979
|
+
// The shortest text the empty box shows: a box is two rows when even this does not fit one row (`composerRows`), and the
|
|
980
|
+
// admin's composer gate reads it to tell that from a box that wrapped for nothing.
|
|
981
|
+
data-short-placeholder={p.shortPlaceholder}
|
|
810
982
|
// The seller typing while it listens stops it at once (their edit is the box; nothing more lands in it).
|
|
811
|
-
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); }}
|
|
812
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}
|
|
813
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
|
+
}
|
|
814
999
|
p.onKeyDown?.(e);
|
|
815
1000
|
if (e.defaultPrevented) return;
|
|
816
1001
|
// Not mid-composition: Enter there picks the IME's candidate (Vietnamese Telex, Chinese pinyin), it does not send.
|
|
@@ -931,6 +1116,8 @@ export interface AssistantChatProps extends Omit<ChatMarkdownProps, "text"> {
|
|
|
931
1116
|
draft?: string;
|
|
932
1117
|
onDraftChange?: (v: string) => void;
|
|
933
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"];
|
|
934
1121
|
inputLabel?: string;
|
|
935
1122
|
/** The empty state: an assistant bubble with what to ask, then the starters. */
|
|
936
1123
|
intro?: ReactNode;
|
|
@@ -1063,7 +1250,7 @@ export function AssistantChat(p: AssistantChatProps) {
|
|
|
1063
1250
|
<ChatComposer
|
|
1064
1251
|
value={draft} onChange={setDraft} onSend={send}
|
|
1065
1252
|
busy={p.busy} onStop={p.onStop} sendWhileBusy={p.sendWhileBusy}
|
|
1066
|
-
placeholder={p.placeholder} label={p.inputLabel} maxLength={p.maxLength}
|
|
1253
|
+
placeholder={p.placeholder} shortPlaceholder={p.shortPlaceholder} label={p.inputLabel} maxLength={p.maxLength}
|
|
1067
1254
|
add={p.add} ai={p.ai} leading={p.engine} tools={p.tools} voice={p.voice} top={p.composerTop} status={p.composerStatus}
|
|
1068
1255
|
textareaRef={inputRef} onKeyDown={p.onComposerKeyDown} onPaste={p.onComposerPaste}
|
|
1069
1256
|
/>
|
|
@@ -46,8 +46,11 @@ export interface ChatAddItem {
|
|
|
46
46
|
disabled?: boolean;
|
|
47
47
|
/** Why it is off, or more about it: its tooltip. */
|
|
48
48
|
title?: string;
|
|
49
|
+
/** A switch, not an action (12/11/2026, Gem's "Use this screen"): `menuitemcheckbox`, the kit's check before it while on.
|
|
50
|
+
* Its `onSelect` turns it over. Left out: a plain row. */
|
|
51
|
+
checked?: boolean;
|
|
49
52
|
}
|
|
50
|
-
export type ChatAddIcon = "image" | "file" | "media" | "screenshot" | "mention" | "link";
|
|
53
|
+
export type ChatAddIcon = "image" | "file" | "media" | "screenshot" | "mention" | "link" | "screen" | "document";
|
|
51
54
|
|
|
52
55
|
export interface ChatComposerAdd {
|
|
53
56
|
items: readonly ChatAddItem[];
|
|
@@ -88,7 +91,7 @@ export interface ChatComposerAi {
|
|
|
88
91
|
export function PlusGlyph() { return <Icon name="plus" />; }
|
|
89
92
|
export function SparkleGlyph() { return <Icon name="sparkle" />; }
|
|
90
93
|
const ROW_GLYPH: Record<ChatAddIcon, IconName> = {
|
|
91
|
-
image: "image", file: "paperclip", media: "media", screenshot: "screenshot", mention: "at", link: "link",
|
|
94
|
+
image: "image", file: "paperclip", media: "media", screenshot: "screenshot", mention: "at", link: "link", screen: "eye", document: "document",
|
|
92
95
|
};
|
|
93
96
|
const iconOf = (it: ChatAddItem): ChatAddIcon =>
|
|
94
97
|
it.icon ?? (it.paste ? "screenshot" : it.onFiles ? (/^\s*image\/[^,]*(\s*,\s*image\/[^,]*)*\s*$/.test(it.accept ?? "") ? "image" : "file") : "media");
|
|
@@ -148,6 +151,8 @@ export function useComposerAdd(add: ChatComposerAdd | null | undefined, disabled
|
|
|
148
151
|
<Menu label={label} icon={<PlusGlyph />} className="gemboss-ec-add" disabled={disabled} loading={add.busy}>
|
|
149
152
|
{items.map((it, i) => (
|
|
150
153
|
<MenuItem key={`${i}:${it.label}`} icon={<Icon name={ROW_GLYPH[iconOf(it)]} size={16} />} description={it.description} disabled={it.disabled} title={it.title}
|
|
154
|
+
// A switch row: the check and `aria-checked` are MenuItem's choice; the role says it turns on and off on its own.
|
|
155
|
+
checked={it.checked} {...(it.checked === undefined ? {} : { role: "menuitemcheckbox" })}
|
|
151
156
|
onClick={() => {
|
|
152
157
|
onNote(null);
|
|
153
158
|
if (it.onFiles) inputs.current[i]?.click();
|