uicore-ts
Version:
UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework tha
91 lines (90 loc) • 5.07 kB
TypeScript
export declare var nil: any;
declare global {
interface Window {
nil: any;
}
}
export type RecursiveRequired<T> = Required<{
[P in keyof T]: T[P] extends object | undefined ? RecursiveRequired<Required<T[P]>> : T[P];
}>;
export declare function wrapInNil<T>(object?: T): Required<T>;
export declare const YES = true;
export declare const NO = false;
export declare function IS<T>(object: T | undefined | null | false): object is T;
export declare function IS_NOT(object: any): object is undefined | null | false;
export declare function IS_DEFINED<T>(object: T | undefined): object is T;
export declare function IS_UNDEFINED(object: any): object is undefined;
export declare function IS_NIL(object: any): object is typeof nil;
export declare function IS_NOT_NIL<T>(object: T | undefined | null): object is T | undefined | null;
export declare function IS_LIKE_NULL(object: any): object is undefined | null;
export declare function IS_NOT_LIKE_NULL<T>(object: T | null | undefined): object is T;
export declare function IS_AN_EMAIL_ADDRESS(email: string): boolean;
export declare function FIRST_OR_NIL<T>(...objects: (T | undefined | null)[]): T;
export declare function FIRST<T>(...objects: (T | undefined | null)[]): T;
export declare function MAKE_ID(randomPartLength?: number): string;
export declare function RETURNER<T>(value?: T): (..._objects: any[]) => T | undefined;
export type UIIFBlockReceiver<T> = (functionToCall: () => any) => UIIFEvaluator<T>;
export type UIIFEvaluatorBase<T> = () => T;
export interface UIIFEvaluator<T> extends UIIFEvaluatorBase<T> {
ELSE_IF: (otherValue: any) => UIIFBlockReceiver<T>;
ELSE: (functionToCall: () => any) => T;
}
export declare function IF<T = any>(value: any): UIIFBlockReceiver<T>;
export declare class UIFunctionCall<T extends (...args: any) => any> {
isAUIFunctionCallObject: boolean;
parameters: Parameters<T>[];
constructor(...parameters: Parameters<T>);
callFunction(functionToCall: T): void;
}
export declare function CALL<T extends (...args: any) => any>(...objects: Parameters<T>): UIFunctionCall<T>;
export declare class UIFunctionExtender<T extends (...args: any) => any> {
isAUIFunctionExtenderObject: boolean;
extendingFunction: T;
static functionByExtendingFunction<T extends (...args: any) => any>(functionToExtend: T, extendingFunction: T): T & {
extendedFunction: T;
};
constructor(extendingFunction: T);
extendedFunction(functionToExtend: T): T & {
extendedFunction: T;
};
}
export declare function EXTEND<T extends (...args: any) => any>(extendingFunction: T): UIFunctionExtender<T>;
export declare class UILazyPropertyValue<T> {
isAUILazyPropertyValueObject: boolean;
initFunction: () => T;
constructor(initFunction: () => T);
setLazyPropertyValue(key: string, target: object): void;
}
export declare function LAZY_VALUE<T>(initFunction: () => T): UILazyPropertyValue<T>;
export type UIInitializerObject<T> = {
[P in keyof T]?: T[P] extends (...args: any) => any ? UIFunctionCall<T[P]> | UIFunctionExtender<T[P]> | T[P] : T[P] extends object ? UIInitializerObject<T[P]> | UILazyPropertyValue<T[P]> : Partial<T[P]>;
};
export declare class UIObject {
constructor();
get class(): any;
get superclass(): any;
isKindOfClass(classObject: any): boolean;
isMemberOfClass(classObject: any): boolean;
static annotationsMap: WeakMap<any, Function[]>;
static recordAnnotation(annotation: Function, target: Function): void;
static classHasAnnotation(classObject: Function, annotation: Function): boolean | undefined;
static annotationsOnClass(classObject: Function): Function[];
static wrapObject<T>(object: T): UIObject & T;
valueForKey(key: string): any;
valueForKeyPath<T = any>(keyPath: string, defaultValue?: T): T | undefined;
static valueForKeyPath<T = any>(keyPath: string, object: any, defaultValue?: T): T | undefined;
setValueForKeyPath(keyPath: string, value: any, createPath?: boolean): boolean;
static setValueForKeyPath(keyPath: string, value: any, currentObject: any, createPath: boolean): boolean;
configureWithObject(object: UIInitializerObject<this>): UIInitializerObject<this>;
configuredWithObject(object: UIInitializerObject<this>): this;
static configureWithObject<TargetObjectType extends object, ConfigurationObjectType extends UIInitializerObject<TargetObjectType>>(configurationTarget: TargetObjectType, object: ConfigurationObjectType): ConfigurationObjectType;
static configuredWithObject<T extends object>(configurationTarget: T, object: UIInitializerObject<T>): T;
get methods(): MethodsOnly<Omit<this, "methods">>;
performFunctionWithSelf<T>(functionToPerform: (self: this) => T): T;
performingFunctionWithSelf(functionToPerform: (self: this) => void): this;
performFunctionWithDelay(delay: number, functionToCall: Function): void;
}
export type MethodsOnly<T> = Pick<T, {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T]>;
export type ValueOf<T> = T[keyof T];