import { ReactNode } from 'react'; /** * Final schema types (output types) * These types represent the final JSON schema output from dial-cli * These are DISTINCT from ParsedTypes - they represent the clean output format */ /** * Dial value types */ type DialValue = string | number | boolean | number[] | string[] | (boolean | number | string)[] | object | null | undefined; /** * Context passed to custom render functions */ interface DialCustomRenderContext { /** Get the current value of a dial field */ getValue: (name: string) => DialValue; /** Set the value of a dial field */ setValue: (name: string, value: DialValue) => void; /** The schema for this custom component */ schema: DialSchema; } /** * Custom render function type for dtype="custom" * Returns a React node to render in place of the standard dial input */ type DialCustomRenderFn = (context: DialCustomRenderContext) => ReactNode; /** * All supported data types for dial controls * This type represents the possible values for the dtype field in DialSchema */ type DialDtype = "boolean" | "number" | "number-int" | "int" | "string" | "text" | "number-rad" | "number-slider" | "select" | "color" | "vector" | "vector3" | "vector-6" | "number-group" | "euler" | "euler-rad" | "euler-deg" | "euler-pi" | "quaternion" | "array" | "tuple" | "interface" | "object" | "button" | "custom"; /** * Group schema (final output format) * Configuration for how properties within a group should be laid out */ interface GroupSchema { /** Group name */ name: string; /** Layout type: grid or flex */ layout?: "grid" | "flex"; /** Grid layout properties */ gridCols?: number; gridRows?: number; gridFlow?: "row" | "column"; gridRowTemplate?: string; gridColTemplate?: string; /** Flex layout properties */ flexWrap?: "nowrap" | "wrap" | "wrap-reverse"; flexJustifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly"; /** Group order for sorting */ groupOrder?: number; } /** * Nested type schema (output structure for complex types) * Used in PropertySchema.typeDefinition */ interface NestedTypeDefinition { /** * Property name (e.g., "args" for a property named args) */ name?: string; /** * Type name (e.g., "ExtrudeArgs" for a type ExtrudeArgs) */ type?: string; kind: "interface" | "tuple"; /** * Nested property schemas (processed output) */ schemas: DialSchema[]; /** * Group configurations for this level */ groups?: GroupSchema[]; } /** * Property schema (final output for a single property) * Clean output format with all dial configuration */ interface DialSchema { /** Property name */ name: string; /** Group this property belongs to */ grouping?: string; /** Nested type definition for complex types */ typeDefinition?: NestedTypeDefinition; dtype?: DialDtype; min?: number; max?: number; step?: number; placeholder?: string; tooltip?: string; default?: string | number | boolean; value?: unknown; options?: string[] | unknown[]; /** Display format for angle values: radians, degrees, or pi notation */ format?: "rad" | "deg" | "pi"; label?: string; icon?: string; helpText?: string; labelPosition?: string; mins?: number[]; maxs?: number[]; steps?: number[]; dtypes?: string[]; placeholders?: string[]; tooltips?: string[]; dimensions?: number; vectorCols?: number; vectorRows?: number; vectorFlow?: "row" | "column"; colSpan?: number; rowSpan?: number; arrayElementType?: string; order?: number; /** Click handler for button dtype (runtime only, not serialized) */ onClick?: () => void; /** Button variant style */ variant?: "primary" | "secondary" | "ghost" | "destructive" | "link"; /** Whether the control is disabled */ disabled?: boolean; /** * Custom render function for dtype="custom" (runtime only, not serialized) * * The render function receives context with getValue/setValue for accessing dial values. * Use useMemo to memoize the render function and avoid unnecessary re-renders. * * @example * ```tsx * const customRender = useMemo(() => ({ getValue, setValue }) => ( * setValue('myField', v)} * /> * ), []); * * // In schema: * { name: 'custom', dtype: 'custom', render: customRender } * ``` */ render?: DialCustomRenderFn; /** * Direct React node for dtype="custom" (runtime only, not serialized) * * Use this when you don't need access to getValue/setValue. * For simple static components or components that manage their own state. * * @example * ```tsx * // Simple static component * { name: 'info', dtype: 'custom', children: } * * // With useMemo for dynamic content (recommended) * const myComponent = useMemo(() => , [someValue]); * { name: 'custom', dtype: 'custom', children: myComponent } * ``` */ children?: ReactNode; } export type { DialCustomRenderContext as D, GroupSchema as G, NestedTypeDefinition as N, DialCustomRenderFn as a, DialDtype as b, DialSchema as c, DialValue as d };