@gemboss/ui 0.67.0 → 0.69.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 (53) hide show
  1. package/CHANGELOG.md +179 -4
  2. package/README.md +89 -9
  3. package/catalog/editor.html +10 -8
  4. package/catalog/index.html +615 -564
  5. package/gemboss-ui.css +3 -3
  6. package/package.json +5 -2
  7. package/parts/components.css +1 -1
  8. package/parts/core.css +1 -1
  9. package/parts/shell.css +1 -1
  10. package/src/assistant/attachments.tsx +486 -0
  11. package/src/assistant/chat-cards.tsx +343 -0
  12. package/src/assistant/chat.tsx +29 -6
  13. package/src/assistant/host.tsx +8 -11
  14. package/src/assistant/index.ts +8 -1
  15. package/src/assistant-chat.css +1 -1
  16. package/src/assistant-plain.js +1 -1
  17. package/src/assistant.css +1 -1
  18. package/src/auth-field.css +1 -1
  19. package/src/auth.tsx +4 -2
  20. package/src/chat-attachments.css +1 -0
  21. package/src/chat-cards.css +1 -0
  22. package/src/chat-plain.js +5 -5
  23. package/src/collections.tsx +8 -1
  24. package/src/dialog.tsx +68 -11
  25. package/src/editor/controls.tsx +51 -10
  26. package/src/editor/field-control.tsx +26 -51
  27. package/src/editor/field-frame.tsx +4 -10
  28. package/src/editor/field-spec.ts +4 -2
  29. package/src/editor/grow-to-text.ts +51 -0
  30. package/src/editor/index.ts +2 -4
  31. package/src/editor/inspector-frame.tsx +143 -32
  32. package/src/editor/items-field.tsx +8 -3
  33. package/src/editor/items.ts +30 -6
  34. package/src/editor/panel.tsx +4 -5
  35. package/src/editor-grow.css +1 -1
  36. package/src/editor-inspector-frame.css +1 -1
  37. package/src/editor-media.css +1 -0
  38. package/src/editor-plain.js +1 -1
  39. package/src/editor-rail.css +1 -1
  40. package/src/editor.css +1 -1
  41. package/src/email-editor/editor.tsx +96 -69
  42. package/src/email-editor.css +1 -1
  43. package/src/gem-at-work.css +1 -1
  44. package/src/gem-at-work.ts +177 -33
  45. package/src/gem-holo.css +1 -1
  46. package/src/icons.tsx +42 -0
  47. package/src/index-table-extras.css +1 -0
  48. package/src/index-table.tsx +37 -16
  49. package/src/menu.tsx +7 -3
  50. package/src/narration.css +1 -1
  51. package/src/selection.tsx +22 -12
  52. package/src/editor/chips.tsx +0 -24
  53. package/src/editor-chips.css +0 -1
package/src/dialog.tsx CHANGED
@@ -14,10 +14,13 @@
14
14
  * to the right edge: it renders `Dialog` and brings sheet.css, so the markup and the behaviour each have one owner.
15
15
  */
16
16
  import "./dialog.css"; // its frame travels with it (09/11/2026): a surface that loads ui.css alone (the admin) draws it too
17
- import React, { useEffect, useId, useRef } from "react";
17
+ import React, { useEffect, useId, useRef, useState } from "react";
18
18
  import { flushSync } from "react-dom";
19
19
  import { Icon } from "./icons";
20
20
  import { consumeEscape } from "./escape";
21
+ // The question `dirty` asks (10/11/2026). ConfirmDialog draws itself with this file's Dialog; it is used only when one renders, so
22
+ // the two modules may name each other.
23
+ import { ConfirmDialog } from "./confirm-dialog";
21
24
 
22
25
  const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
23
26
 
@@ -39,6 +42,8 @@ const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean)
39
42
  * - `dismissible: false` (08/11/2026, ConfirmDialog while the server answers): Escape, the backdrop and ✕ do not close it. The
40
43
  * browser's `cancel` is prevented, and when it closes anyway (Chrome lets a second Escape with no press between go through) it
41
44
  * opens again at once; only `open` turning false closes it then.
45
+ * - `ask` (10/11/2026, Dialog's `dirty`): Escape, the backdrop and ✕ call it instead of closing (the caller asks first), and a
46
+ * close the browser makes anyway opens it again and asks. `leave()` is the close the answer makes: it goes through.
42
47
  */
43
48
  // The control a press last landed on (24/10/2026). Polaris' buttons blur themselves on mouseup (UnstyledButton's
44
49
  // handleMouseUpByBlurring), so a popup opened by a click on one found <body> focused and gave the focus back to <body> on Escape:
@@ -72,10 +77,15 @@ export function holdTab(e: React.KeyboardEvent<HTMLElement>): void {
72
77
  if (own === e.currentTarget) e.stopPropagation();
73
78
  }
74
79
 
75
- export function useModalDialog(open: boolean, onClose: () => void, { focusPanel = false, returnFocusTo, dismissible = true }: { focusPanel?: boolean; returnFocusTo?: string; dismissible?: boolean } = {}) {
80
+ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel = false, returnFocusTo, dismissible = true, ask = null }: { focusPanel?: boolean; returnFocusTo?: string; dismissible?: boolean; ask?: (() => void) | null } = {}) {
76
81
  const ref = useRef<HTMLDialogElement>(null);
77
82
  const dismiss = useRef(dismissible);
78
83
  dismiss.current = dismissible;
84
+ const asks = useRef(ask);
85
+ asks.current = ask;
86
+ // Set by `leave()`, the close an answer makes ("Discard and close"): it is not asked about again. Cleared on every opening.
87
+ const leaving = useRef(false);
88
+ const asking = () => (asks.current && !leaving.current ? asks.current : null);
79
89
  const openNow = useRef(open);
80
90
  openNow.current = open;
81
91
  const opener = useRef<Element | null>(null);
@@ -94,6 +104,7 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
94
104
  const d = ref.current;
95
105
  if (!d) return;
96
106
  if (open && !d.open) {
107
+ leaving.current = false;
97
108
  opener.current = openerNow();
98
109
  d.showModal();
99
110
  shown.current = true;
@@ -106,10 +117,17 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
106
117
  const d = ref.current;
107
118
  if (!d) return undefined;
108
119
  // Not dismissible: Escape does nothing (the browser's cancel is prevented)…
109
- const onCancel = (e: Event) => { if (!dismiss.current) e.preventDefault(); };
120
+ // …and while it asks first (`ask`), a close request asks instead (the Escape a focus outside it sends, a phone's Back).
121
+ const onCancel = (e: Event) => {
122
+ if (!dismiss.current) { e.preventDefault(); return; }
123
+ const a = asking();
124
+ if (a) { e.preventDefault(); a(); }
125
+ };
110
126
  const onNativeClose = () => {
111
- // …and a close the browser made anyway (a second Escape) is undone while the caller still has it open.
112
- if (!dismiss.current && openNow.current) { try { d.showModal(); } catch { /* not connected: it is going anyway */ } return; }
127
+ // …and a close the browser made anyway (a second Escape) is undone while the caller still has it open; one that would
128
+ // have asked asks now.
129
+ const a = dismiss.current ? asking() : null;
130
+ if ((!dismiss.current || a) && openNow.current) { try { d.showModal(); } catch { /* not connected: it is going anyway */ } a?.(); return; }
113
131
  shown.current = false;
114
132
  // What closing changes is on the page before the focus goes back: a picker's typed handle, saved as it closes, replaces its
115
133
  // "Choose a product" with the chosen row, and the focus went to that button an instant before it left (measured, 24/10/2026).
@@ -134,10 +152,13 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
134
152
  }, [open, dismissible]);
135
153
  const onPointerDown = (e: React.PointerEvent<HTMLDialogElement>) => { pressOnBackdrop.current = e.target === e.currentTarget; };
136
154
  const onClick = (e: React.MouseEvent<HTMLDialogElement>) => {
137
- if (e.target === e.currentTarget && pressOnBackdrop.current && dismiss.current) e.currentTarget.close();
155
+ if (e.target === e.currentTarget && pressOnBackdrop.current && dismiss.current) { const a = asking(); if (a) a(); else e.currentTarget.close(); }
138
156
  pressOnBackdrop.current = false;
139
157
  };
140
- return { ref, onClick, onPointerDown, onKeyDown: holdTab };
158
+ /** ✕, or the answer to the question `ask` opened: the second goes through without asking again. */
159
+ const requestClose = () => { const a = asking(); if (a) a(); else ref.current?.close(); };
160
+ const leave = () => { leaving.current = true; ref.current?.close(); };
161
+ return { ref, onClick, onPointerDown, onKeyDown: holdTab, requestClose, leave, asking };
141
162
  }
142
163
 
143
164
  export interface DialogProps {
@@ -163,13 +184,33 @@ export interface DialogProps {
163
184
  returnFocusTo?: string;
164
185
  /** False while it must stay (ConfirmDialog waiting for the server): Escape, the backdrop and ✕ do not close it. Default true. */
165
186
  dismissible?: boolean;
187
+ /** Closing now would lose work nobody saved (typed words, a pasted picture; 10/11/2026, one control set): Escape, ✕ and the
188
+ * backdrop ask first, in the kit's ConfirmDialog over it, as the admin's PluginPopup does (popup-close.ts): "Discard unsaved
189
+ * changes?", Keep editing (it stays as it was) or Discard and close (`onClose`). `open` turning false never asks: the caller
190
+ * closes on purpose. Passed at all (false too), the question is mounted, ready; left out, nothing changes. */
191
+ dirty?: boolean;
192
+ /** The question's words, for a surface's own words or its viewer's language ("Close the composer?"). English by default. */
193
+ dirtyAsk?: { title?: string; body?: React.ReactNode; action?: string; cancelLabel?: string; closeLabel?: string };
166
194
  }
167
195
 
168
- export function Dialog({ open, onClose, title, subtitle, actions, children, footer, wide = false, closeLabel = "Close", className, focusPanel = false, returnFocusTo, lead, dismissible = true }: DialogProps) {
169
- const { ref, onClick, onPointerDown, onKeyDown } = useModalDialog(open, onClose, { focusPanel, returnFocusTo, dismissible });
196
+ const DIRTY_ASK = { title: "Discard unsaved changes?", body: "You have changes that aren’t saved. If you close now, they’re lost.",
197
+ action: "Discard and close", cancelLabel: "Keep editing" };
198
+
199
+ export function Dialog({ open, onClose, title, subtitle, actions, children, footer, wide = false, closeLabel = "Close", className, focusPanel = false, returnFocusTo, lead, dismissible = true, dirty, dirtyAsk }: DialogProps) {
200
+ const [asked, setAsked] = useState(false);
201
+ // Discard pressed: the question closes first (its effect, a child's, runs before this one), then this popup, so the focus goes
202
+ // back to what opened IT, not to a control of a popup that is going.
203
+ const discarding = useRef(false);
204
+ const { ref, onClick, onPointerDown, onKeyDown, requestClose, leave, asking } = useModalDialog(open, onClose,
205
+ { focusPanel, returnFocusTo, dismissible, ask: dirty ? () => setAsked(true) : null });
206
+ useEffect(() => { if (!asked && discarding.current) { discarding.current = false; leave(); } }, [asked]); // eslint-disable-line react-hooks/exhaustive-deps
207
+ // Closed by its caller while asking (saved elsewhere, a route change): the question goes with it.
208
+ if (!open && asked) setAsked(false);
170
209
  const titleId = useId();
171
210
  const subId = useId();
211
+ const words = { ...DIRTY_ASK, ...dirtyAsk };
172
212
  return (
213
+ <>
173
214
  <dialog ref={ref} className={cx("ui-modal", wide && "ui-modal--wide", className)} aria-labelledby={titleId}
174
215
  aria-describedby={subtitle ? subId : undefined} tabIndex={focusPanel ? -1 : undefined} onClick={onClick} onPointerDown={onPointerDown}
175
216
  // Its Escape closes it and only it, as the kit's Popover: the browser closes the <dialog>, and neither the keydown nor the keyup
@@ -177,19 +218,35 @@ export function Dialog({ open, onClose, title, subtitle, actions, children, foot
177
218
  // words on Escape (PickerList's) consumes the key before it gets here.
178
219
  // Not dismissible: the key's default is prevented too, so the browser makes no close request at all (a prevented `cancel`
179
220
  // only holds once: Chrome lets a second Escape with no press between close it).
180
- onKeyDown={(e) => { onKeyDown(e); if (e.key === "Escape" && !e.nativeEvent.isComposing) { consumeEscape(e); if (!dismissible) e.preventDefault(); } }}>
221
+ // Asking first (`dirty`): its Escape asks, and makes no close request either.
222
+ onKeyDown={(e) => {
223
+ onKeyDown(e);
224
+ if (e.key !== "Escape" || e.nativeEvent.isComposing) return;
225
+ consumeEscape(e);
226
+ if (!dismissible) { e.preventDefault(); return; }
227
+ const a = asking();
228
+ if (a) { e.preventDefault(); a(); }
229
+ }}>
181
230
  <div className="ui-modal__head">
182
231
  {lead}
183
232
  {subtitle
184
233
  ? <div className="ui-modal__title"><span id={titleId}>{title}</span><span className="ui-modal__subtitle" id={subId}>{subtitle}</span></div>
185
234
  : <div className="ui-modal__title" id={titleId}>{title}</div>}
186
235
  {actions ? <div className="ui-modal__actions">{actions}</div> : null}
187
- <button type="button" className="ui-modal__close" aria-label={closeLabel} disabled={!dismissible} onClick={() => ref.current?.close()}>
236
+ <button type="button" className="ui-modal__close" aria-label={closeLabel} disabled={!dismissible} onClick={requestClose}>
188
237
  <Icon name="close" size={20} />
189
238
  </button>
190
239
  </div>
191
240
  <div className="ui-modal__body">{children}</div>
192
241
  {footer ? <div className="ui-modal__foot">{footer}</div> : null}
193
242
  </dialog>
243
+ {/* Beside it, not in it: the question's keys and presses are its own, and it opens over this popup in the top layer. */}
244
+ {dirty !== undefined ? (
245
+ <ConfirmDialog open={asked} title={words.title} action={words.action} cancelLabel={words.cancelLabel} closeLabel={words.closeLabel ?? closeLabel}
246
+ busy={false} error={null} onClose={() => setAsked(false)} onConfirm={() => { discarding.current = true; setAsked(false); }}>
247
+ {words.body}
248
+ </ConfirmDialog>
249
+ ) : null}
250
+ </>
194
251
  );
195
252
  }
@@ -12,6 +12,7 @@
12
12
  // blur): the caller decides what an empty edge means, and the admin has three answers to that on purpose.
13
13
  import "../editor.css"; // its own stylesheet travels with it (0.23.0): a surface that never renders it never loads it
14
14
  import "../editor-color.css"; // the swatch button (ColorControl); the picker's own rules are in it too
15
+ import "../editor-media.css"; // MediaCard's picture by its state (data-thumb)
15
16
  import { forwardRef, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
16
17
  import type React from "react";
17
18
  import { cssUrl } from "./css-url";
@@ -559,6 +560,8 @@ export interface ImageControlProps {
559
560
  nameOf?: (url: string) => string | undefined;
560
561
  /** The caller's size in bytes for an image URL, where it knows one (a library's record): read after its pixels, "· 188 KB". */
561
562
  bytesOf?: (url: string) => number | undefined;
563
+ /** What describes the URL box beside its name (a host's line under the field: a save that did not land). */
564
+ describedBy?: string;
562
565
  }
563
566
 
564
567
  /** A file's size in a seller's words, as the Mac's Finder says it (1 KB = 1,000 bytes): "512 bytes", "188 KB", "2.5 MB". A size
@@ -578,9 +581,15 @@ export function fileSizeWords(bytes: number): string {
578
581
  const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
579
582
 
580
583
  export interface MediaCardProps {
581
- /** The 56px picture: an address, drawn as its background; or `picture`, a node (a video's first frame). Neither draws "—". */
584
+ /** The 56px picture (Thumb): an address, drawn over a checkerboard (a white or see-through image shows its edges); or `picture`, a
585
+ * node (a video's first frame). Neither: empty, a dashed square with `glyph`'s icon; holding media with no picture, that icon on grey. */
582
586
  thumbUrl?: string | null;
583
587
  picture?: React.ReactNode;
588
+ /** What the picture is waiting on or could not do, said by its square too (not only by the line beside it): an upload running
589
+ * ("busy", a spinner), media that will not play or load ("broken"; an address of `thumbUrl` that fails is found by the square). */
590
+ thumbState?: "busy" | "broken";
591
+ /** The empty square's icon: an image's (default) or a video's. */
592
+ glyph?: "image" | "video";
584
593
  /** The media's name (its file, its title) and what it is ("640 × 400 · 188 KB", "File · 0:18"). `name` undefined: nothing is
585
594
  * set, and `empty` is said in their place (an empty name with media set still draws the row). */
586
595
  name?: React.ReactNode;
@@ -642,8 +651,41 @@ export interface MediaCardProps {
642
651
  * While the box is open the chips do not take the focus on press: the box's blur would close it, the row would move up under the
643
652
  * pointer, and the press be lost.
644
653
  */
654
+ /**
655
+ * THE 56px PICTURE OF AN IMAGE OR VIDEO FIELD (`.gemboss-ei-img-thumb`), the one owner of its states (§9.3) for the image card, the
656
+ * plain ImageControl and the video card; editor-plain.js writes the same. Chris 10/11/2026 on the UI/UX canvas: an empty field and a
657
+ * white image were both a white square ("ko biết là có ảnh hay background ảnh trắng"). `data-thumb` says which state, editor-media.css
658
+ * draws each: empty, a dashed square with the media's icon; an image, over a checkerboard (a white or see-through one shows its edges);
659
+ * busy, a spinner; held, media set with no picture of its own (a video's page link): the icon on grey; broken, the icon struck through.
660
+ * The icons are the stylesheet's (a mask on ::before, by data-thumb and data-glyph), so this markup and editor-plain.js's are the same.
661
+ * The address goes in --gemboss-thumb, which editor.css's own rule also reads (a page without editor-media.css still shows the image):
662
+ * an inline background-image would be the only layer. An address that does not load is broken whoever passed it (a site's thumbnail
663
+ * gone): the square finds out for itself.
664
+ */
665
+ function Thumb({ url, picture, state, held, glyph = "image" }: {
666
+ url?: string | null; picture?: React.ReactNode; state?: "busy" | "broken"; held?: boolean; glyph?: "image" | "video";
667
+ }) {
668
+ const [failed, setFailed] = useState<string | null>(null);
669
+ useEffect(() => {
670
+ if (!url || picture || typeof Image === "undefined") return undefined;
671
+ let live = true;
672
+ const img = new Image();
673
+ img.onerror = () => { if (live) setFailed(url); };
674
+ img.src = url;
675
+ return () => { live = false; img.onerror = null; img.src = ""; };
676
+ }, [url, picture]);
677
+ // Busy first: a video's frame is not what is being made.
678
+ const thumb = state === "busy" ? "busy" : picture ? "picture" : state ?? (url ? (failed === url ? "broken" : "image") : held ? "held" : "empty");
679
+ return (
680
+ <div className="gemboss-ei-img-thumb" data-thumb={thumb} data-glyph={glyph === "video" ? "video" : undefined} aria-hidden
681
+ style={url && (thumb === "image" || thumb === "busy") ? { "--gemboss-thumb": cssUrl(url) } as React.CSSProperties : undefined}>
682
+ {thumb === "picture" ? picture : thumb === "busy" ? <span className="gemboss-ei-img-spin" /> : null}
683
+ </div>
684
+ );
685
+ }
686
+
645
687
  export function MediaCard({
646
- thumbUrl, picture, name, title, meta, metaLive, empty, pasteLabel, boxId, boxLabel, placeholder, text, onText, open, onOpenChange, onKeep, onLeave,
688
+ thumbUrl, picture, thumbState, glyph = "image", name, title, meta, metaLive, empty, pasteLabel, boxId, boxLabel, placeholder, text, onText, open, onOpenChange, onKeep, onLeave,
647
689
  boxAutoFocus = true, boxDescribedBy, boxInvalid, before, after, more, whileEmpty, onRemove, menuLabel = "More actions", disabled, over, drop, children,
648
690
  }: MediaCardProps) {
649
691
  const pasteRef = useRef<HTMLButtonElement>(null);
@@ -663,9 +705,7 @@ export function MediaCard({
663
705
  const close = (refocus: boolean) => { onOpenChange(false); if (refocus) setBackToPaste(true); };
664
706
  return (
665
707
  <div className="gemboss-ei-img" data-over={over ? "" : undefined} {...drop}>
666
- <div className="gemboss-ei-img-thumb" style={thumbUrl ? { backgroundImage: cssUrl(thumbUrl) } : undefined} aria-hidden>
667
- {picture ?? (thumbUrl ? null : "—")}
668
- </div>
708
+ <Thumb url={thumbUrl} picture={picture} state={thumbState} held={holds} glyph={glyph} />
669
709
  <div className="gemboss-ei-img-ctl">
670
710
  {name !== undefined ? (
671
711
  <div className="gemboss-ei-img-info">
@@ -722,7 +762,7 @@ export function imageFileName(url: string): string {
722
762
  * (a second way in, not the first thing seen). Without `onFile`: the thumbnail, the URL box always, the chips (as before 0.55).
723
763
  * Remove empties it. `.gemboss-ei-img-thumb` and the URL box in `.gemboss-ei-img-ctl` stay where editor-plain.js finds them.
724
764
  */
725
- export function ImageControl({ id, value, onChange, disabled, placeholder, draft, onDraftChange, actions, more, whileEmpty, menuLabel = "More image actions", clearable = true, onFile, nameOf, bytesOf }: ImageControlProps) {
765
+ export function ImageControl({ id, value, onChange, disabled, placeholder, draft, onDraftChange, actions, more, whileEmpty, menuLabel = "More image actions", clearable = true, onFile, nameOf, bytesOf, describedBy }: ImageControlProps) {
726
766
  // Every choice (a value from outside, a URL kept, Remove) is counted: an upload that answers after another choice is dropped, not
727
767
  // put over it.
728
768
  const choice = useRef(0);
@@ -770,11 +810,12 @@ export function ImageControl({ id, value, onChange, disabled, placeholder, draft
770
810
  // a drop and an upload do, and its name and size.
771
811
  if (card) {
772
812
  return (
773
- <MediaCard thumbUrl={shown || null} name={shown ? nameOf?.(shown) || imageFileName(shown) : undefined} title={shown} metaLive
813
+ <MediaCard thumbUrl={shown || null} thumbState={busy ? "busy" : shown && size === "broken" ? "broken" : undefined}
814
+ name={shown ? nameOf?.(shown) || imageFileName(shown) : undefined} title={shown} metaLive
774
815
  meta={busy ? "Uploading…" : size === "broken" ? "Can't load this image"
775
816
  : [size ? `${size.w} × ${size.h}` : "", fileSizeWords(bytesOf?.(shown) ?? 0)].filter(Boolean).join(" · ")}
776
817
  empty={busy ? "Uploading…" : "Drop an image here"}
777
- pasteLabel="Paste a URL" boxId={id} boxLabel="Image URL" placeholder={placeholder ?? "Paste image URL…"}
818
+ pasteLabel="Paste a URL" boxId={id} boxLabel="Image URL" boxDescribedBy={describedBy} placeholder={placeholder ?? "Paste image URL…"}
778
819
  text={text} onText={setText} open={pasting} onOpenChange={(o) => { if (o) setError(""); setPasting(o); }}
779
820
  onKeep={() => { keep(); return true; }} onLeave={() => setText(value)}
780
821
  disabled={disabled} before={actions} more={more} whileEmpty={whileEmpty} menuLabel={menuLabel}
@@ -792,9 +833,9 @@ export function ImageControl({ id, value, onChange, disabled, placeholder, draft
792
833
  // Without `onFile`: the thumbnail, the URL box always, the chips (as before 0.55).
793
834
  return (
794
835
  <div className="gemboss-ei-img">
795
- <div className="gemboss-ei-img-thumb" style={value ? { backgroundImage: cssUrl(value) } : undefined} aria-hidden>{value ? null : "—"}</div>
836
+ <Thumb url={value} />
796
837
  <div className="gemboss-ei-img-ctl">
797
- <input id={id} className="gemboss-field gemboss-ei-inp" placeholder={placeholder ?? "Paste image URL…"} value={text} disabled={disabled}
838
+ <input id={id} className="gemboss-field gemboss-ei-inp" placeholder={placeholder ?? "Paste image URL…"} value={text} disabled={disabled} aria-describedby={describedBy}
798
839
  onChange={(e) => setText(e.target.value)} onBlur={keep} onKeyDown={blurOnEnter} />
799
840
  <div className="gemboss-ei-img-actions">
800
841
  {typeof actions === "function" ? actions(!!value) : actions}
@@ -12,8 +12,8 @@
12
12
  // `base()` (the kit's own control for that kind, for an app that draws a kit kind its way only sometimes). A kind no one draws is a visible
13
13
  // "no control" line, never a text box that seems to work. A choice's `glyph` is drawn as the app's picture by that name (`glyphs`).
14
14
  import "../editor.css"; // its own stylesheet travels with it: a surface that never renders a form never loads it
15
- import "../editor-grow.css"; // the line that grows (CodeLine), its own entry
16
- import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, type ChangeEvent, type FocusEventHandler, type KeyboardEvent, type ReactNode } from "react";
15
+ import "../editor-grow.css"; // the line that grows with its text (GrowLine), its own entry
16
+ import { createContext, useContext, useState, type ChangeEvent, type FocusEventHandler, type KeyboardEvent, type ReactNode } from "react";
17
17
  import { ColorChoicesContext } from "./color-choices";
18
18
  import { ChipButton, ColorControl, ImageControl, RangeControl, Seg, UnitField } from "./controls";
19
19
  import {
@@ -22,6 +22,7 @@ import {
22
22
  } from "./field-spec";
23
23
  import { labelSide, type FieldControlKind } from "./label-side";
24
24
  import { useOnNewValue } from "./new-value";
25
+ import { useGrowToText } from "./grow-to-text";
25
26
  import { Field, InspectorGroup } from "./panel";
26
27
  import { ItemsField } from "./items-field";
27
28
 
@@ -335,9 +336,11 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
335
336
  // The limits stay in sight under the box (not behind the ?): the commit clamps to them, and a 200 that turns into 90 needs its reason on
336
337
  // screen. The setting's own help is behind the ?.
337
338
  <Field label={label} htmlFor={id} hint={"hint" in field ? field.hint : undefined} control={controlOf(field)} onBlurCapture={onBlurCapture} mark={labelMark}>
338
- {field.kind === "text" && field.code ? (
339
- <CodeLine id={id} value={draft} placeholder={field.placeholder} maxLength={maxLength} disabled={disabled} describedBy={describedBy} ariaLabel={ariaLabel}
340
- invalid={invalid} onChange={typed} onCommit={commit} />
339
+ {(field.kind === "text" && field.code) || (field.kind === "textarea" && field.grow) ? (
340
+ // A line of code (text `code`) and a sentence a shopper reads (textarea `grow`) are ONE box (follow-up #46): a line that wraps and
341
+ // grows with its text, read whole; the code one in a monospace face, not spell-checked.
342
+ <GrowLine id={id} code={!!field.code} value={draft} placeholder={field.placeholder} maxLength={maxLength} disabled={disabled} describedBy={describedBy}
343
+ ariaLabel={ariaLabel} invalid={invalid} onChange={typed} onCommit={commit} />
341
344
  ) : field.kind === "textarea" ? (
342
345
  <textarea id={id} className={`gemboss-field gemboss-ei-inp${field.code ? " gemboss-mono" : ""}`} rows={field.rows ?? 2} placeholder={field.placeholder}
343
346
  value={draft} disabled={disabled} maxLength={maxLength} spellCheck={field.code ? false : undefined}
@@ -380,56 +383,28 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
380
383
  );
381
384
  }
382
385
 
383
- const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
384
- /** One line of text, as a CSS value is: a line break typed or pasted becomes a space ("1px\nsolid" is "1px solid", not "1pxsolid"). */
385
- const oneLine = (v: string) => v.replace(/\s*[\r\n]+\s*/g, " ");
386
-
387
- /** Whether the browser sizes the box to its text itself (`field-sizing: content`); where not (Safari, Firefox in 2026), growToText does. */
388
- const sizesItself = () => typeof CSS !== "undefined" && Boolean(CSS.supports?.("field-sizing", "content"));
389
- const growToText = (el: HTMLTextAreaElement) => { el.style.height = "auto"; el.style.height = `${el.scrollHeight + el.offsetHeight - el.clientHeight}px`; };
390
-
391
386
  /**
392
- * A line of code or a CSS value that runs long (FieldSpec text `code`: a condition's expression, a font stack, a border, a shadow), THE
393
- * kit's one `code` (the one-line monospace box #7088 drew for the element panel's "Show when" expression is this, 09/11/2026): one line of
394
- * text in a monospace box that wraps and
395
- * grows with it, across the field under its label (the `code` control), so it is read whole (§9.1). Global styles' Mono font was a 174px
396
- * one-line box beside its label at 330, 172px of its stack out of sight. A textarea, so it can wrap; one line still: Enter commits (it
397
- * leaves the box, as a text box's Enter does) and a line break becomes a space. Its height is its text's: `field-sizing: content`
398
- * (editor.css), and where a browser lacks it this sets it, again when the box's width changes (the line re-wraps).
387
+ * THE kit's one box that grows with its text (follow-up #46, 10/11/2026): one line of text in a textarea that wraps and grows with it,
388
+ * across the field under its label, so it is read whole (§9.1). Two FieldSpecs draw it:
389
+ * - text `code`: a line of code or a CSS value that runs long (a condition's expression, a font stack, a border, a shadow), monospace,
390
+ * not spell-checked, no capitals or corrections on a phone. Global styles' Mono font was a 174px one-line box beside its label at 330,
391
+ * 172px of its stack out of sight (#7080); the element panel's "Show when" box (#7088) is this one;
392
+ * - textarea `grow`: a sentence a shopper reads (a plugin's `message`: the cart drawer's "You're {amount} away from free shipping",
393
+ * which was cut in a one-line box, #7085).
394
+ * One line still: Enter commits (it leaves the box, as a text box's Enter does; not the Enter that ends an input method's composition)
395
+ * and a line break typed or pasted becomes a space, the caret kept. Its height: grow-to-text.ts (`field-sizing: content` in
396
+ * editor-grow.css, set by hand where a browser lacks it, again when its width changes).
399
397
  */
400
- function CodeLine({ id, value, placeholder, maxLength, disabled, describedBy, ariaLabel, invalid, onChange, onCommit }: {
401
- id: string; value: string; placeholder?: string; maxLength?: number; disabled?: boolean; describedBy?: string; ariaLabel?: string; invalid?: boolean;
402
- onChange: (v: string) => void; onCommit: () => void;
398
+ function GrowLine({ id, code, value, placeholder, maxLength, disabled, describedBy, ariaLabel, invalid, onChange, onCommit }: {
399
+ id: string; code: boolean; value: string; placeholder?: string; maxLength?: number; disabled?: boolean; describedBy?: string; ariaLabel?: string;
400
+ invalid?: boolean; onChange: (v: string) => void; onCommit: () => void;
403
401
  }) {
404
- const ref = useRef<HTMLTextAreaElement>(null);
405
- // The caret after a line break became a space: where it was in what was typed, not at the end (React writes the new value, which
406
- // puts the caret last).
407
- const caret = useRef<number | null>(null);
408
- // Without field-sizing: its height on each value, before paint...
409
- useIsoLayoutEffect(() => {
410
- const el = ref.current;
411
- if (el && caret.current !== null) { el.setSelectionRange(caret.current, caret.current); caret.current = null; }
412
- if (el && !sizesItself()) growToText(el);
413
- }, [value]);
414
- // ...and again when its width changes (the line re-wraps): one observer for the box's life, not one per key.
415
- useEffect(() => {
416
- const el = ref.current;
417
- if (!el || sizesItself() || typeof ResizeObserver === "undefined") return;
418
- let width = el.clientWidth;
419
- const watch = new ResizeObserver(() => { if (el.clientWidth !== width) { width = el.clientWidth; growToText(el); } });
420
- watch.observe(el);
421
- return () => watch.disconnect();
422
- }, []);
402
+ const grow = useGrowToText(value, true);
423
403
  return (
424
- <textarea ref={ref} id={id} className="gemboss-field gemboss-ei-inp gemboss-ei-mono gemboss-ei-code-line" rows={1} placeholder={placeholder} value={value}
425
- maxLength={maxLength} disabled={disabled} spellCheck={false} autoCapitalize="off" autoCorrect="off" aria-describedby={describedBy} aria-label={ariaLabel}
426
- aria-invalid={invalid || undefined} onBlur={onCommit}
427
- onChange={(e) => {
428
- const raw = e.target.value;
429
- if (/[\r\n]/.test(raw)) caret.current = oneLine(raw.slice(0, e.target.selectionStart ?? raw.length)).length;
430
- onChange(oneLine(raw));
431
- }}
432
- // Enter commits, but not the Enter that ends an input method's composition (Vietnamese, Chinese, Japanese typing).
404
+ <textarea ref={grow.ref} id={id} className={`gemboss-field gemboss-ei-inp gemboss-ei-grow${code ? " gemboss-ei-mono gemboss-ei-code-line" : ""}`} rows={1}
405
+ placeholder={placeholder} value={value} maxLength={maxLength} disabled={disabled} spellCheck={code ? false : undefined}
406
+ autoCapitalize={code ? "off" : undefined} autoCorrect={code ? "off" : undefined} aria-describedby={describedBy} aria-label={ariaLabel}
407
+ aria-invalid={invalid || undefined} onBlur={onCommit} onChange={(e) => onChange(grow.line(e.target.value, e.target.selectionStart))}
433
408
  onKeyDown={(e) => { if (e.key === "Enter" && !e.nativeEvent.isComposing && e.keyCode !== 229) { e.preventDefault(); e.currentTarget.blur(); } }} />
434
409
  );
435
410
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  // A SCHEMA FORM IN THE SETTINGS FRAME (one settings frame slice 1, 06/11/2026; Chris: three settings frames, "sao không chuẩn hoá"; moved from
3
3
  // the admin's components/shell/FieldFrame.tsx, 08/11/2026). The element panel's frame is the standard (InspectorFrame): a search, the index
4
- // Look · Layout · Visibility · Code, group titles, and a group that holds nothing as a + line, a chip in Look. A schema is drawn here, each
4
+ // Look · Layout · Visibility · Code, group titles, and a group that holds nothing as a + line (one line each, as Sticky and Motion). A schema is drawn here, each
5
5
  // field where the element panel puts the same setting (field-spec.ts frameGroups). The controls are FieldRows' and every field keeps its
6
6
  // stored key and its write: + shows a group and writes nothing, − writes each of its fields cleared (field-spec.ts knobClearWrites).
7
7
  //
@@ -11,7 +11,6 @@
11
11
  import "../editor.css"; // the frame's groups and the rows' fields are editor.css's
12
12
  import "../editor-inspector-frame.css"; // the frame (InspectorFrame brings it too); a search reads its open heads by their class
13
13
  import { useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent, type ReactNode } from "react";
14
- import { InspectorChips } from "./chips";
15
14
  import { FieldRows, useFieldKinds, type FieldGlyphs, type FieldKinds, type FieldRowsProps } from "./field-control";
16
15
  import {
17
16
  foundGroups, frameGroups, groupClearable, groupHolds, groupState, knobClearWrites, knobHolds, knobValue, settingMatches,
@@ -134,7 +133,7 @@ export function FieldFrame({ schema, lead, own = [], after = [], who = [], place
134
133
  if (cleared.length) onChangeMany(cleared);
135
134
  setShown((s) => { const next = new Set(s); next.delete(g.key); return next; });
136
135
  };
137
- const draw = (g: FrameGroup, chip = false) => {
136
+ const draw = (g: FrameGroup) => {
138
137
  if (found) {
139
138
  // Searching: a group the words find is open with the fields they find, every other one not drawn.
140
139
  const hit = found.get(g.key);
@@ -147,7 +146,7 @@ export function FieldFrame({ schema, lead, own = [], after = [], who = [], place
147
146
  // A − where it takes something off on this screen (never a text the seller wrote: groupClearable), or where + showed it with nothing.
148
147
  const removable = holdsHere ? groupClearable(g) : !inherits && shown.has(g.key);
149
148
  return (
150
- <InspectorFrameGroup key={g.key} groupKey={g.key} state={state} title={g.title} disabled={disabled} chip={chip && state === "add"} onAdd={add(g)}
149
+ <InspectorFrameGroup key={g.key} groupKey={g.key} state={state} title={g.title} disabled={disabled} onAdd={add(g)}
151
150
  note={inherits && inheritedFrom ? `from ${inheritedFrom}` : undefined}
152
151
  remove={removable ? { label: `Remove ${g.title.toLowerCase()}`, onRemove: remove(g) } : null}>
153
152
  {state === "add" ? null : rowsOf(g)}
@@ -160,10 +159,6 @@ export function FieldFrame({ schema, lead, own = [], after = [], who = [], place
160
159
  );
161
160
  const of = (c: FrameCluster) => groups.filter((g) => g.cluster === c);
162
161
  const look = of("look");
163
- // The look's shared groups are one run where a + line is a chip (InspectorChips, Control UI C32 slice 3).
164
- const firstShared = look.findIndex((g) => !g.own);
165
- const ownLook = firstShared < 0 ? look : look.slice(0, firstShared);
166
- const sharedLook = firstShared < 0 ? [] : look.slice(firstShared);
167
162
  const place = of("place");
168
163
  const when = of("when");
169
164
  const code = of("code");
@@ -172,8 +167,7 @@ export function FieldFrame({ schema, lead, own = [], after = [], who = [], place
172
167
  <InspectorFrame search={<InspectorSearch value={query} onChange={setQuery} name="section-setting-search" />} searching={!!q}
173
168
  lead={<>{lead}{nothing ? <p className="gemboss-ei-hint" data-find-none="">No setting matches “{q}”.</p> : null}</>}
174
169
  clusters={[
175
- { id: "look", label: labels?.look, on: own.length + look.length + after.length > 0, content: <>{own.map(part)}{ownLook.map((g) => draw(g))}
176
- {sharedLook.length ? <InspectorChips attrs={{ "data-look-chips": "" }}>{sharedLook.map((g) => draw(g, true))}</InspectorChips> : null}{after.map(part)}</> },
170
+ { id: "look", label: labels?.look, on: own.length + look.length + after.length > 0, content: <>{own.map(part)}{look.map((g) => draw(g))}{after.map(part)}</> },
177
171
  { id: "place", label: labels?.place, on: placeParts.length + place.length > 0, content: <>{placeParts.map(part)}{place.map((g) => draw(g))}</> },
178
172
  { id: "when", label: labels?.when, on: who.length + when.length > 0, content: <>{who.map(part)}{when.map((g) => draw(g))}</> },
179
173
  { id: "code", label: labels?.code, on: codeParts.length + code.length > 0, content: <>{codeParts.map(part)}{code.map((g) => draw(g))}</> },
@@ -48,8 +48,10 @@ export type FieldSpec<G extends string = string> =
48
48
  * (§9.1). Still one line of text: Enter commits, a line break typed or pasted becomes a space. Not with `prefix` or `inputType`,
49
49
  * which a line of code has no use for: with `code` they are not drawn. One `code`: #7088's one-line monospace box is this one. */
50
50
  code?: boolean }
51
- // `code`: a stylesheet or a script, in a monospace face, not spell-checked.
52
- | { kind: "textarea"; id: string; label?: string; rows?: number; placeholder?: string; hint?: string; maxLength?: number; code?: boolean }
51
+ // `code`: a stylesheet or a script, in a monospace face, not spell-checked. `grow`: a sentence or two (a message a shopper reads, a
52
+ // template with {tokens}): one line tall to start, as tall as its text after, so it is read whole (§9.1); `rows` does not apply. Still
53
+ // one line of text: Enter commits, a line break typed or pasted becomes a space.
54
+ | { kind: "textarea"; id: string; label?: string; rows?: number; placeholder?: string; hint?: string; maxLength?: number; code?: boolean; grow?: boolean }
53
55
  // `inputMode`: the phone's keypad, as a text box's: default `numeric` (digits alone, which on an iPhone has no point), `decimal` for a
54
56
  // number with a fraction (a width of 12.5 in, a box at 31.25 %). Any number box reads a comma typed for its point as one ("31,25" is
55
57
  // 31.25: the decimal keypad of a comma locale, vi or de, has no ".").
@@ -0,0 +1,51 @@
1
+ // A LINE OF TEXT AS TALL AS ITS TEXT (09/11/2026): a sentence a shopper reads (a plugin's `message`, FieldSpec textarea `grow`), drawn in
2
+ // a textarea so it wraps, read whole. Where the browser sizes a textarea to its text itself (`field-sizing: content`, the CSS of the box
3
+ // that asks for it), its height is left to it; where it does not (Safari, Firefox in 2026), the box's height is set to its text's on each
4
+ // value, and again when its width changes (the text re-wraps). Still one line of text: a line break typed or pasted becomes a space, the
5
+ // caret staying where it was. No React rendering here: a hook for the control that draws the box.
6
+ import { useEffect, useLayoutEffect, useRef } from "react";
7
+
8
+ const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
9
+
10
+ /** Whether the browser sizes the box to its text itself (`field-sizing: content`). */
11
+ export const sizesItself = (): boolean => typeof CSS !== "undefined" && Boolean(CSS.supports?.("field-sizing", "content"));
12
+
13
+ /** The box's height set to its text's (its scroll height and borders). */
14
+ export function growToText(el: HTMLTextAreaElement): void {
15
+ el.style.height = "auto";
16
+ el.style.height = `${el.scrollHeight + el.offsetHeight - el.clientHeight}px`;
17
+ }
18
+
19
+ /** One line of text: a line break (and the spaces around it) becomes one space ("1px\nsolid" is "1px solid", not "1pxsolid"). */
20
+ export const oneLine = (v: string): string => v.replace(/\s*[\r\n]+\s*/g, " ");
21
+
22
+ /**
23
+ * A textarea that grows with its text and holds one line of it (`on`): its `ref`, and `line(raw, caret)` for its change, which says the
24
+ * value without line breaks and keeps the caret where it was (React writing the new value puts it last). Where the browser does not size
25
+ * the box, its height is set on each `value` and when its width changes, watching the box that is drawn now (a box drawn anew is watched
26
+ * anew, not the one it replaced).
27
+ */
28
+ export function useGrowToText(value: string, on: boolean) {
29
+ const ref = useRef<HTMLTextAreaElement>(null);
30
+ const caret = useRef<number | null>(null);
31
+ const watching = useRef<{ el: HTMLTextAreaElement; watch: ResizeObserver } | null>(null);
32
+ useIsoLayoutEffect(() => {
33
+ const el = ref.current;
34
+ if (el && caret.current !== null) { el.setSelectionRange(caret.current, caret.current); caret.current = null; }
35
+ if (!on || !el || sizesItself()) return;
36
+ growToText(el);
37
+ if (typeof ResizeObserver === "undefined" || watching.current?.el === el) return;
38
+ watching.current?.watch.disconnect();
39
+ let width = el.clientWidth;
40
+ const watch = new ResizeObserver(() => { if (el.clientWidth !== width) { width = el.clientWidth; growToText(el); } });
41
+ watch.observe(el);
42
+ watching.current = { el, watch };
43
+ }, [value, on]);
44
+ useEffect(() => () => { watching.current?.watch.disconnect(); watching.current = null; }, []);
45
+ const line = (raw: string, at: number | null): string => {
46
+ if (!on || !/[\r\n]/.test(raw)) return raw;
47
+ caret.current = oneLine(raw.slice(0, at ?? raw.length)).length;
48
+ return oneLine(raw);
49
+ };
50
+ return { ref, line };
51
+ }
@@ -64,13 +64,11 @@ export { ChoiceTiles, tileShapeStyle, type ChoiceTile, type ChoiceTilesProps } f
64
64
  export { Switch, type SwitchProps } from "./switch";
65
65
  // One choice of a few, each a card with its words and a picture (Global styles' form set and style pack): real radios in one group.
66
66
  export { ChoiceCards, type ChoiceCard, type ChoiceCardsProps } from "./choice-cards";
67
- // 31/10/2026: a run of groups where one holding nothing is a chip (Control UI C32 slice 3); its own CSS part, editor-chips.css.
68
- export { InspectorChips, type InspectorChipsProps } from "./chips";
69
67
  // 06/11/2026: the settings FRAME every settings surface draws (one settings frame slice 1): search, the index of clusters, a cluster's
70
68
  // name, and the three group heads (open, a + line, added with a −). The element panel's, taken out of the admin; its own CSS part.
71
69
  export {
72
- INSPECTOR_CLUSTERS, InspectorClusterBreak, InspectorFrame, InspectorFrameGroup, InspectorFramePart, InspectorSearch,
73
- type InspectorFrameCluster, type InspectorFrameGroupProps, type InspectorFrameProps, type InspectorSearchProps,
70
+ INSPECTOR_CLUSTERS, InspectorClusterBreak, InspectorFrame, InspectorFrameGroup, InspectorFramePart, InspectorSearch, JUST_ADDED_MS,
71
+ addedScrollBy, keepAddedInView, type InspectorFrameCluster, type InspectorFrameGroupProps, type InspectorFrameProps, type InspectorSearchProps,
74
72
  } from "./inspector-frame";
75
73
  // 08/11/2026 (one control set): the schema-driven form, moved from the admin. A schema as data (`field-spec`, no React: the kit's kinds,
76
74
  // the fit of a row of chips, what a knob holds, where a field stands in the frame, a search's words), one control per kind (`field-control`: