@gemboss/ui 0.65.0 → 0.66.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 (44) hide show
  1. package/CHANGELOG.md +165 -1
  2. package/README.md +24 -0
  3. package/catalog/editor.html +21 -13
  4. package/catalog/index.html +4 -4
  5. package/gemboss-ui.css +3 -3
  6. package/package.json +6 -1
  7. package/parts/components.css +2 -2
  8. package/parts/core.css +1 -1
  9. package/parts/shell.css +1 -1
  10. package/src/auth.tsx +1 -15
  11. package/src/confirm-buttons.ts +35 -0
  12. package/src/confirm-dialog.css +1 -0
  13. package/src/confirm-dialog.tsx +124 -0
  14. package/src/create-shell.css +1 -1
  15. package/src/create-shell.tsx +7 -4
  16. package/src/dialog.css +1 -0
  17. package/src/dialog.tsx +46 -7
  18. package/src/editor/controls.tsx +54 -17
  19. package/src/editor/field-control.tsx +4 -1
  20. package/src/editor/field-frame.tsx +20 -10
  21. package/src/editor/field-spec.ts +3 -2
  22. package/src/editor/index.ts +5 -3
  23. package/src/editor/label-side.ts +9 -3
  24. package/src/editor/panel.tsx +39 -12
  25. package/src/editor/secret-field.tsx +116 -0
  26. package/src/editor-color.css +1 -1
  27. package/src/editor-plain.js +1 -1
  28. package/src/editor.css +1 -1
  29. package/src/eye-icon.tsx +14 -0
  30. package/src/gemboss-field.css +1 -1
  31. package/src/icons-plain.js +1 -0
  32. package/src/icons.tsx +9 -0
  33. package/src/index.ts +4 -1
  34. package/src/kit-plain.css +1 -1
  35. package/src/list-page.css +1 -1
  36. package/src/list-page.tsx +94 -51
  37. package/src/list-toolbar.css +1 -0
  38. package/src/list-toolbar.tsx +85 -0
  39. package/src/menu-keys.ts +3 -1
  40. package/src/search-dialog.tsx +4 -1
  41. package/src/segmented.tsx +21 -5
  42. package/src/service-switcher.tsx +2 -2
  43. package/src/settings-dialog.tsx +2 -2
  44. package/src/ui.css +1 -1
package/src/dialog.tsx CHANGED
@@ -13,6 +13,7 @@
13
13
  * surface that only opens a Dialog should not download it. `Sheet` (sheet.tsx, 0.35.0) is this same Dialog docked
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
+ import "./dialog.css"; // its frame travels with it (09/11/2026): a surface that loads ui.css alone (the admin) draws it too
16
17
  import React, { useEffect, useId, useRef } from "react";
17
18
  import { flushSync } from "react-dom";
18
19
  import { Icon } from "./icons";
@@ -35,6 +36,9 @@ const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean)
35
36
  * - `returnFocusTo`: a selector focused instead when the opener is gone or hidden by then (a menu item, a palette row: both
36
37
  * leave the screen as they act, and focusing them does nothing). SettingsDialog's default is `[data-settings-trigger]`.
37
38
  * - The page behind holds still while any kit popup is modal: `html:has(dialog.ui-modal:modal)` (kit-plain.css).
39
+ * - `dismissible: false` (08/11/2026, ConfirmDialog while the server answers): Escape, the backdrop and ✕ do not close it. The
40
+ * browser's `cancel` is prevented, and when it closes anyway (Chrome lets a second Escape with no press between go through) it
41
+ * opens again at once; only `open` turning false closes it then.
38
42
  */
39
43
  // The control a press last landed on (24/10/2026). Polaris' buttons blur themselves on mouseup (UnstyledButton's
40
44
  // handleMouseUpByBlurring), so a popup opened by a click on one found <body> focused and gave the focus back to <body> on Escape:
@@ -54,8 +58,26 @@ const openerNow = (): Element | null => {
54
58
  return lastPressed && lastPressed.el.isConnected && Date.now() - lastPressed.at < 2000 ? lastPressed.el : a;
55
59
  };
56
60
 
57
- export function useModalDialog(open: boolean, onClose: () => void, { focusPanel = false, returnFocusTo }: { focusPanel?: boolean; returnFocusTo?: string } = {}) {
61
+ /**
62
+ * Tab belongs to the open popup (09/11/2026). The browser walks the focus through it alone (the page under it is inert), but a
63
+ * dialog of the page it was opened from still hears the key on the document: Polaris' Modal and the admin's own Modal trap Tab
64
+ * there, and at their last control they prevented it and focused their first, which the browser refuses (inert). Tab was stuck on
65
+ * the last button of a kit Dialog or Sheet opened from one (measured: a ConfirmDialog in a Polaris Modal). Stopped once everything
66
+ * inside has had it, so a field's own Tab still works, and only when the key comes from this popup's own content: a dialog drawn
67
+ * INSIDE it (an admin Modal in a Sheet, its window listener a Tab trap of its own) keeps its key (review of #7039).
68
+ */
69
+ export function holdTab(e: React.KeyboardEvent<HTMLElement>): void {
70
+ if (e.key !== "Tab") return;
71
+ const own = (e.target as Element | null)?.closest?.('dialog, [role="dialog"][aria-modal="true"]');
72
+ if (own === e.currentTarget) e.stopPropagation();
73
+ }
74
+
75
+ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel = false, returnFocusTo, dismissible = true }: { focusPanel?: boolean; returnFocusTo?: string; dismissible?: boolean } = {}) {
58
76
  const ref = useRef<HTMLDialogElement>(null);
77
+ const dismiss = useRef(dismissible);
78
+ dismiss.current = dismissible;
79
+ const openNow = useRef(open);
80
+ openNow.current = open;
59
81
  const opener = useRef<Element | null>(null);
60
82
  const shown = useRef(false);
61
83
  const pressOnBackdrop = useRef(false);
@@ -83,26 +105,39 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
83
105
  useEffect(() => {
84
106
  const d = ref.current;
85
107
  if (!d) return undefined;
108
+ // Not dismissible: Escape does nothing (the browser's cancel is prevented)…
109
+ const onCancel = (e: Event) => { if (!dismiss.current) e.preventDefault(); };
86
110
  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; }
87
113
  shown.current = false;
88
114
  // What closing changes is on the page before the focus goes back: a picker's typed handle, saved as it closes, replaces its
89
115
  // "Choose a product" with the chosen row, and the focus went to that button an instant before it left (measured, 24/10/2026).
90
116
  flushSync(() => close.current());
91
117
  giveFocusBack();
92
118
  };
119
+ d.addEventListener("cancel", onCancel);
93
120
  d.addEventListener("close", onNativeClose);
94
121
  return () => {
122
+ d.removeEventListener("cancel", onCancel);
95
123
  d.removeEventListener("close", onNativeClose);
96
124
  // Passive cleanups run after React removed the node; StrictMode's rehearsal leaves it in the document.
97
125
  if (shown.current && !d.isConnected) { shown.current = false; giveFocusBack(); }
98
126
  };
99
127
  }, []);
128
+ // Not dismissible and open: Escape pressed anywhere (the focus may have left the popup) makes no close request.
129
+ useEffect(() => {
130
+ if (!open || dismissible) return undefined;
131
+ const hold = (e: KeyboardEvent) => { if (e.key === "Escape") e.preventDefault(); };
132
+ document.addEventListener("keydown", hold, true);
133
+ return () => document.removeEventListener("keydown", hold, true);
134
+ }, [open, dismissible]);
100
135
  const onPointerDown = (e: React.PointerEvent<HTMLDialogElement>) => { pressOnBackdrop.current = e.target === e.currentTarget; };
101
136
  const onClick = (e: React.MouseEvent<HTMLDialogElement>) => {
102
- if (e.target === e.currentTarget && pressOnBackdrop.current) e.currentTarget.close();
137
+ if (e.target === e.currentTarget && pressOnBackdrop.current && dismiss.current) e.currentTarget.close();
103
138
  pressOnBackdrop.current = false;
104
139
  };
105
- return { ref, onClick, onPointerDown };
140
+ return { ref, onClick, onPointerDown, onKeyDown: holdTab };
106
141
  }
107
142
 
108
143
  export interface DialogProps {
@@ -126,10 +161,12 @@ export interface DialogProps {
126
161
  /** A selector focused on close when what opened it is gone by then (useModalDialog's `returnFocusTo`): a picker's first pick
127
162
  * replaces its "Choose" with the chosen row's Change. */
128
163
  returnFocusTo?: string;
164
+ /** False while it must stay (ConfirmDialog waiting for the server): Escape, the backdrop and ✕ do not close it. Default true. */
165
+ dismissible?: boolean;
129
166
  }
130
167
 
131
- export function Dialog({ open, onClose, title, subtitle, actions, children, footer, wide = false, closeLabel = "Close", className, focusPanel = false, returnFocusTo, lead }: DialogProps) {
132
- const { ref, onClick, onPointerDown } = useModalDialog(open, onClose, { focusPanel, returnFocusTo });
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 });
133
170
  const titleId = useId();
134
171
  const subId = useId();
135
172
  return (
@@ -138,14 +175,16 @@ export function Dialog({ open, onClose, title, subtitle, actions, children, foot
138
175
  // Its Escape closes it and only it, as the kit's Popover: the browser closes the <dialog>, and neither the keydown nor the keyup
139
176
  // goes further out, where a Polaris Modal it was opened from closed as well (on the keyup; escape.ts). A box that clears its
140
177
  // words on Escape (PickerList's) consumes the key before it gets here.
141
- onKeyDown={(e) => { if (e.key === "Escape" && !e.nativeEvent.isComposing) consumeEscape(e); }}>
178
+ // Not dismissible: the key's default is prevented too, so the browser makes no close request at all (a prevented `cancel`
179
+ // 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(); } }}>
142
181
  <div className="ui-modal__head">
143
182
  {lead}
144
183
  {subtitle
145
184
  ? <div className="ui-modal__title"><span id={titleId}>{title}</span><span className="ui-modal__subtitle" id={subId}>{subtitle}</span></div>
146
185
  : <div className="ui-modal__title" id={titleId}>{title}</div>}
147
186
  {actions ? <div className="ui-modal__actions">{actions}</div> : null}
148
- <button type="button" className="ui-modal__close" aria-label={closeLabel} onClick={() => ref.current?.close()}>
187
+ <button type="button" className="ui-modal__close" aria-label={closeLabel} disabled={!dismissible} onClick={() => ref.current?.close()}>
149
188
  <Icon name="close" size={20} />
150
189
  </button>
151
190
  </div>
@@ -190,6 +190,39 @@ export const PickButton = forwardRef<HTMLButtonElement, PickButtonProps>(functio
190
190
  );
191
191
  });
192
192
 
193
+ // ── Checkbox ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
194
+
195
+ export interface CheckboxProps {
196
+ /** 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
+ label: React.ReactNode;
198
+ checked: boolean;
199
+ onChange: (checked: boolean) => void;
200
+ disabled?: boolean;
201
+ /** The box's id, for a host that points at it. */
202
+ id?: string;
203
+ /** Another line that describes it (its reason, the file it is about). */
204
+ describedBy?: string;
205
+ /** Why it is off, while it is (`disabled`): said in its tooltip, a locked control says why (§13). */
206
+ why?: string;
207
+ }
208
+
209
+ /**
210
+ * A YES THE SELLER GIVES (09/11/2026, one control set: the plain kit's `.ui-check` had no React control, and the admin, which cannot load
211
+ * kit-plain.css, drew five of its own in the publish review): "I've checked this preview", "I can back these up", a file to copy. The kit's
212
+ * one checkbox look: `.ui-check`'s numbers (a 44px target, an 18px box, the words beside it, faded and not-allowed while off), so it reads
213
+ * 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
+ * a setting is FieldControl's `toggle`; this is a consent or a pick in a list.
215
+ */
216
+ export function Checkbox({ label, checked, onChange, disabled, id, describedBy, why }: CheckboxProps) {
217
+ return (
218
+ <label className="ui-check gemboss-ei-check" data-disabled={disabled ? "" : undefined} title={disabled && why ? why : undefined}>
219
+ <input type="checkbox" className="gemboss-ei-checkbox" id={id} checked={checked} disabled={disabled} aria-describedby={describedBy}
220
+ onChange={(e) => onChange(e.target.checked)} />
221
+ <span className="gemboss-ei-check-words">{label}</span>
222
+ </label>
223
+ );
224
+ }
225
+
193
226
  // ── UnitField ───────────────────────────────────────────────────────────────────────────────────────────────────────
194
227
 
195
228
  export interface UnitFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "className" | "style"> {
@@ -331,24 +364,28 @@ export function ColorControl({ id, value, onChange, disabled, label, placeholder
331
364
  <ColorPicker value={draft} base={base} label={label} choices={choices} allowNone={allowNone} noneLabel={placeholder}
332
365
  onChange={(next) => { setDraft(next); onChange(next); }} />
333
366
  </Popover>
334
- <span className="gemboss-ei-color-box">
335
- <input id={id} className="gemboss-field gemboss-ei-inp" placeholder={placeholder ?? "Not set"} value={draft} disabled={disabled} aria-describedby={describedBy}
336
- title={themeLabel ? `${themeLabel} (theme colour)` : mixLabel ? (halfMix ? `${mixLabel} (half of each)` : mixLabel) : undefined} data-theme-colour={boxName && !typing ? "" : undefined}
337
- onFocus={(e) => { setTyping(true); if (boxName) { const box = e.currentTarget; selectOnUp.current = true; requestAnimationFrame(() => box.select()); } }}
338
- onMouseUp={(e) => { if (selectOnUp.current) { selectOnUp.current = false; e.preventDefault(); e.currentTarget.select(); } }}
339
- onChange={(e) => { setDraft(e.target.value); onDraft?.(e.target.value); }}
340
- onBlur={() => { setTyping(false); selectOnUp.current = false; onChange(draft); }}
341
- onKeyDown={(e) => { selectOnUp.current = false; blurOnEnter(e); }} />
342
- {boxName && !typing ? <span className="gemboss-ei-color-name" aria-hidden="true"><span className="gemboss-ei-color-name__text">{boxName}</span><span> · {boxKind}</span></span> : null}
367
+ {/* ONE FIELD, the hex and its opacity (09/11/2026, §9.1): one bordered group (gemboss-field.css `--group`), the hex part and the %
368
+ part `__bare` inputs, a hairline between them (editor-color.css). Two boxes side by side left the hex 62px in a 330px panel's
369
+ control column and cut it; one group fits swatch, hex and % on one line there. */}
370
+ <span className="gemboss-field gemboss-field--group gemboss-ei-color-group">
371
+ <span className="gemboss-ei-color-box">
372
+ <input id={id} className="gemboss-field__bare gemboss-ei-inp" placeholder={placeholder ?? "Not set"} value={draft} disabled={disabled} aria-describedby={describedBy}
373
+ title={themeLabel ? `${themeLabel} (theme colour)` : mixLabel ? (halfMix ? `${mixLabel} (half of each)` : mixLabel) : undefined} data-theme-colour={boxName && !typing ? "" : undefined}
374
+ onFocus={(e) => { setTyping(true); if (boxName) { const box = e.currentTarget; selectOnUp.current = true; requestAnimationFrame(() => box.select()); } }}
375
+ onMouseUp={(e) => { if (selectOnUp.current) { selectOnUp.current = false; e.preventDefault(); e.currentTarget.select(); } }}
376
+ onChange={(e) => { setDraft(e.target.value); onDraft?.(e.target.value); }}
377
+ onBlur={() => { setTyping(false); selectOnUp.current = false; onChange(draft); }}
378
+ onKeyDown={(e) => { selectOnUp.current = false; blurOnEnter(e); }} />
379
+ {boxName && !typing ? <span className="gemboss-ei-color-name" aria-hidden="true"><span className="gemboss-ei-color-name__text">{boxName}</span><span> · {boxKind}</span></span> : null}
380
+ </span>
381
+ {/* The % part: the group's last part, its width editor-color.css's (room for "100%" in its face). */}
382
+ {opacity !== null ? (
383
+ // `data-alpha`: the hook editor-plain.js finds it by (the same part on a page without React).
384
+ <input className="gemboss-field__bare gemboss-ei-inp" data-alpha="" aria-label={`${label} opacity`} inputMode="numeric"
385
+ value={alphaDraft ?? `${opacity}%`} disabled={disabled}
386
+ onChange={(e) => setAlphaDraft(e.target.value)} onBlur={(e) => commitAlpha(e.target.value)} onKeyDown={blurOnEnter} />
387
+ ) : null}
343
388
  </span>
344
- {/* A fixed narrow box beside the wide one: its width is editor-color.css's (64px, 72px at a phone's 16px type, where "100%" did
345
- not fit 64: Control UI C10). */}
346
- {opacity !== null ? (
347
- // `data-alpha`: the hook editor-plain.js finds it by (the same box on a page without React).
348
- <input className="gemboss-field gemboss-ei-inp" data-alpha="" aria-label={`${label} opacity`} inputMode="numeric"
349
- value={alphaDraft ?? `${opacity}%`} disabled={disabled}
350
- onChange={(e) => setAlphaDraft(e.target.value)} onBlur={(e) => commitAlpha(e.target.value)} onKeyDown={blurOnEnter} />
351
- ) : null}
352
389
  {why ? <p id={whyId} className="gemboss-ei-color-why">{why}</p> : null}
353
390
  </div>
354
391
  );
@@ -341,7 +341,10 @@ function TextField({ id, label, field, value, disabled, onCommit, onDraft, onBlu
341
341
  // edge (control standard §13b).
342
342
  return unit || prefix
343
343
  ? <UnitField className="gemboss-ei-inp" unit={unit} prefix={prefix} id={id} inputMode={inputMode} placeholder={placeholder} value={draft} maxLength={maxLength} disabled={disabled} {...on} />
344
- : <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} {...on} />;
344
+ // A link, a search or a day takes none of the browser's remembered entries: its list would cover the results, the picker or the
345
+ // buttons under the box (each was a Polaris TextField with autoComplete="off" before the kit's).
346
+ : <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
+ autoComplete={field.kind === "text" && (field.inputType === "url" || field.inputType === "search" || field.inputType === "date") ? "off" : undefined} {...on} />;
345
348
  })()}
346
349
  {bounds || count ? <p className="gemboss-ei-hint">{bounds || count}</p> : null}
347
350
  </Field>
@@ -43,7 +43,8 @@ export function usePartHits(parts: readonly FramePart[], q: string): { hits: Rea
43
43
  const next = new Set<string>();
44
44
  for (const p of parts) {
45
45
  const el = partEls.current.get(p.key);
46
- const labels = el ? [...el.querySelectorAll(LABELS)].map((n) => n.textContent ?? "") : [];
46
+ // Not a sample a part shows (a widget's preview: its own headings and labels are no setting's): `data-search-skip`.
47
+ const labels = el ? [...el.querySelectorAll(LABELS)].filter((n) => !n.closest("[data-search-skip]")).map((n) => n.textContent ?? "") : [];
47
48
  if ([p.words, ...labels].some((t) => settingMatches(q, t))) next.add(p.key);
48
49
  }
49
50
  setHits((h) => (h.size === next.size && [...next].every((k) => h.has(k)) ? h : next));
@@ -69,6 +70,9 @@ export type FieldFrameProps = FieldRowsProps & {
69
70
  lead?: ReactNode;
70
71
  /** The host's own parts, first in Look. */
71
72
  own?: readonly FramePart[];
73
+ /** The host's parts after every one of the schema's groups in Look, its own and its shared ones' chips (Global styles: its form set,
74
+ * product cards and bundle picker after its colours and type). */
75
+ after?: readonly FramePart[];
72
76
  /** Who sees it besides its screens (an audience), first in Visibility. */
73
77
  who?: readonly FramePart[];
74
78
  /** Parts first in Layout (a theme part's spacing with its screen switch, a theme section's arrangement), and in Code (custom CSS). */
@@ -82,9 +86,15 @@ export type FieldFrameProps = FieldRowsProps & {
82
86
  inheritedFrom?: string;
83
87
  /** Which fields are placed by id, and where (field-spec.ts `STYLE_FRAME_PLACES` by default). */
84
88
  places?: FramePlaces;
89
+ /** A host's own name for a cluster, where the kit's (Look · Layout · Visibility · Code) would say the wrong thing: a plugin's Behavior
90
+ * settings in the cluster after its Look. */
91
+ labels?: FrameClusterLabels;
85
92
  };
86
93
 
87
- export function FieldFrame({ schema, lead, own = [], who = [], place: placeParts = [], code: codeParts = [], heldHere, inheritedFrom, onChangeMany, places, ...rows }: FieldFrameProps) {
94
+ /** The clusters' names a host gives them (InspectorFrame's `label`), by cluster. */
95
+ export type FrameClusterLabels = Partial<Record<"look" | "place" | "when" | "code", string>>;
96
+
97
+ export function FieldFrame({ schema, lead, own = [], after = [], who = [], place: placeParts = [], code: codeParts = [], heldHere, inheritedFrom, onChangeMany, places, labels, ...rows }: FieldFrameProps) {
88
98
  const { values, disabled } = rows;
89
99
  // The app's kinds, by prop or FieldKindsProvider: a kind over several settings holds and clears by its own rule.
90
100
  const { kinds } = useFieldKinds(rows.kinds, rows.glyphs);
@@ -103,7 +113,7 @@ export function FieldFrame({ schema, lead, own = [], who = [], place: placeParts
103
113
  const at = f.root.querySelector<HTMLElement>(f.sel);
104
114
  if (at) { focusNext.current = null; at.focus(); } else if (Date.now() > f.until) focusNext.current = null;
105
115
  });
106
- const parts = [...own, ...placeParts, ...who, ...codeParts];
116
+ const parts = [...own, ...after, ...placeParts, ...who, ...codeParts];
107
117
  const { hits, partRef } = usePartHits(parts, q);
108
118
  const found = useMemo(() => (q ? new Map(foundGroups(groups, q).map((g) => [g.key, g])) : null), [groups, q]);
109
119
  const rowsOf = (g: FrameGroup) => (
@@ -162,11 +172,11 @@ export function FieldFrame({ schema, lead, own = [], who = [], place: placeParts
162
172
  <InspectorFrame search={<InspectorSearch value={query} onChange={setQuery} name="section-setting-search" />} searching={!!q}
163
173
  lead={<>{lead}{nothing ? <p className="gemboss-ei-hint" data-find-none="">No setting matches “{q}”.</p> : null}</>}
164
174
  clusters={[
165
- { id: "look", on: own.length + look.length > 0, content: <>{own.map(part)}{ownLook.map((g) => draw(g))}
166
- {sharedLook.length ? <InspectorChips attrs={{ "data-look-chips": "" }}>{sharedLook.map((g) => draw(g, true))}</InspectorChips> : null}</> },
167
- { id: "place", on: placeParts.length + place.length > 0, content: <>{placeParts.map(part)}{place.map((g) => draw(g))}</> },
168
- { id: "when", on: who.length + when.length > 0, content: <>{who.map(part)}{when.map((g) => draw(g))}</> },
169
- { id: "code", on: codeParts.length + code.length > 0, content: <>{codeParts.map(part)}{code.map((g) => draw(g))}</> },
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)}</> },
177
+ { id: "place", label: labels?.place, on: placeParts.length + place.length > 0, content: <>{placeParts.map(part)}{place.map((g) => draw(g))}</> },
178
+ { id: "when", label: labels?.when, on: who.length + when.length > 0, content: <>{who.map(part)}{when.map((g) => draw(g))}</> },
179
+ { id: "code", label: labels?.code, on: codeParts.length + code.length > 0, content: <>{codeParts.map(part)}{code.map((g) => draw(g))}</> },
170
180
  ]} />
171
181
  );
172
182
  }
@@ -176,7 +186,7 @@ const NO_VALUES: Record<string, unknown> = {};
176
186
  const noop = () => {};
177
187
  /** A panel of parts only, in the frame (a plugin's settings, the store's header and footer): the frame, its search and its index around
178
188
  * groups a host draws itself with the kit's controls, no schema of its own. */
179
- export function PartsFrame({ lead, own, place, who, code, kinds, glyphs }: { lead?: ReactNode; own?: readonly FramePart[]; place?: readonly FramePart[]; who?: readonly FramePart[]; code?: readonly FramePart[]; kinds?: FieldKinds; glyphs?: FieldGlyphs }) {
180
- return <FieldFrame schema={NO_SCHEMA} values={NO_VALUES} onChange={noop} onChangeMany={noop} lead={lead} own={own} place={place} who={who} code={code} kinds={kinds} glyphs={glyphs} />;
189
+ export function PartsFrame({ lead, own, place, who, code, labels, kinds, glyphs }: { lead?: ReactNode; own?: readonly FramePart[]; place?: readonly FramePart[]; who?: readonly FramePart[]; code?: readonly FramePart[]; labels?: FrameClusterLabels; kinds?: FieldKinds; glyphs?: FieldGlyphs }) {
190
+ return <FieldFrame schema={NO_SCHEMA} values={NO_VALUES} onChange={noop} onChangeMany={noop} lead={lead} own={own} place={place} who={who} code={code} labels={labels} kinds={kinds} glyphs={glyphs} />;
181
191
  }
182
192
 
@@ -30,8 +30,9 @@ export type FieldSpec<G extends string = string> =
30
30
  // page's "/pages/").
31
31
  | { kind: "text"; id: string; label?: string; placeholder?: string; hint?: string; maxLength?: number; prefix?: string;
32
32
  /** The box's own type where it says what it holds: a link (`url`: the phone's link keyboard), a search (`search`: the browser's clear
33
- * button where it draws one, and Enter keeps the focus in it), an email. Default a plain text box. A box with a `prefix` stays text. */
34
- inputType?: "url" | "search" | "email" }
33
+ * button where it draws one, and Enter keeps the focus in it), an email, a day (`date`: the browser's own date picker, its value
34
+ * YYYY-MM-DD). Default a plain text box. A box with a `prefix` stays text. */
35
+ inputType?: "url" | "search" | "email" | "date" }
35
36
  // `code`: a stylesheet or a script, in a monospace face, not spell-checked.
36
37
  | { kind: "textarea"; id: string; label?: string; rows?: number; placeholder?: string; hint?: string; maxLength?: number; code?: boolean }
37
38
  | { kind: "number"; id: string; label?: string; min?: number; max?: number; step?: number; suffix?: string; hint?: string; placeholder?: string }
@@ -38,8 +38,8 @@ export {
38
38
  type FieldProps, type InspectorGroupProps, type PanelHeaderProps, type PanelTab, type PanelTabsProps,
39
39
  } from "./panel";
40
40
  export {
41
- ChipButton, ColorControl, EdgeBox, fileSizeWords, ImageControl, imageFileName, MediaCard, PickButton, RangeControl, Seg, UnitField, ValueControl,
42
- type ColorChoice, type ColorControlProps, type EdgeBoxProps, type EdgeSide, type ImageControlProps, type MediaCardProps, type PickButtonProps, type RangeControlProps, type SegOption, type SegProps, type UnitFieldProps, type ValueControlProps,
41
+ Checkbox, ChipButton, ColorControl, EdgeBox, fileSizeWords, ImageControl, imageFileName, MediaCard, PickButton, RangeControl, Seg, UnitField, ValueControl,
42
+ type CheckboxProps, type ColorChoice, type ColorControlProps, type EdgeBoxProps, type EdgeSide, type ImageControlProps, type MediaCardProps, type PickButtonProps, type RangeControlProps, type SegOption, type SegProps, type UnitFieldProps, type ValueControlProps,
43
43
  } from "./controls";
44
44
  // 27/10/2026: a control takes a value from outside in the render that brings it, not an effect later (new-value.ts).
45
45
  export { useOnNewValue } from "./new-value";
@@ -79,7 +79,9 @@ export {
79
79
  controlOf, FieldControl, FieldKindsProvider, FieldRenderer, FieldRows, labelBeside,
80
80
  type FieldControlProps, type FieldGlyphs, type FieldKind, type FieldKindProps, type FieldKinds, type FieldRowsProps,
81
81
  } from "./field-control";
82
- export { FieldFrame, PartsFrame, usePartHits, type FieldFrameProps, type FramePart } from "./field-frame";
82
+ export { FieldFrame, PartsFrame, usePartHits, type FieldFrameProps, type FrameClusterLabels, type FramePart } from "./field-frame";
83
+ // 09/11/2026: a secret the seller gives (a token, a key): masked, Show / Paste, never copied out, "Saved, ends in …" once stored.
84
+ export { SecretField, secretTail, type SecretFieldProps } from "./secret-field";
83
85
  export { ColorChoicesContext, type ColorChoices } from "./color-choices";
84
86
  // 24/10/2026: a setting's small panel beside the settings column (top layer; a sheet at phone width); its own CSS part.
85
87
  export { Popover, type PopoverProps } from "./popover";
@@ -39,6 +39,12 @@ export const LABEL_SIDE = {
39
39
  link: "beside",
40
40
  /** A date and time. */
41
41
  date: "beside",
42
+ /** A secret (an API token, a private key): its masked box with Show and Paste, or once stored "Saved, ends in …" and Replace
43
+ * (SecretField). One line, as a text box; its buttons wrap under the box where the column is narrow, as a link's Choose does. */
44
+ secret: "beside",
45
+ /** Which screens show it: three device pictures (Desktop · Tablet · Mobile, each named in its tooltip and for a screen reader), as a
46
+ * vertical alignment's three pictures are (label-side audit decision E, 09/11/2026). Their words did not fit the control column. */
47
+ screens: "beside",
42
48
  // THE PANEL'S WIDTH: the label above, the control under it.
43
49
  /** A text of several lines (a description, custom CSS). */
44
50
  textarea: "above",
@@ -56,10 +62,10 @@ export const LABEL_SIDE = {
56
62
  drawing: "above",
57
63
  /** A line of code (a condition's expression): it reads whole across the field, not cut in the control column. */
58
64
  code: "above",
65
+ /** A sentence in place of a control: a value filled from elsewhere (the section's copy, a product's metafield, a list's content
66
+ * source), or a setting edited in another place. A sentence reads across the field; beside, it is four lines in the control column. */
67
+ note: "above",
59
68
  // ABOVE FOR NOW: the decision is here, not in the host, so what is drawn and the table agree until the control is reworked.
60
- /** Which screens show it (Desktop · Tablet · Mobile): three chips in words, too wide for the row. Three device glyphs beside the
61
- * label move it to `chips` (slice 2 of the label-side work, decision E). */
62
- screens: "above",
63
69
  /** A font's one button (an "Aa" in the font, its name, CSS): a name needs the width (FontPickerField). It follows `pick` in a later
64
70
  * slice (decision C); the element panel's Font is a list (`select`), beside. */
65
71
  "font-pick": "above",
@@ -19,6 +19,14 @@ export interface PanelTab<T extends string = string> {
19
19
  icon?: React.ReactNode;
20
20
  /** The id of the panel this tab shows: `aria-controls` (and editor-plain.js shows it, hiding its siblings'). */
21
21
  controls?: string;
22
+ /** A second line under the label, muted: what the part holds (09/11/2026, the offer editor's Offer · Who & when · Design, UI book
23
+ * OF-1). For the inspector row. It is the tab's description (`aria-describedby`), not part of its name. Under 300px of row only the
24
+ * labels stay. */
25
+ hint?: React.ReactNode;
26
+ /** The tab's own id, for the panel that names itself by it (`aria-labelledby`). */
27
+ tabId?: string;
28
+ /** Its tooltip (the offer editor's: what in that part needs a look). */
29
+ title?: string;
22
30
  }
23
31
 
24
32
  export interface PanelTabsProps<T extends string = string> {
@@ -35,34 +43,47 @@ export interface PanelTabsProps<T extends string = string> {
35
43
  label?: string;
36
44
  /**
37
45
  * Roving focus (default on): only the selected tab is in the Tab order, ←/→ move the selection and the focus with
38
- * it, wrapping at the ends. Off, every tab is a plain stop and arrows do nothing (the admin's Configure · Chat row,
39
- * kept exactly as it was in step 3).
46
+ * it, wrapping at the ends, and Home / End go to the first and the last (09/11/2026, as the offer editor's row did). Off,
47
+ * every tab is a plain stop and keys do nothing (the admin's Configure · Chat row, kept exactly as it was in step 3).
40
48
  */
41
49
  roving?: boolean;
50
+ /** No margin of its own: the row sits flush in a box that has its own padding (the offer editor's card), outside the editor's
51
+ * column. The inspector's row otherwise keeps 8px over it and 12px at its sides there. */
52
+ flush?: boolean;
42
53
  }
43
54
 
44
55
  /** A row of `role="tab"` buttons. The caller owns the selection and draws the panel under it. */
45
- export function PanelTabs<T extends string = string>({ tabs, value, onChange, variant = "column", label, roving = true }: PanelTabsProps<T>) {
56
+ export function PanelTabs<T extends string = string>({ tabs, value, onChange, variant = "column", label, roving = true, flush = false }: PanelTabsProps<T>) {
46
57
  const inspector = variant === "inspector";
58
+ const hints = tabs.some((t) => t.hint != null);
59
+ const uid = useId();
47
60
  const onKeyDown = roving ? (e: React.KeyboardEvent<HTMLDivElement>) => {
48
- if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
61
+ if (e.key !== "ArrowRight" && e.key !== "ArrowLeft" && e.key !== "Home" && e.key !== "End") return;
49
62
  e.preventDefault();
50
63
  const i = tabs.findIndex((t) => t.id === value);
51
- const ni = e.key === "ArrowRight" ? (i + 1) % tabs.length : (i - 1 + tabs.length) % tabs.length;
64
+ const ni = e.key === "Home" ? 0 : e.key === "End" ? tabs.length - 1
65
+ : e.key === "ArrowRight" ? (i + 1) % tabs.length : (i - 1 + tabs.length) % tabs.length;
52
66
  onChange(tabs[ni].id);
53
67
  // Focus follows the selection (roving tabindex).
54
68
  (e.currentTarget.children[ni] as HTMLButtonElement | undefined)?.focus();
55
69
  } : undefined;
56
70
  return (
57
- <div className={inspector ? "gemboss-ei-tabs" : "gemboss-ec-tabs"} role="tablist" aria-label={label} onKeyDown={onKeyDown}>
71
+ <div className={[inspector ? "gemboss-ei-tabs" : "gemboss-ec-tabs", hints ? "has-hints" : "", flush ? "is-flush" : ""].filter(Boolean).join(" ")}
72
+ role="tablist" aria-label={label} onKeyDown={onKeyDown}>
58
73
  {tabs.map((t) => {
59
74
  const on = t.id === value;
60
75
  return (
61
76
  // data-value: what a page without React reads back (editor-plain.js), since the label can be anything.
62
- <button key={t.id} type="button" role="tab" data-value={t.id}
77
+ <button key={t.id} type="button" role="tab" data-value={t.id} id={t.tabId} title={t.title}
63
78
  className={inspector ? `gemboss-ei-tab${on ? " on" : ""}` : "gemboss-ec-tab"}
64
- aria-selected={on} aria-controls={t.controls} tabIndex={roving ? (on ? 0 : -1) : undefined} onClick={() => onChange(t.id)}>
65
- {t.icon}{t.label}
79
+ aria-selected={on} aria-controls={t.controls} aria-describedby={t.hint != null ? `${uid}-${t.id}-hint` : undefined}
80
+ tabIndex={roving ? (on ? 0 : -1) : undefined} onClick={() => onChange(t.id)}>
81
+ {t.icon}{hints ? (
82
+ // Every tab of a row with hints is drawn the same way (one without a hint keeps the column, so the labels line up). The
83
+ // hint describes the tab: hidden from its name, read as its description.
84
+ <span className="gemboss-ei-tab-text"><span>{t.label}</span>
85
+ {t.hint != null ? <span className="gemboss-ei-tab-hint" id={`${uid}-${t.id}-hint`} aria-hidden="true">{t.hint}</span> : null}</span>
86
+ ) : t.label}
66
87
  </button>
67
88
  );
68
89
  })}
@@ -179,6 +200,9 @@ export interface FieldProps {
179
200
  label?: React.ReactNode;
180
201
  /** The control's id, so a click on the label focuses it. */
181
202
  htmlFor?: string;
203
+ /** The label's own id, for a control that is a group of boxes it names (`aria-labelledby`): several checkboxes have no one control a
204
+ * `for` can point at (Screens). */
205
+ labelId?: string;
182
206
  /** A value shown at the label's right edge, bold and tabular (a range's current value: `.gemboss-ei-rangeval`). */
183
207
  labelValue?: React.ReactNode;
184
208
  /** The setting's help (`p.gemboss-ei-hint.gemboss-ei-help-text`). In a plugin's form a line under the control; inside an
@@ -203,6 +227,9 @@ export interface FieldProps {
203
227
  style?: React.CSSProperties;
204
228
  /** Refuse a descendant's pending blur commit on this existing field root, without inserting a DOM wrapper. */
205
229
  onBlurCapture?: React.FocusEventHandler<HTMLDivElement>;
230
+ /** The focus leaving a part of the field, after the part's own blur (a text box whose toolbar, chips and link box are in the field too
231
+ * saves its words when the focus leaves all of them: the admin's TextMarksField). */
232
+ onBlur?: React.FocusEventHandler<HTMLDivElement>;
206
233
  children?: React.ReactNode;
207
234
  }
208
235
 
@@ -220,16 +247,16 @@ export interface FieldProps {
220
247
  * beside it in a group, a drawer or a card alike (05/11/2026, unreleased: the row was laid out only inside a group, so the page settings drawer's
221
248
  * three lists stacked under labels that asked to sit beside them).
222
249
  */
223
- export function Field({ label, htmlFor, labelValue, hint, control, row = false, aside, mark, className, style, onBlurCapture, children }: FieldProps) {
250
+ export function Field({ label, htmlFor, labelId, labelValue, hint, control, row = false, aside, mark, className, style, onBlurCapture, onBlur, children }: FieldProps) {
224
251
  const helpId = useId();
225
252
  const [helpOpen, setHelpOpen] = useState(false);
226
253
  const beside = control ? labelSide(control) === "beside" : row;
227
254
  const cls = ["gemboss-ei-fld", beside && label != null ? "gemboss-ei-fld--row" : "", className].filter(Boolean).join(" ");
228
255
  const labelNode = label != null ? (
229
- <label htmlFor={htmlFor}>{label}{labelValue != null ? <span className="gemboss-ei-rangeval">{labelValue}</span> : null}</label>
256
+ <label htmlFor={htmlFor} id={labelId}>{label}{labelValue != null ? <span className="gemboss-ei-rangeval">{labelValue}</span> : null}</label>
230
257
  ) : null;
231
258
  return (
232
- <div className={cls} style={style} onBlurCapture={onBlurCapture}>
259
+ <div className={cls} style={style} onBlurCapture={onBlurCapture} onBlur={onBlur}>
233
260
  {/* A ? is a button, so it sits BESIDE the label, not in it (a label may hold no other labelable element); so does an aside. */}
234
261
  {(hint || aside || mark) && labelNode ? (
235
262
  <div className="gemboss-ei-lbl">
@@ -0,0 +1,116 @@
1
+ "use client";
2
+ // A SECRET THE SELLER GIVES (09/11/2026, one control set: every admin surface that takes a token or a key drew its own password box, Polaris'
3
+ // or a raw input, each with its own words for "it is stored"). One box for an API token, a private key, an access token:
4
+ // · typed or pasted (Paste reads the clipboard), masked, with Show / Hide for checking what was pasted;
5
+ // · never copied or dragged out of the box (copy, cut and a drag do nothing): a secret goes in, it does not come back out;
6
+ // · autocomplete off and 1Password / LastPass told to stay out; a browser's own password manager may still offer to save it (a masked
7
+ // box is a password box to it), which no attribute reliably stops;
8
+ // · once stored, the box is gone and the field says "Saved", with the last characters when the host knows them, never the secret itself
9
+ // (the host hands only its tail; the kit keeps four characters of it at most). Replace opens an empty box; Cancel closes it.
10
+ // Its label is beside the box (the label-side table: `secret`), the box and its two buttons in the control column, the buttons under the box
11
+ // where the column is too narrow for both (as a link's box and its Choose).
12
+ import "../editor.css"; // its own stylesheet travels with it
13
+ import { useRef, useState, type ClipboardEvent, type DragEvent, type KeyboardEvent, type ReactNode } from "react";
14
+ import { EyeIcon } from "../eye-icon";
15
+ import { Field } from "./panel";
16
+ import { useOnNewValue } from "./new-value";
17
+
18
+ export interface SecretFieldProps {
19
+ /** The box's id (the label points at it). */
20
+ id: string;
21
+ /** What the secret is ("Judge.me private API token"). */
22
+ label: string;
23
+ /** No label drawn: the box is named by it for a screen reader, where its row already says what it is. */
24
+ labelHidden?: boolean;
25
+ /** What is being typed now. Never the stored secret: a host never hands it back. */
26
+ value: string;
27
+ onChange: (value: string) => void;
28
+ /** Enter in the box (the host's Connect or Save). */
29
+ onSubmit?: () => void;
30
+ placeholder?: string;
31
+ /** Where to find it, what happens to it. Drawn as the field's help. */
32
+ hint?: ReactNode;
33
+ disabled?: boolean;
34
+ /** A secret is stored: the field says so instead of a box, with its last characters if the host knows them (`tail`). Replace opens an
35
+ * empty box. `at`: when it was stored, so a new one with the same tail (or none) is a new one too. null / absent: nothing stored. */
36
+ saved?: { tail?: string | null; at?: string | null } | null;
37
+ /** Replace pressed (true) or its Cancel (false), for a host that shows its own Save only while a new secret is typed. */
38
+ onReplacing?: (replacing: boolean) => void;
39
+ /** Controlled: the host holds whether a new secret is being typed over the stored one (it closes the box when its save lands). Absent,
40
+ * the field holds it, and closes it when the stored secret's tail or `at` changes: a host whose secret has neither controls it. */
41
+ replacing?: boolean;
42
+ }
43
+
44
+ /** The last characters a host may show of a stored secret: four at most, whatever it hands. */
45
+ export function secretTail(tail: string | null | undefined): string {
46
+ return (tail ?? "").replace(/\s+/g, "").slice(-4);
47
+ }
48
+
49
+ export function SecretField({ id, label, labelHidden = false, value, onChange, onSubmit, placeholder, hint, disabled, saved, onReplacing, replacing: held }: SecretFieldProps) {
50
+ const [shown, setShown] = useState(false);
51
+ const [own, setReplacing] = useState(false);
52
+ const replacing = held ?? own;
53
+ const [pasteRefused, setPasteRefused] = useState(false);
54
+ // A new secret stored (the host's answer): back to "Saved", masked again.
55
+ const savedKey = saved ? `saved:${secretTail(saved.tail)}:${saved.at ?? ""}` : "none";
56
+ useOnNewValue(() => { setReplacing(false); setShown(false); }, [savedKey, held]);
57
+ // Emptied (a failed connect clears it): masked again, so the next secret never goes in in plain sight.
58
+ useOnNewValue(() => { if (!value) setShown(false); }, [value === ""]);
59
+ // What the box holds now, for a paste the browser answers late: it lands only on the box as it was when Paste was pressed.
60
+ const current = useRef(value);
61
+ current.current = value;
62
+ const replace = (on: boolean) => { setReplacing(on); setShown(false); setPasteRefused(false); if (!on) onChange(""); onReplacing?.(on); };
63
+ const noCopy = (e: ClipboardEvent<HTMLInputElement>) => e.preventDefault();
64
+ const noDrag = (e: DragEvent<HTMLInputElement>) => e.preventDefault();
65
+ const paste = async () => {
66
+ setPasteRefused(false);
67
+ const before = current.current;
68
+ try {
69
+ const text = await navigator.clipboard.readText();
70
+ // Typed or pasted with ⌘V meanwhile (a permission prompt was open): that stays.
71
+ if (text.trim() && current.current === before) onChange(text.trim());
72
+ } catch {
73
+ // The browser would not hand the clipboard over (no permission, not a secure page): ⌘V / Ctrl+V in the box still pastes.
74
+ setPasteRefused(true);
75
+ document.getElementById(id)?.focus();
76
+ }
77
+ };
78
+ const named = labelHidden ? undefined : label;
79
+ const tail = saved ? secretTail(saved.tail) : "";
80
+
81
+ if (saved && !replacing) {
82
+ return (
83
+ <Field label={named} control="secret" hint={hint}>
84
+ <div className="gemboss-ei-secret gemboss-ei-secret--saved" data-secret-saved="">
85
+ <span className="gemboss-ei-secret-said">
86
+ {labelHidden ? <span className="ui-sr-only">{`${label}: `}</span> : null}
87
+ {tail ? <>Saved, ends in <span className="gemboss-ei-secret-tail">{tail}</span></> : "Saved"}
88
+ </span>
89
+ <button type="button" className="ui-btn gemboss-ei-secret-btn" disabled={disabled} aria-label={`Replace ${label}`} onClick={() => replace(true)}>Replace</button>
90
+ </div>
91
+ </Field>
92
+ );
93
+ }
94
+
95
+ return (
96
+ <Field label={named} htmlFor={id} control="secret" hint={hint}>
97
+ <div className="gemboss-ei-secret">
98
+ <input id={id} className="gemboss-field gemboss-ei-inp gemboss-ei-secret-box" type={shown ? "text" : "password"} value={value} disabled={disabled}
99
+ placeholder={placeholder} aria-label={labelHidden ? label : undefined} autoComplete="off" autoCapitalize="off" autoCorrect="off" spellCheck={false}
100
+ data-1p-ignore="" data-lpignore="true" onCopy={noCopy} onCut={noCopy} onDragStart={noDrag}
101
+ onChange={(e) => { setPasteRefused(false); onChange(e.target.value); }}
102
+ onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => { if (e.key === "Enter" && onSubmit) { e.preventDefault(); onSubmit(); } }} />
103
+ <span className="gemboss-ei-secret-acts">
104
+ {/* NAME ONLY, no aria-pressed (the kit's PasswordField): once the name flips, a pressed state says the opposite thing. */}
105
+ <button type="button" className="ui-btn ui-btn--icon gemboss-ei-secret-btn" aria-controls={id} disabled={disabled || !value}
106
+ aria-label={shown ? `Hide ${label}` : `Show ${label}`} title={shown ? "Hide" : "Show"} onClick={() => setShown((s) => !s)}>
107
+ <EyeIcon off={shown} />
108
+ </button>
109
+ <button type="button" className="ui-btn gemboss-ei-secret-btn" disabled={disabled} onClick={() => void paste()}>Paste</button>
110
+ {saved ? <button type="button" className="ui-btn gemboss-ei-secret-btn" disabled={disabled} onClick={() => replace(false)}>Cancel</button> : null}
111
+ </span>
112
+ </div>
113
+ {pasteRefused ? <p className="gemboss-ei-hint" role="status">The browser did not hand over the clipboard: paste in the box with ⌘V or Ctrl+V.</p> : null}
114
+ </Field>
115
+ );
116
+ }