import { TypeFlags } from './type-flags'; import { IJsonPatch } from '../core/NodeUtils'; import { IContext, IValidationResult } from './type-checker'; import { MakeField } from "../core/mst-operations"; import { INode } from '../core/interface'; import { ObjectNode } from '../core/ObjectNode'; export interface ISnapshottable { } export declare type IFunctionReturn = () => T; export declare type TypeOptions = { label?: string; placeholder?: string; disabled?: boolean; visible?: boolean; focused?: boolean; related?: string[] | string | IFunctionReturn | IFunctionReturn; validators?: any; validationDebounceWait?: number; validateOnBlur?: boolean; validateOnChange?: boolean; showErrorsOnChange?: boolean; showErrorsOnBlur?: boolean; showErrorsOnSubmit?: boolean; valueOnChanged?: (field: INode, oldValue, newValue) => void; deserialize?: (value: any) => any; serialize?: (value: any) => any; extra?: any; }; export interface IType { name: string; flags: TypeFlags; isType: boolean; describe(): string; Type: T; SnapshotType: S; valueType: IType; is(thing: any): thing is S | T; create(snapshot?: S, environment?: any): T; validate(thing: any, context: IContext): IValidationResult; getValue(node: INode): T; isAssignableFrom(type: IType): boolean; instantiate(parent: ObjectNode | null, subpath: string, environment: any, initialValue?: any): INode; reconcile(current: INode, newValue: any): INode; getSnapshot(node: INode): S; applySnapshot(node: INode, snapshot: any): void; applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; hasNestedFields(): boolean; getChildren(node: ObjectNode): INode[]; getChildField(node: ObjectNode, key: string): INode; getChildType(key: string): IType; removeChild(node: ObjectNode, subpath: string): void; shouldAttachNode: boolean; readonly options: TypeOptions; setOptions(options: TypeOptions): this; } export interface ISimpleType extends IType { } export interface IComplexType extends IType> { } export interface IEnvironment { makeField?: MakeField; [key: string]: any; } export declare abstract class ComplexType implements IType { readonly isType: boolean; readonly name: string; private _options; constructor(name: string); create(snapshot?: S, environment?: IEnvironment): T; abstract instantiate(parent: ObjectNode | null, subpath: string, environment: any, initialValue: any): INode; abstract flags: TypeFlags; abstract describe(): string; abstract getValue(node: INode): T; abstract getDefaultSnapshot(): any; abstract getSnapshot(node: INode): any; abstract applySnapshot(node: INode, snapshot: any): void; abstract applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; abstract hasNestedFields(): boolean; abstract getChildren(node: ObjectNode): INode[]; abstract getChildField(node: ObjectNode, key: string): INode; abstract getChildType(key: string): IType; abstract removeChild(node: ObjectNode, subpath: string): void; abstract isValidSnapshot(value: any, context: IContext): IValidationResult; abstract shouldAttachNode: boolean; readonly valueType: IType; readonly options: TypeOptions; setOptions(options: TypeOptions): this; isAssignableFrom(type: IType): boolean; validate(value: any, context: IContext): IValidationResult; is(value: any): value is S | T; reconcile(current: ObjectNode, newValue: any): INode; readonly Type: T; readonly SnapshotType: S; } export declare abstract class Type extends ComplexType implements IType { constructor(name: string); abstract instantiate(parent: ObjectNode | null, subpath: string, environment: any, initialValue: any): INode; getValue(node: INode): T; getDefaultSnapshot(): any; getSnapshot(node: INode): any; applySnapshot(node: INode, snapshot: S): void; applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; hasNestedFields(): boolean; getChildren(node: ObjectNode): INode[]; getChildField(node: ObjectNode, key: string): INode; getChildType(key: string): IType; reconcile(current: ObjectNode, newValue: any): INode; removeChild(node: ObjectNode, subpath: string): void; }