/** * shadcn Mapper — Maps ComponentSpec objects to shadcn/ui primitives * and generates production-ready React + TypeScript components. * * Inputs: * - ComponentSpec (from src/specs/types.ts) * - CodegenContext containing the project context and design system tokens * * Outputs: * - ComponentCode: { component: string (TSX), barrel: string (index.ts) } * * Key responsibilities: * 1. Resolve shadcnBase references to the correct shadcn import statements * 2. Build a typed props interface from spec.props declarations * 3. Build variant type unions and runtime variant class maps * 4. Compose component body using shadcn primitives (Card, Button, Input, etc.) * 5. Substitute design token hex values with Tailwind utility classes */ import type { ComponentSpec } from "../specs/types.js"; import type { CodegenContext } from "./generator.js"; import type { DesignToken } from "../engine/registry.js"; interface ComponentCode { component: string; barrel: string; } /** * Per-variant generation context. Optional — only populated when the * generator is emitting one of N variants under a cartesian axis set. * * `priorVariants` lists the sibling variants already generated in this run; * future AI-augmented codegen paths read it to avoid producing near-duplicates. * The template-based path ignores it — the hook is forward-looking. */ export interface VariantContext { axisValues: Record; priorVariants: Array<{ axisValues: Record; code: string; }>; } /** * Generate a React + TypeScript component from a ComponentSpec. * * @param spec - The component spec describing props, variants, shadcn base, and design tokens. * @param ctx - Codegen context providing the project path and design system registry. * @param variantCtx - Optional variant context when emitting one of N cartesian variants. * @returns ComponentCode with `component` (the .tsx source) and `barrel` (index.ts re-export). */ export declare function generateComponent(spec: ComponentSpec, ctx: CodegenContext, variantCtx?: VariantContext): ComponentCode; /** * Given a set of design tokens and an inline class string that may contain * hex colour values, replace known hex values with their Tailwind equivalents. * Also maps token values (from the registry) to Tailwind classes. * * @param classes - raw Tailwind class string, may contain hex values * @param tokens - design system tokens from registry * @returns - class string with hex values replaced by Tailwind classes */ /** * Generate a Storybook 8 CSF3 story file for a ComponentSpec. * Produces a Default story plus one story per variant. * Taps into the 4.6M weekly Storybook download ecosystem. */ export declare function generateStory(spec: ComponentSpec): string; export declare function substituteTokensInClasses(classes: string, tokens: DesignToken[]): string; export {};