UNPKG

asciitorium

Version:
37 lines (36 loc) 1.12 kB
import { Component, ComponentProps } from '../core/Component.js'; /** * Properties for Case component */ export interface CaseProps extends ComponentProps { /** The value to match against Switch condition */ when: string | number; /** Component class or function to instantiate when this case matches */ create?: any; /** Optional props to pass to the component */ with?: any; } /** * Case component for use within Switch. * * Creates a new component instance every time this case is matched, * ensuring proper lifecycle management and clean state. * * Usage: * ```tsx * <Case when="admin" create={AdminPanel} /> * <Case when="user" create={UserPanel} with={{ width: 50 }} /> * ``` * * WARNING: Do not use JSX children syntax - components will persist in memory! */ export declare class Case extends Component { readonly when: string | number; private readonly componentFactory?; constructor(props: CaseProps); /** * Returns the component factory function if provided. */ getComponentFactory(): (() => Component) | undefined; draw(): string[][]; }