1
- //! angular-formly version 6.21.1 built with ♥ by Astrism <[email protected] >, Kent C. Dodds <[email protected] > (ó ì_í)=óò=(ì_í ò)
1
+ //! angular-formly version 6.22.0 built with ♥ by Astrism <[email protected] >, Kent C. Dodds <[email protected] > (ó ì_í)=óò=(ì_í ò)
2
2
3
3
( function webpackUniversalModuleDefinition ( root , factory ) {
4
4
if ( typeof exports === 'object' && typeof module === 'object' )
@@ -147,7 +147,7 @@ return /******/ (function(modules) { // webpackBootstrap
147
147
148
148
ngModule . constant ( 'formlyApiCheck' , _providersFormlyApiCheck2 [ 'default' ] ) ;
149
149
ngModule . constant ( 'formlyErrorAndWarningsUrlPrefix' , _otherDocsBaseUrl2 [ 'default' ] ) ;
150
- ngModule . constant ( 'formlyVersion' , ( "6.21.1 " ) ) ; // <-- webpack variable
150
+ ngModule . constant ( 'formlyVersion' , ( "6.22.0 " ) ) ; // <-- webpack variable
151
151
152
152
ngModule . provider ( 'formlyUsability' , _providersFormlyUsability2 [ 'default' ] ) ;
153
153
ngModule . provider ( 'formlyConfig' , _providersFormlyConfig2 [ 'default' ] ) ;
@@ -328,6 +328,9 @@ return /******/ (function(modules) { // webpackBootstrap
328
328
id : apiCheck . string . optional ,
329
329
name : apiCheck . string . optional ,
330
330
expressionProperties : expressionProperties . optional ,
331
+ extras : apiCheck . shape ( {
332
+ validateOnModelChange : apiCheck . bool . optional
333
+ } ) . strict . optional ,
331
334
data : apiCheck . object . optional ,
332
335
templateOptions : apiCheck . object . optional ,
333
336
wrapper : specifyWrapperType . optional ,
@@ -445,7 +448,7 @@ return /******/ (function(modules) { // webpackBootstrap
445
448
Object . defineProperty ( exports , "__esModule" , {
446
449
value : true
447
450
} ) ;
448
- exports [ "default" ] = "https://github.com/formly-js/angular-formly/blob/" + ( "6.21.1 " ) + "/other/ERRORS_AND_WARNINGS.md#" ;
451
+ exports [ "default" ] = "https://github.com/formly-js/angular-formly/blob/" + ( "6.22.0 " ) + "/other/ERRORS_AND_WARNINGS.md#" ;
449
452
module . exports = exports [ "default" ] ;
450
453
451
454
/***/ } ,
@@ -1248,6 +1251,7 @@ return /******/ (function(modules) { // webpackBootstrap
1248
1251
return {
1249
1252
restrict : 'AE' ,
1250
1253
transclude : true ,
1254
+ require : '?^formlyForm' ,
1251
1255
scope : {
1252
1256
options : '=' ,
1253
1257
model : '=' ,
@@ -1282,7 +1286,6 @@ return /******/ (function(modules) { // webpackBootstrap
1282
1286
setDefaultValue ( ) ;
1283
1287
setInitialValue ( ) ;
1284
1288
runExpressions ( ) ;
1285
- addModelWatcher ( $scope , $scope . options ) ;
1286
1289
addValidationMessages ( $scope . options ) ;
1287
1290
invokeControllers ( $scope , $scope . options , fieldType ) ;
1288
1291
@@ -1315,6 +1318,7 @@ return /******/ (function(modules) { // webpackBootstrap
1315
1318
function simplifyLife ( options ) {
1316
1319
// add a few empty objects (if they don't already exist) so you don't have to undefined check everywhere
1317
1320
formlyUtil . reverseDeepMerge ( options , {
1321
+ extras : { } ,
1318
1322
data : { } ,
1319
1323
templateOptions : { } ,
1320
1324
validation : { }
@@ -1377,13 +1381,6 @@ return /******/ (function(modules) { // webpackBootstrap
1377
1381
} ) ;
1378
1382
}
1379
1383
1380
- // initialization functions
1381
- function addModelWatcher ( scope , options ) {
1382
- if ( options . model ) {
1383
- scope . $watch ( 'options.model' , runExpressions , true ) ;
1384
- }
1385
- }
1386
-
1387
1384
function resetModel ( ) {
1388
1385
$scope . model [ $scope . options . key ] = $scope . options . initialValue ;
1389
1386
if ( $scope . options . formControl ) {
@@ -1445,12 +1442,19 @@ return /******/ (function(modules) { // webpackBootstrap
1445
1442
}
1446
1443
1447
1444
// link function
1448
- function fieldLink ( scope , el ) {
1445
+ function fieldLink ( scope , el , attrs , formlyFormCtrl ) {
1449
1446
if ( scope . options . fieldGroup ) {
1450
1447
setFieldGroupTemplate ( ) ;
1451
1448
return ;
1452
1449
}
1453
1450
1451
+ // watch the field model (if exists) if there is no parent formly-form directive (that would watch it instead)
1452
+ if ( ! formlyFormCtrl && scope . options . model ) {
1453
+ scope . $watch ( 'options.model' , function ( ) {
1454
+ return scope . options . runExpressions ( ) ;
1455
+ } , true ) ;
1456
+ }
1457
+
1454
1458
addAttributes ( ) ;
1455
1459
addClasses ( ) ;
1456
1460
@@ -2080,14 +2084,16 @@ return /******/ (function(modules) { // webpackBootstrap
2080
2084
2081
2085
function onModelOrFormStateChange ( ) {
2082
2086
_angularFix2 [ 'default' ] . forEach ( $scope . fields , function runFieldExpressionProperties ( field , index ) {
2083
- /*jshint -W030 */
2084
2087
var model = field . model || $scope . model ;
2085
- field . runExpressions && field . runExpressions ( model ) ;
2088
+ field . runExpressions && field . runExpressions ( ) ;
2086
2089
if ( field . hideExpression ) {
2087
2090
// can't use hide with expressionProperties reliably
2088
2091
var val = model [ field . key ] ;
2089
2092
field . hide = evalCloseToFormlyExpression ( field . hideExpression , val , field , index ) ;
2090
2093
}
2094
+ if ( field . extras && field . extras . validateOnModelChange && field . formControl ) {
2095
+ field . formControl . $validate ( ) ;
2096
+ }
2091
2097
} ) ;
2092
2098
}
2093
2099
@@ -2102,7 +2108,8 @@ return /******/ (function(modules) { // webpackBootstrap
2102
2108
}
2103
2109
}
2104
2110
2105
- _angularFix2 [ 'default' ] . forEach ( $scope . fields , initModel ) ; // initializes the model property if set to 'formState'
2111
+ setupModels ( ) ;
2112
+
2106
2113
_angularFix2 [ 'default' ] . forEach ( $scope . fields , attachKey ) ; // attaches a key based on the index if a key isn't specified
2107
2114
_angularFix2 [ 'default' ] . forEach ( $scope . fields , setupWatchers ) ; // setup watchers for all fields
2108
2115
}
@@ -2138,6 +2145,22 @@ return /******/ (function(modules) { // webpackBootstrap
2138
2145
} ) ;
2139
2146
}
2140
2147
2148
+ function setupModels ( ) {
2149
+ // a set of field models that are already watched (the $scope.model will have its own watcher)
2150
+ var watchedModels = [ $scope . model ] ;
2151
+
2152
+ _angularFix2 [ 'default' ] . forEach ( $scope . fields , function ( field ) {
2153
+ initModel ( field ) ;
2154
+
2155
+ if ( field . model && watchedModels . indexOf ( field . model ) === - 1 ) {
2156
+ $scope . $watch ( function ( ) {
2157
+ return field . model ;
2158
+ } , onModelOrFormStateChange , true ) ;
2159
+ watchedModels . push ( field . model ) ;
2160
+ }
2161
+ } ) ;
2162
+ }
2163
+
2141
2164
function initModel ( field ) {
2142
2165
if ( _angularFix2 [ 'default' ] . isString ( field . model ) ) {
2143
2166
var expression = field . model ;
0 commit comments