"use client"; import * as z from "zod"; import { ResponsiveContainer } from "recharts"; import { FlexibleReportChart, flexibleChartDataSchema } from "./flexibleReportChart"; const MetricSchema = z.object({ value: z.string().min(1).max(12).meta({ description: "Primary metric value shown in the stat card.", }), label: z.string().min(3).max(24).optional().meta({ description: "Metric label shown below the value.", }), description: z.string().min(6).max(36).optional().meta({ description: "Supporting description shown below the label.", }), }); const StatColumnSchema = z.object({ metrics: z.array(MetricSchema).min(0).max(2).meta({ description: "Two stacked metrics shown in one stat card.", }), }); export const slideLayoutId = "title-chart-metrics-cards-slide"; export const slideLayoutName = "Title Chart with Metrics Cards Slide"; export const slideLayoutDescription = "A slide with a title at the top, chart in the left content area, and optional metric cards arranged side by side on the right."; export const Schema = z.object({ title: z.string().min(3).max(80).default("Data Analysis").meta({ description: "Slide title shown at the top-left.", }), seriesALabel: z.string().min(3).max(20).default("Category A").meta({ description: "Legend label for the first line series.", }), seriesBLabel: z.string().min(3).max(20).default("Category B").meta({ description: "Legend label for the second line series.", }), chartData: flexibleChartDataSchema.default({ type: "line-dual", data: [ { label: "label", valueA: 24, valueB: 40 }, { label: "label", valueA: 55, valueB: 72 }, { label: "label", valueA: 50, valueB: 98 }, { label: "label", valueA: 97, valueB: 86 }, { label: "label", valueA: 70, valueB: 52 }, { label: "label", valueA: 42, valueB: 78 }, { label: "label", valueA: 63, valueB: 51 }, ], }), legendLabel: z.string().min(3).max(32).default("Traditional Workflow").meta({ description: "Legend label shown below the chart.", }), statColumns: z .array(StatColumnSchema) .min(1) .max(2) .default([ { metrics: [ { value: "25K", label: "Students", description: "Ut enim ad minima" }, { value: "25K", label: "Students", description: "Ut enim ad minima" }, ], }, { metrics: [ { value: "25K", label: "Students", description: "Ut enim ad minima" }, { value: "25K", label: "Students", description: "Ut enim ad minima" }, ], }, ]) .meta({ description: "Stat/metric cards shown on the right side of the slide.", }), }); export type SchemaType = z.infer; type StatMetric = { value: string; label?: string; description?: string; }; function StatPill({ metrics }: { metrics: StatMetric[] }) { return (
{metrics.map((metric, index) => (

{metric.value}

{metric.label &&

{metric.label}

} {metric.description &&

{metric.description}

}
{index === 0 && (
)}
))}
); } const DataAnalysisLineStatsSlide = ({ data }: { data: Partial }) => { const { title, seriesALabel, seriesBLabel, chartData, statColumns, legendLabel } = data; const rows = chartData?.data ?? []; const chartType = chartData?.type ?? "line-dual"; const series = chartData?.series ?? []; return (

{title}

{chartType === "line-dual" &&
{seriesALabel} {seriesBLabel}
}

{data.legendLabel}

{statColumns?.map((column, index) => ( ))}
); }; export default DataAnalysisLineStatsSlide;