From 6dd0b2dc5ca7033ddd3eab2743ec54465fb65cf8 Mon Sep 17 00:00:00 2001 From: Scarrier Date: Mon, 4 Jan 2016 15:43:02 -0600 Subject: [PATCH] Fix definition for IFieldGroup, add IFieldArray as convenience type for formly-form fields property, update tests --- angular-formly/angular-formly-tests.ts | 17 ++++++++++++- angular-formly/angular-formly.d.ts | 35 +++++++++++++++----------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/angular-formly/angular-formly-tests.ts b/angular-formly/angular-formly-tests.ts index ef6a38463..2374fde4a 100644 --- a/angular-formly/angular-formly-tests.ts +++ b/angular-formly/angular-formly-tests.ts @@ -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' + } + }] } ] } diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index fce793e7e..7ee3d3194 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -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 -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -16,18 +16,23 @@ declare module 'angular-formly' { declare module AngularFormly { + interface IFieldArray extends Array { + + } 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.