declare module 'tabris-decorators/internals/utils' { export type BaseConstructor = Function & { prototype: T; }; export type Constructor = new (...args: any[]) => T; export type ParameterDecoratorFactory = (target: Constructor, property: string, index: number) => void; export type ClassDecoratorFactory = (type: Constructor) => void; export type CustomPropertiesInfo = { [prop in keyof T]?: PropInfo; }; export interface ParamInfo { type: Constructor; injectParam?: string; inject?: boolean; } export interface PropInfo { inject: boolean; } export type Decorator = (target: T, property?: string, index?: number) => T | void; /** * Takes a callback a decorator function and when possible calls it with the appropriate arguments, * or returns it so it can be can be called later. Rethrows exceptions by the function with an * appropriate error message. */ export function applyDecorator(name: string, args: any[], decorator: Decorator): any; /** * Determines whether a decorator was applied with arguments (dynamic, e.g. "@foo(1,2,2)") * or without (static, e.g. "@foo"). */ export function areStaticDecoratorArgs(args: any[]): boolean; /** * Determines whether a class decorator was applied with arguments (dynamic, e.g. "@foo(1,2,2)") * or without (static, e.g. "@foo"). */ export function areStaticClassDecoratorArgs(args: any[]): boolean; /** * Defines the a getter on the given prototype. If the prototype already has a getter or setter of that name the * function throws. */ export function defineGetter(proto: any, property: string, get: () => any): void; /** * Gets the type (constructor) of the property as emitted by tsc. * Returns the Object constructor if the type can not be represented * by tsc properly at runtime, OR if the compiler option * emitDecoratorMetadata is not enabled. */ export function getPropertyType(proto: any, property: string): Constructor; /** * Returns true if type information was emitted by tsc for this property. */ export function hasPropertyType(proto: any, property: string): boolean; /** * Gets the type of the parameter. If the type can not be represented properly at runtime this throw an error. */ export function getParameterType(fn: any, index: number): Constructor; /** * Gets array of injection data for each parameter of the given function * If none exists it will be created */ export function getOwnParamInfo(fn: any): ParamInfo[]; /** * Gets array of injection data for each parameter of the given function * If none exist and the function is a constructor, the super constructor will checked. * If none exists in the entire chain, null will be returned. */ export function getParamInfo(fn: any): ParamInfo[] | null; export function getCustomProperties(target: T): CustomPropertiesInfo; export function getPropertyInfo(target: T, prop: keyof T): PropInfo; export function hasInjections(fn: any): boolean; export function isPrimitiveType(type: BaseConstructor): boolean; } declare module 'tabris-decorators/api/interfaces' { export { Constructor, BaseConstructor } from 'tabris-decorators/internals/utils'; export { TypeGuard, BindingConverter } from 'tabris-decorators/internals/utils-databinding'; } declare module 'tabris-decorators/internals/Conversion' { import { BindingConverter, Constructor } from 'tabris-decorators/api/interfaces'; export type ConversionOptions = { value: any; proto: Target; name: string; convert?: BindingConverter; fallback?: any; }; export class Conversion { readonly proto: Target; readonly property: Property; static convert(options: ConversionOptions): any; private result; private resolved; private targetMatched; private constructor(); targets(type: Constructor, name?: CandidateProperty): this is Conversion; resolve(value: Property extends keyof Target ? Target[Property] : never): void; } } declare module 'tabris-decorators/internals/utils-databinding' { import { Composite, EventObject, Selector, Widget, WidgetCollection } from 'tabris'; import { BaseConstructor, Constructor } from 'tabris-decorators/internals/utils'; import { Conversion } from 'tabris-decorators/internals/Conversion'; const wasAppendedKey: unique symbol; export const originalAppendKey: unique symbol; export type Direction = '<<' | '>>' | ''; export type WidgetInterface = { [prop: string]: any; [originalAppendKey]: typeof Composite.prototype.append; [wasAppendedKey]: boolean; } & Widget & WidgetProtected & EventTarget; export type TypeGuard = (v: T) => boolean; export type UserType = Constructor; export type WidgetProtected = { _find(selector?: Selector): WidgetCollection; _find(constructor: new (...args: any[]) => U): WidgetCollection; }; export type ParamInfo = { type: Constructor; injectParam?: string; inject?: boolean; }; export type PostAppendHandler = (widgetInstance: WidgetInterface) => void; export type TargetPath = [Direction, string, string]; export type Binding = { path: string; converter?: BindingConverter; }; export type BoundListener> = (this: ComponentType, ev: EventObjectType) => any; export type BindingValue = string | Binding; type Bindable = BindingValue | BindingValue[] | BoundListener>; export type MultipleBindings = { [Property in keyof ModelType]?: Bindable; }; export type BindingConverter = (v: From, conversion: Conversion) => any | void; /** * Gets list of functions to be executed after first time append is called on instances of the given * widget prototype or instance. */ export function postAppendHandlers(widget: WidgetInterface): PostAppendHandler[]; /** * Gets map for the purpose of storing property values of the given instance. */ export function getPropertyStore(instance: any): Map; export function checkPropertyExists(targetWidget: any, targetProperty: string, errorPrefix?: string): void; export function trigger(target: Partial, type: string, eventData: any): void; export function markAsAppended(widget: WidgetInterface): void; export function isAppended(widget: WidgetInterface): boolean; export function checkAppended(widget: WidgetInterface): void; export function parseTargetPath(targetPath: string): TargetPath; export function checkPathSyntax(targetPath: string): void; export function markAsComponent(type: BaseConstructor): void; export function checkIsComponent(widget: Widget): void; export {}; } declare module 'tabris-decorators/api/checkType' { import { BaseConstructor } from 'tabris-decorators/internals/utils'; /** * Performs type checks on the given value. If the check fails the function throws an error message stating the reason. * * The following rules apply: * * Object constructor passes any value * * Object values may be an instance of the given class or any class extending it. * * Primitive types are represented by their boxed type, e.g. a number is `Number`. * * Null and undefined pass unless 'strict' is true * * Boxed values never pass. */ export function checkType(value: any, type: BaseConstructor, strict?: boolean): void; export function isType(value: any, type: BaseConstructor, strict?: boolean): boolean; export function getValueString(value: any): string; export function getTypeName(type: BaseConstructor): string; } declare module 'tabris-decorators/api/convert' { export function convert(value: unknown, type: Function): any; } declare module 'tabris-decorators/api/equals' { export type CompareFn = (valueA: unknown, valueB: unknown) => boolean; export type CompareMode = 'strict' | 'shallow' | 'auto' | CompareFn; export type ValuePair = [T, T]; export type CustomEquals = { equals(value: any): boolean; }; /** * Returns true if the two given values are equal. */ export function equals(values: ValuePair, mode: CompareMode): boolean; } declare module 'tabris-decorators/decorators/property' { import { CompareMode } from 'tabris-decorators/api/equals'; import { CustomPropertyDescriptor } from 'tabris-decorators/internals/CustomPropertyDescriptor'; import { TypeGuard, UserType } from 'tabris-decorators/internals/utils-databinding'; export type CustomPropertyDecorator = (target: Target, property: Name) => void; export type Converter = 'off' | 'auto' | ((value: unknown) => T); export type PropertyDecoratorConfig = TypeGuard | UserType | PropertySuperConfig; export type PropertyInitializer = (instance: Proto, descriptor: CustomPropertyDescriptor) => Proto; export type PropertySuperConfig = { typeGuard?: TypeGuard; type?: UserType; convert?: Converter; equals?: CompareMode; nullable?: boolean; default?: T; observe?: boolean; }; /** * This decorator makes an instance property fire change events, thereby making it bindable. * * `@property` can be used on any class. A matching change event may (optionally) * be declared explicitly to be able to attach listeners. Example: * * ```ts * ‍@property myText: string; * ‍@event readonly onMyTextChanged: ChangeListeners; * ``` * * *Notes:* * * *In TypeScript files `@property` will perform implicit value checks for most types.* * * *In JavaScript files `@property({type: Type})` can be used to enable the same * kind of value checks.* * * *Use `@property(typeGuard)` or `@property({typeGuard: typeGuard})` * to perform explicit value checks in either TypeScript or JavaScript.* * * *Use `@property({default: value})` to define the property default value. * * *Use `@property({nullable: false})` to disallow `null` and `undefined`values. * * *Use `@property({equals: 'auto'})` to relax equality check for objects. * * *Use `@property({convert: 'auto'})` to automatically convert the value to the property's type. */ export function property(targetProto: object, propertyName: string | symbol): void; /** * This decorator makes an instance property fire change events, thereby making it bindable. * * `@property` can be used on any class. A matching change event may (optionally) * be declared explicitly to be able to attach listeners. Example: * * ```ts * ‍@property myText: string; * ‍@event readonly onMyTextChanged: ChangeListeners; * ``` * * *Notes:* * * *In TypeScript files `@property` will perform implicit value checks for most types.* * * *In JavaScript files `@property({type: Type})` can be used to enable the same * kind of value checks.* * * *Use `@property(typeGuard)` or `@property({typeGuard: typeGuard})` * to perform explicit value checks in either TypeScript or JavaScript.* * * *Use `@property({default: value})` to define the property default value. * * *Use `@property({nullable: false})` to disallow `null` and `undefined`values. * * *Use `@property({equals: 'auto'})` to relax equality check for objects. * * *Use `@property({convert: 'auto'})` to automatically convert the value to the property's type. * * *Use `@property({observe: true})` to propagate change events from the assigned object */ export function property(check: PropertyDecoratorConfig): CustomPropertyDecorator; } declare module 'tabris-decorators/internals/CustomPropertyDescriptor' { import { Constructor } from 'tabris-decorators/internals/utils'; import { PropertyInitializer, PropertySuperConfig } from 'tabris-decorators/decorators/property'; export type CustomPropertyConfig = PropertySuperConfig & { initializer?: PropertyInitializer; readonly?: boolean; }; export type InternalChangeHandler = (instance: Proto, value: TargetType, oldValue: TargetType) => void; export const autoDefault: unique symbol; export class CustomPropertyDescriptor { private readonly proto; private readonly propertyName; private static readonly metaDataKey; static get(proto: CandidateProto, propertyName: keyof CandidateProto & string): CustomPropertyDescriptor; static isUnchecked(target: object, propertyName: PropertyName): boolean; static has(target: any, propertyName: PropertyName): target is { [name in PropertyName]: any; }; hasDataSource: boolean; readonly enumerable = true; readonly configurable = true; readonly get: () => TargetType; readonly set: (value: TargetType) => void; readonly changeHandler: Array>; private userType; private typeGuard; private readonly targetType; private equals; private convert; private youHaveBeenWarned; private defaultValue; private nullable; private readonly; private observe; private initializer; constructor(proto: Proto, propertyName: keyof Proto & string); addConfig(config: CustomPropertyConfig): void; toString(): string; get type(): Constructor; private setValue; private getValue; private isUnchecked; private checkType; private setUserType; private addTypeGuard; private setCompareMode; private setInitializer; private setConverter; private setNullable; private setReadonly; private setObserve; private setDefaultValue; private getType; private isConvertible; private handleTypeMissing; } } declare module 'tabris-decorators/decorators/inject' { import 'reflect-metadata'; import { Injector } from 'tabris-decorators/api/Injector'; import { Decorator } from 'tabris-decorators/internals/utils'; export type InjectDecorator = typeof unboundInject; export function bindDecoratorInject(injector: Injector): typeof unboundInject; /** * A decorator that marks a constructor parameter for injections based on the type of the parameter: * ``` * constructor(@inject a: ClassA) { ... } * ``` * A parameter can be passed to the injector (see `@injectable` and `@injectionHandler`) like this: * ``` * constructor(@inject('some value') a: ClassA) { ... } * ``` */ export function unboundInject(param: string): Decorator; export function unboundInject(target: object, property: string, index?: number): void; } declare module 'tabris-decorators/decorators/injectable' { import 'reflect-metadata'; import { InjectionParameter, Injector } from 'tabris-decorators/api/Injector'; import { BaseConstructor, ClassDecoratorFactory, Constructor } from 'tabris-decorators/internals/utils'; export type InjectableDecorator = typeof unboundInjectable; export function bindDecoratorInjectable(injector: Injector): typeof unboundInjectable; /** * A decorator that makes a class injectable via `@inject` or `resolve(type)`. * It can be injected as itself or as any of its super-classes: * * ``` * ‍@injectable class Foo2 extends Foo { ... } * ``` * A configuration object can be passed: * ``` * ‍@injectable({opt: value}) * class Foo2 extends Foo { ... } * ``` * The object can have any of these entries: * - `shared: boolean`: when `true`this makes the class effectively a singleton * - `implements: OtherClass`: allows the class to be injected as `OtherClass` * - `priority: number`: The priority of this class relative to other compatible injectables. Defaults to 0. * - `param: value`: allows injection only when `@inject(param)` gives the exact same parameter value. */ export function unboundInjectable(config: InjectableConfig): ClassDecoratorFactory; export function unboundInjectable(type: Constructor): void; export interface InjectableConfig { shared?: boolean; priority?: number; implements?: BaseConstructor; param?: InjectionParameter; } export const injectableKey: unique symbol; } declare module 'tabris-decorators/decorators/injectionHandler' { import { Injection, Injector } from 'tabris-decorators/api/Injector'; import { BaseConstructor } from 'tabris-decorators/internals/utils'; export type IHFunction = (injection: Injection) => T | void; export type IHDescriptor = TypedPropertyDescriptor>; export type CoreInjectionHandlerDecorator = (target: BaseConstructor, propertyName: string, descriptor: IHDescriptor) => void; export type InjectionHandlerDecorator = typeof unboundInjectionHandler; export function bindDecoratorInjectionHandler(injector: Injector): typeof unboundInjectionHandler; /** * Registers a static method to handle injections for the given type: * ``` * ‍@injectionHandler(MyServiceClass) * static createMyServiceClass(injection: Injection) { * return new MyServiceClass(someArg); * } * ``` * A priority may also be given, defaults to 0: * ```ts * @injectionHandler({targetType: MyServiceClass, priority: 2}) * ``` * * The decorated method must return a value compatible to the given type or `null`/`undefined`. * The method is passed an `Injection` object with the following fields: * - `type`: The exact type that was requested. * - `injector`: The `Injector` instance the injection handler is registered with. * - `param`: An injection parameter that may have been passed via `@inject(param)` or `resolve(type, param)` */ export function unboundInjectionHandler(targetType: BaseConstructor): CoreInjectionHandlerDecorator; export function unboundInjectionHandler(param: { targetType: BaseConstructor; priority?: number; }): CoreInjectionHandlerDecorator; } declare module 'tabris-decorators/decorators/shared' { import { Injector } from 'tabris-decorators/api/Injector'; import { Constructor } from 'tabris-decorators/internals/utils'; export type SharedDecorator = typeof unboundShared; export function bindDecoratorShared(injector: Injector): typeof unboundShared; export function unboundShared(type: Constructor): void; } declare module 'tabris-decorators/internals/applyJsxBindings' { import 'reflect-metadata'; import { Widget } from 'tabris'; import { Severity } from 'tabris-decorators/internals/ExtendedJSX'; import { BindingConverter } from 'tabris-decorators/internals/utils-databinding'; export interface JsxBindings { [targetProperty: string]: string; } export function applyJsxBindings(targetInstance: Widget, bindings: JsxBindings, safety: Severity): void; export function getOneWayBindings(instance: Widget): OneWayBinding[]; export function clearOneWayBindings(instance: Widget): void; export interface OneWayBinding { type: 'bind' | 'template'; converter: BindingConverter; bindingString: string; target: Widget; targetProperty: string; path: string[]; fallbackValue: any; } } declare module 'tabris-decorators/internals/ExtendedJSX' { import { JsxProcessor, NativeObject } from 'tabris'; import { Injector } from 'tabris-decorators/api/Injector'; export interface Properties { [property: string]: any; } export type JsxConstructor = { prototype: JSX.ElementClass; new (): object; }; export type JsxNativeType = { prototype: JSX.ElementClass; new (): NativeObject; }; export type JsxInfo = { source: unknown; } | { processor: ExtendedJSX; componentType: JsxConstructor; sfc: ((param: object) => any); attributes: object; children: JsxInfo[]; }; export function getJsxInfo(source: any): JsxInfo; export function setInjectorOverride(target: JsxConstructor, injector: Injector): void; export type Severity = 'warn' | 'error'; export class ExtendedJSX extends JsxProcessor { private readonly injector; unsafeBindings: Severity; constructor(injector: Injector); createCustomComponent(type: JsxConstructor, attributes: any): JSX.ElementClass | string; createFunctionalComponent(type: ((param: object) => any), attributes: any): JSX.ElementClass | string; createNativeObject(Type: JsxNativeType, attributes: Properties): NativeObject; private extractBindings; private convertType; } } declare module 'tabris-decorators/api/Injector' { import { InjectDecorator } from 'tabris-decorators/decorators/inject'; import { InjectableDecorator } from 'tabris-decorators/decorators/injectable'; import { InjectionHandlerDecorator } from 'tabris-decorators/decorators/injectionHandler'; import { SharedDecorator } from 'tabris-decorators/decorators/shared'; import { ExtendedJSX } from 'tabris-decorators/internals/ExtendedJSX'; import { BaseConstructor } from 'tabris-decorators/internals/utils'; export type InjectionParameter = object | string | number | boolean | null; export type CreateFunction = typeof Injector.prototype.create; export type ResolveFunction = typeof Injector.prototype.resolve; export type RegisterFunction = typeof Injector.prototype.register; export interface HandlerRegistration { targetType: BaseConstructor; handler: InjectionHandlerFunction; priority?: number; } export interface Injection { type: BaseConstructor; param: InjectionParameter; injector: Injector; } export type InjectionHandlerFunction = (injection: Injection) => T | null | undefined; /** * An `Injector` instance manages injection handlers and fulfills injections. * * You may create your own instance of `Injector` if you wish to keep your injection * handlers separate from those kept in the global `injector` object exported * by `tabris-decorators`. You must then use the attached decorators and `JSX` object * instead of the global ones. */ export class Injector { /** * Returns the instance of Injector that was used to create the given object. * Given a class decorated with @inject or @shared it returns the injector * associated with these. */ static get(object: object, fallback?: Injector): Injector; readonly injectionHandler: InjectionHandlerDecorator; readonly inject: InjectDecorator; readonly injectable: InjectableDecorator; readonly shared: SharedDecorator; /** * This object needs to be present in the module namespace to allow JSX expressions that * use this `Injector` instance to fulfill injections. E.g. * ``` * const JSX = injector.jsxProcessor; // shadows global JSX object * ``` * Or to set it as the default for all JSX elements globally: * ``` * JSX.install(injector.jsxProcessor); * ``` */ readonly jsxProcessor: ExtendedJSX; private handlers; private injectionStack; private resolveQueue; /** * Registers a value as a shared injectable for the given type. * Equivalent to calling `addHandler(type, () => value)` or using * `@shared`. */ register: (targetType: BaseConstructor, value: U) => U; /** * Explicitly registers a new injection handler. Same as using the attached `injectionHandler` * decorator. */ addHandler: { (targetType: BaseConstructor, handler: InjectionHandlerFunction): void; (param: HandlerRegistration): void; }; /** * Returns an instance for an injectable type, just like using the `@inject` decorator * would do in a constructor. */ resolve: (type: BaseConstructor, param?: InjectionParameter) => T; /** * `create(type: Class, ...parameters: any[])` * * Creates an instance of the given class and fills in all the constructor parameters decorated with `@inject`. * Parameters given after the type will be passed to the constructor, potentially overriding * the injection value. */ create: (type: new (arg1?: U, arg2?: V, arg3?: W, ...remaining: any[]) => T, arg1?: U, arg2?: V, arg3?: W, ...remaining: any[]) => T; private scheduleResolveProperties; private resolvePropertyInjections; private findHandlerRegistrations; private getUnboxer; private passValue; private unboxValue; private forEachPrototype; private tagResult; } export const injector: Injector; } declare module 'tabris-decorators/internals/subscribe' { export function subscribe(root: any, path: string[], cb: (value: unknown) => void): () => void; export function supportsChangeEvents(target: Partial, targetProperty: string): boolean; } declare module 'tabris-decorators/internals/processOneWayBindings' { import 'reflect-metadata'; import { Widget } from 'tabris'; import { OneWayBinding } from 'tabris-decorators/internals/applyJsxBindings'; import { WidgetInterface } from 'tabris-decorators/internals/utils-databinding'; export function processOneWayBindings(base: WidgetInterface, target: Widget): void; export function initOneWayBinding(base: WidgetInterface, binding: OneWayBinding): void; } declare module 'tabris-decorators/decorators/component' { import 'reflect-metadata'; import { Composite } from 'tabris'; import { Injector } from 'tabris-decorators/api/Injector'; import { Constructor } from 'tabris-decorators/internals/utils'; type ComponentOptions = { injector?: Injector; }; type ComponentDecorator = >(arg: T) => T; /** * A decorator for classes extending `Composite` (directly or indirectly), * otherwise known as a "custom component". * * Encapsules instances of the decorated class and enables data binding features. * * Example for a one-way binding between property `myText` of the decorated * class and property `text` of a child element: * * ```jsx * this.append( * * ); * ``` * * *Notes:* * * *This works on all children (direct or indirect) of the component. * * *Consult the developer guide article on `@component` for further details of one-way bindings.* * * *Due to the encapsulation feature children of the component are only accessible * using either `@getById` or the protected `_children`, `_find` and `_apply` methods.* * * *For creating two-way bindings use `@bind` and `@bindAll`.* */ export function component>(arg: T): T; export function component(options: ComponentOptions): ComponentDecorator; export {}; } declare module 'tabris-decorators/api/StateProvider' { import { Action as GenericAction, DefaultActions, DefaultRootState } from 'tabris-decorators'; import { Widget } from 'tabris'; import { ActionMapper } from 'tabris-decorators/api/ActionMapper'; export type MappedRules = { [selector: string]: { [props: string]: any; }; }; export type StateMapper = (state: RootState) => MappedState & { apply?: MappedRules; }; export interface Action { type: T; } export type AnyAction = DefaultActions[keyof DefaultActions] | { type: typeof NO_ACTION; }; export type Dispatch = (action: A) => A; export type HookOptions = { stateProvider: StateProvider; target: Target; stateMapper?: StateMapper, RootState>; actionMapper?: ActionMapper; }; export const NO_ACTION: unique symbol; export class StateProvider { static hook(options: HookOptions): void; constructor(original: Partial>); getState(): State; subscribe(cb: () => void): void; dispatch: Dispatch; } } declare module 'tabris-decorators/api/ActionMapper' { import { Action as GenericAction, Dispatch } from 'tabris-decorators'; import { EventOfListeners, Listeners, UnpackListeners } from 'tabris'; import { MappedRules } from 'tabris-decorators/api/StateProvider'; export type ActionMapper = ActionMapperFunction | ActionMapperObject; export type ActionMapperFunction = (dispatch: Dispatch) => Callbacks; export type ActionMapperObject = { [Key in CallbackKeysOf]?: ActionCreator; } & { apply?: MappedRules; }; export type Callback = (...args: any[]) => any; export type Callbacks = { [Key in CallbackKeysOf]?: UnpackListeners; } & { apply?: MappedRules; }; type ActionCreator = TargetFunction extends Listeners ? (ev: EventOfListeners) => Action : TargetFunction extends (...args: any[]) => any ? (...args: Parameters) => Action : any; type FunctionKeysOf = { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]; type Forbidden = 'append' | 'children' | 'find' | 'apply' | 'appendTo' | 'insertBefore' | 'insertAfter' | 'detach' | 'siblings' | 'animate' | 'dispose' | 'toString' | 'constructor' | 'bounds' | 'absoluteBounds'; type CallbackKeysOf = FunctionKeysOf>; export {}; } declare module 'tabris-decorators/decorators/connect' { import { Action as GenericAction, AnyAction, DefaultRootState } from 'tabris-decorators'; import 'reflect-metadata'; import { Properties, Widget } from 'tabris'; import { ActionMapper, ActionMapperFunction } from 'tabris-decorators/api/ActionMapper'; import { StateMapper } from 'tabris-decorators/api/StateProvider'; import { Constructor } from 'tabris-decorators/internals/utils'; export type Connectable = Constructor | ((attributes?: any) => U); export type StateToProps = StateMapper>; export type DispatchToProps = ActionMapperFunction; export function connect(mapState: StateMapper : Partial, RootState> | null, mapDispatchToProps?: ActionMapper): >(target: T) => T; } declare module 'tabris-decorators/decorators/prop' { import { CustomPropertyDecorator, PropertyDecoratorConfig } from 'tabris-decorators/decorators/property'; /** * This decorator makes an instance property fire change events, thereby making it bindable. * * `@prop` can be used on any class. A matching change event may (optionally) * be declared explicitly to be able to attach listeners. Example: * * ```ts * ‍@prop myText: string; * ‍@event readonly onMyTextChanged: ChangeListeners; * ``` * * *Notes:* * * *In TypeScript files `@prop` will perform implicit value checks for most types.* * * *In JavaScript files `@prop({type: Type})` or `@prop(Type)` can be used to enable the same * kind of value checks.* * * *`@prop(config)` supports all the same options as `@property(config)`, but uses different defaults.* */ export function prop(targetProto: object, propertyName: string | symbol): void; /** * This decorator makes an instance property fire change events, thereby making it bindable. * * `@prop` can be used on any class. A matching change event may (optionally) * be declared explicitly to be able to attach listeners. Example: * * ```ts * ‍@prop myText: string; * ‍@event readonly onMyTextChanged: ChangeListeners; * ``` * * *Notes:* * * *In TypeScript files `@prop` will perform implicit value checks for most types.* * * *In JavaScript files `@prop({type: Type})` or `@prop(Type)` can be used to enable the same * kind of value checks.* * * *`@prop(config)` supports all the same options as `@property(config)`, but uses different defaults.* */ export function prop(check: PropertyDecoratorConfig): CustomPropertyDecorator; } declare module 'tabris-decorators/decorators/event' { /** * A decorator that can be attached to a property of the type `Listeners`. * * The name of the property must start with "on", e.g. "onMyEvent". * The property will become read-only and contain a `Listeners` instance * that is configured to dispatch events on the object it is attached to. * * When used on a widget the `Listeners` instance will be integrated in * the existing event system. Events triggered via one API will also be issued via the other. */ export function event(targetProto: object, evPropertyName: string): void; export function eventType(evPropertyName: string): string; } declare module 'tabris-decorators/internals/TwoWayBinding' { import { BindingConverter, TargetPath, WidgetInterface } from 'tabris-decorators/internals/utils-databinding'; import { BindSuperConfig } from 'tabris-decorators/decorators/bind'; type LocalPath = [string, string?]; export class TwoWayBinding { private readonly component; private readonly localPath; private readonly targetPath; private readonly convert; static create(component: WidgetInterface, config: BindSuperConfig): void; private initialized; private target; private targetProperty; private direction; private suspended; private fallback; private cancelLocal; private cancelTarget; constructor(component: WidgetInterface, localPath: LocalPath, targetPath: TargetPath, convert: BindingConverter | null); toString(): string; private init; private dispose; private subscribeToLocalValue; private subscribeToTargetValue; private applyFallbackToLocal; private syncBackToTarget; private targetHasPriority; private toLocalValue; private toTargetValue; private subscribe; private setLocalValue; private getLocalValue; private getSourceObject; private getSourcePropertyName; private hasValidSource; private setTargetValue; private getTargetValue; private checkPropertySafety; private getTarget; private bindsToModel; } export {}; } declare module 'tabris-decorators/decorators/bind' { import { Composite } from 'tabris'; import { Converter, CustomPropertyDecorator, PropertySuperConfig } from 'tabris-decorators/decorators/property'; import { BindingConverter, BoundListener, MultipleBindings, TargetPath, WidgetInterface } from 'tabris-decorators/internals/utils-databinding'; export type BindAllConfig = PropertySuperConfig & { all: MultipleBindings; }; export type BindSingleConfig = Omit, 'convert'> & { path: string; convert?: Converter | { property?: Converter; binding?: BindingConverter; }; }; export type BindSuperConfig = Omit, 'convert'> & { componentProto: WidgetInterface; componentProperty: string; targetPath: TargetPath | null; all: MultipleBindingsInternal | null; convert: { property?: Converter; binding?: BindingConverter; }; }; export type BindingInternal = { path: TargetPath; converter: BindingConverter; }; export type MultipleBindingsInternal = { [sourceProperty: string]: BindingInternal[] | BoundListener | null; }; export type BindAllDecorator = (target: Target, property: PropertyName) => void; /** * A decorator for instance properties of classes extending `Composite`, i.e. a custom component. * It creates a two-way binding between the decorated property and a child (direct or indirect) * of the component. Example: * * ```ts * ‍@bind('#childId.text') * myProp: string = 'foo'; * ``` * * *Notes:* * * *`@bind` behaves like `@property` in most regards.* * * *Like `@property` it also supports the `typeGuard` and `type` options.* * * *Use`@bind({all: bindings})` or `@bindAll(bindings)` to create bindings to a model.* * * *`@bind(path, converter)` is the same as `@bind({path: path, converter: {binding: converter}})`.* * * *In addition to id selectors, type selectors and `:host` are also supported.* */ export function bind(config: string, bindingConverter?: BindingConverter): CustomPropertyDecorator; /** * A decorator for instance properties of classes extending `Composite`, i.e. a custom component. * It creates a two-way binding between the decorated property and a child (direct or indirect) * of the component. Example: * * ```ts * ‍@bind('#childId.text') * myProp: string = 'foo'; * ``` * * *Notes:* * * *`@bind` behaves like `@property` in most regards.* * * *Like `@property` it also supports the `typeGuard` and `type` options.* * * *Use`@bind({all: bindings})` or `@bindAll(bindings)` to create bindings to a model.* * * *`@bind(path, converter)` is the same as `@bind({path: path, converter: {binding: converter}})`.* * * *In addition to id selectors, type selectors and `:host` are also supported.* */ export function bind(config: BindSingleConfig): CustomPropertyDecorator; /** * A decorator for instance properties of classes extending `Composite`, i.e. a custom component. * It creates a two-way binding between properties of a model (e.g. an object using `@property`) * and children (direct or indirect) of the component. Example: * * ```ts * ‍@bind(all: { * modelPropA: '#childId1.text' * modelPropB: '#childId2.selection' * }}) * myProp: MyModel; * ``` * * *Notes:* * * *`@bind` behaves like `@property` and supports all the same configuration options.* * * *Use`@bind(path)` or `@bind({path: path})` to create bindings to the component property itself.* * * *`@bindAll(bindings)` can be used as a shorthand for `@bind({all: bindings})`.* * * *In addition to id selectors, type selectors and `:host` are also supported.* */ export function bind(config: BindAllConfig): CustomPropertyDecorator; } declare module 'tabris-decorators/decorators/bindAll' { import { Composite } from 'tabris'; import { MultipleBindings } from 'tabris-decorators/internals/utils-databinding'; import { CustomPropertyDecorator } from 'tabris-decorators/decorators/property'; /** * A decorator for instance properties of classes extending `Composite`, i.e. a custom component. * It creates a two-way binding between properties of a model (e.g. an object using `@property`) * and children (descendants) of the component. Example: * * ```ts * ‍@bindAll({ * modelPropA: '#childId1.text' * modelPropB: '#childId2.selection' * }) * myProp: MyModel; * * ``` * *Notes:* * * *`@bindAll` behaves like `@property` in most regards.* * * *`@bindAll(bindings)` is a shorthand for `@bind({all: bindings})`. The latter * also supports the `typeGuard` and `type` options.* * * *In addition to id selectors, type selectors and `:host` are also supported.* * * * *Use`@bind(path)` or `@bind({path: path})` to create bindings to the property itself.* */ export function bindAll(bindings: MultipleBindings): CustomPropertyDecorator; } declare module 'tabris-decorators/decorators/getById' { import 'reflect-metadata'; import { Composite } from 'tabris'; import { TypeGuard } from 'tabris-decorators/internals/utils-databinding'; /** * A decorator for instance properties of classes extending `Composite`, * otherwise known as a "custom component". * * Makes the decorated property return a component-internal child element * whose id is identical to the property name. This provides an alternative to * the `_find` function. Example: * * ```ts * ‍@getById readonly button1: Button; * ``` * * * *Notes:* * * *The property will be read-only.* * * *If there is no child with the correct id, or more than one, an error will be thrown.* * * *In TypeScript the type of the widget will also be checked.* * * *Use `@getById(typeGuard)` to implement an explicit type check instead. This is * especially useful in JavaScript where the is no implicit type check.* */ export function getById(targetProto: Composite, property: string): void; /** * A decorator for instance properties of classes extending `Composite`, * otherwise known as a "custom component". * * Makes the decorated property return a component-internal child element * whose id is identical to the property name and passes the type guard check. * This is especially useful in JavaScript where the is no implicit type check. * JavaScript example: * * ```ts * /⋆⋆ @type {Button} ⋆/ * ‍@getById(widget => widget instanceof Button) * readonly buttonId; * ``` * * *Notes:* * * *The property will be read-only.* * * *If there is no child with the correct id, or more than one, an error will be thrown.* * * *In TypeScript this feature may be used to override the explicit type check. * * *Use `@getById` if no type check is needed/desired. */ export function getById(check: TypeGuard): PropertyDecorator; } declare module 'tabris-decorators/api/List' { import { Listeners } from 'tabris'; const data: unique symbol; const observers: unique symbol; const init: unique symbol; export type ListLike = { length: number; [index: number]: T; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, T]>; find(predicate: (this: void, value: T, index: number, obj: ListLike) => value is S, thisArg?: any): S | undefined; find(predicate: (value: T, index: number, obj: ListLike) => unknown, thisArg?: any): T | undefined; findIndex(predicate: (value: T, index: number, obj: ListLike) => unknown, thisArg?: any): number; forEach(callbackfn: (value: T, index: number, array: ListLike) => void, thisArg?: any): void; indexOf(searchElement: T, fromIndex?: number): number; join(separator?: string): string; keys(): IterableIterator; lastIndexOf(searchElement: T, fromIndex?: number): number; pop(): T | undefined; push(...items: T[]): number; shift(): T | undefined; splice(start: number, deleteCount?: number, ...items: T[]): T[]; unshift(...items: T[]): number; values(): IterableIterator; }; export type ListLikeConstructor = { new (arrayLength?: number): (any[] | ListLike); new (...items: T[]): (T[] | ListLike); from(arrayLike: ArrayLike | Iterable): ListLike; from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): ListLike; of(...items: T[]): ListLike; }; export type Mutation = { start: number; deleteCount: number; items: T[]; target: ListLike; }; export function listObservers(list: List): Listeners>; export class List implements ListLike { static from(arrayLike: ArrayLike | Iterable, mapfn?: (v: In, k: number) => Out, thisArg?: any): List; static of(...items: Item[]): List; private [data]; private [observers]; constructor(arrayLength?: number); constructor(...items: T[]); constructor(initializer: { [init]: any[]; }); get length(): number; set length(value: number); [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, T]>; find(predicate: (this: void, value: T, index: number, obj: List) => value is S, thisArg?: any): S | undefined; findIndex(predicate: (value: T, index: number, obj: List) => unknown, thisArg?: any): number; forEach(callbackfn: (value: T, index: number, array: List) => void, thisArg?: any): void; indexOf(searchElement: T, fromIndex?: number): number; join(separator?: string): string; keys(): IterableIterator; lastIndexOf(searchElement: T, fromIndex?: number): number; pop(): T | undefined; push(...items: T[]): number; shift(): T | undefined; splice(start: number, deleteCount?: number, ...items: T[]): T[]; unshift(...items: T[]): number; values(): IterableIterator; } export interface List { [index: number]: T; } export {}; } declare module 'tabris-decorators/internals/ListLikeObserver' { import { ListLike, Mutation } from 'tabris-decorators'; export class ListLikeObserver { private _callback; private _source; constructor(_callback: (ev: Mutation) => void); set source(value: ListLike); get source(): ListLike; protected _autoUpdate(prevSource: ListLike): void; } } declare module 'tabris-decorators/api/ItemPicker' { import { ChangeListeners, EventObject, Factory, JSXAttributes, Listeners, Picker, Properties, PropertyChangedEvent } from 'tabris'; import { ListLike, Mutation } from 'tabris-decorators/api/List'; export class ItemPickerSelectEvent extends EventObject { readonly item: ItemType; readonly itemIndex: number; readonly itemText: string; constructor(item: ItemType, itemIndex: number, itemText: string); } export type TextSourceObject = { path: keyof T & string; converter: (v: any) => any; }; export type TextSource = string | TextSourceObject | null; export type ItemPickerProperties = Properties & { items?: ListLike; textSource?: TextSource; }; namespace internal { class ItemPicker extends Picker { jsxAttributes: JSXAttributes & tabris.Attributes & { children?: ListLike | string; }; onItemSelect: Listeners>; onItemsChanged: Listeners>>; onSelectionChanged: Listeners>; onTextSourceChanged: ChangeListeners; private _observer; private _textSource; private _texts; private _unsubsribers; private _inRefresh; constructor({ items, textSource, ...properties }?: ItemPickerProperties); set items(value: ListLike); get items(): ListLike; set selection(value: ItemType); get selection(): ItemType; set textSource(value: TextSource); get textSource(): TextSource; protected _handleListMutation: (ev: Mutation) => void; protected _computeTexts(): void; protected _bindItems(binding: TextSourceObject): any[]; protected _unbindItems(): void; protected _handleSelectionIndexChanged: () => void; protected _handleSelect: ({ index }: { index: number; }) => void; protected _refresh(): void; protected _reorderProperties(properties: string[]): string[]; [JSX.jsxFactory](Type: any, attributes: any): ItemPicker; } } export type ItemPickerConstructor = typeof internal.ItemPicker; export interface ItemPickerFactory extends Factory, ItemPickerConstructor { } export const ItemPicker: ItemPickerFactory; export type ItemPicker = internal.ItemPicker; export {}; } declare module 'tabris-decorators/api/to' { import { Binding, BindingConverter } from 'tabris-decorators/internals/utils-databinding'; /** * Allows assigning a converter function to a one way binding: * * v.toLocaleString())} /> * * This is the same as: * * v.toLocaleString())} /> * * Can also be used to create reuseable shorthands: * * const toLocaleString * = (path: string) => to(path, v => v.toLocaleString()); * * * * The converter function may have a second parameter which is * passed a `Conversion` object that identifies the target of the conversion. */ export function to(path: string, converter: BindingConverter): Binding; } declare module 'tabris-decorators/api/Cell' { import { Attributes, ChangeListeners, Composite, JSXCompositeAttributes, Properties, Widget } from 'tabris'; import { Constructor } from 'tabris-decorators/internals/utils'; const factory: unique symbol; export type ItemTypeDef = Constructor | 'string' | 'number' | 'boolean'; export type ItemCheck = (value: T) => boolean; export type CellCreationArgs = { itemType?: ItemTypeDef; itemCheck?: ItemCheck; item?: never; selectable?: boolean; }; namespace internal { class Cell extends Composite { static factory(original: Cell): () => Cell; jsxAttributes: JSXCompositeAttributes & CellCreationArgs; onItemChanged: ChangeListeners; onItemIndexChanged: ChangeListeners; readonly selectable: boolean; readonly itemType: ItemTypeDef; readonly itemCheck: ItemCheck; item: ItemType; itemIndex: number; private [factory]; constructor(properties?: Properties & CellCreationArgs); [JSX.jsxFactory](Type: any, attributes: any): any; } class TextCell extends Cell { constructor(); } } export type CellConstructor = typeof internal.Cell; export interface CellFactory extends CellConstructor { (attributes?: Attributes>, selector?: (...args: any[]) => Cell): Cell; } export type Cell = internal.Cell; export const Cell: CellFactory; export const TextCell: import("tabris").CallableConstructor Widget>; export type TextCell = internal.TextCell; export {}; } declare module 'tabris-decorators/api/ListView' { import { Attributes, ChangeListeners, CollectionView, EventObject, JSXCompositeAttributes, Listeners, Properties, Widget } from 'tabris'; import { Cell } from 'tabris-decorators/api/Cell'; import { ListLike, Mutation } from 'tabris-decorators/api/List'; export enum ItemAction { Primary = 1, Secondary = 2, Toggle = 3, Dismiss = 4 } export class ListViewSelectEvent extends EventObject { readonly item: ItemType; readonly itemIndex: number; readonly originalEvent: EventObject; readonly action: number; constructor(item: ItemType, itemIndex: number, originalEvent: EventObject, action: number); } namespace internal { class ListView extends CollectionView> { static selectPrimary(ev: EventObject): void; static selectSecondary(ev: EventObject): void; static selectToggle(ev: EventObject): void; static selectDismiss(ev: EventObject): void; static select(ev: EventObject, action?: number): void; jsxAttributes: JSXCompositeAttributes> & Attributes>>; onItemsChanged: ChangeListeners; onSelect: Listeners>; private _observer; constructor(properties?: Properties>); set items(value: ListLike); get items(): ListLike; protected _handleMutation: ({ start, deleteCount, items, target }: Mutation) => void; [JSX.jsxFactory](Type: any, attributes: any): ListView; } } export type ListViewConstructor = typeof internal.ListView; export interface ListViewFactory extends ListViewConstructor { (attributes?: Attributes>, selector?: (...args: any[]) => ListView): ListView; } export const ListView: ListViewFactory; export type ListView = internal.ListView; export {}; } declare module 'tabris-decorators/index' { import { CreateFunction, RegisterFunction, ResolveFunction } from 'tabris-decorators/api/Injector'; import { InjectDecorator } from 'tabris-decorators/decorators/inject'; import { InjectableDecorator } from 'tabris-decorators/decorators/injectable'; import { InjectionHandlerDecorator } from 'tabris-decorators/decorators/injectionHandler'; import { SharedDecorator } from 'tabris-decorators/decorators/shared'; export * from 'tabris-decorators/decorators/component'; export * from 'tabris-decorators/decorators/connect'; export * from 'tabris-decorators/decorators/property'; export * from 'tabris-decorators/decorators/prop'; export * from 'tabris-decorators/decorators/bind'; export * from 'tabris-decorators/decorators/bindAll'; export * from 'tabris-decorators/decorators/getById'; export * from 'tabris-decorators/decorators/event'; export * from 'tabris-decorators/api/checkType'; export * from 'tabris-decorators/api/equals'; export * from 'tabris-decorators/api/convert'; export * from 'tabris-decorators/api/Injector'; export * from 'tabris-decorators/api/StateProvider'; export * from 'tabris-decorators/api/ActionMapper'; export * from 'tabris-decorators/api/ItemPicker'; export * from 'tabris-decorators/api/interfaces'; export * from 'tabris-decorators/api/to'; export * from 'tabris-decorators/api/List'; export * from 'tabris-decorators/api/ListView'; export * from 'tabris-decorators/api/Cell'; export interface DefaultRootState { } export interface DefaultActions { } /** * A decorator that marks a constructor parameter for injections based on the type of the parameter: * ``` * constructor(@inject a: ClassA) { ... } * ``` * A parameter can be passed to the injector (see `@injectable` and `@injectionHandler`) like this: * ``` * constructor(@inject('some value') a: ClassA) { ... } * ``` */ export const inject: InjectDecorator; /** * A decorator that makes a class injectable via `@inject` or `resolve(type)`. * It can be injected as itself or as any of its super-classes: * * ``` * ‍@injectable class Foo2 extends Foo { ... } * ``` * A configuration object can be passed: * ``` * ‍@injectable({opt: value}) * class Foo2 extends Foo { ... } * ``` * The object can have any of these entries: * - `shared: boolean`: when `true`this makes the class effectively a singleton * - `implements: OtherClass`: allows the class to be injected as `OtherClass` * - `priority: number`: The priority of this class relative to other compatible injectables. Defaults to 0. * - `param: value`: allows injection only when `@inject(param)` gives the exact same parameter value. */ export const injectable: InjectableDecorator; /** * Shorthand for `@injectable({shared: true})`. */ export const shared: SharedDecorator; /** * Registers a static method to handle injections for the given type: * ``` * ‍@injectionHandler(MyServiceClass) * static createMyServiceClass(injection: Injection) { * return new MyServiceClass(someArg); * } * ``` * A priority may also be given, defaults to 0: * ```ts * @injectionHandler({targetType: MyServiceClass, priority: 2}) * ``` * * The decorated method must return a value compatible to the given type or `null`/`undefined`. * The method is passed an `Injection` object with the following fields: * - `type`: The exact type that was requested. * - `injector`: The `Injector` instance the injection handler is registered with. * - `param`: An injection parameter that may have been passed via `@inject(param)` or `resolve(type, param)` */ export const injectionHandler: InjectionHandlerDecorator; export const create: CreateFunction; export const resolve: ResolveFunction; export const register: RegisterFunction; } declare module 'tabris-decorators' { export * from 'tabris-decorators/index'; }