interface DecoratorFactory { (t: T): T; } /** A Component class constructor (supports abstract classes) */ export type ComponentConstructor = (abstract new (config?: any) => T) & { isComponentType: true; prototype: T; }; /** Extract the config type from a Component class constructor */ export type ComponentConfigType = T extends abstract new (config?: infer C) => any ? C & { isComponentType?: never; } : unknown; /** Extract the instance type from a Component class constructor */ export type ComponentInstanceType = T extends abstract new (config?: any) => infer I ? I : Component; /** * Type representing any valid input to Component.create that will produce an instance of T. * * Accepts: * - An instance of T (pass-through) * - A constructor for T or any subtype * - A config object for T (when T has a known config type) * - A config object with `type` or `$type` property specifying the constructor * * @example * // In a Chart widget config: * interface ChartConfig { * xAxis?: Creatable; // Accepts NumericAxis, CategoryAxis, etc. * yAxis?: Creatable; * } * * // Usage: * // Just the type * // Config with type * // Instance */ type SubclassConstructor = ComponentConstructor>; type ResolveConfigType = 0 extends 1 & ComponentConfigType ? ComponentConfigType : ComponentConfigType; type ConfigWithType> = { type: TSubCtor; } & ResolveConfigType & (0 extends 1 & ComponentConfigType ? { [key: string]: unknown; } : {}); type ConfigWith$Type> = { $type: TSubCtor; } & ResolveConfigType & (0 extends 1 & ComponentConfigType ? { [key: string]: unknown; } : {}); export type CreateConfig = SubclassConstructor> = TSubCtor | ConfigWithType | ConfigWith$Type; export type Create = ComponentInstanceType | CreateConfig; /** * Type-checks a CreateConfig object based on its `type` or `$type` property. * This is a compile-time helper that returns the input unchanged at runtime. * Uses `const` type parameter (TypeScript 5.0+) to enable excess property checking. * * @example * // With type property * const axisConfig = validateConfig({ type: NumericAxis, min: 0, max: 100 }); * * // With $type property * const selectionConfig = validateConfig({ $type: KeySelection, bind: "selection" }); */ export declare function validateConfig(config: ({ type: TCtor; $type?: never; } & ComponentConfigType) | ({ $type: TCtor; type?: never; } & ComponentConfigType)): any; export declare class Component { static namespace: string; static isComponentType: true; static autoInit: boolean; static factory: (alias: string, config?: any, more?: any) => Component; isComponent: boolean; constructor(config?: any); init(): void; /** * * @param alias * @param type */ static alias(alias: string, type: T): void; static alias(alias: string): DecoratorFactory; /** * Creates a component instance from various input types. * * Supported signatures: * - Pass-through: If input is already a component instance, returns it unchanged * - Array: Maps over array elements, creating components for each * - Class type: Creates instance of the specified class with config * - Config with type/$type: Creates instance of the type specified in config * - String alias: Looks up registered alias and creates that type * - Plain config: Creates instance of the class `create` was called on * * @example * // Pass-through * const btn = new Button(); * Button.create(btn) // returns btn as Button * * // Class type with config * Button.create(Button, { text: "Click" }) // returns Button * * // Config with type property * Widget.create({ type: Button, text: "Click" }) // returns Button * * // Plain config on specific class * Button.create({ text: "Click" }) // returns Button with ButtonConfig typing */ static create(instance: T, unused?: any): T; static create(configs: [...T], more?: Record): { [K in keyof T]: T[K] extends { type: ComponentConstructor; } ? U : T[K] extends { $type: ComponentConstructor; } ? U : Component; }; static create>(config: ({ type: TCtor; $type?: never; isComponentType?: never; } | { $type: TCtor; type?: never; isComponentType?: never; }) & Partial>>, more?: Partial>>): T; static create>(type: TCtor, configs: ComponentConfigType>[], more?: Partial>>): T[]; static create>(type: TCtor, config?: ComponentConfigType>, more?: Partial>>): T; static create(this: { prototype: T; isComponentType: true; }, configs: ComponentConfigType>[], more?: Partial>>): T[]; static create(this: { prototype: T; isComponentType: true; }, config: ComponentConfigType>, more?: Partial>>): T; static create(this: { prototype: T; isComponentType: true; }, alias: string, config?: ComponentConfigType>, more?: Partial>>): T; } export declare function createComponentFactory(factory: any, jsxDriver: any, meta?: any): any; export declare function isComponentFactory(factory: any): boolean; export {}; //# sourceMappingURL=Component.d.ts.map