import { View } from "../data/View"; import { Controller } from "./Controller"; import { RenderingContext } from "./RenderingContext"; import type { Widget } from "./Widget"; /** * Serializable value types that can be safely passed through the framework */ export type SerializableValue = string | number | boolean | object | null | undefined; /** * Core instance data structure used by widgets * * For custom widget data, extend this interface: * @example * interface MyWidgetData extends WidgetData { * customProp: string; * } */ export interface WidgetData { visible?: boolean; disabled?: boolean; enabled?: boolean; text?: string; innerHtml?: string; attrs?: Record; data?: Record; classNames?: string; className?: string; class?: string; style?: Record | string; stateMods?: Record; mod?: Record; pressed?: boolean; icon?: string | boolean; confirm?: string | ConfirmConfig; parentDisabled?: boolean; parentStrict?: boolean; error?: string; } /** * Confirmation dialog configuration */ export interface ConfirmConfig { message: string; title?: string; yesText?: string; noText?: string; } /** * Parent options passed down from overlay/modal components * * For custom parent options, extend this interface: * @example * interface MyParentOptions extends ParentOptions { * customOption: string; * } */ export interface ParentOptions { dismiss?: () => void; } /** * Props object used for rendering (passed to React.createElement) */ export type RenderProps = Record; /** * Result type for yes/no dialogs */ export declare const enum YesNoResult { Yes = "yes", No = "no" } /** * Partial instance-like object used in some render methods * This is a hack to allow passing only the data property instead of full Instance */ export interface PartialInstance { data: Record; widget?: Widget; state?: Record; } /** * Example widget-specific properties for dropdown widgets */ export interface DropdownWidgetProps { lastDropdown?: Instance; dropdownOpen?: boolean; selectedIndex?: number; } /** * Example widget-specific properties for form field widgets */ export interface FieldWidgetProps { inputElement?: HTMLInputElement; validationState?: "valid" | "invalid" | "pending"; } /** * Type aliases for common widget instance types using intersection types */ export type DropdownInstance = Instance & DropdownWidgetProps; export type FieldInstance = Instance & FieldWidgetProps; /** * Base Instance class */ export declare class Instance = Widget> { widget: WidgetType; key: string; id: string; parent?: Instance; parentStore: View; store: View; controller?: Controller; data: Record; rawData: Record; state?: Record; cached: Record; cacheList?: Record | null; dataSelector?: (store: any) => Record; initialized?: boolean; visible?: boolean; explored?: boolean; prepared?: boolean; shouldUpdate?: boolean; childStateDirty?: boolean; detached?: boolean; needsExploreCleanup?: boolean; needsPrepare?: boolean; needsCleanup?: boolean; destroyTracked?: boolean; destroySubscriptions?: Array<() => void> | null; instanceCache?: InstanceCache | null; children?: Instance[]; helpers?: Record; components?: Record; vdom?: any; contentVDOM?: any; renderList?: any; assignedRenderList?: any; outerLayout?: Instance; contentPlaceholder?: any; parentOptions?: any; setters?: Record; record?: any; mappedRecords?: any[]; instances?: Instance[]; selected?: boolean; constructor(widget: WidgetType, key: string, parent?: Instance, parentStore?: any); setParentStore(parentStore: any): void; init(context: RenderingContext): void; checkVisible(context: RenderingContext): boolean; scheduleExploreIfVisible(context: RenderingContext): boolean; cache(key: string, value: any): boolean; markShouldUpdate(context: RenderingContext): void; explore(context: RenderingContext): void; prepare(context: RenderingContext): void; render(context: RenderingContext): null | Record | React.ReactNode[]; cleanup(context: RenderingContext): void; private trackDestroy; private trackDestroyableChild; subscribeOnDestroy(callback: () => void): () => void; destroy(): void; setState(state: Record): void; set(prop: string, value: any, options?: { internal?: boolean; immediate?: boolean; }): boolean; definePropertySetter(prop: string, setter: any): void; protected doSet(prop: string, value: any): boolean; nestedDataSet(key: string, value: any, dataConfig: Record, useParentStore?: boolean): boolean; replaceState(state: Record): void; getInstanceCache(): InstanceCache; clearChildrenCache(): void; getChild(context: RenderingContext | null, widget: Widget, key?: string | number | null, store?: any): Instance; getDetachedChild(widget: Widget, key: string, store?: any): Instance; prepareRenderCleanupChild(widget: any, store?: any, keyPrefix?: string, options?: any): any; getJsxEventProps(): Record | null; getCallback(methodName: string): (...args: any[]) => any; /** * Finds the first controller in the instance tree matching the predicate * @param predicate Function to test each controller * @returns The matching controller or undefined */ findController(predicate: (controller: Controller) => boolean): Controller | undefined; /** * Finds a controller of the specified type in the instance tree * @param type Controller class/constructor to find * @returns The matching controller cast to the specified type, or undefined */ findControllerByType(type: new (...args: any[]) => T): T | undefined; /** * Gets the first controller in the instance tree matching the predicate * @param predicate Function to test each controller * @returns The matching controller * @throws Error if no matching controller is found */ getController(predicate: (controller: Controller) => boolean): Controller; /** * Gets a controller of the specified type in the instance tree * @param type Controller class/constructor to find * @returns The matching controller cast to the specified type * @throws Error if no controller of the specified type is found */ getControllerByType(type: new (...args: any[]) => T): T; getControllerMethod(methodName: string): (...args: any[]) => any; invoke(methodName: string, ...args: any[]): any; invokeControllerMethod(methodName: string, ...args: any[]): any; } export declare class InstanceCache { children: Record; parent: Instance; marked: Record; monitored: Record | null; keyPrefix: string; constructor(parent: Instance, keyPrefix?: string | number | null); getChild(widget: Widget, parentStore: View, key?: string | number | null): Instance; addChild(instance: Instance): void; mark(): void; trackDestroy(instance: Instance): void; destroy(): void; sweep(): void; } //# sourceMappingURL=Instance.d.ts.map