@wireweave/core 3.1.0-beta.2 → 3.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +77 -35
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +76 -35
- package/dist/renderer.cjs +69 -34
- package/dist/renderer.d.cts +32 -2
- package/dist/renderer.d.ts +32 -2
- package/dist/renderer.js +68 -34
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
VALID_ATTRIBUTE_NAMES: () => VALID_ATTRIBUTE_NAMES,
|
|
35
35
|
VALID_COMPONENT_NAMES: () => VALID_COMPONENT_NAMES,
|
|
36
36
|
analyze: () => analyze,
|
|
37
|
+
anchorIntent: () => anchorIntent,
|
|
37
38
|
areIdentical: () => areIdentical,
|
|
38
39
|
buildAnchorIndex: () => buildAnchorIndex,
|
|
39
40
|
buildDomTree: () => buildDomTree,
|
|
@@ -10110,8 +10111,8 @@ function renderCard(node, ctx) {
|
|
|
10110
10111
|
]);
|
|
10111
10112
|
const styles = ctx.buildCommonStyles(node);
|
|
10112
10113
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
10113
|
-
const
|
|
10114
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
10114
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
10115
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
10115
10116
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
10116
10117
|
` : "";
|
|
10117
10118
|
const children = ctx.renderChildren(node.children);
|
|
@@ -10164,6 +10165,45 @@ ${children}
|
|
|
10164
10165
|
</div>`;
|
|
10165
10166
|
}
|
|
10166
10167
|
|
|
10168
|
+
// src/interaction/target.ts
|
|
10169
|
+
function isUrlTarget(target) {
|
|
10170
|
+
if (target === void 0) return false;
|
|
10171
|
+
const value = target.trim();
|
|
10172
|
+
if (value.length === 0 || /\s/.test(value)) return false;
|
|
10173
|
+
if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
|
|
10174
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
10175
|
+
}
|
|
10176
|
+
|
|
10177
|
+
// src/renderer/html/interactive.ts
|
|
10178
|
+
var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
10179
|
+
function interactiveAttrs(node) {
|
|
10180
|
+
return {
|
|
10181
|
+
"data-navigate": node.navigate,
|
|
10182
|
+
[EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
|
|
10183
|
+
"data-opens": node.opens,
|
|
10184
|
+
"data-toggles": node.toggles,
|
|
10185
|
+
"data-action": node.action
|
|
10186
|
+
};
|
|
10187
|
+
}
|
|
10188
|
+
function anchorIntent(node) {
|
|
10189
|
+
const attrs2 = interactiveAttrs(node);
|
|
10190
|
+
if (node.href) return { href: node.href, attrs: attrs2 };
|
|
10191
|
+
if (isUrlTarget(node.navigate)) {
|
|
10192
|
+
return {
|
|
10193
|
+
href: node.navigate.trim(),
|
|
10194
|
+
attrs: {
|
|
10195
|
+
...attrs2,
|
|
10196
|
+
"data-navigate": void 0,
|
|
10197
|
+
[EXTERNAL_NAVIGATE_ATTR]: void 0
|
|
10198
|
+
}
|
|
10199
|
+
};
|
|
10200
|
+
}
|
|
10201
|
+
return { href: "#", attrs: attrs2 };
|
|
10202
|
+
}
|
|
10203
|
+
function nonAnchorIntent(node) {
|
|
10204
|
+
return interactiveAttrs(node);
|
|
10205
|
+
}
|
|
10206
|
+
|
|
10167
10207
|
// src/renderer/html/renderers/text.ts
|
|
10168
10208
|
function isValueWithUnit3(value) {
|
|
10169
10209
|
return typeof value === "object" && value !== null && "value" in value && "unit" in value;
|
|
@@ -10226,14 +10266,11 @@ function renderLink(node, ctx) {
|
|
|
10226
10266
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
10227
10267
|
const styles = ctx.buildCommonStyles(node);
|
|
10228
10268
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
10269
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
10229
10270
|
const attrs2 = {
|
|
10230
10271
|
class: classes,
|
|
10231
|
-
href
|
|
10232
|
-
|
|
10233
|
-
"data-navigate": node.navigate,
|
|
10234
|
-
"data-opens": node.opens,
|
|
10235
|
-
"data-toggles": node.toggles,
|
|
10236
|
-
"data-action": node.action
|
|
10272
|
+
href,
|
|
10273
|
+
...intentAttrs
|
|
10237
10274
|
};
|
|
10238
10275
|
if (node.external) {
|
|
10239
10276
|
attrs2.target = "_blank";
|
|
@@ -56955,8 +56992,8 @@ function renderImage(node, ctx) {
|
|
|
56955
56992
|
}
|
|
56956
56993
|
const label = node.alt || "Image";
|
|
56957
56994
|
const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
56958
|
-
const
|
|
56959
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
56995
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
56996
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
56960
56997
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
56961
56998
|
}
|
|
56962
56999
|
function renderPlaceholder(node, ctx) {
|
|
@@ -56999,13 +57036,13 @@ function renderAvatar(node, ctx) {
|
|
|
56999
57036
|
content = "?";
|
|
57000
57037
|
}
|
|
57001
57038
|
}
|
|
57002
|
-
const
|
|
57003
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
57039
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
57040
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
57004
57041
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
57005
57042
|
}
|
|
57006
57043
|
function renderBadge(node, ctx) {
|
|
57007
|
-
const
|
|
57008
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
57044
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
57045
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
57009
57046
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
57010
57047
|
if (node.icon) {
|
|
57011
57048
|
const iconData = getIconData(node.icon);
|
|
@@ -57044,8 +57081,8 @@ function renderBadge(node, ctx) {
|
|
|
57044
57081
|
}
|
|
57045
57082
|
function renderIcon(node, ctx) {
|
|
57046
57083
|
const iconData = getIconData(node.name);
|
|
57047
|
-
const
|
|
57048
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
57084
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
57085
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
57049
57086
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
57050
57087
|
const wrapperClasses = ctx.buildClassString([
|
|
57051
57088
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -57112,18 +57149,13 @@ function renderDropdown(node, ctx) {
|
|
|
57112
57149
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
57113
57150
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
57114
57151
|
]);
|
|
57115
|
-
const interactiveAttrs = {
|
|
57116
|
-
"data-navigate": dropdownItem.navigate,
|
|
57117
|
-
"data-opens": dropdownItem.opens,
|
|
57118
|
-
"data-toggles": dropdownItem.toggles,
|
|
57119
|
-
"data-action": dropdownItem.action
|
|
57120
|
-
};
|
|
57121
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
57122
57152
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
57123
57153
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
57124
|
-
const href
|
|
57125
|
-
|
|
57154
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
57155
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
57156
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
57126
57157
|
}
|
|
57158
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
57127
57159
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
57128
57160
|
}).join("\n");
|
|
57129
57161
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -57142,7 +57174,9 @@ function renderNavItem(item, ctx) {
|
|
|
57142
57174
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
57143
57175
|
]);
|
|
57144
57176
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
57145
|
-
|
|
57177
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
57178
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
57179
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
57146
57180
|
}
|
|
57147
57181
|
function renderNavChildren(children, ctx) {
|
|
57148
57182
|
return children.map((child) => {
|
|
@@ -57185,13 +57219,7 @@ ${content}
|
|
|
57185
57219
|
if (typeof item === "string") {
|
|
57186
57220
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
57187
57221
|
}
|
|
57188
|
-
|
|
57189
|
-
`${ctx.prefix}-nav-link`,
|
|
57190
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
57191
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
57192
|
-
]);
|
|
57193
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
57194
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
57222
|
+
return renderNavItem(item, ctx);
|
|
57195
57223
|
}).join("\n");
|
|
57196
57224
|
return `<nav class="${classes}"${styleAttr}>
|
|
57197
57225
|
${items}
|
|
@@ -57222,7 +57250,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
57222
57250
|
if (typeof item === "string") {
|
|
57223
57251
|
return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
57224
57252
|
}
|
|
57225
|
-
|
|
57253
|
+
if (isLast) {
|
|
57254
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
57255
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
57256
|
+
}
|
|
57257
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
57258
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
57259
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
57226
57260
|
}).join(separator);
|
|
57227
57261
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
57228
57262
|
}
|
|
@@ -60929,6 +60963,11 @@ function resolveEdge(from, kind, target, trigger, titleToIndex, overlayIds, page
|
|
|
60929
60963
|
edge.resolved = true;
|
|
60930
60964
|
return { edge, isDangling: false };
|
|
60931
60965
|
}
|
|
60966
|
+
if (isUrlTarget(target)) {
|
|
60967
|
+
edge.external = true;
|
|
60968
|
+
edge.resolved = true;
|
|
60969
|
+
return { edge, isDangling: false };
|
|
60970
|
+
}
|
|
60932
60971
|
return { edge, isDangling: true };
|
|
60933
60972
|
}
|
|
60934
60973
|
if (kind === "opens" || kind === "toggles") {
|
|
@@ -60953,6 +60992,7 @@ function extractScreenTransitions(doc) {
|
|
|
60953
60992
|
});
|
|
60954
60993
|
const edges = [];
|
|
60955
60994
|
const dangling = [];
|
|
60995
|
+
const external = [];
|
|
60956
60996
|
pages.forEach((page, pageIndex) => {
|
|
60957
60997
|
const overlayIds = collectOverlayIds(page);
|
|
60958
60998
|
const from = fromDescriptor(pageIndex, page);
|
|
@@ -60968,6 +61008,7 @@ function extractScreenTransitions(doc) {
|
|
|
60968
61008
|
);
|
|
60969
61009
|
edges.push(edge);
|
|
60970
61010
|
if (isDangling) dangling.push(edge);
|
|
61011
|
+
if (edge.external) external.push(edge);
|
|
60971
61012
|
};
|
|
60972
61013
|
for (const child of page.children) {
|
|
60973
61014
|
walk(child, (node) => {
|
|
@@ -60991,7 +61032,7 @@ function extractScreenTransitions(doc) {
|
|
|
60991
61032
|
});
|
|
60992
61033
|
}
|
|
60993
61034
|
});
|
|
60994
|
-
return { screens, edges, dangling };
|
|
61035
|
+
return { screens, edges, dangling, external };
|
|
60995
61036
|
}
|
|
60996
61037
|
function fromDescriptor(pageIndex, page) {
|
|
60997
61038
|
return page.title != null ? { pageIndex, title: page.title } : { pageIndex };
|
|
@@ -61062,6 +61103,7 @@ function buildDomTreeNode(node, path) {
|
|
|
61062
61103
|
VALID_ATTRIBUTE_NAMES,
|
|
61063
61104
|
VALID_COMPONENT_NAMES,
|
|
61064
61105
|
analyze,
|
|
61106
|
+
anchorIntent,
|
|
61065
61107
|
areIdentical,
|
|
61066
61108
|
buildAnchorIndex,
|
|
61067
61109
|
buildDomTree,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ContainerComponentNode, D as ContainerNode, E as DataNode, H as DisplayNode, I as DividerComponentNode, K as DrawerNode, N as DropdownNode, O as FeedbackNode, Q as FooterNode, R as GridNode, T as HeaderNode, V as IconNode, Y as ImageNode, Z as InputComponentNode, _ as InputNode, a2 as LayoutDefinitionNode, a3 as LayoutNode, a4 as LeafNode, a5 as LinkNode, a7 as ListNode, a8 as MainNode, ab as ModalNode, ah as NavNode, ai as NavigationNode, aj as NodeType, ak as OverlayNode, al as PageNode, am as PlaceholderNode, an as PopoverNode, aq as ProgressNode, ar as RadioNode, at as RowNode, au as SectionNode, av as SelectNode, ay as SidebarNode, aA as SliderNode, aB as SlotNode, aF as SpinnerNode, aJ as SwitchNode, aL as TableNode, aM as TabsNode, aO as TextContentNode, aP as TextNode, aT as TextareaNode, aV as TitleNode, aW as ToastNode, aY as TooltipNode, b1 as WireframeDocument, F as DefinitionNode, aC as SourceLocation, $ as InputType } from './types-BDaNyWMR.cjs';
|
|
2
2
|
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, G as DirectionValue, J as DividerNode, L as DrawerPosition, M as DropdownItemNode, P as FlexProps, S as GridProps, U as HeightValue, W as IconSize, X as IconSizeToken, a0 as InteractiveProps, a1 as JustifyValue, a6 as ListItemNode, a9 as MarkerColor, aa as MarkerNode, ac as NavBlockItem, ad as NavChild, ae as NavDivider, af as NavGroupNode, ag as NavItem, ao as Position, ap as PositionProps, as as RelativeNode, aw as SelectOption, ax as ShadowValue, az as SizeProps, aD as SpacingProps, aE as SpacingValue, aG as SpinnerSize, aH as SpinnerSizeToken, aI as StackNode, aK as TabNode, aN as TextAlign, aQ as TextSize, aR as TextSizeToken, aS as TextWeight, aU as TitleLevel, aX as ToastPosition, aZ as TooltipPosition, a_ as TopLevelNode, a$ as ValueWithUnit, b0 as WidthValue } from './types-BDaNyWMR.cjs';
|
|
3
3
|
export { ExpectedToken, ParseError, ParseErrorInfo, ParseOptions, ParseResult, getErrors, isValid, parse, tryParse } from './parser.cjs';
|
|
4
|
-
export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteOptions, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions } from './renderer.cjs';
|
|
4
|
+
export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, InteractiveAttrs, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteOptions, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, anchorIntent, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions } from './renderer.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Type guards for wireweave AST
|
|
@@ -1146,12 +1146,19 @@ interface TransitionEdge {
|
|
|
1146
1146
|
};
|
|
1147
1147
|
/**
|
|
1148
1148
|
* Whether `target` resolved to a concrete destination for its kind:
|
|
1149
|
-
* - `navigate`: a page whose title matches `target
|
|
1149
|
+
* - `navigate`: a page whose title matches `target`, or a URL-shaped external
|
|
1150
|
+
* destination outside this document.
|
|
1150
1151
|
* - `opens` / `toggles`: a `Modal` / `Drawer` with `id === target` in the
|
|
1151
1152
|
* source page.
|
|
1152
1153
|
* - `action`: always `false` (an opaque handler id has no structural target).
|
|
1153
1154
|
*/
|
|
1154
1155
|
resolved: boolean;
|
|
1156
|
+
/**
|
|
1157
|
+
* Present, and always `true`, when a `navigate` target is a URL rather than a
|
|
1158
|
+
* page name. External edges are resolved destinations outside this document,
|
|
1159
|
+
* so `to` remains `null` and they never appear in `dangling`.
|
|
1160
|
+
*/
|
|
1161
|
+
external?: true;
|
|
1155
1162
|
}
|
|
1156
1163
|
/**
|
|
1157
1164
|
* The screen-transition graph derived from a whole document.
|
|
@@ -1160,11 +1167,14 @@ interface ScreenTransitionGraph {
|
|
|
1160
1167
|
screens: TransitionScreen[];
|
|
1161
1168
|
edges: TransitionEdge[];
|
|
1162
1169
|
/**
|
|
1163
|
-
* The subset of `navigate` edges whose target matched no page title
|
|
1164
|
-
* (`resolved === false`, `to === null`). Intra-page
|
|
1165
|
-
* opaque `action` edges
|
|
1170
|
+
* The subset of `navigate` edges whose target matched no page title and was
|
|
1171
|
+
* not URL-shaped (`resolved === false`, `to === null`). Intra-page
|
|
1172
|
+
* `opens` / `toggles`, opaque `action` edges, and external URLs never appear
|
|
1173
|
+
* here.
|
|
1166
1174
|
*/
|
|
1167
1175
|
dangling: TransitionEdge[];
|
|
1176
|
+
/** URL-shaped `navigate` edges that leave the current document. */
|
|
1177
|
+
external: TransitionEdge[];
|
|
1168
1178
|
}
|
|
1169
1179
|
|
|
1170
1180
|
/**
|
|
@@ -1211,10 +1221,10 @@ declare function extractAllScreenFields(doc: WireframeDocument): ScreenFields[];
|
|
|
1211
1221
|
*
|
|
1212
1222
|
* - **`navigate`** is a page transition. Its target resolves to a page when the
|
|
1213
1223
|
* target string, trimmed, exactly matches a page `title` (case-sensitive). On
|
|
1214
|
-
* duplicate titles the first page in document order wins.
|
|
1215
|
-
* (`navigate="/dashboard"`)
|
|
1216
|
-
* {@link ScreenTransitionGraph.
|
|
1217
|
-
*
|
|
1224
|
+
* duplicate titles the first page in document order wins. When no title
|
|
1225
|
+
* matches, URL-shaped targets (`navigate="/dashboard"`, `https://…`) are
|
|
1226
|
+
* reported as {@link ScreenTransitionGraph.external | external}; unmatched
|
|
1227
|
+
* plain names remain {@link ScreenTransitionGraph.dangling | dangling}.
|
|
1218
1228
|
* - **`opens` / `toggles`** target an overlay *within the source page*, not
|
|
1219
1229
|
* another page, so their `to` is always `null`. They resolve when a `Modal`
|
|
1220
1230
|
* or `Drawer` in the same page has `id === target` (the only nodes that carry
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h as AnyNode, A as AccordionNode, a as AlertNode, j as AvatarNode, B as BadgeNode, r as BreadcrumbNode, s as ButtonNode, C as CardNode, w as CheckboxNode, x as ColNode, z as ContainerComponentNode, D as ContainerNode, E as DataNode, H as DisplayNode, I as DividerComponentNode, K as DrawerNode, N as DropdownNode, O as FeedbackNode, Q as FooterNode, R as GridNode, T as HeaderNode, V as IconNode, Y as ImageNode, Z as InputComponentNode, _ as InputNode, a2 as LayoutDefinitionNode, a3 as LayoutNode, a4 as LeafNode, a5 as LinkNode, a7 as ListNode, a8 as MainNode, ab as ModalNode, ah as NavNode, ai as NavigationNode, aj as NodeType, ak as OverlayNode, al as PageNode, am as PlaceholderNode, an as PopoverNode, aq as ProgressNode, ar as RadioNode, at as RowNode, au as SectionNode, av as SelectNode, ay as SidebarNode, aA as SliderNode, aB as SlotNode, aF as SpinnerNode, aJ as SwitchNode, aL as TableNode, aM as TabsNode, aO as TextContentNode, aP as TextNode, aT as TextareaNode, aV as TitleNode, aW as ToastNode, aY as TooltipNode, b1 as WireframeDocument, F as DefinitionNode, aC as SourceLocation, $ as InputType } from './types-BDaNyWMR.js';
|
|
2
2
|
export { b as AlertVariant, c as AlignValue, d as AnchorPosition, e as AnnotationItemNode, f as AnnotationNode, g as AnnotationsNode, i as AppearanceProps, k as AvatarSize, l as AvatarSizeToken, m as BadgeSize, n as BadgeSizeToken, o as BadgeVariant, p as BaseNode, q as BreadcrumbItem, t as ButtonSize, u as ButtonSizeToken, v as ButtonVariant, y as CommonProps, G as DirectionValue, J as DividerNode, L as DrawerPosition, M as DropdownItemNode, P as FlexProps, S as GridProps, U as HeightValue, W as IconSize, X as IconSizeToken, a0 as InteractiveProps, a1 as JustifyValue, a6 as ListItemNode, a9 as MarkerColor, aa as MarkerNode, ac as NavBlockItem, ad as NavChild, ae as NavDivider, af as NavGroupNode, ag as NavItem, ao as Position, ap as PositionProps, as as RelativeNode, aw as SelectOption, ax as ShadowValue, az as SizeProps, aD as SpacingProps, aE as SpacingValue, aG as SpinnerSize, aH as SpinnerSizeToken, aI as StackNode, aK as TabNode, aN as TextAlign, aQ as TextSize, aR as TextSizeToken, aS as TextWeight, aU as TitleLevel, aX as ToastPosition, aZ as TooltipPosition, a_ as TopLevelNode, a$ as ValueWithUnit, b0 as WidthValue } from './types-BDaNyWMR.js';
|
|
3
3
|
export { ExpectedToken, ParseError, ParseErrorInfo, ParseOptions, ParseResult, getErrors, isValid, parse, tryParse } from './parser.js';
|
|
4
|
-
export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteOptions, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions } from './renderer.js';
|
|
4
|
+
export { CanvasOptions, CanvasRenderResult, HtmlRenderer, IconData, IconElement, InteractiveAttrs, PageRenderResult, PlacedPage, RenderContext, RenderOptions, RenderResult, ShellMiss, SiteModel, SiteOptions, SiteScreen, SiteShell, SvgRenderOptions, SvgRenderResult, ThemeColors, ThemeConfig, anchorIntent, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions } from './renderer.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Type guards for wireweave AST
|
|
@@ -1146,12 +1146,19 @@ interface TransitionEdge {
|
|
|
1146
1146
|
};
|
|
1147
1147
|
/**
|
|
1148
1148
|
* Whether `target` resolved to a concrete destination for its kind:
|
|
1149
|
-
* - `navigate`: a page whose title matches `target
|
|
1149
|
+
* - `navigate`: a page whose title matches `target`, or a URL-shaped external
|
|
1150
|
+
* destination outside this document.
|
|
1150
1151
|
* - `opens` / `toggles`: a `Modal` / `Drawer` with `id === target` in the
|
|
1151
1152
|
* source page.
|
|
1152
1153
|
* - `action`: always `false` (an opaque handler id has no structural target).
|
|
1153
1154
|
*/
|
|
1154
1155
|
resolved: boolean;
|
|
1156
|
+
/**
|
|
1157
|
+
* Present, and always `true`, when a `navigate` target is a URL rather than a
|
|
1158
|
+
* page name. External edges are resolved destinations outside this document,
|
|
1159
|
+
* so `to` remains `null` and they never appear in `dangling`.
|
|
1160
|
+
*/
|
|
1161
|
+
external?: true;
|
|
1155
1162
|
}
|
|
1156
1163
|
/**
|
|
1157
1164
|
* The screen-transition graph derived from a whole document.
|
|
@@ -1160,11 +1167,14 @@ interface ScreenTransitionGraph {
|
|
|
1160
1167
|
screens: TransitionScreen[];
|
|
1161
1168
|
edges: TransitionEdge[];
|
|
1162
1169
|
/**
|
|
1163
|
-
* The subset of `navigate` edges whose target matched no page title
|
|
1164
|
-
* (`resolved === false`, `to === null`). Intra-page
|
|
1165
|
-
* opaque `action` edges
|
|
1170
|
+
* The subset of `navigate` edges whose target matched no page title and was
|
|
1171
|
+
* not URL-shaped (`resolved === false`, `to === null`). Intra-page
|
|
1172
|
+
* `opens` / `toggles`, opaque `action` edges, and external URLs never appear
|
|
1173
|
+
* here.
|
|
1166
1174
|
*/
|
|
1167
1175
|
dangling: TransitionEdge[];
|
|
1176
|
+
/** URL-shaped `navigate` edges that leave the current document. */
|
|
1177
|
+
external: TransitionEdge[];
|
|
1168
1178
|
}
|
|
1169
1179
|
|
|
1170
1180
|
/**
|
|
@@ -1211,10 +1221,10 @@ declare function extractAllScreenFields(doc: WireframeDocument): ScreenFields[];
|
|
|
1211
1221
|
*
|
|
1212
1222
|
* - **`navigate`** is a page transition. Its target resolves to a page when the
|
|
1213
1223
|
* target string, trimmed, exactly matches a page `title` (case-sensitive). On
|
|
1214
|
-
* duplicate titles the first page in document order wins.
|
|
1215
|
-
* (`navigate="/dashboard"`)
|
|
1216
|
-
* {@link ScreenTransitionGraph.
|
|
1217
|
-
*
|
|
1224
|
+
* duplicate titles the first page in document order wins. When no title
|
|
1225
|
+
* matches, URL-shaped targets (`navigate="/dashboard"`, `https://…`) are
|
|
1226
|
+
* reported as {@link ScreenTransitionGraph.external | external}; unmatched
|
|
1227
|
+
* plain names remain {@link ScreenTransitionGraph.dangling | dangling}.
|
|
1218
1228
|
* - **`opens` / `toggles`** target an overlay *within the source page*, not
|
|
1219
1229
|
* another page, so their `to` is always `null`. They resolve when a `Modal`
|
|
1220
1230
|
* or `Drawer` in the same page has `id === target` (the only nodes that carry
|
package/dist/index.js
CHANGED
|
@@ -9947,8 +9947,8 @@ function renderCard(node, ctx) {
|
|
|
9947
9947
|
]);
|
|
9948
9948
|
const styles = ctx.buildCommonStyles(node);
|
|
9949
9949
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
9950
|
-
const
|
|
9951
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
9950
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
9951
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
9952
9952
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
9953
9953
|
` : "";
|
|
9954
9954
|
const children = ctx.renderChildren(node.children);
|
|
@@ -10001,6 +10001,45 @@ ${children}
|
|
|
10001
10001
|
</div>`;
|
|
10002
10002
|
}
|
|
10003
10003
|
|
|
10004
|
+
// src/interaction/target.ts
|
|
10005
|
+
function isUrlTarget(target) {
|
|
10006
|
+
if (target === void 0) return false;
|
|
10007
|
+
const value = target.trim();
|
|
10008
|
+
if (value.length === 0 || /\s/.test(value)) return false;
|
|
10009
|
+
if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
|
|
10010
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
10011
|
+
}
|
|
10012
|
+
|
|
10013
|
+
// src/renderer/html/interactive.ts
|
|
10014
|
+
var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
10015
|
+
function interactiveAttrs(node) {
|
|
10016
|
+
return {
|
|
10017
|
+
"data-navigate": node.navigate,
|
|
10018
|
+
[EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
|
|
10019
|
+
"data-opens": node.opens,
|
|
10020
|
+
"data-toggles": node.toggles,
|
|
10021
|
+
"data-action": node.action
|
|
10022
|
+
};
|
|
10023
|
+
}
|
|
10024
|
+
function anchorIntent(node) {
|
|
10025
|
+
const attrs2 = interactiveAttrs(node);
|
|
10026
|
+
if (node.href) return { href: node.href, attrs: attrs2 };
|
|
10027
|
+
if (isUrlTarget(node.navigate)) {
|
|
10028
|
+
return {
|
|
10029
|
+
href: node.navigate.trim(),
|
|
10030
|
+
attrs: {
|
|
10031
|
+
...attrs2,
|
|
10032
|
+
"data-navigate": void 0,
|
|
10033
|
+
[EXTERNAL_NAVIGATE_ATTR]: void 0
|
|
10034
|
+
}
|
|
10035
|
+
};
|
|
10036
|
+
}
|
|
10037
|
+
return { href: "#", attrs: attrs2 };
|
|
10038
|
+
}
|
|
10039
|
+
function nonAnchorIntent(node) {
|
|
10040
|
+
return interactiveAttrs(node);
|
|
10041
|
+
}
|
|
10042
|
+
|
|
10004
10043
|
// src/renderer/html/renderers/text.ts
|
|
10005
10044
|
function isValueWithUnit3(value) {
|
|
10006
10045
|
return typeof value === "object" && value !== null && "value" in value && "unit" in value;
|
|
@@ -10063,14 +10102,11 @@ function renderLink(node, ctx) {
|
|
|
10063
10102
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
10064
10103
|
const styles = ctx.buildCommonStyles(node);
|
|
10065
10104
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
10105
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
10066
10106
|
const attrs2 = {
|
|
10067
10107
|
class: classes,
|
|
10068
|
-
href
|
|
10069
|
-
|
|
10070
|
-
"data-navigate": node.navigate,
|
|
10071
|
-
"data-opens": node.opens,
|
|
10072
|
-
"data-toggles": node.toggles,
|
|
10073
|
-
"data-action": node.action
|
|
10108
|
+
href,
|
|
10109
|
+
...intentAttrs
|
|
10074
10110
|
};
|
|
10075
10111
|
if (node.external) {
|
|
10076
10112
|
attrs2.target = "_blank";
|
|
@@ -56792,8 +56828,8 @@ function renderImage(node, ctx) {
|
|
|
56792
56828
|
}
|
|
56793
56829
|
const label = node.alt || "Image";
|
|
56794
56830
|
const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
56795
|
-
const
|
|
56796
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
56831
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
56832
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
56797
56833
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
56798
56834
|
}
|
|
56799
56835
|
function renderPlaceholder(node, ctx) {
|
|
@@ -56836,13 +56872,13 @@ function renderAvatar(node, ctx) {
|
|
|
56836
56872
|
content = "?";
|
|
56837
56873
|
}
|
|
56838
56874
|
}
|
|
56839
|
-
const
|
|
56840
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
56875
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
56876
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
56841
56877
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
56842
56878
|
}
|
|
56843
56879
|
function renderBadge(node, ctx) {
|
|
56844
|
-
const
|
|
56845
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
56880
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
56881
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
56846
56882
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
56847
56883
|
if (node.icon) {
|
|
56848
56884
|
const iconData = getIconData(node.icon);
|
|
@@ -56881,8 +56917,8 @@ function renderBadge(node, ctx) {
|
|
|
56881
56917
|
}
|
|
56882
56918
|
function renderIcon(node, ctx) {
|
|
56883
56919
|
const iconData = getIconData(node.name);
|
|
56884
|
-
const
|
|
56885
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
56920
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
56921
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
56886
56922
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
56887
56923
|
const wrapperClasses = ctx.buildClassString([
|
|
56888
56924
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -56949,18 +56985,13 @@ function renderDropdown(node, ctx) {
|
|
|
56949
56985
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
56950
56986
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
56951
56987
|
]);
|
|
56952
|
-
const interactiveAttrs = {
|
|
56953
|
-
"data-navigate": dropdownItem.navigate,
|
|
56954
|
-
"data-opens": dropdownItem.opens,
|
|
56955
|
-
"data-toggles": dropdownItem.toggles,
|
|
56956
|
-
"data-action": dropdownItem.action
|
|
56957
|
-
};
|
|
56958
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
56959
56988
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
56960
56989
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
56961
|
-
const href
|
|
56962
|
-
|
|
56990
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
56991
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
56992
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
56963
56993
|
}
|
|
56994
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
56964
56995
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
56965
56996
|
}).join("\n");
|
|
56966
56997
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -56979,7 +57010,9 @@ function renderNavItem(item, ctx) {
|
|
|
56979
57010
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
56980
57011
|
]);
|
|
56981
57012
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
56982
|
-
|
|
57013
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
57014
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
57015
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
56983
57016
|
}
|
|
56984
57017
|
function renderNavChildren(children, ctx) {
|
|
56985
57018
|
return children.map((child) => {
|
|
@@ -57022,13 +57055,7 @@ ${content}
|
|
|
57022
57055
|
if (typeof item === "string") {
|
|
57023
57056
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
57024
57057
|
}
|
|
57025
|
-
|
|
57026
|
-
`${ctx.prefix}-nav-link`,
|
|
57027
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
57028
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
57029
|
-
]);
|
|
57030
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
57031
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
57058
|
+
return renderNavItem(item, ctx);
|
|
57032
57059
|
}).join("\n");
|
|
57033
57060
|
return `<nav class="${classes}"${styleAttr}>
|
|
57034
57061
|
${items}
|
|
@@ -57059,7 +57086,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
57059
57086
|
if (typeof item === "string") {
|
|
57060
57087
|
return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
57061
57088
|
}
|
|
57062
|
-
|
|
57089
|
+
if (isLast) {
|
|
57090
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
57091
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
57092
|
+
}
|
|
57093
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
57094
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
57095
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
57063
57096
|
}).join(separator);
|
|
57064
57097
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
57065
57098
|
}
|
|
@@ -60766,6 +60799,11 @@ function resolveEdge(from, kind, target, trigger, titleToIndex, overlayIds, page
|
|
|
60766
60799
|
edge.resolved = true;
|
|
60767
60800
|
return { edge, isDangling: false };
|
|
60768
60801
|
}
|
|
60802
|
+
if (isUrlTarget(target)) {
|
|
60803
|
+
edge.external = true;
|
|
60804
|
+
edge.resolved = true;
|
|
60805
|
+
return { edge, isDangling: false };
|
|
60806
|
+
}
|
|
60769
60807
|
return { edge, isDangling: true };
|
|
60770
60808
|
}
|
|
60771
60809
|
if (kind === "opens" || kind === "toggles") {
|
|
@@ -60790,6 +60828,7 @@ function extractScreenTransitions(doc) {
|
|
|
60790
60828
|
});
|
|
60791
60829
|
const edges = [];
|
|
60792
60830
|
const dangling = [];
|
|
60831
|
+
const external = [];
|
|
60793
60832
|
pages.forEach((page, pageIndex) => {
|
|
60794
60833
|
const overlayIds = collectOverlayIds(page);
|
|
60795
60834
|
const from = fromDescriptor(pageIndex, page);
|
|
@@ -60805,6 +60844,7 @@ function extractScreenTransitions(doc) {
|
|
|
60805
60844
|
);
|
|
60806
60845
|
edges.push(edge);
|
|
60807
60846
|
if (isDangling) dangling.push(edge);
|
|
60847
|
+
if (edge.external) external.push(edge);
|
|
60808
60848
|
};
|
|
60809
60849
|
for (const child of page.children) {
|
|
60810
60850
|
walk(child, (node) => {
|
|
@@ -60828,7 +60868,7 @@ function extractScreenTransitions(doc) {
|
|
|
60828
60868
|
});
|
|
60829
60869
|
}
|
|
60830
60870
|
});
|
|
60831
|
-
return { screens, edges, dangling };
|
|
60871
|
+
return { screens, edges, dangling, external };
|
|
60832
60872
|
}
|
|
60833
60873
|
function fromDescriptor(pageIndex, page) {
|
|
60834
60874
|
return page.title != null ? { pageIndex, title: page.title } : { pageIndex };
|
|
@@ -60898,6 +60938,7 @@ export {
|
|
|
60898
60938
|
VALID_ATTRIBUTE_NAMES,
|
|
60899
60939
|
VALID_COMPONENT_NAMES,
|
|
60900
60940
|
analyze,
|
|
60941
|
+
anchorIntent,
|
|
60901
60942
|
areIdentical,
|
|
60902
60943
|
buildAnchorIndex,
|
|
60903
60944
|
buildDomTree,
|
package/dist/renderer.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var renderer_exports = {};
|
|
22
22
|
__export(renderer_exports, {
|
|
23
23
|
HtmlRenderer: () => HtmlRenderer,
|
|
24
|
+
anchorIntent: () => anchorIntent,
|
|
24
25
|
buildSiteModel: () => buildSiteModel,
|
|
25
26
|
createHtmlRenderer: () => createHtmlRenderer,
|
|
26
27
|
darkTheme: () => darkTheme,
|
|
@@ -2425,8 +2426,8 @@ function renderCard(node, ctx) {
|
|
|
2425
2426
|
]);
|
|
2426
2427
|
const styles = ctx.buildCommonStyles(node);
|
|
2427
2428
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2428
|
-
const
|
|
2429
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
2429
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
2430
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
2430
2431
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
2431
2432
|
` : "";
|
|
2432
2433
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2479,6 +2480,45 @@ ${children}
|
|
|
2479
2480
|
</div>`;
|
|
2480
2481
|
}
|
|
2481
2482
|
|
|
2483
|
+
// src/interaction/target.ts
|
|
2484
|
+
function isUrlTarget(target) {
|
|
2485
|
+
if (target === void 0) return false;
|
|
2486
|
+
const value = target.trim();
|
|
2487
|
+
if (value.length === 0 || /\s/.test(value)) return false;
|
|
2488
|
+
if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
|
|
2489
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
// src/renderer/html/interactive.ts
|
|
2493
|
+
var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
2494
|
+
function interactiveAttrs(node) {
|
|
2495
|
+
return {
|
|
2496
|
+
"data-navigate": node.navigate,
|
|
2497
|
+
[EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
|
|
2498
|
+
"data-opens": node.opens,
|
|
2499
|
+
"data-toggles": node.toggles,
|
|
2500
|
+
"data-action": node.action
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
function anchorIntent(node) {
|
|
2504
|
+
const attrs2 = interactiveAttrs(node);
|
|
2505
|
+
if (node.href) return { href: node.href, attrs: attrs2 };
|
|
2506
|
+
if (isUrlTarget(node.navigate)) {
|
|
2507
|
+
return {
|
|
2508
|
+
href: node.navigate.trim(),
|
|
2509
|
+
attrs: {
|
|
2510
|
+
...attrs2,
|
|
2511
|
+
"data-navigate": void 0,
|
|
2512
|
+
[EXTERNAL_NAVIGATE_ATTR]: void 0
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
return { href: "#", attrs: attrs2 };
|
|
2517
|
+
}
|
|
2518
|
+
function nonAnchorIntent(node) {
|
|
2519
|
+
return interactiveAttrs(node);
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2482
2522
|
// src/renderer/html/renderers/text.ts
|
|
2483
2523
|
function isValueWithUnit2(value) {
|
|
2484
2524
|
return typeof value === "object" && value !== null && "value" in value && "unit" in value;
|
|
@@ -2541,14 +2581,11 @@ function renderLink(node, ctx) {
|
|
|
2541
2581
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
2542
2582
|
const styles = ctx.buildCommonStyles(node);
|
|
2543
2583
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2584
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
2544
2585
|
const attrs2 = {
|
|
2545
2586
|
class: classes,
|
|
2546
|
-
href
|
|
2547
|
-
|
|
2548
|
-
"data-navigate": node.navigate,
|
|
2549
|
-
"data-opens": node.opens,
|
|
2550
|
-
"data-toggles": node.toggles,
|
|
2551
|
-
"data-action": node.action
|
|
2587
|
+
href,
|
|
2588
|
+
...intentAttrs
|
|
2552
2589
|
};
|
|
2553
2590
|
if (node.external) {
|
|
2554
2591
|
attrs2.target = "_blank";
|
|
@@ -49270,8 +49307,8 @@ function renderImage(node, ctx) {
|
|
|
49270
49307
|
}
|
|
49271
49308
|
const label = node.alt || "Image";
|
|
49272
49309
|
const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
49273
|
-
const
|
|
49274
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49310
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49311
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49275
49312
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
49276
49313
|
}
|
|
49277
49314
|
function renderPlaceholder(node, ctx) {
|
|
@@ -49314,13 +49351,13 @@ function renderAvatar(node, ctx) {
|
|
|
49314
49351
|
content = "?";
|
|
49315
49352
|
}
|
|
49316
49353
|
}
|
|
49317
|
-
const
|
|
49318
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49354
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49355
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49319
49356
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
49320
49357
|
}
|
|
49321
49358
|
function renderBadge(node, ctx) {
|
|
49322
|
-
const
|
|
49323
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49359
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49360
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49324
49361
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
49325
49362
|
if (node.icon) {
|
|
49326
49363
|
const iconData = getIconData(node.icon);
|
|
@@ -49359,8 +49396,8 @@ function renderBadge(node, ctx) {
|
|
|
49359
49396
|
}
|
|
49360
49397
|
function renderIcon(node, ctx) {
|
|
49361
49398
|
const iconData = getIconData(node.name);
|
|
49362
|
-
const
|
|
49363
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49399
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49400
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49364
49401
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
49365
49402
|
const wrapperClasses = ctx.buildClassString([
|
|
49366
49403
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -49427,18 +49464,13 @@ function renderDropdown(node, ctx) {
|
|
|
49427
49464
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
49428
49465
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
49429
49466
|
]);
|
|
49430
|
-
const interactiveAttrs = {
|
|
49431
|
-
"data-navigate": dropdownItem.navigate,
|
|
49432
|
-
"data-opens": dropdownItem.opens,
|
|
49433
|
-
"data-toggles": dropdownItem.toggles,
|
|
49434
|
-
"data-action": dropdownItem.action
|
|
49435
|
-
};
|
|
49436
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
49437
49467
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
49438
49468
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
49439
|
-
const href
|
|
49440
|
-
|
|
49469
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
49470
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
49471
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
49441
49472
|
}
|
|
49473
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
49442
49474
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
49443
49475
|
}).join("\n");
|
|
49444
49476
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -49457,7 +49489,9 @@ function renderNavItem(item, ctx) {
|
|
|
49457
49489
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49458
49490
|
]);
|
|
49459
49491
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49460
|
-
|
|
49492
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49493
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49494
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49461
49495
|
}
|
|
49462
49496
|
function renderNavChildren(children, ctx) {
|
|
49463
49497
|
return children.map((child) => {
|
|
@@ -49500,13 +49534,7 @@ ${content}
|
|
|
49500
49534
|
if (typeof item === "string") {
|
|
49501
49535
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49502
49536
|
}
|
|
49503
|
-
|
|
49504
|
-
`${ctx.prefix}-nav-link`,
|
|
49505
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
49506
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49507
|
-
]);
|
|
49508
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49509
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49537
|
+
return renderNavItem(item, ctx);
|
|
49510
49538
|
}).join("\n");
|
|
49511
49539
|
return `<nav class="${classes}"${styleAttr}>
|
|
49512
49540
|
${items}
|
|
@@ -49537,7 +49565,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
49537
49565
|
if (typeof item === "string") {
|
|
49538
49566
|
return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49539
49567
|
}
|
|
49540
|
-
|
|
49568
|
+
if (isLast) {
|
|
49569
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
49570
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
49571
|
+
}
|
|
49572
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49573
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49574
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
49541
49575
|
}).join(separator);
|
|
49542
49576
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
49543
49577
|
}
|
|
@@ -51101,6 +51135,7 @@ ${css}
|
|
|
51101
51135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
51102
51136
|
0 && (module.exports = {
|
|
51103
51137
|
HtmlRenderer,
|
|
51138
|
+
anchorIntent,
|
|
51104
51139
|
buildSiteModel,
|
|
51105
51140
|
createHtmlRenderer,
|
|
51106
51141
|
darkTheme,
|
package/dist/renderer.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b1 as WireframeDocument, h as AnyNode, al as PageNode, a2 as LayoutDefinitionNode } from './types-BDaNyWMR.cjs';
|
|
1
|
+
import { b1 as WireframeDocument, h as AnyNode, al as PageNode, a2 as LayoutDefinitionNode, a0 as InteractiveProps } from './types-BDaNyWMR.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Renderer type definitions for wireweave
|
|
@@ -523,6 +523,36 @@ interface SiteOptions extends Pick<RenderOptions, 'theme' | 'classPrefix' | 'bac
|
|
|
523
523
|
/** Render pages and their optional named layouts as one self-contained site. */
|
|
524
524
|
declare function renderSite(document: WireframeDocument, options?: SiteOptions): string;
|
|
525
525
|
|
|
526
|
+
/**
|
|
527
|
+
* Shared interaction intent emitted by HTML renderers.
|
|
528
|
+
*
|
|
529
|
+
* Anchor renderers have two destination channels (`href` and
|
|
530
|
+
* `data-navigate`), so the choice between them must have one owner. Consumers
|
|
531
|
+
* such as Studio import {@link anchorIntent} to observe the same decision as
|
|
532
|
+
* the renderer instead of reimplementing it.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
type InteractiveAttrs = {
|
|
536
|
+
'data-navigate': string | undefined;
|
|
537
|
+
'data-navigate-external': true | undefined;
|
|
538
|
+
'data-opens': string | undefined;
|
|
539
|
+
'data-toggles': string | undefined;
|
|
540
|
+
'data-action': string | undefined;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Resolve the attributes emitted for a node rendered as an anchor.
|
|
544
|
+
*
|
|
545
|
+
* An authored `href` wins. Otherwise a URL-shaped `navigate` becomes the real
|
|
546
|
+
* `href`; a page-name target remains in `data-navigate` and the anchor receives
|
|
547
|
+
* an inert `#` href. Other interaction intents are preserved in every branch.
|
|
548
|
+
*/
|
|
549
|
+
declare function anchorIntent(node: Partial<InteractiveProps> & {
|
|
550
|
+
href?: string;
|
|
551
|
+
}): {
|
|
552
|
+
href: string;
|
|
553
|
+
attrs: InteractiveAttrs;
|
|
554
|
+
};
|
|
555
|
+
|
|
526
556
|
/**
|
|
527
557
|
* Lucide Icons Data
|
|
528
558
|
*
|
|
@@ -605,4 +635,4 @@ declare function renderToHtml(document: WireframeDocument, options?: RenderOptio
|
|
|
605
635
|
*/
|
|
606
636
|
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
607
637
|
|
|
608
|
-
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type ShellMiss, type SiteModel, type SiteOptions, type SiteScreen, type SiteShell, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|
|
638
|
+
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type InteractiveAttrs, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type ShellMiss, type SiteModel, type SiteOptions, type SiteScreen, type SiteShell, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, anchorIntent, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b1 as WireframeDocument, h as AnyNode, al as PageNode, a2 as LayoutDefinitionNode } from './types-BDaNyWMR.js';
|
|
1
|
+
import { b1 as WireframeDocument, h as AnyNode, al as PageNode, a2 as LayoutDefinitionNode, a0 as InteractiveProps } from './types-BDaNyWMR.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Renderer type definitions for wireweave
|
|
@@ -523,6 +523,36 @@ interface SiteOptions extends Pick<RenderOptions, 'theme' | 'classPrefix' | 'bac
|
|
|
523
523
|
/** Render pages and their optional named layouts as one self-contained site. */
|
|
524
524
|
declare function renderSite(document: WireframeDocument, options?: SiteOptions): string;
|
|
525
525
|
|
|
526
|
+
/**
|
|
527
|
+
* Shared interaction intent emitted by HTML renderers.
|
|
528
|
+
*
|
|
529
|
+
* Anchor renderers have two destination channels (`href` and
|
|
530
|
+
* `data-navigate`), so the choice between them must have one owner. Consumers
|
|
531
|
+
* such as Studio import {@link anchorIntent} to observe the same decision as
|
|
532
|
+
* the renderer instead of reimplementing it.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
type InteractiveAttrs = {
|
|
536
|
+
'data-navigate': string | undefined;
|
|
537
|
+
'data-navigate-external': true | undefined;
|
|
538
|
+
'data-opens': string | undefined;
|
|
539
|
+
'data-toggles': string | undefined;
|
|
540
|
+
'data-action': string | undefined;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Resolve the attributes emitted for a node rendered as an anchor.
|
|
544
|
+
*
|
|
545
|
+
* An authored `href` wins. Otherwise a URL-shaped `navigate` becomes the real
|
|
546
|
+
* `href`; a page-name target remains in `data-navigate` and the anchor receives
|
|
547
|
+
* an inert `#` href. Other interaction intents are preserved in every branch.
|
|
548
|
+
*/
|
|
549
|
+
declare function anchorIntent(node: Partial<InteractiveProps> & {
|
|
550
|
+
href?: string;
|
|
551
|
+
}): {
|
|
552
|
+
href: string;
|
|
553
|
+
attrs: InteractiveAttrs;
|
|
554
|
+
};
|
|
555
|
+
|
|
526
556
|
/**
|
|
527
557
|
* Lucide Icons Data
|
|
528
558
|
*
|
|
@@ -605,4 +635,4 @@ declare function renderToHtml(document: WireframeDocument, options?: RenderOptio
|
|
|
605
635
|
*/
|
|
606
636
|
declare function renderToSvg(document: WireframeDocument, options?: SvgRenderOptions): SvgRenderResult;
|
|
607
637
|
|
|
608
|
-
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type ShellMiss, type SiteModel, type SiteOptions, type SiteScreen, type SiteShell, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|
|
638
|
+
export { type CanvasOptions, type CanvasRenderResult, HtmlRenderer, type IconData, type IconElement, type InteractiveAttrs, type PageRenderResult, type PlacedPage, type RenderContext, type RenderOptions, type RenderResult, type ShellMiss, type SiteModel, type SiteOptions, type SiteScreen, type SiteShell, type SvgRenderOptions, type SvgRenderResult, type ThemeColors, type ThemeConfig, anchorIntent, buildSiteModel, createHtmlRenderer, darkTheme, defaultTheme, generateComponentStyles, generateStyles, getIconData, getTheme, layoutCanvas, lucideIcons, render, renderCanvas, renderIconSvg, renderPage, renderSite, renderToHtml, renderToSvg, renderUnknownIconSvg, resolvePageDimensions };
|
package/dist/renderer.js
CHANGED
|
@@ -2380,8 +2380,8 @@ function renderCard(node, ctx) {
|
|
|
2380
2380
|
]);
|
|
2381
2381
|
const styles = ctx.buildCommonStyles(node);
|
|
2382
2382
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2383
|
-
const
|
|
2384
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
2383
|
+
const interactiveAttrs2 = buildInteractiveAttrs(node);
|
|
2384
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
2385
2385
|
const title = node.title ? `<h3 class="${ctx.prefix}-title">${ctx.escapeHtml(node.title)}</h3>
|
|
2386
2386
|
` : "";
|
|
2387
2387
|
const children = ctx.renderChildren(node.children);
|
|
@@ -2434,6 +2434,45 @@ ${children}
|
|
|
2434
2434
|
</div>`;
|
|
2435
2435
|
}
|
|
2436
2436
|
|
|
2437
|
+
// src/interaction/target.ts
|
|
2438
|
+
function isUrlTarget(target) {
|
|
2439
|
+
if (target === void 0) return false;
|
|
2440
|
+
const value = target.trim();
|
|
2441
|
+
if (value.length === 0 || /\s/.test(value)) return false;
|
|
2442
|
+
if (value.startsWith("/") || value.startsWith("#") || value.startsWith("?")) return true;
|
|
2443
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
// src/renderer/html/interactive.ts
|
|
2447
|
+
var EXTERNAL_NAVIGATE_ATTR = "data-navigate-external";
|
|
2448
|
+
function interactiveAttrs(node) {
|
|
2449
|
+
return {
|
|
2450
|
+
"data-navigate": node.navigate,
|
|
2451
|
+
[EXTERNAL_NAVIGATE_ATTR]: isUrlTarget(node.navigate) ? true : void 0,
|
|
2452
|
+
"data-opens": node.opens,
|
|
2453
|
+
"data-toggles": node.toggles,
|
|
2454
|
+
"data-action": node.action
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function anchorIntent(node) {
|
|
2458
|
+
const attrs2 = interactiveAttrs(node);
|
|
2459
|
+
if (node.href) return { href: node.href, attrs: attrs2 };
|
|
2460
|
+
if (isUrlTarget(node.navigate)) {
|
|
2461
|
+
return {
|
|
2462
|
+
href: node.navigate.trim(),
|
|
2463
|
+
attrs: {
|
|
2464
|
+
...attrs2,
|
|
2465
|
+
"data-navigate": void 0,
|
|
2466
|
+
[EXTERNAL_NAVIGATE_ATTR]: void 0
|
|
2467
|
+
}
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
return { href: "#", attrs: attrs2 };
|
|
2471
|
+
}
|
|
2472
|
+
function nonAnchorIntent(node) {
|
|
2473
|
+
return interactiveAttrs(node);
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2437
2476
|
// src/renderer/html/renderers/text.ts
|
|
2438
2477
|
function isValueWithUnit2(value) {
|
|
2439
2478
|
return typeof value === "object" && value !== null && "value" in value && "unit" in value;
|
|
@@ -2496,14 +2535,11 @@ function renderLink(node, ctx) {
|
|
|
2496
2535
|
const classes = ctx.buildClassString([`${ctx.prefix}-link`, ...ctx.getCommonClasses(node)]);
|
|
2497
2536
|
const styles = ctx.buildCommonStyles(node);
|
|
2498
2537
|
const styleAttr = styles ? ` style="${styles}"` : "";
|
|
2538
|
+
const { href, attrs: intentAttrs } = anchorIntent(node);
|
|
2499
2539
|
const attrs2 = {
|
|
2500
2540
|
class: classes,
|
|
2501
|
-
href
|
|
2502
|
-
|
|
2503
|
-
"data-navigate": node.navigate,
|
|
2504
|
-
"data-opens": node.opens,
|
|
2505
|
-
"data-toggles": node.toggles,
|
|
2506
|
-
"data-action": node.action
|
|
2541
|
+
href,
|
|
2542
|
+
...intentAttrs
|
|
2507
2543
|
};
|
|
2508
2544
|
if (node.external) {
|
|
2509
2545
|
attrs2.target = "_blank";
|
|
@@ -49225,8 +49261,8 @@ function renderImage(node, ctx) {
|
|
|
49225
49261
|
}
|
|
49226
49262
|
const label = node.alt || "Image";
|
|
49227
49263
|
const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
49228
|
-
const
|
|
49229
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49264
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49265
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49230
49266
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(label)}">${icon}<span>${ctx.escapeHtml(label)}</span></div>`;
|
|
49231
49267
|
}
|
|
49232
49268
|
function renderPlaceholder(node, ctx) {
|
|
@@ -49269,13 +49305,13 @@ function renderAvatar(node, ctx) {
|
|
|
49269
49305
|
content = "?";
|
|
49270
49306
|
}
|
|
49271
49307
|
}
|
|
49272
|
-
const
|
|
49273
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49308
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49309
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49274
49310
|
return `<div class="${classes}"${styleAttr}${interactiveAttrStr} role="img" aria-label="${ctx.escapeHtml(node.name || "Avatar")}">${content}</div>`;
|
|
49275
49311
|
}
|
|
49276
49312
|
function renderBadge(node, ctx) {
|
|
49277
|
-
const
|
|
49278
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49313
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49314
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49279
49315
|
const sizeResolved = resolveSizeValue(node.size, "badge", ctx.prefix);
|
|
49280
49316
|
if (node.icon) {
|
|
49281
49317
|
const iconData = getIconData(node.icon);
|
|
@@ -49314,8 +49350,8 @@ function renderBadge(node, ctx) {
|
|
|
49314
49350
|
}
|
|
49315
49351
|
function renderIcon(node, ctx) {
|
|
49316
49352
|
const iconData = getIconData(node.name);
|
|
49317
|
-
const
|
|
49318
|
-
const interactiveAttrStr = ctx.buildAttrsString(
|
|
49353
|
+
const interactiveAttrs2 = buildInteractiveAttrs2(node);
|
|
49354
|
+
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs2);
|
|
49319
49355
|
const sizeResolved = resolveSizeValue(node.size, "icon", ctx.prefix);
|
|
49320
49356
|
const wrapperClasses = ctx.buildClassString([
|
|
49321
49357
|
`${ctx.prefix}-icon-wrapper`,
|
|
@@ -49382,18 +49418,13 @@ function renderDropdown(node, ctx) {
|
|
|
49382
49418
|
dropdownItem.danger ? `${ctx.prefix}-dropdown-item-danger` : void 0,
|
|
49383
49419
|
dropdownItem.disabled ? `${ctx.prefix}-dropdown-item-disabled` : void 0
|
|
49384
49420
|
]);
|
|
49385
|
-
const interactiveAttrs = {
|
|
49386
|
-
"data-navigate": dropdownItem.navigate,
|
|
49387
|
-
"data-opens": dropdownItem.opens,
|
|
49388
|
-
"data-toggles": dropdownItem.toggles,
|
|
49389
|
-
"data-action": dropdownItem.action
|
|
49390
|
-
};
|
|
49391
|
-
const interactiveAttrStr = ctx.buildAttrsString(interactiveAttrs);
|
|
49392
49421
|
const disabledAttr = dropdownItem.disabled ? ' disabled="disabled"' : "";
|
|
49393
49422
|
if (dropdownItem.href || dropdownItem.navigate) {
|
|
49394
|
-
const href
|
|
49395
|
-
|
|
49423
|
+
const { href, attrs: attrs2 } = anchorIntent(dropdownItem);
|
|
49424
|
+
const anchorAttrStr = ctx.buildAttrsString(attrs2);
|
|
49425
|
+
return `<a class="${itemClasses}" href="${ctx.escapeHtml(href)}"${anchorAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</a>`;
|
|
49396
49426
|
}
|
|
49427
|
+
const interactiveAttrStr = ctx.buildAttrsString(nonAnchorIntent(dropdownItem));
|
|
49397
49428
|
return `<button class="${itemClasses}"${disabledAttr}${interactiveAttrStr}>${ctx.escapeHtml(dropdownItem.label)}</button>`;
|
|
49398
49429
|
}).join("\n");
|
|
49399
49430
|
return `<div class="${classes}"${styleAttr}>
|
|
@@ -49412,7 +49443,9 @@ function renderNavItem(item, ctx) {
|
|
|
49412
49443
|
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49413
49444
|
]);
|
|
49414
49445
|
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49415
|
-
|
|
49446
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49447
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49448
|
+
return `<a class="${linkClasses}" href="${ctx.escapeHtml(href)}"${intentAttrs}>${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49416
49449
|
}
|
|
49417
49450
|
function renderNavChildren(children, ctx) {
|
|
49418
49451
|
return children.map((child) => {
|
|
@@ -49455,13 +49488,7 @@ ${content}
|
|
|
49455
49488
|
if (typeof item === "string") {
|
|
49456
49489
|
return `<a class="${ctx.prefix}-nav-link" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49457
49490
|
}
|
|
49458
|
-
|
|
49459
|
-
`${ctx.prefix}-nav-link`,
|
|
49460
|
-
item.active ? `${ctx.prefix}-nav-link-active` : void 0,
|
|
49461
|
-
item.disabled ? `${ctx.prefix}-nav-link-disabled` : void 0
|
|
49462
|
-
]);
|
|
49463
|
-
const iconHtml = item.icon ? renderIconHtml(item.icon, ctx.prefix) + " " : "";
|
|
49464
|
-
return `<a class="${linkClasses}" href="${item.href || "#"}">${iconHtml}${ctx.escapeHtml(item.label)}</a>`;
|
|
49491
|
+
return renderNavItem(item, ctx);
|
|
49465
49492
|
}).join("\n");
|
|
49466
49493
|
return `<nav class="${classes}"${styleAttr}>
|
|
49467
49494
|
${items}
|
|
@@ -49492,7 +49519,13 @@ function renderBreadcrumb(node, ctx) {
|
|
|
49492
49519
|
if (typeof item === "string") {
|
|
49493
49520
|
return isLast ? `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page">${ctx.escapeHtml(item)}</span>` : `<a class="${ctx.prefix}-breadcrumb-item" href="#">${ctx.escapeHtml(item)}</a>`;
|
|
49494
49521
|
}
|
|
49495
|
-
|
|
49522
|
+
if (isLast) {
|
|
49523
|
+
const intentAttrs2 = ctx.buildAttrsString(nonAnchorIntent(item));
|
|
49524
|
+
return `<span class="${ctx.prefix}-breadcrumb-item" aria-current="page"${intentAttrs2}>${ctx.escapeHtml(item.label)}</span>`;
|
|
49525
|
+
}
|
|
49526
|
+
const { href, attrs: attrs2 } = anchorIntent(item);
|
|
49527
|
+
const intentAttrs = ctx.buildAttrsString(attrs2);
|
|
49528
|
+
return `<a class="${ctx.prefix}-breadcrumb-item" href="${ctx.escapeHtml(href)}"${intentAttrs}>${ctx.escapeHtml(item.label)}</a>`;
|
|
49496
49529
|
}).join(separator);
|
|
49497
49530
|
return `<nav class="${classes}"${styleAttr} aria-label="Breadcrumb">${items}</nav>`;
|
|
49498
49531
|
}
|
|
@@ -51055,6 +51088,7 @@ ${css}
|
|
|
51055
51088
|
}
|
|
51056
51089
|
export {
|
|
51057
51090
|
HtmlRenderer,
|
|
51091
|
+
anchorIntent,
|
|
51058
51092
|
buildSiteModel,
|
|
51059
51093
|
createHtmlRenderer,
|
|
51060
51094
|
darkTheme,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wireweave/core",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.3",
|
|
4
4
|
"description": "Core parser and renderer for wireweave",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.
|
|
7
|
+
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|