@littlepress/renderer-web 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +229 -2
- package/dist/answer/answerComponents.d.ts +107 -0
- package/dist/answer/answerComponents.js +637 -0
- package/dist/answer/download.d.ts +63 -0
- package/dist/answer/download.js +109 -0
- package/dist/answer/downloadExport.d.ts +44 -0
- package/dist/answer/downloadExport.js +266 -0
- package/dist/answer/hostValues.d.ts +28 -0
- package/dist/answer/hostValues.js +379 -0
- package/dist/answer/mapComponent.d.ts +6 -0
- package/dist/answer/mapComponent.js +213 -0
- package/dist/answer/math.d.ts +57 -0
- package/dist/answer/math.js +168 -0
- package/dist/answer/surfaceStream.d.ts +51 -0
- package/dist/answer/surfaceStream.js +260 -0
- package/dist/answer/tableLayout.d.ts +42 -0
- package/dist/answer/tableLayout.js +89 -0
- package/dist/controls/ActionFeedback.d.ts +5 -0
- package/dist/controls/ActionFeedback.js +43 -0
- package/dist/controls/actionDispatch.d.ts +51 -0
- package/dist/controls/actionDispatch.js +211 -0
- package/dist/controls/actionOutcome.generated.d.ts +64 -0
- package/dist/controls/actionOutcome.generated.js +64 -0
- package/dist/controls/calculationPublisher.d.ts +14 -0
- package/dist/controls/calculationPublisher.js +6 -0
- package/dist/controls/calculations.d.ts +20 -0
- package/dist/controls/calculations.generated.d.ts +73 -0
- package/dist/controls/calculations.generated.js +85 -0
- package/dist/controls/calculations.js +208 -0
- package/dist/controls/controlState.d.ts +84 -0
- package/dist/controls/controlState.js +256 -0
- package/dist/controls/fieldMessages.d.ts +41 -0
- package/dist/controls/fieldMessages.js +81 -0
- package/dist/controls/fieldValidation.d.ts +19 -0
- package/dist/controls/fieldValidation.js +98 -0
- package/dist/controls/formComponents.d.ts +23 -0
- package/dist/controls/formComponents.js +738 -0
- package/dist/controls/formProgress.d.ts +63 -0
- package/dist/controls/formProgress.js +122 -0
- package/dist/controls/inputDrafts.d.ts +55 -0
- package/dist/controls/inputDrafts.js +183 -0
- package/dist/controls/inputValidation.d.ts +33 -0
- package/dist/controls/inputValidation.js +119 -0
- package/dist/controls/localWrites.d.ts +9 -0
- package/dist/controls/localWrites.js +29 -0
- package/dist/core/A2uiSurface.d.ts +13 -0
- package/dist/core/A2uiSurface.js +15 -0
- package/dist/core/AtlasIcon.d.ts +18 -0
- package/dist/core/AtlasIcon.js +22 -0
- package/dist/core/AtlasMedia.d.ts +22 -0
- package/dist/core/AtlasMedia.js +45 -0
- package/dist/core/Carousel.d.ts +61 -0
- package/dist/core/Carousel.js +183 -0
- package/dist/core/CoreMedia.d.ts +19 -0
- package/dist/core/CoreMedia.js +25 -0
- package/dist/core/FoundationA2uiSurface.d.ts +86 -0
- package/dist/core/FoundationA2uiSurface.js +440 -0
- package/dist/core/ImagePreview.d.ts +42 -0
- package/dist/core/ImagePreview.js +73 -0
- package/dist/core/LucideIcon.d.ts +19 -0
- package/dist/core/LucideIcon.js +42 -0
- package/dist/core/SurfaceLink.d.ts +35 -0
- package/dist/core/SurfaceLink.js +60 -0
- package/dist/core/appearance/aegis.d.ts +49 -0
- package/dist/core/appearance/aegis.js +34 -0
- package/dist/core/appearance/colour.d.ts +24 -0
- package/dist/core/appearance/colour.js +103 -0
- package/dist/core/appearance/css.d.ts +17 -0
- package/dist/core/appearance/css.js +153 -0
- package/dist/core/appearance/presets.generated.d.ts +4 -0
- package/dist/core/appearance/presets.generated.js +1184 -0
- package/dist/core/appearance/react.d.ts +29 -0
- package/dist/core/appearance/react.js +110 -0
- package/dist/core/appearance/resolve.d.ts +76 -0
- package/dist/core/appearance/resolve.js +127 -0
- package/dist/core/appearance/textScale.d.ts +11 -0
- package/dist/core/appearance/textScale.js +51 -0
- package/dist/core/appearance/theme.d.ts +138 -0
- package/dist/core/appearance/theme.js +274 -0
- package/dist/core/baseComponents.d.ts +53 -0
- package/dist/core/baseComponents.js +480 -0
- package/dist/core/binding.d.ts +46 -0
- package/dist/core/binding.js +118 -0
- package/dist/core/bundle.d.ts +23 -0
- package/dist/core/bundle.js +75 -0
- package/dist/core/catalog/catalog-index.generated.d.ts +44 -0
- package/dist/core/catalog/catalog-index.generated.js +79 -0
- package/dist/core/catalog/icons.generated.d.ts +6 -0
- package/dist/core/catalog/icons.generated.js +1788 -0
- package/dist/core/catalog.d.ts +6 -0
- package/dist/core/catalog.generated.d.ts +50 -0
- package/dist/core/catalog.generated.js +2174 -0
- package/dist/core/catalog.js +8 -0
- package/dist/core/chartRows.d.ts +7 -0
- package/dist/core/chartRows.js +38 -0
- package/dist/core/component-support.d.ts +39 -0
- package/dist/core/component-support.js +127 -0
- package/dist/core/components/actions.d.ts +4 -0
- package/dist/core/components/actions.js +21 -0
- package/dist/core/components/cards.d.ts +9 -0
- package/dist/core/components/cards.js +227 -0
- package/dist/core/components/charts.d.ts +18 -0
- package/dist/core/components/charts.js +412 -0
- package/dist/core/components/comparisonTable.d.ts +50 -0
- package/dist/core/components/comparisonTable.js +89 -0
- package/dist/core/components/content.d.ts +13 -0
- package/dist/core/components/content.js +108 -0
- package/dist/core/components/seriesCharts.d.ts +531 -0
- package/dist/core/components/seriesCharts.js +1053 -0
- package/dist/core/components/stepFlow.d.ts +7 -0
- package/dist/core/components/stepFlow.js +13 -0
- package/dist/core/components.full.d.ts +10 -0
- package/dist/core/components.full.js +41 -0
- package/dist/core/context.d.ts +207 -0
- package/dist/core/context.js +172 -0
- package/dist/core/coverage.d.ts +30 -0
- package/dist/core/coverage.js +93 -0
- package/dist/core/foundation.d.ts +21 -0
- package/dist/core/foundation.js +22 -0
- package/dist/core/fullTheme.d.ts +5 -0
- package/dist/core/fullTheme.js +9 -0
- package/dist/core/iconNodes.generated.d.ts +7 -0
- package/dist/core/iconNodes.generated.js +5 -0
- package/dist/core/lucideIcons.d.ts +5 -0
- package/dist/core/lucideIcons.js +7 -0
- package/dist/core/messages.d.ts +111 -0
- package/dist/core/messages.js +134 -0
- package/dist/core/pointer.d.ts +17 -0
- package/dist/core/pointer.js +104 -0
- package/dist/core/registry.d.ts +12 -0
- package/dist/core/registry.js +114 -0
- package/dist/core/runtime.d.ts +8 -0
- package/dist/core/runtime.js +6 -0
- package/dist/core/state.d.ts +73 -0
- package/dist/core/state.js +274 -0
- package/dist/core/surfaceMotion.d.ts +5 -0
- package/dist/core/surfaceMotion.js +46 -0
- package/dist/core/theme.d.ts +5 -0
- package/dist/core/theme.js +7 -0
- package/dist/core/useSurfaceImage.d.ts +20 -0
- package/dist/core/useSurfaceImage.js +65 -0
- package/dist/graph/RelationshipGraph.d.ts +14 -0
- package/dist/graph/RelationshipGraph.js +206 -0
- package/dist/graph/model.d.ts +20 -0
- package/dist/graph/model.js +36 -0
- package/dist/graph/program/assets.d.ts +3 -0
- package/dist/graph/program/assets.js +3 -0
- package/dist/graph/program/bridge.d.ts +6 -0
- package/dist/graph/program/bridge.generated.d.ts +136 -0
- package/dist/graph/program/bridge.generated.js +1 -0
- package/dist/graph/program/bridge.js +24 -0
- package/dist/graph/program/bridge.schema.json +717 -0
- package/dist/graph/program/bridgeValidator.cjs +2 -0
- package/dist/graph/program/bridgeValidator.d.cts +4 -0
- package/dist/graph/program/runner.d.ts +1 -0
- package/dist/graph/program/runner.html +2193 -0
- package/dist/graph/program/runner.js +157 -0
- package/dist/graph/program/runtime-manifest.json +1 -0
- package/dist/graph/program/view.d.ts +11 -0
- package/dist/graph/program/view.js +210 -0
- package/dist/graph/program/worker.d.ts +1 -0
- package/dist/graph/program/worker.js +2186 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +45 -0
- package/dist/internal/dsh.d.ts +4 -0
- package/dist/internal/dsh.js +3 -0
- package/dist/internal/relationship-graph.d.ts +4 -0
- package/dist/internal/relationship-graph.js +7202 -0
- package/dist/page/layoutComponents.d.ts +6 -0
- package/dist/page/layoutComponents.js +123 -0
- package/dist/page/layoutGeometry.d.ts +68 -0
- package/dist/page/layoutGeometry.js +174 -0
- package/dist/page/pageFormat.d.ts +34 -0
- package/dist/page/pageFormat.js +119 -0
- package/dist/page/printFit.d.ts +81 -0
- package/dist/page/printFit.js +338 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.js +2 -0
- package/dist/report/locate.d.ts +42 -0
- package/dist/report/locate.js +34 -0
- package/dist/styles/renderer.css +4580 -0
- package/licenses/LUCIDE-LICENSE.txt +43 -0
- package/licenses/QUICKJS-EMSCRIPTEN-LICENSE.txt +21 -0
- package/licenses/QUICKJS-VARIANT-LICENSE.txt +47 -0
- package/package.json +68 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { foundationCatalogId, foundationCatalogVersion, foundationComponentNames, foundationWireComponentAliases, foundationWireComponentNames, } from "./catalog.generated.js";
|
|
2
|
+
import { foundationComponentNames, foundationWireComponentAliases, foundationWireComponentNames, } from "./catalog.generated.js";
|
|
3
|
+
/** Wire aliases generated from the Foundation catalog's canonical mapping. */
|
|
4
|
+
export const legacyFoundationComponentAliases = foundationWireComponentAliases;
|
|
5
|
+
export const foundationKnownComponents = new Set([
|
|
6
|
+
...foundationComponentNames,
|
|
7
|
+
...foundationWireComponentNames,
|
|
8
|
+
]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { A2uiJsonObject } from "./messages.ts";
|
|
2
|
+
/**
|
|
3
|
+
* One readable fallback line for an `lp.chart-elements` row. The row has to say what it holds
|
|
4
|
+
* when a chart is unavailable. A record with several numeric fields names each series field;
|
|
5
|
+
* the single `{label, value}` shape the catalog documents keeps reading as `label: value`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function chartRowText(record: A2uiJsonObject): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One readable fallback line for an `lp.chart-elements` row. The row has to say what it holds
|
|
3
|
+
* when a chart is unavailable. A record with several numeric fields names each series field;
|
|
4
|
+
* the single `{label, value}` shape the catalog documents keeps reading as `label: value`.
|
|
5
|
+
*/
|
|
6
|
+
export function chartRowText(record) {
|
|
7
|
+
const label = rowLabel(record);
|
|
8
|
+
const value = rowValueText(record);
|
|
9
|
+
if (label === null)
|
|
10
|
+
return value ?? "";
|
|
11
|
+
return value === null ? label : `${label}: ${value}`;
|
|
12
|
+
}
|
|
13
|
+
function isFiniteNumber(value) {
|
|
14
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
15
|
+
}
|
|
16
|
+
/** The row label: the documented fields first, then the first text the row carries. */
|
|
17
|
+
function rowLabel(record) {
|
|
18
|
+
for (const key of ["label", "name"]) {
|
|
19
|
+
const value = record[key];
|
|
20
|
+
if (typeof value === "string" && value.length > 0)
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
for (const value of Object.values(record)) {
|
|
24
|
+
if (typeof value === "string" && value.length > 0)
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function rowValueText(record) {
|
|
30
|
+
const numeric = Object.entries(record).filter(([, value]) => isFiniteNumber(value));
|
|
31
|
+
if (numeric.length === 1 && numeric[0][0] === "value")
|
|
32
|
+
return String(numeric[0][1]);
|
|
33
|
+
if (numeric.length > 0)
|
|
34
|
+
return numeric.map(([name, value]) => `${name}=${String(value)}`).join(", ");
|
|
35
|
+
// A row whose value is text (a formatted amount, a timeline detail) keeps showing that text.
|
|
36
|
+
const value = record.value;
|
|
37
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import { type A2uiComponent, type A2uiJsonObject } from "./foundation.ts";
|
|
3
|
+
import { type PrintPartPolicy, type RenderContext } from "./runtime.tsx";
|
|
4
|
+
export declare function text(component: A2uiComponent, key: string, context: RenderContext): string | null;
|
|
5
|
+
export declare function flag(component: A2uiComponent, key: string, context: RenderContext): boolean | null;
|
|
6
|
+
export declare function numberValue(component: A2uiComponent, key: string, context: RenderContext): number | null;
|
|
7
|
+
export declare function recordValue(component: A2uiComponent, key: string, context: RenderContext): A2uiJsonObject | null;
|
|
8
|
+
export declare function records(component: A2uiComponent, context: RenderContext, ...keys: string[]): A2uiJsonObject[];
|
|
9
|
+
export declare function stringFromRecord(record: A2uiJsonObject, ...keys: string[]): string | null;
|
|
10
|
+
export declare function numberFromRecord(record: A2uiJsonObject, ...keys: string[]): number | null;
|
|
11
|
+
export declare function accessibilityLabel(component: A2uiComponent, context: RenderContext): string | undefined;
|
|
12
|
+
export type PrintPartAttributes = {
|
|
13
|
+
"data-print-part": string;
|
|
14
|
+
"data-print-policy": PrintPartPolicy;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
};
|
|
17
|
+
/** Stable part markers are the renderer's only content-level fit contract. */
|
|
18
|
+
export declare function printPart(component: A2uiComponent, part: string, fallbackPolicy?: PrintPartPolicy): PrintPartAttributes;
|
|
19
|
+
export declare function ActionButton({ label, onClick, intent, block, printAttributes, leadingIcon, trailingIcon, }: {
|
|
20
|
+
label: string;
|
|
21
|
+
onClick?: (() => void) & {
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
pending?: boolean;
|
|
24
|
+
};
|
|
25
|
+
intent?: unknown;
|
|
26
|
+
block?: boolean;
|
|
27
|
+
printAttributes?: PrintPartAttributes;
|
|
28
|
+
leadingIcon?: unknown;
|
|
29
|
+
trailingIcon?: unknown;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* Honors the catalog's inlined `fallback` when a component's required content
|
|
33
|
+
* did not resolve. `render_degraded` means "draw what you have".
|
|
34
|
+
*/
|
|
35
|
+
export declare function withFallback(component: A2uiComponent, hasContent: boolean, node: ReactNode): ReactNode;
|
|
36
|
+
export declare function EmptyComponent({ component }: {
|
|
37
|
+
component: A2uiComponent;
|
|
38
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function renderChildren(component: A2uiComponent, context: RenderContext): ReactNode[];
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isChildTemplate, isRecord, readBindingPointer, resolveBoolean, resolveRecordList, resolveString, resolveValue, } from "./foundation.js";
|
|
3
|
+
import { RenderComponent, childContext, readFallback, } from "./runtime.js";
|
|
4
|
+
import { rendererCatalog } from "./catalog/catalog-index.generated.js";
|
|
5
|
+
import { AtlasIcon, isRendererIconName } from "./AtlasIcon.js";
|
|
6
|
+
/* -------------------------------------------------------------- primitives */
|
|
7
|
+
export function text(component, key, context) {
|
|
8
|
+
return resolveString(component[key], context.binding, context.valueFunctions);
|
|
9
|
+
}
|
|
10
|
+
export function flag(component, key, context) {
|
|
11
|
+
return resolveBoolean(component[key], context.binding, context.valueFunctions);
|
|
12
|
+
}
|
|
13
|
+
export function numberValue(component, key, context) {
|
|
14
|
+
const value = resolveValue(component[key], context.binding, context.valueFunctions);
|
|
15
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
16
|
+
}
|
|
17
|
+
export function recordValue(component, key, context) {
|
|
18
|
+
const value = resolveValue(component[key], context.binding, context.valueFunctions);
|
|
19
|
+
return isRecord(value) ? value : null;
|
|
20
|
+
}
|
|
21
|
+
export function records(component, context, ...keys) {
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
if (component[key] === undefined)
|
|
24
|
+
continue;
|
|
25
|
+
const value = resolveRecordList(component[key], context.binding, context.valueFunctions);
|
|
26
|
+
if (value.length > 0)
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
export function stringFromRecord(record, ...keys) {
|
|
32
|
+
for (const key of keys) {
|
|
33
|
+
if (typeof record[key] === "string" && record[key].length > 0)
|
|
34
|
+
return record[key];
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export function numberFromRecord(record, ...keys) {
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
if (typeof record[key] === "number" && Number.isFinite(record[key]))
|
|
41
|
+
return record[key];
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
export function accessibilityLabel(component, context) {
|
|
46
|
+
const label = component.accessibility?.label;
|
|
47
|
+
return resolveString(label, context.binding, context.valueFunctions) ?? undefined;
|
|
48
|
+
}
|
|
49
|
+
function intentClass(value) {
|
|
50
|
+
return value === "accent" ? "accent" : value === "ghost" ? "ghost" : value === "danger" ? "danger" : "";
|
|
51
|
+
}
|
|
52
|
+
const printSizesByComponent = new Map(rendererCatalog.map((entry) => [entry.component, entry.printSize]));
|
|
53
|
+
/** Stable part markers are the renderer's only content-level fit contract. */
|
|
54
|
+
export function printPart(component, part, fallbackPolicy = "content") {
|
|
55
|
+
// Repeated parts keep one stable contract name. The DOM can contain several
|
|
56
|
+
// `item` nodes, but Atlas declares the clamp once as `item`, not `item-0`.
|
|
57
|
+
const contractPart = part.replace(/-\d+$/, "");
|
|
58
|
+
const printSize = printSizesByComponent.get(component.component);
|
|
59
|
+
const protectedPart = printSize?.protectedParts?.includes(contractPart) ?? false;
|
|
60
|
+
const clampLines = printSize?.clamp?.[contractPart];
|
|
61
|
+
const policy = protectedPart
|
|
62
|
+
? "protected"
|
|
63
|
+
: typeof clampLines === "number"
|
|
64
|
+
? "clamp"
|
|
65
|
+
: fallbackPolicy;
|
|
66
|
+
// Clamp mechanics stay the -webkit-box line clamp at every tier: a nowrap
|
|
67
|
+
// single-line variant was tried on 2026-08-03 and reverted — nowrap sizes
|
|
68
|
+
// ambient layout to max-content (a landscape masthead byline widened its
|
|
69
|
+
// slot wrapper 194→212px). Padded shells (pills, inputs, buttons) put
|
|
70
|
+
// printPart on an inner span instead, so the clamp box has no padding for a
|
|
71
|
+
// cut line to leak into.
|
|
72
|
+
return {
|
|
73
|
+
"data-print-part": contractPart,
|
|
74
|
+
"data-print-policy": policy,
|
|
75
|
+
style: policy === "clamp" && typeof clampLines === "number"
|
|
76
|
+
? { "--print-clamp-lines": String(clampLines) }
|
|
77
|
+
: undefined,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function ActionButton({ label, onClick, intent, block, printAttributes, leadingIcon, trailingIcon, }) {
|
|
81
|
+
return (_jsxs("button", { type: "button", className: `lp-btn ${intentClass(intent)} ${block ? "block" : ""}`.replace(/\s+/g, " ").trim(), onClick: onClick, "aria-disabled": onClick?.disabled, "aria-busy": onClick?.pending, disabled: !onClick || onClick.disabled, ...printAttributes, children: [isRendererIconName(leadingIcon) ? _jsx(AtlasIcon, { name: leadingIcon, size: "sm" }) : null, _jsx("span", { children: label }), isRendererIconName(trailingIcon) ? _jsx(AtlasIcon, { name: trailingIcon, size: "sm" }) : null] }));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Honors the catalog's inlined `fallback` when a component's required content
|
|
85
|
+
* did not resolve. `render_degraded` means "draw what you have".
|
|
86
|
+
*/
|
|
87
|
+
export function withFallback(component, hasContent, node) {
|
|
88
|
+
if (hasContent)
|
|
89
|
+
return node;
|
|
90
|
+
const fallback = readFallback(component);
|
|
91
|
+
if (!fallback)
|
|
92
|
+
return _jsx(EmptyComponent, { component: component });
|
|
93
|
+
if (fallback.strategy === "hide")
|
|
94
|
+
return null;
|
|
95
|
+
if (fallback.strategy === "replace_with_text") {
|
|
96
|
+
return (_jsx("p", { className: "lp-body a2ui-fallback-text", "data-a2ui-fallback": "replace_with_text", children: fallback.text ?? "Content unavailable." }));
|
|
97
|
+
}
|
|
98
|
+
return node;
|
|
99
|
+
}
|
|
100
|
+
export function EmptyComponent({ component }) {
|
|
101
|
+
return (_jsxs("div", { className: "a2ui-empty", "data-a2ui-component": component.component, children: [_jsx("p", { className: "lp-kicker default", children: "No bound content" }), _jsxs("p", { className: "lp-caption", children: [component.component, " \u00B7 id ", _jsx("code", { children: component.id })] })] }));
|
|
102
|
+
}
|
|
103
|
+
/* --------------------------------------------------------------- structure */
|
|
104
|
+
export function renderChildren(component, context) {
|
|
105
|
+
const children = component.children;
|
|
106
|
+
if (Array.isArray(children)) {
|
|
107
|
+
return children
|
|
108
|
+
.filter((id) => typeof id === "string")
|
|
109
|
+
.map((id, index) => _jsx(RenderComponent, { componentId: id, context: childContext(context, component.id, undefined, index) }, id));
|
|
110
|
+
}
|
|
111
|
+
if (isChildTemplate(children)) {
|
|
112
|
+
const rows = resolveValue(children, context.binding, context.valueFunctions);
|
|
113
|
+
const items = Array.isArray(rows) ? rows : resolveRecordList({ path: children.path }, context.binding);
|
|
114
|
+
const basePointer = readBindingPointer({ path: children.path }, context.binding);
|
|
115
|
+
const list = Array.isArray(rows) ? rows : items;
|
|
116
|
+
const template = context.state.components[children.componentId];
|
|
117
|
+
return list.map((_row, index) => {
|
|
118
|
+
const itemPointer = basePointer ? `${basePointer}/${index}` : null;
|
|
119
|
+
const repeatedContext = childContext(context, component.id, itemPointer, index);
|
|
120
|
+
const itemId = template
|
|
121
|
+
? resolveString(template.itemId, repeatedContext.binding, repeatedContext.valueFunctions)
|
|
122
|
+
: null;
|
|
123
|
+
return (_jsx(RenderComponent, { componentId: children.componentId, context: repeatedContext }, `${children.componentId}-${itemId ?? index}`));
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { actionHandler } from "../runtime.js";
|
|
3
|
+
import { ActionButton, printPart, text, withFallback, } from "../component-support.js";
|
|
4
|
+
const renderStoryEndCard = (component, context) => {
|
|
5
|
+
const headline = text(component, "headline", context);
|
|
6
|
+
const result = text(component, "result", context);
|
|
7
|
+
const body = text(component, "body", context);
|
|
8
|
+
const label = text(component, "label", context) ?? "Share";
|
|
9
|
+
const share = actionHandler(component.shareAction, component, context);
|
|
10
|
+
const replay = actionHandler(component.replayAction, component, context);
|
|
11
|
+
return withFallback(component, Boolean(headline || result || body), _jsxs("section", { className: "lp-cta", children: [headline ? _jsx("p", { className: "lp-title", ...printPart(component, "headline", "clamp"), children: headline }) : null, result ? _jsx("strong", { className: "lp-stat-num", ...printPart(component, "result", "clamp"), children: result }) : null, body ? _jsx("p", { className: "lp-body", ...printPart(component, "sub"), children: body }) : null, _jsxs("div", { className: "lp-action-row", children: [_jsx(ActionButton, { label: label, onClick: share, "aria-disabled": share?.disabled, "aria-busy": share?.pending, intent: component.intent ?? "accent", printAttributes: printPart(component, "cta", "clamp") }), replay ? _jsx(ActionButton, { label: "Read again", onClick: replay, "aria-disabled": replay?.disabled, "aria-busy": replay?.pending, intent: "ghost" }) : null] })] }));
|
|
12
|
+
};
|
|
13
|
+
const renderShareCta = (component, context) => {
|
|
14
|
+
const kicker = text(component, "kicker", context);
|
|
15
|
+
const title = text(component, "title", context) ?? text(component, "headline", context);
|
|
16
|
+
const note = text(component, "note", context) ?? text(component, "body", context) ?? text(component, "caption", context);
|
|
17
|
+
const label = text(component, "label", context) ?? "Share";
|
|
18
|
+
const share = actionHandler(component.shareAction, component, context);
|
|
19
|
+
return withFallback(component, Boolean(title || share), _jsxs("section", { className: "lp-cta", children: [kicker ? _jsx("p", { className: "lp-kicker", ...printPart(component, "kicker", "clamp"), children: kicker }) : null, title ? _jsx("p", { className: "lp-title", ...printPart(component, "title", "clamp"), children: title }) : null, note ? _jsx("p", { className: "lp-caption", ...printPart(component, "note", "clamp"), children: note }) : null, _jsx("div", { className: "lp-action-row", children: _jsx(ActionButton, { label: label, onClick: share, "aria-disabled": share?.disabled, "aria-busy": share?.pending, intent: component.intent ?? "accent" }) })] }));
|
|
20
|
+
};
|
|
21
|
+
export { renderStoryEndCard, renderShareCta, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ComponentRenderer } from "../runtime.tsx";
|
|
2
|
+
declare const renderChecklistCard: ComponentRenderer;
|
|
3
|
+
declare const renderTermDeck: ComponentRenderer;
|
|
4
|
+
declare const renderStepFlow: ComponentRenderer;
|
|
5
|
+
declare const renderMetricRow: ComponentRenderer;
|
|
6
|
+
declare const renderInsightCard: ComponentRenderer;
|
|
7
|
+
declare const renderSourcesPanel: ComponentRenderer;
|
|
8
|
+
declare const renderChapterTimeline: ComponentRenderer;
|
|
9
|
+
export { renderChecklistCard, renderTermDeck, renderStepFlow, renderMetricRow, renderInsightCard, renderSourcesPanel, renderChapterTimeline, };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { buildOpenSourceEventAction, CiteSourceIcon, formatCodeLocation, HostBadgeImage, parseCiteSourceItem, } from "../../answer/answerComponents.js";
|
|
3
|
+
import { validLinkUrl } from "../../answer/hostValues.js";
|
|
4
|
+
import { resolveSurfaceLink } from "../SurfaceLink.js";
|
|
5
|
+
import { surfaceIsStreaming } from "../../controls/actionDispatch.js";
|
|
6
|
+
import { isChineseLanguage, surfaceLanguage } from "../../controls/fieldMessages.js";
|
|
7
|
+
import { readPointer, resolveRecordList, resolveStringList, } from "../foundation.js";
|
|
8
|
+
import { actionHandler, resolveAction } from "../runtime.js";
|
|
9
|
+
import { AtlasIcon, isRendererIconName } from "../AtlasIcon.js";
|
|
10
|
+
import { EmptyComponent, accessibilityLabel, flag, numberValue, printPart, records, stringFromRecord, text, withFallback, } from "../component-support.js";
|
|
11
|
+
import { cellText } from "./comparisonTable.js";
|
|
12
|
+
import { stepFlowState } from "./stepFlow.js";
|
|
13
|
+
const renderChecklistCard = (component, context) => {
|
|
14
|
+
const heading = text(component, "heading", context);
|
|
15
|
+
const summary = text(component, "summary", context);
|
|
16
|
+
const recordItems = resolveRecordList(component.items, context.binding, context.valueFunctions);
|
|
17
|
+
const items = recordItems.length > 0
|
|
18
|
+
? recordItems.map((item, index) => ({
|
|
19
|
+
label: typeof item.label === "string" ? item.label : `Check ${index + 1}`,
|
|
20
|
+
owner: typeof item.owner === "string" ? item.owner : null,
|
|
21
|
+
}))
|
|
22
|
+
: resolveStringList(component.items, context.binding, context.valueFunctions).map((label) => ({ label, owner: null }));
|
|
23
|
+
return withFallback(component, items.length > 0, _jsxs("section", { className: "lp-card lp-checklist", children: [heading ? _jsx("p", { className: "lp-heading", ...printPart(component, "title", "clamp"), children: heading }) : null, _jsx("ul", { className: "lp-list lp-list-check", children: items.map((item, index) => (_jsxs("li", { className: "lp-body", children: [_jsx("span", { ...printPart(component, `itemLabel-${index}`), children: item.label }), item.owner ? (_jsx("span", { className: "lp-meta", ...printPart(component, `owner-${index}`, "clamp"), children: item.owner })) : null] }, `check-${index}`))) }), summary ? _jsx("p", { className: "lp-caption", ...printPart(component, "summary", "clamp"), children: summary }) : null] }));
|
|
24
|
+
};
|
|
25
|
+
const renderTermDeck = (component, context) => {
|
|
26
|
+
const items = resolveRecordList(component.items, context.binding, context.valueFunctions);
|
|
27
|
+
if (items.length === 0)
|
|
28
|
+
return _jsx(EmptyComponent, { component: component });
|
|
29
|
+
const kicker = text(component, "kicker", context);
|
|
30
|
+
const heading = text(component, "heading", context);
|
|
31
|
+
return (_jsxs("section", { className: "lp-term-deck", "aria-label": accessibilityLabel(component, context), children: [kicker ? _jsx("p", { className: "lp-kicker", ...printPart(component, "kicker", "clamp"), children: kicker }) : null, heading ? _jsx("h3", { className: "lp-title", ...printPart(component, "heading", "clamp"), children: heading }) : null, _jsx("div", { className: "lp-term-deck-grid", children: items.map((item, index) => {
|
|
32
|
+
const term = typeof item.title === "string" ? item.title : typeof item.term === "string" ? item.term : null;
|
|
33
|
+
const detail = typeof item.body === "string" ? item.body : typeof item.detail === "string" ? item.detail : null;
|
|
34
|
+
return (_jsxs("article", { className: "lp-term-card", children: [term ? _jsx("p", { className: "lp-term-card-term", ...printPart(component, `term-${index}`, "clamp"), children: term }) : null, detail ? _jsx("p", { className: "lp-caption", ...printPart(component, `brief-${index}`, "clamp"), children: detail }) : null] }, `${term ?? "term"}-${index}`));
|
|
35
|
+
}) })] }));
|
|
36
|
+
};
|
|
37
|
+
// Atlas rule: 2-10 steps; longer records belong in a list.
|
|
38
|
+
const STEP_FLOW_MAX_STEPS = 10;
|
|
39
|
+
/** Item field named by a literal StepFlow prop such as titleField. */
|
|
40
|
+
function stepField(component, key) {
|
|
41
|
+
const value = component[key];
|
|
42
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
43
|
+
}
|
|
44
|
+
const renderStepFlow = (component, context) => {
|
|
45
|
+
const steps = records(component, context, "items", "steps").slice(0, STEP_FLOW_MAX_STEPS);
|
|
46
|
+
const titleField = stepField(component, "titleField");
|
|
47
|
+
const detailField = stepField(component, "detailField");
|
|
48
|
+
const stateField = stepField(component, "stateField") ?? "state";
|
|
49
|
+
const stepState = (step) => stepFlowState(stringFromRecord(step, stateField));
|
|
50
|
+
// The optional header and footer lines, in the renderer visual contract's text roles.
|
|
51
|
+
const kicker = text(component, "kicker", context);
|
|
52
|
+
const headline = text(component, "headline", context);
|
|
53
|
+
const body = text(component, "body", context);
|
|
54
|
+
const caption = text(component, "caption", context);
|
|
55
|
+
const explicitCurrent = numberValue(component, "current", context);
|
|
56
|
+
const stateCurrent = steps.findIndex((step) => stepState(step) === "current");
|
|
57
|
+
const completedCount = steps.filter((step) => stepState(step) === "done").length;
|
|
58
|
+
const current = Math.max(0, Math.min(explicitCurrent ?? (stateCurrent >= 0 ? stateCurrent : completedCount), Math.max(steps.length - 1, 0)));
|
|
59
|
+
return withFallback(component, steps.length > 0, _jsxs("section", { className: "lp-step-flow", "aria-label": accessibilityLabel(component, context), children: [kicker ? _jsx("p", { className: "lp-kicker", ...printPart(component, "kicker", "clamp"), children: kicker }) : null, headline ? _jsx("p", { className: "lp-title", ...printPart(component, "headline", "clamp"), children: headline }) : null, body ? _jsx("p", { className: "lp-body", ...printPart(component, "body", "clamp"), children: body }) : null, _jsxs("p", { className: "lp-meta", ...printPart(component, "progress", "clamp"), children: ["Step ", Math.min(current + 1, steps.length), " of ", steps.length] }), _jsx("ol", { children: steps.map((step, index) => {
|
|
60
|
+
const label = (titleField ? stringFromRecord(step, titleField) : stringFromRecord(step, "label", "title", "name"))
|
|
61
|
+
?? `Step ${index + 1}`;
|
|
62
|
+
const detail = detailField ? stringFromRecord(step, detailField) : stringFromRecord(step, "detail", "body", "description");
|
|
63
|
+
const state = stepState(step) ?? (index < current ? "done" : index === current ? "current" : "pending");
|
|
64
|
+
return (_jsxs("li", { "data-state": state, "aria-current": state === "current" ? "step" : undefined, children: [_jsx("span", { className: "lp-step-marker", "aria-hidden": "true", children: index + 1 }), _jsxs("div", { children: [_jsx("p", { className: "lp-heading", ...printPart(component, "step", "clamp"), children: label }), detail ? _jsx("p", { className: "lp-caption", ...printPart(component, "detail", "clamp"), children: detail }) : null] })] }, `${label}-${index}`));
|
|
65
|
+
}) }), caption ? _jsx("p", { className: "lp-caption", ...printPart(component, "caption", "clamp"), children: caption }) : null] }));
|
|
66
|
+
};
|
|
67
|
+
// Atlas rule: 1-12 cells, values are editorial conclusions, never live counters. A
|
|
68
|
+
// marketing daily carries six to ten KPIs, so the strip wraps instead of stopping at
|
|
69
|
+
// four — and it never drops a cell, which the old slice(0, 4) silently did.
|
|
70
|
+
const METRIC_MAX_CELLS = 12;
|
|
71
|
+
/** Cells one row of the strip holds before it wraps; narrower cards halve it in CSS. */
|
|
72
|
+
const METRIC_ROW_CELLS = 4;
|
|
73
|
+
/** A metric value as drawn: a number the way a chart prints it ("1,284"), text as written. */
|
|
74
|
+
function metricValue(value) {
|
|
75
|
+
return cellText(value) ?? "—";
|
|
76
|
+
}
|
|
77
|
+
const renderMetricRow = (component, context) => {
|
|
78
|
+
const kicker = text(component, "kicker", context);
|
|
79
|
+
const heading = text(component, "heading", context);
|
|
80
|
+
const unit = text(component, "unit", context);
|
|
81
|
+
const caption = text(component, "caption", context);
|
|
82
|
+
const items = resolveRecordList(component.items, context.binding, context.valueFunctions).slice(0, METRIC_MAX_CELLS);
|
|
83
|
+
// Up to one row, each cell sized by its own emphasis. Past that the cells share a
|
|
84
|
+
// fixed grid, because a track per cell would squeeze twelve of them into one line.
|
|
85
|
+
const wraps = items.length > METRIC_ROW_CELLS;
|
|
86
|
+
return withFallback(component, items.length > 0, _jsxs("section", { className: "lp-section lp-metric-strip", children: [kicker ? _jsx("p", { className: "lp-kicker", ...printPart(component, "kicker", "clamp"), children: kicker }) : null, heading ? _jsx("p", { className: "lp-heading", ...printPart(component, "kicker", "clamp"), children: heading }) : null, unit ? _jsx("span", { className: "lp-series-unit", ...printPart(component, "unit", "clamp"), children: unit }) : null, _jsx("div", { className: `lp-metric-row${wraps ? " wraps" : ""}`, style: {
|
|
87
|
+
"--lp-stat-chars": Math.max(1, ...items.map((item) => metricValue(item.value).length)),
|
|
88
|
+
"--metric-columns": wraps
|
|
89
|
+
? `repeat(${METRIC_ROW_CELLS}, minmax(0, 1fr))`
|
|
90
|
+
: items
|
|
91
|
+
.map((item) => (item.emphasis === "primary" ? "minmax(0, 1.22fr)" : "minmax(0, 1fr)"))
|
|
92
|
+
.join(" "),
|
|
93
|
+
}, children: items.map((item, index) => {
|
|
94
|
+
const value = metricValue(item.value);
|
|
95
|
+
const itemId = typeof item.id === "string" ? item.id : `metric-${index}`;
|
|
96
|
+
const icon = typeof item.icon === "string" ? item.icon : null;
|
|
97
|
+
return (_jsxs("div", { className: "lp-metric", "data-emphasis": item.emphasis === "primary" ? "primary" : undefined,
|
|
98
|
+
// A primary cell is 1.22 times as wide; the value is sized for the narrowest
|
|
99
|
+
// cell of the strip, so the wider one must not come out a size larger.
|
|
100
|
+
style: !wraps && item.emphasis === "primary" && items.some((other) => other.emphasis !== "primary")
|
|
101
|
+
? { "--lp-stat-scale": 1 / 1.22 }
|
|
102
|
+
: undefined, children: [isRendererIconName(icon) ? _jsx(AtlasIcon, { name: icon, size: "sm", tone: "muted" }) : null, _jsx("b", { className: [
|
|
103
|
+
"lp-stat-num",
|
|
104
|
+
value.length > 5 ? "is-long" : "",
|
|
105
|
+
value.length > 7 ? "is-very-long" : "",
|
|
106
|
+
].filter(Boolean).join(" "), ...printPart(component, `value-${index}`, "clamp"), children: _jsx("span", { className: "lp-stat-fit", children: value }) }), _jsx("span", { className: "lp-stat-label", ...printPart(component, `label-${index}`, "clamp"), children: typeof item.label === "string" ? item.label : `Metric ${index + 1}` })] }, itemId));
|
|
107
|
+
}) }), caption ? _jsx("p", { className: "lp-caption", ...printPart(component, "caption", "clamp"), children: caption }) : null] }));
|
|
108
|
+
};
|
|
109
|
+
const insightVariantLabels = {
|
|
110
|
+
finding: "Finding",
|
|
111
|
+
tension: "Tension",
|
|
112
|
+
takeaway: "Takeaway",
|
|
113
|
+
opportunity: "Opportunity",
|
|
114
|
+
warning: "Watch",
|
|
115
|
+
};
|
|
116
|
+
const renderInsightCard = (component, context) => {
|
|
117
|
+
const variant = typeof component.variant === "string" ? component.variant : "finding";
|
|
118
|
+
const kicker = text(component, "kicker", context) ?? insightVariantLabels[variant] ?? variant;
|
|
119
|
+
const heading = text(component, "heading", context) ?? text(component, "title", context) ?? text(component, "headline", context);
|
|
120
|
+
const body = text(component, "body", context) ?? text(component, "text", context);
|
|
121
|
+
return withFallback(component, Boolean(heading || body), _jsxs("aside", { className: `lp-card lp-insight lp-insight-${variant}`, "aria-label": accessibilityLabel(component, context), children: [_jsx("p", { className: "lp-kicker", ...printPart(component, "kicker", "clamp"), children: kicker }), heading ? _jsx("p", { className: "lp-title", ...printPart(component, "heading", "clamp"), children: heading }) : null, body ? _jsx("p", { className: "lp-body", ...printPart(component, "body", "clamp"), children: body }) : null] }));
|
|
122
|
+
};
|
|
123
|
+
const renderSourcesPanel = (component, context) => {
|
|
124
|
+
const zh = isChineseLanguage(surfaceLanguage(context.state?.rendererHints));
|
|
125
|
+
const heading = text(component, "heading", context) ?? (zh ? "来源" : "Sources");
|
|
126
|
+
const items = resolveRecordList(component.items, context.binding, context.valueFunctions);
|
|
127
|
+
const streaming = surfaceIsStreaming(context.state);
|
|
128
|
+
return withFallback(component, items.length > 0, _jsxs("section", { className: "lp-card tonal lp-sources", children: [heading ? _jsx("p", { className: "lp-kicker default", ...printPart(component, "heading", "clamp"), children: heading }) : null, items.map((item, index) => {
|
|
129
|
+
const parsed = parseCiteSourceItem(item, index + 1);
|
|
130
|
+
const kind = parsed?.kind ?? (item.kind === "code" || item.kind === "file" ? item.kind : "web");
|
|
131
|
+
const title = parsed?.title ?? (typeof item.title === "string" && item.title.trim() ? item.title : `Source ${index + 1}`);
|
|
132
|
+
const rawUrl = typeof item.url === "string" && item.url.trim() ? item.url.trim() : null;
|
|
133
|
+
const openableUrl = validLinkUrl(rawUrl);
|
|
134
|
+
const site = parsed?.site ?? (typeof item.site === "string" && item.site.trim() ? item.site.trim() : null);
|
|
135
|
+
const excerpt = parsed?.excerpt ?? (typeof item.excerpt === "string" && item.excerpt.trim() ? item.excerpt.trim() : null);
|
|
136
|
+
const faviconUrl = parsed?.faviconUrl
|
|
137
|
+
?? (typeof item.faviconUrl === "string"
|
|
138
|
+
? item.faviconUrl
|
|
139
|
+
: typeof item.favicon_url === "string"
|
|
140
|
+
? item.favicon_url
|
|
141
|
+
: null);
|
|
142
|
+
const sourceId = typeof item.id === "string" && item.id.trim() ? item.id.trim() : null;
|
|
143
|
+
const metaLine = (() => {
|
|
144
|
+
if (parsed?.kind === "code" && parsed.path && parsed.lineStart !== undefined) {
|
|
145
|
+
const loc = formatCodeLocation(parsed.path, parsed.lineStart, parsed.lineEnd);
|
|
146
|
+
return site ? `${loc} · ${site}` : loc;
|
|
147
|
+
}
|
|
148
|
+
if (parsed?.kind === "file" && parsed.fileName) {
|
|
149
|
+
const loc = parsed.path && parsed.path !== parsed.fileName ? parsed.path : parsed.fileName;
|
|
150
|
+
return site ? `${loc} · ${site}` : loc;
|
|
151
|
+
}
|
|
152
|
+
if (site && rawUrl)
|
|
153
|
+
return `${site} · ${rawUrl}`;
|
|
154
|
+
return site ?? rawUrl;
|
|
155
|
+
})();
|
|
156
|
+
const rawUrlAction = openableUrl
|
|
157
|
+
? { functionCall: { call: "openUrl", args: { url: openableUrl } } }
|
|
158
|
+
: undefined;
|
|
159
|
+
const resolvedUrlLink = !streaming && openableUrl && rawUrlAction
|
|
160
|
+
? resolveSurfaceLink(openableUrl, rawUrlAction, component, context, { index, url: openableUrl }, `items/${index}/open`)
|
|
161
|
+
: null;
|
|
162
|
+
const rawOpenSource = !openableUrl && !streaming && sourceId && (kind === "code" || kind === "file")
|
|
163
|
+
? buildOpenSourceEventAction(sourceId)
|
|
164
|
+
: undefined;
|
|
165
|
+
const resolvedOpenSource = rawOpenSource
|
|
166
|
+
? resolveAction(rawOpenSource, component, context, {}, `items/${index}/open`)
|
|
167
|
+
: undefined;
|
|
168
|
+
const hostAcceptsOpenSource = Boolean(resolvedOpenSource && context.actionSession?.hostAccepts(resolvedOpenSource));
|
|
169
|
+
const onOpenSource = hostAcceptsOpenSource && rawOpenSource
|
|
170
|
+
? actionHandler(rawOpenSource, component, context, {}, `items/${index}/open`)
|
|
171
|
+
: undefined;
|
|
172
|
+
const onOpenUrl = resolvedUrlLink?.activate;
|
|
173
|
+
const urlDisabled = streaming || !onOpenUrl || onOpenUrl.disabled === true;
|
|
174
|
+
const sourceDisabled = streaming || !onOpenSource || onOpenSource.disabled === true;
|
|
175
|
+
const iconEl = parsed ? (_jsx(CiteSourceIcon, { source: parsed, size: 18, imgClassName: "lp-source-favicon", initialClassName: "lp-source-initial", kindIconClassName: "lp-source-kind-icon", context: context, streaming: streaming })) : (_jsx(HostBadgeImage, { url: faviconUrl, label: site ?? title, size: 18, imgClassName: "lp-source-favicon", initialClassName: "lp-source-initial", context: context, streaming: streaming }));
|
|
176
|
+
const body = (_jsxs(_Fragment, { children: [iconEl, _jsxs("span", { className: "lp-row-main", children: [_jsx("span", { className: "lp-heading", ...printPart(component, `source-${index}`, "clamp"), children: title }), metaLine ? (_jsx("span", { className: "lp-meta", ...printPart(component, `excerpt-${index}`, "clamp"), children: metaLine })) : null, excerpt ? _jsx("span", { className: "lp-meta lp-source-excerpt", children: excerpt }) : null] })] }));
|
|
177
|
+
if (resolvedUrlLink && resolvedUrlLink.mode === "host" && !streaming) {
|
|
178
|
+
return (_jsx("button", { type: "button", className: "lp-row lp-source-row", "data-source-kind": kind, "data-action-key": `items/${index}/open`, disabled: urlDisabled, "aria-disabled": urlDisabled ? true : undefined, "aria-busy": onOpenUrl?.pending ? true : undefined, onClick: () => {
|
|
179
|
+
if (!urlDisabled)
|
|
180
|
+
onOpenUrl?.();
|
|
181
|
+
}, children: body }, `source-${index}`));
|
|
182
|
+
}
|
|
183
|
+
if (resolvedUrlLink && resolvedUrlLink.mode === "default" && resolvedUrlLink.safeUrl && !streaming) {
|
|
184
|
+
const isHttp = /^https?:\/\//i.test(resolvedUrlLink.safeUrl);
|
|
185
|
+
return (_jsx("a", { className: "lp-row lp-source-row", "data-source-kind": kind, href: resolvedUrlLink.safeUrl, target: isHttp ? "_blank" : undefined, rel: isHttp ? "noopener noreferrer" : undefined, referrerPolicy: isHttp ? "no-referrer" : undefined, "data-action-key": `items/${index}/open`, "aria-disabled": urlDisabled ? true : undefined, "aria-busy": onOpenUrl?.pending ? true : undefined, onClick: (event) => {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
if (!urlDisabled)
|
|
188
|
+
onOpenUrl?.();
|
|
189
|
+
}, children: body }, `source-${index}`));
|
|
190
|
+
}
|
|
191
|
+
if (hostAcceptsOpenSource && onOpenSource && !streaming) {
|
|
192
|
+
return (_jsx("button", { type: "button", className: "lp-row lp-source-row", "data-source-kind": kind, "data-action-key": `items/${index}/open`, disabled: sourceDisabled, "aria-busy": onOpenSource.pending ? true : undefined, onClick: () => {
|
|
193
|
+
if (!sourceDisabled)
|
|
194
|
+
onOpenSource();
|
|
195
|
+
}, children: body }, `source-${index}`));
|
|
196
|
+
}
|
|
197
|
+
return (_jsx("div", { className: "lp-row lp-source-row", "data-source-kind": kind, "data-streaming": streaming ? "true" : undefined, children: body }, `source-${index}`));
|
|
198
|
+
})] }));
|
|
199
|
+
};
|
|
200
|
+
function formatTimestamp(ms) {
|
|
201
|
+
if (typeof ms !== "number" || !Number.isFinite(ms) || ms < 0)
|
|
202
|
+
return null;
|
|
203
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
204
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
205
|
+
const seconds = totalSeconds % 60;
|
|
206
|
+
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
|
207
|
+
}
|
|
208
|
+
const renderChapterTimeline = (component, context) => {
|
|
209
|
+
const chapters = resolveRecordList(component.items, context.binding, context.valueFunctions);
|
|
210
|
+
const showTimestamps = flag(component, "showTimestamps", context) ?? true;
|
|
211
|
+
const showProgress = flag(component, "showProgress", context) ?? false;
|
|
212
|
+
const progressPath = typeof component.progressPath === "string" ? component.progressPath : null;
|
|
213
|
+
const positionMs = progressPath ? readPointer(context.binding.dataModel, progressPath) : null;
|
|
214
|
+
const position = typeof positionMs === "number" ? positionMs : null;
|
|
215
|
+
return withFallback(component, chapters.length > 0, _jsx("section", { className: "lp-section lp-timeline", children: chapters.map((chapter, index) => {
|
|
216
|
+
const startMs = chapter.startMs;
|
|
217
|
+
// ADR 0004 N1 disposition 4: the row index is appended by the renderer,
|
|
218
|
+
// because the whole list is bound as one DynamicValue.
|
|
219
|
+
const onSelect = actionHandler(component.itemAction, component, context, {
|
|
220
|
+
index,
|
|
221
|
+
chapterId: typeof chapter.id === "string" ? chapter.id : undefined,
|
|
222
|
+
});
|
|
223
|
+
const played = showProgress && position !== null && typeof startMs === "number" && position >= startMs;
|
|
224
|
+
return (_jsxs("div", { className: "lp-row", children: [showTimestamps ? (_jsx("span", { className: "lp-meta lp-timeline-time", ...printPart(component, "timestamp", "clamp"), children: formatTimestamp(startMs) ?? stringFromRecord(chapter, "time") ?? "--:--" })) : null, _jsxs("button", { type: "button", className: "lp-row-main", onClick: onSelect, "aria-disabled": onSelect?.disabled, "aria-busy": onSelect?.pending, disabled: !onSelect || onSelect.disabled, children: [_jsx("span", { className: "lp-heading", ...printPart(component, `title-${index}`, "clamp"), children: typeof chapter.title === "string" ? chapter.title : `Chapter ${index + 1}` }), showProgress ? (_jsx("span", { className: "lp-progress", "aria-hidden": "true", children: _jsx("span", { className: played ? "on" : "" }) })) : null] })] }, typeof chapter.id === "string" ? chapter.id : `chapter-${index}`));
|
|
225
|
+
}) }));
|
|
226
|
+
};
|
|
227
|
+
export { renderChecklistCard, renderTermDeck, renderStepFlow, renderMetricRow, renderInsightCard, renderSourcesPanel, renderChapterTimeline, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ComponentRenderer } from "../runtime.tsx";
|
|
2
|
+
declare const renderBarChart: ComponentRenderer;
|
|
3
|
+
declare const renderLineChart: ComponentRenderer;
|
|
4
|
+
declare const renderAreaChart: ComponentRenderer;
|
|
5
|
+
/**
|
|
6
|
+
* The scatter chart (S47): two value axes, the line chart's hairline rules
|
|
7
|
+
* across the plot, and one marker per row and series. One unnamed series draws
|
|
8
|
+
* accent circles with no legend; several series each take a series colour and
|
|
9
|
+
* their own marker shape, so colour is never the only difference.
|
|
10
|
+
*/
|
|
11
|
+
declare const renderScatterChart: ComponentRenderer;
|
|
12
|
+
declare const renderPieChart: ComponentRenderer;
|
|
13
|
+
declare const renderRadarInsightChart: ComponentRenderer;
|
|
14
|
+
declare const renderQuadrantMap: ComponentRenderer;
|
|
15
|
+
declare const renderRadialBarChart: ComponentRenderer;
|
|
16
|
+
declare const renderDivergingBarChart: ComponentRenderer;
|
|
17
|
+
declare const renderComparisonTable: ComponentRenderer;
|
|
18
|
+
export { renderBarChart, renderLineChart, renderAreaChart, renderPieChart, renderScatterChart, renderRadialBarChart, renderRadarInsightChart, renderQuadrantMap, renderDivergingBarChart, renderComparisonTable, };
|