import type { Instance } from "./Instance"; import { Selector } from "../data/Selector"; import { AccessorChain } from "../data/createAccessorModelProxy"; export type Bind = { bind: string; defaultValue?: any; throttle?: number; debounce?: number; }; export type Tpl = { tpl: string; }; export type Expr = { expr: string; set?: (value: any, instance?: Instance) => boolean; throttle?: number; debounce?: number; }; export type Binding = Bind | Tpl | Expr; export type GetSet = { get: Selector; set?: (value: T, instance: Instance) => boolean; throttle?: number; debounce?: number; }; export interface StructuredSelector { [prop: string]: Selector; } export type Prop = T | Binding | Selector | AccessorChain | GetSet; export type WritableProp = Bind | AccessorChain; export interface DataRecord { [prop: string]: any; } export interface Config { [prop: string]: any; } export interface StructuredProp { [prop: string]: Prop; } /** * Utility type that extracts the resolved value type from a Prop. * Used to derive the runtime type of structured props. */ export type ResolveProp

= P extends Selector ? T : P extends AccessorChain ? T : P extends GetSet ? T : P extends Bind ? any : P extends Tpl ? string : P extends Expr ? any : P; /** * Utility type that resolves a structured prop object to its runtime value types. * Transforms { name: StringProp, count: NumberProp } to { name: string, count: number } */ export type ResolveStructuredPropType = { [K in keyof S]: ResolveProp; }; /** * Resolves the runtime value type from either a Prop or a StructuredProp. * Use this for generic widgets like ContentResolver and Validator where the * input can be either a single prop or a structured object. * * - For Prop (Selector, AccessorChain, GetSet), resolves to T * - For bindings (Bind, Tpl, Expr), resolves to any/string/any * - For structured objects, recursively resolves each property via ResolveStructuredProp * - For literal values, returns them as-is */ export type ResolvePropType

= P extends Selector ? T : P extends AccessorChain ? T : P extends GetSet ? T : P extends Bind ? any : P extends Tpl ? string : P extends Expr ? any : P extends object ? ResolveStructuredPropType

: P; /** * Generic structured prop type that provides type safety for params and their resolved values. * Use with ContentResolver and similar widgets to type the onResolve callback params. */ export type TypedStructuredProp> = { [K in keyof T]: Prop; }; export type StringProp = Prop; export type StyleProp = Prop | StructuredProp; export type NumberProp = Prop; export type BooleanProp = Prop; export type ClassProp = Prop | StructuredProp; export type RecordsProp = Prop; export type SortersProp = Prop; export type UnknownProp = Prop; export type ModProp = StringProp | StructuredProp; export type RecordAlias = string | { toString(): string }; export type SortDirection = "ASC" | "DESC"; export interface Sorter { field?: string; value?: (record: DataRecord) => any; direction: SortDirection; } export interface CollatorOptions { localeMatcher?: "lookup" | "best fit"; usage?: "sort" | "search"; sensitivity?: "base" | "accent" | "case" | "variant"; ignorePunctuation?: boolean; numeric?: boolean; caseFirst?: "upper" | "lower" | "false"; }