@drawnagency/primitives 0.1.89 → 0.1.91
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/dist/{chunk-75P6HWPN.js → chunk-5BM2Y3NJ.js} +5 -3
- package/dist/{chunk-VK5KNH73.js → chunk-AGWE2LJG.js} +2 -2
- package/dist/{chunk-2QXJ2KGB.js → chunk-KBQNJZUX.js} +1 -1
- package/dist/{chunk-WCBYXNAG.js → chunk-KMQZYORS.js} +1 -0
- package/dist/{chunk-Y24T75HT.js → chunk-MK7YB2A4.js} +1 -1
- package/dist/{chunk-QFV5TSPO.js → chunk-SIYQ37QY.js} +12 -4
- package/dist/{chunk-J75XGXYD.js → chunk-XKRQMTE4.js} +9 -0
- package/dist/{chunk-L2MAJKKC.js → chunk-XUIJHYKI.js} +2 -2
- package/dist/{chunk-MVX4ULYE.js → chunk-ZLG7S54V.js} +241 -82
- package/dist/components/chat/ChatPanel.d.ts +14 -6
- package/dist/components/chat/ChatPanel.d.ts.map +1 -1
- package/dist/components/chat/ChatWidget.d.ts.map +1 -1
- package/dist/components/editor/AudienceIndicator.d.ts +6 -0
- package/dist/components/editor/AudienceIndicator.d.ts.map +1 -1
- package/dist/components/editor/ChildBlockWrapper.d.ts.map +1 -1
- package/dist/components/editor/ColSpanControl.d.ts.map +1 -1
- package/dist/components/editor/DragHandle.d.ts +3 -1
- package/dist/components/editor/DragHandle.d.ts.map +1 -1
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -1
- package/dist/components/editor/StatusIndicator.d.ts +7 -0
- package/dist/components/editor/StatusIndicator.d.ts.map +1 -1
- package/dist/components/editor/index.js +98 -76
- package/dist/components/primitives/index.js +3 -3
- package/dist/components/sections/Container/Container.d.ts +3 -2
- package/dist/components/sections/Container/Container.d.ts.map +1 -1
- package/dist/components/sections/Container/ContainerSettingsForm.d.ts +4 -2
- package/dist/components/sections/Container/ContainerSettingsForm.d.ts.map +1 -1
- package/dist/components/sections/Container/index.d.ts +8 -2
- package/dist/components/sections/Container/index.d.ts.map +1 -1
- package/dist/components/sections/SectionLayout.d.ts +3 -1
- package/dist/components/sections/SectionLayout.d.ts.map +1 -1
- package/dist/components/sections/ViewRenderer.d.ts +3 -1
- package/dist/components/sections/ViewRenderer.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +8 -2
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/brand-guide.js +3 -3
- package/dist/components/sections/core-sections.d.ts +8 -2
- package/dist/components/sections/core-sections.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.js +6 -6
- package/dist/components/sections/register.js +6 -6
- package/dist/components/shared/Fab.d.ts +37 -0
- package/dist/components/shared/Fab.d.ts.map +1 -0
- package/dist/components/shared/Tooltip.d.ts +8 -1
- package/dist/components/shared/Tooltip.d.ts.map +1 -1
- package/dist/components/shell/AudiencePreviewMenu.d.ts +7 -0
- package/dist/components/shell/AudiencePreviewMenu.d.ts.map +1 -0
- package/dist/components/shell/AuthoringDefaultsMenu.d.ts +10 -0
- package/dist/components/shell/AuthoringDefaultsMenu.d.ts.map +1 -0
- package/dist/components/shell/BugReportFAB.d.ts.map +1 -1
- package/dist/components/shell/EditorContext.d.ts +3 -0
- package/dist/components/shell/EditorContext.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/components/shell/SiteSettingsChatbot.d.ts.map +1 -1
- package/dist/hooks/useBuildStatus.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/lib/authoring-defaults.d.ts +17 -0
- package/dist/lib/authoring-defaults.d.ts.map +1 -0
- package/dist/lib/container-grid.d.ts +6 -0
- package/dist/lib/container-grid.d.ts.map +1 -1
- package/dist/lib/index.js +3 -3
- package/dist/lib/migrate-sections-transform.js +1 -1
- package/dist/media/index.js +1 -1
- package/dist/schemas/index.js +4 -2
- package/dist/schemas/site-config.d.ts +6 -0
- package/dist/schemas/site-config.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/ChatPanel.tsx +51 -19
- package/src/components/chat/ChatWidget.tsx +113 -51
- package/src/components/editor/AudienceIndicator.tsx +50 -37
- package/src/components/editor/ChildBlockWrapper.tsx +8 -7
- package/src/components/editor/ColSpanControl.tsx +14 -11
- package/src/components/editor/DragHandle.tsx +5 -2
- package/src/components/editor/PagesModal.tsx +10 -10
- package/src/components/editor/SectionWrapper.tsx +32 -21
- package/src/components/editor/StatusIndicator.tsx +37 -24
- package/src/components/sections/Container/Container.tsx +185 -43
- package/src/components/sections/Container/ContainerSettingsForm.tsx +64 -24
- package/src/components/sections/Container/index.tsx +45 -20
- package/src/components/sections/SectionLayout.tsx +13 -3
- package/src/components/sections/ViewRenderer.tsx +11 -2
- package/src/components/shared/Fab.tsx +57 -0
- package/src/components/shared/Tooltip.tsx +18 -2
- package/src/components/shell/AudiencePreviewMenu.tsx +73 -0
- package/src/components/shell/AuthoringDefaultsMenu.tsx +54 -0
- package/src/components/shell/BugReportFAB.tsx +3 -7
- package/src/components/shell/EditorContext.tsx +5 -1
- package/src/components/shell/EditorShell.tsx +80 -25
- package/src/components/shell/SiteSettingsChatbot.tsx +2 -1
- package/src/hooks/useBuildStatus.ts +35 -4
- package/src/lib/authoring-defaults.ts +42 -0
- package/src/lib/container-grid.ts +14 -0
- package/src/lib/migrate-sections-transform.ts +5 -3
- package/src/schemas/site-config.ts +1 -1
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
// Chat launcher + shell chooser. Browser-safe: no node imports, no process.env.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// -
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// -
|
|
11
|
-
//
|
|
12
|
-
//
|
|
3
|
+
// Both variants share the same conversation experience: >=768px it docks as a
|
|
4
|
+
// full-height right sidebar (html.bp-chat-docked shifts the page band left —
|
|
5
|
+
// see base.css); below 768px it opens as a bottom sheet. Open/close is
|
|
6
|
+
// animated (sidebar slides in as the band shifts, sheet slides up, and ALL
|
|
7
|
+
// page FABs shrink/fade away); prefers-reduced-motion keeps everything
|
|
8
|
+
// instant. FABs show only while closed. Docked-open is the default and the
|
|
9
|
+
// preference persists per tab (sessionStorage, mirrored by Layout.astro's
|
|
10
|
+
// pre-paint script so the column is reserved before hydration) — shared
|
|
11
|
+
// across viewer pages and /edit.
|
|
12
|
+
//
|
|
13
|
+
// The variants differ only in the launcher's placement:
|
|
14
|
+
// - "viewer" (default): viewport corner (viewer-fab tracks the sidebar edge).
|
|
15
|
+
// - "editor": BOTTOM of the /edit route's FAB column (edit-mode toggle at
|
|
16
|
+
// bottom-16, bug report at bottom-28 above it), aligned to the content edge
|
|
17
|
+
// via fab-container-right like its neighbors.
|
|
13
18
|
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
14
|
-
import
|
|
19
|
+
import Fab from "../shared/Fab";
|
|
15
20
|
|
|
16
21
|
const ChatPanel = lazy(() => import("./ChatPanel"));
|
|
17
22
|
|
|
@@ -34,19 +39,79 @@ export interface ChatWidgetProps {
|
|
|
34
39
|
audience?: string | null;
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
/** Matches the 300ms slide transitions in base.css / ChatPanel. */
|
|
43
|
+
const CLOSE_MS = 300;
|
|
44
|
+
/** How long html.bp-chat-animating stays on: the 300ms glide plus a timer-
|
|
45
|
+
* jitter buffer. The class gates the band/nav FLIP transforms in base.css —
|
|
46
|
+
* it must outlive the transition (or the glide would cut off early) but
|
|
47
|
+
* MUST come off afterwards, because a resting transform re-anchors
|
|
48
|
+
* position:fixed descendants. */
|
|
49
|
+
const ANIM_MS = 350;
|
|
50
|
+
|
|
37
51
|
export default function ChatWidget({ siteName, botName, thinkingPhrases, tasks, isEditor, draftChatbot, variant = "viewer", audience }: ChatWidgetProps) {
|
|
38
52
|
const [open, setOpen] = useState(false);
|
|
39
53
|
const [everOpened, setEverOpened] = useState(false);
|
|
40
54
|
const [docked, setDocked] = useState(false);
|
|
41
55
|
const [userOpened, setUserOpened] = useState(false);
|
|
56
|
+
// Close is animated: the panel stays mounted while it slides out.
|
|
57
|
+
const [closing, setClosing] = useState(false);
|
|
58
|
+
const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
59
|
+
const animTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
42
60
|
const fabRef = useRef<HTMLButtonElement>(null);
|
|
43
|
-
|
|
61
|
+
|
|
62
|
+
useEffect(() => () => {
|
|
63
|
+
if (closeTimer.current) clearTimeout(closeTimer.current);
|
|
64
|
+
if (animTimer.current) clearTimeout(animTimer.current);
|
|
65
|
+
document.documentElement.classList.remove("bp-chat-animating");
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
function clearCloseTimer() {
|
|
69
|
+
if (closeTimer.current) clearTimeout(closeTimer.current);
|
|
70
|
+
closeTimer.current = null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function motionOk(): boolean {
|
|
74
|
+
return typeof window.matchMedia === "function" && !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Open the FLIP window for a docked toggle: while bp-chat-animating is on
|
|
78
|
+
* <html>, base.css glides the band/nav via transform between the snapped
|
|
79
|
+
* layouts (see the @property note there). User-driven toggles only — the
|
|
80
|
+
* page-load restore must not replay the glide. */
|
|
81
|
+
function beginShiftWindow() {
|
|
82
|
+
if (!docked || !motionOk()) return;
|
|
83
|
+
document.documentElement.classList.add("bp-chat-animating");
|
|
84
|
+
if (animTimer.current) clearTimeout(animTimer.current);
|
|
85
|
+
animTimer.current = setTimeout(() => {
|
|
86
|
+
document.documentElement.classList.remove("bp-chat-animating");
|
|
87
|
+
animTimer.current = null;
|
|
88
|
+
}, ANIM_MS);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function openPanel() {
|
|
92
|
+
clearCloseTimer();
|
|
93
|
+
beginShiftWindow();
|
|
94
|
+
setClosing(false);
|
|
95
|
+
setOpen(true);
|
|
96
|
+
setEverOpened(true);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function closePanel() {
|
|
100
|
+
clearCloseTimer();
|
|
101
|
+
beginShiftWindow();
|
|
102
|
+
setOpen(false);
|
|
103
|
+
// Reduced motion unmounts immediately — the pre-animation behavior.
|
|
104
|
+
if (motionOk()) {
|
|
105
|
+
setClosing(true);
|
|
106
|
+
closeTimer.current = setTimeout(() => { setClosing(false); closeTimer.current = null; }, CLOSE_MS);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
44
109
|
|
|
45
110
|
// Post-hydration restore. The server renders only the FAB; Layout.astro's
|
|
46
111
|
// pre-paint script has already reserved the docked column and CSS hides the
|
|
47
112
|
// FAB under html.bp-chat-docked, so this state sync causes no layout jump.
|
|
48
113
|
useEffect(() => {
|
|
49
|
-
if (
|
|
114
|
+
if (typeof window.matchMedia !== "function") return;
|
|
50
115
|
const mq = window.matchMedia(DOCK_QUERY);
|
|
51
116
|
const apply = () => setDocked(mq.matches);
|
|
52
117
|
apply();
|
|
@@ -55,59 +120,56 @@ export default function ChatWidget({ siteName, botName, thinkingPhrases, tasks,
|
|
|
55
120
|
try { storedOpen = window.sessionStorage.getItem(OPEN_KEY) !== "0"; } catch {}
|
|
56
121
|
if (mq.matches && storedOpen) { setOpen(true); setEverOpened(true); }
|
|
57
122
|
return () => mq.removeEventListener("change", apply);
|
|
58
|
-
}, [
|
|
123
|
+
}, []);
|
|
59
124
|
|
|
60
|
-
// Reflect
|
|
61
|
-
//
|
|
62
|
-
//
|
|
125
|
+
// Reflect open state on <html>: bp-chat-docked drives the band shift (and
|
|
126
|
+
// the /edit toolbar/FAB-column shift), bp-chat-open (any mode) drives the
|
|
127
|
+
// document FAB's hide/handoff — both animated in base.css. Persist the
|
|
128
|
+
// preference; only the docked state persists — the phone sheet always
|
|
129
|
+
// starts closed.
|
|
63
130
|
useEffect(() => {
|
|
64
|
-
if (!isViewer) return;
|
|
65
131
|
document.documentElement.classList.toggle("bp-chat-docked", open && docked);
|
|
132
|
+
document.documentElement.classList.toggle("bp-chat-open", open);
|
|
66
133
|
if (docked) {
|
|
67
134
|
try { window.sessionStorage.setItem(OPEN_KEY, open ? "1" : "0"); } catch {}
|
|
68
135
|
}
|
|
69
|
-
return () =>
|
|
70
|
-
|
|
136
|
+
return () => {
|
|
137
|
+
document.documentElement.classList.remove("bp-chat-docked");
|
|
138
|
+
document.documentElement.classList.remove("bp-chat-open");
|
|
139
|
+
};
|
|
140
|
+
}, [open, docked]);
|
|
71
141
|
|
|
72
142
|
// Closing the sheet/sidebar returns focus to the launcher.
|
|
73
143
|
useEffect(() => {
|
|
74
|
-
if (
|
|
75
|
-
}, [open, everOpened
|
|
76
|
-
|
|
77
|
-
const showFab = !isViewer || !open;
|
|
144
|
+
if (!open && everOpened) fabRef.current?.focus();
|
|
145
|
+
}, [open, everOpened]);
|
|
78
146
|
|
|
147
|
+
// The launcher stays mounted while the chat is open so it can shrink and
|
|
148
|
+
// fade out (and reverse back in): base.css hides ALL FABs (.viewer-fab and
|
|
149
|
+
// the /edit .fab-container-right column, this button included) under
|
|
150
|
+
// html.bp-chat-open/.bp-chat-docked, with visibility dropped after the fade
|
|
151
|
+
// so no invisible button can take focus or clicks.
|
|
79
152
|
return (
|
|
80
153
|
<>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)}
|
|
94
|
-
>
|
|
95
|
-
{open ? (
|
|
96
|
-
<svg xmlns="http://www.w3.org/2000/svg" className={variant === "editor" ? "h-5 w-5" : "h-6 w-6"} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
97
|
-
<path d="m6 9 6 6 6-6" />
|
|
98
|
-
</svg>
|
|
99
|
-
) : (
|
|
100
|
-
<svg xmlns="http://www.w3.org/2000/svg" className={variant === "editor" ? "h-5 w-5" : "h-6 w-6"} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
101
|
-
<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z" />
|
|
102
|
-
</svg>
|
|
103
|
-
)}
|
|
104
|
-
</button>
|
|
105
|
-
)}
|
|
154
|
+
<Fab
|
|
155
|
+
ref={fabRef}
|
|
156
|
+
label={`Chat with ${botName}`}
|
|
157
|
+
column={variant === "editor" ? "editor" : "viewer"}
|
|
158
|
+
className="bottom-4"
|
|
159
|
+
aria-expanded={open}
|
|
160
|
+
onClick={() => { setUserOpened(true); if (open) closePanel(); else openPanel(); }}
|
|
161
|
+
>
|
|
162
|
+
<svg xmlns="http://www.w3.org/2000/svg" className={variant === "editor" ? "h-5 w-5" : "h-6 w-6"} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
163
|
+
<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z" />
|
|
164
|
+
</svg>
|
|
165
|
+
</Fab>
|
|
106
166
|
{everOpened && (
|
|
107
167
|
<Suspense fallback={null}>
|
|
108
168
|
<ChatPanel
|
|
109
169
|
open={open}
|
|
110
|
-
|
|
170
|
+
closing={closing}
|
|
171
|
+
animateEnter={userOpened}
|
|
172
|
+
onClose={closePanel}
|
|
111
173
|
siteName={siteName}
|
|
112
174
|
botName={botName}
|
|
113
175
|
thinkingPhrases={thinkingPhrases}
|
|
@@ -115,7 +177,7 @@ export default function ChatWidget({ siteName, botName, thinkingPhrases, tasks,
|
|
|
115
177
|
isEditor={isEditor}
|
|
116
178
|
draftChatbot={draftChatbot}
|
|
117
179
|
variant={variant}
|
|
118
|
-
mode={
|
|
180
|
+
mode={docked ? "docked" : "sheet"}
|
|
119
181
|
focusComposer={userOpened}
|
|
120
182
|
audience={audience}
|
|
121
183
|
/>
|
|
@@ -4,6 +4,55 @@ import { IndicatorPill } from "./IndicatorPill";
|
|
|
4
4
|
import { PopoverItem } from "../shared/PopoverItem";
|
|
5
5
|
import type { Audience } from "../../auth/types";
|
|
6
6
|
|
|
7
|
+
interface AudienceChecklistProps {
|
|
8
|
+
access: string[];
|
|
9
|
+
audiences: Audience[];
|
|
10
|
+
onToggle: (name: string) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function AudienceChecklist({ access, audiences, onToggle }: AudienceChecklistProps) {
|
|
14
|
+
if (audiences.length === 0) {
|
|
15
|
+
return (
|
|
16
|
+
<div className="px-3 py-2 text-xs text-base-contrast-light whitespace-nowrap">
|
|
17
|
+
No audiences configured. Add audiences in Site Settings → Viewer Access.
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return (
|
|
22
|
+
<ul role="list" className="w-full overflow-hidden py-1">
|
|
23
|
+
{audiences.map((a) => {
|
|
24
|
+
const checked = access.includes(a.name);
|
|
25
|
+
return (
|
|
26
|
+
<li key={a.name}>
|
|
27
|
+
<PopoverItem
|
|
28
|
+
role="checkbox"
|
|
29
|
+
aria-checked={checked}
|
|
30
|
+
onClick={() => onToggle(a.name)}
|
|
31
|
+
>
|
|
32
|
+
<span
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
className={cn(
|
|
35
|
+
"flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",
|
|
36
|
+
checked
|
|
37
|
+
? "border-primary bg-primary text-primary-contrast"
|
|
38
|
+
: "border-base-300 bg-base",
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
{checked && <Check size={14} strokeWidth={3} />}
|
|
42
|
+
</span>
|
|
43
|
+
<span
|
|
44
|
+
className="h-3 w-3 shrink-0 rounded-full border border-base-200"
|
|
45
|
+
style={{ backgroundColor: a.color ?? "#9ca3af" }}
|
|
46
|
+
/>
|
|
47
|
+
<span className="font-medium text-base-contrast whitespace-nowrap">{a.displayName}</span>
|
|
48
|
+
</PopoverItem>
|
|
49
|
+
</li>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</ul>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
7
56
|
interface AudienceIndicatorProps {
|
|
8
57
|
access: string[];
|
|
9
58
|
audiences: Audience[];
|
|
@@ -39,43 +88,7 @@ export function AudienceIndicator({ access, audiences, onChange, disabled }: Aud
|
|
|
39
88
|
buttonClassName={selected.length === 0 ? "text-base-contrast-light" : undefined}
|
|
40
89
|
disabled={disabled}
|
|
41
90
|
clickContent={
|
|
42
|
-
|
|
43
|
-
<div className="px-3 py-2 text-xs text-base-contrast-light whitespace-nowrap">
|
|
44
|
-
No audiences configured. Add audiences in Site Settings → Viewer Access.
|
|
45
|
-
</div>
|
|
46
|
-
) : (
|
|
47
|
-
<ul role="list" className="w-full overflow-hidden py-1">
|
|
48
|
-
{audiences.map((a) => {
|
|
49
|
-
const checked = access.includes(a.name);
|
|
50
|
-
return (
|
|
51
|
-
<li key={a.name}>
|
|
52
|
-
<PopoverItem
|
|
53
|
-
role="checkbox"
|
|
54
|
-
aria-checked={checked}
|
|
55
|
-
onClick={() => toggle(a.name)}
|
|
56
|
-
>
|
|
57
|
-
<span
|
|
58
|
-
aria-hidden="true"
|
|
59
|
-
className={cn(
|
|
60
|
-
"flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",
|
|
61
|
-
checked
|
|
62
|
-
? "border-primary bg-primary text-primary-contrast"
|
|
63
|
-
: "border-base-300 bg-base",
|
|
64
|
-
)}
|
|
65
|
-
>
|
|
66
|
-
{checked && <Check size={14} strokeWidth={3} />}
|
|
67
|
-
</span>
|
|
68
|
-
<span
|
|
69
|
-
className="h-3 w-3 shrink-0 rounded-full border border-base-200"
|
|
70
|
-
style={{ backgroundColor: a.color ?? "#9ca3af" }}
|
|
71
|
-
/>
|
|
72
|
-
<span className="font-medium text-base-contrast">{a.displayName}</span>
|
|
73
|
-
</PopoverItem>
|
|
74
|
-
</li>
|
|
75
|
-
);
|
|
76
|
-
})}
|
|
77
|
-
</ul>
|
|
78
|
-
)
|
|
91
|
+
<AudienceChecklist access={access} audiences={audiences} onToggle={toggle} />
|
|
79
92
|
}
|
|
80
93
|
/>
|
|
81
94
|
);
|
|
@@ -5,6 +5,7 @@ import { DragHandle } from "./DragHandle";
|
|
|
5
5
|
import { DeleteButton } from "./DeleteButton";
|
|
6
6
|
import { SettingsButton } from "./SettingsButton";
|
|
7
7
|
import { ColSpanControl } from "./ColSpanControl";
|
|
8
|
+
import { Tooltip, Kbd } from "../shared/Tooltip";
|
|
8
9
|
import { cn } from "../../lib/cn";
|
|
9
10
|
|
|
10
11
|
export interface ChildBlockWrapperProps {
|
|
@@ -70,17 +71,17 @@ export const ChildBlockWrapper = forwardRef<HTMLDivElement, ChildBlockWrapperPro
|
|
|
70
71
|
>
|
|
71
72
|
<span className="sr-only">{label}</span>
|
|
72
73
|
<div className="pointer-events-auto">
|
|
73
|
-
<DragHandle ref={dragHandleRef} />
|
|
74
|
+
<DragHandle ref={dragHandleRef} tooltipSide="right" />
|
|
74
75
|
</div>
|
|
75
76
|
<div className="pointer-events-auto">
|
|
76
77
|
<ColSpanControl colSpan={colSpan} columns={columns} onChange={onColSpanChange} />
|
|
77
78
|
</div>
|
|
78
79
|
{hasSettings && onOpenSettings && (
|
|
79
|
-
<
|
|
80
|
+
<Tooltip side="right" className="pointer-events-auto" content={<><Kbd>Edit</Kbd> settings</>}>
|
|
80
81
|
<SettingsButton onClick={onOpenSettings} />
|
|
81
|
-
</
|
|
82
|
+
</Tooltip>
|
|
82
83
|
)}
|
|
83
|
-
<
|
|
84
|
+
<Tooltip side="right" className="pointer-events-auto" content={<><Kbd>Duplicate</Kbd> block</>}>
|
|
84
85
|
<button
|
|
85
86
|
type="button"
|
|
86
87
|
aria-label="Duplicate block"
|
|
@@ -89,10 +90,10 @@ export const ChildBlockWrapper = forwardRef<HTMLDivElement, ChildBlockWrapperPro
|
|
|
89
90
|
>
|
|
90
91
|
<CopyPlus size={16} />
|
|
91
92
|
</button>
|
|
92
|
-
</
|
|
93
|
-
<
|
|
93
|
+
</Tooltip>
|
|
94
|
+
<Tooltip side="right" className="pointer-events-auto" content={<><Kbd>Delete</Kbd> block</>}>
|
|
94
95
|
<DeleteButton onDelete={onDelete} />
|
|
95
|
-
</
|
|
96
|
+
</Tooltip>
|
|
96
97
|
</div>
|
|
97
98
|
|
|
98
99
|
{/* Drop-edge indicators */}
|
|
@@ -2,6 +2,7 @@ import { useRef, useState } from "react";
|
|
|
2
2
|
import { Columns3 } from "lucide-react";
|
|
3
3
|
import { Popover } from "../shared/Popover";
|
|
4
4
|
import { PopoverItem } from "../shared/PopoverItem";
|
|
5
|
+
import { Tooltip, Kbd } from "../shared/Tooltip";
|
|
5
6
|
import { cn } from "../../lib/cn";
|
|
6
7
|
|
|
7
8
|
interface ColSpanControlProps {
|
|
@@ -21,17 +22,19 @@ export function ColSpanControl({ colSpan, columns, onChange }: ColSpanControlPro
|
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
24
|
<div className="relative">
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
<Tooltip side="right" content={<><Kbd>Set</Kbd> column span</>}>
|
|
26
|
+
<button
|
|
27
|
+
ref={buttonRef}
|
|
28
|
+
type="button"
|
|
29
|
+
aria-label="Column span"
|
|
30
|
+
aria-haspopup="true"
|
|
31
|
+
aria-expanded={open}
|
|
32
|
+
onClick={() => setOpen((v) => !v)}
|
|
33
|
+
className="pointer-events-auto inline-flex cursor-pointer items-center gap-1 rounded p-1 text-xs text-base-contrast-light hover:text-primary"
|
|
34
|
+
>
|
|
35
|
+
<Columns3 size={14} />
|
|
36
|
+
</button>
|
|
37
|
+
</Tooltip>
|
|
35
38
|
|
|
36
39
|
<Popover isOpen={open} onClose={() => setOpen(false)} anchorRef={buttonRef} className="min-w-28">
|
|
37
40
|
<ul role="list" className="py-1">
|
|
@@ -3,9 +3,12 @@ import { DragHandle as DragHandleIcon } from "../shared/icons";
|
|
|
3
3
|
import { IconButton } from "../shared/IconButton";
|
|
4
4
|
import { Tooltip, Kbd } from "../shared/Tooltip";
|
|
5
5
|
|
|
6
|
-
export const DragHandle = forwardRef<HTMLButtonElement>(function DragHandle(
|
|
6
|
+
export const DragHandle = forwardRef<HTMLButtonElement, { tooltipSide?: "bottom" | "right" }>(function DragHandle(
|
|
7
|
+
{ tooltipSide },
|
|
8
|
+
ref,
|
|
9
|
+
) {
|
|
7
10
|
return (
|
|
8
|
-
<Tooltip content={<><Kbd>Drag</Kbd> to move</>}>
|
|
11
|
+
<Tooltip side={tooltipSide} content={<><Kbd>Drag</Kbd> to move</>}>
|
|
9
12
|
<IconButton
|
|
10
13
|
ref={ref}
|
|
11
14
|
icon={<DragHandleIcon size={18} />}
|
|
@@ -205,15 +205,15 @@ function PageRow({
|
|
|
205
205
|
return (
|
|
206
206
|
<div
|
|
207
207
|
ref={rowRef}
|
|
208
|
-
className={cn("relative
|
|
208
|
+
className={cn("relative flex items-start gap-1", isDragging && "opacity-50")}
|
|
209
209
|
>
|
|
210
210
|
<DropEdgeIndicator edge={closestEdge} />
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
{draggable && (
|
|
212
|
+
<div className="flex shrink-0 items-center py-2 [&_[role=tooltip]]:hidden">
|
|
213
|
+
<DragHandle ref={handleRef} />
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
216
|
+
<div className={cn("min-w-0 flex-1 rounded-md border border-base-200 bg-base", isDragging && "outline outline-2 outline-primary/50")}>
|
|
217
217
|
<button
|
|
218
218
|
type="button"
|
|
219
219
|
aria-label={`Edit settings for ${pageDisplayTitle(page.title)}`}
|
|
@@ -238,9 +238,8 @@ function PageRow({
|
|
|
238
238
|
className={cn("shrink-0 text-base-contrast/50 transition-transform", expanded && "rotate-180")}
|
|
239
239
|
/>
|
|
240
240
|
</button>
|
|
241
|
-
</div>
|
|
242
241
|
|
|
243
|
-
|
|
242
|
+
{expanded && (
|
|
244
243
|
<div className="flex flex-col gap-3 border-t border-base-200 px-3 py-3">
|
|
245
244
|
<Input
|
|
246
245
|
label="Title"
|
|
@@ -314,7 +313,8 @@ function PageRow({
|
|
|
314
313
|
</Button>
|
|
315
314
|
</div>
|
|
316
315
|
</div>
|
|
317
|
-
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
318
|
</div>
|
|
319
319
|
);
|
|
320
320
|
}
|
|
@@ -5,6 +5,8 @@ import { DragHandle } from "./DragHandle";
|
|
|
5
5
|
import { InsertButton } from "./InsertButton";
|
|
6
6
|
import { DeleteButton } from "./DeleteButton";
|
|
7
7
|
import { SettingsButton } from "./SettingsButton";
|
|
8
|
+
import { IconButton } from "../shared/IconButton";
|
|
9
|
+
import { Tooltip, Kbd } from "../shared/Tooltip";
|
|
8
10
|
import { StatusIndicator } from "./StatusIndicator";
|
|
9
11
|
import { AudienceIndicator } from "./AudienceIndicator";
|
|
10
12
|
import { LockBadge } from "./LockBadge";
|
|
@@ -298,7 +300,10 @@ export function SectionWrapper({
|
|
|
298
300
|
{/* Status + settings + delete — top-right, above content */}
|
|
299
301
|
<div
|
|
300
302
|
className={cn(
|
|
301
|
-
|
|
303
|
+
// When a selector inside this cluster is open (Popover renders role="dialog"),
|
|
304
|
+
// lift the whole cluster above sibling sections' chrome (z-30, hover:z-[60]) and
|
|
305
|
+
// the inline type picker (z-50) so the open dropdown isn't overlapped.
|
|
306
|
+
"pointer-events-none absolute right-0 bottom-full z-30 has-[[role=dialog]]:z-[70] mb-1 flex items-center gap-2 transition-opacity",
|
|
302
307
|
// A lock is important state — keep the cluster visible without hover.
|
|
303
308
|
alwaysShow || isLocked ? "opacity-100" : "opacity-0 group-hover:opacity-100",
|
|
304
309
|
)}
|
|
@@ -327,32 +332,38 @@ export function SectionWrapper({
|
|
|
327
332
|
</div>
|
|
328
333
|
|
|
329
334
|
{!isLocked && onAddChild && (
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
</
|
|
335
|
+
<Tooltip className="pointer-events-auto" content={<><Kbd>Add</Kbd> a block</>}>
|
|
336
|
+
<IconButton
|
|
337
|
+
icon={<Plus size={16} />}
|
|
338
|
+
label="Add block"
|
|
339
|
+
onClick={onAddChild}
|
|
340
|
+
className="pointer-events-auto hover:text-primary"
|
|
341
|
+
/>
|
|
342
|
+
</Tooltip>
|
|
338
343
|
)}
|
|
339
344
|
|
|
340
|
-
{!isLocked &&
|
|
341
|
-
<
|
|
345
|
+
{!isLocked && onMoveSection && (
|
|
346
|
+
<Tooltip className="pointer-events-auto" content={<><Kbd>Move</Kbd> to page</>}>
|
|
347
|
+
<IconButton
|
|
348
|
+
icon={<ArrowRightLeft size={16} />}
|
|
349
|
+
label="Move to page"
|
|
350
|
+
onClick={onMoveSection}
|
|
351
|
+
className="pointer-events-auto hover:text-primary"
|
|
352
|
+
/>
|
|
353
|
+
</Tooltip>
|
|
342
354
|
)}
|
|
343
355
|
|
|
344
|
-
{!isLocked &&
|
|
345
|
-
<
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
aria-label="Move to page"
|
|
349
|
-
className="pointer-events-auto cursor-pointer rounded p-1 text-base-contrast-light hover:text-primary"
|
|
350
|
-
>
|
|
351
|
-
<ArrowRightLeft size={16} />
|
|
352
|
-
</button>
|
|
356
|
+
{!isLocked && hasSettings && (
|
|
357
|
+
<Tooltip className="pointer-events-auto" content={<><Kbd>Edit</Kbd> settings</>}>
|
|
358
|
+
<SettingsButton onClick={handleSettingsClick} />
|
|
359
|
+
</Tooltip>
|
|
353
360
|
)}
|
|
354
361
|
|
|
355
|
-
{!isLocked && onDelete &&
|
|
362
|
+
{!isLocked && onDelete && (
|
|
363
|
+
<Tooltip className="pointer-events-auto" content={<><Kbd>Delete</Kbd> section</>}>
|
|
364
|
+
<DeleteButton onDelete={onDelete} />
|
|
365
|
+
</Tooltip>
|
|
366
|
+
)}
|
|
356
367
|
</div>
|
|
357
368
|
|
|
358
369
|
{/* Drop indicator — centered in the section's own padding-top */}
|
|
@@ -83,6 +83,42 @@ const dotColorClasses: Record<StatusColor, string> = {
|
|
|
83
83
|
|
|
84
84
|
const STATUSES: Status[] = ["draft", "live", "archived"];
|
|
85
85
|
|
|
86
|
+
interface StatusRadioListProps {
|
|
87
|
+
status: Status;
|
|
88
|
+
onChange: (status: Status) => void;
|
|
89
|
+
onClose?: () => void;
|
|
90
|
+
ariaLabel?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function StatusRadioList({ status, onChange, onClose, ariaLabel = "Section status" }: StatusRadioListProps) {
|
|
94
|
+
return (
|
|
95
|
+
<ul role="radiogroup" aria-label={ariaLabel} className="w-full overflow-hidden py-1">
|
|
96
|
+
{STATUSES.map((s) => {
|
|
97
|
+
const checked = s === status;
|
|
98
|
+
return (
|
|
99
|
+
<li key={s}>
|
|
100
|
+
<PopoverItem
|
|
101
|
+
role="radio"
|
|
102
|
+
aria-checked={checked}
|
|
103
|
+
onClick={() => {
|
|
104
|
+
if (s !== status) onChange(s);
|
|
105
|
+
onClose?.();
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<span
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
className={cn("h-3 w-3 shrink-0 rounded-full border border-base-200", dotColorClasses[s])}
|
|
111
|
+
/>
|
|
112
|
+
<span className="flex-1 font-medium capitalize text-base-contrast">{s}</span>
|
|
113
|
+
{checked && <Check size={14} strokeWidth={3} className="text-primary" />}
|
|
114
|
+
</PopoverItem>
|
|
115
|
+
</li>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</ul>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
86
122
|
interface StatusIndicatorProps {
|
|
87
123
|
mainStatus: string | null;
|
|
88
124
|
savedStatus: string;
|
|
@@ -122,30 +158,7 @@ export function StatusIndicator({
|
|
|
122
158
|
buttonClassName="text-base-contrast-light"
|
|
123
159
|
disabled={disabled}
|
|
124
160
|
clickContent={(onClose) => (
|
|
125
|
-
<
|
|
126
|
-
{STATUSES.map((s) => {
|
|
127
|
-
const checked = s === status;
|
|
128
|
-
return (
|
|
129
|
-
<li key={s}>
|
|
130
|
-
<PopoverItem
|
|
131
|
-
role="radio"
|
|
132
|
-
aria-checked={checked}
|
|
133
|
-
onClick={() => {
|
|
134
|
-
if (s !== status) onChange(s);
|
|
135
|
-
onClose();
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<span
|
|
139
|
-
aria-hidden="true"
|
|
140
|
-
className={cn("h-3 w-3 shrink-0 rounded-full border border-base-200", dotColorClasses[s])}
|
|
141
|
-
/>
|
|
142
|
-
<span className="flex-1 font-medium capitalize text-base-contrast">{s}</span>
|
|
143
|
-
{checked && <Check size={14} strokeWidth={3} className="text-primary" />}
|
|
144
|
-
</PopoverItem>
|
|
145
|
-
</li>
|
|
146
|
-
);
|
|
147
|
-
})}
|
|
148
|
-
</ul>
|
|
161
|
+
<StatusRadioList status={status} onChange={onChange} onClose={onClose} />
|
|
149
162
|
)}
|
|
150
163
|
/>
|
|
151
164
|
);
|