ai-chatbot/lib/detail-ui-dsl-v2.ts
Your Name 05cf3ae54e
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat: add detail ui dsl v2 renderer
2026-03-22 12:23:37 +08:00

107 lines
2.3 KiB
TypeScript

import type { DetailUiGlobalStyle } from "@/lib/detail-ui-protocol";
export type DetailUiDslRegion = {
x: number;
y: number;
width: number;
height: number;
};
export type DetailUiDslNode =
| {
kind: "panel";
id: string;
variant?: "glass" | "solid" | "ghost";
tone?: "light" | "dark" | "accent";
region?: DetailUiDslRegion;
direction?: "column" | "row";
gap?: number;
children: DetailUiDslNode[];
}
| {
kind: "stack";
id: string;
gap?: number;
children: DetailUiDslNode[];
}
| {
kind: "row";
id: string;
gap?: number;
columns?: number;
children: DetailUiDslNode[];
}
| {
kind: "badge";
id: string;
icon?: "sparkle" | "shield" | "arrow" | "check";
text: string;
tone?: "primary" | "secondary" | "neutral";
}
| {
kind: "heading";
id: string;
text: string;
level?: 1 | 2 | 3;
emphasis?: "hero" | "section";
}
| {
kind: "body";
id: string;
text: string;
emphasis?: "normal" | "muted" | "strong";
}
| {
kind: "feature-card";
id: string;
icon?: "sparkle" | "shield" | "arrow" | "check";
tone?: "primary" | "secondary" | "neutral";
tag?: string;
title: string;
body?: string;
}
| {
kind: "spec-table";
id: string;
rows: Array<{ label: string; value: string }>;
}
| {
kind: "compare";
id: string;
before: { title: string; body: string };
after: { title: string; body: string };
}
| {
kind: "proof";
id: string;
icon?: "shield" | "check" | "sparkle";
text: string;
}
| {
kind: "cta";
id: string;
headline?: string;
buttonText: string;
supportText?: string;
};
export interface DetailUiDslV2Document {
version: "detail-ui-dsl/v2";
surfaceId: string;
screenIndex: number;
generationMode: "classic" | "agent_layout";
screenSize: {
width: number;
height: number;
};
designStyle?: DetailUiGlobalStyle;
region: DetailUiDslRegion;
layoutVariant:
| "hero-left-panel"
| "hero-right-panel"
| "top-banner-bottom-grid"
| "floating-split"
| "cta-focus";
nodes: DetailUiDslNode[];
}