@perkyzz/emvb 0.3.0 → 0.5.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 +22 -4
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +5 -2
- package/src/admin/access/role.ts +9 -3
- package/src/admin/agents-api.ts +39 -0
- package/src/admin/api.ts +17 -7
- package/src/admin/content-api.ts +7 -51
- package/src/admin/content-item.ts +22 -0
- package/src/admin/design-api.ts +30 -0
- package/src/admin/editor/A11yCopilot.tsx +1 -1
- package/src/admin/editor/CommandPalette.tsx +43 -2
- package/src/admin/editor/Editor.tsx +133 -332
- package/src/admin/editor/EditorOverlay.tsx +3 -1
- package/src/admin/editor/PerfMeter.tsx +1 -1
- package/src/admin/editor/ShortcutsDialog.tsx +4 -1
- package/src/admin/editor/Timeline.tsx +124 -9
- package/src/admin/editor/canvas/CanvasFrame.tsx +51 -368
- package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
- package/src/admin/editor/canvas/SelectionOverlay.tsx +86 -46
- package/src/admin/editor/canvas/canvas-scale.ts +20 -0
- package/src/admin/editor/canvas/drop-line.ts +24 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
- package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
- package/src/admin/editor/collection-previews.ts +28 -5
- package/src/admin/editor/editor-chrome.tsx +346 -0
- package/src/admin/editor/editor-commands.ts +360 -0
- package/src/admin/editor/editor-css.ts +4 -0
- package/src/admin/editor/element-chrome.ts +89 -0
- package/src/admin/editor/feature-css.ts +37 -18
- package/src/admin/editor/host.ts +33 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
- package/src/admin/editor/icons/library.ts +29 -19
- package/src/admin/editor/icons/use-icon-library.ts +315 -0
- package/src/admin/editor/palette-items.ts +36 -5
- package/src/admin/editor/palette.ts +9 -4
- package/src/admin/editor/panels/AddPanel.tsx +2 -67
- package/src/admin/editor/panels/ColorControl.tsx +21 -18
- package/src/admin/editor/panels/ElementPanel.tsx +40 -99
- package/src/admin/editor/panels/LayersPanel.tsx +34 -62
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +16 -10
- package/src/admin/editor/panels/TokenScales.tsx +4 -2
- package/src/admin/editor/panels/VariableSection.tsx +1 -10
- package/src/admin/editor/panels/color-space.ts +12 -1
- package/src/admin/editor/panels/inline-error.tsx +11 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +143 -1
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +115 -7
- package/src/admin/editor/panels/settings/DraftTextField.tsx +42 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +6 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
- package/src/admin/editor/panels/settings/IconPicker.tsx +21 -1
- package/src/admin/editor/panels/settings/ImageSourcesField.tsx +111 -0
- package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
- package/src/admin/editor/panels/settings/MediaPicker.tsx +2 -3
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +178 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -2
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/panels/settings/form-names.ts +7 -11
- package/src/admin/editor/panels/settings/length-units.ts +15 -4
- package/src/admin/editor/panels/settings/link-rules.ts +19 -0
- package/src/admin/editor/panels/settings/number-input.ts +11 -0
- package/src/admin/editor/panels/settings/query-style.ts +65 -0
- package/src/admin/editor/panels/settings/style-sections.ts +5 -1
- package/src/admin/editor/panels/style-target.ts +105 -0
- package/src/admin/editor/panels/variable-values.ts +4 -2
- package/src/admin/editor/remote-change.ts +67 -0
- package/src/admin/editor/section-templates.ts +43 -21
- package/src/admin/editor/shortcuts.ts +4 -0
- package/src/admin/editor/store.ts +10 -1
- package/src/admin/editor/useClipboardActions.ts +1 -1
- package/src/admin/editor/useEditorCommands.ts +61 -13
- package/src/admin/editor/useEditorData.ts +7 -1
- package/src/admin/editor/useEditorShortcuts.ts +23 -15
- package/src/admin/editor/useNodeActions.ts +6 -1
- package/src/admin/forms-api.ts +17 -6
- package/src/admin/icon-uploads-api.ts +18 -0
- package/src/admin/index.tsx +3 -1
- package/src/admin/media-api.ts +20 -0
- package/src/admin/pages/AgentsPage.tsx +274 -0
- package/src/admin/theme-api.ts +5 -18
- package/src/admin/ui.ts +28 -0
- package/src/astro/content-port.ts +24 -0
- package/src/astro/floats/runtime.ts +10 -0
- package/src/astro/forms/EmVBFormsClient.astro +11 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
- package/src/astro/forms/client.ts +1 -0
- package/src/astro/forms-definitions.ts +24 -11
- package/src/astro/index.ts +1 -0
- package/src/astro/popups/runtime.ts +15 -0
- package/src/astro/render-session.ts +85 -0
- package/src/astro/request-data.ts +20 -8
- package/src/astro/resolve-theme.ts +166 -76
- package/src/astro/resolve.ts +57 -16
- package/src/astro/tabs/runtime.ts +60 -1
- package/src/astro/theme-posts.ts +16 -5
- package/src/astro/visitor.ts +67 -5
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +202 -26
- package/src/core/arrange.ts +71 -38
- package/src/core/audience/rules.ts +22 -2
- package/src/core/canvas-styles.ts +24 -0
- package/src/core/clipboard.ts +11 -32
- package/src/core/css/generate.ts +18 -1
- package/src/core/css/print.ts +12 -0
- package/src/core/css/scope.ts +3 -3
- package/src/core/css-keywords.ts +83 -0
- package/src/core/data/bindings.ts +4 -6
- package/src/core/design/classes.ts +13 -15
- package/src/core/design/diff.ts +55 -0
- package/src/core/design/merge.ts +127 -0
- package/src/core/design/variables.ts +25 -21
- package/src/core/elements/dynamic-elements.ts +30 -0
- package/src/core/elements/form-elements.ts +20 -3
- package/src/core/elements/index.ts +211 -7
- package/src/core/forms/binding.ts +4 -13
- package/src/core/index.ts +10 -0
- package/src/core/local-style.ts +27 -0
- package/src/core/migrate/index.ts +9 -4
- package/src/core/nesting.ts +4 -23
- package/src/core/perf/scripts.ts +9 -6
- package/src/core/record.ts +3 -0
- package/src/core/render/context.ts +2 -0
- package/src/core/render/dynamic-post.ts +22 -7
- package/src/core/render/form.ts +145 -15
- package/src/core/render/index.ts +195 -14
- package/src/core/render/pagination.ts +21 -2
- package/src/core/render/vnode.ts +12 -2
- package/src/core/sanitize/css.ts +90 -77
- package/src/core/sanitize/embed-url.ts +7 -1
- package/src/core/sanitize/href.ts +13 -1
- package/src/core/sanitize/svg.ts +8 -3
- package/src/core/sanitize/url.ts +10 -1
- package/src/core/schema/descriptors.ts +4 -1
- package/src/core/schema/design.ts +5 -7
- package/src/core/schema/layout.ts +160 -181
- package/src/core/schema/style.ts +53 -63
- package/src/core/share/link.ts +72 -29
- package/src/core/tabs/presence.ts +7 -17
- package/src/core/theme/dynamic.ts +205 -39
- package/src/core/theme/float.ts +1 -1
- package/src/core/tree-ops.ts +57 -0
- package/src/index.ts +14 -2
- package/src/mcp/errors.ts +44 -0
- package/src/mcp/index.ts +4 -0
- package/src/mcp/ports.ts +78 -0
- package/src/mcp/prompts.ts +76 -0
- package/src/mcp/publish.ts +60 -0
- package/src/mcp/queue.ts +19 -0
- package/src/mcp/rate-limit.ts +80 -0
- package/src/mcp/read.ts +419 -0
- package/src/mcp/refs.ts +84 -0
- package/src/mcp/settings.ts +18 -0
- package/src/mcp/tools.ts +265 -0
- package/src/mcp/write.ts +582 -0
- package/src/server/agent-settings.ts +134 -0
- package/src/server/design-routes.ts +75 -18
- package/src/server/icon-routes.ts +72 -16
- package/src/server/mcp-routes.ts +265 -0
- package/src/server/plugin.ts +40 -4
- package/src/admin/editor/icons/sets/fontawesome.json +0 -1
- package/src/admin/editor/icons/sets/lucide.json +0 -1
- package/src/admin/editor/icons/sets/remix.json +0 -1
- package/src/admin/editor/icons/sets/tabler.json +0 -1
|
@@ -3,23 +3,13 @@ import type { Fetcher } from "../../api.ts";
|
|
|
3
3
|
import {
|
|
4
4
|
CaretDownIcon,
|
|
5
5
|
CaretRightIcon,
|
|
6
|
-
CheckSquareIcon,
|
|
7
|
-
ClipboardTextIcon,
|
|
8
|
-
ImageIcon,
|
|
9
|
-
NotePencilIcon,
|
|
10
6
|
PaintBrushIcon,
|
|
11
|
-
PaperPlaneTiltIcon,
|
|
12
7
|
PencilSimpleIcon,
|
|
13
|
-
RadioButtonIcon,
|
|
14
|
-
RowsIcon,
|
|
15
|
-
SquaresFourIcon,
|
|
16
|
-
StarIcon,
|
|
17
|
-
TextHIcon,
|
|
18
|
-
TextboxIcon,
|
|
19
8
|
WarningCircleIcon,
|
|
20
|
-
YoutubeLogoIcon,
|
|
21
9
|
} from "@phosphor-icons/react";
|
|
22
10
|
import * as React from "react";
|
|
11
|
+
import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
|
|
12
|
+
import { indexLayout } from "../../../core/tree-ops.ts";
|
|
23
13
|
import type { ThemePartType } from "../../../core/theme/part-types.ts";
|
|
24
14
|
import { sharedPartH1 } from "./settings/heading-warning.ts";
|
|
25
15
|
import { UNNAMED_BOX_LINK_NOTE, unnamedBoxLink } from "./settings/box-link-name.ts";
|
|
@@ -31,24 +21,16 @@ import { duplicateFieldName } from "./settings/form-names.ts";
|
|
|
31
21
|
import { hasItemList, ItemList, type ItemActions } from "./settings/ItemList.tsx";
|
|
32
22
|
import {
|
|
33
23
|
ELEMENT_DESCRIPTORS,
|
|
34
|
-
findNode,
|
|
35
24
|
hasLocalStyles,
|
|
36
25
|
localStylesToClass,
|
|
37
26
|
localToClassRefusal,
|
|
38
27
|
isFormNode,
|
|
39
|
-
parentOf,
|
|
40
28
|
type DesignSystem,
|
|
41
29
|
type ElementDescriptor,
|
|
42
30
|
type Layout,
|
|
43
31
|
type Arranged,
|
|
44
32
|
inheritedStyle,
|
|
45
33
|
type LayoutNode,
|
|
46
|
-
patchClassDevices,
|
|
47
|
-
patchClassState,
|
|
48
|
-
patchClassStyle,
|
|
49
|
-
patchDeviceStyle,
|
|
50
|
-
patchStates,
|
|
51
|
-
type DeviceStyles,
|
|
52
34
|
type PopupDevice,
|
|
53
35
|
type ResponsiveDevice,
|
|
54
36
|
classStylesInListOrder,
|
|
@@ -60,6 +42,7 @@ import {
|
|
|
60
42
|
type StyleProps,
|
|
61
43
|
type StyleStates,
|
|
62
44
|
} from "../../../core/index.ts";
|
|
45
|
+
import { applyStylePatch } from "./style-target.ts";
|
|
63
46
|
import { FieldControl } from "./settings/FieldControl.tsx";
|
|
64
47
|
import { BindingsEditor } from "./settings/BindingsEditor.tsx";
|
|
65
48
|
import { VariantEditor } from "./settings/VariantEditor.tsx";
|
|
@@ -69,7 +52,12 @@ import { BoxControl } from "./settings/BoxControl.tsx";
|
|
|
69
52
|
import { boxGroupOf } from "./settings/box-sides.ts";
|
|
70
53
|
import { IconShapeRow, IconSingleColorRow } from "./settings/IconControls.tsx";
|
|
71
54
|
import { StyleRow } from "./settings/StyleRow.tsx";
|
|
72
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
AttributesEditor,
|
|
57
|
+
ContainerQueryFields,
|
|
58
|
+
DirectionField,
|
|
59
|
+
HtmlIdField,
|
|
60
|
+
} from "./settings/AdvancedFields.tsx";
|
|
73
61
|
import { ClassChipInput } from "./settings/ClassChipInput.tsx";
|
|
74
62
|
import { StateDot, StateSwitcher, type StyleStateChoice } from "./settings/StateSwitcher.tsx";
|
|
75
63
|
import {
|
|
@@ -83,60 +71,17 @@ import {
|
|
|
83
71
|
type StyleSectionId,
|
|
84
72
|
} from "./settings/style-sections.ts";
|
|
85
73
|
|
|
86
|
-
export const ELEMENT_NAMES: Record<string, string> = Object.fromEntries(
|
|
87
|
-
ELEMENT_DESCRIPTORS.map((d) => [d.type, d.name]),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
74
|
const enclosingFormId = (layout: Layout, nodeId: string): string | undefined => {
|
|
91
|
-
|
|
75
|
+
const index = indexLayout(layout);
|
|
76
|
+
let current = index.parentOf.get(nodeId);
|
|
92
77
|
while (current) {
|
|
93
|
-
const node =
|
|
78
|
+
const node = index.byId.get(current);
|
|
94
79
|
if (node && isFormNode(node)) return node.props.formId || undefined;
|
|
95
|
-
current = parentOf(
|
|
80
|
+
current = index.parentOf.get(current);
|
|
96
81
|
}
|
|
97
82
|
return undefined;
|
|
98
83
|
};
|
|
99
84
|
|
|
100
|
-
const ICONS: Record<string, typeof TextHIcon> = {
|
|
101
|
-
heading: TextHIcon,
|
|
102
|
-
container: SquaresFourIcon,
|
|
103
|
-
"div-block": SquaresFourIcon,
|
|
104
|
-
"layout-section": RowsIcon,
|
|
105
|
-
flexbox: SquaresFourIcon,
|
|
106
|
-
image: ImageIcon,
|
|
107
|
-
icon: StarIcon,
|
|
108
|
-
svg: StarIcon,
|
|
109
|
-
tabs: SquaresFourIcon,
|
|
110
|
-
"tab-panel": SquaresFourIcon,
|
|
111
|
-
video: YoutubeLogoIcon,
|
|
112
|
-
form: ClipboardTextIcon,
|
|
113
|
-
"text-input": TextboxIcon,
|
|
114
|
-
textarea: NotePencilIcon,
|
|
115
|
-
select: TextboxIcon,
|
|
116
|
-
checkbox: CheckSquareIcon,
|
|
117
|
-
radio: RadioButtonIcon,
|
|
118
|
-
submit: PaperPlaneTiltIcon,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const withStyle = (node: LayoutNode, patch: Partial<StyleProps>): LayoutNode => {
|
|
122
|
-
const style: Record<string, unknown> = { ...node.style, ...patch };
|
|
123
|
-
for (const key of Object.keys(style)) if (style[key] === undefined) delete style[key];
|
|
124
|
-
return {
|
|
125
|
-
...node,
|
|
126
|
-
style: Object.keys(style).length > 0 ? (style as StyleProps) : undefined,
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const withDevices = (node: LayoutNode, devices: DeviceStyles | undefined): LayoutNode => {
|
|
131
|
-
const { devices: _old, ...rest } = node;
|
|
132
|
-
return (devices ? { ...rest, devices } : rest) as LayoutNode;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const withStates = (node: LayoutNode, states: StyleStates | undefined): LayoutNode => {
|
|
136
|
-
const { states: _old, ...rest } = node;
|
|
137
|
-
return (states ? { ...rest, states } : rest) as LayoutNode;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
85
|
const sectionKey = (type: string) => `emvb-style-sections:${type}`;
|
|
141
86
|
|
|
142
87
|
/**
|
|
@@ -417,13 +362,20 @@ function KnownElementPanel({
|
|
|
417
362
|
const position = positionInEffect(node, design, cls);
|
|
418
363
|
const iconSvg =
|
|
419
364
|
node.type === "icon" && typeof node.props.iconSvg === "string" ? node.props.iconSvg : undefined;
|
|
420
|
-
const strokeAdjustable =
|
|
365
|
+
const strokeAdjustable = React.useMemo(
|
|
366
|
+
() => (node.type === "icon" && !cls ? iconHasAdjustableStroke(iconSvg) : true),
|
|
367
|
+
[node.type, cls, iconSvg],
|
|
368
|
+
);
|
|
369
|
+
const ownColors = React.useMemo(
|
|
370
|
+
() => node.type === "icon" && iconHasOwnColors(iconSvg),
|
|
371
|
+
[node.type, iconSvg],
|
|
372
|
+
);
|
|
421
373
|
const singleColorOffered =
|
|
422
374
|
node.type === "icon" &&
|
|
423
375
|
!cls &&
|
|
424
376
|
!responsive &&
|
|
425
377
|
styleState === "normal" &&
|
|
426
|
-
(node.props.singleColor === true ||
|
|
378
|
+
(node.props.singleColor === true || ownColors);
|
|
427
379
|
// W-296: elsewhere (Hover, Focus, a device) Colour does nothing on such an SVG until Force single
|
|
428
380
|
// colour is on, and that switch only lives in Normal on Desktop, so say so there.
|
|
429
381
|
const colorIgnoredHere =
|
|
@@ -431,36 +383,22 @@ function KnownElementPanel({
|
|
|
431
383
|
!cls &&
|
|
432
384
|
!singleColorOffered &&
|
|
433
385
|
node.props.singleColor !== true &&
|
|
434
|
-
|
|
386
|
+
ownColors;
|
|
435
387
|
const patchStyle = (patch: Partial<StyleProps>) => {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
);
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
const state = styleState;
|
|
450
|
-
if (!cls) {
|
|
451
|
-
onChange(
|
|
452
|
-
state === "normal"
|
|
453
|
-
? withStyle(node, patch)
|
|
454
|
-
: withStates(node, patchStates(node.states, state, patch)),
|
|
455
|
-
);
|
|
388
|
+
const written = applyStylePatch({
|
|
389
|
+
node,
|
|
390
|
+
design,
|
|
391
|
+
classId: cls ? cls.id : null,
|
|
392
|
+
device,
|
|
393
|
+
state: styleState,
|
|
394
|
+
patch,
|
|
395
|
+
});
|
|
396
|
+
if (written.kind === "node") {
|
|
397
|
+
onChange(written.node);
|
|
456
398
|
return;
|
|
457
399
|
}
|
|
458
400
|
setDesignError(null);
|
|
459
|
-
|
|
460
|
-
state === "normal"
|
|
461
|
-
? patchClassStyle(design, cls.id, patch)
|
|
462
|
-
: patchClassState(design, cls.id, state, patch);
|
|
463
|
-
onDesignChange(next).catch((error: unknown) =>
|
|
401
|
+
onDesignChange(written.design).catch((error: unknown) =>
|
|
464
402
|
setDesignError(
|
|
465
403
|
error instanceof Error ? error.message : "Couldn't save the class. Try again.",
|
|
466
404
|
),
|
|
@@ -472,7 +410,7 @@ function KnownElementPanel({
|
|
|
472
410
|
const bodyRef = React.useRef<HTMLDivElement>(null);
|
|
473
411
|
useTabScroll(bodyRef, tab, node.id);
|
|
474
412
|
|
|
475
|
-
const Icon =
|
|
413
|
+
const Icon = elementIcon(node.type);
|
|
476
414
|
const crumbs = breadcrumb(layout, node.id);
|
|
477
415
|
const section = (
|
|
478
416
|
id: StyleSectionId,
|
|
@@ -647,6 +585,8 @@ function KnownElementPanel({
|
|
|
647
585
|
(node.htmlId ? 1 : 0) + (node.attributes?.length ?? 0),
|
|
648
586
|
<>
|
|
649
587
|
<HtmlIdField node={node} layout={layout} onChange={onChange} />
|
|
588
|
+
<DirectionField node={node} onChange={onChange} />
|
|
589
|
+
<ContainerQueryFields node={node} onChange={onChange} />
|
|
650
590
|
<AttributesEditor
|
|
651
591
|
attributes={node.attributes}
|
|
652
592
|
onChange={(attributes) => onChange({ ...node, attributes })}
|
|
@@ -789,16 +729,17 @@ function breadcrumb(
|
|
|
789
729
|
id: string,
|
|
790
730
|
): Array<{ id: string | null; label: string }> {
|
|
791
731
|
if (!layout) return [];
|
|
732
|
+
const index = indexLayout(layout);
|
|
792
733
|
const chain: Array<{ id: string; label: string }> = [];
|
|
793
734
|
let current: string | undefined = id;
|
|
794
735
|
while (current) {
|
|
795
|
-
const node =
|
|
736
|
+
const node = index.byId.get(current);
|
|
796
737
|
if (!node) break;
|
|
797
738
|
chain.unshift({
|
|
798
739
|
id: node.id,
|
|
799
740
|
label: ELEMENT_NAMES[node.type] ?? node.type,
|
|
800
741
|
});
|
|
801
|
-
current = parentOf(
|
|
742
|
+
current = index.parentOf.get(current);
|
|
802
743
|
}
|
|
803
744
|
return [{ id: null, label: "Page" }, ...chain];
|
|
804
745
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CaretDownIcon,
|
|
3
|
-
CaretRightIcon,
|
|
4
|
-
RowsIcon,
|
|
5
|
-
SquaresFourIcon,
|
|
6
|
-
TextHIcon,
|
|
7
|
-
} from "@phosphor-icons/react";
|
|
1
|
+
import { CaretDownIcon, CaretRightIcon } from "@phosphor-icons/react";
|
|
8
2
|
import * as React from "react";
|
|
9
3
|
import {
|
|
10
4
|
firstChild,
|
|
@@ -20,23 +14,14 @@ import {
|
|
|
20
14
|
SCRIPT_LABELS,
|
|
21
15
|
type PageScript,
|
|
22
16
|
} from "../../../core/index.ts";
|
|
17
|
+
import { indexLayout } from "../../../core/tree-ops.ts";
|
|
23
18
|
import { EXISTING_ELEMENT_MIME } from "../dnd/drop-target.ts";
|
|
24
|
-
import { ELEMENT_NAMES } from "
|
|
19
|
+
import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
|
|
20
|
+
import { editorCommands } from "../editor-commands.ts";
|
|
25
21
|
import { dragStash } from "../dnd/drag-stash.ts";
|
|
26
22
|
import { StateDot } from "./settings/StateSwitcher.tsx";
|
|
27
23
|
import type { ClipboardActions } from "../useClipboardActions.ts";
|
|
28
24
|
|
|
29
|
-
const ICONS: Record<string, typeof TextHIcon> = {
|
|
30
|
-
heading: TextHIcon,
|
|
31
|
-
container: SquaresFourIcon,
|
|
32
|
-
svg: SquaresFourIcon,
|
|
33
|
-
tabs: SquaresFourIcon,
|
|
34
|
-
"tab-panel": SquaresFourIcon,
|
|
35
|
-
"div-block": SquaresFourIcon,
|
|
36
|
-
"layout-section": RowsIcon,
|
|
37
|
-
flexbox: SquaresFourIcon,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
25
|
const rows = (
|
|
41
26
|
node: LayoutNode,
|
|
42
27
|
depth: number,
|
|
@@ -92,47 +77,33 @@ function menuItems(
|
|
|
92
77
|
clip: ClipboardActions | undefined,
|
|
93
78
|
rename: () => void,
|
|
94
79
|
): MenuItem[] {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
{ label: "Copy style", run: clip.copyStyle },
|
|
123
|
-
{ label: "Paste style", run: clip.pasteStyle, disabled: !!clip.pasteStyleBlocked },
|
|
124
|
-
]
|
|
125
|
-
: [];
|
|
126
|
-
if (isRoot) return [...naming, ...clipboard, ...style];
|
|
127
|
-
return [
|
|
128
|
-
...naming,
|
|
129
|
-
...clipboard,
|
|
130
|
-
{ label: "Duplicate", run: actions.onDuplicate },
|
|
131
|
-
...style,
|
|
132
|
-
{ label: "Move up", run: actions.onMoveUp },
|
|
133
|
-
{ label: "Move down", run: actions.onMoveDown },
|
|
134
|
-
{ label: "Delete", run: actions.onDelete, className: "emvb-danger-text" },
|
|
135
|
-
];
|
|
80
|
+
return editorCommands({
|
|
81
|
+
surface: "layers",
|
|
82
|
+
targetId: node.id,
|
|
83
|
+
isRoot,
|
|
84
|
+
isParent: isParentNode(node),
|
|
85
|
+
device: "desktop",
|
|
86
|
+
canDuplicate: !isRoot,
|
|
87
|
+
canDelete: !isRoot,
|
|
88
|
+
runners: {
|
|
89
|
+
rename: actions.onRename ? rename : undefined,
|
|
90
|
+
duplicate: actions.onDuplicate,
|
|
91
|
+
remove: actions.onDelete,
|
|
92
|
+
moveUp: actions.onMoveUp,
|
|
93
|
+
moveDown: actions.onMoveDown,
|
|
94
|
+
copy: clip?.copy,
|
|
95
|
+
paste: clip?.paste,
|
|
96
|
+
copyStyle: clip?.copyStyle,
|
|
97
|
+
pasteStyle: clip?.pasteStyle,
|
|
98
|
+
pasteBlocked: clip?.pasteBlocked,
|
|
99
|
+
pasteStyleBlocked: clip?.pasteStyleBlocked,
|
|
100
|
+
},
|
|
101
|
+
}).map((command) => ({
|
|
102
|
+
label: command.label,
|
|
103
|
+
run: () => command.run(),
|
|
104
|
+
disabled: command.disabled,
|
|
105
|
+
className: command.danger ? "emvb-danger-text" : undefined,
|
|
106
|
+
}));
|
|
136
107
|
}
|
|
137
108
|
|
|
138
109
|
/** What a key does in the tree: select another row, toggle the selected one, or nothing. */
|
|
@@ -242,10 +213,11 @@ export function LayersPanel({
|
|
|
242
213
|
if (!layout || !selectedId) return;
|
|
243
214
|
setCollapsed((current) => {
|
|
244
215
|
const next = new Set(current);
|
|
216
|
+
const parents = indexLayout(layout).parentOf;
|
|
245
217
|
let id: string | undefined = selectedId;
|
|
246
218
|
while (id) {
|
|
247
219
|
next.delete(id);
|
|
248
|
-
id =
|
|
220
|
+
id = parents.get(id);
|
|
249
221
|
}
|
|
250
222
|
return next;
|
|
251
223
|
});
|
|
@@ -345,7 +317,7 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
345
317
|
}) {
|
|
346
318
|
const onToggle = () => toggleRow(node.id);
|
|
347
319
|
const onMenu = (open: boolean) => menuRow(node.id, open);
|
|
348
|
-
const Icon =
|
|
320
|
+
const Icon = elementIcon(node.type);
|
|
349
321
|
const preview = layerPreview(node);
|
|
350
322
|
const typeName = ELEMENT_NAMES[node.type] ?? node.type;
|
|
351
323
|
// A label names the row in place of the type (W-157); the type stays in the tooltip.
|
|
@@ -66,6 +66,7 @@ export function SettingsPanel({
|
|
|
66
66
|
layout={state.page.layout}
|
|
67
67
|
onDesignChange={onDesignChange}
|
|
68
68
|
unpublished={state.designUnpublished === true}
|
|
69
|
+
published={state.publishedDesign}
|
|
69
70
|
onPublishStyles={onPublishStyles}
|
|
70
71
|
{...(onDesignItemDeleted ? { onDeleted: onDesignItemDeleted } : {})}
|
|
71
72
|
onLayoutChange={(layout) =>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Button, Select, Tabs } from "@cloudflare/kumo";
|
|
2
2
|
import { deletionOf, type Deletion } from "../restore-deleted.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { XIcon } from "@phosphor-icons/react";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import {
|
|
6
6
|
clearClassRefs,
|
|
7
7
|
deleteVariable,
|
|
8
|
+
designChangeLabel,
|
|
9
|
+
designChanges,
|
|
8
10
|
designFromJson,
|
|
9
11
|
designToJson,
|
|
10
12
|
findClassUsages,
|
|
@@ -27,6 +29,7 @@ import { stopEditorShortcuts } from "./settings/ClassChip.tsx";
|
|
|
27
29
|
import { StyleRow } from "./settings/StyleRow.tsx";
|
|
28
30
|
import { FIELD } from "../../ui.ts";
|
|
29
31
|
import { TokenScales } from "./TokenScales.tsx";
|
|
32
|
+
import { InlineError } from "./inline-error.tsx";
|
|
30
33
|
import { VariableSection } from "./VariableSection.tsx";
|
|
31
34
|
|
|
32
35
|
const STYLE_NOTE = "Style changes stay unpublished until you publish styles.";
|
|
@@ -36,6 +39,8 @@ type Props = {
|
|
|
36
39
|
layout: Layout | null;
|
|
37
40
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
38
41
|
unpublished?: boolean;
|
|
42
|
+
/** Published design. With `unpublished`, the drawer lists what Publish styles will change. */
|
|
43
|
+
published?: DesignSystem;
|
|
39
44
|
onPublishStyles?: () => Promise<void>;
|
|
40
45
|
onLayoutChange: (layout: Layout) => void;
|
|
41
46
|
/** W-252: called with what a delete removes, before the page loses its uses. */
|
|
@@ -43,15 +48,6 @@ type Props = {
|
|
|
43
48
|
onClose: () => void;
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
function InlineError({ children }: { children: string }) {
|
|
47
|
-
return (
|
|
48
|
-
<p className="emvb-inline-error" role="alert">
|
|
49
|
-
<WarningCircleIcon size={16} aria-hidden="true" />
|
|
50
|
-
{children}
|
|
51
|
-
</p>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
function exportDesign(design: DesignSystem) {
|
|
56
52
|
const blob = new Blob([designToJson(design)], { type: "application/json" });
|
|
57
53
|
const url = URL.createObjectURL(blob);
|
|
@@ -71,6 +67,7 @@ export function SiteStylesDrawer({
|
|
|
71
67
|
layout,
|
|
72
68
|
onDesignChange,
|
|
73
69
|
unpublished = false,
|
|
70
|
+
published,
|
|
74
71
|
onPublishStyles,
|
|
75
72
|
onLayoutChange,
|
|
76
73
|
onDeleted,
|
|
@@ -160,6 +157,15 @@ export function SiteStylesDrawer({
|
|
|
160
157
|
aria-label="Site styles actions"
|
|
161
158
|
data-emvb-site-styles-actions=""
|
|
162
159
|
>
|
|
160
|
+
{unpublished && published && (
|
|
161
|
+
<ul className="emvb-helper" data-emvb-style-diff="">
|
|
162
|
+
{designChanges(published, design).map((change) => (
|
|
163
|
+
<li key={`${change.kind}:${change.what}:${change.name}`}>
|
|
164
|
+
{designChangeLabel(change)}
|
|
165
|
+
</li>
|
|
166
|
+
))}
|
|
167
|
+
</ul>
|
|
168
|
+
)}
|
|
163
169
|
{unpublished && (
|
|
164
170
|
<Button type="button" variant="primary" size="sm" onClick={() => void publish()}>
|
|
165
171
|
Publish styles
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
typeScale,
|
|
8
8
|
type DesignSystem,
|
|
9
9
|
} from "../../../core/index.ts";
|
|
10
|
+
import { fieldNumber } from "./settings/number-input.ts";
|
|
10
11
|
|
|
12
|
+
// W-436: the fields are labelled "(px)", so "18px" is 18.
|
|
11
13
|
const num = (text: string): number | undefined => {
|
|
12
|
-
const n =
|
|
13
|
-
return
|
|
14
|
+
const n = fieldNumber(text, "px");
|
|
15
|
+
return Number.isFinite(n) ? n : undefined;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
TextAaIcon,
|
|
10
10
|
TextTIcon,
|
|
11
11
|
TrashIcon,
|
|
12
|
-
WarningCircleIcon,
|
|
13
12
|
type Icon,
|
|
14
13
|
} from "@phosphor-icons/react";
|
|
15
14
|
import * as React from "react";
|
|
@@ -27,6 +26,7 @@ import {
|
|
|
27
26
|
type VariableKind,
|
|
28
27
|
} from "../../../core/index.ts";
|
|
29
28
|
import { FIELD } from "../../ui.ts";
|
|
29
|
+
import { InlineError } from "./inline-error.tsx";
|
|
30
30
|
import {
|
|
31
31
|
CreateRow,
|
|
32
32
|
matches,
|
|
@@ -79,15 +79,6 @@ const MAX_BAR = 64;
|
|
|
79
79
|
|
|
80
80
|
type Item = { id: string; name: string; value: string | Length };
|
|
81
81
|
|
|
82
|
-
function InlineError({ children }: { children: string }) {
|
|
83
|
-
return (
|
|
84
|
-
<p className="emvb-inline-error" role="alert">
|
|
85
|
-
<WarningCircleIcon size={16} aria-hidden="true" />
|
|
86
|
-
{children}
|
|
87
|
-
</p>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
82
|
/** The kind's visual sample in the row: a swatch, "Ag" in the font, "Aa" at the size. */
|
|
92
83
|
function Preview({ kind, value }: { kind: VariableKind; value: string | Length }) {
|
|
93
84
|
if (kind === "color" && typeof value === "string") {
|
|
@@ -30,6 +30,16 @@ export function parseHex(hex: string): Rgba | null {
|
|
|
30
30
|
return { r, g, b, a };
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* W-434: a typed or pasted hex as stored, or undefined. Spaces are trimmed and a missing "#" is
|
|
35
|
+
* added, since design tools (Figma among them) copy "1A2B3C" without it.
|
|
36
|
+
*/
|
|
37
|
+
export function hexInput(text: string): string | undefined {
|
|
38
|
+
const trimmed = text.trim();
|
|
39
|
+
const hex = trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
40
|
+
return HEX.test(hex) ? hex : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
/** 6 digits when opaque, 8 when not. */
|
|
34
44
|
export function toHex({ r, g, b, a }: Rgba): string {
|
|
35
45
|
const hex = [r, g, b].map((n) => channel(n).toString(16).padStart(2, "0")).join("");
|
|
@@ -52,7 +62,8 @@ export function parseRgb(text: string): Rgba | null {
|
|
|
52
62
|
.trim()
|
|
53
63
|
.replace(/^rgba?\(/i, "")
|
|
54
64
|
.replace(/\)$/, "")
|
|
55
|
-
|
|
65
|
+
// W-435: CSS's own "rgb(0 0 0 / 50%)", as DevTools copies it, puts a slash before alpha.
|
|
66
|
+
.split(/[\s,/]+/)
|
|
56
67
|
.filter(Boolean);
|
|
57
68
|
if (parts.length !== 3 && parts.length !== 4) return null;
|
|
58
69
|
const nums = parts.slice(0, 3).map((part) => Number(part));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WarningCircleIcon } from "@phosphor-icons/react";
|
|
2
|
+
|
|
3
|
+
/** A one-line alert under a field. */
|
|
4
|
+
export function InlineError({ children }: { children: string }) {
|
|
5
|
+
return (
|
|
6
|
+
<p className="emvb-inline-error" role="alert">
|
|
7
|
+
<WarningCircleIcon size={16} aria-hidden="true" />
|
|
8
|
+
{children}
|
|
9
|
+
</p>
|
|
10
|
+
);
|
|
11
|
+
}
|