|
|
import _WidgetBase = require("dijit/_WidgetBase");
|
|
|
import _FormWidget = require("./_FormWidget");
|
|
|
import { DeclareConstructor } from "dojo/_base/declare";
|
|
|
|
|
|
interface OnValidStateChange {
|
|
|
(isValid?: boolean): void;
|
|
|
}
|
|
|
|
|
|
interface _FormMixin {
|
|
|
|
|
|
/**
|
|
|
* Will be "Error" if one or more of the child widgets has an invalid value,
|
|
|
* "Incomplete" if not all of the required child widgets are filled in. Otherwise, "",
|
|
|
* which indicates that the form is ready to be submitted.
|
|
|
*/
|
|
|
state: '' | 'Error' | 'Incomplete';
|
|
|
|
|
|
/**
|
|
|
* Returns all form widget descendants, searching through non-form child widgets like BorderContainer
|
|
|
*/
|
|
|
_getDescendantFormWidgets(children?: _WidgetBase[]): _FormWidget[];
|
|
|
|
|
|
reset(): void;
|
|
|
|
|
|
/**
|
|
|
* returns if the form is valid - same as isValid - but
|
|
|
* provides a few additional (ui-specific) features:
|
|
|
*
|
|
|
* 1. it will highlight any sub-widgets that are not valid
|
|
|
* 2. it will call focus() on the first invalid sub-widget
|
|
|
*/
|
|
|
validate(): boolean;
|
|
|
|
|
|
setValues(val: any): _FormMixin;
|
|
|
getValues(): any;
|
|
|
|
|
|
/**
|
|
|
* Returns true if all of the widgets are valid.
|
|
|
* Deprecated, will be removed in 2.0. Use get("state") instead.
|
|
|
*/
|
|
|
isValid(): boolean;
|
|
|
|
|
|
/**
|
|
|
* Stub function to connect to if you want to do something
|
|
|
* (like disable/enable a submit button) when the valid
|
|
|
* state changes on the form as a whole.
|
|
|
*
|
|
|
* Deprecated. Will be removed in 2.0. Use watch("state", ...) instead.
|
|
|
*/
|
|
|
onValidStateChange: OnValidStateChange;
|
|
|
|
|
|
/**
|
|
|
* Compute what this.state should be based on state of children
|
|
|
*/
|
|
|
_getState(): '' | 'Error' | 'Incomplete';
|
|
|
|
|
|
/**
|
|
|
* Deprecated method. Applications no longer need to call this. Remove for 2.0.
|
|
|
*/
|
|
|
disconnectChildren(): void;
|
|
|
|
|
|
/**
|
|
|
* You can call this function directly, ex. in the event that you
|
|
|
* programmatically add a widget to the form *after* the form has been
|
|
|
* initialized.
|
|
|
*/
|
|
|
connectChildren(inStartup?: boolean): void;
|
|
|
|
|
|
/**
|
|
|
* Called when child's value or disabled state changes
|
|
|
*/
|
|
|
_onChildChange(attr?: string): void;
|
|
|
|
|
|
startup(): void;
|
|
|
destroy(preserveDom?: boolean): void;
|
|
|
}
|
|
|
|
|
|
type _FormMixinConstructor = DeclareConstructor<_FormMixin>;
|
|
|
declare const _FormMixin: _FormMixinConstructor;
|
|
|
export = _FormMixin;
|
|
|
|