@gemboss/ui 0.64.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.
- package/CHANGELOG.md +213 -1
- package/README.md +67 -5
- package/catalog/editor.html +21 -13
- package/catalog/index.html +4 -4
- package/gemboss-ui.css +3 -3
- package/package.json +8 -1
- package/parts/components.css +2 -2
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/auth.tsx +1 -15
- package/src/confirm-buttons.ts +35 -0
- package/src/confirm-dialog.css +1 -0
- package/src/confirm-dialog.tsx +124 -0
- package/src/create-shell.css +1 -1
- package/src/create-shell.tsx +7 -4
- package/src/dialog.css +1 -0
- package/src/dialog.tsx +46 -7
- package/src/editor/color-choices.ts +9 -0
- package/src/editor/controls.tsx +59 -19
- package/src/editor/field-control.tsx +456 -0
- package/src/editor/field-frame.tsx +192 -0
- package/src/editor/field-spec.ts +346 -0
- package/src/editor/index.ts +20 -2
- package/src/editor/label-side.ts +9 -3
- package/src/editor/panel.tsx +39 -12
- package/src/editor/secret-field.tsx +116 -0
- package/src/editor-color.css +1 -1
- package/src/editor-plain.js +1 -1
- package/src/editor.css +1 -1
- package/src/email-editor/editor.tsx +37 -9
- package/src/email-editor/model.ts +5 -1
- package/src/email-editor.css +1 -1
- package/src/eye-icon.tsx +14 -0
- package/src/gem-at-work.css +1 -1
- package/src/gem-at-work.ts +223 -11
- package/src/gemboss-field.css +1 -1
- package/src/icons-plain.js +1 -0
- package/src/icons.tsx +9 -0
- package/src/index.ts +4 -1
- package/src/kit-plain.css +1 -1
- package/src/list-page.css +1 -1
- package/src/list-page.tsx +181 -55
- package/src/list-toolbar.css +1 -0
- package/src/list-toolbar.tsx +85 -0
- package/src/menu-keys.ts +3 -1
- package/src/search-dialog.tsx +4 -1
- package/src/segmented.tsx +21 -5
- package/src/service-switcher.tsx +2 -2
- package/src/settings-dialog.tsx +2 -2
- 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
|
-
|
|
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
|
-
|
|
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>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// THE COLOURS A COLOUR FIELD OFFERS AS CHIPS (A4b, 21/10/2026; moved from the admin's lib/color-choices.ts with FieldControl, 08/11/2026):
|
|
2
|
+
// the context a host fills (the admin's element panel: the theme's colours by role, then the ones used lately on the store) and every
|
|
3
|
+
// colour field of a form reads. Null: no chips (the theme inspector has no page). Its own module, no JSX, so a node test reads it.
|
|
4
|
+
import { createContext } from "react";
|
|
5
|
+
import type { ColorChoice } from "./controls";
|
|
6
|
+
|
|
7
|
+
export type ColorChoices = { choices: ColorChoice[]; remember: (color: string) => void };
|
|
8
|
+
/** What a colour field offers (null: no chips). */
|
|
9
|
+
export const ColorChoicesContext = createContext<ColorChoices | null>(null);
|
package/src/editor/controls.tsx
CHANGED
|
@@ -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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
);
|
|
@@ -471,10 +508,13 @@ export const ChipButton = forwardRef<HTMLButtonElement, {
|
|
|
471
508
|
disabled?: boolean;
|
|
472
509
|
/** `aria-expanded`, for a chip that opens something under it (the Library grid). */
|
|
473
510
|
expanded?: boolean;
|
|
511
|
+
/** Its name for a screen reader when its words alone are one of many alike ("All settings" in each element's group: "All settings
|
|
512
|
+
* for Row"); absent, its words are its name. */
|
|
513
|
+
label?: string;
|
|
474
514
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
475
515
|
children: React.ReactNode;
|
|
476
|
-
}>(function ChipButton({ disabled, expanded, onClick, children }, ref) {
|
|
477
|
-
return <button ref={ref} type="button" className="ui-btn" disabled={disabled} aria-expanded={expanded} onClick={onClick}>{children}</button>;
|
|
516
|
+
}>(function ChipButton({ disabled, expanded, label, onClick, children }, ref) {
|
|
517
|
+
return <button ref={ref} type="button" className="ui-btn" disabled={disabled} aria-expanded={expanded} aria-label={label} onClick={onClick}>{children}</button>;
|
|
478
518
|
});
|
|
479
519
|
|
|
480
520
|
export interface ImageControlProps {
|