@yoozly/ngrx-form
Advanced tools
Comparing version 0.0.3 to 0.0.4
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@ngrx/store'), require('rxjs/operators'), require('rxjs')) : | ||
typeof define === 'function' && define.amd ? define('@yoozly/ngrx-form', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@ngrx/store', 'rxjs/operators', 'rxjs'], factory) : | ||
(factory((global.yoozly = global.yoozly || {}, global.yoozly['ngrx-form'] = {}),global.ng.common,global.ng.core,global.ng.forms,global.store,global.rxjs.operators,global.rxjs)); | ||
}(this, (function (exports,common,core,forms,store,operators,rxjs) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/forms'), require('@ngrx/store'), require('rxjs/operators'), require('rxjs'), require('@angular/core')) : | ||
typeof define === 'function' && define.amd ? define('@yoozly/ngrx-form', ['exports', '@angular/forms', '@ngrx/store', 'rxjs/operators', 'rxjs', '@angular/core'], factory) : | ||
(factory((global.yoozly = global.yoozly || {}, global.yoozly['ngrx-form'] = {}),global.ng.forms,global.store,global.rxjs.operators,global.rxjs,global.ng.core)); | ||
}(this, (function (exports,forms,store,operators,rxjs,core) { 'use strict'; | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @param {?} formstate | ||
* @return {?} | ||
*/ | ||
function getInitialState(formstate) { | ||
return { | ||
value: formstate, | ||
errors: {}, | ||
pristine: true, | ||
valid: false | ||
}; | ||
} | ||
/*! ***************************************************************************** | ||
@@ -50,2 +33,26 @@ Copyright (c) Microsoft Corporation. All rights reserved. | ||
}; | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) | ||
return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) | ||
ar.push(r.value); | ||
} | ||
catch (error) { | ||
e = { error: error }; | ||
} | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) | ||
m.call(i); | ||
} | ||
finally { | ||
if (e) | ||
throw e.error; | ||
} | ||
} | ||
return ar; | ||
} | ||
@@ -56,8 +63,94 @@ /** | ||
*/ | ||
var NgrxformDirective = /** @class */ (function () { | ||
function NgrxformDirective(formGroupDirective, store$$1) { | ||
/** | ||
* @return {?} | ||
*/ | ||
function getInitialState() { | ||
return { | ||
value: {}, | ||
errors: {}, | ||
pristine: true, | ||
valid: false | ||
}; | ||
} | ||
/** | ||
* @param {?} forms | ||
* @return {?} | ||
*/ | ||
function NgrxFormReducer(forms$$1) { | ||
/** @type {?} */ | ||
var reducers = forms$$1.reduce(( /** | ||
* @param {?} results | ||
* @param {?} key | ||
* @return {?} | ||
*/function (results, key) { | ||
var _a; | ||
return __assign({}, results, (_a = {}, _a[key] = ( /** | ||
* @param {?=} state | ||
* @param {?=} action | ||
* @return {?} | ||
*/function (state, action) { | ||
if (state === void 0) { | ||
state = getInitialState(); | ||
} | ||
return state; | ||
}), _a)); | ||
}), {}); | ||
return reducers; | ||
} | ||
/** | ||
* @param {?} reducer | ||
* @return {?} | ||
*/ | ||
function ngrxForm(reducer) { | ||
return ( /** | ||
* @param {?} state | ||
* @param {?} action | ||
* @return {?} | ||
*/function (state, action) { | ||
var _a, _b; | ||
if (action.type == "[NgrxForm] Update Form" /* UPDATE_FORM */) { | ||
var _c = action.payload, feature = _c.feature, path = _c.path, form = _c.form; | ||
state = __assign({}, state, (_a = {}, _a[feature] = __assign({}, state[feature], (_b = {}, _b[path] = __assign({}, state[feature][path], form), _b)), _a)); | ||
} | ||
/** @type {?} */ | ||
var nextState = reducer(state, action); | ||
return nextState; | ||
}); | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
var NGRX_FORMS_FEATURE = new core.InjectionToken("Feature Name"); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
var Updateform = /** @class */ (function () { | ||
function Updateform(payload) { | ||
this.payload = payload; | ||
this.type = "[NgrxForm] Update Form" /* UPDATE_FORM */; | ||
} | ||
return Updateform; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
var NgrxFormDirective = /** @class */ (function () { | ||
function NgrxFormDirective(featureName, formGroupDirective, store$$1) { | ||
this.featureName = featureName; | ||
this.formGroupDirective = formGroupDirective; | ||
this.store = store$$1; | ||
this.componentDestroy$ = new rxjs.Subject(); | ||
this.updating = false; | ||
this.updating = null; | ||
} | ||
@@ -67,3 +160,3 @@ /** | ||
*/ | ||
NgrxformDirective.prototype.ngOnInit = /** | ||
NgrxFormDirective.prototype.ngOnInit = /** | ||
* @return {?} | ||
@@ -79,3 +172,3 @@ */ | ||
*/ | ||
NgrxformDirective.prototype.rehydrateForm = /** | ||
NgrxFormDirective.prototype.rehydrateForm = /** | ||
* @private | ||
@@ -90,12 +183,7 @@ * @return {?} | ||
* @return {?} | ||
*/function (data) { return data[_this.config.feature][_this.config.path]; })), operators.tap(( /** | ||
*/function (data) { return data[_this.featureName][_this.path]; })), operators.tap(( /** | ||
* @param {?} formObject | ||
* @return {?} | ||
*/function (formObject) { | ||
/** @type {?} */ | ||
var isEqual = JSON.stringify(_this.updating) === JSON.stringify(formObject.value); | ||
if (!isEqual) { | ||
_this.updating = formObject.value; | ||
_this.formGroupDirective.form.patchValue(formObject.value); | ||
} | ||
_this.formGroupDirective.form.patchValue(formObject.value); | ||
})), operators.takeUntil(this.componentDestroy$)) | ||
@@ -108,3 +196,3 @@ .subscribe(); | ||
*/ | ||
NgrxformDirective.prototype.updateFormState = /** | ||
NgrxFormDirective.prototype.updateFormState = /** | ||
* @private | ||
@@ -115,16 +203,31 @@ * @return {?} | ||
var _this = this; | ||
this.formGroupDirective.form.valueChanges | ||
.pipe(operators.debounceTime(400), operators.distinctUntilChanged(), operators.takeUntil(this.componentDestroy$), operators.tap(( /** | ||
* @param {?} datas | ||
/** @type {?} */ | ||
var formChanges$ = this.formGroupDirective.form.valueChanges.pipe(operators.debounceTime(400)); | ||
/** @type {?} */ | ||
var storeDatas$ = this.store.pipe(store.select(( /** | ||
* @param {?} data | ||
* @return {?} | ||
*/function (data) { return data[_this.featureName][_this.path].value; }))); | ||
rxjs.combineLatest(formChanges$, storeDatas$) | ||
.pipe(operators.takeUntil(this.componentDestroy$), operators.filter(( /** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/function (datas) { | ||
return _this.store.dispatch({ | ||
payload: { | ||
value: datas, | ||
*/function (_a) { | ||
var _b = __read(_a, 2), formDatas = _b[0], storeDatas = _b[1]; | ||
return JSON.stringify(formDatas) !== JSON.stringify(storeDatas); | ||
})), operators.map(( /** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/function (_a) { | ||
var _b = __read(_a, 2), formDatas = _b[0], storeDatas = _b[1]; | ||
return _this.store.dispatch(new Updateform({ | ||
feature: _this.featureName, | ||
path: _this.path, | ||
form: { | ||
value: formDatas, | ||
errors: _this.getErrors(_this.formGroupDirective.form), | ||
pristine: _this.formGroupDirective.pristine, | ||
valid: _this.formGroupDirective.valid | ||
}, | ||
type: _this.config.action | ||
}); | ||
} | ||
})); | ||
}))) | ||
@@ -136,30 +239,27 @@ .subscribe(); | ||
* @param {?} formGroup | ||
* @param {?=} errors | ||
* @return {?} | ||
*/ | ||
NgrxformDirective.prototype.getErrors = /** | ||
NgrxFormDirective.prototype.getErrors = /** | ||
* @private | ||
* @param {?} formGroup | ||
* @param {?=} errors | ||
* @return {?} | ||
*/ | ||
function (formGroup, errors) { | ||
function (formGroup) { | ||
var _this = this; | ||
if (errors === void 0) { | ||
errors = {}; | ||
} | ||
Object.keys(formGroup.controls).forEach(( /** | ||
* @param {?} field | ||
* @return {?} | ||
*/function (field) { | ||
/** @type {?} */ | ||
var control = formGroup.get(field); | ||
return Object.keys(formGroup.controls) | ||
.map(( /** | ||
* @param {?} field | ||
* @return {?} | ||
*/function (field) { return formGroup.get(field); })) | ||
.map(( /** | ||
* @param {?} control | ||
* @return {?} | ||
*/function (control) { | ||
if (control instanceof forms.FormControl && control.errors) { | ||
errors[field] = control.errors; | ||
return control.errors; | ||
} | ||
else if (control instanceof forms.FormGroup) { | ||
errors = __assign({}, errors, _this.getErrors(control)); | ||
return __assign({}, _this.getErrors(control)); | ||
} | ||
})); | ||
return errors; | ||
}; | ||
@@ -169,3 +269,3 @@ /** | ||
*/ | ||
NgrxformDirective.prototype.ngOnDestroy = /** | ||
NgrxFormDirective.prototype.ngOnDestroy = /** | ||
* @return {?} | ||
@@ -177,10 +277,11 @@ */ | ||
}; | ||
NgrxformDirective.decorators = [ | ||
NgrxFormDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[NgrxConnect]' | ||
selector: "[NgrxFormConnect]" | ||
},] } | ||
]; | ||
/** @nocollapse */ | ||
NgrxformDirective.ctorParameters = function () { | ||
NgrxFormDirective.ctorParameters = function () { | ||
return [ | ||
{ type: String, decorators: [{ type: core.Inject, args: [NGRX_FORMS_FEATURE,] }] }, | ||
{ type: forms.FormGroupDirective }, | ||
@@ -190,6 +291,6 @@ { type: store.Store } | ||
}; | ||
NgrxformDirective.propDecorators = { | ||
config: [{ type: core.Input, args: ['NgrxConnect',] }] | ||
NgrxFormDirective.propDecorators = { | ||
path: [{ type: core.Input, args: ["NgrxFormConnect",] }] | ||
}; | ||
return NgrxformDirective; | ||
return NgrxFormDirective; | ||
}()); | ||
@@ -204,7 +305,26 @@ | ||
} | ||
/** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
NgrxFormModule.forFeature = /** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
function (feature) { | ||
return { | ||
ngModule: NgrxFormModule, | ||
providers: [ | ||
{ | ||
provide: NGRX_FORMS_FEATURE, | ||
useValue: feature | ||
} | ||
] | ||
}; | ||
}; | ||
NgrxFormModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
declarations: [NgrxformDirective], | ||
imports: [common.CommonModule], | ||
exports: [NgrxformDirective] | ||
declarations: [NgrxFormDirective], | ||
exports: [NgrxFormDirective], | ||
imports: [] | ||
},] } | ||
@@ -221,4 +341,7 @@ ]; | ||
exports.getInitialState = getInitialState; | ||
exports.NgrxFormReducer = NgrxFormReducer; | ||
exports.ngrxForm = ngrxForm; | ||
exports.NgrxFormModule = NgrxFormModule; | ||
exports.ɵa = NgrxformDirective; | ||
exports.ɵa = NgrxFormDirective; | ||
exports.ɵb = NGRX_FORMS_FEATURE; | ||
@@ -225,0 +348,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/forms"),require("@ngrx/store"),require("rxjs/operators"),require("rxjs")):"function"==typeof define&&define.amd?define("@yoozly/ngrx-form",["exports","@angular/common","@angular/core","@angular/forms","@ngrx/store","rxjs/operators","rxjs"],t):t((r.yoozly=r.yoozly||{},r.yoozly["ngrx-form"]={}),r.ng.common,r.ng.core,r.ng.forms,r.store,r.rxjs.operators,r.rxjs)}(this,function(r,t,e,i,o,n,s){"use strict";var a=function(){return(a=Object.assign||function(r){for(var t,e=1,o=arguments.length;e<o;e++)for(var n in t=arguments[e])Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n]);return r}).apply(this,arguments)},u=function(){function r(r,t){this.formGroupDirective=r,this.store=t,this.componentDestroy$=new s.Subject,this.updating=!1}return r.prototype.ngOnInit=function(){this.rehydrateForm(),this.updateFormState()},r.prototype.rehydrateForm=function(){var t=this;this.store.pipe(o.select(function(r){return r[t.config.feature][t.config.path]}),n.tap(function(r){JSON.stringify(t.updating)===JSON.stringify(r.value)||(t.updating=r.value,t.formGroupDirective.form.patchValue(r.value))}),n.takeUntil(this.componentDestroy$)).subscribe()},r.prototype.updateFormState=function(){var t=this;this.formGroupDirective.form.valueChanges.pipe(n.debounceTime(400),n.distinctUntilChanged(),n.takeUntil(this.componentDestroy$),n.tap(function(r){return t.store.dispatch({payload:{value:r,errors:t.getErrors(t.formGroupDirective.form),pristine:t.formGroupDirective.pristine,valid:t.formGroupDirective.valid},type:t.config.action})})).subscribe()},r.prototype.getErrors=function(e,o){var n=this;return void 0===o&&(o={}),Object.keys(e.controls).forEach(function(r){var t=e.get(r);t instanceof i.FormControl&&t.errors?o[r]=t.errors:t instanceof i.FormGroup&&(o=a({},o,n.getErrors(t)))}),o},r.prototype.ngOnDestroy=function(){this.componentDestroy$.next(),this.componentDestroy$.complete()},r.decorators=[{type:e.Directive,args:[{selector:"[NgrxConnect]"}]}],r.ctorParameters=function(){return[{type:i.FormGroupDirective},{type:o.Store}]},r.propDecorators={config:[{type:e.Input,args:["NgrxConnect"]}]},r}(),c=function(){function r(){}return r.decorators=[{type:e.NgModule,args:[{declarations:[u],imports:[t.CommonModule],exports:[u]}]}],r}();r.getInitialState=function p(r){return{value:r,errors:{},pristine:!0,valid:!1}},r.NgrxFormModule=c,r.ɵa=u,Object.defineProperty(r,"__esModule",{value:!0})}); | ||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/forms"),require("@ngrx/store"),require("rxjs/operators"),require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@yoozly/ngrx-form",["exports","@angular/forms","@ngrx/store","rxjs/operators","rxjs","@angular/core"],e):e((r.yoozly=r.yoozly||{},r.yoozly["ngrx-form"]={}),r.ng.forms,r.store,r.rxjs.operators,r.rxjs,r.ng.core)}(this,function(r,o,t,n,i,a){"use strict";var p=function(){return(p=Object.assign||function(r){for(var e,t=1,o=arguments.length;t<o;t++)for(var n in e=arguments[t])Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}).apply(this,arguments)};function u(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var o,n,i=t.call(r),a=[];try{for(;(void 0===e||0<e--)&&!(o=i.next()).done;)a.push(o.value)}catch(u){n={error:u}}finally{try{o&&!o.done&&(t=i["return"])&&t.call(i)}finally{if(n)throw n.error}}return a}function e(){return{value:{},errors:{},pristine:!0,valid:!1}}var s=new a.InjectionToken("Feature Name"),c=function m(r){this.payload=r,this.type="[NgrxForm] Update Form"},f=function(){function r(r,e,t){this.featureName=r,this.formGroupDirective=e,this.store=t,this.componentDestroy$=new i.Subject,this.updating=null}return r.prototype.ngOnInit=function(){this.rehydrateForm(),this.updateFormState()},r.prototype.rehydrateForm=function(){var e=this;this.store.pipe(t.select(function(r){return r[e.featureName][e.path]}),n.tap(function(r){e.formGroupDirective.form.patchValue(r.value)}),n.takeUntil(this.componentDestroy$)).subscribe()},r.prototype.updateFormState=function(){var o=this,r=this.formGroupDirective.form.valueChanges.pipe(n.debounceTime(400)),e=this.store.pipe(t.select(function(r){return r[o.featureName][o.path].value}));i.combineLatest(r,e).pipe(n.takeUntil(this.componentDestroy$),n.filter(function(r){var e=u(r,2),t=e[0],o=e[1];return JSON.stringify(t)!==JSON.stringify(o)}),n.map(function(r){var e=u(r,2),t=e[0];e[1];return o.store.dispatch(new c({feature:o.featureName,path:o.path,form:{value:t,errors:o.getErrors(o.formGroupDirective.form),pristine:o.formGroupDirective.pristine,valid:o.formGroupDirective.valid}}))})).subscribe()},r.prototype.getErrors=function(e){var t=this;return Object.keys(e.controls).map(function(r){return e.get(r)}).map(function(r){return r instanceof o.FormControl&&r.errors?r.errors:r instanceof o.FormGroup?p({},t.getErrors(r)):void 0})},r.prototype.ngOnDestroy=function(){this.componentDestroy$.next(),this.componentDestroy$.complete()},r.decorators=[{type:a.Directive,args:[{selector:"[NgrxFormConnect]"}]}],r.ctorParameters=function(){return[{type:String,decorators:[{type:a.Inject,args:[s]}]},{type:o.FormGroupDirective},{type:t.Store}]},r.propDecorators={path:[{type:a.Input,args:["NgrxFormConnect"]}]},r}(),l=function(){function e(){}return e.forFeature=function(r){return{ngModule:e,providers:[{provide:s,useValue:r}]}},e.decorators=[{type:a.NgModule,args:[{declarations:[f],exports:[f],imports:[]}]}],e}();r.getInitialState=e,r.NgrxFormReducer=function y(r){return r.reduce(function(r,e){var t;return p({},r,((t={})[e]=function(r,e){return void 0===r&&(r={value:{},errors:{},pristine:!0,valid:!1}),r},t))},{})},r.ngrxForm=function d(s){return function(r,e){var t,o;if("[NgrxForm] Update Form"==e.type){var n=e.payload,i=n.feature,a=n.path,u=n.form;r=p({},r,((t={})[i]=p({},r[i],((o={})[a]=p({},r[i][a],u),o)),t))}return s(r,e)}},r.NgrxFormModule=l,r.ɵa=f,r.ɵb=s,Object.defineProperty(r,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=yoozly-ngrx-form.umd.min.js.map |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export {} from "./ngrxform.model"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9tb2RlbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLGVBQWMsa0JBQWtCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi9uZ3J4Zm9ybS5tb2RlbFwiO1xuIl19 | ||
export {} from "./form.models"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9tb2RlbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLGVBQWMsZUFBZSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vZm9ybS5tb2RlbHNcIjtcbiJdfQ== |
@@ -6,13 +6,28 @@ /** | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { NgrxformDirective } from "./directives/ngrxform.directive"; | ||
import { NgrxFormDirective } from "./directives/form.directives"; | ||
import { NGRX_FORMS_FEATURE } from "./services/form.tokens"; | ||
export class NgrxFormModule { | ||
/** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
static forFeature(feature) { | ||
return { | ||
ngModule: NgrxFormModule, | ||
providers: [ | ||
{ | ||
provide: NGRX_FORMS_FEATURE, | ||
useValue: feature | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
NgrxFormModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [NgrxformDirective], | ||
imports: [CommonModule], | ||
exports: [NgrxformDirective] | ||
declarations: [NgrxFormDirective], | ||
exports: [NgrxFormDirective], | ||
imports: [] | ||
},] } | ||
]; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmdyeC1mb3JtLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsibGliL25ncngtZm9ybS5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBRS9DLE9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nb2R1bGUsXG4gICAgICBwcm92aWRlcnM6IFtcbiAgICAgICAge1xuICAgICAgICAgIHByb3ZpZGU6IE5HUlhfRk9STVNfRkVBVFVSRSxcbiAgICAgICAgICB1c2VWYWx1ZTogZmVhdHVyZVxuICAgICAgICB9XG4gICAgICBdXG4gICAgfTtcbiAgfVxufVxuIl19 |
@@ -5,14 +5,3 @@ /** | ||
*/ | ||
/** | ||
* @param {?} formstate | ||
* @return {?} | ||
*/ | ||
export function getInitialState(formstate) { | ||
return { | ||
value: formstate, | ||
errors: {}, | ||
pristine: true, | ||
valid: false | ||
}; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9zdG9yZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQUVBLE1BQU0sVUFBVSxlQUFlLENBQUMsU0FBUztJQUN2QyxPQUFPO1FBQ0wsS0FBSyxFQUFFLFNBQVM7UUFDaEIsTUFBTSxFQUFFLEVBQUU7UUFDVixRQUFRLEVBQUUsSUFBSTtRQUNkLEtBQUssRUFBRSxLQUFLO0tBQ2IsQ0FBQztBQUNKLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ3J4Zm9ybVN0YXRlIH0gZnJvbSBcIi4uL21vZGVsc1wiO1xuXG5leHBvcnQgZnVuY3Rpb24gZ2V0SW5pdGlhbFN0YXRlKGZvcm1zdGF0ZSk6IE5ncnhmb3JtU3RhdGU8YW55PiB7XG4gIHJldHVybiB7XG4gICAgdmFsdWU6IGZvcm1zdGF0ZSxcbiAgICBlcnJvcnM6IHt9LFxuICAgIHByaXN0aW5lOiB0cnVlLFxuICAgIHZhbGlkOiBmYWxzZVxuICB9O1xufVxuIl19 | ||
export { getInitialState, NgrxFormReducer, ngrxForm } from "./form.reducers"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9zdG9yZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsMkRBQWMsaUJBQWlCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi9mb3JtLnJlZHVjZXJzXCI7XG4iXX0= |
@@ -9,4 +9,4 @@ /** | ||
export {} from "./lib/models"; | ||
export { getInitialState } from "./lib/store"; | ||
export { getInitialState, NgrxFormReducer, ngrxForm } from "./lib/store"; | ||
export { NgrxFormModule } from "./lib/ngrx-form.module"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsicHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZUFBYyxjQUFjLENBQUM7QUFDN0IsZ0NBQWMsYUFBYSxDQUFDO0FBQzVCLCtCQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZ3J4LWZvcm1cbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbW9kZWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvc3RvcmVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3J4LWZvcm0ubW9kdWxlXCI7XG4iXX0= | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsicHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZUFBYyxjQUFjLENBQUM7QUFDN0IsMkRBQWMsYUFBYSxDQUFDO0FBQzVCLCtCQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZ3J4LWZvcm1cbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbW9kZWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvc3RvcmVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3J4LWZvcm0ubW9kdWxlXCI7XG4iXX0= |
@@ -8,4 +8,5 @@ /** | ||
*/ | ||
export { getInitialState, NgrxFormModule } from './public_api'; | ||
export { NgrxformDirective as ɵa } from './lib/directives/ngrxform.directive'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieW9vemx5LW5ncngtZm9ybS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsieW9vemx5LW5ncngtZm9ybS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZ0RBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxpQkFBaUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxxQ0FBcUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWNfYXBpJztcblxuZXhwb3J0IHtOZ3J4Zm9ybURpcmVjdGl2ZSBhcyDJtWF9IGZyb20gJy4vbGliL2RpcmVjdGl2ZXMvbmdyeGZvcm0uZGlyZWN0aXZlJzsiXX0= | ||
export { getInitialState, NgrxFormReducer, ngrxForm, NgrxFormModule } from './public_api'; | ||
export { NgrxFormDirective as ɵa } from './lib/directives/form.directives'; | ||
export { NGRX_FORMS_FEATURE as ɵb } from './lib/services/form.tokens'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieW9vemx5LW5ncngtZm9ybS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsieW9vemx5LW5ncngtZm9ybS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsMkVBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxpQkFBaUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxrQ0FBa0MsQ0FBQztBQUN6RSxPQUFPLEVBQUMsa0JBQWtCLElBQUksRUFBRSxFQUFDLE1BQU0sNEJBQTRCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG5cbmV4cG9ydCB7TmdyeEZvcm1EaXJlY3RpdmUgYXMgybVhfSBmcm9tICcuL2xpYi9kaXJlY3RpdmVzL2Zvcm0uZGlyZWN0aXZlcyc7XG5leHBvcnQge05HUlhfRk9STVNfRkVBVFVSRSBhcyDJtWJ9IGZyb20gJy4vbGliL3NlcnZpY2VzL2Zvcm0udG9rZW5zJzsiXX0= |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export {} from "./ngrxform.model"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9tb2RlbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLGVBQWMsa0JBQWtCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi9uZ3J4Zm9ybS5tb2RlbFwiO1xuIl19 | ||
export {} from "./form.models"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9tb2RlbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLGVBQWMsZUFBZSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSBcIi4vZm9ybS5tb2RlbHNcIjtcbiJdfQ== |
@@ -6,12 +6,31 @@ /** | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { NgrxformDirective } from "./directives/ngrxform.directive"; | ||
import { NgrxFormDirective } from "./directives/form.directives"; | ||
import { NGRX_FORMS_FEATURE } from "./services/form.tokens"; | ||
var NgrxFormModule = /** @class */ (function () { | ||
function NgrxFormModule() { | ||
} | ||
/** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
NgrxFormModule.forFeature = /** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
function (feature) { | ||
return { | ||
ngModule: NgrxFormModule, | ||
providers: [ | ||
{ | ||
provide: NGRX_FORMS_FEATURE, | ||
useValue: feature | ||
} | ||
] | ||
}; | ||
}; | ||
NgrxFormModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [NgrxformDirective], | ||
imports: [CommonModule], | ||
exports: [NgrxformDirective] | ||
declarations: [NgrxFormDirective], | ||
exports: [NgrxFormDirective], | ||
imports: [] | ||
},] } | ||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eyBOZ3J4Rm9ybURpcmVjdGl2ZSB9IGZyb20gXCIuL2RpcmVjdGl2ZXMvZm9ybS5kaXJlY3RpdmVzXCI7XG5pbXBvcnQgeyBOR1JYX0ZPUk1TX0ZFQVRVUkUgfSBmcm9tIFwiLi9zZXJ2aWNlcy9mb3JtLnRva2Vuc1wiO1xuXG5ATmdNb2R1bGUoe1xuICBkZWNsYXJhdGlvbnM6IFtOZ3J4Rm9ybURpcmVjdGl2ZV0sXG4gIGV4cG9ydHM6IFtOZ3J4Rm9ybURpcmVjdGl2ZV0sXG4gIGltcG9ydHM6IFtdXG59KVxuZXhwb3J0IGNsYXNzIE5ncnhGb3JtTW9kdWxlIHtcbiAgc3RhdGljIGZvckZlYXR1cmUoZmVhdHVyZTogc3RyaW5nKTogTW9kdWxlV2l0aFByb3ZpZGVycyB7XG4gICAgcmV0dXJuIHtcbiAgICAgIG5nTW9kdWxlOiBOZ3J4Rm9ybU1vZHVsZSxcbiAgICAgIHByb3ZpZGVyczogW1xuICAgICAgICB7XG4gICAgICAgICAgcHJvdmlkZTogTkdSWF9GT1JNU19GRUFUVVJFLFxuICAgICAgICAgIHVzZVZhbHVlOiBmZWF0dXJlXG4gICAgICAgIH1cbiAgICAgIF1cbiAgICB9O1xuICB9XG59XG4iXX0= |
@@ -5,14 +5,3 @@ /** | ||
*/ | ||
/** | ||
* @param {?} formstate | ||
* @return {?} | ||
*/ | ||
export function getInitialState(formstate) { | ||
return { | ||
value: formstate, | ||
errors: {}, | ||
pristine: true, | ||
valid: false | ||
}; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9zdG9yZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQUVBLE1BQU0sVUFBVSxlQUFlLENBQUMsU0FBUztJQUN2QyxPQUFPO1FBQ0wsS0FBSyxFQUFFLFNBQVM7UUFDaEIsTUFBTSxFQUFFLEVBQUU7UUFDVixRQUFRLEVBQUUsSUFBSTtRQUNkLEtBQUssRUFBRSxLQUFLO0tBQ2IsQ0FBQztBQUNKLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ3J4Zm9ybVN0YXRlIH0gZnJvbSBcIi4uL21vZGVsc1wiO1xuXG5leHBvcnQgZnVuY3Rpb24gZ2V0SW5pdGlhbFN0YXRlKGZvcm1zdGF0ZSk6IE5ncnhmb3JtU3RhdGU8YW55PiB7XG4gIHJldHVybiB7XG4gICAgdmFsdWU6IGZvcm1zdGF0ZSxcbiAgICBlcnJvcnM6IHt9LFxuICAgIHByaXN0aW5lOiB0cnVlLFxuICAgIHZhbGlkOiBmYWxzZVxuICB9O1xufVxuIl19 | ||
export { getInitialState, NgrxFormReducer, ngrxForm } from "./form.reducers"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AeW9vemx5L25ncngtZm9ybS8iLCJzb3VyY2VzIjpbImxpYi9zdG9yZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsMkRBQWMsaUJBQWlCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tIFwiLi9mb3JtLnJlZHVjZXJzXCI7XG4iXX0= |
@@ -9,4 +9,4 @@ /** | ||
export {} from "./lib/models"; | ||
export { getInitialState } from "./lib/store"; | ||
export { getInitialState, NgrxFormReducer, ngrxForm } from "./lib/store"; | ||
export { NgrxFormModule } from "./lib/ngrx-form.module"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsicHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZUFBYyxjQUFjLENBQUM7QUFDN0IsZ0NBQWMsYUFBYSxDQUFDO0FBQzVCLCtCQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZ3J4LWZvcm1cbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbW9kZWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvc3RvcmVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3J4LWZvcm0ubW9kdWxlXCI7XG4iXX0= | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsicHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZUFBYyxjQUFjLENBQUM7QUFDN0IsMkRBQWMsYUFBYSxDQUFDO0FBQzVCLCtCQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBuZ3J4LWZvcm1cbiAqL1xuXG5leHBvcnQgKiBmcm9tIFwiLi9saWIvbW9kZWxzXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9saWIvc3RvcmVcIjtcbmV4cG9ydCAqIGZyb20gXCIuL2xpYi9uZ3J4LWZvcm0ubW9kdWxlXCI7XG4iXX0= |
@@ -8,4 +8,5 @@ /** | ||
*/ | ||
export { getInitialState, NgrxFormModule } from './public_api'; | ||
export { NgrxformDirective as ɵa } from './lib/directives/ngrxform.directive'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieW9vemx5LW5ncngtZm9ybS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsieW9vemx5LW5ncngtZm9ybS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsZ0RBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxpQkFBaUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxxQ0FBcUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWNfYXBpJztcblxuZXhwb3J0IHtOZ3J4Zm9ybURpcmVjdGl2ZSBhcyDJtWF9IGZyb20gJy4vbGliL2RpcmVjdGl2ZXMvbmdyeGZvcm0uZGlyZWN0aXZlJzsiXX0= | ||
export { getInitialState, NgrxFormReducer, ngrxForm, NgrxFormModule } from './public_api'; | ||
export { NgrxFormDirective as ɵa } from './lib/directives/form.directives'; | ||
export { NGRX_FORMS_FEATURE as ɵb } from './lib/services/form.tokens'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieW9vemx5LW5ncngtZm9ybS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0B5b296bHkvbmdyeC1mb3JtLyIsInNvdXJjZXMiOlsieW9vemx5LW5ncngtZm9ybS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsMkVBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxpQkFBaUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxrQ0FBa0MsQ0FBQztBQUN6RSxPQUFPLEVBQUMsa0JBQWtCLElBQUksRUFBRSxFQUFDLE1BQU0sNEJBQTRCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG5cbmV4cG9ydCB7TmdyeEZvcm1EaXJlY3RpdmUgYXMgybVhfSBmcm9tICcuL2xpYi9kaXJlY3RpdmVzL2Zvcm0uZGlyZWN0aXZlcyc7XG5leHBvcnQge05HUlhfRk9STVNfRkVBVFVSRSBhcyDJtWJ9IGZyb20gJy4vbGliL3NlcnZpY2VzL2Zvcm0udG9rZW5zJzsiXX0= |
@@ -1,7 +0,6 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Directive, Input, NgModule } from '@angular/core'; | ||
import { FormGroupDirective, FormGroup, FormControl } from '@angular/forms'; | ||
import { Store, select } from '@ngrx/store'; | ||
import { tap, debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; | ||
import { Subject } from 'rxjs'; | ||
import { tap, debounceTime, takeUntil, filter, map } from 'rxjs/operators'; | ||
import { Subject, combineLatest } from 'rxjs'; | ||
import { InjectionToken, Directive, Input, Inject, NgModule } from '@angular/core'; | ||
@@ -23,8 +22,7 @@ /** | ||
/** | ||
* @param {?} formstate | ||
* @return {?} | ||
*/ | ||
function getInitialState(formstate) { | ||
function getInitialState() { | ||
return { | ||
value: formstate, | ||
value: {}, | ||
errors: {}, | ||
@@ -35,2 +33,43 @@ pristine: true, | ||
} | ||
/** | ||
* @param {?} forms | ||
* @return {?} | ||
*/ | ||
function NgrxFormReducer(forms) { | ||
/** @type {?} */ | ||
const reducers = forms.reduce((/** | ||
* @param {?} results | ||
* @param {?} key | ||
* @return {?} | ||
*/ | ||
(results, key) => { | ||
return Object.assign({}, results, { [key]: (/** | ||
* @param {?=} state | ||
* @param {?=} action | ||
* @return {?} | ||
*/ | ||
(state = getInitialState(), action) => state) }); | ||
}), {}); | ||
return reducers; | ||
} | ||
/** | ||
* @param {?} reducer | ||
* @return {?} | ||
*/ | ||
function ngrxForm(reducer) { | ||
return (/** | ||
* @param {?} state | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
function (state, action) { | ||
if (action.type == "[NgrxForm] Update Form" /* UPDATE_FORM */) { | ||
const { feature, path, form } = action.payload; | ||
state = Object.assign({}, state, { [feature]: Object.assign({}, state[feature], { [path]: Object.assign({}, state[feature][path], form) }) }); | ||
} | ||
/** @type {?} */ | ||
let nextState = reducer(state, action); | ||
return nextState; | ||
}); | ||
} | ||
@@ -41,12 +80,40 @@ /** | ||
*/ | ||
class NgrxformDirective { | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
const NGRX_FORMS_FEATURE = new InjectionToken("Feature Name"); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
class Updateform { | ||
/** | ||
* @param {?} payload | ||
*/ | ||
constructor(payload) { | ||
this.payload = payload; | ||
this.type = "[NgrxForm] Update Form" /* UPDATE_FORM */; | ||
} | ||
} | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
class NgrxFormDirective { | ||
/** | ||
* @param {?} featureName | ||
* @param {?} formGroupDirective | ||
* @param {?} store | ||
*/ | ||
constructor(formGroupDirective, store) { | ||
constructor(featureName, formGroupDirective, store) { | ||
this.featureName = featureName; | ||
this.formGroupDirective = formGroupDirective; | ||
this.store = store; | ||
this.componentDestroy$ = new Subject(); | ||
this.updating = false; | ||
this.updating = null; | ||
} | ||
@@ -70,3 +137,3 @@ /** | ||
*/ | ||
data => data[this.config.feature][this.config.path])), tap((/** | ||
data => data[this.featureName][this.path])), tap((/** | ||
* @param {?} formObject | ||
@@ -76,8 +143,3 @@ * @return {?} | ||
(formObject) => { | ||
/** @type {?} */ | ||
const isEqual = JSON.stringify(this.updating) === JSON.stringify(formObject.value); | ||
if (!isEqual) { | ||
this.updating = formObject.value; | ||
this.formGroupDirective.form.patchValue(formObject.value); | ||
} | ||
this.formGroupDirective.form.patchValue(formObject.value); | ||
})), takeUntil(this.componentDestroy$)) | ||
@@ -91,16 +153,29 @@ .subscribe(); | ||
updateFormState() { | ||
this.formGroupDirective.form.valueChanges | ||
.pipe(debounceTime(400), distinctUntilChanged(), takeUntil(this.componentDestroy$), tap((/** | ||
* @param {?} datas | ||
/** @type {?} */ | ||
const formChanges$ = this.formGroupDirective.form.valueChanges.pipe(debounceTime(400)); | ||
/** @type {?} */ | ||
const storeDatas$ = this.store.pipe(select((/** | ||
* @param {?} data | ||
* @return {?} | ||
*/ | ||
datas => this.store.dispatch({ | ||
payload: { | ||
value: datas, | ||
(data) => data[this.featureName][this.path].value))); | ||
combineLatest(formChanges$, storeDatas$) | ||
.pipe(takeUntil(this.componentDestroy$), filter((/** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/ | ||
([formDatas, storeDatas]) => JSON.stringify(formDatas) !== JSON.stringify(storeDatas))), map((/** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/ | ||
([formDatas, storeDatas]) => this.store.dispatch(new Updateform({ | ||
feature: this.featureName, | ||
path: this.path, | ||
form: { | ||
value: formDatas, | ||
errors: this.getErrors(this.formGroupDirective.form), | ||
pristine: this.formGroupDirective.pristine, | ||
valid: this.formGroupDirective.valid | ||
}, | ||
type: this.config.action | ||
})))) | ||
} | ||
}))))) | ||
.subscribe(); | ||
@@ -111,21 +186,23 @@ } | ||
* @param {?} formGroup | ||
* @param {?=} errors | ||
* @return {?} | ||
*/ | ||
getErrors(formGroup, errors = {}) { | ||
Object.keys(formGroup.controls).forEach((/** | ||
getErrors(formGroup) { | ||
return Object.keys(formGroup.controls) | ||
.map((/** | ||
* @param {?} field | ||
* @return {?} | ||
*/ | ||
field => { | ||
/** @type {?} */ | ||
const control = formGroup.get(field); | ||
field => formGroup.get(field))) | ||
.map((/** | ||
* @param {?} control | ||
* @return {?} | ||
*/ | ||
control => { | ||
if (control instanceof FormControl && control.errors) { | ||
errors[field] = control.errors; | ||
return control.errors; | ||
} | ||
else if (control instanceof FormGroup) { | ||
errors = Object.assign({}, errors, this.getErrors(control)); | ||
return Object.assign({}, this.getErrors(control)); | ||
} | ||
})); | ||
return errors; | ||
} | ||
@@ -140,14 +217,15 @@ /** | ||
} | ||
NgrxformDirective.decorators = [ | ||
NgrxFormDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[NgrxConnect]' | ||
selector: "[NgrxFormConnect]" | ||
},] } | ||
]; | ||
/** @nocollapse */ | ||
NgrxformDirective.ctorParameters = () => [ | ||
NgrxFormDirective.ctorParameters = () => [ | ||
{ type: String, decorators: [{ type: Inject, args: [NGRX_FORMS_FEATURE,] }] }, | ||
{ type: FormGroupDirective }, | ||
{ type: Store } | ||
]; | ||
NgrxformDirective.propDecorators = { | ||
config: [{ type: Input, args: ['NgrxConnect',] }] | ||
NgrxFormDirective.propDecorators = { | ||
path: [{ type: Input, args: ["NgrxFormConnect",] }] | ||
}; | ||
@@ -160,8 +238,23 @@ | ||
class NgrxFormModule { | ||
/** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
static forFeature(feature) { | ||
return { | ||
ngModule: NgrxFormModule, | ||
providers: [ | ||
{ | ||
provide: NGRX_FORMS_FEATURE, | ||
useValue: feature | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
NgrxFormModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [NgrxformDirective], | ||
imports: [CommonModule], | ||
exports: [NgrxformDirective] | ||
declarations: [NgrxFormDirective], | ||
exports: [NgrxFormDirective], | ||
imports: [] | ||
},] } | ||
@@ -180,4 +273,4 @@ ]; | ||
export { getInitialState, NgrxFormModule, NgrxformDirective as ɵa }; | ||
export { getInitialState, NgrxFormReducer, ngrxForm, NgrxFormModule, NgrxFormDirective as ɵa, NGRX_FORMS_FEATURE as ɵb }; | ||
//# sourceMappingURL=yoozly-ngrx-form.js.map |
@@ -1,8 +0,7 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { __assign } from 'tslib'; | ||
import { Directive, Input, NgModule } from '@angular/core'; | ||
import { __read, __assign } from 'tslib'; | ||
import { FormGroupDirective, FormGroup, FormControl } from '@angular/forms'; | ||
import { Store, select } from '@ngrx/store'; | ||
import { tap, debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; | ||
import { Subject } from 'rxjs'; | ||
import { tap, debounceTime, takeUntil, filter, map } from 'rxjs/operators'; | ||
import { Subject, combineLatest } from 'rxjs'; | ||
import { InjectionToken, Directive, Input, Inject, NgModule } from '@angular/core'; | ||
@@ -24,8 +23,7 @@ /** | ||
/** | ||
* @param {?} formstate | ||
* @return {?} | ||
*/ | ||
function getInitialState(formstate) { | ||
function getInitialState() { | ||
return { | ||
value: formstate, | ||
value: {}, | ||
errors: {}, | ||
@@ -36,2 +34,48 @@ pristine: true, | ||
} | ||
/** | ||
* @param {?} forms | ||
* @return {?} | ||
*/ | ||
function NgrxFormReducer(forms) { | ||
/** @type {?} */ | ||
var reducers = forms.reduce((/** | ||
* @param {?} results | ||
* @param {?} key | ||
* @return {?} | ||
*/ | ||
function (results, key) { | ||
var _a; | ||
return __assign({}, results, (_a = {}, _a[key] = (/** | ||
* @param {?=} state | ||
* @param {?=} action | ||
* @return {?} | ||
*/ | ||
function (state, action) { | ||
if (state === void 0) { state = getInitialState(); } | ||
return state; | ||
}), _a)); | ||
}), {}); | ||
return reducers; | ||
} | ||
/** | ||
* @param {?} reducer | ||
* @return {?} | ||
*/ | ||
function ngrxForm(reducer) { | ||
return (/** | ||
* @param {?} state | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
function (state, action) { | ||
var _a, _b; | ||
if (action.type == "[NgrxForm] Update Form" /* UPDATE_FORM */) { | ||
var _c = action.payload, feature = _c.feature, path = _c.path, form = _c.form; | ||
state = __assign({}, state, (_a = {}, _a[feature] = __assign({}, state[feature], (_b = {}, _b[path] = __assign({}, state[feature][path], form), _b)), _a)); | ||
} | ||
/** @type {?} */ | ||
var nextState = reducer(state, action); | ||
return nextState; | ||
}); | ||
} | ||
@@ -42,8 +86,33 @@ /** | ||
*/ | ||
var NgrxformDirective = /** @class */ (function () { | ||
function NgrxformDirective(formGroupDirective, store) { | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
var NGRX_FORMS_FEATURE = new InjectionToken("Feature Name"); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
var Updateform = /** @class */ (function () { | ||
function Updateform(payload) { | ||
this.payload = payload; | ||
this.type = "[NgrxForm] Update Form" /* UPDATE_FORM */; | ||
} | ||
return Updateform; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
var NgrxFormDirective = /** @class */ (function () { | ||
function NgrxFormDirective(featureName, formGroupDirective, store) { | ||
this.featureName = featureName; | ||
this.formGroupDirective = formGroupDirective; | ||
this.store = store; | ||
this.componentDestroy$ = new Subject(); | ||
this.updating = false; | ||
this.updating = null; | ||
} | ||
@@ -53,3 +122,3 @@ /** | ||
*/ | ||
NgrxformDirective.prototype.ngOnInit = /** | ||
NgrxFormDirective.prototype.ngOnInit = /** | ||
* @return {?} | ||
@@ -65,3 +134,3 @@ */ | ||
*/ | ||
NgrxformDirective.prototype.rehydrateForm = /** | ||
NgrxFormDirective.prototype.rehydrateForm = /** | ||
* @private | ||
@@ -77,3 +146,3 @@ * @return {?} | ||
*/ | ||
function (data) { return data[_this.config.feature][_this.config.path]; })), tap((/** | ||
function (data) { return data[_this.featureName][_this.path]; })), tap((/** | ||
* @param {?} formObject | ||
@@ -83,8 +152,3 @@ * @return {?} | ||
function (formObject) { | ||
/** @type {?} */ | ||
var isEqual = JSON.stringify(_this.updating) === JSON.stringify(formObject.value); | ||
if (!isEqual) { | ||
_this.updating = formObject.value; | ||
_this.formGroupDirective.form.patchValue(formObject.value); | ||
} | ||
_this.formGroupDirective.form.patchValue(formObject.value); | ||
})), takeUntil(this.componentDestroy$)) | ||
@@ -97,3 +161,3 @@ .subscribe(); | ||
*/ | ||
NgrxformDirective.prototype.updateFormState = /** | ||
NgrxFormDirective.prototype.updateFormState = /** | ||
* @private | ||
@@ -104,17 +168,34 @@ * @return {?} | ||
var _this = this; | ||
this.formGroupDirective.form.valueChanges | ||
.pipe(debounceTime(400), distinctUntilChanged(), takeUntil(this.componentDestroy$), tap((/** | ||
* @param {?} datas | ||
/** @type {?} */ | ||
var formChanges$ = this.formGroupDirective.form.valueChanges.pipe(debounceTime(400)); | ||
/** @type {?} */ | ||
var storeDatas$ = this.store.pipe(select((/** | ||
* @param {?} data | ||
* @return {?} | ||
*/ | ||
function (datas) { | ||
return _this.store.dispatch({ | ||
payload: { | ||
value: datas, | ||
function (data) { return data[_this.featureName][_this.path].value; }))); | ||
combineLatest(formChanges$, storeDatas$) | ||
.pipe(takeUntil(this.componentDestroy$), filter((/** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/ | ||
function (_a) { | ||
var _b = __read(_a, 2), formDatas = _b[0], storeDatas = _b[1]; | ||
return JSON.stringify(formDatas) !== JSON.stringify(storeDatas); | ||
})), map((/** | ||
* @param {?} __0 | ||
* @return {?} | ||
*/ | ||
function (_a) { | ||
var _b = __read(_a, 2), formDatas = _b[0], storeDatas = _b[1]; | ||
return _this.store.dispatch(new Updateform({ | ||
feature: _this.featureName, | ||
path: _this.path, | ||
form: { | ||
value: formDatas, | ||
errors: _this.getErrors(_this.formGroupDirective.form), | ||
pristine: _this.formGroupDirective.pristine, | ||
valid: _this.formGroupDirective.valid | ||
}, | ||
type: _this.config.action | ||
}); | ||
} | ||
})); | ||
}))) | ||
@@ -126,29 +207,29 @@ .subscribe(); | ||
* @param {?} formGroup | ||
* @param {?=} errors | ||
* @return {?} | ||
*/ | ||
NgrxformDirective.prototype.getErrors = /** | ||
NgrxFormDirective.prototype.getErrors = /** | ||
* @private | ||
* @param {?} formGroup | ||
* @param {?=} errors | ||
* @return {?} | ||
*/ | ||
function (formGroup, errors) { | ||
function (formGroup) { | ||
var _this = this; | ||
if (errors === void 0) { errors = {}; } | ||
Object.keys(formGroup.controls).forEach((/** | ||
return Object.keys(formGroup.controls) | ||
.map((/** | ||
* @param {?} field | ||
* @return {?} | ||
*/ | ||
function (field) { | ||
/** @type {?} */ | ||
var control = formGroup.get(field); | ||
function (field) { return formGroup.get(field); })) | ||
.map((/** | ||
* @param {?} control | ||
* @return {?} | ||
*/ | ||
function (control) { | ||
if (control instanceof FormControl && control.errors) { | ||
errors[field] = control.errors; | ||
return control.errors; | ||
} | ||
else if (control instanceof FormGroup) { | ||
errors = __assign({}, errors, _this.getErrors(control)); | ||
return __assign({}, _this.getErrors(control)); | ||
} | ||
})); | ||
return errors; | ||
}; | ||
@@ -158,3 +239,3 @@ /** | ||
*/ | ||
NgrxformDirective.prototype.ngOnDestroy = /** | ||
NgrxFormDirective.prototype.ngOnDestroy = /** | ||
* @return {?} | ||
@@ -166,16 +247,17 @@ */ | ||
}; | ||
NgrxformDirective.decorators = [ | ||
NgrxFormDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[NgrxConnect]' | ||
selector: "[NgrxFormConnect]" | ||
},] } | ||
]; | ||
/** @nocollapse */ | ||
NgrxformDirective.ctorParameters = function () { return [ | ||
NgrxFormDirective.ctorParameters = function () { return [ | ||
{ type: String, decorators: [{ type: Inject, args: [NGRX_FORMS_FEATURE,] }] }, | ||
{ type: FormGroupDirective }, | ||
{ type: Store } | ||
]; }; | ||
NgrxformDirective.propDecorators = { | ||
config: [{ type: Input, args: ['NgrxConnect',] }] | ||
NgrxFormDirective.propDecorators = { | ||
path: [{ type: Input, args: ["NgrxFormConnect",] }] | ||
}; | ||
return NgrxformDirective; | ||
return NgrxFormDirective; | ||
}()); | ||
@@ -190,7 +272,26 @@ | ||
} | ||
/** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
NgrxFormModule.forFeature = /** | ||
* @param {?} feature | ||
* @return {?} | ||
*/ | ||
function (feature) { | ||
return { | ||
ngModule: NgrxFormModule, | ||
providers: [ | ||
{ | ||
provide: NGRX_FORMS_FEATURE, | ||
useValue: feature | ||
} | ||
] | ||
}; | ||
}; | ||
NgrxFormModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [NgrxformDirective], | ||
imports: [CommonModule], | ||
exports: [NgrxformDirective] | ||
declarations: [NgrxFormDirective], | ||
exports: [NgrxFormDirective], | ||
imports: [] | ||
},] } | ||
@@ -211,4 +312,4 @@ ]; | ||
export { getInitialState, NgrxFormModule, NgrxformDirective as ɵa }; | ||
export { getInitialState, NgrxFormReducer, ngrxForm, NgrxFormModule, NgrxFormDirective as ɵa, NGRX_FORMS_FEATURE as ɵb }; | ||
//# sourceMappingURL=yoozly-ngrx-form.js.map |
@@ -1,1 +0,1 @@ | ||
export * from "./ngrxform.model"; | ||
export * from "./form.models"; |
@@ -0,2 +1,4 @@ | ||
import { ModuleWithProviders } from "@angular/core"; | ||
export declare class NgrxFormModule { | ||
static forFeature(feature: string): ModuleWithProviders; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { NgrxformState } from "../models"; | ||
export declare function getInitialState(formstate: any): NgrxformState<any>; | ||
export * from "./form.reducers"; |
{ | ||
"name": "@yoozly/ngrx-form", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Guillaume Doutriaux", | ||
"peerDependencies": { | ||
"@angular/common": "^7.2.0", | ||
"@angular/core": "^7.2.0" | ||
"@angular/core": "~7.2.0", | ||
"@angular/forms": "~7.2.0", | ||
"@ngrx/core": "^1.2.0", | ||
"@ngrx/store": "^7.2.0", | ||
"rxjs": "~6.3.3" | ||
}, | ||
@@ -8,0 +12,0 @@ "main": "bundles/yoozly-ngrx-form.umd.js", |
# NgrxForm | ||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0. | ||
## Code scaffolding | ||
Run `ng generate component component-name --project ngrx-form` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngrx-form`. | ||
> Note: Don't forget to add `--project ngrx-form` or else it will be added to the default project in your `angular.json` file. | ||
## Build | ||
Run `ng build ngrx-form` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
## Publishing | ||
After building your library with `ng build ngrx-form`, go to the dist folder `cd dist/ngrx-form` and run `npm publish`. | ||
## Running unit tests | ||
Run `ng test ngrx-form` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
## Further help | ||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). | ||
Bindings between @angular/reactive-forms and @ngrx/store. |
@@ -5,2 +5,3 @@ /** | ||
export * from './public_api'; | ||
export { NgrxformDirective as ɵa } from './lib/directives/ngrxform.directive'; | ||
export { NgrxFormDirective as ɵa } from './lib/directives/form.directives'; | ||
export { NGRX_FORMS_FEATURE as ɵb } from './lib/services/form.tokens'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"exports":[{"from":"./lib/ngrxform.model"}],"metadata":{"getInitialState":{"__symbolic":"function","parameters":["formstate"],"value":{"value":{"__symbolic":"reference","name":"formstate"},"errors":{},"pristine":true,"valid":false}},"NgrxFormModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":5,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":7,"character":12}],"exports":[{"__symbolic":"reference","name":"ɵa"}]}]}],"members":{}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":14,"character":1},"arguments":[{"selector":"[NgrxConnect]"}]}],"members":{"config":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":18,"character":3},"arguments":["NgrxConnect"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/forms","name":"FormGroupDirective","line":24,"character":32},{"__symbolic":"reference","name":"Store","module":"@ngrx/store","arguments":[{"__symbolic":"reference","name":"any"}]}]}],"ngOnInit":[{"__symbolic":"method"}],"rehydrateForm":[{"__symbolic":"method"}],"updateFormState":[{"__symbolic":"method"}],"getErrors":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]}}},"origins":{"getInitialState":"./lib/store","NgrxFormModule":"./lib/ngrx-form.module","ɵa":"./lib/directives/ngrxform.directive"},"importAs":"@yoozly/ngrx-form"} | ||
{"__symbolic":"module","version":4,"exports":[{"from":"./lib/form.reducers"}],"metadata":{"NgrxFormModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":5,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"exports":[{"__symbolic":"reference","name":"ɵa"}],"imports":[]}]}],"members":{},"statics":{"forFeature":{"__symbolic":"function","parameters":["feature"],"value":{"ngModule":{"__symbolic":"reference","name":"NgrxFormModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵb"},"useValue":{"__symbolic":"reference","name":"feature"}}]}}}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":17,"character":1},"arguments":[{"selector":"[NgrxFormConnect]"}]}],"members":{"path":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":21,"character":3},"arguments":["NgrxFormConnect"]}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":27,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵb"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"@angular/forms","name":"FormGroupDirective","line":28,"character":32},{"__symbolic":"reference","name":"Store","module":"@ngrx/store","arguments":[{"__symbolic":"reference","name":"any"}]}]}],"ngOnInit":[{"__symbolic":"method"}],"rehydrateForm":[{"__symbolic":"method"}],"updateFormState":[{"__symbolic":"method"}],"getErrors":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]}},"ɵb":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":2,"character":38},"arguments":["Feature Name"]}},"origins":{"NgrxFormModule":"./lib/ngrx-form.module","ɵa":"./lib/directives/form.directives","ɵb":"./lib/services/form.tokens"},"importAs":"@yoozly/ngrx-form"} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
181607
42
1651
1
6
4
1