@gemboss/ui 0.65.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.
- package/CHANGELOG.md +349 -2
- package/README.md +33 -4
- package/catalog/editor.html +21 -13
- package/catalog/index.html +6 -6
- package/gemboss-ui.css +3 -3
- package/package.json +10 -1
- package/parts/components.css +2 -2
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/engine.tsx +2 -18
- package/src/auth.tsx +1 -15
- package/src/board-auto-more.tsx +168 -0
- package/src/collections.tsx +10 -1
- package/src/confirm-buttons.ts +37 -0
- package/src/confirm-dialog.css +1 -0
- package/src/confirm-dialog.tsx +128 -0
- package/src/copy-field.css +1 -0
- package/src/copy-field.tsx +48 -0
- package/src/copy-text.ts +20 -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/choice-cards.tsx +71 -0
- package/src/editor/controls.tsx +61 -19
- package/src/editor/field-control.tsx +146 -58
- package/src/editor/field-frame.tsx +20 -10
- package/src/editor/field-spec.ts +43 -8
- package/src/editor/index.ts +16 -5
- package/src/editor/items-field.tsx +185 -0
- package/src/editor/items.ts +126 -0
- package/src/editor/label-side.ts +11 -4
- package/src/editor/panel.tsx +39 -12
- package/src/editor/repeater.tsx +37 -7
- package/src/editor/secret-field.tsx +118 -0
- package/src/editor/switch.tsx +34 -0
- package/src/editor-color.css +1 -1
- package/src/editor-grow.css +1 -0
- package/src/editor-insert.css +1 -1
- package/src/editor-plain.js +1 -1
- package/src/editor-repeater.css +1 -1
- package/src/editor-switch.css +1 -0
- package/src/editor.css +1 -1
- package/src/eye-icon.tsx +14 -0
- package/src/gemboss-field.css +1 -1
- package/src/icons-plain.js +1 -0
- package/src/icons.tsx +9 -0
- package/src/index.ts +7 -1
- package/src/kit-plain.css +1 -1
- package/src/list-page.css +1 -1
- package/src/list-page.tsx +94 -51
- 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 +24 -6
- package/src/service-switcher.tsx +2 -2
- package/src/settings-dialog.tsx +2 -2
- package/src/ui.css +1 -1
package/src/editor/controls.tsx
CHANGED
|
@@ -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
|
}
|
|
@@ -190,6 +192,42 @@ export const PickButton = forwardRef<HTMLButtonElement, PickButtonProps>(functio
|
|
|
190
192
|
);
|
|
191
193
|
});
|
|
192
194
|
|
|
195
|
+
// ── Checkbox ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
196
|
+
|
|
197
|
+
export interface CheckboxProps {
|
|
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. */
|
|
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;
|
|
203
|
+
checked: boolean;
|
|
204
|
+
onChange: (checked: boolean) => void;
|
|
205
|
+
disabled?: boolean;
|
|
206
|
+
/** The box's id, for a host that points at it. */
|
|
207
|
+
id?: string;
|
|
208
|
+
/** Another line that describes it (its reason, the file it is about). */
|
|
209
|
+
describedBy?: string;
|
|
210
|
+
/** Why it is off, while it is (`disabled`): said in its tooltip, a locked control says why (§13). */
|
|
211
|
+
why?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 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
|
|
216
|
+
* 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
|
|
217
|
+
* 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
|
|
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:
|
|
219
|
+
* a setting is FieldControl's `toggle`; this is a consent or a pick in a list.
|
|
220
|
+
*/
|
|
221
|
+
export function Checkbox({ label, labelHidden = false, checked, onChange, disabled, id, describedBy, why }: CheckboxProps) {
|
|
222
|
+
return (
|
|
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}>
|
|
224
|
+
<input type="checkbox" className="gemboss-ei-checkbox" id={id} checked={checked} disabled={disabled} aria-describedby={describedBy}
|
|
225
|
+
onChange={(e) => onChange(e.target.checked)} />
|
|
226
|
+
<span className={labelHidden ? "gemboss-ei-check-words ui-sr-only" : "gemboss-ei-check-words"}>{label}</span>
|
|
227
|
+
</label>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
193
231
|
// ── UnitField ───────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
194
232
|
|
|
195
233
|
export interface UnitFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "className" | "style"> {
|
|
@@ -331,24 +369,28 @@ export function ColorControl({ id, value, onChange, disabled, label, placeholder
|
|
|
331
369
|
<ColorPicker value={draft} base={base} label={label} choices={choices} allowNone={allowNone} noneLabel={placeholder}
|
|
332
370
|
onChange={(next) => { setDraft(next); onChange(next); }} />
|
|
333
371
|
</Popover>
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
372
|
+
{/* ONE FIELD, the hex and its opacity (09/11/2026, §9.1): one bordered group (gemboss-field.css `--group`), the hex part and the %
|
|
373
|
+
part `__bare` inputs, a hairline between them (editor-color.css). Two boxes side by side left the hex 62px in a 330px panel's
|
|
374
|
+
control column and cut it; one group fits swatch, hex and % on one line there. */}
|
|
375
|
+
<span className="gemboss-field gemboss-field--group gemboss-ei-color-group">
|
|
376
|
+
<span className="gemboss-ei-color-box">
|
|
377
|
+
<input id={id} className="gemboss-field__bare gemboss-ei-inp" placeholder={placeholder ?? "Not set"} value={draft} disabled={disabled} aria-describedby={describedBy}
|
|
378
|
+
title={themeLabel ? `${themeLabel} (theme colour)` : mixLabel ? (halfMix ? `${mixLabel} (half of each)` : mixLabel) : undefined} data-theme-colour={boxName && !typing ? "" : undefined}
|
|
379
|
+
onFocus={(e) => { setTyping(true); if (boxName) { const box = e.currentTarget; selectOnUp.current = true; requestAnimationFrame(() => box.select()); } }}
|
|
380
|
+
onMouseUp={(e) => { if (selectOnUp.current) { selectOnUp.current = false; e.preventDefault(); e.currentTarget.select(); } }}
|
|
381
|
+
onChange={(e) => { setDraft(e.target.value); onDraft?.(e.target.value); }}
|
|
382
|
+
onBlur={() => { setTyping(false); selectOnUp.current = false; onChange(draft); }}
|
|
383
|
+
onKeyDown={(e) => { selectOnUp.current = false; blurOnEnter(e); }} />
|
|
384
|
+
{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}
|
|
385
|
+
</span>
|
|
386
|
+
{/* The % part: the group's last part, its width editor-color.css's (room for "100%" in its face). */}
|
|
387
|
+
{opacity !== null ? (
|
|
388
|
+
// `data-alpha`: the hook editor-plain.js finds it by (the same part on a page without React).
|
|
389
|
+
<input className="gemboss-field__bare gemboss-ei-inp" data-alpha="" aria-label={`${label} opacity`} inputMode="numeric"
|
|
390
|
+
value={alphaDraft ?? `${opacity}%`} disabled={disabled}
|
|
391
|
+
onChange={(e) => setAlphaDraft(e.target.value)} onBlur={(e) => commitAlpha(e.target.value)} onKeyDown={blurOnEnter} />
|
|
392
|
+
) : null}
|
|
343
393
|
</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
394
|
{why ? <p id={whyId} className="gemboss-ei-color-why">{why}</p> : null}
|
|
353
395
|
</div>
|
|
354
396
|
);
|
|
@@ -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
|
|
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,
|
|
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((
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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 === "
|
|
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,22 +348,92 @@ 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
|
-
|
|
336
|
-
|
|
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
|
-
|
|
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).
|
|
342
369
|
return unit || prefix
|
|
343
370
|
? <UnitField className="gemboss-ei-inp" unit={unit} prefix={prefix} id={id} inputMode={inputMode} placeholder={placeholder} value={draft} maxLength={maxLength} disabled={disabled} {...on} />
|
|
344
|
-
|
|
371
|
+
// 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
|
|
372
|
+
// buttons under the box (each was a Polaris TextField with autoComplete="off" before the kit's).
|
|
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}
|
|
374
|
+
autoComplete={field.kind === "text" && (field.inputType === "url" || field.inputType === "search" || field.inputType === "date") ? "off" : undefined} {...on} />;
|
|
345
375
|
})()}
|
|
346
|
-
{bounds
|
|
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}
|
|
347
379
|
</Field>
|
|
348
380
|
);
|
|
349
381
|
}
|
|
350
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
|
+
|
|
351
437
|
function RangeField({ id, label, field, value, disabled, onCommit, onBlurCapture, labelMark }: {
|
|
352
438
|
id: string; label: string; field: Extract<FieldSpec, { kind: "range" }>;
|
|
353
439
|
value: unknown; disabled?: boolean; onCommit: (v: unknown) => void;
|
|
@@ -407,6 +493,8 @@ export type FieldRowsProps = {
|
|
|
407
493
|
onDraft?: (id: string, value: unknown) => void;
|
|
408
494
|
/** The controls' ids, `<idPrefix><field id>`, for a host whose form is mounted more than once. Else `fr-<field id>`. */
|
|
409
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;
|
|
410
498
|
/** The app's kinds and glyphs (FieldKindsProvider by default). */
|
|
411
499
|
kinds?: FieldKinds;
|
|
412
500
|
glyphs?: FieldGlyphs;
|
|
@@ -415,7 +503,7 @@ export type FieldRowsProps = {
|
|
|
415
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,
|
|
416
504
|
* whichever frame holds the group (FieldRenderer's static groups, FieldFrame's settings frame). A kind over several stored settings
|
|
417
505
|
* (`spread`) reads them and writes back only the ones it changed, and is locked when any of them is. */
|
|
418
|
-
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[] }) {
|
|
419
507
|
const { kinds, glyphs } = useFieldKinds(kindsProp, glyphsProp);
|
|
420
508
|
const inputId = (f: AnyFieldSpec) => (idPrefix ? `${idPrefix}${f.id}` : undefined);
|
|
421
509
|
const spreadOf = (f: AnyFieldSpec) => kindIn(kinds, f.kind)?.spread;
|
|
@@ -427,11 +515,11 @@ export function FieldRows({ fields, values, onChange, disabled, off, offWhy, onP
|
|
|
427
515
|
// Several settings, one control: only the settings a change touched are written. Locked when any of them is.
|
|
428
516
|
const locked = !!off && [f.id, ...spread.ids(f)].some((id) => off.has(id));
|
|
429
517
|
return <FieldControl key={f.id} field={f} inputId={inputId(f)} disabled={disabled || locked} describedBy={locked ? offWhy : undefined}
|
|
430
|
-
value={knobValue(f, values, kinds)} kinds={kinds} glyphs={glyphs}
|
|
518
|
+
value={knobValue(f, values, kinds)} kinds={kinds} glyphs={glyphs} shopId={shopId}
|
|
431
519
|
onChange={(v) => { for (const [id, next] of spread.write(f, v, values)) onChange(id, next); }} />;
|
|
432
520
|
}
|
|
433
521
|
return <FieldControl key={f.id} field={f} inputId={inputId(f)} value={values[f.id]} disabled={disabled || off?.has(f.id)}
|
|
434
|
-
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}
|
|
435
523
|
onChange={(v) => onChange(f.id, v)} onPickImage={onPickImage} onDraft={onDraft ? (v) => onDraft(f.id, v) : undefined} />;
|
|
436
524
|
})}
|
|
437
525
|
</>
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|