@web-atoms/core-docs
Version:
66 lines • 3.13 kB
TypeScript
import { IValueConverter } from "./IValueConverter";
export interface IAtomComponent {
element: any;
viewModel: any;
localViewModel: any;
data: any;
app: {
callLater: (f: () => void) => void;
};
runAfterInit(f: () => void): void;
setLocalValue(e: any, name: string, value: any): void;
bindEvent(e: any, name: string, handler: any): any;
bind(e: any, name: string, path: any, twoWays: boolean, converter: any, source?: any): any;
}
/**
* Bindings needs to be cloned...
*/
export declare type bindingFunction<T extends IAtomComponent = IAtomComponent> = (control: T, e?: any) => any;
export declare type bindingFunctionCommand<T extends IAtomComponent = IAtomComponent> = (control: T, e?: any) => (p: any) => void;
export interface IData<T> extends IAtomComponent {
data: T;
}
export interface IVM<T> extends IAtomComponent {
viewModel: T;
}
export interface ILVM<T> extends IAtomComponent {
localViewModel: T;
}
export interface IBinder<T extends IAtomComponent> {
presenter(name?: string): Bind;
event(handler: (control: T, e?: CustomEvent) => void): any;
oneTime(path: bindingFunction<T>): Bind;
oneWay(path: bindingFunction<T>): Bind;
twoWays(path: bindingFunction<T>, events?: string[]): Bind;
}
export declare const bindSymbol: unique symbol;
export default class Bind {
readonly setupFunction: ((name: string, b: Bind, c: IAtomComponent, e: any, self?: any) => void);
readonly name?: string;
readonly eventList?: string[];
static forControl<C extends IAtomComponent>(): IBinder<C>;
static forData<D>(): IBinder<IData<D>>;
static forViewModel<D>(): IBinder<IVM<D>>;
static forLocalViewModel<D>(): IBinder<ILVM<D>>;
static presenter(name?: string): any;
static event<T extends IAtomComponent = IAtomComponent>(sourcePath: (control: T, e?: CustomEvent) => void): any;
static oneTime<T extends IAtomComponent = IAtomComponent>(sourcePath: bindingFunction<T>): any;
static command<T>(action: (p: T) => any): {
[bindSymbol](name: string, control: IAtomComponent, e: any): void;
};
static oneWayCommand<T extends IAtomComponent = IAtomComponent>(sourcePath: bindingFunctionCommand<T>): any;
static oneWay<T extends IAtomComponent = IAtomComponent>(sourcePath: bindingFunction<T>): any;
static twoWays<T extends IAtomComponent = IAtomComponent>(sourcePath: bindingFunction<T>, events?: string[], converter?: IValueConverter): any;
/**
* Use this for HTML only, this will fire two way binding
* as soon as the input/textarea box is updated
* @param sourcePath binding lambda expression
*/
static twoWaysImmediate<T extends IAtomComponent = IAtomComponent>(sourcePath: bindingFunction<T>): any;
readonly sourcePath: bindingFunction;
readonly pathList: string[][];
readonly thisPathList: string[][];
readonly combined: string[][];
constructor(setupFunction: ((name: string, b: Bind, c: IAtomComponent, e: any, self?: any) => void), sourcePath: bindingFunction, name?: string, eventList?: string[]);
}
//# sourceMappingURL=Bind.d.ts.map