@gemboss/ui 0.50.0 → 0.52.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 +216 -0
- package/README.md +153 -1
- package/catalog/editor.html +25 -12
- package/catalog/index.html +635 -93
- package/gemboss-ui.css +3 -3
- package/package.json +8 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/engine-settings-store.ts +95 -0
- package/src/assistant/engine-settings.tsx +106 -0
- package/src/assistant/engine.tsx +98 -31
- package/src/assistant/index.ts +2 -0
- package/src/assistant-engine.css +1 -1
- package/src/auth-extras.css +1 -0
- package/src/auth-footer.css +1 -0
- package/src/auth-footer.tsx +71 -0
- package/src/auth-signin-plain.js +1 -1
- package/src/auth-sso-plain.js +1 -1
- package/src/auth-steps.css +1 -0
- package/src/auth-steps.tsx +179 -0
- package/src/auth.css +1 -1
- package/src/auth.tsx +159 -31
- package/src/dialog.tsx +3 -0
- package/src/editor/color-picker.tsx +183 -0
- package/src/editor/controls.tsx +49 -33
- package/src/editor/index.ts +8 -0
- package/src/editor/picker-grid.tsx +186 -0
- package/src/editor/picker.tsx +275 -0
- package/src/editor/popover.tsx +160 -0
- package/src/editor/swatch.ts +2 -1
- package/src/editor-color.css +1 -0
- package/src/editor-picker-grid.css +1 -0
- package/src/editor-picker.css +1 -0
- package/src/editor-plain.js +1 -1
- package/src/editor-popover.css +1 -0
- package/src/editor.css +1 -1
- package/src/engine-plain.js +1 -1
- package/src/icons.tsx +4 -0
- package/src/index.ts +4 -1
- package/src/theme.tsx +13 -3
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// PICKER LIST (24/10/2026, Chris: the editor's pickers looked bare and each drew its own; "chuẩn hoá theo ui kit"). One body for
|
|
3
|
+
// every "choose one of these" popup in the editors: a link's product, page or section, a video, a font, a page. Before it, five
|
|
4
|
+
// pickers drew five lists in the admin's own CSS (rows, search box, empty and loading lines), each a little different.
|
|
5
|
+
//
|
|
6
|
+
// Polaris' pattern for picking from a searchable list is a Combobox over a Listbox, and this is that, at the kit's numbers:
|
|
7
|
+
// · the search box keeps the focus: ↑ ↓ move the highlighted row, Enter picks it, Escape clears the box first (the popup's own
|
|
8
|
+
// Escape closes it when the box is empty); with no search box the list takes the focus and the same keys work on it. An
|
|
9
|
+
// Enter or an Escape that ends an IME composition (Vietnamese, Chinese) is the typing's, not the list's (as SearchDialog);
|
|
10
|
+
// · the highlight is a ROW, kept by its key: a list that changes under it never leaves it on another row for a frame (review
|
|
11
|
+
// of #5290); the pointer moves it too, and it is painted only while the picker has the focus;
|
|
12
|
+
// · `.gemboss-ei-pick-row[role=option]`: a 40px picture (a photo, or an icon for a page or a section), the title (20px line,
|
|
13
|
+
// 650) with a status pill (`ui-tag`), a second line; the row now chosen has a check and `aria-selected`; one click picks;
|
|
14
|
+
// · the second line puts a NOTE first, in its own box the ellipsis never reaches (review of gemboss #5283: "Opens the popup"
|
|
15
|
+
// at the end of a long line was cut off), then the rest, cut with "…";
|
|
16
|
+
// · a row that cannot be picked is shown, says why (its note), and does nothing (`aria-disabled`);
|
|
17
|
+
// · states (the kit's collection states): loading keeps the rows' place with skeletons; RELOADING keeps the rows of the last
|
|
18
|
+
// answer dimmed and `aria-busy`, and nothing is picked from them (they answer another search: an Enter there wrote the
|
|
19
|
+
// previous query's first row, review of #5290); an error is the kit's danger notice with Try again; a search that finds
|
|
20
|
+
// nothing says so and offers Clear search; an empty list says what the caller gives it; "Show more" ends a long list.
|
|
21
|
+
// Its grid sibling, PickerGrid (picker-grid.tsx), draws the same search box, highlight and states (PickSearch, usePickHighlight,
|
|
22
|
+
// PickNothing, exported for it, not from the package).
|
|
23
|
+
// Its own part (`editor-picker.css`): only a surface that draws a picker loads it.
|
|
24
|
+
import "../editor-picker.css";
|
|
25
|
+
import React, { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
26
|
+
import { Icon, type IconName } from "../icons";
|
|
27
|
+
|
|
28
|
+
export type PickerTone = "neutral" | "info" | "success" | "warning" | "critical";
|
|
29
|
+
|
|
30
|
+
export interface PickerItem {
|
|
31
|
+
/** What `onPick` gets, and what `current` is compared with. */
|
|
32
|
+
key: string;
|
|
33
|
+
title: string;
|
|
34
|
+
/** The title drawn as what it names: a font's name in its own face, at a size its shape reads at (`{ fontFamily, fontSize }`). */
|
|
35
|
+
titleStyle?: React.CSSProperties;
|
|
36
|
+
/** The rest of the second line (a path, a heading), cut with "…" when it does not fit. */
|
|
37
|
+
subtitle?: string;
|
|
38
|
+
/** What to know before picking, first on the second line and never cut ("Opens the popup", "Opens once it is active"). */
|
|
39
|
+
note?: string;
|
|
40
|
+
/** A short status beside the title, as a pill ("Draft", "Archived"). */
|
|
41
|
+
badge?: { label: string; tone?: PickerTone };
|
|
42
|
+
/** A photo: a URL, or null for a thing that could have one and has none (a grey square keeps its place). */
|
|
43
|
+
image?: string | null;
|
|
44
|
+
/** For a thing that has no photo (a page, a section): its icon in the same 40px tile. */
|
|
45
|
+
icon?: IconName;
|
|
46
|
+
/** A drawn picture of the caller's instead (an SVG the kit has no icon for: a cart, a product tag), in the same 40px tile. */
|
|
47
|
+
picture?: React.ReactNode;
|
|
48
|
+
/** The row opens a list of its own (the page picker's Products, Collections): a chevron at its end instead of the check,
|
|
49
|
+
* and picking it is the caller's step into that list. Current, it is marked by the chosen row's tint (and `aria-selected`). */
|
|
50
|
+
drill?: boolean;
|
|
51
|
+
/** Present: shown, not pickable, and this is said as its note (a locked row says why). */
|
|
52
|
+
disabledReason?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface PickerListProps {
|
|
56
|
+
/** The list's accessible name ("Sections", "Products"). */
|
|
57
|
+
label: string;
|
|
58
|
+
items: readonly PickerItem[];
|
|
59
|
+
/** The key now chosen: its row has the check (a drill row: the tint), and is the one highlighted first. */
|
|
60
|
+
current?: string | null;
|
|
61
|
+
onPick: (key: string) => void;
|
|
62
|
+
/** The search box above the list; leave it out for a short list. The caller filters `items` (or asks a server). `autoFocus`:
|
|
63
|
+
* the box takes the focus when the list appears, and is the `[data-autofocus]` the kit's Dialog and Popover focus on opening
|
|
64
|
+
* (every picker in the editors sets it: the search box is where a picker is used from). */
|
|
65
|
+
search?: PickerSearch;
|
|
66
|
+
/**
|
|
67
|
+
* `loading`: skeleton rows in the list's place (a first read). `reloading`: `items` are the last answer, kept on screen
|
|
68
|
+
* dimmed while the next one is read (a search being typed), and not pickable. `error`: `error.message`, Try again with
|
|
69
|
+
* `error.onRetry`.
|
|
70
|
+
*/
|
|
71
|
+
state?: "ready" | "loading" | "reloading" | "error";
|
|
72
|
+
error?: { message: string; onRetry?: () => void };
|
|
73
|
+
/** What an empty list says when nothing is searched ("This page has no sections yet."), and one action. */
|
|
74
|
+
empty?: { title: string; body?: string; action?: React.ReactNode };
|
|
75
|
+
/** More rows than these: "Show more" after the last one. */
|
|
76
|
+
more?: { onClick: () => void; busy?: boolean; label?: string };
|
|
77
|
+
/** Skeleton rows while loading (default 4). */
|
|
78
|
+
loadingRows?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @internal shared with picker-grid.tsx */
|
|
82
|
+
export type PickerSearch = { value: string; onChange: (value: string) => void; placeholder?: string; label?: string; autoFocus?: boolean };
|
|
83
|
+
|
|
84
|
+
/** @internal shared with picker-grid.tsx. `search.autoFocus` under a mouse only: under a finger (the kit's `(pointer: coarse)`, as
|
|
85
|
+
* §9.1's targets) a focused box raises the on-screen keyboard over the list the person came to tap (review, 24/10/2026). */
|
|
86
|
+
export const typesFirst = (search?: PickerSearch) =>
|
|
87
|
+
Boolean(search?.autoFocus) && !(typeof window !== "undefined" && window.matchMedia?.("(pointer: coarse)").matches);
|
|
88
|
+
|
|
89
|
+
/** The search box both pickers draw: the kit's grouped field (an icon in the box, as the admin's "Find a setting"), `gemboss-field`
|
|
90
|
+
* owning the look, here only the icon and the ✕ placed (text-fields-share-one-look.test.ts). A text box with a search keyboard, not
|
|
91
|
+
* type=search: it is a combobox, and the browser's own ✕ would sit beside the kit's. */
|
|
92
|
+
export function PickSearch({ search, boxRef, listId, hasList, activeId, onKeyDown, onClear }: {
|
|
93
|
+
search: PickerSearch; boxRef: React.RefObject<HTMLInputElement>; listId: string; hasList: boolean; activeId?: string;
|
|
94
|
+
onKeyDown: (e: React.KeyboardEvent) => void; onClear: () => void;
|
|
95
|
+
}) {
|
|
96
|
+
return (
|
|
97
|
+
<label className="gemboss-field gemboss-field--group gemboss-ei-pick-search">
|
|
98
|
+
<Icon name="search" size={16} className="gemboss-ei-pick-search-icon" />
|
|
99
|
+
<input ref={boxRef} type="text" inputMode="search" enterKeyHint="search" className="gemboss-field__bare" value={search.value} placeholder={search.placeholder ?? "Search"}
|
|
100
|
+
aria-label={search.label ?? search.placeholder ?? "Search"} role="combobox" aria-expanded={hasList} aria-controls={hasList ? listId : undefined}
|
|
101
|
+
aria-autocomplete="list" aria-activedescendant={activeId} autoComplete="off" spellCheck={false} data-autofocus={typesFirst(search) ? "" : undefined}
|
|
102
|
+
onChange={(e) => search.onChange(e.target.value)} onKeyDown={onKeyDown} />
|
|
103
|
+
{search.value ? (
|
|
104
|
+
<button type="button" className="gemboss-ei-pick-clear" aria-label="Clear search" onClick={onClear}>
|
|
105
|
+
<Icon name="close" size={16} />
|
|
106
|
+
</button>
|
|
107
|
+
) : null}
|
|
108
|
+
</label>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** What both pickers draw instead of their items: skeletons (given), the kit's error, a search that found nothing, an empty list. */
|
|
113
|
+
export function PickNothing({ phase, skeleton, error, empty, query, onClear }: {
|
|
114
|
+
phase: "loading" | "error" | "empty"; skeleton: React.ReactNode; error?: { message: string; onRetry?: () => void };
|
|
115
|
+
empty?: { title: string; body?: string; action?: React.ReactNode }; query: string; onClear: () => void;
|
|
116
|
+
}) {
|
|
117
|
+
if (phase === "loading") return <>{skeleton}</>;
|
|
118
|
+
if (phase === "error") {
|
|
119
|
+
// The kit's error (CollectionState's): a danger notice, never an empty list.
|
|
120
|
+
return (
|
|
121
|
+
<div className="ui-notice ui-notice--danger gemboss-ei-pick-error" role="alert">
|
|
122
|
+
<b>{error?.message ?? "This list could not be read."}</b>
|
|
123
|
+
{error?.onRetry ? <button type="button" className="ui-btn" onClick={error.onRetry}>Try again</button> : null}
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return query.trim() ? (
|
|
128
|
+
<div className="ui-empty">
|
|
129
|
+
<p className="ui-empty__title">No results for “{query.trim()}”</p>
|
|
130
|
+
<p className="ui-empty__body">Check the spelling or search for something else.</p>
|
|
131
|
+
<button type="button" className="ui-btn" onClick={onClear}>Clear search</button>
|
|
132
|
+
{/* The caller's way forward too (the image picker's Upload): a library with nothing in it, searched, hid it (review of #5325). */}
|
|
133
|
+
{empty?.action ?? null}
|
|
134
|
+
</div>
|
|
135
|
+
) : (
|
|
136
|
+
<div className="ui-empty">
|
|
137
|
+
<p className="ui-empty__title">{empty?.title ?? "Nothing to choose yet."}</p>
|
|
138
|
+
{empty?.body ? <p className="ui-empty__body">{empty.body}</p> : null}
|
|
139
|
+
{empty?.action ?? null}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** @internal shared with picker-grid.tsx. The highlight both pickers keep: a KEY (a list that changes under it never leaves it on
|
|
145
|
+
* another item for a frame, review of #5290), forgotten when the search changes; unset or gone, the chosen item when it can be
|
|
146
|
+
* picked, else the first that can. It is scrolled into view when the keys (or the list) move it, never when the pointer does:
|
|
147
|
+
* a pointer resting on a half-shown tile scrolled the grid under itself, and the next tile under it moved it again (review of
|
|
148
|
+
* slice 3). */
|
|
149
|
+
export function usePickHighlight<T extends { key: string }>(shown: readonly T[], can: (t: T) => boolean, chosen: string | null, query: string, idOf: (i: number) => string) {
|
|
150
|
+
const [activeKey, setActiveKey] = useState<string | null>(null);
|
|
151
|
+
// The key the pointer put the highlight on: that one is not scrolled to (a flag alone stayed set when the pointer's move left
|
|
152
|
+
// the highlight where it was, and the next move by the keys or the list skipped its scroll: review of #5325).
|
|
153
|
+
const byPointer = useRef<string | null>(null);
|
|
154
|
+
useEffect(() => { setActiveKey(null); }, [query]);
|
|
155
|
+
const byKey = activeKey === null ? -1 : shown.findIndex((t) => t.key === activeKey && can(t));
|
|
156
|
+
const atChosen = shown.findIndex((t) => t.key === chosen && can(t));
|
|
157
|
+
const active = byKey >= 0 ? byKey : atChosen >= 0 ? atChosen : shown.findIndex(can);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (active >= 0 && byPointer.current !== shown[active]?.key) document.getElementById(idOf(active))?.scrollIntoView?.({ block: "nearest" });
|
|
160
|
+
byPointer.current = null;
|
|
161
|
+
}, [active]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
162
|
+
const highlight = (key: string, by: "keys" | "pointer") => { byPointer.current = by === "pointer" ? key : null; setActiveKey(key); };
|
|
163
|
+
return { active, highlight };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// A row that opens a list of its own ends with this.
|
|
167
|
+
const DRILL = <Icon name="chevronRight" size={16} className="gemboss-ei-pick-drill" />;
|
|
168
|
+
|
|
169
|
+
const TONE: Record<PickerTone, string> = { neutral: "ui-tag", info: "ui-tag ui-tag--accent", success: "ui-tag ui-tag--success", warning: "ui-tag ui-tag--warning", critical: "ui-tag ui-tag--danger" };
|
|
170
|
+
|
|
171
|
+
export function PickerList({ label, items, current = null, onPick, search, state = "ready", error, empty, more, loadingRows = 4 }: PickerListProps) {
|
|
172
|
+
const base = useId();
|
|
173
|
+
const boxRef = useRef<HTMLInputElement>(null);
|
|
174
|
+
// Reloading with nothing to keep is a first read: skeletons, not "nothing here".
|
|
175
|
+
const phase = state === "reloading" && items.length === 0 ? "loading" : state;
|
|
176
|
+
const shown = phase === "ready" || phase === "reloading" ? items : [];
|
|
177
|
+
const live = phase === "ready";
|
|
178
|
+
const pickable = useMemo(() => shown.map((it, i) => (it.disabledReason ? -1 : i)).filter((i) => i >= 0), [shown]);
|
|
179
|
+
const query = search?.value ?? "";
|
|
180
|
+
const optionId = (i: number) => `${base}-o${i}`;
|
|
181
|
+
const { active, highlight } = usePickHighlight(shown, (it) => !it.disabledReason, current, query, optionId);
|
|
182
|
+
|
|
183
|
+
const pick = (it: PickerItem | undefined) => { if (live && it && !it.disabledReason) onPick(it.key); };
|
|
184
|
+
const move = (by: 1 | -1 | "first" | "last") => {
|
|
185
|
+
if (!pickable.length) return;
|
|
186
|
+
const at = pickable.indexOf(active);
|
|
187
|
+
const next = by === "first" ? 0 : by === "last" ? pickable.length - 1 : at < 0 ? 0 : Math.min(pickable.length - 1, Math.max(0, at + by));
|
|
188
|
+
highlight(shown[pickable[next]!]!.key, "keys");
|
|
189
|
+
};
|
|
190
|
+
const clear = () => { search?.onChange(""); boxRef.current?.focus(); };
|
|
191
|
+
// The box carries `data-autofocus`, which the kit's Dialog and Popover focus as they open; this covers a list that appears in a
|
|
192
|
+
// container already open (a drill-down's new list). Once, as the list appears.
|
|
193
|
+
useEffect(() => { if (typesFirst(search)) boxRef.current?.focus(); }, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
194
|
+
const keyDown = (e: React.KeyboardEvent, fromBox: boolean) => {
|
|
195
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
196
|
+
if (e.key === "ArrowDown") { e.preventDefault(); move(1); }
|
|
197
|
+
else if (e.key === "ArrowUp") { e.preventDefault(); move(-1); }
|
|
198
|
+
else if (!fromBox && e.key === "Home") { e.preventDefault(); move("first"); }
|
|
199
|
+
else if (!fromBox && e.key === "End") { e.preventDefault(); move("last"); }
|
|
200
|
+
else if (e.key === "Enter" || (!fromBox && e.key === " ")) {
|
|
201
|
+
// Reloading: the rows answer another search; Enter waits for this one (nothing is written).
|
|
202
|
+
if (shown.length) e.preventDefault();
|
|
203
|
+
pick(shown[active]);
|
|
204
|
+
} else if (fromBox && e.key === "Escape" && query) { e.preventDefault(); e.stopPropagation(); clear(); }
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const listId = `${base}-list`;
|
|
208
|
+
const hasList = shown.length > 0;
|
|
209
|
+
const activeId = live && active >= 0 && shown[active] ? optionId(active) : undefined;
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div className="gemboss-ei-pick">
|
|
213
|
+
{search ? <PickSearch search={search} boxRef={boxRef} listId={listId} hasList={hasList} activeId={activeId} onKeyDown={(e) => keyDown(e, true)} onClear={clear} /> : null}
|
|
214
|
+
|
|
215
|
+
{phase === "loading" || phase === "error" || !hasList ? (
|
|
216
|
+
<PickNothing phase={phase === "loading" ? "loading" : phase === "error" ? "error" : "empty"} error={error} empty={empty} query={query} onClear={clear}
|
|
217
|
+
skeleton={
|
|
218
|
+
<div className="gemboss-ei-pick-skeleton" role="status" aria-label="Loading">
|
|
219
|
+
{Array.from({ length: loadingRows }, (_, i) => (
|
|
220
|
+
<div key={i} className="gemboss-ei-pick-skeleton-row" aria-hidden>
|
|
221
|
+
<span className="gemboss-ei-pick-media ui-skeleton__line" />
|
|
222
|
+
<span className="gemboss-ei-pick-skeleton-text"><span className="ui-skeleton__line" /><span className="ui-skeleton__line" /></span>
|
|
223
|
+
</div>
|
|
224
|
+
))}
|
|
225
|
+
</div>
|
|
226
|
+
} />
|
|
227
|
+
) : (
|
|
228
|
+
<>
|
|
229
|
+
<ul id={listId} className={`gemboss-ei-pick-list${live ? "" : " is-reloading"}`} role="listbox" aria-label={label} aria-busy={live ? undefined : true}
|
|
230
|
+
tabIndex={search ? -1 : 0} aria-activedescendant={search ? undefined : activeId} onKeyDown={search ? undefined : (e) => keyDown(e, false)}>
|
|
231
|
+
{shown.map((it, i) => {
|
|
232
|
+
const chosen = it.key === current;
|
|
233
|
+
const note = it.disabledReason ?? it.note;
|
|
234
|
+
return (
|
|
235
|
+
<li key={it.key} id={optionId(i)} role="option" aria-selected={chosen} aria-disabled={it.disabledReason || !live ? true : undefined}
|
|
236
|
+
className={`gemboss-ei-pick-row${i === active ? " is-active" : ""}`} data-key={it.key}
|
|
237
|
+
onMouseDown={(e) => e.preventDefault() /* the search box keeps the focus */}
|
|
238
|
+
onMouseMove={() => { if (!it.disabledReason && i !== active) highlight(it.key, "pointer"); }}
|
|
239
|
+
onClick={() => pick(it)}>
|
|
240
|
+
{it.image !== undefined ? (
|
|
241
|
+
it.image ? <img className="gemboss-ei-pick-media" src={it.image} alt="" loading="lazy" /> : <span className="gemboss-ei-pick-media" aria-hidden />
|
|
242
|
+
) : it.icon ? (
|
|
243
|
+
<span className="gemboss-ei-pick-media gemboss-ei-pick-media--icon" aria-hidden><Icon name={it.icon} size={20} /></span>
|
|
244
|
+
) : it.picture ? (
|
|
245
|
+
<span className="gemboss-ei-pick-media gemboss-ei-pick-media--icon" aria-hidden>{it.picture}</span>
|
|
246
|
+
) : null}
|
|
247
|
+
<span className="gemboss-ei-pick-text">
|
|
248
|
+
<span className="gemboss-ei-pick-head">
|
|
249
|
+
<span className="gemboss-ei-pick-title" style={it.titleStyle}>{it.title}</span>
|
|
250
|
+
{it.badge ? <span className={TONE[it.badge.tone ?? "neutral"]}>{it.badge.label}</span> : null}
|
|
251
|
+
</span>
|
|
252
|
+
{note || it.subtitle ? (
|
|
253
|
+
<span className="gemboss-ei-pick-sub">
|
|
254
|
+
{note ? <span className={`gemboss-ei-pick-note${it.disabledReason ? " is-blocked" : ""}`}>{note}</span> : null}
|
|
255
|
+
{it.subtitle ? <span className="gemboss-ei-pick-rest">{note ? `· ${it.subtitle}` : it.subtitle}</span> : null}
|
|
256
|
+
</span>
|
|
257
|
+
) : null}
|
|
258
|
+
</span>
|
|
259
|
+
{it.drill ? DRILL : chosen ? <Icon name="check" size={20} className="gemboss-ei-pick-check" /> : null}
|
|
260
|
+
</li>
|
|
261
|
+
);
|
|
262
|
+
})}
|
|
263
|
+
</ul>
|
|
264
|
+
</>
|
|
265
|
+
)}
|
|
266
|
+
{/* After the list, or after "no results" / an empty list: the next page may hold what this one did not (the first page of a
|
|
267
|
+
store's Shopify files, all held already or none matching, kept Load more out of reach: review of #5325). */}
|
|
268
|
+
{more && (phase === "ready" || phase === "reloading") ? (
|
|
269
|
+
<div className="gemboss-ei-pick-more">
|
|
270
|
+
<button type="button" className="ui-btn" disabled={more.busy} onClick={more.onClick}>{more.busy ? "Loading…" : (more.label ?? "Show more")}</button>
|
|
271
|
+
</div>
|
|
272
|
+
) : null}
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// POPOVER (24/10/2026, Chris: the editor needs the small panels GemPages opens from a setting, "tham khảo cái gì hợp lý… ưu tiên ui
|
|
3
|
+
// ux dễ dùng"). A setting that needs more room than its row (a colour's picker, later a typography or a shadow) opens this beside
|
|
4
|
+
// the settings column, over the canvas, so the column does not grow and the canvas stays in view:
|
|
5
|
+
// · in the top layer (`popover="manual"`), like the kit menu's list and RepeaterList's layer, and in a portal on <body>: the
|
|
6
|
+
// panel's own rules (`.gemboss-ei-fld :is(button, input)`, a bundle panel's 44px floor) never reach inside it (review of
|
|
7
|
+
// #5296: they drew the picker's 12px bars 44 tall); where the browser has no popover API it opens in place, under its row;
|
|
8
|
+
// · BESIDE the column the anchor scrolls in, on the side with room (the canvas side), its top at the anchor's row and kept on
|
|
9
|
+
// screen; no room either side: under the anchor (`placeFloating`); placed again on a scroll or a resize outside it;
|
|
10
|
+
// `placement="below"`: always under the anchor (a trigger with no column beside it: the editor top bar's page picker);
|
|
11
|
+
// · at phone width (`max-width: 47.9975em`) a sheet along the bottom of the screen (editor-popover.css);
|
|
12
|
+
// · a head with its title, ← Back for a nested panel (`onBack`) and ✕; Escape steps back in a nested panel (as ← Back: the page
|
|
13
|
+
// picker's Products › back to its pages), else closes it (and only it), as does a press outside
|
|
14
|
+
// it and its anchor, or the focus moving into a frame (the canvas is an iframe: its presses never reach this document); the
|
|
15
|
+
// focus goes in on open, and back to what opened it (`returnTo`, else the anchor) on Escape or ✕ (a press outside leaves it
|
|
16
|
+
// where that press put it); placed again when it changes size (a list growing in it) and on a scroll that moves its row.
|
|
17
|
+
// Its own part (`editor-popover.css`); the surface is the shared `gemboss-popover-surface` (shell).
|
|
18
|
+
import "../editor-popover.css";
|
|
19
|
+
import React, { useEffect, useId, useLayoutEffect, useRef } from "react";
|
|
20
|
+
import { createPortal } from "react-dom";
|
|
21
|
+
import { Icon } from "../icons";
|
|
22
|
+
import { canFloatMenus, placeFloating } from "../menu-layer";
|
|
23
|
+
|
|
24
|
+
export interface PopoverProps {
|
|
25
|
+
open: boolean;
|
|
26
|
+
/** What it is placed against (its row) and the column that sits in. */
|
|
27
|
+
anchor: HTMLElement | null;
|
|
28
|
+
/** What gets the focus back on Escape or ✕: the button that opened it (default: the anchor). */
|
|
29
|
+
returnTo?: HTMLElement | null;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
title: string;
|
|
32
|
+
/** A nested panel's way back (Border › Color): a ← in the head. */
|
|
33
|
+
onBack?: () => void;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
/** Its width beside the column, in px (default 280). A sheet at phone width is the screen's. */
|
|
36
|
+
width?: number;
|
|
37
|
+
/** `beside` (default): beside the anchor's column, as a setting's panel. `below`: under the anchor, as a menu from a top bar. */
|
|
38
|
+
placement?: "beside" | "below";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const GAP = 8, EDGE = 8;
|
|
42
|
+
// A layout effect in the browser (placed before paint), a plain one on a server render (the editor catalog's), as team-chat.tsx.
|
|
43
|
+
const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
44
|
+
const PHONE = "(max-width: 47.9975em)";
|
|
45
|
+
|
|
46
|
+
/** The column the anchor sits in: its nearest ancestor that scrolls up and down (the settings panel), whether or not it overflows
|
|
47
|
+
* now (a short panel is still the panel). */
|
|
48
|
+
function columnOf(el: HTMLElement): HTMLElement | null {
|
|
49
|
+
for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
50
|
+
const oy = getComputedStyle(p).overflowY;
|
|
51
|
+
if (oy === "auto" || oy === "scroll") return p;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The card around the scrolling column: the boxes that only pad or border it (each edge within 24px of the column's), up to
|
|
57
|
+
* the first that is wider (a layout). The popover sits beside the card, not over its edge (measured in the page editor: the
|
|
58
|
+
* settings body ends at 372, its card at 389). */
|
|
59
|
+
function cardOf(col: HTMLElement): HTMLElement {
|
|
60
|
+
const c = col.getBoundingClientRect();
|
|
61
|
+
let card = col;
|
|
62
|
+
for (let p = col.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
63
|
+
const r = p.getBoundingClientRect();
|
|
64
|
+
// Only a box that HOLDS the column is its card: a zero box (`display: contents`) or a narrower wrapper is passed over, or the
|
|
65
|
+
// popover was placed against its rect, over the column (review of #5323).
|
|
66
|
+
if (r.left > c.left + 0.5 || r.right < c.right - 0.5) continue;
|
|
67
|
+
if (r.left < c.left - 24 || r.right > c.right + 24) break;
|
|
68
|
+
card = p;
|
|
69
|
+
}
|
|
70
|
+
return card;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Beside the column's card on the side with room (right first), top at the anchor's row, on screen; neither: under the anchor. */
|
|
74
|
+
function place(layer: HTMLElement, anchor: HTMLElement, width: number, placement: "beside" | "below") {
|
|
75
|
+
if (window.matchMedia?.(PHONE).matches) { layer.style.left = layer.style.top = layer.style.maxHeight = ""; layer.dataset.side = "sheet"; return; }
|
|
76
|
+
layer.style.width = `${width}px`;
|
|
77
|
+
if (placement === "below") { placeFloating(layer, anchor); return; }
|
|
78
|
+
const column = columnOf(anchor);
|
|
79
|
+
const col = (column ? cardOf(column) : anchor).getBoundingClientRect();
|
|
80
|
+
const r = anchor.getBoundingClientRect();
|
|
81
|
+
const vw = document.documentElement.clientWidth, vh = window.innerHeight;
|
|
82
|
+
const right = vw - col.right - GAP - EDGE, left = col.left - GAP - EDGE;
|
|
83
|
+
if (right < width && left < width) { placeFloating(layer, anchor); return; }
|
|
84
|
+
layer.style.maxHeight = `${vh - 2 * EDGE}px`;
|
|
85
|
+
const h = Math.min(layer.offsetHeight, vh - 2 * EDGE);
|
|
86
|
+
const top = Math.max(EDGE, Math.min(r.top, vh - EDGE - h));
|
|
87
|
+
const x = right >= width ? col.right + GAP : col.left - GAP - width;
|
|
88
|
+
layer.style.left = `${Math.round(x)}px`;
|
|
89
|
+
layer.style.top = `${Math.round(top)}px`;
|
|
90
|
+
layer.dataset.side = right >= width ? "right" : "left";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function Popover({ open, anchor, returnTo, onClose, title, onBack, children, width = 280, placement = "beside" }: PopoverProps) {
|
|
94
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
95
|
+
const titleId = useId();
|
|
96
|
+
const floating = canFloatMenus();
|
|
97
|
+
const close = useRef(onClose);
|
|
98
|
+
close.current = onClose;
|
|
99
|
+
|
|
100
|
+
useIsoLayoutEffect(() => {
|
|
101
|
+
const el = ref.current;
|
|
102
|
+
if (!open || !el || !anchor) return;
|
|
103
|
+
if (floating) {
|
|
104
|
+
if (el.getAttribute("popover") !== "manual") el.setAttribute("popover", "manual");
|
|
105
|
+
if (!el.matches(":popover-open")) el.showPopover();
|
|
106
|
+
}
|
|
107
|
+
const again = () => { if (floating) place(el, anchor, width, placement); };
|
|
108
|
+
again();
|
|
109
|
+
// The focus goes in (the first thing to use, else the layer), and comes back to the anchor however it closes.
|
|
110
|
+
(el.querySelector<HTMLElement>("[data-autofocus]") ?? el).focus({ preventScroll: true });
|
|
111
|
+
// A scroll that moves the anchor (the page, or a box the anchor is in): placed again. Others (a chat streaming beside it, a
|
|
112
|
+
// scroll inside it) leave it be, as the kit menu's closeDetachedMenus does.
|
|
113
|
+
const onScroll = (e: Event) => {
|
|
114
|
+
const t = e.target;
|
|
115
|
+
if (t instanceof Node && el.contains(t)) return;
|
|
116
|
+
if (t === document || t === document.documentElement || (t instanceof Node && t.contains(anchor))) again();
|
|
117
|
+
};
|
|
118
|
+
const onDown = (e: PointerEvent) => { const t = e.target as Node; if (!el.contains(t) && !anchor.contains(t)) close.current(); };
|
|
119
|
+
// The canvas is an iframe: a press in it never reaches this document, but the focus leaving for it does.
|
|
120
|
+
const onBlur = () => { setTimeout(() => { if (document.activeElement instanceof HTMLIFrameElement) close.current(); }, 0); };
|
|
121
|
+
const grows = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(again);
|
|
122
|
+
grows?.observe(el);
|
|
123
|
+
window.addEventListener("scroll", onScroll, true);
|
|
124
|
+
window.addEventListener("resize", again);
|
|
125
|
+
window.addEventListener("blur", onBlur);
|
|
126
|
+
document.addEventListener("pointerdown", onDown, true);
|
|
127
|
+
return () => {
|
|
128
|
+
grows?.disconnect();
|
|
129
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
130
|
+
window.removeEventListener("resize", again);
|
|
131
|
+
window.removeEventListener("blur", onBlur);
|
|
132
|
+
document.removeEventListener("pointerdown", onDown, true);
|
|
133
|
+
if (floating && el.matches(":popover-open")) el.hidePopover();
|
|
134
|
+
};
|
|
135
|
+
}, [open, anchor, floating, width, placement]);
|
|
136
|
+
|
|
137
|
+
const shut = () => { onClose(); (returnTo ?? anchor)?.focus({ preventScroll: true }); };
|
|
138
|
+
const back = () => {
|
|
139
|
+
onBack?.();
|
|
140
|
+
// The panel it steps back to is drawn next, and what had the focus (← Back, a box) may be gone with it: the focus stays in the
|
|
141
|
+
// popover (its [data-autofocus], else the layer), never on <body>.
|
|
142
|
+
requestAnimationFrame(() => {
|
|
143
|
+
const el = ref.current;
|
|
144
|
+
if (el && !el.contains(document.activeElement)) (el.querySelector<HTMLElement>("[data-autofocus]") ?? el).focus({ preventScroll: true });
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
if (!open) return null;
|
|
148
|
+
const layer = (
|
|
149
|
+
<div ref={ref} className={`gemboss-ei-pop gemboss-popover-surface${floating ? "" : " gemboss-ei-pop--inline"}`} role="dialog" aria-labelledby={titleId}
|
|
150
|
+
tabIndex={-1} onKeyDown={(e) => { if (e.key === "Escape" && !e.nativeEvent.isComposing) { e.preventDefault(); e.stopPropagation(); if (onBack) back(); else shut(); } }}>
|
|
151
|
+
<div className="gemboss-ei-pop-head">
|
|
152
|
+
{onBack ? <button type="button" className="gemboss-ei-pop-btn" aria-label="Back" onClick={back}><Icon name="chevronLeft" size={16} /></button> : null}
|
|
153
|
+
<span className="gemboss-ei-pop-title" id={titleId}>{title}</span>
|
|
154
|
+
<button type="button" className="gemboss-ei-pop-btn" aria-label="Close" onClick={shut}><Icon name="close" size={16} /></button>
|
|
155
|
+
</div>
|
|
156
|
+
<div className="gemboss-ei-pop-body">{children}</div>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
return floating && typeof document !== "undefined" ? createPortal(layer, document.body) : layer;
|
|
160
|
+
}
|
package/src/editor/swatch.ts
CHANGED
|
@@ -115,7 +115,8 @@ export function parseColor(value: string): Rgba | null {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const hex2 = (n: number) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0");
|
|
118
|
-
|
|
118
|
+
/** `#rrggbb` of a colour's channels (rounded, clamped): the swatch's, pickSwatch's and the colour picker's one way of writing hex. */
|
|
119
|
+
export const hexOf = (c: Pick<Rgba, "r" | "g" | "b">) => `#${hex2(c.r)}${hex2(c.g)}${hex2(c.b)}`;
|
|
119
120
|
const alphaText = (a: number) => String(Math.round(a * 100) / 100);
|
|
120
121
|
|
|
121
122
|
/** A colour written as the field already writes it: a hex stays a hex, anything else becomes `rgb()`; with transparency `rgba()`. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-ei-swatch{display:grid;padding:2px}.gemboss-ei-swatch-fill{display:block;border-radius:6px;background:linear-gradient(var(--sw,#fff),var(--sw,#fff)),conic-gradient(#d8dbe0 25%,#fff 0 50%,#d8dbe0 0 75%,#fff 0) 0 0/8px 8px}.gemboss-ei-swatch[data-empty] .gemboss-ei-swatch-fill{background:linear-gradient(to top right,#0000 46%,var(--ui-text-muted,#686b71) 46% 54%,#0000 54%),#fff}.gemboss-ei-swatch[aria-expanded=true]{border-color:var(--ui-focus,#5661f5);box-shadow:0 0 0 1px var(--ui-focus,#5661f5)}.gemboss-ei-cp{display:flex;flex-direction:column;gap:var(--ui-space-3,12px);min-width:0}.gemboss-ei-cp-area{position:relative;height:160px;border-radius:var(--ui-radius-md,8px);background:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,var(--cp-hue,red));cursor:crosshair;touch-action:none;outline:none}.gemboss-ei-cp-area:focus-visible{box-shadow:0 0 0 2px var(--ui-surface,#fff),0 0 0 4px var(--ui-focus,#5661f5)}.gemboss-ei-cp-thumb{position:absolute;width:14px;height:14px;box-sizing:border-box;border:2px solid #fff;border-radius:50%;background:var(--cp-now,#fff);box-shadow:0 0 0 1px #0000004d,inset 0 0 0 1px #0000004d;transform:translate(-50%,-50%);pointer-events:none}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha){-webkit-appearance:none;appearance:none;display:block;width:100%;height:12px;margin:0;border-radius:6px;cursor:pointer;outline:none}.gemboss-ei-cp-hue{background:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.gemboss-ei-cp-alpha{background:linear-gradient(to right,#0000,var(--cp-now,#000)),conic-gradient(#d8dbe0 25%,#fff 0 50%,#d8dbe0 0 75%,#fff 0) 0 0/8px 8px}.gemboss-ei-cp-alpha:disabled{opacity:.4;cursor:default}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha)::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 0 1px #00000059,inset 0 0 0 1px #00000059}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha)::-moz-range-thumb{width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 0 1px #00000059}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha):focus-visible{box-shadow:0 0 0 2px var(--ui-surface,#fff),0 0 0 4px var(--ui-focus,#5661f5)}.gemboss-ei-cp-row{display:flex;align-items:center;gap:var(--ui-space-2,8px)}.gemboss-ei-cp-now{flex:none;width:32px;height:32px;box-sizing:border-box;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:linear-gradient(var(--cp-now,#fff),var(--cp-now,#fff)),conic-gradient(#d8dbe0 25%,#fff 0 50%,#d8dbe0 0 75%,#fff 0) 0 0/8px 8px}.gemboss-ei-cp-hex{flex:1;min-width:0;font-variant-numeric:tabular-nums;text-transform:uppercase}.gemboss-ei-cp-pct{flex:none;min-width:36px;text-align:right;font-size:var(--ui-fs-caption,12px);color:var(--ui-text-muted,#686b71);font-variant-numeric:tabular-nums}.gemboss-ei-cp-drop{flex:none;display:grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:var(--ui-surface,#fff);color:var(--ui-text-strong,#1b1c1e);cursor:pointer}.gemboss-ei-cp-drop:hover{background:var(--ui-surface-2,#eceef2)}.gemboss-ei-cp-drop:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:1px}.gemboss-ei-cp-group{display:flex;flex-direction:column;gap:6px}.gemboss-ei-cp-label{font-size:var(--ui-fs-caption,12px);line-height:16px;font-weight:550;color:var(--ui-text-muted,#686b71)}.gemboss-ei-cp-chips{display:flex;flex-wrap:wrap;gap:var(--ui-space-2,8px)}.gemboss-ei-cp-none{align-self:flex-start;display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:0 10px 0 6px;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:var(--ui-surface,#fff);font:inherit;font-size:var(--ui-fs-caption,12px);font-weight:550;color:var(--ui-text-strong,#1b1c1e);cursor:pointer}.gemboss-ei-cp-none[aria-pressed=true]{border-color:var(--ui-focus,#5661f5);box-shadow:inset 0 0 0 1px var(--ui-focus,#5661f5)}.gemboss-ei-cp-none:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:1px}.gemboss-ei-cp-none-sw{width:16px;height:16px;box-sizing:border-box;border:1px solid var(--ui-border,#e5e7ea);border-radius:4px;background:linear-gradient(to top right,#0000 44%,var(--gemboss-danger,#d72c0d) 44% 56%,#0000 56%),#fff}@media (pointer:coarse),(max-width:47.9975em){.gemboss-ei-color .gemboss-ei-swatch{width:44px;height:44px}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha){height:44px;border-radius:0;background-clip:content-box;padding:16px 0;box-sizing:border-box}.gemboss-ei-cp-hue{background:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red) content-box}.gemboss-ei-cp :is(.gemboss-ei-cp-hue,.gemboss-ei-cp-alpha)::-webkit-slider-thumb{width:24px;height:24px}.gemboss-ei-cp-drop,.gemboss-ei-cp-now{width:44px;height:44px}.gemboss-ei-cp-none{min-height:44px}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-ei-pickgrid{list-style:none;margin:0;padding:2px;display:grid;grid-template-columns:repeat(auto-fill,minmax(min(120px,calc(50% - 6px)),1fr));gap:var(--ui-space-3,12px);max-height:min(60vh,520px);overflow-y:auto;outline:none}.gemboss-ei-pickgrid.is-icon{grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:6px}.gemboss-ei-pickgrid.is-reloading{opacity:.55}.gemboss-ei-pickgrid-tile{position:relative;display:flex;flex-direction:column;gap:2px;min-width:0;padding:4px;border:1px solid transparent;border-radius:var(--ui-radius-lg,12px);cursor:pointer;color:inherit}.is-icon>.gemboss-ei-pickgrid-tile{align-items:center;justify-content:center;gap:4px;min-height:56px;padding:6px 4px;border-color:var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px)}.gemboss-ei-pickgrid-tile:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pickgrid-tile.is-active:not([aria-disabled=true]){background:var(--ui-surface-2,#eceef2)}.gemboss-ei-pickgrid-tile[aria-selected=true]{border-color:var(--ui-focus,#5661f5);box-shadow:inset 0 0 0 1px var(--ui-focus,#5661f5);background:var(--gemboss-accent-soft,#eef0fe)}.gemboss-ei-pickgrid:focus-visible>.gemboss-ei-pickgrid-tile.is-active{outline:2px solid var(--ui-focus,#5661f5);outline-offset:1px}.gemboss-ei-pickgrid-tile[aria-disabled=true]{cursor:default}.gemboss-ei-pickgrid-pic{display:grid;place-items:center;width:100%;aspect-ratio:1;box-sizing:border-box;object-fit:cover;border-radius:var(--ui-radius-md,8px);background:var(--ui-surface-2,#eceef2);color:var(--ui-text-muted,#686b71)}.gemboss-ei-pickgrid-pic.is-whole{object-fit:contain;padding:8px}.gemboss-ei-pickgrid-pic.is-checker{background:conic-gradient(var(--ui-border,#d8dbe0) 25%,var(--ui-surface,#fff) 0 50%,var(--ui-border,#d8dbe0) 0 75%,var(--ui-surface,#fff) 0) 0 0/12px 12px}.is-icon .gemboss-ei-pickgrid-pic{width:26px;height:26px;aspect-ratio:auto;background:none;color:inherit}.gemboss-ei-pickgrid-name,.gemboss-ei-pickgrid-sub{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-fs-caption,12px);line-height:16px}.gemboss-ei-pickgrid-name{margin-top:4px;font-weight:550;color:var(--ui-text-strong,#1b1c1e)}.is-icon .gemboss-ei-pickgrid-name{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;margin-top:0;white-space:normal;overflow-wrap:anywhere;font-weight:450;text-align:center}.gemboss-ei-pickgrid-sub{color:var(--ui-text-muted,#686b71)}.gemboss-ei-pickgrid-tile.is-error .gemboss-ei-pickgrid-sub{white-space:normal;color:var(--gemboss-danger-strong,var(--gemboss-danger,#c4291c))}.gemboss-ei-pickgrid-tile.is-busy .gemboss-ei-pickgrid-pic:after{content:"";width:16px;height:16px;border:2px solid var(--ui-border,#e5e7ea);border-top-color:var(--ui-focus,#5661f5);border-radius:50%;animation:gemboss-ei-pickgrid-spin .8s linear infinite}@keyframes gemboss-ei-pickgrid-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.gemboss-ei-pickgrid-tile.is-busy .gemboss-ei-pickgrid-pic:after{animation:none}}.gemboss-ei-pickgrid-check{position:absolute;top:8px;right:8px;padding:2px;border-radius:50%;background:var(--ui-focus,#5661f5);color:#fff}.is-icon .gemboss-ei-pickgrid-check{top:2px;right:2px;padding:1px}.gemboss-ei-pickgrid-skeleton{display:flex;flex-direction:column;gap:6px;padding:4px}.gemboss-ei-pickgrid-skeleton>.gemboss-ei-pickgrid-pic{height:auto}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-ei-pick{display:flex;flex-direction:column;gap:var(--ui-space-3,12px);min-width:0}.gemboss-ei-pick-search{flex:none}.gemboss-ei-pick-search-icon{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-clear{flex:none;display:grid;place-items:center;width:24px;height:24px;margin-right:var(--ui-space-1,4px);padding:0;border:0;border-radius:var(--ui-radius-sm,6px);background:none;color:var(--ui-text-muted,#686b71);cursor:pointer}.gemboss-ei-pick-clear:hover{background:var(--ui-surface-2,#eceef2);color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-clear:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:0}.gemboss-ei-pick-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;max-height:min(50vh,420px);overflow-y:auto;outline:none}.gemboss-ei-pick-row{flex:none;display:flex;align-items:center;gap:var(--ui-space-3,12px);min-height:44px;padding:var(--ui-space-2,8px);border-radius:var(--ui-radius-md,8px);cursor:pointer;color:inherit}.gemboss-ei-pick-row:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row.is-active:not([aria-disabled=true]){background:var(--ui-surface-2,#eceef2)}.gemboss-ei-pick-row[aria-selected=true]{background:var(--gemboss-accent-soft,#eef0fe)}.gemboss-ei-pick-row[aria-selected=true]:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row[aria-selected=true].is-active:not([aria-disabled=true]){background:color-mix(in srgb,var(--ui-focus,#5661f5) 6%,var(--gemboss-accent-soft,#eef0fe))}.gemboss-ei-pick-list:focus-visible>.gemboss-ei-pick-row.is-active{outline:2px solid var(--ui-focus,#5661f5);outline-offset:-2px}.gemboss-ei-pick-row[aria-disabled=true]{cursor:default}.gemboss-ei-pick-list:not(.is-reloading) .gemboss-ei-pick-row[aria-disabled=true] :is(.gemboss-ei-pick-title,.gemboss-ei-pick-media){opacity:.55}.gemboss-ei-pick-list.is-reloading{opacity:.55}.gemboss-ei-pick-media{flex:none;display:grid;place-items:center;width:40px;height:40px;box-sizing:border-box;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:var(--ui-surface-2,#eceef2);object-fit:cover;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.gemboss-ei-pick-head{display:flex;align-items:center;gap:var(--ui-space-2,8px);min-width:0}.gemboss-ei-pick-title{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-fs-body,13px);line-height:20px;font-weight:650;color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-head>.ui-tag{flex:none}.gemboss-ei-pick-sub{display:flex;min-width:0;font-size:var(--ui-fs-body,13px);line-height:20px;color:var(--ui-text-muted,#686b71);white-space:nowrap}.gemboss-ei-pick-note{flex:0 0 auto;max-width:100%;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note.is-blocked{color:var(--gemboss-danger-strong,var(--gemboss-danger,#c4291c))}.gemboss-ei-pick-rest{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note+.gemboss-ei-pick-rest{margin-left:.25em}.gemboss-ei-pick-check{flex:none;color:var(--ui-focus,#5661f5)}.gemboss-ei-pick-drill{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-error{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--ui-space-3,12px)}.gemboss-ei-pick-more>.ui-btn{width:100%}.gemboss-ei-pick-skeleton{display:flex;flex-direction:column}.gemboss-ei-pick-skeleton-row{display:flex;align-items:center;gap:var(--ui-space-3,12px);padding:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-row>.gemboss-ei-pick-media{height:40px;border:0}.gemboss-ei-pick-skeleton-text{flex:1;display:flex;flex-direction:column;gap:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-text>:first-child{width:40%}.gemboss-ei-pick-skeleton-text>:last-child{width:70%}@media (pointer:coarse),(max-width:47.9975em){.gemboss-ei-pick-clear{width:44px;height:44px;margin-right:0}}
|
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 N=5,K=360,A=typeof WeakSet=="function"?new WeakSet:null,u=function(t,e,r){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},M=function(t,e){var r=Number(t);return isFinite(r)&&r>0?r:e};function d(t){return t.querySelector(".gemboss-editor-body")}function b(t){var e=d(t);return e&&e.querySelector(":scope > .gemboss-editor-resizer")}function p(t){var e=b(t);return{min:M(e&&e.getAttribute("aria-valuemin"),300),cap:M(e&&(e.getAttribute("data-gb-max")||e.getAttribute("aria-valuemax")),680)}}function C(t){var e=p(t),r=d(t),i=r?r.getBoundingClientRect().width:0;return i>0?Math.max(e.min,Math.min(e.cap,i-K-N)):e.cap}var w=typeof WeakMap=="function"?new WeakMap:null;function q(t){var e=w?w.get(t):t._gbWant;return e??S(t)}function O(t,e){w?w.set(t,e):t._gbWant=e}function m(t,e,r,i){var a=d(t),n=b(t);if(a){var s=i??C(t),o=p(t),l=Math.round(Math.min(s,Math.max(o.min,e)));if(a.style.setProperty("--gemboss-chat-w",l+"px"),n&&(n.setAttribute("aria-valuenow",String(l)),n.setAttribute("aria-valuemax",String(s))),r){O(t,l);var f=a.getAttribute("data-gb-storage");if(f)try{localStorage.setItem(f,String(l))}catch{}u(t,"gemboss:editor-split",{width:l})}return l}}function S(t){var e=b(t);return M(e&&e.getAttribute("aria-valuenow"),384)}function U(t){var e=d(t),r=b(t);if(!(!e||!r)){r.hasAttribute("data-gb-max")||r.setAttribute("data-gb-max",r.getAttribute("aria-valuemax")||"680");var i=e.getAttribute("data-gb-storage"),a=S(t);if(i)try{var n=Number(localStorage.getItem(i));n>=p(t).min&&n<=p(t).cap&&(a=n)}catch{}O(t,a),e.classList.contains("is-chat-collapsed")||m(t,a,!1)}}function j(t,e){var r=d(t);if(r&&!(e.button!==0||e.isPrimary===!1)){e.preventDefault();var i=r.getBoundingClientRect().left,a=C(t),n=0,s=S(t);document.body.classList.add("ui-resizing");var o=function(f){s=f.clientX-i-N,n||(n=requestAnimationFrame(function(){n=0,m(t,s,!1,a)}))},l=function(){n&&cancelAnimationFrame(n),document.body.classList.remove("ui-resizing"),removeEventListener("pointermove",o),removeEventListener("pointerup",l),removeEventListener("pointercancel",l),removeEventListener("blur",l),m(t,s,!0,a)};addEventListener("pointermove",o),addEventListener("pointerup",l),addEventListener("pointercancel",l),addEventListener("blur",l)}}function H(t,e){if(!(e.altKey||e.metaKey||e.ctrlKey)){var r=e.shiftKey?64:16,i=S(t),a=p(t);if(e.key==="ArrowLeft")i-=r;else if(e.key==="ArrowRight")i+=r;else if(e.key==="Home")i=a.min;else if(e.key==="End")i=C(t);else return;e.preventDefault(),m(t,i,!0)}}function G(t,e){var r=d(t);if(r){var i=!r.classList.contains("is-chat-collapsed");r.classList.toggle("is-chat-collapsed",i),i?r.style.setProperty("--gemboss-chat-w","0px"):m(t,q(t),!1),e.classList.toggle("collapsed",i),e.setAttribute("aria-pressed",String(i)),e.setAttribute("aria-label",i?"Show chat panel":"Hide chat panel"),e.title=i?"Show chat panel":"Hide chat \u2014 full-width preview";var a=e.querySelector("rect[fill='currentColor']");a&&(a.style.display=i?"none":""),u(t,"gemboss:editor-chat",{collapsed:i})}}function V(t,e){var r=e.closest(".gemboss-pv-devices");r&&(r.querySelectorAll(".gemboss-pv-device").forEach(function(i){var a=i===e;i.classList.toggle("active",a),i.setAttribute("aria-pressed",String(a))}),u(t,"gemboss:editor-device",{device:e.getAttribute("data-device")||(e.title||"").toLowerCase()}))}function X(t,e){var r=e.getAttribute("data-pane")||(Array.prototype.indexOf.call(e.parentNode.children,e)===0?"chat":"preview"),i=d(t);i&&(i.setAttribute("data-mobile-pane",r),e.parentNode.querySelectorAll(".gemboss-editor-mobile-tab").forEach(function(a){var n=a===e;a.classList.toggle("active",n),a.setAttribute("aria-selected",String(n))}),u(t,"gemboss:editor-pane",{pane:r}))}var c=null;function I(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(),i=e.right-r.right;r.left+i<8&&(i=8-r.left),Math.abs(i)>=.5&&(t.menu.style.right=parseFloat(t.menu.style.right)-i+"px")}function h(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 J(t,e){var r=e.nextElementSibling;if(!r||!r.classList.contains("gemboss-editor-menu"))return!1;var i=c&&c.trigger===e;return h(!1),i||(c={root:t,trigger:e,menu:r},r.hidden=!1,e.setAttribute("aria-expanded","true"),e.classList.add("active"),I(c),u(t,"gemboss:editor-menu",{open:!0,menu:r})),!0}var P=!1;function Q(){P||(P=!0,document.addEventListener("pointerdown",function(t){c&&!c.menu.contains(t.target)&&!c.trigger.contains(t.target)&&h(!1)}),addEventListener("keydown",function(t){t.key!=="Escape"||!c||t.isComposing||t.keyCode===229||(t.preventDefault(),t.stopImmediatePropagation(),h(!0))},!0),addEventListener("resize",function(){c&&I(c)}),addEventListener("blur",function(){h(!1)}))}function Y(t){var e=t&&t.classList&&t.classList.contains("gemboss-editor")?[t]:Array.prototype.slice.call((t||document).querySelectorAll(".gemboss-editor"));return Q(),e.forEach(function(r){if(!(A?A.has(r):r._gbEditor)){A?A.add(r):r._gbEditor=!0,U(r);var i=d(r);i&&typeof ResizeObserver=="function"&&new ResizeObserver(function(){i.classList.contains("is-chat-collapsed")||m(r,q(r),!1)}).observe(i),r.addEventListener("pointerdown",function(a){var n=a.target.closest(".gemboss-editor-resizer");n&&n===b(r)&&j(r,a)}),r.addEventListener("keydown",function(a){a.target.classList&&a.target.classList.contains("gemboss-editor-resizer")&&a.target===b(r)&&H(r,a)}),r.addEventListener("click",function(a){var n=a.target,s;if(s=n.closest(".gemboss-editor-chat-toggle"))return G(r,s);if(s=n.closest(".gemboss-pv-devices .gemboss-pv-device"))return V(r,s);if(s=n.closest(".gemboss-editor-mobile-tab"))return X(r,s);if((s=n.closest('[aria-haspopup="menu"]'))&&J(r,s)){a.stopPropagation();return}c&&(s=n.closest(".gemboss-editor-menu-item"))&&c.menu.contains(s)&&h(!0)})}}),e.length}g.initEditorFrame=Y;function y(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,i,a,n;if(e){var s=e[1].length<=4?e[1].replace(/./g,"$&$&"):e[1];return n=function(ue){return parseInt(s.substr(ue,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 o=r[1].split("/");if(i=o[0].indexOf(",")>=0?o[0].split(","):o[0].trim().split(/\s+/),o.length===2&&i.push(o[1]),o.length>2||i.length<3||i.length>4)return null;var l=[];for(a=0;a<i.length;a++){var f=i[a].trim(),v=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?%?$/i.test(f)?parseFloat(f):f==="none"?0:NaN;if(isNaN(v))return null;/%$/.test(f)&&(v=v/100*(a<3?255:1)),l.push(a<3?Math.min(255,Math.max(0,Math.round(v))):Math.min(1,Math.max(0,v)))}return{r:l[0],g:l[1],b:l[2],a:l.length===4?l[3]:1}}function W(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?W(e):"rgb("+e.r+", "+e.g+", "+e.b+")"}function _(t,e){var r=y(e),i=y(t);return r?B(t,r,i?i.a:1):t}function T(t,e){var r=y(t);return r&&isFinite(e)?B(t,r,Math.min(100,Math.max(0,Math.round(e)))/100):t}g.colorOf=y,g.pickSwatch=_,g.withOpacity=T;var F=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,i=R(r),a=i.some(function(n){return n.hasAttribute("tabindex")});i.forEach(function(n){var s=n===t;n.setAttribute("aria-selected",String(s)),n.classList.contains("gemboss-ei-tab")&&n.classList.toggle("on",s),a&&n.setAttribute("tabindex",s?"0":"-1");var o=n.getAttribute("aria-controls"),l=o&&document.getElementById(o);l&&(l.hidden=!s)}),e&&t.focus(),u(t,"gemboss:editor-tab",{tab:F(t),index:i.indexOf(t)})}function Z(t,e){if(!(e.key!=="ArrowRight"&&e.key!=="ArrowLeft")){var r=R(t);if(r.some(function(n){return n.hasAttribute("tabindex")})){var i=r.findIndex(function(n){return n.getAttribute("aria-selected")==="true"}),a=e.key==="ArrowRight"?(i+1)%r.length:(i-1+r.length)%r.length;e.preventDefault(),z(r[a],!0)}}}function ee(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 te(t){var e=t.closest(".gemboss-ei-seg");Array.prototype.forEach.call(e.querySelectorAll("button"),function(r){var i=r===t;r.classList.toggle("active",i),r.classList.toggle("on",i),r.hasAttribute("aria-pressed")&&r.setAttribute("aria-pressed",String(i))}),u(e,"gemboss:editor-seg",{value:F(t)})}var re={text:"Text",accent:"Accent","accent-text":"Accent text",muted:"Muted",background:"Background",surface:"Surface",border:"Border",success:"Success",warning:"Warning",danger:"Danger"},ie=0;function ae(t){var e=t.trim(),r=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(e);if(r){var i=r[1].toLowerCase();return"Theme color: "+(re[i]||i.charAt(0).toUpperCase()+i.slice(1).replace(/-/g," "))+". Type a color to use your own."}return/^var\(/i.test(e)?"A theme value. 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."}function L(t){var e=t.querySelector(".gemboss-ei-swatch"),r=t.querySelector("input:not([type=color]):not([data-alpha])");if(!(!e||!r)){var i=r.value,a=y(i),n=!i||!!a;e.value=a?W(a):"#000000";var s=t.querySelector("input[data-alpha]");a&&!s&&(s=document.createElement("input"),s.className="gemboss-field gemboss-ei-inp",s.setAttribute("data-alpha",""),s.setAttribute("inputmode","numeric"),s.setAttribute("aria-label",(e.getAttribute("aria-label")||"Color swatch").replace(/ swatch$/,"")+" opacity"),s.style.flex="0 0 64px",r.parentNode.insertBefore(s,r.nextSibling)),s&&(s.hidden=!a,a&&(s.value=Math.round(a.a*100)+"%"),s.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 l=ae(i);e.title=l,o||(o=document.createElement("p"),o.className="gemboss-ei-color-why",t.appendChild(o)),o.id||(o.id="gemboss-ei-color-why-"+ ++ie),o.textContent=l,e.setAttribute("aria-describedby",o.id)}}function ne(t){for(var e=t.labels||[],r=null,i=0;i<e.length&&!r;i++)r=e[i].querySelector(".gemboss-ei-rangeval");r&&(r.textContent=t.value+(r.getAttribute("data-suffix")||""))}function se(t){var e={},r=["t","r","b","l"];return Array.prototype.forEach.call(t.querySelectorAll("input"),function(i,a){e[r[a]]=i.value.trim()}),e}function $(t){return'url("'+t.replace(/["\\]/g,"\\$&").replace(/[\u0000-\u001f\u007f]/g,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})+'")'}g.cssUrl=$;function oe(t,e){var r=t.querySelector(".gemboss-ei-img-thumb");r&&(r.style.backgroundImage=e?$(e):"",r.textContent=e?"":"\u2014")}function D(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),oe(t,e.value),u(t,"gemboss:editor-image",{value:e.value}))}var E=typeof WeakSet=="function"?new WeakSet:null,x=function(t){return t.__gbPanel?!1:(t.__gbPanel=!0,!0)};function le(t){var e=t||document;return(E?E.has(e):e._gbPanel)?0:(E?E.add(e):e._gbPanel=!0,Array.prototype.forEach.call(e.querySelectorAll(".gemboss-ei-color"),L),e.addEventListener("click",function(r){var i=r.target,a;if(!(!i.closest||!x(r))){if(a=i.closest('.gemboss-ec-tabs > [role="tab"], .gemboss-ei-tabs > [role="tab"]'))return z(a,!1);if(a=i.closest(".gemboss-ei-gh"))return ee(a);if((a=i.closest(".gemboss-ei-seg button"))&&!a.disabled)return te(a);if((a=i.closest("[data-gb-image-clear]"))&&!a.disabled){var n=a.closest(".gemboss-ei-img"),s=n&&n.querySelector(".gemboss-ei-img-ctl input");s&&(s.value="",D(n,s))}}}),e.addEventListener("keydown",function(r){var i=r.target;if(!(!i.closest||!x(r))){var a=i.closest('.gemboss-ec-tabs[role="tablist"], .gemboss-ei-tabs[role="tablist"]');if(a&&i.getAttribute("role")==="tab")return Z(a,r);r.key==="Enter"&&i.tagName==="INPUT"&&i.type!=="color"&&i.type!=="range"&&i.closest(".gemboss-ei-color, .gemboss-ei-edgebox, .gemboss-ei-img")&&(r.preventDefault(),i.blur())}}),e.addEventListener("input",function(r){var i=r.target;if(!(!i.closest||!x(r))){if(i.classList.contains("gemboss-ei-range")){ne(i),u(i,"gemboss:editor-range",{value:Number(i.value)});return}if(i.classList.contains("gemboss-ei-swatch")){var a=i.closest(".gemboss-ei-color"),n=a&&a.querySelector("input:not([type=color]):not([data-alpha])"),s=n?_(n.value,i.value):i.value;n&&(n.value=s),u(a||i,"gemboss:editor-color",{value:s})}}}),e.addEventListener("focusout",function(r){var i=r.target;if(!(!i.closest||i.tagName!=="INPUT"||!x(r))){var a;if(i.hasAttribute("data-alpha")&&(a=i.closest(".gemboss-ei-color"))){var n=a.querySelector("input:not([type=color]):not([data-alpha])"),s=Number(String(i.value).replace(/%/g,"").trim()),o=n&&String(i.value).trim()&&isFinite(s)?T(n.value,s):null;o&&o!==n.value?(n.value=o,L(a),u(a,"gemboss:editor-color",{value:o})):L(a);return}if(i.type!=="color"&&(a=i.closest(".gemboss-ei-color"))){L(a),u(a,"gemboss:editor-color",{value:i.value});return}if(a=i.closest(".gemboss-ei-edgebox")){u(a,"gemboss:editor-edges",se(a));return}(a=i.closest(".gemboss-ei-img"))&&D(a,i)}}),1)}g.initEditorPanel=le})(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 C=5,D=360,w=typeof WeakSet=="function"?new WeakSet:null,u=function(t,e,r){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},M=function(t,e){var r=Number(t);return isFinite(r)&&r>0?r:e};function d(t){return t.querySelector(".gemboss-editor-body")}function b(t){var e=d(t);return e&&e.querySelector(":scope > .gemboss-editor-resizer")}function h(t){var e=b(t);return{min:M(e&&e.getAttribute("aria-valuemin"),300),cap:M(e&&(e.getAttribute("data-gb-max")||e.getAttribute("aria-valuemax")),680)}}function N(t){var e=h(t),r=d(t),i=r?r.getBoundingClientRect().width:0;return i>0?Math.max(e.min,Math.min(e.cap,i-D-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 O(t,e){S?S.set(t,e):t._gbWant=e}function v(t,e,r,i){var a=d(t),n=b(t);if(a){var s=i??N(t),l=h(t),o=Math.round(Math.min(s,Math.max(l.min,e)));if(a.style.setProperty("--gemboss-chat-w",o+"px"),n&&(n.setAttribute("aria-valuenow",String(o)),n.setAttribute("aria-valuemax",String(s))),r){O(t,o);var f=a.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=b(t);return M(e&&e.getAttribute("aria-valuenow"),384)}function K(t){var e=d(t),r=b(t);if(!(!e||!r)){r.hasAttribute("data-gb-max")||r.setAttribute("data-gb-max",r.getAttribute("aria-valuemax")||"680");var i=e.getAttribute("data-gb-storage"),a=E(t);if(i)try{var n=Number(localStorage.getItem(i));n>=h(t).min&&n<=h(t).cap&&(a=n)}catch{}O(t,a),e.classList.contains("is-chat-collapsed")||v(t,a,!1)}}function j(t,e){var r=d(t);if(r&&!(e.button!==0||e.isPrimary===!1)){e.preventDefault();var i=r.getBoundingClientRect().left,a=N(t),n=0,s=E(t);document.body.classList.add("ui-resizing");var l=function(f){s=f.clientX-i-C,n||(n=requestAnimationFrame(function(){n=0,v(t,s,!1,a)}))},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,a)};addEventListener("pointermove",l),addEventListener("pointerup",o),addEventListener("pointercancel",o),addEventListener("blur",o)}}function H(t,e){if(!(e.altKey||e.metaKey||e.ctrlKey)){var r=e.shiftKey?64:16,i=E(t),a=h(t);if(e.key==="ArrowLeft")i-=r;else if(e.key==="ArrowRight")i+=r;else if(e.key==="Home")i=a.min;else if(e.key==="End")i=N(t);else return;e.preventDefault(),v(t,i,!0)}}function G(t,e){var r=d(t);if(r){var i=!r.classList.contains("is-chat-collapsed");r.classList.toggle("is-chat-collapsed",i),i?r.style.setProperty("--gemboss-chat-w","0px"):v(t,P(t),!1),e.classList.toggle("collapsed",i),e.setAttribute("aria-pressed",String(i)),e.setAttribute("aria-label",i?"Show chat panel":"Hide chat panel"),e.title=i?"Show chat panel":"Hide chat \u2014 full-width preview";var a=e.querySelector("rect[fill='currentColor']");a&&(a.style.display=i?"none":""),u(t,"gemboss:editor-chat",{collapsed:i})}}function V(t,e){var r=e.closest(".gemboss-pv-devices");r&&(r.querySelectorAll(".gemboss-pv-device").forEach(function(i){var a=i===e;i.classList.toggle("active",a),i.setAttribute("aria-pressed",String(a))}),u(t,"gemboss:editor-device",{device:e.getAttribute("data-device")||(e.title||"").toLowerCase()}))}function X(t,e){var r=e.getAttribute("data-pane")||(Array.prototype.indexOf.call(e.parentNode.children,e)===0?"chat":"preview"),i=d(t);i&&(i.setAttribute("data-mobile-pane",r),e.parentNode.querySelectorAll(".gemboss-editor-mobile-tab").forEach(function(a){var n=a===e;a.classList.toggle("active",n),a.setAttribute("aria-selected",String(n))}),u(t,"gemboss:editor-pane",{pane:r}))}var c=null;function I(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(),i=e.right-r.right;r.left+i<8&&(i=8-r.left),Math.abs(i)>=.5&&(t.menu.style.right=parseFloat(t.menu.style.right)-i+"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 J(t,e){var r=e.nextElementSibling;if(!r||!r.classList.contains("gemboss-editor-menu"))return!1;var i=c&&c.trigger===e;return y(!1),i||(c={root:t,trigger:e,menu:r},r.hidden=!1,e.setAttribute("aria-expanded","true"),e.classList.add("active"),I(c),u(t,"gemboss:editor-menu",{open:!0,menu:r})),!0}var B=!1;function Q(){B||(B=!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&&I(c)}),addEventListener("blur",function(){y(!1)}))}function Y(t){var e=t&&t.classList&&t.classList.contains("gemboss-editor")?[t]:Array.prototype.slice.call((t||document).querySelectorAll(".gemboss-editor"));return Q(),e.forEach(function(r){if(!(w?w.has(r):r._gbEditor)){w?w.add(r):r._gbEditor=!0,K(r);var i=d(r);i&&typeof ResizeObserver=="function"&&new ResizeObserver(function(){i.classList.contains("is-chat-collapsed")||v(r,P(r),!1)}).observe(i),r.addEventListener("pointerdown",function(a){var n=a.target.closest(".gemboss-editor-resizer");n&&n===b(r)&&j(r,a)}),r.addEventListener("keydown",function(a){a.target.classList&&a.target.classList.contains("gemboss-editor-resizer")&&a.target===b(r)&&H(r,a)}),r.addEventListener("click",function(a){var n=a.target,s;if(s=n.closest(".gemboss-editor-chat-toggle"))return G(r,s);if(s=n.closest(".gemboss-pv-devices .gemboss-pv-device"))return V(r,s);if(s=n.closest(".gemboss-editor-mobile-tab"))return X(r,s);if((s=n.closest('[aria-haspopup="menu"]'))&&J(r,s)){a.stopPropagation();return}c&&(s=n.closest(".gemboss-editor-menu-item"))&&c.menu.contains(s)&&y(!0)})}}),e.length}g.initEditorFrame=Y;function m(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,i,a,n;if(e){var s=e[1].length<=4?e[1].replace(/./g,"$&$&"):e[1];return n=function(ce){return parseInt(s.substr(ce,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(i=l[0].indexOf(",")>=0?l[0].split(","):l[0].trim().split(/\s+/),l.length===2&&i.push(l[1]),l.length>2||i.length<3||i.length>4)return null;var o=[];for(a=0;a<i.length;a++){var f=i[a].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*(a<3?255:1)),o.push(a<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 T(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=m(e),i=m(t);return r?T(t,r,i?i.a:1):t}function _(t,e){var r=m(t);return r&&isFinite(e)?T(t,r,Math.min(100,Math.max(0,Math.round(e)))/100):t}g.colorOf=m,g.pickSwatch=W,g.withOpacity=_;var F=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,i=R(r),a=i.some(function(n){return n.hasAttribute("tabindex")});i.forEach(function(n){var s=n===t;n.setAttribute("aria-selected",String(s)),n.classList.contains("gemboss-ei-tab")&&n.classList.toggle("on",s),a&&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:F(t),index:i.indexOf(t)})}function Z(t,e){if(!(e.key!=="ArrowRight"&&e.key!=="ArrowLeft")){var r=R(t);if(r.some(function(n){return n.hasAttribute("tabindex")})){var i=r.findIndex(function(n){return n.getAttribute("aria-selected")==="true"}),a=e.key==="ArrowRight"?(i+1)%r.length:(i-1+r.length)%r.length;e.preventDefault(),z(r[a],!0)}}}function ee(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 te(t){var e=t.closest(".gemboss-ei-seg");Array.prototype.forEach.call(e.querySelectorAll("button"),function(r){var i=r===t;r.classList.toggle("active",i),r.classList.toggle("on",i),r.hasAttribute("aria-pressed")&&r.setAttribute("aria-pressed",String(i))}),u(e,"gemboss:editor-seg",{value:F(t)})}var re={text:"Text",accent:"Accent","accent-text":"Accent text",muted:"Muted",background:"Background",surface:"Surface",border:"Border",success:"Success",warning:"Warning",danger:"Danger"},ie=0;function ae(t){var e=t.trim(),r=/^var\(\s*--gem-color-([a-z-]+)\s*\)$/i.exec(e);if(r){var i=r[1].toLowerCase();return"Theme color: "+(re[i]||i.charAt(0).toUpperCase()+i.slice(1).replace(/-/g," "))+". Type a color to use your own."}return/^var\(/i.test(e)?"A theme value. 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."}function A(t){var e=t.querySelector(".gemboss-ei-swatch"),r=t.querySelector("input:not([type=color]):not([data-alpha])");if(!(!e||!r)){var i=r.value,a=m(i),n=!i||!!a;if(e.tagName==="BUTTON"){var s=e.querySelector(".gemboss-ei-swatch-fill");s&&(a?s.style.setProperty("--sw","rgba("+a.r+", "+a.g+", "+a.b+", "+a.a+")"):s.style.removeProperty("--sw")),i?e.removeAttribute("data-empty"):e.setAttribute("data-empty","")}else e.value=a?q(a):"#000000";var l=t.querySelector("input[data-alpha]");a&&!l&&(l=document.createElement("input"),l.className="gemboss-field gemboss-ei-inp",l.setAttribute("data-alpha",""),l.setAttribute("inputmode","numeric"),l.setAttribute("aria-label",(e.getAttribute("aria-label")||"Color swatch").replace(/ swatch$/,"")+" opacity"),l.style.flex="0 0 64px",r.parentNode.insertBefore(l,r.nextSibling)),l&&(l.hidden=!a,a&&(l.value=Math.round(a.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=ae(i);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-"+ ++ie),o.textContent=f,e.setAttribute("aria-describedby",o.id)}}function ne(t){for(var e=t.labels||[],r=null,i=0;i<e.length&&!r;i++)r=e[i].querySelector(".gemboss-ei-rangeval");r&&(r.textContent=t.value+(r.getAttribute("data-suffix")||""))}function se(t){var e={},r=["t","r","b","l"];return Array.prototype.forEach.call(t.querySelectorAll("input"),function(i,a){e[r[a]]=i.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 oe(t,e){var r=t.querySelector(".gemboss-ei-img-thumb");r&&(r.style.backgroundImage=e?U(e):"",r.textContent=e?"":"\u2014")}function $(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),oe(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 le(t){var e=t.closest(".gemboss-ei-color");if(e){var r=e.querySelector("input:not([type=color]):not([data-alpha])"),i=e.querySelector("input[data-gb-swatch-native]");i||(i=document.createElement("input"),i.type="color",i.setAttribute("data-gb-swatch-native",""),i.tabIndex=-1,i.setAttribute("aria-hidden","true"),i.style.cssText="position:absolute;width:1px;height:1px;opacity:0;pointer-events:none",t.parentNode.insertBefore(i,t.nextSibling));var a=r&&m(r.value);i.value=a?q(a):"#ffffff";try{i.showPicker?i.showPicker():i.click()}catch{i.click()}}}function ue(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 i=r.target,a;if(!(!i.closest||!x(r))){if(a=i.closest('.gemboss-ec-tabs > [role="tab"], .gemboss-ei-tabs > [role="tab"]'))return z(a,!1);if(a=i.closest(".gemboss-ei-gh"))return ee(a);if((a=i.closest(".gemboss-ei-seg button"))&&!a.disabled)return te(a);if((a=i.closest("button.gemboss-ei-swatch"))&&!a.disabled)return le(a);if((a=i.closest("[data-gb-image-clear]"))&&!a.disabled){var n=a.closest(".gemboss-ei-img"),s=n&&n.querySelector(".gemboss-ei-img-ctl input");s&&(s.value="",$(n,s))}}}),e.addEventListener("keydown",function(r){var i=r.target;if(!(!i.closest||!x(r))){var a=i.closest('.gemboss-ec-tabs[role="tablist"], .gemboss-ei-tabs[role="tablist"]');if(a&&i.getAttribute("role")==="tab")return Z(a,r);r.key==="Enter"&&i.tagName==="INPUT"&&i.type!=="color"&&i.type!=="range"&&i.closest(".gemboss-ei-color, .gemboss-ei-edgebox, .gemboss-ei-img")&&(r.preventDefault(),i.blur())}}),e.addEventListener("input",function(r){var i=r.target;if(!(!i.closest||!x(r))){if(i.classList.contains("gemboss-ei-range")){ne(i),u(i,"gemboss:editor-range",{value:Number(i.value)});return}if(i.classList.contains("gemboss-ei-swatch")||i.hasAttribute("data-gb-swatch-native")){var a=i.closest(".gemboss-ei-color"),n=a&&a.querySelector("input:not([type=color]):not([data-alpha])"),s=n?W(n.value,i.value):i.value;n&&(n.value=s),a&&i.hasAttribute("data-gb-swatch-native")&&A(a),u(a||i,"gemboss:editor-color",{value:s})}}}),e.addEventListener("focusout",function(r){var i=r.target;if(!(!i.closest||i.tagName!=="INPUT"||!x(r))){var a;if(i.hasAttribute("data-alpha")&&(a=i.closest(".gemboss-ei-color"))){var n=a.querySelector("input:not([type=color]):not([data-alpha])"),s=Number(String(i.value).replace(/%/g,"").trim()),l=n&&String(i.value).trim()&&isFinite(s)?_(n.value,s):null;l&&l!==n.value?(n.value=l,A(a),u(a,"gemboss:editor-color",{value:l})):A(a);return}if(i.type!=="color"&&(a=i.closest(".gemboss-ei-color"))){A(a),u(a,"gemboss:editor-color",{value:i.value});return}if(a=i.closest(".gemboss-ei-edgebox")){u(a,"gemboss:editor-edges",se(a));return}(a=i.closest(".gemboss-ei-img"))&&$(a,i)}}),1)}g.initEditorPanel=ue})(typeof globalThis<"u"?globalThis:this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gemboss-ei-pop[popover]{position:fixed;inset:auto;margin:0;padding:0;overflow:auto;color:inherit}.gemboss-ei-pop[popover]:not(:popover-open){display:none}.gemboss-ei-pop{box-sizing:border-box;display:flex;flex-direction:column;outline:none;z-index:40}.gemboss-ei-pop--inline{position:static;flex-basis:100%;margin-top:var(--ui-space-2,8px)}.gemboss-ei-pop-head{display:flex;align-items:center;gap:var(--ui-space-1,4px);min-height:44px;padding:0 var(--ui-space-2,8px) 0 var(--ui-space-3,12px);border-bottom:1px solid var(--ui-border,#e5e7ea)}.gemboss-ei-pop-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-fs-body,13px);line-height:20px;font-weight:650;color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pop-btn{flex:none;display:grid;place-items:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--ui-radius-sm,6px);background:none;color:var(--ui-text-muted,#686b71);cursor:pointer}.gemboss-ei-pop-btn:hover{background:var(--ui-surface-2,#eceef2);color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pop-btn:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:0}.gemboss-ei-pop-body{padding:var(--ui-space-3,12px);overflow:auto}@media (pointer:coarse),(max-width:47.9975em){.gemboss-ei-pop-btn{width:44px;height:44px}}@media (max-width:47.9975em){.gemboss-ei-pop[popover]{inset:auto 0 0;width:auto!important;max-height:85dvh;border-bottom-left-radius:0;border-bottom-right-radius:0;padding-bottom:env(safe-area-inset-bottom,0px)}}
|