@perkyzz/emvb 0.9.0 → 1.0.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/README.md +1 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/editor/A11yCopilot.tsx +1 -1
- package/src/admin/editor/Editor.tsx +297 -248
- package/src/admin/editor/Timeline.tsx +2 -1
- package/src/admin/editor/TopBar.tsx +4 -2
- package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
- package/src/admin/editor/canvas/canvas-scale.ts +2 -2
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +26 -4
- package/src/admin/editor/editor-chrome.tsx +3 -3
- package/src/admin/editor/editor-commands.ts +8 -3
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +49 -14
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +53 -1
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +51 -10
- package/src/admin/editor/panels/style-target.ts +9 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/store.ts +6 -2
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +4 -4
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +15 -6
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +15 -1
- package/src/admin/pages/ThemePartList.tsx +15 -1
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/ui.ts +39 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/resolve-theme.ts +14 -1
- package/src/astro/resolve.ts +89 -2
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +44 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +285 -0
- package/src/core/css/generate.ts +89 -20
- package/src/core/css/trace.ts +18 -9
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +4 -5
- package/src/core/design/devices.ts +13 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +17 -4
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +1 -1
- package/src/core/import/elementor/atomic.ts +1595 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +949 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +409 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +82 -0
- package/src/core/json-schema.ts +107 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +5 -5
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +140 -20
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +125 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +2 -1
- package/src/core/schema/layout.ts +82 -14
- package/src/core/schema/style.ts +251 -114
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +1 -0
- package/src/core/theme/popup-rules.ts +17 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -9
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
typeMayAddScript,
|
|
8
8
|
type ElementType,
|
|
9
9
|
} from "../../../core/index.ts";
|
|
10
|
+
import { useExtensionElements } from "../extensions-context.tsx";
|
|
11
|
+
import { PuzzlePieceIcon } from "@phosphor-icons/react";
|
|
10
12
|
import { NEW_ELEMENT_MIME } from "../dnd/drop-target.ts";
|
|
11
13
|
import { BUTTON, FIELD } from "../../ui.ts";
|
|
12
14
|
import { isCancelEscape } from "../ime.ts";
|
|
@@ -29,7 +31,7 @@ export function AddPanel({
|
|
|
29
31
|
defaultQuery = "",
|
|
30
32
|
formsAvailable = true,
|
|
31
33
|
}: {
|
|
32
|
-
onAdd: (type: ElementType) => void;
|
|
34
|
+
onAdd: (type: ElementType | string) => void;
|
|
33
35
|
/** Adds a section recipe (W-320); without it, recipes are not offered. */
|
|
34
36
|
onRecipe?: (id: string) => void;
|
|
35
37
|
/** My sections (W-876); without it the group is not shown. */
|
|
@@ -51,6 +53,9 @@ export function AddPanel({
|
|
|
51
53
|
(formsAvailable || d.group !== "form") &&
|
|
52
54
|
matchesSearch(query, d.name, d.group),
|
|
53
55
|
);
|
|
56
|
+
const extensionElements = useExtensionElements().filter((el) =>
|
|
57
|
+
matchesSearch(query, el.label, el.name, "extension"),
|
|
58
|
+
);
|
|
54
59
|
const recipes = onRecipe
|
|
55
60
|
? SECTION_RECIPES.filter((r) => matchesSearch(query, r.name, r.description, "recipe section"))
|
|
56
61
|
: [];
|
|
@@ -131,6 +136,31 @@ export function AddPanel({
|
|
|
131
136
|
);
|
|
132
137
|
})
|
|
133
138
|
)}
|
|
139
|
+
{extensionElements.length > 0 && (
|
|
140
|
+
<div className="emvb-add-group" data-emvb-extensions="">
|
|
141
|
+
<h3 className="emvb-add-group-title">Extensions</h3>
|
|
142
|
+
<div className="emvb-add-tiles" aria-label="Extensions">
|
|
143
|
+
{extensionElements.map((tile) => (
|
|
144
|
+
<button
|
|
145
|
+
key={tile.type}
|
|
146
|
+
type="button"
|
|
147
|
+
className="emvb-element-tile"
|
|
148
|
+
data-emvb-add-tile={tile.type}
|
|
149
|
+
draggable
|
|
150
|
+
onDragStart={(event) => {
|
|
151
|
+
event.dataTransfer.setData(NEW_ELEMENT_MIME, tile.type);
|
|
152
|
+
event.dataTransfer.effectAllowed = "copy";
|
|
153
|
+
dragStash.new(tile.type);
|
|
154
|
+
}}
|
|
155
|
+
onClick={() => onAdd(tile.type)}
|
|
156
|
+
>
|
|
157
|
+
<PuzzlePieceIcon size={20} aria-hidden="true" />
|
|
158
|
+
<span>{tile.label}</span>
|
|
159
|
+
</button>
|
|
160
|
+
))}
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
)}
|
|
134
164
|
{onRecipe && recipes.length > 0 && (
|
|
135
165
|
<div className="emvb-add-group" data-emvb-recipes="">
|
|
136
166
|
<h3 className="emvb-add-group-title">Section recipes</h3>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Badge, Button } from "@cloudflare/kumo";
|
|
2
|
+
import { PaperPlaneRightIcon } from "@phosphor-icons/react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { MAX_REQUEST_PROMPT } from "../../../core/limits.ts";
|
|
5
|
+
import { FIELD } from "../../ui.ts";
|
|
6
|
+
import type { CoDesign } from "../useCoDesign.ts";
|
|
7
|
+
|
|
8
|
+
/** How long since an agent last checked before the panel stops calling it connected. */
|
|
9
|
+
const CONNECTED_MS = 2 * 60_000;
|
|
10
|
+
|
|
11
|
+
const ago = (iso: string, now: number) => {
|
|
12
|
+
const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1000));
|
|
13
|
+
if (seconds < 60) return "just now";
|
|
14
|
+
const minutes = Math.round(seconds / 60);
|
|
15
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
16
|
+
const hours = Math.round(minutes / 60);
|
|
17
|
+
return hours < 48 ? `${hours} h ago` : "days ago";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* W-931 prompt relay (D-063): the person asks their own agent from the editor. The request waits
|
|
22
|
+
* until an agent reads it with get_requests and answers with a proposal reviewed below. The status
|
|
23
|
+
* says when an agent last checked, so "nobody is listening" is visible before anyone waits.
|
|
24
|
+
*/
|
|
25
|
+
export function AgentRequestBox({ co, now = Date.now() }: { co: CoDesign; now?: number }) {
|
|
26
|
+
const [prompt, setPrompt] = React.useState("");
|
|
27
|
+
const [sending, setSending] = React.useState(false);
|
|
28
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
29
|
+
const { requests, agentSeenAt } = co.proposals;
|
|
30
|
+
const connected = agentSeenAt !== null && now - Date.parse(agentSeenAt) < CONNECTED_MS;
|
|
31
|
+
const shown = requests.slice(0, 5);
|
|
32
|
+
const send = async (event: React.FormEvent) => {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
if (sending) return;
|
|
35
|
+
setSending(true);
|
|
36
|
+
const failed = await co.ask(prompt);
|
|
37
|
+
setSending(false);
|
|
38
|
+
setError(failed);
|
|
39
|
+
if (!failed) setPrompt("");
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
<section className="emvb-codesign-ask" aria-label="Ask your agent" data-emvb-agent-ask="">
|
|
43
|
+
<form onSubmit={send} className="emvb-codesign-ask-form">
|
|
44
|
+
<label htmlFor="emvb-agent-prompt" className="emvb-codesign-group-title">
|
|
45
|
+
Ask your agent
|
|
46
|
+
</label>
|
|
47
|
+
<textarea
|
|
48
|
+
id="emvb-agent-prompt"
|
|
49
|
+
dir="auto"
|
|
50
|
+
className={`${FIELD} emvb-textarea`}
|
|
51
|
+
rows={3}
|
|
52
|
+
maxLength={MAX_REQUEST_PROMPT}
|
|
53
|
+
value={prompt}
|
|
54
|
+
placeholder="For example: tighten the hero copy and add a pricing section"
|
|
55
|
+
aria-invalid={error ? true : undefined}
|
|
56
|
+
aria-describedby="emvb-agent-prompt-status"
|
|
57
|
+
readOnly={sending}
|
|
58
|
+
onChange={(e) => setPrompt(e.target.value)}
|
|
59
|
+
/>
|
|
60
|
+
<div className="emvb-codesign-actions">
|
|
61
|
+
<Button
|
|
62
|
+
type="submit"
|
|
63
|
+
size="sm"
|
|
64
|
+
variant="primary"
|
|
65
|
+
disabled={!prompt.trim()}
|
|
66
|
+
aria-busy={sending || undefined}
|
|
67
|
+
icon={<PaperPlaneRightIcon aria-hidden="true" />}
|
|
68
|
+
data-emvb-agent-send=""
|
|
69
|
+
>
|
|
70
|
+
Send to agent
|
|
71
|
+
</Button>
|
|
72
|
+
</div>
|
|
73
|
+
<p
|
|
74
|
+
id="emvb-agent-prompt-status"
|
|
75
|
+
className="emvb-helper"
|
|
76
|
+
role={error ? "alert" : undefined}
|
|
77
|
+
data-emvb-agent-connection={connected ? "connected" : "idle"}
|
|
78
|
+
>
|
|
79
|
+
{error ??
|
|
80
|
+
(agentSeenAt === null
|
|
81
|
+
? "No agent has checked for requests yet. An admin sets one up in Pages VisualBuilder → AI agents; it answers with a proposal you review here."
|
|
82
|
+
: connected
|
|
83
|
+
? `An agent is connected (checked ${ago(agentSeenAt, now)}).`
|
|
84
|
+
: `An agent last checked ${ago(agentSeenAt, now)}. It may not see new requests until it checks again.`)}
|
|
85
|
+
</p>
|
|
86
|
+
</form>
|
|
87
|
+
{shown.length > 0 && (
|
|
88
|
+
<ul className="emvb-codesign-ops" aria-label="Your requests">
|
|
89
|
+
{shown.map((r) => (
|
|
90
|
+
<li key={r.id} className="emvb-codesign-op" data-emvb-agent-request={r.status}>
|
|
91
|
+
<span className="emvb-codesign-op-text">{r.prompt}</span>
|
|
92
|
+
<span className="emvb-codesign-op-actions">
|
|
93
|
+
{r.status === "answered" ? (
|
|
94
|
+
<Badge variant="blue">Answered</Badge>
|
|
95
|
+
) : (
|
|
96
|
+
<>
|
|
97
|
+
<Badge variant="neutral">Waiting</Badge>
|
|
98
|
+
<Button
|
|
99
|
+
size="sm"
|
|
100
|
+
variant="ghost"
|
|
101
|
+
aria-label={`Cancel request: ${r.prompt.slice(0, 60)}`}
|
|
102
|
+
data-emvb-agent-cancel=""
|
|
103
|
+
onClick={() => void co.cancel(r.id)}
|
|
104
|
+
>
|
|
105
|
+
Cancel
|
|
106
|
+
</Button>
|
|
107
|
+
</>
|
|
108
|
+
)}
|
|
109
|
+
</span>
|
|
110
|
+
</li>
|
|
111
|
+
))}
|
|
112
|
+
</ul>
|
|
113
|
+
)}
|
|
114
|
+
</section>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
classNameTakenMessage,
|
|
25
25
|
type DesignSystem,
|
|
26
26
|
type Layout,
|
|
27
|
-
type
|
|
27
|
+
type FlatStyleProps,
|
|
28
|
+
flattenMotion,
|
|
28
29
|
} from "../../../core/index.ts";
|
|
29
30
|
import { FIELD } from "../../ui.ts";
|
|
30
31
|
import { useEditedNoun } from "../edited-noun.ts";
|
|
@@ -60,13 +61,15 @@ const CLASS_SECTIONS: StyleSectionId[] = [
|
|
|
60
61
|
|
|
61
62
|
function classKeys(
|
|
62
63
|
section: StyleSectionId,
|
|
63
|
-
style:
|
|
64
|
-
position:
|
|
64
|
+
style: FlatStyleProps | undefined,
|
|
65
|
+
position: FlatStyleProps["position"],
|
|
65
66
|
state: StyleStateChoice,
|
|
66
67
|
): StyleKey[] {
|
|
67
68
|
const keys = keysFor("container", section, style, position);
|
|
68
69
|
const withFit =
|
|
69
|
-
section === "size" && !keys.includes("objectFit")
|
|
70
|
+
section === "size" && !keys.includes("objectFit")
|
|
71
|
+
? [...keys, "objectFit" as const, "objectPosition" as const]
|
|
72
|
+
: keys;
|
|
70
73
|
return (
|
|
71
74
|
state === "normal"
|
|
72
75
|
? withFit
|
|
@@ -91,7 +94,7 @@ function ClassStyleEditor({
|
|
|
91
94
|
}) {
|
|
92
95
|
const [state, setState] = React.useState<StyleStateChoice>("normal");
|
|
93
96
|
const [section, setSection] = React.useState<StyleSectionId>("layout");
|
|
94
|
-
const style = state === "normal" ? cls.style : cls.states?.[state];
|
|
97
|
+
const style = flattenMotion(state === "normal" ? cls.style : cls.states?.[state]);
|
|
95
98
|
const position = style?.position ?? cls.style.position;
|
|
96
99
|
const keys = classKeys(section, style, position, state);
|
|
97
100
|
return (
|
|
@@ -181,7 +184,7 @@ export function ClassesSection({
|
|
|
181
184
|
"class",
|
|
182
185
|
classes.map((c) => c.id),
|
|
183
186
|
);
|
|
184
|
-
const next = { id, name: trimmed, style: {} as
|
|
187
|
+
const next = { id, name: trimmed, style: {} as FlatStyleProps };
|
|
185
188
|
// W-610: a failed save keeps the row and what was typed, so it can be retried.
|
|
186
189
|
if ((await onSave({ ...design, classes: [...classes, next] })) === false) return;
|
|
187
190
|
setCreating(false);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Banner, Button, Empty } from "@cloudflare/kumo";
|
|
2
|
+
import {
|
|
3
|
+
CheckIcon,
|
|
4
|
+
EyeIcon,
|
|
5
|
+
EyeSlashIcon,
|
|
6
|
+
RobotIcon,
|
|
7
|
+
WarningCircleIcon,
|
|
8
|
+
XIcon,
|
|
9
|
+
} from "@phosphor-icons/react";
|
|
10
|
+
import type { Layout } from "../../../core/index.ts";
|
|
11
|
+
import type { PendingProposal } from "../../proposals-api.ts";
|
|
12
|
+
import { describeOp, groupOf, GROUP_LABELS, GROUP_ORDER, type Op } from "../co-design.ts";
|
|
13
|
+
import type { CoDesign } from "../useCoDesign.ts";
|
|
14
|
+
import { AgentRequestBox } from "./AgentRequestBox.tsx";
|
|
15
|
+
|
|
16
|
+
const when = (iso: string) => {
|
|
17
|
+
const date = new Date(iso);
|
|
18
|
+
return Number.isNaN(date.getTime())
|
|
19
|
+
? ""
|
|
20
|
+
: date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* W-930 co-design review (D-064, D-067): agent proposals for this page, each change listed by group
|
|
25
|
+
* with its own Accept and Reject. Agent text is shown as quoted content, never as instructions.
|
|
26
|
+
*/
|
|
27
|
+
export function CoDesignPanel({ co, layout }: { co: CoDesign; layout: Layout | null }) {
|
|
28
|
+
const { items, ready, failed } = co.proposals;
|
|
29
|
+
return (
|
|
30
|
+
<div className="emvb-codesign" data-emvb-codesign="">
|
|
31
|
+
<AgentRequestBox co={co} />
|
|
32
|
+
<p
|
|
33
|
+
className="emvb-helper emvb-codesign-status"
|
|
34
|
+
aria-live="polite"
|
|
35
|
+
data-emvb-codesign-status=""
|
|
36
|
+
>
|
|
37
|
+
<RobotIcon size={14} aria-hidden="true" />
|
|
38
|
+
{failed
|
|
39
|
+
? "Can't reach the site to check for agent proposals. Retrying."
|
|
40
|
+
: !ready
|
|
41
|
+
? "Checking for agent proposals…"
|
|
42
|
+
: items.length === 0
|
|
43
|
+
? "No agent proposals for this page."
|
|
44
|
+
: `${items.length} ${items.length === 1 ? "proposal" : "proposals"} waiting for review.`}
|
|
45
|
+
{co.unsaved > 0 && ` ${co.unsaved} accepted, not saved yet.`}
|
|
46
|
+
</p>
|
|
47
|
+
{co.error && (
|
|
48
|
+
<Banner
|
|
49
|
+
role="alert"
|
|
50
|
+
variant="error"
|
|
51
|
+
icon={<WarningCircleIcon aria-hidden="true" />}
|
|
52
|
+
title="Couldn't accept that change"
|
|
53
|
+
description={co.error}
|
|
54
|
+
data-emvb-codesign-error=""
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
{ready && items.length === 0 && (
|
|
58
|
+
<div className="emvb-site-empty-card" data-emvb-codesign-empty="">
|
|
59
|
+
<Empty
|
|
60
|
+
size="sm"
|
|
61
|
+
icon={<RobotIcon size={24} aria-hidden="true" />}
|
|
62
|
+
title="Nothing to review"
|
|
63
|
+
description="When your agent answers a request, or proposes changes on its own, they show here for you to accept or reject one by one. Nothing changes until you do."
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
{items.map((p) => (
|
|
68
|
+
<ProposalCard key={p.id} p={p} co={co} layout={layout} />
|
|
69
|
+
))}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function ProposalCard({
|
|
75
|
+
p,
|
|
76
|
+
co,
|
|
77
|
+
layout,
|
|
78
|
+
}: {
|
|
79
|
+
p: PendingProposal;
|
|
80
|
+
co: CoDesign;
|
|
81
|
+
layout: Layout | null;
|
|
82
|
+
}) {
|
|
83
|
+
const pending = co.pending(p);
|
|
84
|
+
const previewing = co.previewId === p.id;
|
|
85
|
+
const decided = co.decisions[p.id] ?? {};
|
|
86
|
+
if (pending.length === 0) return null;
|
|
87
|
+
return (
|
|
88
|
+
<section
|
|
89
|
+
className="emvb-codesign-card"
|
|
90
|
+
aria-label={`Agent proposal from ${when(p.createdAt)}`}
|
|
91
|
+
data-emvb-proposal={p.id}
|
|
92
|
+
>
|
|
93
|
+
<header className="emvb-codesign-head">
|
|
94
|
+
<strong>Proposal · {when(p.createdAt)}</strong>
|
|
95
|
+
<Button
|
|
96
|
+
size="sm"
|
|
97
|
+
variant="ghost"
|
|
98
|
+
aria-pressed={previewing}
|
|
99
|
+
data-emvb-proposal-preview=""
|
|
100
|
+
icon={previewing ? <EyeSlashIcon aria-hidden="true" /> : <EyeIcon aria-hidden="true" />}
|
|
101
|
+
onClick={() => co.setPreviewId(previewing ? null : p.id)}
|
|
102
|
+
>
|
|
103
|
+
{previewing ? "Hide preview" : "Preview"}
|
|
104
|
+
</Button>
|
|
105
|
+
</header>
|
|
106
|
+
{GROUP_ORDER.map((group) => {
|
|
107
|
+
const ops = pending.filter((i) => groupOf(p.proposal.ops[i] as Op) === group);
|
|
108
|
+
if (ops.length === 0) return null;
|
|
109
|
+
return (
|
|
110
|
+
<div key={group} className="emvb-codesign-group" data-emvb-proposal-group={group}>
|
|
111
|
+
<h4 className="emvb-codesign-group-title">{GROUP_LABELS[group]}</h4>
|
|
112
|
+
<ul className="emvb-codesign-ops">
|
|
113
|
+
{ops.map((i) => {
|
|
114
|
+
const text = describeOp(p.proposal.ops[i] as Op, layout);
|
|
115
|
+
return (
|
|
116
|
+
<li key={i} className="emvb-codesign-op" data-emvb-proposal-op={i}>
|
|
117
|
+
<span className="emvb-codesign-op-text">{text}</span>
|
|
118
|
+
<span className="emvb-codesign-op-actions">
|
|
119
|
+
<Button
|
|
120
|
+
size="sm"
|
|
121
|
+
variant="ghost"
|
|
122
|
+
shape="square"
|
|
123
|
+
aria-label={`Accept: ${text}`}
|
|
124
|
+
title="Accept"
|
|
125
|
+
data-emvb-op-accept=""
|
|
126
|
+
icon={<CheckIcon aria-hidden="true" />}
|
|
127
|
+
onClick={() => co.accept(p, [i])}
|
|
128
|
+
/>
|
|
129
|
+
<Button
|
|
130
|
+
size="sm"
|
|
131
|
+
variant="ghost"
|
|
132
|
+
shape="square"
|
|
133
|
+
aria-label={`Reject: ${text}`}
|
|
134
|
+
title="Reject"
|
|
135
|
+
data-emvb-op-reject=""
|
|
136
|
+
icon={<XIcon aria-hidden="true" />}
|
|
137
|
+
onClick={() => co.reject(p, [i])}
|
|
138
|
+
/>
|
|
139
|
+
</span>
|
|
140
|
+
</li>
|
|
141
|
+
);
|
|
142
|
+
})}
|
|
143
|
+
</ul>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
})}
|
|
147
|
+
<footer className="emvb-codesign-actions">
|
|
148
|
+
<Button
|
|
149
|
+
size="sm"
|
|
150
|
+
variant="primary"
|
|
151
|
+
data-emvb-accept-all=""
|
|
152
|
+
onClick={() => co.accept(p, pending)}
|
|
153
|
+
>
|
|
154
|
+
Accept all ({pending.length})
|
|
155
|
+
</Button>
|
|
156
|
+
<Button
|
|
157
|
+
size="sm"
|
|
158
|
+
variant="secondary"
|
|
159
|
+
data-emvb-reject-all=""
|
|
160
|
+
onClick={() => co.reject(p, pending)}
|
|
161
|
+
>
|
|
162
|
+
Reject all
|
|
163
|
+
</Button>
|
|
164
|
+
{Object.keys(decided).length > 0 && (
|
|
165
|
+
<span className="emvb-helper">{Object.keys(decided).length} decided</span>
|
|
166
|
+
)}
|
|
167
|
+
</footer>
|
|
168
|
+
</section>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
slugify,
|
|
7
7
|
variableListFull,
|
|
8
8
|
type DesignSystem,
|
|
9
|
-
type
|
|
9
|
+
type FlatStyleProps,
|
|
10
10
|
} from "../../../core/index.ts";
|
|
11
11
|
|
|
12
|
-
type ColorValue =
|
|
12
|
+
type ColorValue = FlatStyleProps["color"];
|
|
13
13
|
import { BUTTON, FIELD } from "../../ui.ts";
|
|
14
14
|
import {
|
|
15
15
|
formatOklch,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
type Arranged,
|
|
37
37
|
inheritedStyle,
|
|
38
38
|
type LayoutNode,
|
|
39
|
-
type
|
|
39
|
+
type Device,
|
|
40
40
|
type ResponsiveDevice,
|
|
41
41
|
classStylesInListOrder,
|
|
42
42
|
iconHasAdjustableStroke,
|
|
@@ -44,7 +44,8 @@ import {
|
|
|
44
44
|
resolveCascade,
|
|
45
45
|
SAMPLE_POST,
|
|
46
46
|
STYLE_STATES,
|
|
47
|
-
type
|
|
47
|
+
type FlatStyleProps,
|
|
48
|
+
flattenMotion,
|
|
48
49
|
type StyleStates,
|
|
49
50
|
boxLinkHeldBack,
|
|
50
51
|
} from "../../../core/index.ts";
|
|
@@ -65,6 +66,7 @@ import {
|
|
|
65
66
|
HtmlIdField,
|
|
66
67
|
} from "./settings/AdvancedFields.tsx";
|
|
67
68
|
import { ClassChipInput } from "./settings/ClassChipInput.tsx";
|
|
69
|
+
import { useExtensionElement } from "../extensions-context.tsx";
|
|
68
70
|
import { StateDot, StateSwitcher, type StyleStateChoice } from "./settings/StateSwitcher.tsx";
|
|
69
71
|
import {
|
|
70
72
|
DEFAULT_UI,
|
|
@@ -131,7 +133,7 @@ const writeSections = (type: string, open: Set<StyleSectionId>) => {
|
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
135
|
|
|
134
|
-
const countSet = (type: string, style:
|
|
136
|
+
const countSet = (type: string, style: FlatStyleProps | undefined, section: StyleSectionId) =>
|
|
135
137
|
keysFor(type, section, style).filter((key) => style?.[key] !== undefined).length;
|
|
136
138
|
|
|
137
139
|
/** Whether any state sets a key of this section (the section header's dot in Normal). */
|
|
@@ -159,7 +161,7 @@ const JUMP_HELP: Record<Exclude<StyleStateChoice, "normal">, string> = {
|
|
|
159
161
|
const positionInEffect = (
|
|
160
162
|
node: LayoutNode,
|
|
161
163
|
design: DesignSystem,
|
|
162
|
-
cls: { style?:
|
|
164
|
+
cls: { style?: FlatStyleProps } | undefined,
|
|
163
165
|
) =>
|
|
164
166
|
cls
|
|
165
167
|
? cls.style?.position
|
|
@@ -218,7 +220,7 @@ type Props = {
|
|
|
218
220
|
/** The chosen style state, for the canvas preview (W-089). */
|
|
219
221
|
onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
|
|
220
222
|
/** Tablet and mobile edit overrides. Desktop edits `style` (W-096). */
|
|
221
|
-
device?:
|
|
223
|
+
device?: Device;
|
|
222
224
|
/** Add, move and delete for Accordion items and Tabs panels (W-130). */
|
|
223
225
|
items?: ItemActions;
|
|
224
226
|
/** The theme part being edited, if any, for the H1 warning (W-208). */
|
|
@@ -321,7 +323,7 @@ function pairFields<F extends { key: string }>(fields: readonly F[]): F[][] {
|
|
|
321
323
|
|
|
322
324
|
/** UX-071: fields that only apply to some values of another field on the same element. */
|
|
323
325
|
const SHOWN_WHEN: Readonly<
|
|
324
|
-
Record<string, (props: Record<string, unknown>, device:
|
|
326
|
+
Record<string, (props: Record<string, unknown>, device: Device) => boolean>
|
|
325
327
|
> = {
|
|
326
328
|
"loop.columns": (props) => props["display"] === "grid" || props["display"] === "cards",
|
|
327
329
|
"pagination.countText": (props) => props["showCount"] === true,
|
|
@@ -335,7 +337,7 @@ const SHOWN_WHEN: Readonly<
|
|
|
335
337
|
"grid.columnTracksMobile": (_props, device) => device === "mobile",
|
|
336
338
|
};
|
|
337
339
|
|
|
338
|
-
function fieldShown(key: string, node: LayoutNode, device:
|
|
340
|
+
function fieldShown(key: string, node: LayoutNode, device: Device = "desktop"): boolean {
|
|
339
341
|
const props = node.props as Record<string, unknown>;
|
|
340
342
|
// A stored value always shows, so it can be seen and reset.
|
|
341
343
|
if (props[key] !== undefined) return true;
|
|
@@ -349,7 +351,19 @@ function fieldShown(key: string, node: LayoutNode, device: PopupDevice = "deskto
|
|
|
349
351
|
|
|
350
352
|
/** Right panel with an element selected (IA / W-021): descriptor Content + Style sections. */
|
|
351
353
|
export function ElementPanel(props: Props) {
|
|
352
|
-
const
|
|
354
|
+
const builtIn = ELEMENT_DESCRIPTORS.find((d) => d.type === props.node.type);
|
|
355
|
+
const extension = useExtensionElement(props.node.type);
|
|
356
|
+
const descriptor: ElementDescriptor | undefined = builtIn
|
|
357
|
+
? builtIn
|
|
358
|
+
: extension
|
|
359
|
+
? {
|
|
360
|
+
type: extension.type,
|
|
361
|
+
name: extension.label,
|
|
362
|
+
group: extension.group,
|
|
363
|
+
defaultTab: "content",
|
|
364
|
+
fields: [...extension.fields],
|
|
365
|
+
}
|
|
366
|
+
: undefined;
|
|
353
367
|
if (!descriptor) {
|
|
354
368
|
return (
|
|
355
369
|
<div
|
|
@@ -357,9 +371,21 @@ export function ElementPanel(props: Props) {
|
|
|
357
371
|
data-emvb-panel="element"
|
|
358
372
|
data-emvb-element={props.node.type}
|
|
359
373
|
>
|
|
360
|
-
<h2 className="emvb-panel-title">
|
|
374
|
+
<h2 className="emvb-panel-title">
|
|
375
|
+
{props.node.type.startsWith("ext:") ? "Missing extension" : "Unknown element"}
|
|
376
|
+
</h2>
|
|
361
377
|
<p className="emvb-helper">
|
|
362
|
-
|
|
378
|
+
{props.node.type.startsWith("ext:") ? (
|
|
379
|
+
<>
|
|
380
|
+
This block needs the extension for "{props.node.type}". It can be moved or
|
|
381
|
+
deleted; install the extension to edit it.
|
|
382
|
+
</>
|
|
383
|
+
) : (
|
|
384
|
+
<>
|
|
385
|
+
Unknown element "{props.node.type}". It can be moved or deleted, but not
|
|
386
|
+
edited.
|
|
387
|
+
</>
|
|
388
|
+
)}
|
|
363
389
|
</p>
|
|
364
390
|
{props.rejection && <Alert>{props.rejection}</Alert>}
|
|
365
391
|
</div>
|
|
@@ -413,10 +439,16 @@ function KnownElementPanel({
|
|
|
413
439
|
React.useEffect(() => {
|
|
414
440
|
onStyleState?.(node.id, tab === "style" ? styleState : "normal");
|
|
415
441
|
}, [node.id, styleState, tab, onStyleState]);
|
|
416
|
-
|
|
442
|
+
// W-925: the rows read the flat motion keys; applyStylePatch nests them again.
|
|
443
|
+
const normal = flattenMotion(cls ? cls.style : node.style);
|
|
417
444
|
const states = cls ? cls.states : node.states;
|
|
418
445
|
const responsive: ResponsiveDevice | null = device === "desktop" ? null : device;
|
|
419
|
-
const
|
|
446
|
+
const storedDevices = cls ? cls.devices : node.devices;
|
|
447
|
+
const ownerDevices = storedDevices && {
|
|
448
|
+
laptop: flattenMotion(storedDevices.laptop),
|
|
449
|
+
tablet: flattenMotion(storedDevices.tablet),
|
|
450
|
+
mobile: flattenMotion(storedDevices.mobile),
|
|
451
|
+
};
|
|
420
452
|
const style = responsive
|
|
421
453
|
? ownerDevices?.[responsive]
|
|
422
454
|
: styleState === "normal"
|
|
@@ -425,6 +457,8 @@ function KnownElementPanel({
|
|
|
425
457
|
const ownInherited = responsive
|
|
426
458
|
? {
|
|
427
459
|
...normal,
|
|
460
|
+
// W-956: each device inherits the wider ones: Laptop, then Tablet.
|
|
461
|
+
...(responsive !== "laptop" ? ownerDevices?.laptop : undefined),
|
|
428
462
|
...(responsive === "mobile" ? ownerDevices?.tablet : undefined),
|
|
429
463
|
}
|
|
430
464
|
: styleState === "normal"
|
|
@@ -463,7 +497,7 @@ function KnownElementPanel({
|
|
|
463
497
|
!singleColorOffered &&
|
|
464
498
|
node.props.singleColor !== true &&
|
|
465
499
|
ownColors;
|
|
466
|
-
const patchStyle = (patch: Partial<
|
|
500
|
+
const patchStyle = (patch: Partial<FlatStyleProps>) => {
|
|
467
501
|
const written = applyStylePatch({
|
|
468
502
|
node,
|
|
469
503
|
design,
|
|
@@ -581,7 +615,8 @@ function KnownElementPanel({
|
|
|
581
615
|
duplicateName={
|
|
582
616
|
field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
|
|
583
617
|
}
|
|
584
|
-
|
|
618
|
+
// Field values have no laptop setting: Laptop edits the desktop value.
|
|
619
|
+
device={device === "laptop" ? "desktop" : device}
|
|
585
620
|
/>
|
|
586
621
|
</React.Fragment>
|
|
587
622
|
));
|