@perkyzz/emvb 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +59 -2
- package/THIRD_PARTY_NOTICES.md +32 -0
- package/licenses/fontawesome-free.LICENSE +165 -0
- package/licenses/lucide-static.LICENSE +43 -0
- package/licenses/remixicon.LICENSE +201 -0
- package/licenses/tabler-icons.LICENSE +21 -0
- package/package.json +76 -4
- package/src/admin/access/RequireEditor.tsx +39 -0
- package/src/admin/access/role.ts +36 -0
- package/src/admin/access/sidebar-shim.ts +108 -0
- package/src/admin/api.ts +75 -0
- package/src/admin/content-api.ts +210 -0
- package/src/admin/editor/Editor.tsx +532 -0
- package/src/admin/editor/EditorOverlay.tsx +66 -0
- package/src/admin/editor/ShortcutsDialog.tsx +30 -0
- package/src/admin/editor/SmallScreenNotice.tsx +21 -0
- package/src/admin/editor/TopBar.tsx +243 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +536 -0
- package/src/admin/editor/canvas/CanvasTextEdit.tsx +87 -0
- package/src/admin/editor/canvas/DeviceBar.tsx +91 -0
- package/src/admin/editor/canvas/EmptyCanvas.tsx +49 -0
- package/src/admin/editor/canvas/SelectionOverlay.tsx +239 -0
- package/src/admin/editor/canvas/canvas-events.ts +245 -0
- package/src/admin/editor/canvas/state-preview.ts +19 -0
- package/src/admin/editor/canvas/tab-reveal.ts +101 -0
- package/src/admin/editor/canvas/vnode-react.tsx +69 -0
- package/src/admin/editor/clipboard-store.ts +44 -0
- package/src/admin/editor/dialogs.tsx +164 -0
- package/src/admin/editor/dnd/drag-stash.ts +27 -0
- package/src/admin/editor/dnd/drop-target.ts +148 -0
- package/src/admin/editor/dnd/new-element.ts +107 -0
- package/src/admin/editor/editor-css.ts +625 -0
- package/src/admin/editor/exit.ts +27 -0
- package/src/admin/editor/host.ts +30 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +850 -0
- package/src/admin/editor/icons/library.ts +243 -0
- package/src/admin/editor/icons/set-format.ts +29 -0
- package/src/admin/editor/icons/sets/fontawesome.json +1 -0
- package/src/admin/editor/icons/sets/lucide.json +1 -0
- package/src/admin/editor/icons/sets/remix.json +1 -0
- package/src/admin/editor/icons/sets/tabler.json +1 -0
- package/src/admin/editor/panels/AddPanel.tsx +146 -0
- package/src/admin/editor/panels/ClassesSection.tsx +372 -0
- package/src/admin/editor/panels/ColorControl.tsx +477 -0
- package/src/admin/editor/panels/ConditionsEditor.tsx +201 -0
- package/src/admin/editor/panels/ElementPanel.tsx +773 -0
- package/src/admin/editor/panels/LayersPanel.tsx +573 -0
- package/src/admin/editor/panels/LeftPanel.tsx +81 -0
- package/src/admin/editor/panels/PageSettings.tsx +255 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +113 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +548 -0
- package/src/admin/editor/panels/TriggerSettings.tsx +132 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +214 -0
- package/src/admin/editor/panels/VariableSection.tsx +530 -0
- package/src/admin/editor/panels/color-space.ts +195 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +119 -0
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +418 -0
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +221 -0
- package/src/admin/editor/panels/settings/BoxControl.tsx +271 -0
- package/src/admin/editor/panels/settings/ChoiceGroup.tsx +138 -0
- package/src/admin/editor/panels/settings/ClassChip.tsx +167 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +451 -0
- package/src/admin/editor/panels/settings/DraftTextField.tsx +242 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +354 -0
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +119 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +270 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +106 -0
- package/src/admin/editor/panels/settings/IconControls.tsx +438 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +170 -0
- package/src/admin/editor/panels/settings/ItemList.tsx +199 -0
- package/src/admin/editor/panels/settings/LengthRow.tsx +217 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +130 -0
- package/src/admin/editor/panels/settings/MediaPicker.tsx +220 -0
- package/src/admin/editor/panels/settings/NumberRow.tsx +154 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +87 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +563 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +171 -0
- package/src/admin/editor/panels/settings/advanced-rules.ts +63 -0
- package/src/admin/editor/panels/settings/background-mode.ts +112 -0
- package/src/admin/editor/panels/settings/box-link-name.ts +38 -0
- package/src/admin/editor/panels/settings/box-sides.ts +153 -0
- package/src/admin/editor/panels/settings/button-url.ts +27 -0
- package/src/admin/editor/panels/settings/class-suggest.ts +53 -0
- package/src/admin/editor/panels/settings/form-names.ts +38 -0
- package/src/admin/editor/panels/settings/heading-warning.ts +25 -0
- package/src/admin/editor/panels/settings/image-alt.ts +25 -0
- package/src/admin/editor/panels/settings/length-units.ts +116 -0
- package/src/admin/editor/panels/settings/loop-context.ts +26 -0
- package/src/admin/editor/panels/settings/node-props.ts +11 -0
- package/src/admin/editor/panels/settings/style-sections.ts +394 -0
- package/src/admin/editor/panels/settings/svg-images.ts +14 -0
- package/src/admin/editor/panels/site-list.tsx +209 -0
- package/src/admin/editor/panels/variable-values.ts +73 -0
- package/src/admin/editor/restore-deleted.ts +80 -0
- package/src/admin/editor/section-templates.ts +50 -0
- package/src/admin/editor/shortcuts.ts +20 -0
- package/src/admin/editor/store.ts +240 -0
- package/src/admin/editor/useClipboardActions.ts +136 -0
- package/src/admin/editor/useEditorCommands.ts +203 -0
- package/src/admin/editor/useEditorData.ts +193 -0
- package/src/admin/editor/useEditorShortcuts.ts +180 -0
- package/src/admin/editor/useMediaQuery.ts +20 -0
- package/src/admin/editor/useNodeActions.ts +184 -0
- package/src/admin/editor/useSave.ts +242 -0
- package/src/admin/entry-status.ts +19 -0
- package/src/admin/forms-api.ts +73 -0
- package/src/admin/icon-uploads-api.ts +44 -0
- package/src/admin/index.tsx +20 -0
- package/src/admin/media-api.ts +68 -0
- package/src/admin/pages/CreateDialog.tsx +150 -0
- package/src/admin/pages/EditorPage.tsx +57 -0
- package/src/admin/pages/NewPageDialog.tsx +83 -0
- package/src/admin/pages/NewThemePartDialog.tsx +61 -0
- package/src/admin/pages/PageList.tsx +91 -0
- package/src/admin/pages/PagesPage.tsx +25 -0
- package/src/admin/pages/SetupShell.tsx +90 -0
- package/src/admin/pages/ThemeBuilderPage.tsx +25 -0
- package/src/admin/pages/ThemePartList.tsx +221 -0
- package/src/admin/pages/list-kit.tsx +125 -0
- package/src/admin/setup/plan.ts +150 -0
- package/src/admin/setup/run.ts +61 -0
- package/src/admin/setup/spec.ts +107 -0
- package/src/admin/setup/useSetupStatus.ts +62 -0
- package/src/admin/theme-api.ts +233 -0
- package/src/admin/ui.ts +244 -0
- package/src/admin/widgets/LayoutField.tsx +67 -0
- package/src/astro/EmVBPage.astro +63 -0
- package/src/astro/env.d.ts +5 -0
- package/src/astro/floats/EmVBFloatsRuntime.astro +9 -0
- package/src/astro/floats/index.ts +1 -0
- package/src/astro/floats/runtime.ts +78 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +9 -0
- package/src/astro/forms/index.ts +1 -0
- package/src/astro/forms-definitions.ts +126 -0
- package/src/astro/index.ts +16 -0
- package/src/astro/menu/EmVBMenuRuntime.astro +9 -0
- package/src/astro/menu/index.ts +1 -0
- package/src/astro/menu/runtime.ts +37 -0
- package/src/astro/popups/EmVBPopupsRuntime.astro +9 -0
- package/src/astro/popups/index.ts +1 -0
- package/src/astro/popups/runtime.ts +296 -0
- package/src/astro/render.ts +108 -0
- package/src/astro/resolve-theme.ts +515 -0
- package/src/astro/resolve.ts +65 -0
- package/src/astro/tabs/EmVBTabsRuntime.astro +10 -0
- package/src/astro/tabs/index.ts +1 -0
- package/src/astro/tabs/runtime.ts +116 -0
- package/src/astro/theme-context.ts +89 -0
- package/src/astro/theme-posts.ts +84 -0
- package/src/constants.ts +12 -0
- package/src/core/arrange.ts +448 -0
- package/src/core/clipboard.ts +504 -0
- package/src/core/css/generate.ts +236 -0
- package/src/core/css/scope.ts +88 -0
- package/src/core/design/cascade.ts +28 -0
- package/src/core/design/classes.ts +224 -0
- package/src/core/design/devices.ts +56 -0
- package/src/core/design/states.ts +49 -0
- package/src/core/design/transfer.ts +132 -0
- package/src/core/design/variables.ts +359 -0
- package/src/core/elements/definition.ts +12 -0
- package/src/core/elements/dynamic-elements.ts +225 -0
- package/src/core/elements/field-id.ts +6 -0
- package/src/core/elements/form-elements.ts +219 -0
- package/src/core/elements/index.ts +960 -0
- package/src/core/elements/menu.ts +190 -0
- package/src/core/elements/plain-text.ts +32 -0
- package/src/core/forms/binding.ts +61 -0
- package/src/core/forms/definition.ts +45 -0
- package/src/core/forms/success-layout.ts +63 -0
- package/src/core/icons/catalog.ts +273 -0
- package/src/core/index.ts +380 -0
- package/src/core/limits.ts +9 -0
- package/src/core/migrate/index.ts +126 -0
- package/src/core/nesting.ts +51 -0
- package/src/core/render/context.ts +21 -0
- package/src/core/render/dynamic-post.ts +175 -0
- package/src/core/render/extras.ts +98 -0
- package/src/core/render/form.ts +235 -0
- package/src/core/render/index.ts +372 -0
- package/src/core/render/loop.ts +43 -0
- package/src/core/render/pagination.ts +76 -0
- package/src/core/render/section.ts +37 -0
- package/src/core/render/tabs.ts +76 -0
- package/src/core/render/vnode.ts +87 -0
- package/src/core/sanitize/css.ts +771 -0
- package/src/core/sanitize/embed-url.ts +160 -0
- package/src/core/sanitize/escape.ts +10 -0
- package/src/core/sanitize/href.ts +6 -0
- package/src/core/sanitize/media-url.ts +7 -0
- package/src/core/sanitize/svg-upload.ts +203 -0
- package/src/core/sanitize/svg.ts +374 -0
- package/src/core/sanitize/url.ts +31 -0
- package/src/core/schema/descriptors.ts +37 -0
- package/src/core/schema/design.ts +93 -0
- package/src/core/schema/layout.ts +1008 -0
- package/src/core/schema/state-names.ts +4 -0
- package/src/core/schema/style.ts +336 -0
- package/src/core/stats.ts +18 -0
- package/src/core/tabs/presence.ts +25 -0
- package/src/core/theme/conditions.ts +324 -0
- package/src/core/theme/dynamic.ts +143 -0
- package/src/core/theme/float.ts +113 -0
- package/src/core/theme/pagination.ts +97 -0
- package/src/core/theme/parse-doc.ts +36 -0
- package/src/core/theme/part-types.ts +81 -0
- package/src/core/theme/popup-markup.ts +41 -0
- package/src/core/theme/popup-rules.ts +62 -0
- package/src/core/theme/triggers.ts +104 -0
- package/src/core/tree-ops.ts +139 -0
- package/src/core/validate.ts +185 -0
- package/src/index.ts +18 -0
- package/src/server/design-routes.ts +125 -0
- package/src/server/hooks.ts +118 -0
- package/src/server/icon-routes.ts +79 -0
- package/src/server/plugin.ts +43 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { MenuItemNode, MenuNode } from "../schema/layout.ts";
|
|
2
|
+
import { sanitizeHref } from "../sanitize/href.ts";
|
|
3
|
+
import type { VNode } from "../render/vnode.ts";
|
|
4
|
+
import type { ElementDefinition } from "./definition.ts";
|
|
5
|
+
|
|
6
|
+
const newTabAttrs = (newTab: boolean | undefined): Record<string, string> =>
|
|
7
|
+
newTab ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
8
|
+
|
|
9
|
+
/** Names the item's own disclosure. Nested panels already carry their parent item's name. */
|
|
10
|
+
function stampGroup(children: VNode["children"], name: string): VNode["children"] {
|
|
11
|
+
return children.map((child) => {
|
|
12
|
+
if (typeof child === "string" || child.tag !== "li") return child;
|
|
13
|
+
return {
|
|
14
|
+
...child,
|
|
15
|
+
children: child.children.map((bar) => {
|
|
16
|
+
if (typeof bar === "string" || bar.tag !== "div") return bar;
|
|
17
|
+
return {
|
|
18
|
+
...bar,
|
|
19
|
+
children: bar.children.map((inner) => {
|
|
20
|
+
if (typeof inner === "string" || inner.tag !== "details") return inner;
|
|
21
|
+
return { ...inner, attrs: { ...inner.attrs, name } };
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Runs of menu items become a list. Other elements stay in the panel beside that list. */
|
|
30
|
+
function groupItems(children: VNode["children"]): VNode["children"] {
|
|
31
|
+
const out: VNode["children"] = [];
|
|
32
|
+
let batch: VNode[] = [];
|
|
33
|
+
const flush = () => {
|
|
34
|
+
if (batch.length === 0) return;
|
|
35
|
+
out.push({
|
|
36
|
+
tag: "ul",
|
|
37
|
+
attrs: { class: "emvb-menu__list emvb-menu__list--sub" },
|
|
38
|
+
children: batch,
|
|
39
|
+
});
|
|
40
|
+
batch = [];
|
|
41
|
+
};
|
|
42
|
+
for (const child of children) {
|
|
43
|
+
if (typeof child !== "string" && child.tag === "li") batch.push(child);
|
|
44
|
+
else {
|
|
45
|
+
flush();
|
|
46
|
+
out.push(child);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
flush();
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const MENU_CSS = [
|
|
54
|
+
// The list inherits the menu's flex styles, so Layout's direction, alignment and gap move the items.
|
|
55
|
+
".emvb-menu{position:relative;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:.25rem 1.25rem}",
|
|
56
|
+
".emvb-menu>.emvb-menu__list{display:flex;flex:1 1 auto;flex-direction:inherit;flex-wrap:inherit;align-items:inherit;justify-content:inherit;gap:inherit;min-width:0;margin:0;padding:0;list-style:none}",
|
|
57
|
+
".emvb-menu--column{flex-direction:column;align-items:stretch;gap:.15rem}",
|
|
58
|
+
".emvb-menu__list--sub{display:flex;flex-direction:column;align-items:stretch;gap:.15rem;margin:0;padding:0;list-style:none}",
|
|
59
|
+
".emvb-menu-item{position:relative}",
|
|
60
|
+
".emvb-menu-item--wide{position:static}",
|
|
61
|
+
".emvb-menu-item__bar{display:flex;align-items:center;gap:.15rem}",
|
|
62
|
+
".emvb-menu-item__link,.emvb-menu-item__label{color:inherit;text-decoration:none}",
|
|
63
|
+
".emvb-menu-item__toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;cursor:pointer;list-style:none}",
|
|
64
|
+
".emvb-menu-item__toggle::-webkit-details-marker{display:none}",
|
|
65
|
+
".emvb-menu-item__toggle::before{content:'';width:.4rem;height:.4rem;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg) translateY(-1px)}",
|
|
66
|
+
".emvb-menu-panel{display:none;position:absolute;z-index:30;top:100%;inset-inline-start:0;min-width:12rem;padding:.75rem;background:canvas;color:canvastext;border:1px solid #00000014;box-shadow:0 12px 32px #00000029}",
|
|
67
|
+
".emvb-menu-item__disclosure[open]>.emvb-menu-panel{display:block}",
|
|
68
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel,.emvb-menu-item:focus-within>.emvb-menu-item__bar>.emvb-menu-item__disclosure>.emvb-menu-panel{display:block}}",
|
|
69
|
+
// W-267: a closed <details> hides its content (::details-content is content-visibility:hidden),
|
|
70
|
+
// so the hover rule above showed nothing until the details' content is made visible too. Its own
|
|
71
|
+
// rule: a browser without ::details-content drops only this one. Hover only: keyboard users open
|
|
72
|
+
// a dropdown with its toggle, and Tab doesn't walk through every closed dropdown's links.
|
|
73
|
+
"@media (hover:hover) and (pointer:fine){.emvb-menu-item:hover>.emvb-menu-item__bar>.emvb-menu-item__disclosure::details-content{content-visibility:visible}}",
|
|
74
|
+
".emvb-menu-panel--wide{inset-inline:0;min-width:0}",
|
|
75
|
+
".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
|
|
76
|
+
".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
|
|
77
|
+
].join("");
|
|
78
|
+
|
|
79
|
+
export const menu: ElementDefinition<MenuNode> = {
|
|
80
|
+
baseCss: MENU_CSS,
|
|
81
|
+
defaults: () => ({ type: "menu", props: { direction: "row" }, children: [] }),
|
|
82
|
+
descriptor: {
|
|
83
|
+
type: "menu",
|
|
84
|
+
name: "Menu",
|
|
85
|
+
group: "content",
|
|
86
|
+
defaultTab: "content",
|
|
87
|
+
fields: [
|
|
88
|
+
{
|
|
89
|
+
key: "label",
|
|
90
|
+
kind: "text",
|
|
91
|
+
label: "Name",
|
|
92
|
+
optional: true,
|
|
93
|
+
message: "Names the menu for assistive technology. Leave it blank to use Menu.",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: "direction",
|
|
97
|
+
kind: "select",
|
|
98
|
+
label: "Direction",
|
|
99
|
+
options: [
|
|
100
|
+
{ value: "row", label: "Horizontal" },
|
|
101
|
+
{ value: "column", label: "Vertical" },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
build: (node, attrs, children) => {
|
|
107
|
+
const column = node.props.direction === "column";
|
|
108
|
+
const classes = [attrs.class, column ? "emvb-menu--column" : ""].filter(Boolean).join(" ");
|
|
109
|
+
// W-198: a Menu with nothing in it is no navigation landmark; a plain box keeps its styles.
|
|
110
|
+
if (children.length === 0) {
|
|
111
|
+
return {
|
|
112
|
+
tag: "div",
|
|
113
|
+
attrs: { ...attrs, class: classes, "data-emvb-menu-empty": "" },
|
|
114
|
+
children: [],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const label = node.props.label?.trim() || "Menu";
|
|
118
|
+
return {
|
|
119
|
+
tag: "nav",
|
|
120
|
+
attrs: { ...attrs, class: classes, "aria-label": label },
|
|
121
|
+
children: [
|
|
122
|
+
{
|
|
123
|
+
tag: "ul",
|
|
124
|
+
attrs: { class: "emvb-menu__list" },
|
|
125
|
+
children: stampGroup(children, `emvb-menu-${node.id}`),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const menuItem: ElementDefinition<MenuItemNode> = {
|
|
133
|
+
baseCss: "",
|
|
134
|
+
defaults: () => ({ type: "menu-item", props: { text: "Item", href: "/" }, children: [] }),
|
|
135
|
+
descriptor: {
|
|
136
|
+
type: "menu-item",
|
|
137
|
+
name: "Menu item",
|
|
138
|
+
group: "content",
|
|
139
|
+
defaultTab: "content",
|
|
140
|
+
fields: [
|
|
141
|
+
{ key: "text", kind: "text", label: "Label" },
|
|
142
|
+
{
|
|
143
|
+
key: "href",
|
|
144
|
+
kind: "href",
|
|
145
|
+
label: "Link",
|
|
146
|
+
optional: true,
|
|
147
|
+
message: "Use a full URL such as https://example.com or a path such as /pricing.",
|
|
148
|
+
},
|
|
149
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true },
|
|
150
|
+
{ key: "wide", kind: "boolean", label: "Wide panel", optional: true },
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
build: (node, attrs, children) => {
|
|
154
|
+
const wide = node.props.wide === true;
|
|
155
|
+
const classes = [attrs.class, wide ? "emvb-menu-item--wide" : ""].filter(Boolean).join(" ");
|
|
156
|
+
const href = node.props.href?.trim() ? sanitizeHref(node.props.href) : undefined;
|
|
157
|
+
const label: VNode = href
|
|
158
|
+
? {
|
|
159
|
+
tag: "a",
|
|
160
|
+
attrs: { class: "emvb-menu-item__link", href, ...newTabAttrs(node.props.newTab) },
|
|
161
|
+
children: [node.props.text],
|
|
162
|
+
}
|
|
163
|
+
: { tag: "span", attrs: { class: "emvb-menu-item__label" }, children: [node.props.text] };
|
|
164
|
+
const bar: VNode["children"] = [label];
|
|
165
|
+
if (children.length > 0) {
|
|
166
|
+
const panelClass = wide ? "emvb-menu-panel emvb-menu-panel--wide" : "emvb-menu-panel";
|
|
167
|
+
bar.push({
|
|
168
|
+
tag: "details",
|
|
169
|
+
attrs: { class: "emvb-menu-item__disclosure" },
|
|
170
|
+
children: [
|
|
171
|
+
{
|
|
172
|
+
tag: "summary",
|
|
173
|
+
attrs: { class: "emvb-menu-item__toggle", "aria-label": `Open ${node.props.text}` },
|
|
174
|
+
children: [],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
tag: "div",
|
|
178
|
+
attrs: { class: panelClass },
|
|
179
|
+
children: groupItems(stampGroup(children, `emvb-menu-${node.id}`)),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
tag: "li",
|
|
186
|
+
attrs: { ...attrs, class: classes },
|
|
187
|
+
children: [{ tag: "div", attrs: { class: "emvb-menu-item__bar" }, children: bar }],
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MAX_TEXT_LENGTH } from "../limits.ts";
|
|
2
|
+
import type { LayoutNode } from "../schema/layout.ts";
|
|
3
|
+
|
|
4
|
+
/** Elements whose visible words are one `props.text` string (W-097). */
|
|
5
|
+
const PLAIN_TEXT = ["heading", "text", "label", "link", "button"] as const;
|
|
6
|
+
|
|
7
|
+
export function isPlainTextNode(node: LayoutNode): boolean {
|
|
8
|
+
return (PLAIN_TEXT as readonly string[]).includes(node.type);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The stored string, or null when this element is not edited on the canvas. */
|
|
12
|
+
export function plainTextOf(node: LayoutNode): string | null {
|
|
13
|
+
if (!isPlainTextNode(node)) return null;
|
|
14
|
+
const text = "text" in node.props ? node.props.text : undefined;
|
|
15
|
+
return typeof text === "string" ? text : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Paragraphs keep line breaks. Headings, labels, links and buttons stay one line. */
|
|
19
|
+
export function isMultilineText(node: LayoutNode): boolean {
|
|
20
|
+
return node.type === "text";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The string a canvas edit may store. Over-long text is cut to the schema limit. */
|
|
24
|
+
export function commitPlainText(text: string, multiline: boolean): string {
|
|
25
|
+
const flat = multiline ? text : text.replaceAll("\n", "");
|
|
26
|
+
return flat.slice(0, MAX_TEXT_LENGTH);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function withPlainText(node: LayoutNode, text: string): LayoutNode {
|
|
30
|
+
if (!isPlainTextNode(node) || !("text" in node.props)) return node;
|
|
31
|
+
return { ...node, props: { ...node.props, text } };
|
|
32
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isFormNode, type Layout, type LayoutNode } from "../schema/layout.ts";
|
|
2
|
+
import { nodeChildren } from "../tree-ops.ts";
|
|
3
|
+
import { fieldsOf, type FormDefinitions } from "./definition.ts";
|
|
4
|
+
|
|
5
|
+
export type MissingRequiredField = {
|
|
6
|
+
formNodeId: string;
|
|
7
|
+
formId: string;
|
|
8
|
+
field: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function walk(node: LayoutNode, visit: (node: LayoutNode) => void): void {
|
|
12
|
+
visit(node);
|
|
13
|
+
for (const child of nodeChildren(node)) walk(child, visit);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function boundFields(form: LayoutNode): Set<string> {
|
|
17
|
+
const names = new Set<string>();
|
|
18
|
+
walk(form, (node) => {
|
|
19
|
+
if (
|
|
20
|
+
node.type === "text-input" ||
|
|
21
|
+
node.type === "textarea" ||
|
|
22
|
+
node.type === "select" ||
|
|
23
|
+
node.type === "checkbox" ||
|
|
24
|
+
node.type === "radio"
|
|
25
|
+
) {
|
|
26
|
+
const field = (node.props as { field?: string }).field;
|
|
27
|
+
if (field) names.add(field);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return names;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Required fields on the forms-plugin definition that have no EmVB input bound (R-040).
|
|
35
|
+
*/
|
|
36
|
+
export function findMissingRequiredFields(
|
|
37
|
+
layout: Layout,
|
|
38
|
+
definitions: FormDefinitions,
|
|
39
|
+
): MissingRequiredField[] {
|
|
40
|
+
const missing: MissingRequiredField[] = [];
|
|
41
|
+
walk(layout.root, (node) => {
|
|
42
|
+
if (!isFormNode(node) || !node.props.formId) return;
|
|
43
|
+
const definition = definitions.get(node.props.formId);
|
|
44
|
+
if (!definition) return;
|
|
45
|
+
const bound = boundFields(node);
|
|
46
|
+
for (const field of fieldsOf(definition)) {
|
|
47
|
+
if (field.required && !bound.has(field.name)) {
|
|
48
|
+
missing.push({ formNodeId: node.id, formId: node.props.formId, field: field.name });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return missing;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function layoutHasForm(layout: Layout): boolean {
|
|
56
|
+
let found = false;
|
|
57
|
+
walk(layout.root, (node) => {
|
|
58
|
+
if (isFormNode(node) && node.props.formId.trim()) found = true;
|
|
59
|
+
});
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Minimal public form definition (forms-plugin `definition` route). */
|
|
2
|
+
export type PublicFormField = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
label: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
options?: ReadonlyArray<{ label: string; value: string }>;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Constraints the forms plugin's own embed puts on the control (W-297). */
|
|
10
|
+
validation?: PublicFieldValidation;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** The constraint subset the renderer can apply; anything else is ignored. */
|
|
14
|
+
export type PublicFieldValidation = {
|
|
15
|
+
minLength?: number;
|
|
16
|
+
maxLength?: number;
|
|
17
|
+
min?: number;
|
|
18
|
+
max?: number;
|
|
19
|
+
pattern?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type PublicFormDefinition = {
|
|
23
|
+
name: string;
|
|
24
|
+
slug: string;
|
|
25
|
+
status: string;
|
|
26
|
+
pages: ReadonlyArray<{ fields: ReadonlyArray<PublicFormField> }>;
|
|
27
|
+
settings: {
|
|
28
|
+
spamProtection?: string;
|
|
29
|
+
submitLabel?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type FormDefinitions = ReadonlyMap<string, PublicFormDefinition>;
|
|
34
|
+
|
|
35
|
+
export function fieldsOf(definition: PublicFormDefinition): PublicFormField[] {
|
|
36
|
+
return definition.pages.flatMap((page) => [...page.fields]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function fieldByName(
|
|
40
|
+
definition: PublicFormDefinition | undefined,
|
|
41
|
+
name: string,
|
|
42
|
+
): PublicFormField | undefined {
|
|
43
|
+
if (!definition) return undefined;
|
|
44
|
+
return fieldsOf(definition).find((field) => field.name === name);
|
|
45
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LAYOUT_SCHEMA_VERSION, type Layout } from "../schema/layout.ts";
|
|
2
|
+
|
|
3
|
+
/** Fixture layout for the BRIEF success signal (W-039): container + heading/text/image/button + form. */
|
|
4
|
+
export function successSignalLayout(opts: {
|
|
5
|
+
formId: string;
|
|
6
|
+
colorVar: string;
|
|
7
|
+
classId: string;
|
|
8
|
+
imageSrc: string;
|
|
9
|
+
heading: string;
|
|
10
|
+
}): Layout {
|
|
11
|
+
return {
|
|
12
|
+
schemaVersion: LAYOUT_SCHEMA_VERSION,
|
|
13
|
+
root: {
|
|
14
|
+
id: "root0001",
|
|
15
|
+
type: "container",
|
|
16
|
+
props: {},
|
|
17
|
+
style: { flexDirection: "column", gap: { value: 16, unit: "px" } },
|
|
18
|
+
children: [
|
|
19
|
+
{
|
|
20
|
+
id: "head0001",
|
|
21
|
+
type: "heading",
|
|
22
|
+
props: { text: opts.heading, level: 1 },
|
|
23
|
+
style: { color: { var: opts.colorVar } },
|
|
24
|
+
classes: [opts.classId],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "text0001",
|
|
28
|
+
type: "text",
|
|
29
|
+
props: { text: "Welcome to the EmVB success page." },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "img00001",
|
|
33
|
+
type: "image",
|
|
34
|
+
props: {
|
|
35
|
+
src: opts.imageSrc,
|
|
36
|
+
alt: "Hero",
|
|
37
|
+
decorative: false,
|
|
38
|
+
width: 1,
|
|
39
|
+
height: 1,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "btn00001",
|
|
44
|
+
type: "button",
|
|
45
|
+
props: { text: "Learn more", href: "/about" },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "form0001",
|
|
49
|
+
type: "form",
|
|
50
|
+
props: { formId: opts.formId },
|
|
51
|
+
children: [
|
|
52
|
+
{
|
|
53
|
+
id: "inp00001",
|
|
54
|
+
type: "text-input",
|
|
55
|
+
props: { field: "email", label: "Email", placeholder: "you@example.com" },
|
|
56
|
+
},
|
|
57
|
+
{ id: "sub00001", type: "submit", props: { label: "Send" } },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/** Bundled Lucide icons as path geometry (A-04 / W-025). No remote fetch. */
|
|
2
|
+
|
|
3
|
+
export type IconPrimitive = {
|
|
4
|
+
tag: "path" | "circle" | "line" | "polyline" | "polygon" | "rect";
|
|
5
|
+
attrs: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type BundledIcon = {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** Inner SVG primitives only — the renderer wraps them in a fixed <svg>. */
|
|
12
|
+
children: readonly IconPrimitive[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const BUNDLED_ICONS: readonly BundledIcon[] = [
|
|
16
|
+
{
|
|
17
|
+
id: "arrow-left",
|
|
18
|
+
label: "Arrow Left",
|
|
19
|
+
children: [
|
|
20
|
+
{ tag: "path", attrs: { d: "m12 19-7-7 7-7" } },
|
|
21
|
+
{ tag: "path", attrs: { d: "M19 12H5" } },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "arrow-right",
|
|
26
|
+
label: "Arrow Right",
|
|
27
|
+
children: [
|
|
28
|
+
{ tag: "path", attrs: { d: "M5 12h14" } },
|
|
29
|
+
{ tag: "path", attrs: { d: "m12 5 7 7-7 7" } },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "calendar",
|
|
34
|
+
label: "Calendar",
|
|
35
|
+
children: [
|
|
36
|
+
{ tag: "path", attrs: { d: "M8 2v3" } },
|
|
37
|
+
{ tag: "path", attrs: { d: "M16 2v3" } },
|
|
38
|
+
{ tag: "rect", attrs: { x: "3", y: "3", width: "18", height: "18", rx: "2" } },
|
|
39
|
+
{ tag: "path", attrs: { d: "M3 9h18" } },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "camera",
|
|
44
|
+
label: "Camera",
|
|
45
|
+
children: [
|
|
46
|
+
{
|
|
47
|
+
tag: "path",
|
|
48
|
+
attrs: {
|
|
49
|
+
d: "M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{ tag: "circle", attrs: { cx: "12", cy: "13", r: "3" } },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "check",
|
|
57
|
+
label: "Check",
|
|
58
|
+
children: [{ tag: "path", attrs: { d: "M20 6 9 17l-5-5" } }],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "circle-alert",
|
|
62
|
+
label: "Circle Alert",
|
|
63
|
+
children: [
|
|
64
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
65
|
+
{ tag: "line", attrs: {} },
|
|
66
|
+
{ tag: "line", attrs: {} },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "circle-check",
|
|
71
|
+
label: "Circle Check",
|
|
72
|
+
children: [
|
|
73
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
74
|
+
{ tag: "path", attrs: { d: "m16 9-5.5 5.5L8 12" } },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "clock",
|
|
79
|
+
label: "Clock",
|
|
80
|
+
children: [
|
|
81
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
82
|
+
{ tag: "path", attrs: { d: "M12 6v6l4 2" } },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "download",
|
|
87
|
+
label: "Download",
|
|
88
|
+
children: [
|
|
89
|
+
{ tag: "path", attrs: { d: "M12 15V3" } },
|
|
90
|
+
{ tag: "path", attrs: { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" } },
|
|
91
|
+
{ tag: "path", attrs: { d: "m7 10 5 5 5-5" } },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "external-link",
|
|
96
|
+
label: "External Link",
|
|
97
|
+
children: [
|
|
98
|
+
{ tag: "path", attrs: { d: "M15 3h6v6" } },
|
|
99
|
+
{ tag: "path", attrs: { d: "M10 14 21 3" } },
|
|
100
|
+
{ tag: "path", attrs: { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" } },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "globe",
|
|
105
|
+
label: "Globe",
|
|
106
|
+
children: [
|
|
107
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
108
|
+
{ tag: "path", attrs: { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" } },
|
|
109
|
+
{ tag: "path", attrs: { d: "M2 12h20" } },
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "heart",
|
|
114
|
+
label: "Heart",
|
|
115
|
+
children: [
|
|
116
|
+
{
|
|
117
|
+
tag: "path",
|
|
118
|
+
attrs: {
|
|
119
|
+
d: "M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "house",
|
|
126
|
+
label: "House",
|
|
127
|
+
children: [
|
|
128
|
+
{ tag: "path", attrs: { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" } },
|
|
129
|
+
{
|
|
130
|
+
tag: "path",
|
|
131
|
+
attrs: {
|
|
132
|
+
d: "M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "info",
|
|
139
|
+
label: "Info",
|
|
140
|
+
children: [
|
|
141
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "10" } },
|
|
142
|
+
{ tag: "path", attrs: { d: "M12 16v-4" } },
|
|
143
|
+
{ tag: "path", attrs: { d: "M12 8h.01" } },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "mail",
|
|
148
|
+
label: "Mail",
|
|
149
|
+
children: [
|
|
150
|
+
{ tag: "path", attrs: { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" } },
|
|
151
|
+
{ tag: "rect", attrs: { x: "2", y: "4", width: "20", height: "16", rx: "2" } },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "menu",
|
|
156
|
+
label: "Menu",
|
|
157
|
+
children: [
|
|
158
|
+
{ tag: "path", attrs: { d: "M4 5h16" } },
|
|
159
|
+
{ tag: "path", attrs: { d: "M4 12h16" } },
|
|
160
|
+
{ tag: "path", attrs: { d: "M4 19h16" } },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "minus",
|
|
165
|
+
label: "Minus",
|
|
166
|
+
children: [{ tag: "path", attrs: { d: "M5 12h14" } }],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: "phone",
|
|
170
|
+
label: "Phone",
|
|
171
|
+
children: [
|
|
172
|
+
{
|
|
173
|
+
tag: "path",
|
|
174
|
+
attrs: {
|
|
175
|
+
d: "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "play",
|
|
182
|
+
label: "Play",
|
|
183
|
+
children: [
|
|
184
|
+
{
|
|
185
|
+
tag: "path",
|
|
186
|
+
attrs: {
|
|
187
|
+
d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "plus",
|
|
194
|
+
label: "Plus",
|
|
195
|
+
children: [
|
|
196
|
+
{ tag: "path", attrs: { d: "M5 12h14" } },
|
|
197
|
+
{ tag: "path", attrs: { d: "M12 5v14" } },
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "search",
|
|
202
|
+
label: "Search",
|
|
203
|
+
children: [
|
|
204
|
+
{ tag: "path", attrs: { d: "m21 21-4.34-4.34" } },
|
|
205
|
+
{ tag: "circle", attrs: { cx: "11", cy: "11", r: "8" } },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: "settings",
|
|
210
|
+
label: "Settings",
|
|
211
|
+
children: [
|
|
212
|
+
{
|
|
213
|
+
tag: "path",
|
|
214
|
+
attrs: {
|
|
215
|
+
d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{ tag: "circle", attrs: { cx: "12", cy: "12", r: "3" } },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: "shopping-cart",
|
|
223
|
+
label: "Shopping Cart",
|
|
224
|
+
children: [
|
|
225
|
+
{
|
|
226
|
+
tag: "path",
|
|
227
|
+
attrs: { d: "m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18" },
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
tag: "path",
|
|
231
|
+
attrs: { d: "M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25" },
|
|
232
|
+
},
|
|
233
|
+
{ tag: "circle", attrs: { cx: "18", cy: "20", r: "2" } },
|
|
234
|
+
{ tag: "circle", attrs: { cx: "8", cy: "20", r: "2" } },
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "star",
|
|
239
|
+
label: "Star",
|
|
240
|
+
children: [
|
|
241
|
+
{
|
|
242
|
+
tag: "path",
|
|
243
|
+
attrs: {
|
|
244
|
+
d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "user",
|
|
251
|
+
label: "User",
|
|
252
|
+
children: [
|
|
253
|
+
{ tag: "path", attrs: { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" } },
|
|
254
|
+
{ tag: "circle", attrs: { cx: "12", cy: "7", r: "4" } },
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "x",
|
|
259
|
+
label: "X",
|
|
260
|
+
children: [
|
|
261
|
+
{ tag: "path", attrs: { d: "M18 6 6 18" } },
|
|
262
|
+
{ tag: "path", attrs: { d: "m6 6 12 12" } },
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
export const BUNDLED_ICON_IDS = BUNDLED_ICONS.map((icon) => icon.id);
|
|
268
|
+
|
|
269
|
+
const byId = new Map(BUNDLED_ICONS.map((icon) => [icon.id, icon]));
|
|
270
|
+
|
|
271
|
+
export function getBundledIcon(id: string): BundledIcon | undefined {
|
|
272
|
+
return byId.get(id);
|
|
273
|
+
}
|