Fix definition for IFieldGroup, add IFieldArray as convenience type for formly-form fields property, update tests

This commit is contained in:
Scarrier
2016-01-04 15:43:02 -06:00
parent bdaf2f0eb1
commit 6dd0b2dc5c
2 changed files with 36 additions and 16 deletions
+16 -1
View File
@@ -24,7 +24,7 @@ class FormConfig {
}
class AppController {
fields: AngularFormly.IFieldConfigurationObject[];
fields: AngularFormly.IFieldArray;
constructor() {
var vm = this;
vm.fields = [
@@ -99,6 +99,21 @@ class AppController {
templateOptions: {
label: 'no wrapper here...'
}
},
{
//From http://angular-formly.com/#/example/other/nested-formly-forms
key: 'address',
wrapper: 'panel',
templateOptions: { label: 'Address' },
fieldGroup: [{
key: 'town',
type: 'input',
templateOptions: {
required: true,
type: 'text',
label: 'Town'
}
}]
}
]
}
+20 -15
View File
@@ -1,7 +1,7 @@
// Type definitions for angular-formly 6.18.0
// Type definitions for angular-formly 7.2.3
// Project: https://github.com/formly-js/angular-formly
// Definitions by: Scott Hatcher <https://github.com/scatcher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
@@ -16,18 +16,23 @@ declare module 'angular-formly' {
declare module AngularFormly {
interface IFieldArray extends Array<IFieldConfigurationObject|IFieldGroup> {
}
interface IFieldGroup {
data?: Object;
className?: string;
elementAttributes?: { [key: string]: string };
fieldGroup: IFieldConfigurationObject[];
elementAttributes?: string;
fieldGroup: IFieldArray;
form?: Object;
hide?: boolean;
hideExpression?: string | IExpresssionFunction;
hideExpression?: string | IExpressionFunction;
key?: string | number;
model?: string | Object;
options?: IFormOptionsAPI
options?: IFormOptionsAPI;
templateOptions?: ITemplateOptions;
wrapper?: string | string[];
}
@@ -46,7 +51,7 @@ declare module AngularFormly {
/**
* see http://docs.angular-formly.com/docs/formly-expressions#expressionproperties-validators--messages
*/
interface IExpresssionFunction {
interface IExpressionFunction {
($viewValue: any, $modelValue: any, scope: ITemplateScope): any;
}
@@ -122,8 +127,8 @@ declare module AngularFormly {
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
*/
interface IValidator {
expression: string | IExpresssionFunction;
message?: string | IExpresssionFunction;
expression: string | IExpressionFunction;
message?: string | IExpressionFunction;
}
@@ -154,7 +159,7 @@ declare module AngularFormly {
* see http://angular-formly.com/#/example/other/unique-value-async-validation
*/
asyncValidators?: {
[key: string]: string | IExpresssionFunction | IValidator;
[key: string]: string | IExpressionFunction | IValidator;
}
/**
@@ -204,7 +209,7 @@ declare module AngularFormly {
* see http://docs.angular-formly.com/docs/field-configuration-object#expressionproperties-object
*/
expressionProperties?: {
[key: string]: string | IExpresssionFunction | IValidator;
[key: string]: string | IExpressionFunction | IValidator;
}
@@ -224,7 +229,7 @@ declare module AngularFormly {
*
* see http://docs.angular-formly.com/docs/field-configuration-object#hideexpression-string--function
*/
hideExpression?: string | IExpresssionFunction;
hideExpression?: string | IExpressionFunction;
/**
@@ -416,7 +421,7 @@ declare module AngularFormly {
* like in this example.
*/
messages?: {
[key: string]: IExpresssionFunction | string;
[key: string]: IExpressionFunction | string;
}
@@ -440,7 +445,7 @@ declare module AngularFormly {
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
*/
validators?: {
[key: string]: string | IExpresssionFunction | IValidator;
[key: string]: string | IExpressionFunction | IValidator;
}
@@ -573,7 +578,7 @@ declare module AngularFormly {
//Shortcut to options.formControl
fc: ng.IFormController | ng.IFormController[];
//all the fields for the form
fields: IFieldConfigurationObject[];
fields: IFieldArray;
//the form controller the field is in
form: any;
//The object passed as options.formState to the formly-form directive. Use this to share state between fields.