diff --git a/dojo-typings/readme.md b/dojo-typings/readme.md new file mode 100644 --- /dev/null +++ b/dojo-typings/readme.md @@ -0,0 +1,33 @@ +# dojo-typings + +This project is forked from the original `dojo-typings` package to +improve it with more tight and customizable type definitions. + +The primary aims are + +* Parametrize collections with items type. +* Distinguish sync and async methods in stores. +* Parametrize widget typings with event and attribute maps. + +## Changes + +### 1.0.1 + +Maintenance release + +* `NodeList-fx` added overloads to all methods to distinguish returned values + of different types (`Animation | this`). +* Added missing signatures to `NodeList` constructor +* Improved `dijit.form._FormWidgetMixin` +* Added module declarations `dijit/form/_FormWidgetMixin`, + `dijit/form/_FormValueMixin`, `dijit/_HasDropDown` + +### 1.0.0 + +Initial release + +* Parametrized `dojo/Stateful`, `diji/_WidgetBase` +* split `dojo.store.api.Store` in two `SyncStore` and `AsyncStore` interfaces + * `dojo/store/Memory` implements `SyncStore` and can be used synchronously, + * `dojo/store/Rest` implements `AsyncStore` and all its methods are + returning explicit promises. diff --git a/dojo-typings/src/main/typings/dijit/form.d.ts b/dojo-typings/src/main/typings/dijit/form.d.ts --- a/dojo-typings/src/main/typings/dijit/form.d.ts +++ b/dojo-typings/src/main/typings/dijit/form.d.ts @@ -1,1889 +1,1868 @@ declare namespace dijit { - namespace form { + namespace form { - /* implied */ + /* implied */ - interface Constraints { - [prop: string]: any; - } + interface Constraints { + [prop: string]: any; + } - interface ConstrainedValueFunction { - /** - * Returns a value that has been constrained by the constraints - * @param value The value to constrain - * @param constraints The constraints to use - * @returns The constrained value - */ - (value: V, constraints: C): T; - } + interface ConstrainedValueFunction { + /** + * Returns a value that has been constrained by the constraints + * @param value The value to constrain + * @param constraints The constraints to use + * @returns The constrained value + */ + (value: V, constraints: C): T; + } - interface ConstrainedValidFunction { - /** - * Returns true if the value is valid based on the constraints, otherwise - * returns false. - * @param value The value to check - * @param constraints The constraints to use - * @returns true if valid, otherwise false - */ - (value: any, constraints: C): boolean; - } + interface ConstrainedValidFunction { + /** + * Returns true if the value is valid based on the constraints, otherwise + * returns false. + * @param value The value to check + * @param constraints The constraints to use + * @returns true if valid, otherwise false + */ + (value: any, constraints: C): boolean; + } - interface ConstraintsToRegExpString { - /** - * Takes a set of constraints and returns a RegExpString that can be used - * to match values against - * @param constraints The constraints to use - * @returns The RegExpString that represents the constraints - */ - (constraints: C): string; - } + interface ConstraintsToRegExpString { + /** + * Takes a set of constraints and returns a RegExpString that can be used + * to match values against + * @param constraints The constraints to use + * @returns The RegExpString that represents the constraints + */ + (constraints: C): string; + } - interface SerializationFunction { - (val: any, options?: Object): string; - } + interface SerializationFunction { + (val: any, options?: Object): string; + } - /* dijit/form/_AutoCompleterMixin */ + /* dijit/form/_AutoCompleterMixin */ - /* tslint:disable:class-name */ - interface _AutoCompleterMixin extends _SearchMixin { - /** - * This is the item returned by the dojo/store/api/Store implementation that - * provides the data for this ComboBox, it's the currently selected item. - */ - item: T; + /* tslint:disable:class-name */ + interface _AutoCompleterMixin extends _SearchMixin { + /** + * This is the item returned by the dojo/store/api/Store implementation that + * provides the data for this ComboBox, it's the currently selected item. + */ + item: T; - /** - * If user types in a partial string, and then tab out of the `` box, - * automatically copy the first entry displayed in the drop down list to - * the `` field - */ - autoComplete: boolean; + /** + * If user types in a partial string, and then tab out of the `` box, + * automatically copy the first entry displayed in the drop down list to + * the `` field + */ + autoComplete: boolean; - /** - * One of: "first", "all" or "none". - */ - highlightMatch: string; - /* TODO: Uncomment for TS 1.8 and remove above */ - /* highlightMatch: 'fisrt' | 'all' | 'none'; */ + /** + * One of: "first", "all" or "none". + */ + highlightMatch: string; + /* TODO: Uncomment for TS 1.8 and remove above */ + /* highlightMatch: 'fisrt' | 'all' | 'none'; */ - /** - * The entries in the drop down list come from this attribute in the - * dojo.data items. - * If not specified, the searchAttr attribute is used instead. - */ - labelAttr: string; + /** + * The entries in the drop down list come from this attribute in the + * dojo.data items. + * If not specified, the searchAttr attribute is used instead. + */ + labelAttr: string; - /** - * Specifies how to interpret the labelAttr in the data store items. - * Can be "html" or "text". - */ - labelType: string; + /** + * Specifies how to interpret the labelAttr in the data store items. + * Can be "html" or "text". + */ + labelType: string; - /** - * Flags to _HasDropDown to limit height of drop down to make it fit in viewport - */ - maxHeight: number; + /** + * Flags to _HasDropDown to limit height of drop down to make it fit in viewport + */ + maxHeight: number; - /** - * For backwards compatibility let onClick events propagate, even clicks on the down arrow button - */ - _stopClickEvents: boolean; + /** + * For backwards compatibility let onClick events propagate, even clicks on the down arrow button + */ + _stopClickEvents: boolean; - _getCaretPos(element: HTMLElement): number; - _setCaretPos(element: HTMLElement, location: number): void; + _getCaretPos(element: HTMLElement): number; + _setCaretPos(element: HTMLElement, location: number): void; - /** - * Overrides _HasDropDown.loadDropDown(). - */ - loadDropDown(loadCallback: () => void): void; + /** + * Overrides _HasDropDown.loadDropDown(). + */ + loadDropDown(loadCallback: () => void): void; - /** - * signal to _HasDropDown that it needs to call loadDropDown() to load the - * drop down asynchronously before displaying it - */ - isLoaded(): boolean; + /** + * signal to _HasDropDown that it needs to call loadDropDown() to load the + * drop down asynchronously before displaying it + */ + isLoaded(): boolean; - /** - * Overrides _HasDropDown.closeDropDown(). Closes the drop down (assuming that it's open). - * This method is the callback when the user types ESC or clicking - * the button icon while the drop down is open. It's also called by other code. - */ - closeDropDown(focus?: boolean): void; + /** + * Overrides _HasDropDown.closeDropDown(). Closes the drop down (assuming that it's open). + * This method is the callback when the user types ESC or clicking + * the button icon while the drop down is open. It's also called by other code. + */ + closeDropDown(focus?: boolean): void; - postMixInProperties(): void; - postCreate(): void; + postMixInProperties(): void; + postCreate(): void; - /** - * Highlights the string entered by the user in the menu. By default this - * highlights the first occurrence found. Override this method - * to implement your custom highlighting. - */ - doHighlight(label: string, find: string): string; - reset(): void; - labelFunc(item: T, store: dojo.store.api.Store): string; + /** + * Highlights the string entered by the user in the menu. By default this + * highlights the first occurrence found. Override this method + * to implement your custom highlighting. + */ + doHighlight(label: string, find: string): string; + reset(): void; + labelFunc(item: T, store: dojo.store.api.Store): string; - // set(name: 'value', value: string): this; - // set(name: 'item', value: T): this; - // set(name: 'disabled', value: boolean): this; - // set(name: string, value: any): this; - // set(values: Object): this; - } + // set(name: 'value', value: string): this; + // set(name: 'item', value: T): this; + // set(name: 'disabled', value: boolean): this; + // set(name: string, value: any): this; + // set(values: Object): this; + } - /* dijit/form/_ButtonMixin */ + /* dijit/form/_ButtonMixin */ - interface _ButtonMixin { - /** - * A mixin to add a thin standard API wrapper to a normal HTML button - */ - label: string; + interface _ButtonMixin { + /** + * A mixin to add a thin standard API wrapper to a normal HTML button + */ + label: string; - /** - * Type of button (submit, reset, button, checkbox, radio) - */ - type: string; - postCreate(): void; + /** + * Type of button (submit, reset, button, checkbox, radio) + */ + type: string; + postCreate(): void; - /** - * Callback for when button is clicked. - * If type="submit", return true to perform submit, or false to cancel it. - */ - onClick(e: MouseEvent): boolean | void; - onSetLabel(e: Event): void; - } + /** + * Callback for when button is clicked. + * If type="submit", return true to perform submit, or false to cancel it. + */ + onClick(e: MouseEvent): boolean | void; + onSetLabel(e: Event): void; + } - /* dijit/form/_CheckBoxMixin */ + /* dijit/form/_CheckBoxMixin */ - interface _CheckBoxMixin { - /** - * type attribute on `` node. - * Overrides `dijit/form/Button.type`. Users should not change this value. - */ - type: string; + interface _CheckBoxMixin { + /** + * type attribute on `` node. + * Overrides `dijit/form/Button.type`. Users should not change this value. + */ + type: string; - /** - * As an initialization parameter, equivalent to value field on normal checkbox - * (if checked, the value is passed as the value when form is submitted). - */ - value: string; + /** + * As an initialization parameter, equivalent to value field on normal checkbox + * (if checked, the value is passed as the value when form is submitted). + */ + value: string; - /** - * Should this widget respond to user input? - * In markup, this is specified as "readOnly". - * Similar to disabled except readOnly form values are submitted. - */ - readOnly: boolean; + /** + * Should this widget respond to user input? + * In markup, this is specified as "readOnly". + * Similar to disabled except readOnly form values are submitted. + */ + readOnly: boolean; - reset: () => void; - } + reset: () => void; + } - /* dijit/form/_ComboBoxMenu */ + /* dijit/form/_ComboBoxMenu */ - interface _ComboBoxMenu extends _WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin { - templateString: string; - baseClass: string; + interface _ComboBoxMenu extends _WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin { + templateString: string; + baseClass: string; - /** - * Add hover CSS - */ - onHover(node: HTMLElement): void; + /** + * Add hover CSS + */ + onHover(node: HTMLElement): void; - /** - * Remove hover CSS - */ - onUnhover(node: HTMLElement): void; + /** + * Remove hover CSS + */ + onUnhover(node: HTMLElement): void; - /** - * Add selected CSS - */ - onSelect(node: HTMLElement): void; + /** + * Add selected CSS + */ + onSelect(node: HTMLElement): void; - /** - * Remove selected CSS - */ - onDeselect(node: HTMLElement): void; + /** + * Remove selected CSS + */ + onDeselect(node: HTMLElement): void; - /** - * Handles page-up and page-down keypresses - */ - _page(up?: boolean): void; + /** + * Handles page-up and page-down keypresses + */ + _page(up?: boolean): void; - /** - * Handle keystroke event forwarded from ComboBox, returning false if it's - * a keystroke I recognize and process, true otherwise. - */ - handleKey(evt: KeyboardEvent): boolean; + /** + * Handle keystroke event forwarded from ComboBox, returning false if it's + * a keystroke I recognize and process, true otherwise. + */ + handleKey(evt: KeyboardEvent): boolean; - // set(name: string, value: any): this; - // set(values: Object): this; - } + // set(name: string, value: any): this; + // set(values: Object): this; + } - interface _ComboBoxMenuConstructor extends _WidgetBaseConstructor<_ComboBoxMenu> { - new (params: Object, srcNodeRef: dojo.NodeOrString): _ComboBoxMenu; - } + interface _ComboBoxMenuConstructor extends _WidgetBaseConstructor<_ComboBoxMenu> { + new (params: Object, srcNodeRef: dojo.NodeOrString): _ComboBoxMenu; + } - /* dijit/form/_ComboBoxMenuMixin */ + /* dijit/form/_ComboBoxMenuMixin */ - interface _ComboBoxMenuMixin { - /** - * Holds "next" and "previous" text for paging buttons on drop down - */ - _messages: { next: string; previous: string; }; - - onClick(node: HTMLElement): void; + interface _ComboBoxMenuMixin { + /** + * Holds "next" and "previous" text for paging buttons on drop down + */ + _messages: { next: string; previous: string; }; - /** - * Notifies ComboBox/FilteringSelect that user selected an option. - */ - onChange(direction: number): void; + onClick(node: HTMLElement): void; - /** - * Notifies ComboBox/FilteringSelect that user clicked to advance to next/previous page. - */ - onPage(direction: number): void; + /** + * Notifies ComboBox/FilteringSelect that user selected an option. + */ + onChange(direction: number): void; - /** - * Callback from dijit.popup code to this widget, notifying it that it closed - */ - onClose(): void; + /** + * Notifies ComboBox/FilteringSelect that user clicked to advance to next/previous page. + */ + onPage(direction: number): void; - /** - * Fills in the items in the drop down list - */ - createOptions(results: T[], options: dojo.store.api.QueryOptions, labelFunc: (item: T) => { html: boolean; label: string; }): void; + /** + * Callback from dijit.popup code to this widget, notifying it that it closed + */ + onClose(): void; - /** - * Clears the entries in the drop down list, but of course keeps the previous and next buttons. - */ - clearResultList(): void; + /** + * Fills in the items in the drop down list + */ + createOptions(results: T[], options: dojo.store.api.QueryOptions, labelFunc: (item: T) => { html: boolean; label: string; }): void; - /** - * Highlight the first real item in the list (not Previous Choices). - */ - highlightFirstOption(): void; + /** + * Clears the entries in the drop down list, but of course keeps the previous and next buttons. + */ + clearResultList(): void; - /** - * Highlight the last real item in the list (not More Choices). - */ - highlightLastOption(): void; + /** + * Highlight the first real item in the list (not Previous Choices). + */ + highlightFirstOption(): void; + + /** + * Highlight the last real item in the list (not More Choices). + */ + highlightLastOption(): void; - selectFirstNode(): void; - selectLastNode(): void; - getHighlightedOption(): HTMLElement; + selectFirstNode(): void; + selectLastNode(): void; + getHighlightedOption(): HTMLElement; - // set(name: 'value', value: Object): this; - // set(name: string, value: any): this; - // set(values: Object): this; - } + // set(name: 'value', value: Object): this; + // set(name: string, value: any): this; + // set(values: Object): this; + } - /* dijit/form/_DateTimeTextBox */ + /* dijit/form/_DateTimeTextBox */ - interface DateTimeConstraints extends Constraints, dojo.date.DateLocaleFormatOptions { } + interface DateTimeConstraints extends Constraints, dojo.date.DateLocaleFormatOptions { } - interface _DateTimeTextBox extends RangeBoundTextBox, _HasDropDown { - templateString: string; + interface _DateTimeTextBox extends RangeBoundTextBox, _HasDropDown { + templateString: string; - /** - * Set this textbox to display a down arrow button, to open the drop down list. - */ - hasDownArrow: boolean; - cssStateNodes: CSSStateNodes; + /** + * Set this textbox to display a down arrow button, to open the drop down list. + */ + hasDownArrow: boolean; + cssStateNodes: CSSStateNodes; - /** - * Despite the name, this parameter specifies both constraints on the input - * (including starting/ending dates/times allowed) as well as - * formatting options like whether the date is displayed in long (ex: December 25, 2005) - * or short (ex: 12/25/2005) format. See `dijit/form/_DateTimeTextBox.__Constraints` for details. - */ - constraints: DateTimeConstraints; + /** + * Despite the name, this parameter specifies both constraints on the input + * (including starting/ending dates/times allowed) as well as + * formatting options like whether the date is displayed in long (ex: December 25, 2005) + * or short (ex: 12/25/2005) format. See `dijit/form/_DateTimeTextBox.__Constraints` for details. + */ + constraints: DateTimeConstraints; - /** - * The constraints without the min/max properties. Used by the compare() method - */ - _unboundedConstraints: DateTimeConstraints; + /** + * The constraints without the min/max properties. Used by the compare() method + */ + _unboundedConstraints: DateTimeConstraints; - pattern: (options?: dojo.date.DateLocaleFormatOptions | RangeBoundTextBoxConstraints) => string; + pattern: (options?: dojo.date.DateLocaleFormatOptions | RangeBoundTextBoxConstraints) => string; - /** - * JavaScript namespace to find calendar routines. If unspecified, uses Gregorian calendar routines - * at dojo/date and dojo/date/locale. - */ - datePackage: string; + /** + * JavaScript namespace to find calendar routines. If unspecified, uses Gregorian calendar routines + * at dojo/date and dojo/date/locale. + */ + datePackage: string; - postMixInProperties(): void; - compare(val1: Date, val2: Date): number; - autoWidth: boolean; + postMixInProperties(): void; + compare(val1: Date, val2: Date): number; + autoWidth: boolean; - /** - * Formats the value as a Date, according to specified locale (second argument) - */ - format: ConstrainedValueFunction; + /** + * Formats the value as a Date, according to specified locale (second argument) + */ + format: ConstrainedValueFunction; - /** - * Parses as string as a Date, according to constraints - */ - parse: ConstrainedValueFunction; + /** + * Parses as string as a Date, according to constraints + */ + parse: ConstrainedValueFunction; - serialize(val: any, options?: dojo.date.StampFormatOptions): string; + serialize(val: any, options?: dojo.date.StampFormatOptions): string; - /** - * The default value to focus in the popupClass widget when the textbox value is empty. - */ - dropDownDefaultValue: Date; + /** + * The default value to focus in the popupClass widget when the textbox value is empty. + */ + dropDownDefaultValue: Date; - /** - * The value of this widget as a JavaScript Date object. Use get("value") / set("value", val) to manipulate. - * When passed to the parser in markup, must be specified according to `dojo/date/stamp.fromISOString()` - */ - value: Date; + /** + * The value of this widget as a JavaScript Date object. Use get("value") / set("value", val) to manipulate. + * When passed to the parser in markup, must be specified according to `dojo/date/stamp.fromISOString()` + */ + value: Date; - _blankValue: string; + _blankValue: string; - /** - * Name of the popup widget class used to select a date/time. - * Subclasses should specify this. - */ - popupClass: string | _WidgetBaseConstructor; + /** + * Name of the popup widget class used to select a date/time. + * Subclasses should specify this. + */ + popupClass: string | _WidgetBaseConstructor; - /** - * Specifies constraints.selector passed to dojo.date functions, should be either - * "date" or "time". - * Subclass must specify this. - */ - _selector: string; - /* TODO: uncomment for TS 1.8 */ - /* _selector: 'data' | 'time'; */ + /** + * Specifies constraints.selector passed to dojo.date functions, should be either + * "date" or "time". + * Subclass must specify this. + */ + _selector: string; + /* TODO: uncomment for TS 1.8 */ + /* _selector: 'data' | 'time'; */ - buildRendering(): void; + buildRendering(): void; - /** - * Runs various tests on the value, checking for invalid conditions - */ - _isInvalidDate(value: Date): boolean; + /** + * Runs various tests on the value, checking for invalid conditions + */ + _isInvalidDate(value: Date): boolean; - // get(name: 'displayedValue'): string; - // get(name: string): any; + // get(name: 'displayedValue'): string; + // get(name: string): any; - // set(name: 'displayedValue', value: string): this; - // set(name: 'dropDownDefaultValue', value: Date): this; - // set(name: 'value', value: Date | string): this; - // set(name: 'constraints', value: DateTimeConstraints): this; - // set(name: string, value: any): this; - // set(values: Object): this; - } - - interface _DateTimeTextBoxConstructor extends _WidgetBaseConstructor<_DateTimeTextBox> { } + // set(name: 'displayedValue', value: string): this; + // set(name: 'dropDownDefaultValue', value: Date): this; + // set(name: 'value', value: Date | string): this; + // set(name: 'constraints', value: DateTimeConstraints): this; + // set(name: string, value: any): this; + // set(values: Object): this; + } - /* dijit/form/_ExpandingTextAreaMixin */ + interface _DateTimeTextBoxConstructor extends _WidgetBaseConstructor<_DateTimeTextBox> { } + + /* dijit/form/_ExpandingTextAreaMixin */ - interface _ExpandingTextAreaMixin { - postCreate(): void; - startup(): void; - resize(): void; - } + interface _ExpandingTextAreaMixin { + postCreate(): void; + startup(): void; + resize(): void; + } - /* dijit/form/_FormMixin */ - - interface OnValidStateChange { - (isValid?: boolean): void; - } + /* dijit/form/_FormMixin */ - interface _FormMixin { + 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'; + /** + * 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 all form widget descendants, searching through non-form child widgets like BorderContainer + */ + _getDescendantFormWidgets(children?: _WidgetBase[]): _FormWidget[]; - /** - * 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; + reset(): void; - setValues(val: any): _FormMixin; - getValues(): any; + /** + * 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; + /** + * 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'; + /** + * 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; - /** - * Deprecated method. Applications no longer need to call this. Remove for 2.0. - */ - disconnectChildren(): void; + /** + * Compute what this.state should be based on state of children + */ + _getState(): '' | 'Error' | 'Incomplete'; - /** - * 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; + /** + * Deprecated method. Applications no longer need to call this. Remove for 2.0. + */ + disconnectChildren(): void; - /** - * Called when child's value or disabled state changes - */ - _onChildChange(attr?: string): void; - - startup(): void; - destroy(preserveDom?: boolean): 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; - interface _FormMixinConstructor extends dojo._base.DeclareConstructor<_FormMixin> { } - - /* dijit/form/_FormSelectWidget */ + /** + * Called when child's value or disabled state changes + */ + _onChildChange(attr?: string): void; - interface SelectOption { - value?: string; - label: string; - selected?: boolean; - disabled?: boolean; - } + startup(): void; + destroy(preserveDom?: boolean): void; + } + + interface _FormMixinConstructor extends dojo._base.DeclareConstructor<_FormMixin> { } + + /* dijit/form/_FormSelectWidget */ - interface _FormSelectWidget extends _FormValueWidget { - /** - * Whether or not we are multi-valued - */ - multiple: boolean; + interface SelectOption { + value?: string; + label: string; + selected?: boolean; + disabled?: boolean; + } - /** - * The set of options for our select item. Roughly corresponds to - * the html `