Skip to content

Commit

Permalink
Fix definition for IFieldGroup, add IFieldArray as convenience type f…
Browse files Browse the repository at this point in the history
…or formly-form fields property, update tests
  • Loading branch information
Scarrier committed Jan 4, 2016
1 parent bdaf2f0 commit 6dd0b2d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
17 changes: 16 additions & 1 deletion angular-formly/angular-formly-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FormConfig {
}

class AppController {
fields: AngularFormly.IFieldConfigurationObject[];
fields: AngularFormly.IFieldArray;
constructor() {
var vm = this;
vm.fields = [
Expand Down Expand Up @@ -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'
}
}]
}
]
}
Expand Down
35 changes: 20 additions & 15 deletions angular-formly/angular-formly.d.ts
Original file line number Diff line number Diff line change
@@ -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" />

Expand All @@ -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[];
}


Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}


Expand All @@ -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;


/**
Expand Down Expand Up @@ -416,7 +421,7 @@ declare module AngularFormly {
* like in this example.
*/
messages?: {
[key: string]: IExpresssionFunction | string;
[key: string]: IExpressionFunction | string;
}


Expand All @@ -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;
}


Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6dd0b2d

Please sign in to comment.