@gemboss/ui 0.67.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +179 -4
- package/README.md +89 -9
- package/catalog/editor.html +10 -8
- package/catalog/index.html +615 -564
- package/gemboss-ui.css +3 -3
- package/package.json +5 -2
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/attachments.tsx +486 -0
- package/src/assistant/chat-cards.tsx +343 -0
- package/src/assistant/chat.tsx +29 -6
- package/src/assistant/host.tsx +8 -11
- package/src/assistant/index.ts +8 -1
- package/src/assistant-chat.css +1 -1
- package/src/assistant-plain.js +1 -1
- package/src/assistant.css +1 -1
- package/src/auth-field.css +1 -1
- package/src/auth.tsx +4 -2
- package/src/chat-attachments.css +1 -0
- package/src/chat-cards.css +1 -0
- package/src/chat-plain.js +5 -5
- package/src/collections.tsx +8 -1
- package/src/dialog.tsx +68 -11
- package/src/editor/controls.tsx +51 -10
- package/src/editor/field-control.tsx +26 -51
- package/src/editor/field-frame.tsx +4 -10
- package/src/editor/field-spec.ts +4 -2
- package/src/editor/grow-to-text.ts +51 -0
- package/src/editor/index.ts +2 -4
- package/src/editor/inspector-frame.tsx +143 -32
- package/src/editor/items-field.tsx +8 -3
- package/src/editor/items.ts +30 -6
- package/src/editor/panel.tsx +4 -5
- package/src/editor-grow.css +1 -1
- package/src/editor-inspector-frame.css +1 -1
- package/src/editor-media.css +1 -0
- package/src/editor-plain.js +1 -1
- package/src/editor-rail.css +1 -1
- package/src/editor.css +1 -1
- package/src/email-editor/editor.tsx +96 -69
- package/src/email-editor.css +1 -1
- package/src/gem-at-work.css +1 -1
- package/src/gem-at-work.ts +177 -33
- package/src/gem-holo.css +1 -1
- package/src/icons.tsx +42 -0
- package/src/index-table-extras.css +1 -0
- package/src/index-table.tsx +37 -16
- package/src/menu.tsx +7 -3
- package/src/narration.css +1 -1
- package/src/selection.tsx +22 -12
- package/src/editor/chips.tsx +0 -24
- package/src/editor-chips.css +0 -1
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
// THE SETTINGS FRAME (06/11/2026, one settings frame slice 1). Chris found three frames around one set of controls: the element panel's
|
|
3
|
-
// (search, an index of four clusters, group titles, groups that hold nothing as + lines
|
|
3
|
+
// (search, an index of four clusters, group titles, groups that hold nothing as + lines), the theme editor's folding groups,
|
|
4
4
|
// and a library section's Style as a flat list under uppercase heads. The element panel's is the standard (about 96% of the setting rows
|
|
5
5
|
// drawn); this is it, taken out of the admin's ElementNodePanel so every settings surface draws the same frame:
|
|
6
6
|
//
|
|
7
7
|
// div.gemboss-ei-frame[data-settings-frame] (display: contents: no box of its own, the panel's rows stay its host's children in layout)
|
|
8
|
-
// › head (the host's own row)
|
|
8
|
+
// › head (the host's own row)
|
|
9
|
+
// › div.gemboss-ei-bar[data-settings-bar] (sticky): the index as tabs (Look · Layout · Visibility · Code) and a 🔍 that opens the
|
|
10
|
+
// search in the tabs' place; with one cluster, the search box alone
|
|
9
11
|
// › aside (a popover anchored in the panel) › lead (what governs everything under it)
|
|
10
|
-
// › per cluster: div.gemboss-ei-cluster[data-panel-cluster] (its name) › its groups
|
|
11
|
-
// A search's results take the place of the
|
|
12
|
+
// › per cluster: div.gemboss-ei-cluster[data-panel-cluster] (room, its name for a screen reader only: the tabs say it) › its groups
|
|
13
|
+
// A search's results take the place of the lead and the clusters.
|
|
14
|
+
//
|
|
15
|
+
// FEWER LAYERS (Chris 10/11/2026 on the UI/UX canvas, threads "rối tầng lớp": "bạn làm đi thấy hợp lý ntn thì làm"). Above the first
|
|
16
|
+
// control the panel stacked six lines of words of one size: the element's name, the search box, the index, Edit for, the cluster's
|
|
17
|
+
// name (the index's word again) and the group's. The index is the tabs now, the search a 🔍 at their end, and a cluster's name is not
|
|
18
|
+
// drawn twice: two lines above the first group, the host's head and the tabs.
|
|
12
19
|
//
|
|
13
20
|
// The groups are the caller's, drawn with InspectorFrameGroup: open (always shown, no fold), add (a group holding nothing: its name and a
|
|
14
|
-
//
|
|
21
|
+
// + at the right of its one line, as Sticky and Motion; no chips since 10/11/2026) or added (its rows under its name and a − that clears
|
|
22
|
+
// them; just added, marked a moment and kept in view). What a + or a − writes is the caller's: the frame decides how a panel looks and moves, never what it stores.
|
|
15
23
|
// Its own part, editor-inspector-frame.css: only a surface that draws the frame loads it.
|
|
16
24
|
import "../editor.css"; // a group's note (.gemboss-ei-gh-note) and the group itself are editor.css's
|
|
17
25
|
import "../editor-inspector-frame.css";
|
|
@@ -56,8 +64,9 @@ export function InspectorSearch({ value, onChange, placeholder = "Find a setting
|
|
|
56
64
|
|
|
57
65
|
// ── InspectorClusterBreak ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
58
66
|
|
|
59
|
-
/** Where a cluster starts (Control UI C32
|
|
60
|
-
* the panel
|
|
67
|
+
/** Where a cluster starts (Control UI C32): room, not a line. Its name is a heading for a screen reader only since 10/11/2026: the tabs
|
|
68
|
+
* over the panel name the clusters, and a second LOOK under the tab Look was one line more of the same word. `first`: at the top, with
|
|
69
|
+
* no room above. */
|
|
61
70
|
export function InspectorClusterBreak({ cluster, label, first = false, hidden = false }: { cluster: string; label?: React.ReactNode; first?: boolean; hidden?: boolean }) {
|
|
62
71
|
return (
|
|
63
72
|
<div className={first ? "gemboss-ei-cluster gemboss-ei-cluster--first" : "gemboss-ei-cluster"} data-panel-cluster={cluster} hidden={hidden || undefined}>
|
|
@@ -128,8 +137,12 @@ const FramedStatic: FramedStaticGroup = ({ title, hint, attrs, children }) => (
|
|
|
128
137
|
);
|
|
129
138
|
|
|
130
139
|
export function InspectorFrame({ head, search, aside, lead, clusters, results, searching = false, indexAttrs }: InspectorFrameProps) {
|
|
131
|
-
// The
|
|
132
|
-
const [
|
|
140
|
+
// The bar over the panel (its tabs and its 🔍); its parent holds the clusters the tabs jump to (this panel's, not another one).
|
|
141
|
+
const [barEl, setBarEl] = useState<HTMLElement | null>(null);
|
|
142
|
+
// The search opened from the 🔍 (it stays open while it holds words: `searching` or `results`, the host's).
|
|
143
|
+
const [finding, setFinding] = useState(false);
|
|
144
|
+
const findButton = useRef<HTMLButtonElement>(null);
|
|
145
|
+
const wasOpen = useRef(false);
|
|
133
146
|
// The cluster the panel stands in (element review C34, Chris 31/10: "bấm … không biết nó nhảy đi đâu"), kept as the panel scrolls: the
|
|
134
147
|
// last cluster whose name is above the top third of the panel's view. Not "the last one at the end": the clusters after Look are short,
|
|
135
148
|
// so the end shows two or three of them and the one being read is the one near the top.
|
|
@@ -144,13 +157,13 @@ export function InspectorFrame({ head, search, aside, lead, clusters, results, s
|
|
|
144
157
|
// the listeners attached only when it is another box.
|
|
145
158
|
const [box, setBox] = useState<HTMLElement | null>(null);
|
|
146
159
|
useBrowserLayoutEffect(() => {
|
|
147
|
-
const b =
|
|
160
|
+
const b = barEl && !searching && !results ? scrollerOf(barEl) : null;
|
|
148
161
|
if (b !== box) setBox(b);
|
|
149
162
|
});
|
|
150
163
|
const firstRef = useRef(first);
|
|
151
164
|
firstRef.current = first;
|
|
152
165
|
useEffect(() => {
|
|
153
|
-
if (!box || !
|
|
166
|
+
if (!box || !barEl) return undefined;
|
|
154
167
|
let frame = 0;
|
|
155
168
|
const read = () => {
|
|
156
169
|
frame = 0;
|
|
@@ -158,7 +171,7 @@ export function InspectorFrame({ head, search, aside, lead, clusters, results, s
|
|
|
158
171
|
if (j && (performance.now() - j.at < 1000 || Math.abs(box.scrollTop - j.top) < 4)) { setHere(j.cluster); return; }
|
|
159
172
|
jumped.current = null;
|
|
160
173
|
const line = box.getBoundingClientRect().top + box.clientHeight / 3;
|
|
161
|
-
const labels = [...(
|
|
174
|
+
const labels = [...(barEl.parentElement?.querySelectorAll<HTMLElement>(":scope > [data-panel-cluster]") ?? [])];
|
|
162
175
|
const passed = labels.filter((l) => l.getBoundingClientRect().top <= line);
|
|
163
176
|
setHere(passed.at(-1)?.getAttribute("data-panel-cluster") ?? firstRef.current);
|
|
164
177
|
};
|
|
@@ -173,18 +186,35 @@ export function InspectorFrame({ head, search, aside, lead, clusters, results, s
|
|
|
173
186
|
for (const t of ["wheel", "touchstart", "keydown", "pointerdown"] as const) box.removeEventListener(t, byHand);
|
|
174
187
|
if (frame) cancelAnimationFrame(frame);
|
|
175
188
|
};
|
|
176
|
-
}, [box,
|
|
177
|
-
if (results) return <div className="gemboss-ei-frame" data-settings-frame=""><StaticGroupInFrame.Provider value={FramedStatic}>{head}{search}{aside}{results}</StaticGroupInFrame.Provider></div>;
|
|
189
|
+
}, [box, barEl]);
|
|
178
190
|
const shown = clusters.filter((c) => c.on ?? hasContent(c.content));
|
|
191
|
+
// THE BAR. With tabs, the search is a 🔍 at their end that opens the box in their place (open while it holds words); Escape in an empty
|
|
192
|
+
// box, or ✕, closes it. With one cluster (no tabs), the box itself. The box is always drawn, hidden while closed: opening and closing
|
|
193
|
+
// never draw it again from nothing, and a panel that turns to its results as the seller types keeps the box (and the focus) it typed in.
|
|
194
|
+
const tabs = shown.length > 1;
|
|
195
|
+
const open = !!search && (!tabs || finding || searching || !!results);
|
|
196
|
+
const closable = tabs && !searching && !results;
|
|
197
|
+
// The box takes the focus as the 🔍 opens it. Closed while the focus was in it (Escape, ✕, or the host's words emptied): the 🔍 has it
|
|
198
|
+
// back, never the page; closed while the seller is elsewhere, the focus stays where they are.
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
if (open && !wasOpen.current && finding) barEl?.querySelector<HTMLInputElement>("input")?.focus();
|
|
201
|
+
if (!open && wasOpen.current && tabs) {
|
|
202
|
+
const at = document.activeElement;
|
|
203
|
+
if (!at || at === document.body || barEl?.contains(at)) findButton.current?.focus();
|
|
204
|
+
}
|
|
205
|
+
wasOpen.current = open;
|
|
206
|
+
}, [open, finding, tabs, barEl]);
|
|
179
207
|
// One press away, as far down as it stands: the cluster's name at the top of the panel, the focus on its first control, the cluster's
|
|
180
208
|
// own first (a section's words, who it is for), and never past its end.
|
|
181
209
|
const jumpTo = (cluster: string) => {
|
|
182
|
-
const panel =
|
|
210
|
+
const panel = barEl?.parentElement;
|
|
183
211
|
const label = panel?.querySelector(`:scope > [data-panel-cluster="${cluster}"]`);
|
|
184
212
|
if (!(label instanceof HTMLElement)) return;
|
|
185
213
|
// The panel's own scroller moves, not the page around it: scrollIntoView moves every scrolling box up the tree.
|
|
186
214
|
const scroller = scrollerOf(label);
|
|
187
|
-
|
|
215
|
+
// Under the sticky bar and the room under it, as at open (not behind it).
|
|
216
|
+
const under = barEl ? barEl.offsetHeight + (parseFloat(getComputedStyle(barEl).marginBottom) || 0) : 0;
|
|
217
|
+
const top = scroller ? Math.min(scroller.scrollTop + label.getBoundingClientRect().top - scroller.getBoundingClientRect().top - under, scroller.scrollHeight - scroller.clientHeight) : 0;
|
|
188
218
|
jumped.current = { cluster, top, at: performance.now() };
|
|
189
219
|
scroller?.scrollTo({ top, behavior: reducedMotion() ? "auto" : "smooth" });
|
|
190
220
|
setHere(cluster);
|
|
@@ -195,18 +225,34 @@ export function InspectorFrame({ head, search, aside, lead, clusters, results, s
|
|
|
195
225
|
if (to instanceof HTMLElement) { to.focus({ preventScroll: true }); break; }
|
|
196
226
|
}
|
|
197
227
|
};
|
|
198
|
-
const index =
|
|
199
|
-
<nav
|
|
200
|
-
{
|
|
201
|
-
|
|
202
|
-
<button type="button" className="gemboss-ei-index-link" onClick={() => jumpTo(c.id)} data-jump={c.id}
|
|
203
|
-
aria-current={here === c.id ? "location" : undefined}>{c.label ?? INSPECTOR_CLUSTERS[c.id] ?? c.id}</button></Fragment>)}
|
|
228
|
+
const index = tabs ? (
|
|
229
|
+
<nav className="gemboss-ei-index" aria-label="Jump to" data-settings-index="" hidden={open || undefined} {...indexAttrs}>
|
|
230
|
+
{shown.map((c) => <button key={c.id} type="button" className="gemboss-ei-index-link" onClick={() => jumpTo(c.id)} data-jump={c.id}
|
|
231
|
+
aria-current={here === c.id ? "location" : undefined}>{c.label ?? INSPECTOR_CLUSTERS[c.id] ?? c.id}</button>)}
|
|
204
232
|
</nav>
|
|
205
233
|
) : null;
|
|
234
|
+
const bar = search || index ? (
|
|
235
|
+
<div ref={setBarEl} className="gemboss-ei-bar" data-settings-bar="" data-tabs={tabs ? "" : undefined}>
|
|
236
|
+
{search ? (
|
|
237
|
+
<div className="gemboss-ei-bar-find" hidden={!open || undefined}
|
|
238
|
+
onKeyDown={(e) => { if (e.key === "Escape" && !e.defaultPrevented && closable) { e.preventDefault(); setFinding(false); } }}>
|
|
239
|
+
{search}
|
|
240
|
+
{tabs ? <button type="button" className="gemboss-ei-bar-btn" aria-label="Close search" title="Close search" hidden={!closable || undefined}
|
|
241
|
+
onClick={() => setFinding(false)}><Icon name="close" size={16} /></button> : null}
|
|
242
|
+
</div>
|
|
243
|
+
) : null}
|
|
244
|
+
{index}
|
|
245
|
+
{tabs && search ? (
|
|
246
|
+
<button ref={findButton} type="button" className="gemboss-ei-bar-btn" aria-label="Find a setting" title="Find a setting" data-settings-find=""
|
|
247
|
+
hidden={open || undefined} onClick={() => setFinding(true)}><Icon name="search" size={16} /></button>
|
|
248
|
+
) : null}
|
|
249
|
+
</div>
|
|
250
|
+
) : null;
|
|
251
|
+
if (results) return <div className="gemboss-ei-frame" data-settings-frame=""><StaticGroupInFrame.Provider value={FramedStatic}>{head}{bar}{aside}{results}</StaticGroupInFrame.Provider></div>;
|
|
206
252
|
return (
|
|
207
253
|
<div className="gemboss-ei-frame" data-settings-frame="" data-searching={searching ? "" : undefined}>
|
|
208
254
|
<StaticGroupInFrame.Provider value={FramedStatic}>
|
|
209
|
-
{head}{
|
|
255
|
+
{head}{bar}{aside}{lead}
|
|
210
256
|
{shown.map((c) => <Fragment key={c.id}><InspectorClusterBreak cluster={c.id} label={c.label} first={c === shown[0]} hidden={searching} />{c.content}</Fragment>)}
|
|
211
257
|
</StaticGroupInFrame.Provider>
|
|
212
258
|
</div>
|
|
@@ -227,10 +273,13 @@ export interface InspectorFrameGroupProps {
|
|
|
227
273
|
groupKey: string;
|
|
228
274
|
/**
|
|
229
275
|
* `open`: always shown (the type and the space round it, an element's own groups): its name and note, no fold, no target's height.
|
|
230
|
-
* `add`: it holds nothing: its name and a
|
|
276
|
+
* `add`: it holds nothing: one line, its name and a + at the right, the whole line the target (Figma's empty section: Fill +, Stroke +,
|
|
277
|
+
* Effects +), as Sticky and Motion are. Every group the seller adds is this line, in its own place (Chris 10/11/2026: Background,
|
|
278
|
+
* Size, Shadow "mỗi cái là một dòng" like Sticky and Motion; the chips of Control UI C32 slice 3 wrapped, and a chip pressed opened
|
|
279
|
+
* its group in the middle of the run, pushing the chips after it to new places: the eye lost where it was).
|
|
231
280
|
* `added`: it holds a value, or + showed it: its rows under its name and a − in the place the + was.
|
|
232
|
-
* ONE component for the three, so a group that changes state stays the same element in the same place: pressed,
|
|
233
|
-
* where it was and the focus stays in it (Control UI C33); a remount dropped the focus to the page.
|
|
281
|
+
* ONE component for the three, so a group that changes state stays the same element in the same place: pressed, the line becomes the
|
|
282
|
+
* group's head where it was and the focus stays in it (Control UI C33); a remount dropped the focus to the page.
|
|
234
283
|
*/
|
|
235
284
|
state: "open" | "add" | "added";
|
|
236
285
|
title: string;
|
|
@@ -240,7 +289,6 @@ export interface InspectorFrameGroupProps {
|
|
|
240
289
|
/** `add`: what + does, and its accessible name (default "Add <title>"). */
|
|
241
290
|
onAdd?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
242
291
|
addLabel?: string;
|
|
243
|
-
chip?: boolean;
|
|
244
292
|
/** `added`: the −. Absent where it would write nothing (a value held on another screen keeps the group added). */
|
|
245
293
|
remove?: { label: string; onRemove: (e: React.MouseEvent<HTMLButtonElement>) => void } | null;
|
|
246
294
|
/** `added`: small actions before the − (Play, Preview). */
|
|
@@ -250,23 +298,86 @@ export interface InspectorFrameGroupProps {
|
|
|
250
298
|
children?: React.ReactNode;
|
|
251
299
|
}
|
|
252
300
|
|
|
253
|
-
|
|
301
|
+
/** How long a group just added stays marked (its head and rows tinted, fading): long enough to be seen, short enough not to stay. */
|
|
302
|
+
export const JUST_ADDED_MS = 1200;
|
|
303
|
+
|
|
304
|
+
/** How long after a press of + the group's arrival is that press's answer (an add with a start is a write, answered later). */
|
|
305
|
+
const PRESS_ANSWERED_MS = 5000;
|
|
306
|
+
|
|
307
|
+
/** The bottom of what sticks over the top of `within` at `x` (a sticky head in the column; over the page, the admin's fixed top bar), else
|
|
308
|
+
* `top`: a head scrolled under it would be out of sight. */
|
|
309
|
+
function coveredTop(within: Element, x: number, top: number): number {
|
|
310
|
+
for (let n = document.elementFromPoint(x, Math.max(0, top) + 1); n && n !== within; n = n.parentElement) {
|
|
311
|
+
const pos = getComputedStyle(n).position;
|
|
312
|
+
if (pos === "fixed" || pos === "sticky") return Math.max(top, n.getBoundingClientRect().bottom);
|
|
313
|
+
}
|
|
314
|
+
return top;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* A group just added opens DOWNWARD from its head, which stays where the + was. Where its rows run past the bottom of what is seen of
|
|
319
|
+
* the column, the column scrolls by what is hidden, never so far that the head leaves the top (a group taller than the column shows its
|
|
320
|
+
* head and as many rows as fit): the eye stays on the line it pressed, and sees what + brought. What is seen: the column's box within
|
|
321
|
+
* the window, below anything that sticks over its top; with no column that scrolls, the window below the page's fixed bar.
|
|
322
|
+
*/
|
|
323
|
+
export function keepAddedInView(el: HTMLElement, reduced: boolean): void {
|
|
324
|
+
const col = scrollerOf(el);
|
|
325
|
+
const box = col ?? (document.scrollingElement as HTMLElement | null);
|
|
326
|
+
if (!box) return;
|
|
327
|
+
const r = col ? col.getBoundingClientRect() : { top: 0, bottom: window.innerHeight };
|
|
328
|
+
const top = Math.max(r.top, 0);
|
|
329
|
+
const area = { top: coveredTop(col ?? document.documentElement, el.getBoundingClientRect().left + 1, top), bottom: Math.min(r.bottom, window.innerHeight) };
|
|
330
|
+
const by = addedScrollBy(el.getBoundingClientRect(), area);
|
|
331
|
+
if (by > 0) box.scrollBy({ top: by, behavior: reduced ? "auto" : "smooth" });
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** How far the column scrolls for a group just added at `group` in the visible `area` (both in the viewport's px): what of it is hidden
|
|
335
|
+
* below, 8px to spare, but never more than keeps its head 8px under the top. 0 when it is all in sight. */
|
|
336
|
+
export function addedScrollBy(group: { top: number; bottom: number }, area: { top: number; bottom: number }): number {
|
|
337
|
+
const hidden = group.bottom - area.bottom + 8;
|
|
338
|
+
if (hidden <= 0) return 0;
|
|
339
|
+
return Math.max(0, Math.min(hidden, group.top - area.top - 8));
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function InspectorFrameGroup({ groupKey, state, title, note, label, onAdd, addLabel, remove, acts, disabled, children }: InspectorFrameGroupProps) {
|
|
343
|
+
// The same element in its three states (one div). `add` -> `added` ANSWERING A PRESS OF ITS + marks it for JUST_ADDED_MS and keeps it
|
|
344
|
+
// in view (keepAddedInView). A group a value brings (an Undo, a chat's write, another writer's save, another screen's values) is
|
|
345
|
+
// drawn added as before, unmarked, and moves nothing: the seller did not ask, so the column stays where they were reading (review).
|
|
346
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
347
|
+
const was = useRef(state);
|
|
348
|
+
const pressedAt = useRef(0);
|
|
349
|
+
const [fresh, setFresh] = useState(false);
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
const before = was.current;
|
|
352
|
+
was.current = state;
|
|
353
|
+
if (before !== "add" || state !== "added" || !ref.current) return;
|
|
354
|
+
const asked = Date.now() - pressedAt.current <= PRESS_ANSWERED_MS;
|
|
355
|
+
pressedAt.current = 0;
|
|
356
|
+
if (!asked) return;
|
|
357
|
+
const el = ref.current;
|
|
358
|
+
const frame = requestAnimationFrame(() => keepAddedInView(el, reducedMotion()));
|
|
359
|
+
setFresh(true);
|
|
360
|
+
const off = window.setTimeout(() => setFresh(false), JUST_ADDED_MS);
|
|
361
|
+
// Back to its line before the mark is gone (a refused write, a − at once): unmarked, not marked again by a later redraw (review).
|
|
362
|
+
return () => { cancelAnimationFrame(frame); window.clearTimeout(off); setFresh(false); };
|
|
363
|
+
}, [state]);
|
|
364
|
+
const press = (e: React.MouseEvent<HTMLButtonElement>) => { pressedAt.current = Date.now(); onAdd?.(e); };
|
|
254
365
|
const noteNode = note ? <small className="gemboss-ei-gh-note"> · {note}</small> : null;
|
|
255
366
|
if (state === "add") return (
|
|
256
|
-
<div className="gemboss-ei-grp gemboss-ei-addline" data-add-group={groupKey}
|
|
257
|
-
<button type="button" className="gemboss-ei-addhead" disabled={disabled} onClick={
|
|
367
|
+
<div ref={ref} className="gemboss-ei-grp gemboss-ei-addline" data-add-group={groupKey}>
|
|
368
|
+
<button type="button" className="gemboss-ei-addhead" disabled={disabled} onClick={press} aria-label={addLabel ?? `Add ${title.toLowerCase()}`}>
|
|
258
369
|
<span>{title}</span><span className="gemboss-ei-addplus" aria-hidden="true">+</span>
|
|
259
370
|
</button>
|
|
260
371
|
</div>
|
|
261
372
|
);
|
|
262
373
|
if (state === "open") return (
|
|
263
|
-
<div className="gemboss-ei-grp" data-open-group={groupKey} role="group" aria-label={label ?? title}>
|
|
374
|
+
<div ref={ref} className="gemboss-ei-grp" data-open-group={groupKey} role="group" aria-label={label ?? title}>
|
|
264
375
|
<div className="gemboss-ei-openhead" data-ei-head=""><span>{title}{noteNode}</span></div>
|
|
265
376
|
{children}
|
|
266
377
|
</div>
|
|
267
378
|
);
|
|
268
379
|
return (
|
|
269
|
-
<div className="gemboss-ei-grp" data-added-group={groupKey} role="group" aria-label={label ?? title}>
|
|
380
|
+
<div ref={ref} className="gemboss-ei-grp" data-added-group={groupKey} data-just-added={fresh ? "" : undefined} role="group" aria-label={label ?? title}>
|
|
270
381
|
<div className="gemboss-ei-addedhead" data-ei-head="">
|
|
271
382
|
<span>{title}{noteNode}</span>
|
|
272
383
|
{acts || remove ? (
|
|
@@ -46,9 +46,10 @@ export interface ItemsFieldProps {
|
|
|
46
46
|
touch?: boolean;
|
|
47
47
|
/** The controls' ids start with it (a host whose list is mounted twice). */
|
|
48
48
|
idPrefix?: string;
|
|
49
|
-
/** For a row's fields: the shop an app's kinds read, the media library, the app's kinds and glyphs.
|
|
49
|
+
/** For a row's fields: the shop an app's kinds read, the media library, the app's kinds and glyphs. A picture's "Library": `put` writes
|
|
50
|
+
* the one picked into the field of the row that asked, whenever the host's picker answers (that row by its key, wherever it moved). */
|
|
50
51
|
shopId?: string;
|
|
51
|
-
onPickImage?: (id: string, current: string) => void;
|
|
52
|
+
onPickImage?: (id: string, current: string, put: (url: string) => void) => void;
|
|
52
53
|
kinds?: FieldKinds;
|
|
53
54
|
glyphs?: FieldGlyphs;
|
|
54
55
|
}
|
|
@@ -170,7 +171,11 @@ export function ItemsField({ field, value, onChange, label, disabled, rowHolds,
|
|
|
170
171
|
const values = rowValues(row, fields);
|
|
171
172
|
return <>
|
|
172
173
|
<FieldRows fields={editable} values={values} disabled={disabled} idPrefix={`${prefix}-${key}-`}
|
|
173
|
-
shopId={shopId}
|
|
174
|
+
shopId={shopId} kinds={kinds} glyphs={glyphs}
|
|
175
|
+
onPickImage={onPickImage ? (id, current) => onPickImage(id, current, (url) => {
|
|
176
|
+
const f = fields.find((x) => x.id === id);
|
|
177
|
+
if (f) list.patch(key, (r) => withRowValue(r, f, url, fields) as never);
|
|
178
|
+
}) : undefined}
|
|
174
179
|
// By the row's KEY, onto its latest version (useKeyedRows.patch): a field that commits late changes the right row after a move.
|
|
175
180
|
onChange={(id, v) => {
|
|
176
181
|
const f = fields.find((x) => x.id === id);
|
package/src/editor/items.ts
CHANGED
|
@@ -10,8 +10,9 @@ import type { FieldSpec, RowFieldSpec } from "./field-spec";
|
|
|
10
10
|
/** A list setting's spec (FieldSpec `repeater`). */
|
|
11
11
|
export type ItemsSpec = Extract<FieldSpec, { kind: "repeater" }>;
|
|
12
12
|
/** One field of a row: the kit's or an app's kind; `from` names older keys the same value is stored under (read from the first that holds
|
|
13
|
-
* one, written back where it was read).
|
|
14
|
-
|
|
13
|
+
* one, written back where it was read). `nullish`: the older keys are read only where the field's own key is not set at all, as a
|
|
14
|
+
* reader that takes `heading ?? label` does: an emptied heading is the heading (empty), not the label under it. */
|
|
15
|
+
export type RowField = RowFieldSpec & { nullish?: boolean };
|
|
15
16
|
|
|
16
17
|
type Rec = Record<string, unknown>;
|
|
17
18
|
const isRecord = (v: unknown): v is Rec => !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -34,8 +35,15 @@ const wordsField = (fields: readonly RowField[]) => fields.find((f) => f.kind ==
|
|
|
34
35
|
export const IMAGE_URL_KEYS = ["url", "src", "image", "image_url"] as const;
|
|
35
36
|
const urlKeyOf = (o: Rec) => IMAGE_URL_KEYS.find((k) => typeof o[k] === "string");
|
|
36
37
|
|
|
37
|
-
/** Where a field's value is stored in an object row: the first of its id and its older keys the row holds
|
|
38
|
-
|
|
38
|
+
/** Where a field's value is stored in an object row: the first of its id and its older keys the row holds a value under (for a picture,
|
|
39
|
+
* an address: `image: []` beside `media: [url]` reads `media`, as a reader taking the first with a picture does), else its id. A
|
|
40
|
+
* `nullish` field: the first key SET, empty or not. */
|
|
41
|
+
const keyOf = (row: Rec, f: RowField) => {
|
|
42
|
+
const keys = [f.id, ...(f.from ?? [])];
|
|
43
|
+
if (f.nullish) return keys.find((k) => Object.hasOwn(row, k) && row[k] !== undefined && row[k] !== null) ?? f.id;
|
|
44
|
+
const holds = (v: unknown) => { const x = f.kind === "image" ? shown(f, v) : v; return !blank(typeof x === "string" && f.kind === "image" ? x.trim() : x); };
|
|
45
|
+
return keys.find((k) => Object.hasOwn(row, k) && holds(row[k])) ?? f.id;
|
|
46
|
+
};
|
|
39
47
|
|
|
40
48
|
/** A field's value as its control shows it: a picture's address (whatever shape holds it), any other value as stored. */
|
|
41
49
|
function shown(f: RowField, v: unknown): unknown {
|
|
@@ -57,18 +65,33 @@ export function rowValues(row: unknown, fields: readonly RowField[]): Rec {
|
|
|
57
65
|
* cannot show: drawn as text it read "[object Object]", and a save stored those words over it (#7081). */
|
|
58
66
|
const PLAIN = (v: unknown) => v === undefined || v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean";
|
|
59
67
|
|
|
60
|
-
/**
|
|
68
|
+
/** A picture object the control can change: its address under one of IMAGE_URL_KEYS, or no address key yet (`url` is added). */
|
|
69
|
+
const pictureObject = (v: unknown) => isRecord(v) && (urlKeyOf(v) !== undefined || !IMAGE_URL_KEYS.some((k) => k in v));
|
|
70
|
+
|
|
71
|
+
/** Whether a field of this row can be edited with its control without losing what is stored: a plain value, or a picture's address
|
|
72
|
+
* (alone, in an object beside its alt text, or the first of a list of them: a slide's `media: [url]`). */
|
|
61
73
|
export function rowFieldEditable(row: unknown, f: RowField): boolean {
|
|
62
74
|
if (typeof row === "string" || !isRecord(row)) return true;
|
|
63
75
|
const v = row[keyOf(row, f)];
|
|
64
|
-
if (f.kind === "image") return PLAIN(v) || (
|
|
76
|
+
if (f.kind === "image") return PLAIN(v) || pictureObject(v) || (Array.isArray(v) && v.every((x) => typeof x === "string" || pictureObject(x)));
|
|
65
77
|
return PLAIN(v);
|
|
66
78
|
}
|
|
67
79
|
|
|
80
|
+
/** A list of pictures with the one the row shows (its first with an address) at `url`: that one keeps its shape (an address stays an
|
|
81
|
+
* address, an object keeps its alt text), every other one stays; emptied, that one comes off. None with an address: `url` goes first. */
|
|
82
|
+
function withFirstPicture(list: readonly unknown[], f: RowField, url: unknown): unknown[] {
|
|
83
|
+
const at = list.findIndex((x) => !blank(shown(f, x)));
|
|
84
|
+
if (at < 0) return blank(url) ? [...list] : [url, ...list];
|
|
85
|
+
if (blank(url)) return list.filter((_x, i) => i !== at);
|
|
86
|
+
const was = list[at];
|
|
87
|
+
return list.map((x, i) => (i !== at ? x : isRecord(was) ? { ...was, [urlKeyOf(was) ?? "url"]: url } : url));
|
|
88
|
+
}
|
|
89
|
+
|
|
68
90
|
/**
|
|
69
91
|
* The row with one field changed, everything else as stored:
|
|
70
92
|
* · an object keeps every other key, the field written under the key it was read from (an older name stays that name);
|
|
71
93
|
* · a picture stored as an object keeps its alt text and the rest, the address written under the key it was read from (`url` else);
|
|
94
|
+
* · a picture that is the first of a list (`media: [url, …]`) is replaced in its place, the list and its other pictures kept;
|
|
72
95
|
* · a string row stays a string while it is the words that change; another field turns it into an object holding both;
|
|
73
96
|
* · emptying a field the row does not hold changes nothing (empty and unset are one value).
|
|
74
97
|
*/
|
|
@@ -84,6 +107,7 @@ export function withRowValue(row: unknown, f: RowField, value: unknown, fields:
|
|
|
84
107
|
if (blank(value) && !Object.hasOwn(base, key)) return row;
|
|
85
108
|
const was = base[key];
|
|
86
109
|
if (f.kind === "image" && isRecord(was)) return { ...base, [key]: { ...was, [urlKeyOf(was) ?? "url"]: value } };
|
|
110
|
+
if (f.kind === "image" && Array.isArray(was)) return { ...base, [key]: withFirstPicture(was, f, value) };
|
|
87
111
|
return { ...base, [key]: value };
|
|
88
112
|
}
|
|
89
113
|
|
package/src/editor/panel.tsx
CHANGED
|
@@ -96,7 +96,8 @@ export function PanelTabs<T extends string = string>({ tabs, value, onChange, va
|
|
|
96
96
|
export interface PanelHeaderProps {
|
|
97
97
|
/** What the panel edits (a section's name). */
|
|
98
98
|
title: React.ReactNode;
|
|
99
|
-
/** The line under it,
|
|
99
|
+
/** The line under it, muted, in words: what the panel edits and where it is ("Section · Home", "in Image with text"), never a
|
|
100
|
+
* type's slug (Chris 10/11/2026). Drawn whenever it is not undefined. */
|
|
100
101
|
subtitle?: React.ReactNode;
|
|
101
102
|
/** Icon buttons after the title: `PanelAction`s. The first sits at the right edge's start (margin-left: auto). */
|
|
102
103
|
actions?: React.ReactNode;
|
|
@@ -104,14 +105,12 @@ export interface PanelHeaderProps {
|
|
|
104
105
|
onClose?: () => void;
|
|
105
106
|
/** The close button's accessible name. Default "Close". */
|
|
106
107
|
closeLabel?: string;
|
|
107
|
-
/** A floating panel's grab handle: adds `.gemboss-ei-drag` (grab cursor) and takes the mouse-down that starts a drag. */
|
|
108
|
-
onDragStart?: React.MouseEventHandler<HTMLElement>;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
/** `header.gemboss-ei-head`: title (+ subtitle) · actions · ✕. */
|
|
112
|
-
export function PanelHeader({ title, subtitle, actions, onClose, closeLabel = "Close"
|
|
111
|
+
export function PanelHeader({ title, subtitle, actions, onClose, closeLabel = "Close" }: PanelHeaderProps) {
|
|
113
112
|
return (
|
|
114
|
-
<header className=
|
|
113
|
+
<header className="gemboss-ei-head">
|
|
115
114
|
<span className="gemboss-ei-title">
|
|
116
115
|
{title}
|
|
117
116
|
{subtitle !== undefined ? <small>{subtitle}</small> : null}
|
package/src/editor-grow.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
textarea.gemboss-field.gemboss-ei-
|
|
1
|
+
textarea.gemboss-field.gemboss-ei-grow{resize:none;overflow:hidden;field-sizing:content}textarea.gemboss-field.gemboss-ei-code-line{overflow-wrap:anywhere}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.gemboss-ei-frame{display:contents}.gemboss-ei-find{margin-bottom:8px}.gemboss-ei-index{display:flex;flex-wrap:wrap;align-items:
|
|
1
|
+
.gemboss-ei-frame{display:contents}.gemboss-ei-find{margin-bottom:8px}.gemboss-ei-bar{position:sticky;top:0;z-index:3;display:flex;align-items:stretch;gap:4px;min-height:36px;margin:0 0 8px;background:var(--gemboss-panel-bg,var(--gemboss-surface,#fff));border-bottom:1px solid var(--gemboss-divider-soft);box-shadow:calc(-1*var(--gemboss-ec-inset,16px)) 0 0 0 var(--gemboss-panel-bg,var(--gemboss-surface,#fff)),var(--gemboss-ec-inset,16px) 0 0 0 var(--gemboss-panel-bg,var(--gemboss-surface,#fff))}.gemboss-ei-index{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:stretch;gap:0;margin:0}.gemboss-ei-index-link{flex:none;min-height:36px;margin-bottom:-1px;padding:0 6px;border:0;border-bottom:2px solid transparent;border-radius:0;background:none;font:inherit;font-size:12px;line-height:16px;color:var(--gemboss-text-muted);cursor:pointer;white-space:nowrap}.gemboss-ei-index-link:hover{color:var(--gemboss-text)}.gemboss-ei-index-link:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:-2px;border-radius:4px}.gemboss-ei-index-link[aria-current]{color:var(--gemboss-text);font-weight:600;border-bottom-color:var(--gemboss-text)}.gemboss-ei-bar-btn{align-self:center;display:grid;place-items:center;flex:none;width:28px;height:28px;padding:0;border:0;border-radius:6px;background:none;color:var(--gemboss-text-muted);cursor:pointer}.gemboss-ei-bar-btn:hover{background:var(--gemboss-hover);color:var(--gemboss-text)}.gemboss-ei-bar-btn:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:2px}.gemboss-ei-bar-find{flex:1;min-width:0;display:flex;align-items:center;gap:4px;padding:4px 0}.gemboss-ei-bar-find>.gemboss-ei-find{flex:1;min-width:0;margin:0}.gemboss-ei-bar:not([data-tabs]){border-bottom:0}.gemboss-ei-cluster{display:block;position:relative;height:calc(var(--gemboss-ei-gap-group,16px)*2 + 1px);margin:0}.gemboss-ei-cluster--first{height:0}.gemboss-ei-cluster-name{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.gemboss-ei-part{display:contents}.gemboss-ei-part>.gemboss-ei-grp:last-child{border-bottom:1px solid var(--gemboss-divider-soft)}.gemboss-ei-part:last-child>.gemboss-ei-grp:last-child{border-bottom:none}.gemboss-ei-part[hidden],.gemboss-ei-index[hidden],.gemboss-ei-cluster[hidden],.gemboss-ei-bar-find[hidden],.gemboss-ei-bar-btn[hidden]{display:none}.gemboss-ei-addhead{display:flex;align-items:center;justify-content:space-between;width:100%;min-height:28px;padding:0;border:0;background:none;font:inherit;font-size:13px;line-height:20px;color:var(--gemboss-text-muted);cursor:pointer;text-align:left}.gemboss-ei-addhead:hover{color:var(--gemboss-text)}.gemboss-ei-addhead:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:2px;border-radius:4px}.gemboss-ei-addhead:disabled{cursor:default}.gemboss-ei-addplus{display:grid;place-items:center;width:24px;height:24px;border-radius:8px;font-size:16px;line-height:1}.gemboss-ei-addline .gemboss-ei-addhead{width:calc(100% + 16px);margin-inline:-8px;padding-inline:8px;border-radius:8px}.gemboss-ei-addline .gemboss-ei-addhead:hover:not(:disabled){background:var(--gemboss-hover)}.gemboss-ei-addline .gemboss-ei-addhead:active:not(:disabled){background:var(--gemboss-active-bg)}.gemboss-ei-grp.gemboss-ei-addline{padding:4px 0}.gemboss-ei-addedhead{display:flex;align-items:center;justify-content:space-between;gap:6px;min-height:28px;font-size:13px;line-height:20px;font-weight:650;color:var(--gemboss-text)}.gemboss-ei-openhead{font-size:13px;line-height:20px;font-weight:650;color:var(--gemboss-text)}.gemboss-ei-headacts{display:flex;align-items:center;gap:4px}.gemboss-ei-addsign{display:grid;place-items:center;flex:none;width:24px;height:24px;padding:0;border:0;border-radius:8px;background:none;font:inherit;font-size:16px;font-weight:400;line-height:1;color:var(--gemboss-text-muted);cursor:pointer}.gemboss-ei-addsign:hover{background:var(--gemboss-hover);color:var(--gemboss-text)}.gemboss-ei-addsign:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:2px}.gemboss-ei-addsign:active:not(:disabled){background:var(--gemboss-active-bg)}.gemboss-ei-addsign:disabled{cursor:default;opacity:.5}@media (pointer: coarse),(max-width:47.9975em){.gemboss-ei-index-link{min-width:44px;min-height:44px}.gemboss-ei-bar-btn{width:44px;height:44px}.gemboss-ei-addhead,.gemboss-ei-addedhead{min-height:44px}.gemboss-ei-addsign{width:44px;height:44px}.gemboss-ei-grp.gemboss-ei-addline{padding:2px 0}}.gemboss-ei-grp[data-just-added]{border-radius:8px;animation:gemboss-ei-just-added 1.2s ease-out}@keyframes gemboss-ei-just-added{0%{background:color-mix(in srgb,var(--ui-focus,#5661f5) 9%,transparent);box-shadow:0 0 0 8px color-mix(in srgb,var(--ui-focus,#5661f5) 9%,transparent)}to{background:transparent;box-shadow:0 0 0 8px transparent}}@media (prefers-reduced-motion:reduce){.gemboss-ei-grp[data-just-added]{animation:none}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-ei-img-thumb[data-thumb=empty]{border-style:dashed;border-color:var(--gemboss-field-line)}.gemboss-ei-img-thumb[data-thumb=empty],.gemboss-ei-img-thumb[data-thumb=held],.gemboss-ei-img-thumb[data-thumb=broken],.gemboss-ei-img-thumb[data-thumb=busy]{background-color:var(--gemboss-hover)}.gemboss-ei-img-thumb[data-thumb=image]{background:var(--gemboss-thumb) center/cover no-repeat,repeating-conic-gradient(var(--gemboss-divider-soft) 0 25%,var(--gemboss-surface) 0 50%) 0 0/12px 12px}.gemboss-ei-img-spin{width:16px;height:16px;border:2px solid var(--gemboss-divider-soft);border-top-color:var(--gemboss-primary);border-radius:50%;box-shadow:0 0 0 4px var(--gemboss-surface);animation:gemboss-ei-img-spin .7s linear infinite}@keyframes gemboss-ei-img-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.gemboss-ei-img-spin{animation:none}}.gemboss-ei-img-thumb{--gemboss-thumb-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='15' rx='2'/%3E%3Ccircle cx='9' cy='9.5' r='1.5'/%3E%3Cpath d='m20 15-4.5-4.5L6 19.5'/%3E%3C/svg%3E")}.gemboss-ei-img-thumb[data-glyph=video]{--gemboss-thumb-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5.5' width='13' height='13' rx='2'/%3E%3Cpath d='m16 10 5-3v10l-5-3z'/%3E%3C/svg%3E")}.gemboss-ei-img-thumb[data-thumb=broken]{--gemboss-thumb-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='15' rx='2'/%3E%3Ccircle cx='9' cy='9.5' r='1.5'/%3E%3Cpath d='m20 15-4.5-4.5L6 19.5'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E")}.gemboss-ei-img-thumb[data-thumb=empty]:before,.gemboss-ei-img-thumb[data-thumb=held]:before,.gemboss-ei-img-thumb[data-thumb=broken]:before{content:"";width:20px;height:20px;background:currentColor;-webkit-mask:var(--gemboss-thumb-glyph) center/contain no-repeat;mask:var(--gemboss-thumb-glyph) center/contain no-repeat}
|
package/src/editor-plain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(k){"use strict";var g=k.gembossUI;if(!g){k.console&&k.console.error("@gemboss/ui editor-plain.js: load kit-plain.js first (it defines gembossUI)");return}if(g.initEditorFrame)return;var C=5,j=360,w=typeof WeakSet=="function"?new WeakSet:null,u=function(t,e,r){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},N=function(t,e){var r=Number(t);return isFinite(r)&&r>0?r:e};function d(t){return t.querySelector(".gemboss-editor-body")}function m(t){var e=d(t);return e&&e.querySelector(":scope > .gemboss-editor-resizer")}function h(t){var e=m(t);return{min:N(e&&e.getAttribute("aria-valuemin"),300),cap:N(e&&(e.getAttribute("data-gb-max")||e.getAttribute("aria-valuemax")),680)}}function M(t){var e=h(t),r=d(t),a=r?r.getBoundingClientRect().width:0;return a>0?Math.max(e.min,Math.min(e.cap,a-j-C)):e.cap}var S=typeof WeakMap=="function"?new WeakMap:null;function P(t){var e=S?S.get(t):t._gbWant;return e??E(t)}function I(t,e){S?S.set(t,e):t._gbWant=e}function v(t,e,r,a){var i=d(t),n=m(t);if(i){var s=a??M(t),l=h(t),o=Math.round(Math.min(s,Math.max(l.min,e)));if(i.style.setProperty("--gemboss-chat-w",o+"px"),n&&(n.setAttribute("aria-valuenow",String(o)),n.setAttribute("aria-valuemax",String(s))),r){I(t,o);var f=i.getAttribute("data-gb-storage");if(f)try{localStorage.setItem(f,String(o))}catch{}u(t,"gemboss:editor-split",{width:o})}return o}}function E(t){var e=m(t);return N(e&&e.getAttribute("aria-valuenow"),384)}function H(t){var e=d(t),r=m(t);if(!(!e||!r)){r.hasAttribute("data-gb-max")||r.setAttribute("data-gb-max",r.getAttribute("aria-valuemax")||"680");var a=e.getAttribute("data-gb-storage"),i=E(t);if(a)try{var n=Number(localStorage.getItem(a));n>=h(t).min&&n<=h(t).cap&&(i=n)}catch{}I(t,i),e.classList.contains("is-chat-collapsed")||v(t,i,!1)}}function G(t,e){var r=d(t);if(r&&!(e.button!==0||e.isPrimary===!1)){e.preventDefault();var a=r.getBoundingClientRect().left,i=M(t),n=0,s=E(t);document.body.classList.add("ui-resizing");var l=function(f){s=f.clientX-a-C,n||(n=requestAnimationFrame(function(){n=0,v(t,s,!1,i)}))},o=function(){n&&cancelAnimationFrame(n),document.body.classList.remove("ui-resizing"),removeEventListener("pointermove",l),removeEventListener("pointerup",o),removeEventListener("pointercancel",o),removeEventListener("blur",o),v(t,s,!0,i)};addEventListener("pointermove",l),addEventListener("pointerup",o),addEventListener("pointercancel",o),addEventListener("blur",o)}}function V(t,e){if(!(e.altKey||e.metaKey||e.ctrlKey)){var r=e.shiftKey?64:16,a=E(t),i=h(t);if(e.key==="ArrowLeft")a-=r;else if(e.key==="ArrowRight")a+=r;else if(e.key==="Home")a=i.min;else if(e.key==="End")a=M(t);else return;e.preventDefault(),v(t,a,!0)}}function X(t,e){var r=d(t);if(r){var a=!r.classList.contains("is-chat-collapsed");r.classList.toggle("is-chat-collapsed",a),a?r.style.setProperty("--gemboss-chat-w","0px"):v(t,P(t),!1),e.classList.toggle("collapsed",a),e.setAttribute("aria-pressed",String(a)),e.setAttribute("aria-label",a?"Show chat panel":"Hide chat panel"),e.title=a?"Show chat panel":"Hide chat \u2014 full-width preview";var i=e.querySelector("rect[fill='currentColor']");i&&(i.style.display=a?"none":""),u(t,"gemboss:editor-chat",{collapsed:a})}}function J(t,e){var r=e.closest(".gemboss-pv-devices");r&&(r.querySelectorAll(".gemboss-pv-device").forEach(function(a){var i=a===e;a.classList.toggle("active",i),a.setAttribute("aria-pressed",String(i))}),u(t,"gemboss:editor-device",{device:e.getAttribute("data-device")||(e.title||"").toLowerCase()}))}function Q(t,e){var r=e.getAttribute("data-pane")||(Array.prototype.indexOf.call(e.parentNode.children,e)===0?"chat":"preview"),a=d(t);a&&(a.setAttribute("data-mobile-pane",r),e.parentNode.querySelectorAll(".gemboss-editor-mobile-tab").forEach(function(i){var n=i===e;i.classList.toggle("active",n),i.setAttribute("aria-selected",String(n))}),u(t,"gemboss:editor-pane",{pane:r}))}var c=null;function O(t){var e=t.trigger.getBoundingClientRect();t.menu.style.top=e.bottom+6+"px",t.menu.style.right=Math.max(8,innerWidth-e.right)+"px";var r=t.menu.getBoundingClientRect(),a=e.right-r.right;r.left+a<8&&(a=8-r.left),Math.abs(a)>=.5&&(t.menu.style.right=parseFloat(t.menu.style.right)-a+"px")}function y(t){var e=c;e&&(c=null,e.menu.hidden=!0,e.trigger.setAttribute("aria-expanded","false"),e.trigger.classList.remove("active"),t&&e.trigger.focus(),u(e.root,"gemboss:editor-menu",{open:!1,menu:e.menu}))}function Y(t,e){var r=e.nextElementSibling;if(!r||!r.classList.contains("gemboss-editor-menu"))return!1;var a=c&&c.trigger===e;return y(!1),a||(c={root:t,trigger:e,menu:r},r.hidden=!1,e.setAttribute("aria-expanded","true"),e.classList.add("active"),O(c),u(t,"gemboss:editor-menu",{open:!0,menu:r})),!0}var T=!1;function Z(){T||(T=!0,document.addEventListener("pointerdown",function(t){c&&!c.menu.contains(t.target)&&!c.trigger.contains(t.target)&&y(!1)}),addEventListener("keydown",function(t){t.key!=="Escape"||!c||t.isComposing||t.keyCode===229||(t.preventDefault(),t.stopImmediatePropagation(),y(!0))},!0),addEventListener("resize",function(){c&&O(c)}),addEventListener("blur",function(){y(!1)}))}function ee(t){var e=t&&t.classList&&t.classList.contains("gemboss-editor")?[t]:Array.prototype.slice.call((t||document).querySelectorAll(".gemboss-editor"));return Z(),e.forEach(function(r){if(!(w?w.has(r):r._gbEditor)){w?w.add(r):r._gbEditor=!0,H(r);var a=d(r);a&&typeof ResizeObserver=="function"&&new ResizeObserver(function(){a.classList.contains("is-chat-collapsed")||v(r,P(r),!1)}).observe(a),r.addEventListener("pointerdown",function(i){var n=i.target.closest(".gemboss-editor-resizer");n&&n===m(r)&&G(r,i)}),r.addEventListener("keydown",function(i){i.target.classList&&i.target.classList.contains("gemboss-editor-resizer")&&i.target===m(r)&&V(r,i)}),r.addEventListener("click",function(i){var n=i.target,s;if(s=n.closest(".gemboss-editor-chat-toggle"))return X(r,s);if(s=n.closest(".gemboss-pv-devices .gemboss-pv-device"))return J(r,s);if(s=n.closest(".gemboss-editor-mobile-tab"))return Q(r,s);if((s=n.closest('[aria-haspopup="menu"]'))&&Y(r,s)){i.stopPropagation();return}c&&(s=n.closest(".gemboss-editor-menu-item"))&&c.menu.contains(s)&&y(!0)})}}),e.length}g.initEditorFrame=ee;function b(t){if(!t||t!==t.trim())return null;var e=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t),r,a,i,n;if(e){var s=e[1].length<=4?e[1].replace(/./g,"$&$&"):e[1];return n=function(de){return parseInt(s.substr(de,2),16)},{r:n(0),g:n(2),b:n(4),a:s.length===8?Math.round(n(6)/255*1e3)/1e3:1}}if(r=/^rgba?\(\s*([^()]*?)\s*\)$/i.exec(t),!r)return null;var l=r[1].split("/");if(a=l[0].indexOf(",")>=0?l[0].split(","):l[0].trim().split(/\s+/),l.length===2&&a.push(l[1]),l.length>2||a.length<3||a.length>4)return null;var o=[];for(i=0;i<a.length;i++){var f=a[i].trim(),p=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?%?$/i.test(f)?parseFloat(f):f==="none"?0:NaN;if(isNaN(p))return null;/%$/.test(f)&&(p=p/100*(i<3?255:1)),o.push(i<3?Math.min(255,Math.max(0,Math.round(p))):Math.min(1,Math.max(0,p)))}return{r:o[0],g:o[1],b:o[2],a:o.length===4?o[3]:1}}function q(t){return"#"+[t.r,t.g,t.b].map(function(e){return(e<16?"0":"")+e.toString(16)}).join("")}function B(t,e,r){return r<1?"rgba("+e.r+", "+e.g+", "+e.b+", "+Math.round(r*100)/100+")":/^#/.test(t)||!t?q(e):"rgb("+e.r+", "+e.g+", "+e.b+")"}function W(t,e){var r=b(e),a=b(t);return r?B(t,r,a?a.a:1):t}function _(t,e){var r=b(t);return r&&isFinite(e)?B(t,r,Math.min(100,Math.max(0,Math.round(e)))/100):t}g.colorOf=b,g.pickSwatch=W,g.withOpacity=_;var $=function(t){var e=t.getAttribute("data-value");return e??(t.textContent||"").trim()},R=function(t){return Array.prototype.filter.call(t.children,function(e){return e.getAttribute("role")==="tab"})};function z(t,e){var r=t.parentNode,a=R(r),i=a.some(function(n){return n.hasAttribute("tabindex")});a.forEach(function(n){var s=n===t;n.setAttribute("aria-selected",String(s)),n.classList.contains("gemboss-ei-tab")&&n.classList.toggle("on",s),i&&n.setAttribute("tabindex",s?"0":"-1");var l=n.getAttribute("aria-controls"),o=l&&document.getElementById(l);o&&(o.hidden=!s)}),e&&t.focus(),u(t,"gemboss:editor-tab",{tab:$(t),index:a.indexOf(t)})}function te(t,e){if(!(e.key!=="ArrowRight"&&e.key!=="ArrowLeft")){var r=R(t);if(r.some(function(n){return n.hasAttribute("tabindex")})){var a=r.findIndex(function(n){return n.getAttribute("aria-selected")==="true"}),i=e.key==="ArrowRight"?(a+1)%r.length:(a-1+r.length)%r.length;e.preventDefault(),z(r[i],!0)}}}function re(t){var e=t.getAttribute("data-open")!=="open";t.setAttribute("data-open",e?"open":"closed"),t.setAttribute("aria-expanded",String(e));var r=t.querySelector(".gemboss-ei-chev");r&&(r.textContent=e?"\u25BE":"\u25B8"),u(t,"gemboss:editor-group",{open:e})}function ae(t){var e=t.closest(".gemboss-ei-seg");Array.prototype.forEach.call(e.querySelectorAll("button"),function(r){var a=r===t;r.classList.toggle("active",a),r.classList.toggle("on",a),r.hasAttribute("aria-pressed")&&r.setAttribute("aria-pressed",String(a))}),u(e,"gemboss:editor-seg",{value:$(t)})}var ie={text:"Text",accent:"Accent","accent-text":"Accent text",muted:"Muted",background:"Background",surface:"Surface",border:"Border",success:"Success",warning:"Warning",danger:"Danger"},ne=0;function F(t){return ie[t]||t.charAt(0).toUpperCase()+t.slice(1).replace(/-/g," ")}function se(t){var e=t.trim(),r=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(e);if(r)return"Theme color: "+F(r[1].toLowerCase())+". Type a color to use your own.";if(/^var\(/i.test(e))return"A theme value. Type a color to use your own.";var a=oe(e);return a?"A mix of "+a.replace(" + "," and ")+", half of each. Type a color to use your own.":/^color-mix\(/i.test(e)?"A mix of colors. Type a color to use your own.":"Kept as written: the swatch shows one color (hex, rgb, hsl or oklch), not a gradient or a name."}var D="(var\\([^()]*\\)|[^,()]+(?:\\([^()]*\\))?)";function oe(t){var e=new RegExp("^color-mix\\(\\s*in\\s+srgb\\s*,"+D+","+D+"\\)$","i").exec(t);function r(n){n=n.trim();var s=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(n);return s?F(s[1].toLowerCase()):b(n)||/^(hsla?|oklch)\([^()]*\)$/i.test(n)?n:null}var a=e&&r(e[1]),i=e&&r(e[2]);return a&&i?a+" + "+i:null}function A(t){var e=t.querySelector(".gemboss-ei-swatch"),r=t.querySelector("input:not([type=color]):not([data-alpha])");if(!(!e||!r)){var a=r.value,i=b(a),n=!a||!!i;if(e.tagName==="BUTTON"){var s=e.querySelector(".gemboss-ei-swatch-fill");s&&(i?s.style.setProperty("--sw","rgba("+i.r+", "+i.g+", "+i.b+", "+i.a+")"):s.style.removeProperty("--sw")),a?e.removeAttribute("data-empty"):e.setAttribute("data-empty","")}else e.value=i?q(i):"#000000";var l=t.querySelector("input[data-alpha]");i&&!l&&(l=document.createElement("input"),l.className=r.className,l.setAttribute("data-alpha",""),l.setAttribute("inputmode","numeric"),l.setAttribute("aria-label",(e.getAttribute("aria-label")||"Color swatch").replace(/ swatch$/,"")+" opacity"),(t.querySelector(".gemboss-ei-color-group")||t).appendChild(l)),l&&(l.hidden=!i,i&&(l.value=Math.round(i.a*100)+"%"),l.disabled=r.disabled),e.disabled=r.disabled||!n;var o=t.querySelector(".gemboss-ei-color-why");if(n){e.removeAttribute("title"),e.removeAttribute("aria-describedby"),o&&o.parentNode.removeChild(o);return}var f=se(a);e.title=f,o||(o=document.createElement("p"),o.className="gemboss-ei-color-why",t.appendChild(o)),o.id||(o.id="gemboss-ei-color-why-"+ ++ne),o.textContent=f,e.setAttribute("aria-describedby",o.id)}}function le(t){for(var e=t.labels||[],r=null,a=0;a<e.length&&!r;a++)r=e[a].querySelector(".gemboss-ei-rangeval");r&&(r.textContent=t.value+(r.getAttribute("data-suffix")||""))}function ue(t){var e={},r=["t","r","b","l"];return Array.prototype.forEach.call(t.querySelectorAll("input"),function(a,i){e[r[i]]=a.value.trim()}),e}function U(t){return'url("'+t.replace(/["\\]/g,"\\$&").replace(/[\u0000-\u001f\u007f]/g,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})+'")'}g.cssUrl=U;function ce(t,e){var r=t.querySelector(".gemboss-ei-img-thumb");r&&(r.style.backgroundImage=e?U(e):"",r.textContent=e?"":"\u2014")}function K(t,e){var r=t.getAttribute("data-gb-value")!=null?t.getAttribute("data-gb-value"):e.defaultValue;e.value!==r&&(t.setAttribute("data-gb-value",e.value),ce(t,e.value),u(t,"gemboss:editor-image",{value:e.value}))}var L=typeof WeakSet=="function"?new WeakSet:null,x=function(t){return t.__gbPanel?!1:(t.__gbPanel=!0,!0)};function fe(t){var e=t.closest(".gemboss-ei-color");if(e){var r=e.querySelector("input:not([type=color]):not([data-alpha])"),a=e.querySelector("input[data-gb-swatch-native]");a||(a=document.createElement("input"),a.type="color",a.setAttribute("data-gb-swatch-native",""),a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;width:1px;height:1px;opacity:0;pointer-events:none",t.parentNode.insertBefore(a,t.nextSibling));var i=r&&b(r.value);a.value=i?q(i):"#ffffff";try{a.showPicker?a.showPicker():a.click()}catch{a.click()}}}function ge(t){var e=t||document;return(L?L.has(e):e._gbPanel)?0:(L?L.add(e):e._gbPanel=!0,Array.prototype.forEach.call(e.querySelectorAll(".gemboss-ei-color"),A),e.addEventListener("click",function(r){var a=r.target,i;if(!(!a.closest||!x(r))){if(i=a.closest('.gemboss-ec-tabs > [role="tab"], .gemboss-ei-tabs > [role="tab"]'))return z(i,!1);if(i=a.closest(".gemboss-ei-gh"))return re(i);if((i=a.closest(".gemboss-ei-seg button"))&&!i.disabled)return ae(i);if((i=a.closest("button.gemboss-ei-swatch"))&&!i.disabled)return fe(i);if((i=a.closest("[data-gb-image-clear]"))&&!i.disabled){var n=i.closest(".gemboss-ei-img"),s=n&&n.querySelector(".gemboss-ei-img-ctl input");s&&(s.value="",K(n,s))}}}),e.addEventListener("keydown",function(r){var a=r.target;if(!(!a.closest||!x(r))){var i=a.closest('.gemboss-ec-tabs[role="tablist"], .gemboss-ei-tabs[role="tablist"]');if(i&&a.getAttribute("role")==="tab")return te(i,r);r.key==="Enter"&&a.tagName==="INPUT"&&a.type!=="color"&&a.type!=="range"&&a.closest(".gemboss-ei-color, .gemboss-ei-edgebox, .gemboss-ei-img")&&(r.preventDefault(),a.blur())}}),e.addEventListener("input",function(r){var a=r.target;if(!(!a.closest||!x(r))){if(a.classList.contains("gemboss-ei-range")){le(a),u(a,"gemboss:editor-range",{value:Number(a.value)});return}if(a.classList.contains("gemboss-ei-swatch")||a.hasAttribute("data-gb-swatch-native")){var i=a.closest(".gemboss-ei-color"),n=i&&i.querySelector("input:not([type=color]):not([data-alpha])"),s=n?W(n.value,a.value):a.value;n&&(n.value=s),i&&a.hasAttribute("data-gb-swatch-native")&&A(i),u(i||a,"gemboss:editor-color",{value:s})}}}),e.addEventListener("focusout",function(r){var a=r.target;if(!(!a.closest||a.tagName!=="INPUT"||!x(r))){var i;if(a.hasAttribute("data-alpha")&&(i=a.closest(".gemboss-ei-color"))){var n=i.querySelector("input:not([type=color]):not([data-alpha])"),s=Number(String(a.value).replace(/%/g,"").trim()),l=n&&String(a.value).trim()&&isFinite(s)?_(n.value,s):null;l&&l!==n.value?(n.value=l,A(i),u(i,"gemboss:editor-color",{value:l})):A(i);return}if(a.type!=="color"&&(i=a.closest(".gemboss-ei-color"))){A(i),u(i,"gemboss:editor-color",{value:a.value});return}if(i=a.closest(".gemboss-ei-edgebox")){u(i,"gemboss:editor-edges",ue(i));return}(i=a.closest(".gemboss-ei-img"))&&K(i,a)}}),1)}g.initEditorPanel=ge})(typeof globalThis<"u"?globalThis:this);
|
|
1
|
+
(function(k){"use strict";var g=k.gembossUI;if(!g){k.console&&k.console.error("@gemboss/ui editor-plain.js: load kit-plain.js first (it defines gembossUI)");return}if(g.initEditorFrame)return;var K=5,j=360,w=typeof WeakSet=="function"?new WeakSet:null,u=function(t,e,r){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},N=function(t,e){var r=Number(t);return isFinite(r)&&r>0?r:e};function d(t){return t.querySelector(".gemboss-editor-body")}function m(t){var e=d(t);return e&&e.querySelector(":scope > .gemboss-editor-resizer")}function h(t){var e=m(t);return{min:N(e&&e.getAttribute("aria-valuemin"),300),cap:N(e&&(e.getAttribute("data-gb-max")||e.getAttribute("aria-valuemax")),680)}}function M(t){var e=h(t),r=d(t),a=r?r.getBoundingClientRect().width:0;return a>0?Math.max(e.min,Math.min(e.cap,a-j-K)):e.cap}var S=typeof WeakMap=="function"?new WeakMap:null;function q(t){var e=S?S.get(t):t._gbWant;return e??E(t)}function P(t,e){S?S.set(t,e):t._gbWant=e}function v(t,e,r,a){var i=d(t),n=m(t);if(i){var s=a??M(t),l=h(t),o=Math.round(Math.min(s,Math.max(l.min,e)));if(i.style.setProperty("--gemboss-chat-w",o+"px"),n&&(n.setAttribute("aria-valuenow",String(o)),n.setAttribute("aria-valuemax",String(s))),r){P(t,o);var f=i.getAttribute("data-gb-storage");if(f)try{localStorage.setItem(f,String(o))}catch{}u(t,"gemboss:editor-split",{width:o})}return o}}function E(t){var e=m(t);return N(e&&e.getAttribute("aria-valuenow"),384)}function H(t){var e=d(t),r=m(t);if(!(!e||!r)){r.hasAttribute("data-gb-max")||r.setAttribute("data-gb-max",r.getAttribute("aria-valuemax")||"680");var a=e.getAttribute("data-gb-storage"),i=E(t);if(a)try{var n=Number(localStorage.getItem(a));n>=h(t).min&&n<=h(t).cap&&(i=n)}catch{}P(t,i),e.classList.contains("is-chat-collapsed")||v(t,i,!1)}}function G(t,e){var r=d(t);if(r&&!(e.button!==0||e.isPrimary===!1)){e.preventDefault();var a=r.firstElementChild.getBoundingClientRect().left,i=M(t),n=0,s=E(t);document.body.classList.add("ui-resizing");var l=function(f){s=f.clientX-a,n||(n=requestAnimationFrame(function(){n=0,v(t,s,!1,i)}))},o=function(){n&&cancelAnimationFrame(n),document.body.classList.remove("ui-resizing"),removeEventListener("pointermove",l),removeEventListener("pointerup",o),removeEventListener("pointercancel",o),removeEventListener("blur",o),v(t,s,!0,i)};addEventListener("pointermove",l),addEventListener("pointerup",o),addEventListener("pointercancel",o),addEventListener("blur",o)}}function V(t,e){if(!(e.altKey||e.metaKey||e.ctrlKey)){var r=e.shiftKey?64:16,a=E(t),i=h(t);if(e.key==="ArrowLeft")a-=r;else if(e.key==="ArrowRight")a+=r;else if(e.key==="Home")a=i.min;else if(e.key==="End")a=M(t);else return;e.preventDefault(),v(t,a,!0)}}function X(t,e){var r=d(t);if(r){var a=!r.classList.contains("is-chat-collapsed");r.classList.toggle("is-chat-collapsed",a),a?r.style.setProperty("--gemboss-chat-w","0px"):v(t,q(t),!1),e.classList.toggle("collapsed",a),e.setAttribute("aria-pressed",String(a)),e.setAttribute("aria-label",a?"Show chat panel":"Hide chat panel"),e.title=a?"Show chat panel":"Hide chat \u2014 full-width preview";var i=e.querySelector("rect[fill='currentColor']");i&&(i.style.display=a?"none":""),u(t,"gemboss:editor-chat",{collapsed:a})}}function J(t,e){var r=e.closest(".gemboss-pv-devices");r&&(r.querySelectorAll(".gemboss-pv-device").forEach(function(a){var i=a===e;a.classList.toggle("active",i),a.setAttribute("aria-pressed",String(i))}),u(t,"gemboss:editor-device",{device:e.getAttribute("data-device")||(e.title||"").toLowerCase()}))}function Q(t,e){var r=e.getAttribute("data-pane")||(Array.prototype.indexOf.call(e.parentNode.children,e)===0?"chat":"preview"),a=d(t);a&&(a.setAttribute("data-mobile-pane",r),e.parentNode.querySelectorAll(".gemboss-editor-mobile-tab").forEach(function(i){var n=i===e;i.classList.toggle("active",n),i.setAttribute("aria-selected",String(n))}),u(t,"gemboss:editor-pane",{pane:r}))}var c=null;function O(t){var e=t.trigger.getBoundingClientRect();t.menu.style.top=e.bottom+6+"px",t.menu.style.right=Math.max(8,innerWidth-e.right)+"px";var r=t.menu.getBoundingClientRect(),a=e.right-r.right;r.left+a<8&&(a=8-r.left),Math.abs(a)>=.5&&(t.menu.style.right=parseFloat(t.menu.style.right)-a+"px")}function y(t){var e=c;e&&(c=null,e.menu.hidden=!0,e.trigger.setAttribute("aria-expanded","false"),e.trigger.classList.remove("active"),t&&e.trigger.focus(),u(e.root,"gemboss:editor-menu",{open:!1,menu:e.menu}))}function Y(t,e){var r=e.nextElementSibling;if(!r||!r.classList.contains("gemboss-editor-menu"))return!1;var a=c&&c.trigger===e;return y(!1),a||(c={root:t,trigger:e,menu:r},r.hidden=!1,e.setAttribute("aria-expanded","true"),e.classList.add("active"),O(c),u(t,"gemboss:editor-menu",{open:!0,menu:r})),!0}var T=!1;function Z(){T||(T=!0,document.addEventListener("pointerdown",function(t){c&&!c.menu.contains(t.target)&&!c.trigger.contains(t.target)&&y(!1)}),addEventListener("keydown",function(t){t.key!=="Escape"||!c||t.isComposing||t.keyCode===229||(t.preventDefault(),t.stopImmediatePropagation(),y(!0))},!0),addEventListener("resize",function(){c&&O(c)}),addEventListener("blur",function(){y(!1)}))}function ee(t){var e=t&&t.classList&&t.classList.contains("gemboss-editor")?[t]:Array.prototype.slice.call((t||document).querySelectorAll(".gemboss-editor"));return Z(),e.forEach(function(r){if(!(w?w.has(r):r._gbEditor)){w?w.add(r):r._gbEditor=!0,H(r);var a=d(r);a&&typeof ResizeObserver=="function"&&new ResizeObserver(function(){a.classList.contains("is-chat-collapsed")||v(r,q(r),!1)}).observe(a),r.addEventListener("pointerdown",function(i){var n=i.target.closest(".gemboss-editor-resizer");n&&n===m(r)&&G(r,i)}),r.addEventListener("keydown",function(i){i.target.classList&&i.target.classList.contains("gemboss-editor-resizer")&&i.target===m(r)&&V(r,i)}),r.addEventListener("click",function(i){var n=i.target,s;if(s=n.closest(".gemboss-editor-chat-toggle"))return X(r,s);if(s=n.closest(".gemboss-pv-devices .gemboss-pv-device"))return J(r,s);if(s=n.closest(".gemboss-editor-mobile-tab"))return Q(r,s);if((s=n.closest('[aria-haspopup="menu"]'))&&Y(r,s)){i.stopPropagation();return}c&&(s=n.closest(".gemboss-editor-menu-item"))&&c.menu.contains(s)&&y(!0)})}}),e.length}g.initEditorFrame=ee;function b(t){if(!t||t!==t.trim())return null;var e=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t),r,a,i,n;if(e){var s=e[1].length<=4?e[1].replace(/./g,"$&$&"):e[1];return n=function(de){return parseInt(s.substr(de,2),16)},{r:n(0),g:n(2),b:n(4),a:s.length===8?Math.round(n(6)/255*1e3)/1e3:1}}if(r=/^rgba?\(\s*([^()]*?)\s*\)$/i.exec(t),!r)return null;var l=r[1].split("/");if(a=l[0].indexOf(",")>=0?l[0].split(","):l[0].trim().split(/\s+/),l.length===2&&a.push(l[1]),l.length>2||a.length<3||a.length>4)return null;var o=[];for(i=0;i<a.length;i++){var f=a[i].trim(),p=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?%?$/i.test(f)?parseFloat(f):f==="none"?0:NaN;if(isNaN(p))return null;/%$/.test(f)&&(p=p/100*(i<3?255:1)),o.push(i<3?Math.min(255,Math.max(0,Math.round(p))):Math.min(1,Math.max(0,p)))}return{r:o[0],g:o[1],b:o[2],a:o.length===4?o[3]:1}}function C(t){return"#"+[t.r,t.g,t.b].map(function(e){return(e<16?"0":"")+e.toString(16)}).join("")}function I(t,e,r){return r<1?"rgba("+e.r+", "+e.g+", "+e.b+", "+Math.round(r*100)/100+")":/^#/.test(t)||!t?C(e):"rgb("+e.r+", "+e.g+", "+e.b+")"}function B(t,e){var r=b(e),a=b(t);return r?I(t,r,a?a.a:1):t}function W(t,e){var r=b(t);return r&&isFinite(e)?I(t,r,Math.min(100,Math.max(0,Math.round(e)))/100):t}g.colorOf=b,g.pickSwatch=B,g.withOpacity=W;var _=function(t){var e=t.getAttribute("data-value");return e??(t.textContent||"").trim()},$=function(t){return Array.prototype.filter.call(t.children,function(e){return e.getAttribute("role")==="tab"})};function R(t,e){var r=t.parentNode,a=$(r),i=a.some(function(n){return n.hasAttribute("tabindex")});a.forEach(function(n){var s=n===t;n.setAttribute("aria-selected",String(s)),n.classList.contains("gemboss-ei-tab")&&n.classList.toggle("on",s),i&&n.setAttribute("tabindex",s?"0":"-1");var l=n.getAttribute("aria-controls"),o=l&&document.getElementById(l);o&&(o.hidden=!s)}),e&&t.focus(),u(t,"gemboss:editor-tab",{tab:_(t),index:a.indexOf(t)})}function te(t,e){if(!(e.key!=="ArrowRight"&&e.key!=="ArrowLeft")){var r=$(t);if(r.some(function(n){return n.hasAttribute("tabindex")})){var a=r.findIndex(function(n){return n.getAttribute("aria-selected")==="true"}),i=e.key==="ArrowRight"?(a+1)%r.length:(a-1+r.length)%r.length;e.preventDefault(),R(r[i],!0)}}}function re(t){var e=t.getAttribute("data-open")!=="open";t.setAttribute("data-open",e?"open":"closed"),t.setAttribute("aria-expanded",String(e));var r=t.querySelector(".gemboss-ei-chev");r&&(r.textContent=e?"\u25BE":"\u25B8"),u(t,"gemboss:editor-group",{open:e})}function ae(t){var e=t.closest(".gemboss-ei-seg");Array.prototype.forEach.call(e.querySelectorAll("button"),function(r){var a=r===t;r.classList.toggle("active",a),r.classList.toggle("on",a),r.hasAttribute("aria-pressed")&&r.setAttribute("aria-pressed",String(a))}),u(e,"gemboss:editor-seg",{value:_(t)})}var ie={text:"Text",accent:"Accent","accent-text":"Accent text",muted:"Muted",background:"Background",surface:"Surface",border:"Border",success:"Success",warning:"Warning",danger:"Danger"},ne=0;function z(t){return ie[t]||t.charAt(0).toUpperCase()+t.slice(1).replace(/-/g," ")}function se(t){var e=t.trim(),r=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(e);if(r)return"Theme color: "+z(r[1].toLowerCase())+". Type a color to use your own.";if(/^var\(/i.test(e))return"A theme value. Type a color to use your own.";var a=oe(e);return a?"A mix of "+a.replace(" + "," and ")+", half of each. Type a color to use your own.":/^color-mix\(/i.test(e)?"A mix of colors. Type a color to use your own.":"Kept as written: the swatch shows one color (hex, rgb, hsl or oklch), not a gradient or a name."}var F="(var\\([^()]*\\)|[^,()]+(?:\\([^()]*\\))?)";function oe(t){var e=new RegExp("^color-mix\\(\\s*in\\s+srgb\\s*,"+F+","+F+"\\)$","i").exec(t);function r(n){n=n.trim();var s=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(n);return s?z(s[1].toLowerCase()):b(n)||/^(hsla?|oklch)\([^()]*\)$/i.test(n)?n:null}var a=e&&r(e[1]),i=e&&r(e[2]);return a&&i?a+" + "+i:null}function A(t){var e=t.querySelector(".gemboss-ei-swatch"),r=t.querySelector("input:not([type=color]):not([data-alpha])");if(!(!e||!r)){var a=r.value,i=b(a),n=!a||!!i;if(e.tagName==="BUTTON"){var s=e.querySelector(".gemboss-ei-swatch-fill");s&&(i?s.style.setProperty("--sw","rgba("+i.r+", "+i.g+", "+i.b+", "+i.a+")"):s.style.removeProperty("--sw")),a?e.removeAttribute("data-empty"):e.setAttribute("data-empty","")}else e.value=i?C(i):"#000000";var l=t.querySelector("input[data-alpha]");i&&!l&&(l=document.createElement("input"),l.className=r.className,l.setAttribute("data-alpha",""),l.setAttribute("inputmode","numeric"),l.setAttribute("aria-label",(e.getAttribute("aria-label")||"Color swatch").replace(/ swatch$/,"")+" opacity"),(t.querySelector(".gemboss-ei-color-group")||t).appendChild(l)),l&&(l.hidden=!i,i&&(l.value=Math.round(i.a*100)+"%"),l.disabled=r.disabled),e.disabled=r.disabled||!n;var o=t.querySelector(".gemboss-ei-color-why");if(n){e.removeAttribute("title"),e.removeAttribute("aria-describedby"),o&&o.parentNode.removeChild(o);return}var f=se(a);e.title=f,o||(o=document.createElement("p"),o.className="gemboss-ei-color-why",t.appendChild(o)),o.id||(o.id="gemboss-ei-color-why-"+ ++ne),o.textContent=f,e.setAttribute("aria-describedby",o.id)}}function le(t){for(var e=t.labels||[],r=null,a=0;a<e.length&&!r;a++)r=e[a].querySelector(".gemboss-ei-rangeval");r&&(r.textContent=t.value+(r.getAttribute("data-suffix")||""))}function ue(t){var e={},r=["t","r","b","l"];return Array.prototype.forEach.call(t.querySelectorAll("input"),function(a,i){e[r[i]]=a.value.trim()}),e}function D(t){return'url("'+t.replace(/["\\]/g,"\\$&").replace(/[\u0000-\u001f\u007f]/g,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})+'")'}g.cssUrl=D;function ce(t,e){var r=t.querySelector(".gemboss-ei-img-thumb");r&&(r.style.setProperty("--gemboss-thumb",e?D(e):""),r.setAttribute("data-thumb",e?"image":"empty"),r.textContent="")}function U(t,e){var r=t.getAttribute("data-gb-value")!=null?t.getAttribute("data-gb-value"):e.defaultValue;e.value!==r&&(t.setAttribute("data-gb-value",e.value),ce(t,e.value),u(t,"gemboss:editor-image",{value:e.value}))}var L=typeof WeakSet=="function"?new WeakSet:null,x=function(t){return t.__gbPanel?!1:(t.__gbPanel=!0,!0)};function fe(t){var e=t.closest(".gemboss-ei-color");if(e){var r=e.querySelector("input:not([type=color]):not([data-alpha])"),a=e.querySelector("input[data-gb-swatch-native]");a||(a=document.createElement("input"),a.type="color",a.setAttribute("data-gb-swatch-native",""),a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;width:1px;height:1px;opacity:0;pointer-events:none",t.parentNode.insertBefore(a,t.nextSibling));var i=r&&b(r.value);a.value=i?C(i):"#ffffff";try{a.showPicker?a.showPicker():a.click()}catch{a.click()}}}function ge(t){var e=t||document;return(L?L.has(e):e._gbPanel)?0:(L?L.add(e):e._gbPanel=!0,Array.prototype.forEach.call(e.querySelectorAll(".gemboss-ei-color"),A),e.addEventListener("click",function(r){var a=r.target,i;if(!(!a.closest||!x(r))){if(i=a.closest('.gemboss-ec-tabs > [role="tab"], .gemboss-ei-tabs > [role="tab"]'))return R(i,!1);if(i=a.closest(".gemboss-ei-gh"))return re(i);if((i=a.closest(".gemboss-ei-seg button"))&&!i.disabled)return ae(i);if((i=a.closest("button.gemboss-ei-swatch"))&&!i.disabled)return fe(i);if((i=a.closest("[data-gb-image-clear]"))&&!i.disabled){var n=i.closest(".gemboss-ei-img"),s=n&&n.querySelector(".gemboss-ei-img-ctl input");s&&(s.value="",U(n,s))}}}),e.addEventListener("keydown",function(r){var a=r.target;if(!(!a.closest||!x(r))){var i=a.closest('.gemboss-ec-tabs[role="tablist"], .gemboss-ei-tabs[role="tablist"]');if(i&&a.getAttribute("role")==="tab")return te(i,r);r.key==="Enter"&&a.tagName==="INPUT"&&a.type!=="color"&&a.type!=="range"&&a.closest(".gemboss-ei-color, .gemboss-ei-edgebox, .gemboss-ei-img")&&(r.preventDefault(),a.blur())}}),e.addEventListener("input",function(r){var a=r.target;if(!(!a.closest||!x(r))){if(a.classList.contains("gemboss-ei-range")){le(a),u(a,"gemboss:editor-range",{value:Number(a.value)});return}if(a.classList.contains("gemboss-ei-swatch")||a.hasAttribute("data-gb-swatch-native")){var i=a.closest(".gemboss-ei-color"),n=i&&i.querySelector("input:not([type=color]):not([data-alpha])"),s=n?B(n.value,a.value):a.value;n&&(n.value=s),i&&a.hasAttribute("data-gb-swatch-native")&&A(i),u(i||a,"gemboss:editor-color",{value:s})}}}),e.addEventListener("focusout",function(r){var a=r.target;if(!(!a.closest||a.tagName!=="INPUT"||!x(r))){var i;if(a.hasAttribute("data-alpha")&&(i=a.closest(".gemboss-ei-color"))){var n=i.querySelector("input:not([type=color]):not([data-alpha])"),s=Number(String(a.value).replace(/%/g,"").trim()),l=n&&String(a.value).trim()&&isFinite(s)?W(n.value,s):null;l&&l!==n.value?(n.value=l,A(i),u(i,"gemboss:editor-color",{value:l})):A(i);return}if(a.type!=="color"&&(i=a.closest(".gemboss-ei-color"))){A(i),u(i,"gemboss:editor-color",{value:a.value});return}if(i=a.closest(".gemboss-ei-edgebox")){u(i,"gemboss:editor-edges",ue(i));return}(i=a.closest(".gemboss-ei-img"))&&U(i,a)}}),1)}g.initEditorPanel=ge})(typeof globalThis<"u"?globalThis:this);
|
package/src/editor-rail.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gemboss-editor-rail-foot{display:none}@media (min-width:761px){.gemboss-pageedit.gemboss-pageedit--rail,.gemboss-pageedit--rail .gemboss-layers{left:56px}body:not(.gemboss-editor-rail) .gemboss-pageedit--rail{box-shadow:-1px 0 0 var(--gemboss-divider),-56px 0 0 var(--gemboss-nav-bg)}body.gemboss-editor-rail nav.icon-nav{display:flex!important;top:0;height:100dvh;width:56px;padding-top:6px;z-index:310}body.gemboss-editor-rail nav.icon-nav:focus-within,body.gemboss-editor-rail.gemboss-editor-rail-open nav.icon-nav{z-index:330}body.gemboss-editor-rail .icon-nav>.gnav-bottom{padding-bottom:0}body.gemboss-editor-rail .gemboss-editor-rail-foot{display:block;padding:0 12px 12px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav{border-right:0;box-shadow:inset -1px 0 0 var(--gemboss-divider)}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav :is(.gnav-scroll,.gnav-bottom,.gemboss-editor-rail-foot){padding-inline:12px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item{position:relative;justify-content:center;gap:0;padding:6px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-sub{display:none}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item:focus-visible .gnav-label{position:fixed;left:64px;width:auto;height:auto;overflow:visible;clip-path:none;padding:4px 8px;border-radius:var(--gemboss-radius-md);background:var(--gemboss-text);color:var(--gemboss-surface);font-size:var(--gemboss-fs-caption);pointer-events:none}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item>:not(.gnav-ico,.gnav-label){position:absolute;top:2px;right:0}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-scroll{scrollbar-width:none;background:linear-gradient(var(--gemboss-nav-bg) 30%,transparent) 0 0/ calc(100% - 1px) 24px no-repeat local,linear-gradient(transparent,var(--gemboss-nav-bg) 70%) 0 100%/ calc(100% - 1px) 24px no-repeat local,radial-gradient(farthest-side at 50% 0,rgba(31,30,29,.22),transparent) 0 0/ calc(100% - 1px) 8px no-repeat scroll,radial-gradient(farthest-side at 50% 100%,rgba(31,30,29,.22),transparent) 0 100%/ calc(100% - 1px) 8px no-repeat scroll}body.gemboss-editor-rail.gemboss-editor-rail-open nav.icon-nav{width:240px;box-shadow:2px 0 26px #1f1e1d33}@media (min-width:1001px) and (max-width:1056px){.gemboss-pageedit--rail .gemboss-editor-body{flex-direction:column;gap:var(--gemboss-
|
|
1
|
+
.gemboss-editor-rail-foot{display:none}@media (min-width:761px){.gemboss-pageedit.gemboss-pageedit--rail,.gemboss-pageedit--rail .gemboss-layers{left:56px}body:not(.gemboss-editor-rail) .gemboss-pageedit--rail{box-shadow:-1px 0 0 var(--gemboss-divider),-56px 0 0 var(--gemboss-nav-bg)}body.gemboss-editor-rail nav.icon-nav{display:flex!important;top:0;height:100dvh;width:56px;padding-top:6px;z-index:310}body.gemboss-editor-rail nav.icon-nav:focus-within,body.gemboss-editor-rail.gemboss-editor-rail-open nav.icon-nav{z-index:330}body.gemboss-editor-rail .icon-nav>.gnav-bottom{padding-bottom:0}body.gemboss-editor-rail .gemboss-editor-rail-foot{display:block;padding:0 12px 12px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav{border-right:0;box-shadow:inset -1px 0 0 var(--gemboss-divider)}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav :is(.gnav-scroll,.gnav-bottom,.gemboss-editor-rail-foot){padding-inline:12px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item{position:relative;justify-content:center;gap:0;padding:6px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-sub{display:none}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item:focus-visible .gnav-label{position:fixed;left:64px;width:auto;height:auto;overflow:visible;clip-path:none;padding:4px 8px;border-radius:var(--gemboss-radius-md);background:var(--gemboss-text);color:var(--gemboss-surface);font-size:var(--gemboss-fs-caption);pointer-events:none}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item>:not(.gnav-ico,.gnav-label){position:absolute;top:2px;right:0}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-scroll{scrollbar-width:none;background:linear-gradient(var(--gemboss-nav-bg) 30%,transparent) 0 0/ calc(100% - 1px) 24px no-repeat local,linear-gradient(transparent,var(--gemboss-nav-bg) 70%) 0 100%/ calc(100% - 1px) 24px no-repeat local,radial-gradient(farthest-side at 50% 0,rgba(31,30,29,.22),transparent) 0 0/ calc(100% - 1px) 8px no-repeat scroll,radial-gradient(farthest-side at 50% 100%,rgba(31,30,29,.22),transparent) 0 100%/ calc(100% - 1px) 8px no-repeat scroll}body.gemboss-editor-rail.gemboss-editor-rail-open nav.icon-nav{width:240px;box-shadow:2px 0 26px #1f1e1d33}@media (min-width:1001px) and (max-width:1056px){.gemboss-pageedit--rail .gemboss-editor-body{flex-direction:column;gap:0}.gemboss-pageedit--rail .gemboss-editor-body>.gemboss-ec{border-right:0;border-bottom:1px solid var(--gemboss-divider)}.gemboss-pageedit--rail .gemboss-editor-resizer{display:none}.gemboss-pageedit--rail .gemboss-editor-body.is-chat-collapsed .gemboss-ec{max-height:0;min-height:0}.gemboss-pageedit--rail .gemboss-editor-body>.gemboss-ec{width:auto;flex:0 0 auto;height:44%;min-height:min(520px,76%);max-height:76%}}@media (min-width:1201px) and (max-width:1256px){.gemboss-pageedit--rail .gemboss-pageedit-scope{display:none}}}@media (min-width:761px) and (pointer:coarse),(min-width:761px) and (max-width:47.9975em){body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav :is(.gnav-scroll,.gnav-bottom,.gemboss-editor-rail-foot){padding-inline:6px}body.gemboss-editor-rail:not(.gemboss-editor-rail-open) .icon-nav .gnav-item{padding:12px}}
|