@gemboss/ui 0.66.0 → 0.67.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.
@@ -75,9 +75,13 @@ export interface ConfirmDialogProps {
75
75
  children: ReactNode;
76
76
  /** 620 wide (Polaris' default Modal) instead of the kit's 460: a question that lists what goes (images, photos). */
77
77
  wide?: boolean;
78
+ /** The refused button's words (default "Try again") and the ✕'s name (default "Close"), for a surface in the viewer's language
79
+ * (GemCommunity: en / vi / zh; 09/11/2026). */
80
+ retryLabel?: string;
81
+ closeLabel?: string;
78
82
  }
79
83
 
80
- export function ConfirmDialog({ open, title, action, destructive = true, alternative, cancelLabel = "Cancel", busyCloseLabel, disabled = false, busy, error, canRetry = true, onConfirm, onClose, children, wide = false }: ConfirmDialogProps) {
84
+ export function ConfirmDialog({ open, title, action, destructive = true, alternative, cancelLabel = "Cancel", busyCloseLabel, disabled = false, busy, error, canRetry = true, onConfirm, onClose, children, wide = false, retryLabel, closeLabel }: ConfirmDialogProps) {
81
85
  const closable = !busy || Boolean(busyCloseLabel);
82
86
  // onClose is the person closing it. The kit's Dialog also reports the close that `open` turning false makes (the caller closing
83
87
  // it when the thing is done): not forwarded, so a caller hears one close, as with the Polaris Modal this replaced.
@@ -95,13 +99,13 @@ export function ConfirmDialog({ open, title, action, destructive = true, alterna
95
99
  if (open !== wasOpen) { setWasOpen(open); if (open) { setLast("main"); setShown(true); } }
96
100
  const closed = () => { setShown(false); close(); };
97
101
  const b = confirmButtons({ action, alternative: alternative?.content, cancelLabel, busyCloseLabel, disabled, alternativeDisabled: Boolean(alternative?.disabled),
98
- busy, error: error !== null, canRetry, last });
102
+ busy, error: error !== null, canRetry, last, retryLabel });
99
103
  const spinner = <span className="ui-spinner" aria-hidden="true" />;
100
104
  // An off button stays focusable (aria-disabled, never disabled: the kit's rule, Gems/CLAUDE.md §13), so the focus stays in the
101
105
  // question while the server answers, and its press does nothing.
102
106
  const off = (o: boolean) => (o ? { "aria-disabled": true as const } : {});
103
107
  return (
104
- <Dialog open={open} onClose={closed} title={title} dismissible={closable} wide={wide} className="ui-confirm" footer={(
108
+ <Dialog open={open} onClose={closed} title={title} dismissible={closable} wide={wide} className="ui-confirm" closeLabel={closeLabel} footer={(
105
109
  <>
106
110
  {alternative && b.alternative ? (
107
111
  <button type="button" className="ui-btn" {...off(b.alternative.disabled || b.alternative.loading)} aria-busy={b.alternative.loading || undefined}
@@ -0,0 +1 @@
1
+ .ui-copy-field{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}.ui-copy-field__value{flex:1 1 220px;min-width:0;background:var(--gemboss-divider-soft)}
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ // A VALUE TO TAKE AWAY (09/11/2026; Chris 08/11: one control set). A link to send traffic to, a review link, a code: the value in a box the
3
+ // seller can select but not change (focus selects it whole), and Copy beside it, which says Copied for two seconds, or "Copy it by hand"
4
+ // when the browser refuses the clipboard (the box is selected then, so ⌘C / Ctrl+C takes it). More actions on the same row come after
5
+ // Copy (`children`: an Open). The admin drew this by hand on several screens (Go live's link, a share-for-review link), each its own box.
6
+ import "./copy-field.css"; // its own stylesheet travels with it: a surface that never draws it never loads it
7
+ import React, { useEffect, useRef, useState } from "react";
8
+ import { copyText } from "./copy-text";
9
+
10
+ export interface CopyFieldProps {
11
+ value: string;
12
+ /** The box's accessible name ("Link for your traffic"). */
13
+ label: string;
14
+ /** The button's words. Default "Copy link". */
15
+ copyLabel?: string;
16
+ /** More actions on the row, after Copy (an Open). */
17
+ children?: React.ReactNode;
18
+ /** Told after a press: copied (true), or the browser refused (false). */
19
+ onCopied?: (ok: boolean) => void;
20
+ }
21
+
22
+ export function CopyField({ value, label, copyLabel = "Copy link", children, onCopied }: CopyFieldProps) {
23
+ const [said, setSaid] = useState<"idle" | "done" | "failed">("idle");
24
+ const box = useRef<HTMLInputElement>(null);
25
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
26
+ useEffect(() => () => { if (timer.current) clearTimeout(timer.current); }, []);
27
+ const say = (s: "done" | "failed") => {
28
+ setSaid(s);
29
+ if (timer.current) clearTimeout(timer.current);
30
+ timer.current = setTimeout(() => { timer.current = null; setSaid("idle"); }, 2000);
31
+ };
32
+ // The kit's one copy (copyText: the Clipboard API, else the old way). Refused both ways, the box takes the focus with its text selected,
33
+ // so ⌘C / Ctrl+C is the next key.
34
+ const copy = () => {
35
+ void copyText(value).then((ok) => {
36
+ if (!ok) box.current?.focus(); // its onFocus selects it whole
37
+ say(ok ? "done" : "failed");
38
+ onCopied?.(ok);
39
+ });
40
+ };
41
+ return (
42
+ <div className="ui-copy-field">
43
+ <input ref={box} className="gemboss-field ui-copy-field__value" value={value} readOnly aria-label={label} onFocus={(e) => e.currentTarget.select()} />
44
+ <button type="button" className="ui-btn" onClick={copy}>{said === "done" ? "Copied" : said === "failed" ? "Copy it by hand" : copyLabel}</button>
45
+ {children}
46
+ </div>
47
+ );
48
+ }
@@ -0,0 +1,20 @@
1
+ // Text onto the clipboard: the Clipboard API, else (an http:// page, a refused permission, an old Safari) a selected text area and
2
+ // execCommand. True when it got there. Its own module (09/11/2026, CopyField): the assistant's engine re-exports it.
3
+ /** Copies through the async clipboard, else through a selected textarea (an http:// page, an old Safari). */
4
+ export async function copyText(text: string): Promise<boolean> {
5
+ try {
6
+ if (navigator.clipboard?.writeText) { await navigator.clipboard.writeText(text); return true; }
7
+ } catch { /* permission refused: try the old way */ }
8
+ try {
9
+ const ta = document.createElement("textarea");
10
+ ta.value = text;
11
+ ta.setAttribute("readonly", "");
12
+ ta.style.position = "fixed";
13
+ ta.style.opacity = "0";
14
+ document.body.appendChild(ta);
15
+ ta.select();
16
+ const ok = document.execCommand("copy");
17
+ ta.remove();
18
+ return ok;
19
+ } catch { return false; }
20
+ }
@@ -1 +1 @@
1
- .ui-create-icon{display:grid;place-items:center;width:100%;height:100%;min-width:30px;min-height:30px;border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-create-steps{display:flex;align-items:center;gap:8px;margin:0;padding:0;list-style:none;font-size:var(--gemboss-fs-caption, 12px);color:var(--ui-text-muted)}.ui-create-step{display:flex;align-items:center;gap:6px;white-space:nowrap}.ui-create-step+.ui-create-step:before{content:"";width:24px;height:1px;margin-right:2px;background:var(--ui-border)}.ui-create-step__n{display:grid;place-items:center;width:20px;height:20px;box-sizing:border-box;border:1px solid var(--ui-border);border-radius:999px;font-size:var(--gemboss-fs-micro, 11px)}.ui-create-step--on{font-weight:600;color:var(--ui-text)}.ui-create-step--on .ui-create-step__n{border-color:var(--ui-text);background:var(--ui-text);color:var(--gemboss-surface, #fff)}.ui-create-step--done .ui-create-step__n{border-color:transparent;background:var(--gemboss-success-soft, #e6f4ee);color:var(--gemboss-success, #007f5f)}.ui-create-rail{display:flex;flex-direction:column;gap:20px;min-height:100%;box-sizing:border-box;padding:20px;background:var(--ui-surface)}.ui-create-rail__foot{margin:auto 0 0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text-muted)}.ui-create-group{display:flex;flex-direction:column;gap:8px}.ui-create-label{font-size:var(--gemboss-fs-micro, 11px);font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--ui-text-muted)}.ui-create-door{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 12px;text-align:left;cursor:pointer;border:1px solid var(--ui-border);border-radius:var(--gemboss-radius-lg, 12px);background:var(--gemboss-surface, #fff);color:var(--ui-text);font:inherit}.ui-create-door:hover{border-color:var(--ui-text-muted)}.ui-create-door--on{border-color:var(--ui-text);box-shadow:inset 0 0 0 1px var(--ui-text)}.ui-create-door:disabled{opacity:.5;cursor:default}.ui-create-door__art{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-create-door__col{display:flex;flex-direction:column;gap:2px;min-width:0}.ui-create-door__col b{font-size:var(--gemboss-fs-body, 14px);font-weight:600}.ui-create-door__col span{font-size:var(--gemboss-fs-caption, 12px);line-height:1.4;color:var(--ui-text-muted)}.ui-create-chips{display:flex;flex-wrap:wrap;gap:6px}.ui-create-chip{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 12px;cursor:pointer;border:1px solid var(--ui-border);border-radius:999px;background:var(--gemboss-surface, #fff);color:var(--ui-text);font:inherit;font-size:var(--gemboss-fs-caption, 12px)}.ui-create-chip--on{border-color:var(--ui-text);background:var(--ui-text);color:var(--gemboss-surface, #fff);font-weight:600}.ui-create-chip__n{opacity:.6}.ui-create-dot{flex:none;width:8px;height:8px;border-radius:999px;background:#a4a6ad}.ui-create-dot--cold{background:#5661f5}.ui-create-dot--warm{background:#c27c0e}.ui-create-dot--ready{background:#d9480f}.ui-create-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(240px,100%),1fr));gap:16px}.ui-create-grid--wide{grid-template-columns:repeat(auto-fill,minmax(min(400px,100%),1fr));gap:20px}.ui-create-card{display:flex;flex-direction:column;min-width:0;overflow:hidden;border:1px solid var(--ui-border);border-radius:var(--gemboss-radius-xl, 16px);background:var(--gemboss-surface, #fff)}.ui-create-card--on{border-color:var(--ui-text);box-shadow:inset 0 0 0 1px var(--ui-text)}.ui-create-card--dashed{border-style:dashed}.ui-create-card__pic{position:relative;height:150px}.ui-create-card__pic>.ui-stage{height:100%;box-sizing:border-box;border-radius:0}.ui-create-card__pic--wide{height:auto;aspect-ratio:16 / 9;overflow:hidden;border-bottom:1px solid var(--ui-border);background:var(--gemboss-surface, #fff)}.ui-create-card__badge{position:absolute;top:8px;left:8px;z-index:1;padding:2px 8px;border-radius:999px;background:var(--gemboss-surface, #fff);color:var(--ui-text);font-size:var(--gemboss-fs-micro, 11px);font-weight:600}.ui-create-card__body{display:flex;flex:1 1 auto;flex-direction:column;gap:6px;padding:12px 16px 16px}.ui-create-card__eyebrow{display:flex;align-items:center;gap:6px;font-size:var(--gemboss-fs-micro, 11px);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--ui-text-muted)}.ui-create-card__eyebrow--cold{color:#5661f5}.ui-create-card__eyebrow--warm{color:#a86a0a}.ui-create-card__eyebrow--ready{color:#c2410c}.ui-create-card__title{margin:0;font-size:var(--gemboss-fs-body-lg, 16px);font-weight:600;color:var(--ui-text)}.ui-create-card__line{margin:0;font-size:var(--gemboss-fs-body, 14px);line-height:1.45;color:var(--ui-text-muted)}.ui-create-card__inside{margin:0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text)}.ui-create-card__note{margin:0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text-muted)}.ui-create-card__act{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto;padding-top:8px}.ui-stage.ui-create-pic{justify-content:center;gap:6px;padding:16px 20%}.ui-create-pic .ui-stage__tile{padding:6px 12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ui-create-pic__more{align-self:center;color:var(--ui-stage-ink-dim)}.ui-create-pic--path{display:flex;align-items:center;justify-content:center;height:100%;box-sizing:border-box;padding:16px;background:radial-gradient(rgba(86,97,245,.13) 1px,transparent 1.5px) 0 0 / 16px 16px,linear-gradient(180deg,var(--gemboss-accent-wash, #f7f8ff),#f2f3fe);border-bottom:1px solid var(--gemboss-accent-tint, #dfe2ff);color:var(--ui-text);font-size:var(--gemboss-fs-caption, 12px)}.ui-create-path{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px}.ui-create-path__step{display:flex;align-items:center;gap:6px}.ui-create-path__arrow{color:#8b93ff}.ui-create-path__tile{display:flex;flex-direction:column;align-items:center;gap:4px;max-width:76px;padding:6px;text-align:center;border:1px solid var(--gemboss-accent-tint, #dfe2ff);border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-surface, #fff);box-shadow:0 1px 2px #1b1c1e0f;font-size:var(--gemboss-fs-micro, 11px);line-height:1.2}.ui-create-path__tile img{width:40px;height:40px;object-fit:cover;border-radius:var(--gemboss-radius-sm, 6px);background:#f2f3fe}@media (max-width: 47.9975em){.ui-create-step:not(.ui-create-step--on){display:none}.ui-create-step+.ui-create-step:before{display:none}}@media (pointer: coarse){.ui-create-chip{min-height:44px}}
1
+ .ui-create-icon{display:grid;place-items:center;width:100%;height:100%;min-width:30px;min-height:30px;border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-create-steps{display:flex;align-items:center;gap:8px;margin:0;padding:0;list-style:none;font-size:var(--gemboss-fs-caption, 12px);color:var(--ui-text-muted)}.ui-create-step{display:flex;align-items:center;gap:6px;white-space:nowrap}.ui-create-step+.ui-create-step:before{content:"";width:24px;height:1px;margin-right:2px;background:var(--ui-border)}.ui-create-step__n{display:grid;place-items:center;width:20px;height:20px;box-sizing:border-box;border:1px solid var(--ui-border);border-radius:999px;font-size:var(--gemboss-fs-micro, 11px)}.ui-create-step--on{font-weight:600;color:var(--ui-text)}.ui-create-step--on .ui-create-step__n{border-color:var(--ui-text);background:var(--ui-text);color:var(--gemboss-surface, #fff)}.ui-create-step--done .ui-create-step__n{border-color:transparent;background:var(--gemboss-success-soft, #e6f4ee);color:var(--gemboss-success, #007f5f)}.ui-create-rail{display:flex;flex-direction:column;gap:20px;min-height:100%;box-sizing:border-box;padding:20px;background:var(--ui-surface)}.ui-create-rail__foot{margin:auto 0 0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text-muted)}.ui-create-group{display:flex;flex-direction:column;gap:8px}.ui-create-label{font-size:var(--gemboss-fs-micro, 11px);font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--ui-text-muted)}.ui-create-door{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 12px;text-align:left;cursor:pointer;border:1px solid var(--ui-border);border-radius:var(--gemboss-radius-lg, 12px);background:var(--gemboss-surface, #fff);color:var(--ui-text);font:inherit}.ui-create-door:hover{border-color:var(--ui-text-muted)}.ui-create-door--on{border-color:var(--ui-text);box-shadow:inset 0 0 0 1px var(--ui-text)}.ui-create-door:disabled{opacity:.5;cursor:default}.ui-create-door__art{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-accent-soft, #eef0fe);color:var(--gemboss-accent, #5661f5)}.ui-create-door__col{display:flex;flex-direction:column;gap:2px;min-width:0}.ui-create-door__col b{font-size:var(--gemboss-fs-body, 14px);font-weight:600}.ui-create-door__col span{font-size:var(--gemboss-fs-caption, 12px);line-height:1.4;color:var(--ui-text-muted)}.ui-create-chips{display:flex;flex-wrap:wrap;gap:6px}.ui-create-chip{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 12px;cursor:pointer;border:1px solid var(--ui-border);border-radius:999px;background:var(--gemboss-surface, #fff);color:var(--ui-text);font:inherit;font-size:var(--gemboss-fs-caption, 12px)}.ui-create-chip--on{border-color:var(--ui-text);background:var(--ui-text);color:var(--gemboss-surface, #fff);font-weight:600}.ui-create-chip__n{opacity:.6}.ui-create-dot{flex:none;width:8px;height:8px;border-radius:999px;background:#a4a6ad}.ui-create-dot--cold{background:#5661f5}.ui-create-dot--warm{background:#c27c0e}.ui-create-dot--ready{background:#d9480f}.ui-create-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(240px,100%),1fr));gap:16px}.ui-create-grid--wide{grid-template-columns:repeat(auto-fill,minmax(min(340px,100%),1fr));gap:20px}.ui-create-card{display:flex;flex-direction:column;min-width:0;overflow:hidden;border:1px solid var(--ui-border);border-radius:var(--gemboss-radius-xl, 16px);background:var(--gemboss-surface, #fff)}.ui-create-card--on{border-color:var(--ui-text);box-shadow:inset 0 0 0 1px var(--ui-text)}.ui-create-card--dashed{border-style:dashed}.ui-create-card__pic{position:relative;height:150px}.ui-create-card__pic>.ui-stage{height:100%;box-sizing:border-box;border-radius:0}.ui-create-card__pic--wide{height:auto;aspect-ratio:16 / 9;overflow:hidden;border-bottom:1px solid var(--ui-border);background:var(--gemboss-surface, #fff)}.ui-create-card__badge{position:absolute;top:8px;left:8px;z-index:1;padding:2px 8px;border-radius:999px;background:var(--gemboss-surface, #fff);color:var(--ui-text);font-size:var(--gemboss-fs-micro, 11px);font-weight:600}.ui-create-card__body{display:flex;flex:1 1 auto;flex-direction:column;gap:6px;padding:12px 16px 16px}.ui-create-card__eyebrow{display:flex;align-items:center;gap:6px;font-size:var(--gemboss-fs-micro, 11px);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--ui-text-muted)}.ui-create-card__eyebrow--cold{color:#5661f5}.ui-create-card__eyebrow--warm{color:#a86a0a}.ui-create-card__eyebrow--ready{color:#c2410c}.ui-create-card__title{margin:0;font-size:var(--gemboss-fs-body-lg, 16px);font-weight:600;color:var(--ui-text)}.ui-create-card__line{margin:0;font-size:var(--gemboss-fs-body, 14px);line-height:1.45;color:var(--ui-text-muted)}.ui-create-card__inside{margin:0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text)}.ui-create-card__note{margin:0;font-size:var(--gemboss-fs-caption, 12px);line-height:1.5;color:var(--ui-text-muted)}.ui-create-card__act{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto;padding-top:8px}.ui-stage.ui-create-pic{justify-content:center;gap:6px;padding:16px 20%}.ui-create-pic .ui-stage__tile{padding:6px 12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ui-create-pic__more{align-self:center;color:var(--ui-stage-ink-dim)}.ui-create-pic--path{display:flex;align-items:center;justify-content:center;height:100%;box-sizing:border-box;padding:16px;background:radial-gradient(rgba(86,97,245,.13) 1px,transparent 1.5px) 0 0 / 16px 16px,linear-gradient(180deg,var(--gemboss-accent-wash, #f7f8ff),#f2f3fe);border-bottom:1px solid var(--gemboss-accent-tint, #dfe2ff);color:var(--ui-text);font-size:var(--gemboss-fs-caption, 12px)}.ui-create-path{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px}.ui-create-path__step{display:flex;align-items:center;gap:6px}.ui-create-path__arrow{color:#8b93ff}.ui-create-path__tile{display:flex;flex-direction:column;align-items:center;gap:4px;max-width:76px;padding:6px;text-align:center;border:1px solid var(--gemboss-accent-tint, #dfe2ff);border-radius:var(--gemboss-radius-md, 8px);background:var(--gemboss-surface, #fff);box-shadow:0 1px 2px #1b1c1e0f;font-size:var(--gemboss-fs-micro, 11px);line-height:1.2}.ui-create-path__tile img{width:40px;height:40px;object-fit:cover;border-radius:var(--gemboss-radius-sm, 6px);background:#f2f3fe}@media (max-width: 47.9975em){.ui-create-step:not(.ui-create-step--on){display:none}.ui-create-step+.ui-create-step:before{display:none}}@media (pointer: coarse){.ui-create-chip{min-height:44px}}
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ // CHOICE CARDS (09/11/2026, one control set: Chris 08/11 "các control phải có bộ control và kiểu có sự tái sử dụng dùng chung shared
3
+ // component… đừng mỗi cho mỗi kiểu"). One choice of a few where each needs its words and a picture to be told apart BEFORE it is picked:
4
+ // Global styles' form set (a sample field drawn from each set's values, what it suits) and its style pack (four swatches, its fonts and
5
+ // buttons). A list or chips would show the names only; choice tiles (tiles.tsx) a picture and a name. The admin drew both by hand, each
6
+ // with its own radio card.
7
+ //
8
+ // · `.gemboss-ei-choices[role=radiogroup]` › one `label.gemboss-ei-choice` per option (the whole card is the radio's label, so it is
9
+ // one target, at least 44px tall at every width) › `input[type=radio].gemboss-ei-choice-input` · the words (`-name`, `-line`s) ·
10
+ // the picture (`-pic`), before the words or after them (`pictureAt`);
11
+ // · real radios in one group (`name`): Tab enters at the one picked, the arrow keys move the pick and Space picks, as the browser's own
12
+ // radios do; a pick calls `onChange` (a host that applies on a button of its own keeps the pick until then);
13
+ // · the caller owns the value: a value no card has (a set of the theme's own) checks none.
14
+ // Its look is editor.css's (the harnesses that draw a settings panel already load it).
15
+ import "../editor.css";
16
+ import { forwardRef, type CSSProperties, type ReactNode } from "react";
17
+
18
+ export interface ChoiceCard {
19
+ value: string;
20
+ /** Its name: the card's first line, in bold. */
21
+ label: ReactNode;
22
+ /** Lines under the name, muted (what it suits, its fonts and buttons). */
23
+ lines?: readonly ReactNode[];
24
+ /** Its picture (a sample, swatches): drawn at the group's `pictureAt`. Decorative: the words name the choice. */
25
+ picture?: ReactNode;
26
+ /** Shown but not choosable (Erase my data for a member who is not the store's Owner): its radio off, the card faded. Its `lines` say
27
+ * why. */
28
+ disabled?: boolean;
29
+ }
30
+
31
+ export interface ChoiceCardsProps {
32
+ /** The radios' name, one group on the page. */
33
+ name: string;
34
+ /** The group's accessible name (the setting's). */
35
+ label: string;
36
+ options: readonly ChoiceCard[];
37
+ /** The card that is checked; null or a value no card has: none. */
38
+ value: string | null;
39
+ onChange: (value: string) => void;
40
+ disabled?: boolean;
41
+ /** Where each card's picture goes: before its words (`start`, default) or after them (`end`). */
42
+ pictureAt?: "start" | "end";
43
+ /** The group's id (a button that shows it points at it: `aria-controls`). */
44
+ id?: string;
45
+ /** On the group: a host's layout (a long list held to a height that scrolls). Never a look. */
46
+ style?: CSSProperties;
47
+ }
48
+
49
+ export const ChoiceCards = forwardRef<HTMLDivElement, ChoiceCardsProps>(function ChoiceCards({ name, label, options, value, onChange, disabled, pictureAt = "start", id, style }, ref) {
50
+ return (
51
+ <div ref={ref} id={id} className="gemboss-ei-choices" role="radiogroup" aria-label={label} style={style}>
52
+ {options.map((o) => {
53
+ const checked = value === o.value;
54
+ const off = disabled || o.disabled;
55
+ const pic = o.picture != null ? <span className="gemboss-ei-choice-pic" aria-hidden="true">{o.picture}</span> : null;
56
+ return (
57
+ <label key={o.value} className="gemboss-ei-choice" data-checked={checked ? "" : undefined} data-disabled={off ? "" : undefined}>
58
+ <input type="radio" className="gemboss-ei-choice-input" name={name} value={o.value} checked={checked} disabled={off}
59
+ onChange={() => onChange(o.value)} />
60
+ {pictureAt === "start" ? pic : null}
61
+ <span className="gemboss-ei-choice-words">
62
+ <span className="gemboss-ei-choice-name">{o.label}</span>
63
+ {(o.lines ?? []).map((line, i) => <span key={i} className="gemboss-ei-choice-line">{line}</span>)}
64
+ </span>
65
+ {pictureAt === "end" ? pic : null}
66
+ </label>
67
+ );
68
+ })}
69
+ </div>
70
+ );
71
+ });
@@ -48,6 +48,8 @@ export interface SegProps<T extends string = string> {
48
48
  style?: React.CSSProperties;
49
49
  /** Options per row: more wrap into rows (Segmented's `wrap`). ValueControl sets it past six chips. */
50
50
  wrap?: number;
51
+ /** A line that describes the group (its reason, what the setting does), on the group (`aria-describedby`). */
52
+ describedBy?: string;
51
53
  }
52
54
 
53
55
  /**
@@ -55,9 +57,9 @@ export interface SegProps<T extends string = string> {
55
57
  * other switch in the editors (0.20.0; it was a grey track with a raised white tab of its own). `gemboss-ei-seg` stays on
56
58
  * the group as the hook editor-plain.js finds, and each button carries its `data-value`.
57
59
  */
58
- export function Seg<T extends string = string>({ options, value, onChange, disabled, label, style, wrap }: SegProps<T>) {
60
+ export function Seg<T extends string = string>({ options, value, onChange, disabled, label, style, wrap, describedBy }: SegProps<T>) {
59
61
  return (
60
- <Segmented<T> fill wrap={wrap} className="gemboss-ei-seg" style={style} ariaLabel={label ?? ""} value={(value ?? "") as T | ""} onChange={onChange} disabled={disabled}
62
+ <Segmented<T> fill wrap={wrap} className="gemboss-ei-seg" style={style} ariaLabel={label ?? ""} describedBy={describedBy} value={(value ?? "") as T | ""} onChange={onChange} disabled={disabled}
61
63
  options={options.map((o) => ({ value: o.value, label: o.label ?? o.value, ...(o.name ? { ariaLabel: o.name, title: o.name } : {}) }))} />
62
64
  );
63
65
  }
@@ -195,6 +197,9 @@ export const PickButton = forwardRef<HTMLButtonElement, PickButtonProps>(functio
195
197
  export interface CheckboxProps {
196
198
  /** Its own words, beside the box: the box and its words are one control (a label wraps both), so it has no label side. */
197
199
  label: React.ReactNode;
200
+ /** Its words read only, where its row or tile already says what it is (a tick on a print file's tile): the box alone, in the middle of a
201
+ * 44px square target. */
202
+ labelHidden?: boolean;
198
203
  checked: boolean;
199
204
  onChange: (checked: boolean) => void;
200
205
  disabled?: boolean;
@@ -213,12 +218,12 @@ export interface CheckboxProps {
213
218
  * the same wherever it is drawn; `.gemboss-ei-check` carries them in editor.css for a host without kit-plain.css. Not a setting's On / Off:
214
219
  * a setting is FieldControl's `toggle`; this is a consent or a pick in a list.
215
220
  */
216
- export function Checkbox({ label, checked, onChange, disabled, id, describedBy, why }: CheckboxProps) {
221
+ export function Checkbox({ label, labelHidden = false, checked, onChange, disabled, id, describedBy, why }: CheckboxProps) {
217
222
  return (
218
- <label className="ui-check gemboss-ei-check" data-disabled={disabled ? "" : undefined} title={disabled && why ? why : undefined}>
223
+ <label className={labelHidden ? "ui-check gemboss-ei-check gemboss-ei-check--bare" : "ui-check gemboss-ei-check"} data-disabled={disabled ? "" : undefined} title={disabled && why ? why : undefined}>
219
224
  <input type="checkbox" className="gemboss-ei-checkbox" id={id} checked={checked} disabled={disabled} aria-describedby={describedBy}
220
225
  onChange={(e) => onChange(e.target.checked)} />
221
- <span className="gemboss-ei-check-words">{label}</span>
226
+ <span className={labelHidden ? "gemboss-ei-check-words ui-sr-only" : "gemboss-ei-check-words"}>{label}</span>
222
227
  </label>
223
228
  );
224
229
  }
@@ -12,7 +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 { createContext, useContext, useState, type ChangeEvent, type CSSProperties, type FocusEventHandler, type KeyboardEvent, type ReactNode } from "react";
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";
16
17
  import { ColorChoicesContext } from "./color-choices";
17
18
  import { ChipButton, ColorControl, ImageControl, RangeControl, Seg, UnitField } from "./controls";
18
19
  import {
@@ -22,6 +23,7 @@ import {
22
23
  import { labelSide, type FieldControlKind } from "./label-side";
23
24
  import { useOnNewValue } from "./new-value";
24
25
  import { Field, InspectorGroup } from "./panel";
26
+ import { ItemsField } from "./items-field";
25
27
 
26
28
  // ── An app's kinds ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
27
29
 
@@ -81,7 +83,7 @@ export function controlOf(field: AnyFieldSpec, value?: unknown, rules?: FieldKin
81
83
  case "color": return "color";
82
84
  case "range": return "range";
83
85
  case "number": return "number";
84
- case "text": return "text";
86
+ case "text": return f.code ? "code" : "text";
85
87
  case "textarea": return "textarea";
86
88
  case "image": return "image";
87
89
  case "repeater": return "list";
@@ -125,6 +127,12 @@ export type FieldControlProps = {
125
127
  onDraft?: (v: unknown) => void;
126
128
  /** A host's refusal before a numeric control normalizes its raw draft on blur; no wrapper is added. */
127
129
  onBlurCapture?: FocusEventHandler<HTMLDivElement>;
130
+ /** A line in sight under the control, across the field (not behind the ?, which is the setting's help): what a switch does, why a
131
+ * list has nothing to offer. The control is described by it (its id `<control id>-note`). Honoured by select and toggle. */
132
+ note?: ReactNode;
133
+ /** The id of a `<datalist>` the host draws once for many boxes (a menu's addresses: its store pages and collections), offered as the
134
+ * box is typed in. Honoured by text. */
135
+ listId?: string;
128
136
  /** The app's kinds (FieldKindsProvider by default). */
129
137
  kinds?: FieldKinds;
130
138
  /** The app's glyphs (FieldKindsProvider by default). */
@@ -155,9 +163,13 @@ export function FieldControl(props: FieldControlProps) {
155
163
  }
156
164
 
157
165
  function kitControl(p: Drawn): ReactNode {
158
- const { value, onChange, disabled, onPickImage, onDraft, onBlurCapture, inputId, mark, labelMark, describedBy, shopId, colorDrafts = false, labelHidden = false, invalid = false, kinds, glyphs, id, lbl, named, ariaLabel } = p;
166
+ const { value, onChange, disabled, onPickImage, onDraft, onBlurCapture, inputId, mark, labelMark, shopId, listId, note, colorDrafts = false, labelHidden = false, invalid = false, kinds, glyphs, id, lbl, named, ariaLabel } = p;
159
167
  if (!isKitFieldKind(p.field.kind)) return <UnknownKind field={p.field} named={named} />;
160
168
  const field = p.field as FieldSpec;
169
+ // A note under a select or a switch: in the field (a row's note spans it, editor.css), and what the control is described by.
170
+ const noteId = note != null && (field.kind === "select" || field.kind === "toggle") ? `${id}-note` : undefined;
171
+ const describedBy = [p.describedBy, noteId].filter(Boolean).join(" ") || undefined;
172
+ const noteLine = noteId ? <p className="gemboss-ei-hint" id={noteId}>{note}</p> : null;
161
173
  switch (field.kind) {
162
174
  case "toggle": {
163
175
  const on = value === true || value === "true";
@@ -165,8 +177,9 @@ function kitControl(p: Drawn): ReactNode {
165
177
  // The seam's `info` for a checkbox is `hint`. It fills the control column like every segmented row (control standard §13b: one
166
178
  // width rule).
167
179
  <Field label={named} className="togrow" hint={field.hint} control="toggle" mark={labelMark}>
168
- <Seg<"on" | "off"> label={lbl} value={on ? "on" : "off"} disabled={disabled} onChange={(v) => onChange(v === "on")}
180
+ <Seg<"on" | "off"> label={lbl} value={on ? "on" : "off"} disabled={disabled} describedBy={describedBy} onChange={(v) => onChange(v === "on")}
169
181
  options={[{ value: "on", label: field.onLabel ?? "On" }, { value: "off", label: field.offLabel ?? "Off" }]} />
182
+ {noteLine}
170
183
  </Field>
171
184
  );
172
185
  }
@@ -183,8 +196,12 @@ function kitControl(p: Drawn): ReactNode {
183
196
  {/* Nothing stored: said, not the first option shown as if chosen. Picking an option then writes it. A clearable list keeps it
184
197
  as a choice. */}
185
198
  {(cur === "" || field.clearable) && !field.options.some((o) => o.value === "") ? <option value="" disabled={!field.clearable}>Not set</option> : null}
186
- {field.options.map((o) => <option key={o.value} value={o.value}>{o.label ?? labelize(o.value)}</option>)}
199
+ {optionRuns(field.options).map((run) => {
200
+ const opts = run.options.map((o) => <option key={o.value} value={o.value} disabled={o.disabled || undefined}>{o.label ?? labelize(o.value)}</option>);
201
+ return run.group === undefined ? opts : <optgroup key={`${run.group}-${run.options[0]!.value}`} label={run.group}>{opts}</optgroup>;
202
+ })}
187
203
  </select>
204
+ {noteLine}
188
205
  </Field>
189
206
  );
190
207
  }
@@ -209,7 +226,7 @@ function kitControl(p: Drawn): ReactNode {
209
226
  return (
210
227
  // Here the chips fit the row's control column (3/5 of the field, chipsFitBeside): more, or longer labels, are a list.
211
228
  <Field label={named} hint={field.hint} control="chips" mark={labelMark}>
212
- <Seg label={lbl} value={shown} disabled={disabled} onChange={(v) => { if (v !== shown) onChange(v); else if (field.clearable) onChange(""); }}
229
+ <Seg label={lbl} value={shown} disabled={disabled} describedBy={describedBy} onChange={(v) => { if (v !== shown) onChange(v); else if (field.clearable) onChange(""); }}
213
230
  options={field.options.map((o, i) => (o.glyph
214
231
  ? { value: o.value, label: pictures[i] ?? o.label ?? labelize(o.value), name: o.label ?? labelize(o.value) }
215
232
  : { value: o.value, label: o.label ?? labelize(o.value), ...(o.name ? { name: o.name } : {}) }))} />
@@ -226,17 +243,31 @@ function kitControl(p: Drawn): ReactNode {
226
243
  case "range":
227
244
  return <RangeField id={id} label={lbl} field={field} value={value} disabled={disabled} onCommit={onChange} onBlurCapture={onBlurCapture} labelMark={labelMark} />;
228
245
  case "repeater":
229
- return <RepeaterField label={lbl} field={field} value={Array.isArray(value) ? (value as Array<Record<string, unknown>>) : []} disabled={disabled} onChange={onChange} />;
246
+ // The kit's Items control (items-field.tsx): one write of the whole list per change, each row's other keys kept.
247
+ return <ItemsField label={lbl} field={field} value={value} disabled={disabled} onChange={(next) => onChange(next)} idPrefix={id}
248
+ shopId={shopId} onPickImage={onPickImage} kinds={kinds} glyphs={glyphs} />;
230
249
  case "textarea":
231
250
  case "number":
232
251
  case "text":
233
- return <TextField id={id} label={named} field={field} value={value} disabled={disabled} onCommit={onChange} onDraft={onDraft} onBlurCapture={onBlurCapture} describedBy={describedBy} labelMark={labelMark} ariaLabel={ariaLabel} invalid={invalid} />;
252
+ return <TextField id={id} label={named} field={field} value={value} disabled={disabled} onCommit={onChange} onDraft={onDraft} onBlurCapture={onBlurCapture} describedBy={describedBy} labelMark={labelMark} ariaLabel={ariaLabel} invalid={invalid} listId={field.kind === "text" ? listId : undefined} />;
234
253
  default:
235
254
  // A kit kind with no drawing here yet: said in sight, as any kind no one draws.
236
255
  return <UnknownKind field={p.field} named={named} />;
237
256
  }
238
257
  }
239
258
 
259
+ /** A list's choices in runs, each run's `group` its heading (`<optgroup>`) or none: a group named again after another one is a second
260
+ * heading, so the choices keep the order the host gave. */
261
+ function optionRuns<O extends { group?: string }>(options: readonly O[]): Array<{ group?: string; options: O[] }> {
262
+ const runs: Array<{ group?: string; options: O[] }> = [];
263
+ for (const o of options) {
264
+ const last = runs.at(-1);
265
+ if (last && last.group === o.group) last.options.push(o);
266
+ else runs.push({ group: o.group, options: [o] });
267
+ }
268
+ return runs;
269
+ }
270
+
240
271
  /** A kind no one draws here (an app's kind not registered in this form): said in sight, so a setting never goes missing in silence. */
241
272
  function UnknownKind({ field, named }: { field: AnyFieldSpec; named: ReactNode }) {
242
273
  return (
@@ -246,51 +277,16 @@ function UnknownKind({ field, named }: { field: AnyFieldSpec; named: ReactNode }
246
277
  );
247
278
  }
248
279
 
249
- function RepeaterField({ label, field, value, disabled, onChange }: {
250
- label: string;
251
- field: Extract<FieldSpec, { kind: "repeater" }>;
252
- value: Array<Record<string, unknown>>;
253
- disabled?: boolean;
254
- onChange: (v: unknown) => void;
255
- }) {
256
- const update = (i: number, key: string, v: string) => onChange(value.map((r, ri) => (ri === i ? { ...r, [key]: v } : r)));
257
- const add = () => onChange([...value, Object.fromEntries(field.item.map((f) => [f.key, ""]))]);
258
- const remove = (i: number) => onChange(value.filter((_, ri) => ri !== i));
259
- const rowStyle: CSSProperties = { display: "flex", gap: 6, alignItems: "flex-start", marginBottom: 6 };
260
- const fieldsStyle: CSSProperties = { display: "grid", gap: 4, flex: 1 };
261
- return (
262
- <Field label={label} hint={field.hint} control="list">
263
- {value.map((row, i) => (
264
- <div style={rowStyle} key={i}>
265
- <div style={fieldsStyle}>
266
- {field.item.map((it) => (
267
- it.long
268
- ? <textarea key={it.key} className="gemboss-field gemboss-ei-inp" rows={2} placeholder={it.label ?? labelize(it.key)} disabled={disabled}
269
- value={String(row[it.key] ?? "")} onChange={(e) => update(i, it.key, e.target.value)} />
270
- : <input key={it.key} className="gemboss-field gemboss-ei-inp" placeholder={it.label ?? labelize(it.key)} disabled={disabled}
271
- value={String(row[it.key] ?? "")} onChange={(e) => update(i, it.key, e.target.value)} />
272
- ))}
273
- </div>
274
- <button type="button" className="gemboss-control gemboss-control--icon gemboss-ei-inp"
275
- disabled={disabled} aria-label="Remove row" onClick={() => remove(i)}>×</button>
276
- </div>
277
- ))}
278
- <button type="button" className="gemboss-control gemboss-ei-inp" disabled={disabled} onClick={add}>+ {field.addLabel ?? "Add"}</button>
279
- </Field>
280
- );
281
- }
282
-
283
280
  /** Text / number / textarea: draft locally, commit on blur or Enter (never per keystroke, so a live preview isn't hammered while typing).
284
- * Numbers persist as numbers, else "" (reverts to default). */
285
- function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlurCapture, describedBy, labelMark, ariaLabel, invalid = false }: {
281
+ * Numbers persist as numbers, else "" (reverts to default). A number box steps with ↑ / ↓ as the browser's own number box does (by its
282
+ * `step`, 1 by default, held to its bounds; an empty box starts at its floor, else 0), each step a draft like a key typed. */
283
+ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlurCapture, describedBy, labelMark, ariaLabel, invalid = false, listId }: {
286
284
  id: string; label: ReactNode; field: Extract<FieldSpec, { kind: "text" | "number" | "textarea" }>; ariaLabel?: string; invalid?: boolean;
287
285
  value: unknown; disabled?: boolean; onCommit: (v: unknown) => void; onDraft?: (v: unknown) => void;
288
- onBlurCapture?: FocusEventHandler<HTMLDivElement>; describedBy?: string; labelMark?: ReactNode;
286
+ onBlurCapture?: FocusEventHandler<HTMLDivElement>; describedBy?: string; labelMark?: ReactNode; listId?: string;
289
287
  }) {
290
288
  const norm = (v: unknown) => (v === undefined || v === null ? "" : String(v));
291
289
  const [draft, setDraft] = useState(norm(value));
292
- // A value from outside (Take latest, an Undo, the chat's write) replaces the draft while this renders, not in an effect a render later.
293
- useOnNewValue(() => setDraft(norm(value)), [value]);
294
290
  const isNum = field.kind === "number";
295
291
  // Bounds a setting declares (a 10..90 % scroll depth) are shown AND held: a value outside them is clamped on commit, so what the panel
296
292
  // keeps is what the storefront uses.
@@ -298,8 +294,16 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
298
294
  const hi = isNum ? field.max : undefined;
299
295
  // An unset bound is no bound: with `hi ?? n` the typed value was its own ceiling, so under a floor alone (min 1) a 0 stayed 0.
300
296
  const clamp = (n: number) => Math.min(hi ?? Infinity, Math.max(lo ?? -Infinity, n));
297
+ // A number as typed, a comma read as its point (the decimal keypad of a comma locale has no "."): "31,25" is 31.25, not a box left empty.
298
+ const read = (d: string) => Number(d.replace(",", "."));
299
+ // What a draft commits: the text, or a number as it reads, held to the bounds ("" for none).
300
+ const committed = (d: string) => (!isNum ? d : d.trim() !== "" && Number.isFinite(read(d)) ? String(clamp(read(d))) : "");
301
+ // A value from outside (Take latest, an Undo, the chat's write) replaces the draft while this renders, not in an effect a render later;
302
+ // but not the draft's own echo (a host that shows each draft at once hands it back): a "0" typed in a box held to 1 stays "0" while it is
303
+ // typed, and turns 1 when the box is left (review 09/11/2026: the box jumped to "1" under the seller's fingers).
304
+ useOnNewValue(() => { if (norm(value) !== committed(draft)) setDraft(norm(value)); }, [value]);
301
305
  const commit = () => {
302
- const next = isNum ? (draft !== "" && Number.isFinite(Number(draft)) ? clamp(Number(draft)) : "") : draft;
306
+ const next = isNum ? (draft !== "" && Number.isFinite(read(draft)) ? clamp(read(draft)) : "") : draft;
303
307
  // A clamped number can equal the stored value, so the host correctly skips that write.
304
308
  // Normalize the local draft too: without a new prop value, its effect cannot replace an invalid draft.
305
309
  if (isNum) setDraft(norm(next));
@@ -310,7 +314,16 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
310
314
  setDraft(raw);
311
315
  if (!onDraft) return;
312
316
  if (!isNum) { onDraft(raw); return; }
313
- if (raw.trim() !== "" && Number.isFinite(Number(raw))) onDraft(clamp(Number(raw)));
317
+ if (raw.trim() !== "" && Number.isFinite(read(raw))) onDraft(clamp(read(raw)));
318
+ };
319
+ // ↑ / ↓ on a number: the next step from what the box holds (a box holding no number keeps the keys for its caret).
320
+ const stepped = (dir: 1 | -1): string | null => {
321
+ const step = field.kind === "number" && field.step && field.step > 0 ? field.step : 1;
322
+ if (draft.trim() === "") return String(clamp(lo ?? 0));
323
+ const n = read(draft);
324
+ if (!Number.isFinite(n)) return null;
325
+ const places = (String(step).split(".")[1] ?? "").length;
326
+ return String(clamp(Number((n + dir * step).toFixed(places))));
314
327
  };
315
328
  // A lone bound says itself too: the commit raises a 0 to a floor of 1, and that needs its reason on screen as much as a pair does.
316
329
  const boundUnit = isNum && field.suffix ? ` ${field.suffix}` : "";
@@ -322,7 +335,10 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
322
335
  // 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
323
336
  // screen. The setting's own help is behind the ?.
324
337
  <Field label={label} htmlFor={id} hint={"hint" in field ? field.hint : undefined} control={controlOf(field)} onBlurCapture={onBlurCapture} mark={labelMark}>
325
- {field.kind === "textarea" ? (
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} />
341
+ ) : field.kind === "textarea" ? (
326
342
  <textarea id={id} className={`gemboss-field gemboss-ei-inp${field.code ? " gemboss-mono" : ""}`} rows={field.rows ?? 2} placeholder={field.placeholder}
327
343
  value={draft} disabled={disabled} maxLength={maxLength} spellCheck={field.code ? false : undefined}
328
344
  aria-describedby={describedBy} aria-label={ariaLabel} onChange={(e) => typed(e.target.value)} onBlur={commit} />
@@ -332,10 +348,21 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
332
348
  const on = {
333
349
  onChange: (e: ChangeEvent<HTMLInputElement>) => typed(e.target.value), onBlur: commit, "aria-describedby": describedBy, "aria-label": ariaLabel,
334
350
  "aria-invalid": invalid || undefined,
335
- // Enter commits by leaving the box; a search commits as it is typed and keeps the focus.
336
- onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => { if (e.key === "Enter" && !(field.kind === "text" && field.inputType === "search")) { e.preventDefault(); (e.target as HTMLInputElement).blur(); } },
351
+ onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {
352
+ // Enter commits by leaving the box; a search commits as it is typed and keeps the focus.
353
+ if (e.key === "Enter" && !(field.kind === "text" && field.inputType === "search")) { e.preventDefault(); (e.target as HTMLInputElement).blur(); return; }
354
+ if (isNum && (e.key === "ArrowUp" || e.key === "ArrowDown") && !e.metaKey && !e.ctrlKey && !e.altKey) {
355
+ const next = stepped(e.key === "ArrowUp" ? 1 : -1);
356
+ if (next !== null) { e.preventDefault(); typed(next); }
357
+ }
358
+ },
359
+ ...(listId ? { list: listId } : {}),
360
+ // An ID typed as written: none of the help a word gets. `on` is spread after the url/search/date `autoComplete` below, so its "off" holds.
361
+ ...(field.kind === "text" && field.verbatim ? { spellCheck: false, autoCapitalize: "off", autoCorrect: "off", autoComplete: "off" } : {}),
337
362
  };
338
- const inputMode = isNum ? ("numeric" as const) : undefined;
363
+ // A phone's keypad: a number's digits by default, a box's `inputMode` where it says (`decimal`: digits and a point, so a width of
364
+ // 12.5 in can be typed on an iPhone, whose digits keypad has no point).
365
+ const inputMode = field.kind === "number" ? field.inputMode ?? ("numeric" as const) : field.kind === "text" ? field.inputMode : undefined;
339
366
  const placeholder = field.kind === "text" || field.kind === "number" ? field.placeholder : undefined;
340
367
  // The unit INSIDE its box (UnitField, Polaris TextField's `suffix`): beside it, the box ended short of every other control's right
341
368
  // edge (control standard §13b).
@@ -346,11 +373,67 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
346
373
  : <input id={id} className="gemboss-field gemboss-ei-inp" type={field.kind === "text" ? field.inputType : undefined} inputMode={inputMode} placeholder={placeholder} value={draft} maxLength={maxLength} disabled={disabled}
347
374
  autoComplete={field.kind === "text" && (field.inputType === "url" || field.inputType === "search" || field.inputType === "date") ? "off" : undefined} {...on} />;
348
375
  })()}
349
- {bounds || count ? <p className="gemboss-ei-hint">{bounds || count}</p> : null}
376
+ {/* A number's bounds are a sentence, across the field like every note; a count is the box's own, under it at its end (editor.css
377
+ `.gemboss-ei-count`). */}
378
+ {bounds ? <p className="gemboss-ei-hint">{bounds}</p> : count ? <p className="gemboss-ei-hint gemboss-ei-count">{count}</p> : null}
350
379
  </Field>
351
380
  );
352
381
  }
353
382
 
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
+ /**
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).
399
+ */
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;
403
+ }) {
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
+ }, []);
423
+ 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).
433
+ onKeyDown={(e) => { if (e.key === "Enter" && !e.nativeEvent.isComposing && e.keyCode !== 229) { e.preventDefault(); e.currentTarget.blur(); } }} />
434
+ );
435
+ }
436
+
354
437
  function RangeField({ id, label, field, value, disabled, onCommit, onBlurCapture, labelMark }: {
355
438
  id: string; label: string; field: Extract<FieldSpec, { kind: "range" }>;
356
439
  value: unknown; disabled?: boolean; onCommit: (v: unknown) => void;
@@ -410,6 +493,8 @@ export type FieldRowsProps = {
410
493
  onDraft?: (id: string, value: unknown) => void;
411
494
  /** The controls' ids, `<idPrefix><field id>`, for a host whose form is mounted more than once. Else `fr-<field id>`. */
412
495
  idPrefix?: string;
496
+ /** The shop an app's kinds read (a link picker searching its products), for every field of the run. */
497
+ shopId?: string;
413
498
  /** The app's kinds and glyphs (FieldKindsProvider by default). */
414
499
  kinds?: FieldKinds;
415
500
  glyphs?: FieldGlyphs;
@@ -418,7 +503,7 @@ export type FieldRowsProps = {
418
503
  /** One group's fields, each its control, with the label on one side for the run (firstSideFirst). What a schema form draws inside a group,
419
504
  * whichever frame holds the group (FieldRenderer's static groups, FieldFrame's settings frame). A kind over several stored settings
420
505
  * (`spread`) reads them and writes back only the ones it changed, and is locked when any of them is. */
421
- export function FieldRows({ fields, values, onChange, disabled, off, offWhy, onPickImage, onDraft, idPrefix, kinds: kindsProp, glyphs: glyphsProp }: FieldRowsProps & { fields: readonly AnyFieldSpec[] }) {
506
+ export function FieldRows({ fields, values, onChange, disabled, off, offWhy, onPickImage, onDraft, idPrefix, shopId, kinds: kindsProp, glyphs: glyphsProp }: FieldRowsProps & { fields: readonly AnyFieldSpec[] }) {
422
507
  const { kinds, glyphs } = useFieldKinds(kindsProp, glyphsProp);
423
508
  const inputId = (f: AnyFieldSpec) => (idPrefix ? `${idPrefix}${f.id}` : undefined);
424
509
  const spreadOf = (f: AnyFieldSpec) => kindIn(kinds, f.kind)?.spread;
@@ -430,11 +515,11 @@ export function FieldRows({ fields, values, onChange, disabled, off, offWhy, onP
430
515
  // Several settings, one control: only the settings a change touched are written. Locked when any of them is.
431
516
  const locked = !!off && [f.id, ...spread.ids(f)].some((id) => off.has(id));
432
517
  return <FieldControl key={f.id} field={f} inputId={inputId(f)} disabled={disabled || locked} describedBy={locked ? offWhy : undefined}
433
- value={knobValue(f, values, kinds)} kinds={kinds} glyphs={glyphs}
518
+ value={knobValue(f, values, kinds)} kinds={kinds} glyphs={glyphs} shopId={shopId}
434
519
  onChange={(v) => { for (const [id, next] of spread.write(f, v, values)) onChange(id, next); }} />;
435
520
  }
436
521
  return <FieldControl key={f.id} field={f} inputId={inputId(f)} value={values[f.id]} disabled={disabled || off?.has(f.id)}
437
- describedBy={off?.has(f.id) ? offWhy : undefined} kinds={kinds} glyphs={glyphs}
522
+ describedBy={off?.has(f.id) ? offWhy : undefined} kinds={kinds} glyphs={glyphs} shopId={shopId}
438
523
  onChange={(v) => onChange(f.id, v)} onPickImage={onPickImage} onDraft={onDraft ? (v) => onDraft(f.id, v) : undefined} />;
439
524
  })}
440
525
  </>