Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ngneat/forms-manager

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngneat/forms-manager - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

esm2015/lib/builders.js

1202

bundles/ngneat-forms-manager.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('lodash.isequal')) :
typeof define === 'function' && define.amd ? define('@ngneat/forms-manager', ['exports', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/core', 'lodash.isequal'], factory) :
(factory((global.ngneat = global.ngneat || {}, global.ngneat['forms-manager'] = {}),global.ng.forms,global.rxjs,global.rxjs.operators,global.ng.core,global.isEqual));
}(this, (function (exports,forms,rxjs,operators,i0,isEqual) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/forms')) :
typeof define === 'function' && define.amd ? define('@ngneat/forms-manager', ['exports', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/forms'], factory) :
(factory((global.ngneat = global.ngneat || {}, global.ngneat['forms-manager'] = {}),global.rxjs,global.rxjs.operators,global.ng.core,global.ng.forms));
}(this, (function (exports,rxjs,operators,i0,forms) { 'use strict';
isEqual = isEqual && isEqual.hasOwnProperty('default') ? isEqual['default'] : isEqual;
/*! *****************************************************************************

@@ -138,3 +136,2 @@ Copyright (c) Microsoft Corporation. All rights reserved.

'valid',
'rawValue',
];

@@ -152,2 +149,18 @@ /**

/**
* @param {?} arr
* @param {?} cb
* @return {?}
*/
function filtrArrayKeys(arr, cb) {
return arr.reduce(( /**
* @param {?} acc
* @param {?} control
* @param {?} index
* @return {?}
*/function (acc, control, index) {
acc[index] = filterKeys(control, cb);
return acc;
}), []);
}
/**
* @param {?} obj

@@ -168,4 +181,7 @@ * @param {?} cb

if (isObject(value)) {
filtered[key] = filterKeys(obj[key], cb);
filtered[key] = filterKeys(value, cb);
}
else if (Array.isArray(value) && key === 'controls') {
filtered[key] = filtrArrayKeys(value, cb);
}
else {

@@ -314,3 +330,3 @@ filtered[key] = value;

}
return ( /** @type {?} */(__assign({ storage: __assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
return ( /** @type {?} */(__assign({}, defaults, { storage: __assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
}

@@ -352,2 +368,235 @@ var NgFormsManagerConfig = /** @class */ (function () {

* @fileoverview added by tsickle
* Generated from: lib/isEqual.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// https://github.com/epoberezkin/fast-deep-equal
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function isEqual(a, b) {
if (a === b) {
return true;
}
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) {
return false;
}
/** @type {?} */
var length;
/** @type {?} */
var i;
/** @type {?} */
var keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!isEqual(a[i], b[i])) {
return false;
}
}
return true;
}
if (a.constructor === RegExp) {
return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) {
return a.valueOf() === b.valueOf();
}
if (a.toString !== Object.prototype.toString) {
return a.toString() === b.toString();
}
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
return false;
}
}
for (i = length; i-- !== 0;) {
/** @type {?} */
var key = keys[i];
if (!isEqual(a[key], b[key])) {
return false;
}
}
return true;
}
// true if both NaN, false otherwise
return a !== a && b !== b;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/builders.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template FormsState
* @param {?} name
* @param {?} control
* @return {?}
*/
function toStore(name, control) {
var e_1, _a;
/** @type {?} */
var value;
if (control instanceof forms.FormControl) {
value = buildValue(control);
return value;
}
if (control instanceof forms.FormGroup || control instanceof forms.FormArray) {
value = buildValue(control);
try {
for (var _b = __values(Object.keys(control.controls)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
/** @type {?} */
var current = control.controls[key];
if (current instanceof forms.FormGroup || current instanceof forms.FormArray) {
value.controls[key] = toStore(name, current);
}
else {
value.controls[key] = buildValue(current);
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
return value;
}
/**
* @param {?} formValue
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function handleFormArray(formValue, control, arrControlFactory) {
if (control instanceof forms.FormArray) {
clearFormArray(( /** @type {?} */(control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach(( /**
* @param {?} v
* @param {?} i
* @return {?}
*/function (v, i) {
return (( /** @type {?} */(control))).insert(i, (( /** @type {?} */(arrControlFactory)))(v));
}));
}
else {
Object.keys(formValue).forEach(( /**
* @param {?} controlName
* @return {?}
*/function (controlName) {
/** @type {?} */
var value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof forms.FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error("Please provide arrControlFactory for " + controlName);
}
/** @type {?} */
var current_1 = ( /** @type {?} */(control.get(controlName)));
/** @type {?} */
var fc_1 = arrControlFactory[controlName];
clearFormArray(current_1);
value.forEach(( /**
* @param {?} v
* @param {?} i
* @return {?}
*/function (v, i) { return current_1.insert(i, fc_1(v)); }));
}
}));
}
}
/**
* @param {?} snapshot
* @param {?} controls
* @return {?}
*/
function deleteControl(snapshot, controls) {
return Object.keys(snapshot).reduce(( /**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/function (acc, currentFormName) {
if (controls.includes(currentFormName) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
}
/**
* @param {?} control
* @param {?} path
* @return {?}
*/
function findControl(control, path) {
var _a = __read(path.split('.')), first = _a[0], rest = _a.slice(1);
if (rest.length === 0) {
return control.controls[first];
}
return rest.reduce(( /**
* @param {?} current
* @param {?} name
* @return {?}
*/function (current, name) {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control.controls[first]);
}
/**
* @param {?} control
* @return {?}
*/
function buildValue(control) {
/** @type {?} */
var value = {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: (( /** @type {?} */(control))).getRawValue ? (( /** @type {?} */(control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
if (control instanceof forms.FormGroup || control instanceof forms.FormArray) {
value['controls'] = control instanceof forms.FormArray ? [] : {};
}
return value;
}
/**
* @param {?} control
* @return {?}
*/
function clearFormArray(control) {
while (control.length !== 0) {
control.removeAt(0);
}
}
/**
* @fileoverview added by tsickle
* Generated from: lib/forms-manager.ts

@@ -362,18 +611,42 @@ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc

this.config = config;
this.valueChanges = new Map();
this.instances = new Map();
this.valueChanges$$ = new Map();
this.instances$$ = new Map();
this.destroy$$ = new rxjs.Subject();
this.store = new FormsStore(( /** @type {?} */({})));
}
/**
* @param {?} formName
*
* @example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValid = /**
* @param {?} formName
NgFormsManager.prototype.validityChanges = /**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(operators.map(( /**
function (name, path) {
return this.controlChanges(name, path).pipe(operators.map(( /**
* @param {?} control

@@ -384,13 +657,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDirty = /**
* @param {?} formName
NgFormsManager.prototype.dirtyChanges = /**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(operators.map(( /**
function (name, path) {
return this.controlChanges(name, path).pipe(operators.map(( /**
* @param {?} control

@@ -401,13 +697,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDisabled = /**
* @param {?} formName
NgFormsManager.prototype.disableChanges = /**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(operators.map(( /**
function (name, path) {
return this.controlChanges(name, path).pipe(operators.map(( /**
* @param {?} control

@@ -418,13 +737,13 @@ * @return {?}

/**
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValue = /**
* @param {?} formName
NgFormsManager.prototype.valueChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(operators.map(( /**
function (name, path) {
return this.controlChanges(name, path).pipe(operators.map(( /**
* @param {?} control

@@ -435,15 +754,41 @@ * @return {?}

/**
* @template T
* @param {?} formName
*
* @example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
*/
/**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectErrors = /**
* @template T
* @param {?} formName
NgFormsManager.prototype.errorsChanges = /**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(operators.map(( /**
function (name, path) {
return this.controlChanges(name, path).pipe(operators.map(( /**
* @param {?} control

@@ -454,32 +799,28 @@ * @return {?}

/**
* If no path specified it means that it's a single FormControl or FormArray
*/
/**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectControl = /**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
NgFormsManager.prototype.controlChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
var _this = this;
function (name, path) {
/** @type {?} */
var control$ = this.store.select(( /**
* @param {?} state
* @return {?}
*/function (state) { return state[( /** @type {?} */(name))]; })).pipe(filterNil);
if (!path) {
return ( /** @type {?} */(this.selectForm(formName)));
return control$.pipe(operators.distinctUntilChanged(( /**
* @param {?} a
* @param {?} b
* @return {?}
*/function (a, b) { return isEqual(a, b); })));
}
return this.store
.select(( /**
* @param {?} state
* @return {?}
*/function (state) { return state[( /** @type {?} */(formName))]; }))
.pipe(filterNil, operators.map(( /**
* @param {?} form
* @return {?}
*/function (form) { return _this.resolveControl(form, path); })), operators.distinctUntilChanged(( /**
return control$.pipe(operators.map(( /**
* @param {?} control
* @return {?}
*/function (control) { return findControl(control, path); })), operators.distinctUntilChanged(( /**
* @param {?} a

@@ -491,4 +832,42 @@ * @param {?} b

/**
* @template T
* @param {?} formName
*
* @example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
*/
/**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.controlDestroyed = /**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
function (name) {
return this.destroy$$
.asObservable()
.pipe(operators.filter(( /**
* @param {?} controlName
* @return {?}
*/function (controlName) { return name === controlName || controlName === '$$ALL'; })));
};
/**
* @param {?} name
* @param {?=} path

@@ -498,15 +877,14 @@ * @return {?}

NgFormsManager.prototype.getControl = /**
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
function (name, path) {
if (!path) {
return ( /** @type {?} */(this.getForm(formName)));
return ( /** @type {?} */(this.store.getValue()[name]));
}
if (this.hasForm(formName)) {
if (this.hasControl(name)) {
/** @type {?} */
var form = this.getForm(formName);
return this.resolveControl(form, path);
var control = this.getControl(name);
return findControl(control, path);
}

@@ -516,56 +894,291 @@ return null;

/**
*
* @example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
*/
/**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.hasControl = /**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (name, path) {
return !!this.getControl(name, path);
};
/**
*
* @example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.selectForm = /**
NgFormsManager.prototype.patchValue = /**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, options) {
if (options === void 0) {
options = { filterNil: true };
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).patchValue(value, options);
}
return this.store
.select(( /**
* @param {?} state
* @return {?}
*/function (state) { return state[( /** @type {?} */(formName))]; }))
.pipe(options.filterNil ? filterNil : ( /**
* @param {?} s
* @return {?}
*/function (s) { return s; }));
};
/**
* @template Name
* @param {?} formName
*
* @example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.getForm = /**
* @template Name
* @param {?} formName
NgFormsManager.prototype.setValue = /**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName) {
return this.store.getValue()[( /** @type {?} */(formName))];
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).setValue(value, options);
}
};
/**
* @param {?} formName
*
* @example
*
* manager.unsubscribe('login');
*
*/
/**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.hasForm = /**
* @param {?} formName
NgFormsManager.prototype.unsubscribe = /**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
function (formName) {
return !!this.getForm(formName);
function (name) {
var _this = this;
var e_1, _a;
if (name) {
/** @type {?} */
var names = coerceArray(name);
try {
for (var names_1 = __values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) {
var name_1 = names_1_1.value;
if (this.valueChanges$$.has(name_1)) {
this.valueChanges$$.get(name_1).unsubscribe();
}
this.valueChanges$$.delete(name_1);
this.instances$$.delete(name_1);
this.destroy$$.next(name_1);
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (names_1_1 && !names_1_1.done && (_a = names_1.return))
_a.call(names_1);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
else {
this.valueChanges$$.forEach(( /**
* @param {?} subscription
* @return {?}
*/function (subscription) {
subscription.unsubscribe();
_this.destroy$$.next('$$ALL');
}));
this.valueChanges$$.clear();
this.instances$$.clear();
}
};
/**
*
* @example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
*/
/**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.clear = /**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
name ? this.deleteControl(name) : this.store.set(( /** @type {?} */({})));
this.removeFromStorage();
};
/**
*
* @example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
*/
/**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
this.unsubscribe(name);
this.clear(name);
};
/**
*
* @example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
*/
/**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config

@@ -575,10 +1188,21 @@ * @return {THIS}

NgFormsManager.prototype.upsert = /**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config
* @return {THIS}
*/
function (formName, form, config) {
function (name, control, config) {
var _this = this;

@@ -591,14 +1215,14 @@ if (config === void 0) {

var mergedConfig = ( /** @type {?} */(( /** @type {?} */(this)).config.merge(config)));
if (isBrowser() && config.persistState && ( /** @type {?} */(this)).hasForm(formName) === false) {
if (isBrowser() && config.persistState && ( /** @type {?} */(this)).hasControl(name) === false) {
/** @type {?} */
var storageValue = ( /** @type {?} */(this)).getFromStorage(mergedConfig.storage.key);
if (storageValue[formName]) {
if (storageValue[name]) {
( /** @type {?} */(this)).store.update(( /** @type {?} */(_a = {},
_a[formName] = mergeDeep(( /** @type {?} */(this)).buildFormStoreState(formName, form), storageValue[formName]),
_a[name] = mergeDeep(toStore(name, control), storageValue[name]),
_a)));
}
}
/** If the form already exist, patch the form with the store value */
if (( /** @type {?} */(this)).hasForm(formName) === true) {
form.patchValue(( /** @type {?} */(this)).resolveStoreToForm(formName, form, mergedConfig.arrControlFactory), {
/** If the control already exist, patch the control with the store value */
if (( /** @type {?} */(this)).hasControl(name) === true) {
control.patchValue(( /** @type {?} */(this)).toControlValue(name, control, mergedConfig.arrControlFactory), {
emitEvent: false,

@@ -609,7 +1233,7 @@ });

/** @type {?} */
var value = ( /** @type {?} */(this)).updateStore(formName, form);
( /** @type {?} */(this)).updateStorage(formName, value, mergedConfig);
var value = ( /** @type {?} */(this)).updateStore(name, control);
( /** @type {?} */(this)).updateStorage(name, value, mergedConfig);
}
/** @type {?} */
var unsubscribe = rxjs.merge(form.valueChanges, form.statusChanges.pipe(operators.distinctUntilChanged()))
var unsubscribe = rxjs.merge(control.valueChanges, control.statusChanges.pipe(operators.distinctUntilChanged()))
.pipe(operators.debounceTime(mergedConfig.debounceTime))

@@ -620,80 +1244,15 @@ .subscribe(( /**

/** @type {?} */
var value = ( /** @type {?} */(_this)).updateStore(formName, form);
( /** @type {?} */(_this)).updateStorage(formName, value, mergedConfig);
var value = ( /** @type {?} */(_this)).updateStore(name, control);
( /** @type {?} */(_this)).updateStorage(name, value, mergedConfig);
}));
( /** @type {?} */(this)).valueChanges.set(formName, unsubscribe);
( /** @type {?} */(this)).instances.set(formName, form);
( /** @type {?} */(this)).valueChanges$$.set(name, unsubscribe);
( /** @type {?} */(this)).instances$$.set(name, control);
return ( /** @type {?} */(this));
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @private
* @return {?}
*/
NgFormsManager.prototype.patchValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).patchValue(value, options);
}
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.setValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).setValue(value, options);
}
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.clear = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
if (formName) {
this.removeFromStore(formName);
}
else {
this.store.set(( /** @type {?} */({})));
}
this.removeFromStorage();
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
this.clear(formName);
this.unsubscribe(formName);
};
/**
* @return {?}
*/
NgFormsManager.prototype.removeFromStorage = /**
* @private
* @return {?}

@@ -705,37 +1264,4 @@ */

/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.unsubscribe = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
var _this = this;
/** @type {?} */
var toArray = coerceArray(formName);
if (formName) {
toArray.forEach(( /**
* @param {?} name
* @return {?}
*/function (name) {
if (_this.valueChanges.has(name)) {
_this.valueChanges.get(name).unsubscribe();
_this.valueChanges.delete(name);
}
_this.instances.delete(name);
}));
}
else {
this.valueChanges.forEach(( /**
* @param {?} subscription
* @return {?}
*/function (subscription) { return subscription.unsubscribe(); }));
this.valueChanges.clear();
this.instances.clear();
}
};
/**
* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -747,3 +1273,3 @@ * @param {?} config

* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -753,7 +1279,7 @@ * @param {?} config

*/
function (formName, value, config) {
function (name, value, config) {
if (isBrowser() && config.persistState) {
/** @type {?} */
var storageValue = this.getFromStorage(config.storage.key);
storageValue[formName] = filterControlKeys(value);
storageValue[name] = filterControlKeys(value);
localStorage.setItem(config.storage.key, JSON.stringify(storageValue));

@@ -777,78 +1303,23 @@ }

* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.removeFromStore = /**
NgFormsManager.prototype.deleteControl = /**
* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
function (formName) {
/** @type {?} */
var toArray = coerceArray(formName);
/** @type {?} */
var snapshot = this.store.getValue();
/** @type {?} */
var newState = Object.keys(snapshot).reduce(( /**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/function (acc, currentFormName) {
if (toArray.includes(( /** @type {?} */(currentFormName))) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
this.store.set(( /** @type {?} */(newState)));
function (name) {
this.store.set(( /** @type {?} */(deleteControl(this.store.getValue(), coerceArray(name)))));
};
/**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.resolveControl = /**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
function (form, path) {
var _a = __read(path.split('.')), first = _a[0], rest = _a.slice(1);
if (rest.length === 0) {
return form.controls[first];
}
return this.find(form.controls[first], rest);
};
/**
* @private
* @param {?} name
* @param {?} control
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.find = /**
* @private
* @param {?} control
* @param {?} path
* @return {?}
*/
function (control, path) {
return path.reduce(( /**
* @param {?} current
* @param {?} name
* @return {?}
*/function (current, name) {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control);
};
/**
* @private
* @param {?} formName
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.resolveStoreToForm = /**
NgFormsManager.prototype.toControlValue = /**
* @private
* @param {?} formName
* @param {?} name
* @param {?} control

@@ -858,12 +1329,12 @@ * @param {?} arrControlFactory

*/
function (formName, control, arrControlFactory) {
function (name, control, arrControlFactory) {
/** @type {?} */
var form = this.getForm(formName);
var currentControl = this.getControl(name);
/** @type {?} */
var value = form.value;
/** It means it a single control */
if (!form.controls) {
var value = currentControl.value;
/** It means it's not a FormGroup or FormArray */
if (!currentControl.controls) {
return value;
}
this.handleFormArray(value, control, arrControlFactory);
handleFormArray(value, control, arrControlFactory);
return value;

@@ -873,166 +1344,21 @@ };

* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.handleFormArray = /**
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function (formValue, control, arrControlFactory) {
var _this = this;
if (control instanceof forms.FormArray) {
this.cleanArray(( /** @type {?} */(control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach(( /**
* @param {?} v
* @param {?} i
* @return {?}
*/function (v, i) {
return (( /** @type {?} */(control))).insert(i, (( /** @type {?} */(arrControlFactory)))(v));
}));
}
else {
Object.keys(formValue).forEach(( /**
* @param {?} controlName
* @return {?}
*/function (controlName) {
/** @type {?} */
var value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof forms.FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error('Please provide arrControlFactory for ' + controlName);
}
/** @type {?} */
var current_1 = ( /** @type {?} */(control.get(controlName)));
/** @type {?} */
var fc_1 = arrControlFactory[controlName];
_this.cleanArray(current_1);
value.forEach(( /**
* @param {?} v
* @param {?} i
* @return {?}
*/function (v, i) { return current_1.insert(i, fc_1(v)); }));
}
}));
}
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.cleanArray = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
while (control.length !== 0) {
control.removeAt(0);
}
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.buildFormStoreState = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
var e_1, _a;
/** @type {?} */
var value;
if (form instanceof forms.FormControl) {
value = this.resolveFormToStore(form);
}
if (form instanceof forms.FormGroup || form instanceof forms.FormArray) {
// The root form group
value = __assign({}, this.resolveFormToStore(form), { controls: {} });
try {
for (var _b = __values(Object.keys(form.controls)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
/** @type {?} */
var control = form.controls[key];
if (control instanceof forms.FormGroup || form instanceof forms.FormArray) {
value.controls[key] = this.buildFormStoreState(formName, control);
}
else {
value.controls[key] = this.resolveFormToStore(control);
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
return value;
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
function (name, control) {
var _a;
/** @type {?} */
var value = this.buildFormStoreState(formName, form);
var value = toStore(name, control);
this.store.update(( /** @type {?} */(_a = {},
_a[formName] = value,
_a[name] = value,
_a)));
return value;
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.resolveFormToStore = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
return {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: (( /** @type {?} */(control))).getRawValue ? (( /** @type {?} */(control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
};
NgFormsManager.decorators = [

@@ -1039,0 +1365,0 @@ { type: i0.Injectable, args: [{ providedIn: 'root' },] }

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/forms"),require("rxjs"),require("rxjs/operators"),require("@angular/core"),require("lodash.isequal")):"function"==typeof define&&define.amd?define("@ngneat/forms-manager",["exports","@angular/forms","rxjs","rxjs/operators","@angular/core","lodash.isequal"],e):e((t.ngneat=t.ngneat||{},t.ngneat["forms-manager"]={}),t.ng.forms,t.rxjs,t.rxjs.operators,t.ng.core,t.isEqual)}(this,function(t,l,f,p,e,n){"use strict";n=n&&n.hasOwnProperty("default")?n["default"]:n;var h=function(){return(h=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function d(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function i(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(o=i.next()).done;)a.push(o.value)}catch(s){n={error:s}}finally{try{o&&!o.done&&(r=i["return"])&&r.call(i)}finally{if(n)throw n.error}}return a}function y(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var a=function(t){return t.pipe(p.filter(function(t){return null!=t}))};function s(t){return function e(t){return null===t||t===undefined}(t)?[]:Array.isArray(t)?t:[t]}function g(t){return null!=t&&!Array.isArray(t)&&"object"==typeof t}var r=["dirty","disabled","invalid","pending","errors","pristine","touched","valid","rawValue"];function u(t){return function l(t,e){var r,o;var n={};try{for(var i=d(Object.keys(t)),a=i.next();!a.done;a=i.next()){var s=a.value,u=t[s];!1===e(s)&&(g(u)?n[s]=l(t[s],e):n[s]=u)}}catch(c){r={error:c}}finally{try{a&&!a.done&&(o=i["return"])&&o.call(i)}finally{if(r)throw r.error}}return n}(t,function(t){return r.includes(t)})}function v(){return"undefined"!=typeof window}var o=(c.prototype.select=function(t){return this.store.asObservable().pipe(p.map(t),p.distinctUntilChanged())},c.prototype.getValue=function(){return this.store.getValue()},c.prototype.set=function(t){this.store.next(t)},c.prototype.update=function(t){this.store.next(Object.assign({},this.getValue(),t))},c);function c(t){this.state=t,this.store=new f.BehaviorSubject(t)}var m={storage:{key:"ngFormsManager"},debounceTime:300};var F=(b.prototype.merge=function(t){return void 0===t&&(t={}),function o(t,e,r){return void 0===e&&(e={}),h({storage:h({},t.storage,e.storage,r.storage)},e,r)}(m,this.config,t)},b);function b(t){void 0===t&&(t={}),this.config=t}var S=new e.InjectionToken("NG_FORMS_MANAGER_CONFIG",{providedIn:"root",factory:function(){return new F}}),C=(j.prototype.selectValid=function(t,e){return this.selectControl(t,e).pipe(p.map(function(t){return t.valid}))},j.prototype.selectDirty=function(t,e){return this.selectControl(t,e).pipe(p.map(function(t){return t.dirty}))},j.prototype.selectDisabled=function(t,e){return this.selectControl(t,e).pipe(p.map(function(t){return t.disabled}))},j.prototype.selectValue=function(t,e){return this.selectControl(t,e).pipe(p.map(function(t){return t.value}))},j.prototype.selectErrors=function(t,e){return this.selectControl(t,e).pipe(p.map(function(t){return t.errors}))},j.prototype.selectControl=function(e,r){var o=this;return r?this.store.select(function(t){return t[e]}).pipe(a,p.map(function(t){return o.resolveControl(t,r)}),p.distinctUntilChanged(function(t,e){return n(t,e)})):this.selectForm(e)},j.prototype.getControl=function(t,e){if(!e)return this.getForm(t);if(this.hasForm(t)){var r=this.getForm(t);return this.resolveControl(r,e)}return null},j.prototype.selectForm=function(e,t){return void 0===t&&(t={filterNil:!0}),this.store.select(function(t){return t[e]}).pipe(t.filterNil?a:function(t){return t})},j.prototype.getForm=function(t){return this.store.getValue()[t]},j.prototype.hasForm=function(t){return!!this.getForm(t)},j.prototype.upsert=function(e,r,t){var o,n=this;void 0===t&&(t={});var i=this.config.merge(t);if(v()&&t.persistState&&!1===this.hasForm(e)){var a=this.getFromStorage(i.storage.key);a[e]&&this.store.update(((o={})[e]=function c(t){for(var e,r,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];if(!o.length)return t;var i=o.shift();if(g(t)&&g(i))for(var a in i)g(i[a])?(t[a]||Object.assign(t,((e={})[a]={},e)),c(t[a],i[a])):Object.assign(t,((r={})[a]=i[a],r));return c.apply(void 0,y([t],o))}(this.buildFormStoreState(e,r),a[e]),o))}if(!0===this.hasForm(e))r.patchValue(this.resolveStoreToForm(e,r,i.arrControlFactory),{emitEvent:!1});else{var s=this.updateStore(e,r);this.updateStorage(e,s,i)}var u=f.merge(r.valueChanges,r.statusChanges.pipe(p.distinctUntilChanged())).pipe(p.debounceTime(i.debounceTime)).subscribe(function(){var t=n.updateStore(e,r);n.updateStorage(e,t,i)});return this.valueChanges.set(e,u),this.instances.set(e,r),this},j.prototype.patchValue=function(t,e,r){this.instances.has(t)&&this.instances.get(t).patchValue(e,r)},j.prototype.setValue=function(t,e,r){this.instances.has(t)&&this.instances.get(t).setValue(e,r)},j.prototype.clear=function(t){t?this.removeFromStore(t):this.store.set({}),this.removeFromStorage()},j.prototype.destroy=function(t){this.clear(t),this.unsubscribe(t)},j.prototype.removeFromStorage=function(){localStorage.setItem(this.config.merge().storage.key,JSON.stringify(this.store.getValue()))},j.prototype.unsubscribe=function(t){var e=this,r=s(t);t?r.forEach(function(t){e.valueChanges.has(t)&&(e.valueChanges.get(t).unsubscribe(),e.valueChanges["delete"](t)),e.instances["delete"](t)}):(this.valueChanges.forEach(function(t){return t.unsubscribe()}),this.valueChanges.clear(),this.instances.clear())},j.prototype.updateStorage=function(t,e,r){if(v()&&r.persistState){var o=this.getFromStorage(r.storage.key);o[t]=u(e),localStorage.setItem(r.storage.key,JSON.stringify(o))}},j.prototype.getFromStorage=function(t){return JSON.parse(localStorage.getItem(t)||"{}")},j.prototype.removeFromStore=function(t){var r=s(t),o=this.store.getValue(),e=Object.keys(o).reduce(function(t,e){return!1===r.includes(e)&&(t[e]=o[e]),t},{});this.store.set(e)},j.prototype.resolveControl=function(t,e){var r=i(e.split(".")),o=r[0],n=r.slice(1);return 0===n.length?t.controls[o]:this.find(t.controls[o],n)},j.prototype.find=function(t,e){return e.reduce(function(t,e){return t.controls.hasOwnProperty(e)?t.controls[e]:null},t)},j.prototype.resolveStoreToForm=function(t,e,r){var o=this.getForm(t),n=o.value;return o.controls&&this.handleFormArray(n,e,r),n},j.prototype.handleFormArray=function(n,i,a){var s=this;if(i instanceof l.FormArray){if(this.cleanArray(i),!a)throw new Error("Please provide arrControlFactory");n.forEach(function(t,e){return i.insert(e,a(t))})}else Object.keys(n).forEach(function(t){var e=n[t];if(Array.isArray(e)&&i.get(t)instanceof l.FormArray){if(!a||a&&!(t in a))throw new Error("Please provide arrControlFactory for "+t);var r=i.get(t),o=a[t];s.cleanArray(r),e.forEach(function(t,e){return r.insert(e,o(t))})}})},j.prototype.cleanArray=function(t){for(;0!==t.length;)t.removeAt(0)},j.prototype.buildFormStoreState=function(t,e){var r,o,n;if(e instanceof l.FormControl&&(n=this.resolveFormToStore(e)),e instanceof l.FormGroup||e instanceof l.FormArray){n=h({},this.resolveFormToStore(e),{controls:{}});try{for(var i=d(Object.keys(e.controls)),a=i.next();!a.done;a=i.next()){var s=a.value,u=e.controls[s];u instanceof l.FormGroup||e instanceof l.FormArray?n.controls[s]=this.buildFormStoreState(t,u):n.controls[s]=this.resolveFormToStore(u)}}catch(c){r={error:c}}finally{try{a&&!a.done&&(o=i["return"])&&o.call(i)}finally{if(r)throw r.error}}}return n},j.prototype.updateStore=function(t,e){var r,o=this.buildFormStoreState(t,e);return this.store.update(((r={})[t]=o,r)),o},j.prototype.resolveFormToStore=function(t){return{value:function e(t){return g(t)?h({},t):Array.isArray(t)?y(t):t}(t.value),rawValue:t.getRawValue?t.getRawValue():null,valid:t.valid,dirty:t.dirty,invalid:t.invalid,disabled:t.disabled,errors:t.errors,touched:t.touched,pristine:t.pristine,pending:t.pending}},j.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],j.ctorParameters=function(){return[{type:F,decorators:[{type:e.Optional},{type:e.Inject,args:[S]}]}]},j.ngInjectableDef=e.defineInjectable({factory:function(){return new j(e.inject(S,8))},token:j,providedIn:"root"}),j);function j(t){this.config=t,this.valueChanges=new Map,this.instances=new Map,this.store=new o({})}t.NgFormsManager=C,t.setAsyncValidators=function A(t,e){t.setValidators(s(e)),t.updateValueAndValidity()},t.setValidators=function V(t,e){t.setValidators(s(e)),t.updateValueAndValidity()},t.NgFormsManagerConfig=F,t.NG_FORMS_MANAGER_CONFIG=S,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("rxjs"),require("rxjs/operators"),require("@angular/core"),require("@angular/forms")):"function"==typeof define&&define.amd?define("@ngneat/forms-manager",["exports","rxjs","rxjs/operators","@angular/core","@angular/forms"],r):r((t.ngneat=t.ngneat||{},t.ngneat["forms-manager"]={}),t.rxjs,t.rxjs.operators,t.ng.core,t.ng.forms)}(this,function(t,l,f,r,p){"use strict";var o=function(){return(o=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t}).apply(this,arguments)};function h(t){var r="function"==typeof Symbol&&t[Symbol.iterator],e=0;return r?r.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}function i(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,i=e.call(t),a=[];try{for(;(void 0===r||0<r--)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(e=i["return"])&&e.call(i)}finally{if(o)throw o.error}}return a}function g(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(i(arguments[r]));return t}var n=function(t){return t.pipe(f.filter(function(t){return null!=t}))};function c(t){return function r(t){return null===t||t===undefined}(t)?[]:Array.isArray(t)?t:[t]}function y(t){return null!=t&&!Array.isArray(t)&&"object"==typeof t}var a=["dirty","disabled","invalid","pending","errors","pristine","touched","valid"];function d(t,n){return t.reduce(function(t,r,e){return t[e]=v(r,n),t},[])}function v(t,r){var e,n,o={};try{for(var i=h(Object.keys(t)),a=i.next();!a.done;a=i.next()){var s=a.value,u=t[s];!1===r(s)&&(y(u)?o[s]=v(u,r):Array.isArray(u)&&"controls"===s?o[s]=d(u,r):o[s]=u)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(n=i["return"])&&n.call(i)}finally{if(e)throw e.error}}return o}function m(){return"undefined"!=typeof window}var e=(s.prototype.select=function(t){return this.store.asObservable().pipe(f.map(t),f.distinctUntilChanged())},s.prototype.getValue=function(){return this.store.getValue()},s.prototype.set=function(t){this.store.next(t)},s.prototype.update=function(t){this.store.next(Object.assign({},this.getValue(),t))},s);function s(t){this.state=t,this.store=new l.BehaviorSubject(t)}var u={storage:{key:"ngFormsManager"},debounceTime:300};var b=(C.prototype.merge=function(t){return void 0===t&&(t={}),function n(t,r,e){return void 0===r&&(r={}),o({},t,{storage:o({},t.storage,r.storage,e.storage)},r,e)}(u,this.config,t)},C);function C(t){void 0===t&&(t={}),this.config=t}var $=new r.InjectionToken("NG_FORMS_MANAGER_CONFIG",{providedIn:"root",factory:function(){return new b}});function j(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var e,n,o;if(Array.isArray(t)){if((e=t.length)!=r.length)return!1;for(n=e;0!=n--;)if(!j(t[n],r[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((e=(o=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(n=e;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=e;0!=n--;){var i=o[n];if(!j(t[i],r[i]))return!1}return!0}return t!=t&&r!=r}function O(t,r){var e,n,o;if(r instanceof p.FormControl)return o=A(r);if(r instanceof p.FormGroup||r instanceof p.FormArray){o=A(r);try{for(var i=h(Object.keys(r.controls)),a=i.next();!a.done;a=i.next()){var s=a.value,u=r.controls[s];u instanceof p.FormGroup||u instanceof p.FormArray?o.controls[s]=O(t,u):o.controls[s]=A(u)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(n=i["return"])&&n.call(i)}finally{if(e)throw e.error}}}return o}function S(t,r){var e=i(r.split(".")),n=e[0],o=e.slice(1);return 0===o.length?t.controls[n]:o.reduce(function(t,r){return t.controls.hasOwnProperty(r)?t.controls[r]:null},t.controls[n])}function A(t){var r={value:function e(t){return y(t)?o({},t):Array.isArray(t)?g(t):t}(t.value),rawValue:t.getRawValue?t.getRawValue():null,valid:t.valid,dirty:t.dirty,invalid:t.invalid,disabled:t.disabled,errors:t.errors,touched:t.touched,pristine:t.pristine,pending:t.pending};return(t instanceof p.FormGroup||t instanceof p.FormArray)&&(r.controls=t instanceof p.FormArray?[]:{}),r}function F(t){for(;0!==t.length;)t.removeAt(0)}var w=(V.prototype.validityChanges=function(t,r){return this.controlChanges(t,r).pipe(f.map(function(t){return t.valid}))},V.prototype.dirtyChanges=function(t,r){return this.controlChanges(t,r).pipe(f.map(function(t){return t.dirty}))},V.prototype.disableChanges=function(t,r){return this.controlChanges(t,r).pipe(f.map(function(t){return t.disabled}))},V.prototype.valueChanges=function(t,r){return this.controlChanges(t,r).pipe(f.map(function(t){return t.value}))},V.prototype.errorsChanges=function(t,r){return this.controlChanges(t,r).pipe(f.map(function(t){return t.errors}))},V.prototype.controlChanges=function(r,e){var t=this.store.select(function(t){return t[r]}).pipe(n);return e?t.pipe(f.map(function(t){return S(t,e)}),f.distinctUntilChanged(function(t,r){return j(t,r)})):t.pipe(f.distinctUntilChanged(function(t,r){return j(t,r)}))},V.prototype.controlDestroyed=function(r){return this.destroy$$.asObservable().pipe(f.filter(function(t){return r===t||"$$ALL"===t}))},V.prototype.getControl=function(t,r){return r?this.hasControl(t)?S(this.getControl(t),r):null:this.store.getValue()[t]},V.prototype.hasControl=function(t,r){return!!this.getControl(t,r)},V.prototype.patchValue=function(t,r,e){this.instances$$.has(t)&&this.instances$$.get(t).patchValue(r,e)},V.prototype.setValue=function(t,r,e){this.instances$$.has(t)&&this.instances$$.get(t).setValue(r,e)},V.prototype.unsubscribe=function(t){var r,e,n=this;if(t){var o=c(t);try{for(var i=h(o),a=i.next();!a.done;a=i.next()){var s=a.value;this.valueChanges$$.has(s)&&this.valueChanges$$.get(s).unsubscribe(),this.valueChanges$$["delete"](s),this.instances$$["delete"](s),this.destroy$$.next(s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(e=i["return"])&&e.call(i)}finally{if(r)throw r.error}}}else this.valueChanges$$.forEach(function(t){t.unsubscribe(),n.destroy$$.next("$$ALL")}),this.valueChanges$$.clear(),this.instances$$.clear()},V.prototype.clear=function(t){t?this.deleteControl(t):this.store.set({}),this.removeFromStorage()},V.prototype.destroy=function(t){this.unsubscribe(t),this.clear(t)},V.prototype.upsert=function(r,e,t){var n,o=this;void 0===t&&(t={});var i=this.config.merge(t);if(m()&&t.persistState&&!1===this.hasControl(r)){var a=this.getFromStorage(i.storage.key);a[r]&&this.store.update(((n={})[r]=function c(t){for(var r,e,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(!n.length)return t;var i=n.shift();if(y(t)&&y(i))for(var a in i)y(i[a])?(t[a]||Object.assign(t,((r={})[a]={},r)),c(t[a],i[a])):Object.assign(t,((e={})[a]=i[a],e));return c.apply(void 0,g([t],n))}(O(r,e),a[r]),n))}if(!0===this.hasControl(r))e.patchValue(this.toControlValue(r,e,i.arrControlFactory),{emitEvent:!1});else{var s=this.updateStore(r,e);this.updateStorage(r,s,i)}var u=l.merge(e.valueChanges,e.statusChanges.pipe(f.distinctUntilChanged())).pipe(f.debounceTime(i.debounceTime)).subscribe(function(){var t=o.updateStore(r,e);o.updateStorage(r,t,i)});return this.valueChanges$$.set(r,u),this.instances$$.set(r,e),this},V.prototype.removeFromStorage=function(){localStorage.setItem(this.config.merge().storage.key,JSON.stringify(this.store.getValue()))},V.prototype.updateStorage=function(t,r,e){if(m()&&e.persistState){var n=this.getFromStorage(e.storage.key);n[t]=function o(t){return v(t,function(t){return a.includes(t)})}(r),localStorage.setItem(e.storage.key,JSON.stringify(n))}},V.prototype.getFromStorage=function(t){return JSON.parse(localStorage.getItem(t)||"{}")},V.prototype.deleteControl=function(t){this.store.set(function r(e,n){return Object.keys(e).reduce(function(t,r){return!1===n.includes(r)&&(t[r]=e[r]),t},{})}(this.store.getValue(),c(t)))},V.prototype.toControlValue=function(t,r,e){var n=this.getControl(t),o=n.value;return n.controls&&function s(o,i,a){if(i instanceof p.FormArray){if(F(i),!a)throw new Error("Please provide arrControlFactory");o.forEach(function(t,r){return i.insert(r,a(t))})}else Object.keys(o).forEach(function(t){var r=o[t];if(Array.isArray(r)&&i.get(t)instanceof p.FormArray){if(!a||a&&!(t in a))throw new Error("Please provide arrControlFactory for "+t);var e=i.get(t),n=a[t];F(e),r.forEach(function(t,r){return e.insert(r,n(t))})}})}(o,r,e),o},V.prototype.updateStore=function(t,r){var e,n=O(t,r);return this.store.update(((e={})[t]=n,e)),n},V.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],V.ctorParameters=function(){return[{type:b,decorators:[{type:r.Optional},{type:r.Inject,args:[$]}]}]},V.ngInjectableDef=r.defineInjectable({factory:function(){return new V(r.inject($,8))},token:V,providedIn:"root"}),V);function V(t){this.config=t,this.valueChanges$$=new Map,this.instances$$=new Map,this.destroy$$=new l.Subject,this.store=new e({})}t.NgFormsManager=w,t.setAsyncValidators=function x(t,r){t.setValidators(c(r)),t.updateValueAndValidity()},t.setValidators=function k(t,r){t.setValidators(c(r)),t.updateValueAndValidity()},t.NgFormsManagerConfig=b,t.NG_FORMS_MANAGER_CONFIG=$,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngneat-forms-manager.umd.min.js.map

@@ -21,3 +21,3 @@ /**

export function mergeConfig(defaults, providerConfig = {}, inlineConfig) {
return (/** @type {?} */ (Object.assign({ storage: Object.assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
return (/** @type {?} */ (Object.assign({}, defaults, { storage: Object.assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
}

@@ -56,2 +56,2 @@ export class NgFormsManagerConfig {

});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQG5nbmVhdC9mb3Jtcy1tYW5hZ2VyLyIsInNvdXJjZXMiOlsibGliL2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzI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aW5saW5lQ29uZmlnLFxuICB9IGFzIENvbmZpZztcbn1cblxuZXhwb3J0IGNsYXNzIE5nRm9ybXNNYW5hZ2VyQ29uZmlnIHtcbiAgY29uc3RydWN0b3IocHJpdmF0ZSBjb25maWc6IFBhcnRpYWw8Q29uZmlnPiA9IHt9KSB7fVxuXG4gIG1lcmdlKGlubGluZTogUGFydGlhbDxDb25maWc+ID0ge30pOiBDb25maWcge1xuICAgIHJldHVybiBtZXJnZUNvbmZpZyhkZWZhdWx0cywgdGhpcy5jb25maWcsIGlubGluZSk7XG4gIH1cbn1cblxuZXhwb3J0IGNvbnN0IE5HX0ZPUk1TX01BTkFHRVJfQ09ORklHID0gbmV3IEluamVjdGlvblRva2VuPE5nRm9ybXNNYW5hZ2VyQ29uZmlnPihcbiAgJ05HX0ZPUk1TX01BTkFHRVJfQ09ORklHJyxcbiAge1xuICAgIHByb3ZpZGVkSW46ICdyb290JyxcbiAgICBmYWN0b3J5OiAoKSA9PiB7XG4gICAgICByZXR1cm4gbmV3IE5nRm9ybXNNYW5hZ2VyQ29uZmlnKCk7XG4gICAgfSxcbiAgfVxuKTtcbiJdfQ==

@@ -7,9 +7,9 @@ /**

import { Inject, Injectable, Optional } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { clone, coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils';
import { merge } from 'rxjs';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import { coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils';
import { merge, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs/operators';
import { FormsStore } from './forms-manager.store';
import { NG_FORMS_MANAGER_CONFIG, NgFormsManagerConfig } from './config';
import isEqual from 'lodash.isequal';
import { isEqual } from './isEqual';
import { deleteControl, findControl, handleFormArray, toStore } from './builders';
import * as i0 from "@angular/core";

@@ -26,13 +26,21 @@ import * as i1 from "./config";

this.config = config;
this.valueChanges = new Map();
this.instances = new Map();
this.valueChanges$$ = new Map();
this.instances$$ = new Map();
this.destroy$$ = new Subject();
this.store = new FormsStore((/** @type {?} */ ({})));
}
/**
* @param {?} formName
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectValid(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
validityChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -44,8 +52,15 @@ * @return {?}

/**
* @param {?} formName
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectDirty(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
dirtyChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -57,8 +72,15 @@ * @return {?}

/**
* @param {?} formName
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectDisabled(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
disableChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -70,8 +92,8 @@ * @return {?}

/**
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectValue(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
valueChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -83,9 +105,17 @@ * @return {?}

/**
* @template T
* @param {?} formName
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectErrors(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
errorsChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -97,23 +127,26 @@ * @return {?}

/**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectControl(formName, path) {
if (!path) {
return (/** @type {?} */ (this.selectForm(formName)));
}
return this.store
.select((/**
controlChanges(name, path) {
/** @type {?} */
const control$ = this.store.select((/**
* @param {?} state
* @return {?}
*/
state => state[(/** @type {?} */ (formName))]))
.pipe(filterNil, map((/**
* @param {?} form
state => state[(/** @type {?} */ (name))])).pipe(filterNil);
if (!path) {
return control$.pipe(distinctUntilChanged((/**
* @param {?} a
* @param {?} b
* @return {?}
*/
(a, b) => isEqual(a, b))));
}
return control$.pipe(map((/**
* @param {?} control
* @return {?}
*/
form => this.resolveControl(form, path))), distinctUntilChanged((/**
control => findControl(control, path))), distinctUntilChanged((/**
* @param {?} a

@@ -126,15 +159,34 @@ * @param {?} b

/**
* @template T
* @param {?} formName
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
controlDestroyed(name) {
return this.destroy$$
.asObservable()
.pipe(filter((/**
* @param {?} controlName
* @return {?}
*/
controlName => name === controlName || controlName === '$$ALL')));
}
/**
* @param {?} name
* @param {?=} path
* @return {?}
*/
getControl(formName, path) {
getControl(name, path) {
if (!path) {
return (/** @type {?} */ (this.getForm(formName)));
return (/** @type {?} */ (this.store.getValue()[name]));
}
if (this.hasForm(formName)) {
if (this.hasControl(name)) {
/** @type {?} */
const form = this.getForm(formName);
return this.resolveControl(form, path);
const control = this.getControl(name);
return findControl(control, path);
}

@@ -144,58 +196,154 @@ return null;

/**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
hasControl(name, path) {
return !!this.getControl(name, path);
}
/**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
selectForm(formName, options = { filterNil: true }) {
return this.store
.select((/**
* @param {?} state
* @return {?}
*/
state => state[(/** @type {?} */ (formName))]))
.pipe(options.filterNil ? filterNil : (/**
* @param {?} s
* @return {?}
*/
s => s));
patchValue(name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).patchValue(value, options);
}
}
/**
* @template Name
* @param {?} formName
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
getForm(formName) {
return this.store.getValue()[(/** @type {?} */ (formName))];
setValue(name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).setValue(value, options);
}
}
/**
* @param {?} formName
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
hasForm(formName) {
return !!this.getForm(formName);
unsubscribe(name) {
if (name) {
/** @type {?} */
const names = coerceArray(name);
for (const name of names) {
if (this.valueChanges$$.has(name)) {
this.valueChanges$$.get(name).unsubscribe();
}
this.valueChanges$$.delete(name);
this.instances$$.delete(name);
this.destroy$$.next(name);
}
}
else {
this.valueChanges$$.forEach((/**
* @param {?} subscription
* @return {?}
*/
subscription => {
subscription.unsubscribe();
this.destroy$$.next('$$ALL');
}));
this.valueChanges$$.clear();
this.instances$$.clear();
}
}
/**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
clear(name) {
name ? this.deleteControl(name) : this.store.set((/** @type {?} */ ({})));
this.removeFromStorage();
}
/**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
destroy(name) {
this.unsubscribe(name);
this.clear(name);
}
/**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config
* @return {THIS}
*/
upsert(formName, form, config = {}) {
upsert(name, control, config = {}) {
/** @type {?} */
const mergedConfig = (/** @type {?} */ ((/** @type {?} */ (this)).config.merge(config)));
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasForm(formName) === false) {
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasControl(name) === false) {
/** @type {?} */
const storageValue = (/** @type {?} */ (this)).getFromStorage(mergedConfig.storage.key);
if (storageValue[formName]) {
if (storageValue[name]) {
(/** @type {?} */ (this)).store.update((/** @type {?} */ ({
[formName]: mergeDeep((/** @type {?} */ (this)).buildFormStoreState(formName, form), storageValue[formName]),
[name]: mergeDeep(toStore(name, control), storageValue[name]),
})));
}
}
/** If the form already exist, patch the form with the store value */
if ((/** @type {?} */ (this)).hasForm(formName) === true) {
form.patchValue((/** @type {?} */ (this)).resolveStoreToForm(formName, form, mergedConfig.arrControlFactory), {
/** If the control already exist, patch the control with the store value */
if ((/** @type {?} */ (this)).hasControl(name) === true) {
control.patchValue((/** @type {?} */ (this)).toControlValue(name, control, mergedConfig.arrControlFactory), {
emitEvent: false,

@@ -206,7 +354,7 @@ });

/** @type {?} */
const value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
const value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}
/** @type {?} */
const unsubscribe = merge(form.valueChanges, form.statusChanges.pipe(distinctUntilChanged()))
const unsubscribe = merge(control.valueChanges, control.statusChanges.pipe(distinctUntilChanged()))
.pipe(debounceTime(mergedConfig.debounceTime))

@@ -218,57 +366,13 @@ .subscribe((/**

/** @type {?} */
const value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
const value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}));
(/** @type {?} */ (this)).valueChanges.set(formName, unsubscribe);
(/** @type {?} */ (this)).instances.set(formName, form);
(/** @type {?} */ (this)).valueChanges$$.set(name, unsubscribe);
(/** @type {?} */ (this)).instances$$.set(name, control);
return (/** @type {?} */ (this));
}
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @private
* @return {?}
*/
patchValue(formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).patchValue(value, options);
}
}
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
setValue(formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).setValue(value, options);
}
}
/**
* @param {?=} formName
* @return {?}
*/
clear(formName) {
if (formName) {
this.removeFromStore(formName);
}
else {
this.store.set((/** @type {?} */ ({})));
}
this.removeFromStorage();
}
/**
* @param {?=} formName
* @return {?}
*/
destroy(formName) {
this.clear(formName);
this.unsubscribe(formName);
}
/**
* @return {?}
*/
removeFromStorage() {

@@ -278,34 +382,4 @@ localStorage.setItem(this.config.merge().storage.key, JSON.stringify(this.store.getValue()));

/**
* @param {?=} formName
* @return {?}
*/
unsubscribe(formName) {
/** @type {?} */
const toArray = coerceArray(formName);
if (formName) {
toArray.forEach((/**
* @param {?} name
* @return {?}
*/
name => {
if (this.valueChanges.has(name)) {
this.valueChanges.get(name).unsubscribe();
this.valueChanges.delete(name);
}
this.instances.delete(name);
}));
}
else {
this.valueChanges.forEach((/**
* @param {?} subscription
* @return {?}
*/
subscription => subscription.unsubscribe()));
this.valueChanges.clear();
this.instances.clear();
}
}
/**
* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -315,7 +389,7 @@ * @param {?} config

*/
updateStorage(formName, value, config) {
updateStorage(name, value, config) {
if (isBrowser() && config.persistState) {
/** @type {?} */
const storageValue = this.getFromStorage(config.storage.key);
storageValue[formName] = filterControlKeys(value);
storageValue[name] = filterControlKeys(value);
localStorage.setItem(config.storage.key, JSON.stringify(storageValue));

@@ -334,70 +408,25 @@ }

* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
removeFromStore(formName) {
/** @type {?} */
const toArray = coerceArray(formName);
/** @type {?} */
const snapshot = this.store.getValue();
/** @type {?} */
const newState = Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
(acc, currentFormName) => {
if (toArray.includes((/** @type {?} */ (currentFormName))) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
this.store.set((/** @type {?} */ (newState)));
deleteControl(name) {
this.store.set((/** @type {?} */ (deleteControl(this.store.getValue(), coerceArray(name)))));
}
/**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
resolveControl(form, path) {
const [first, ...rest] = path.split('.');
if (rest.length === 0) {
return form.controls[first];
}
return this.find(form.controls[first], rest);
}
/**
* @private
* @param {?} name
* @param {?} control
* @param {?} path
* @return {?}
*/
find(control, path) {
return path.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
(current, name) => {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control);
}
/**
* @private
* @param {?} formName
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
resolveStoreToForm(formName, control, arrControlFactory) {
toControlValue(name, control, arrControlFactory) {
/** @type {?} */
const form = this.getForm(formName);
const currentControl = this.getControl(name);
/** @type {?} */
const value = form.value;
/** It means it a single control */
if (!form.controls) {
const value = currentControl.value;
/** It means it's not a FormGroup or FormArray */
if (!currentControl.controls) {
return value;
}
this.handleFormArray(value, control, arrControlFactory);
handleFormArray(value, control, arrControlFactory);
return value;

@@ -407,119 +436,14 @@ }

* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
handleFormArray(formValue, control, arrControlFactory) {
if (control instanceof FormArray) {
this.cleanArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v))));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
controlName => {
/** @type {?} */
const value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error('Please provide arrControlFactory for ' + controlName);
}
/** @type {?} */
const current = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
const fc = arrControlFactory[controlName];
this.cleanArray(current);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => current.insert(i, fc(v))));
}
}));
}
}
/**
* @private
* @param {?} control
* @return {?}
*/
cleanArray(control) {
while (control.length !== 0) {
control.removeAt(0);
}
}
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
buildFormStoreState(formName, form) {
updateStore(name, control) {
/** @type {?} */
let value;
if (form instanceof FormControl) {
value = this.resolveFormToStore(form);
}
if (form instanceof FormGroup || form instanceof FormArray) {
// The root form group
value = Object.assign({}, this.resolveFormToStore(form), { controls: {} });
for (const key of Object.keys(form.controls)) {
/** @type {?} */
const control = form.controls[key];
if (control instanceof FormGroup || form instanceof FormArray) {
value.controls[key] = this.buildFormStoreState(formName, control);
}
else {
value.controls[key] = this.resolveFormToStore(control);
}
}
}
return value;
}
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
updateStore(formName, form) {
/** @type {?} */
const value = this.buildFormStoreState(formName, form);
const value = toStore(name, control);
this.store.update((/** @type {?} */ ({
[formName]: value,
[name]: value,
})));
return value;
}
/**
* @private
* @param {?} control
* @return {?}
*/
resolveFormToStore(control) {
return {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
}
}

@@ -544,3 +468,3 @@ NgFormsManager.decorators = [

*/
NgFormsManager.prototype.valueChanges;
NgFormsManager.prototype.valueChanges$$;
/**

@@ -550,3 +474,3 @@ * @type {?}

*/
NgFormsManager.prototype.instances;
NgFormsManager.prototype.instances$$;
/**

@@ -556,4 +480,9 @@ * @type {?}

*/
NgFormsManager.prototype.destroy$$;
/**
* @type {?}
* @private
*/
NgFormsManager.prototype.config;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybXMtbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvZm9ybXMtbWFuYWdlci8iLCJzb3VyY2VzIjpbImxpYi9mb3Jtcy1tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsT0FBTyxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQzdELE9BQU8sRUFBbUIsU0FBUyxFQUFFLFdBQVcsRUFBRSxTQUFTLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUNwRixPQUFPLEVBQUUsS0FBSyxFQUFFLFdBQVcsRUFBRSxpQkFBaUIsRUFBRSxTQUFTLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxNQUFNLFNBQVMsQ0FBQztBQUNqRyxPQUFPLEVBQUUsS0FBSyxFQUE0QixNQUFNLE1BQU0sQ0FBQztBQUN2RCxPQUFPLEVBQUUsWUFBWSxFQUFFLG9CQUFvQixFQUFFLEdBQUcsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3pFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUVuRCxPQUFPLEVBQVUsdUJBQXVCLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSxVQUFVLENBQUM7QUFDakYsT0F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vcmUudXBkYXRlKHtcbiAgICAgIFtuYW1lXTogdmFsdWUsXG4gICAgfSBhcyBhbnkpO1xuXG4gICAgcmV0dXJuIHZhbHVlO1xuICB9XG59XG4iXX0=

@@ -8,14 +8,5 @@ /**

* @record
* @template C
*/
export function AbstractGroup() { }
if (false) {
/** @type {?} */
AbstractGroup.prototype.controls;
}
/**
* @record
* @template T
*/
export function HashMap() { }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2Zvcm1zLW1hbmFnZXIvIiwic291cmNlcyI6WyJsaWIvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBT0EsbUNBRUM7OztJQURDLGlDQUF3RDs7Ozs7O0FBSzFELDZCQUVDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQWJzdHJhY3RDb250cm9sIH0gZnJvbSAnQGFuZ3VsYXIvZm9ybXMnO1xuXG5leHBvcnQgdHlwZSBfQWJzdHJhY3RDb250cm9sPFQgPSBhbnk+ID0gUGljazxcbiAgQWJzdHJhY3RDb250cm9sLFxuICAndmFsaWQnIHwgJ2ludmFsaWQnIHwgJ2Rpc2FibGVkJyB8ICdlcnJvcnMnIHwgJ3RvdWNoZWQnIHwgJ3ByaXN0aW5lJyB8ICdwZW5kaW5nJyB8ICdkaXJ0eSdcbj4gJiB7IHJhd1ZhbHVlOiBUOyB2YWx1ZTogVCB9O1xuXG5leHBvcnQgaW50ZXJmYWNlIEFic3RyYWN0R3JvdXA8QyA9IGFueT4gZXh0ZW5kcyBfQWJzdHJhY3RDb250cm9sPEM+IHtcbiAgY29udHJvbHM6IHsgcmVhZG9ubHkgW1AgaW4ga2V5b2YgQ106IF9BYnN0cmFjdENvbnRyb2wgfTtcbn1cblxuZXhwb3J0IHR5cGUgQ29udHJvbEZhY3RvcnkgPSAodmFsdWU6I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hdGU+ID0ga2V5b2YgRm9ybXNTdGF0ZSB8IChrZXlvZiBGb3Jtc1N0YXRlKVtdO1xuIl19

@@ -63,3 +63,2 @@ /**

'valid',
'rawValue',
];

@@ -78,2 +77,19 @@ /**

/**
* @param {?} arr
* @param {?} cb
* @return {?}
*/
function filtrArrayKeys(arr, cb) {
return arr.reduce((/**
* @param {?} acc
* @param {?} control
* @param {?} index
* @return {?}
*/
(acc, control, index) => {
acc[index] = filterKeys(control, cb);
return acc;
}), []);
}
/**
* @param {?} obj

@@ -83,3 +99,3 @@ * @param {?} cb

*/
export function filterKeys(obj, cb) {
function filterKeys(obj, cb) {
/** @type {?} */

@@ -92,4 +108,7 @@ const filtered = {};

if (isObject(value)) {
filtered[key] = filterKeys(obj[key], cb);
filtered[key] = filterKeys(value, cb);
}
else if (Array.isArray(value) && key === 'controls') {
filtered[key] = filtrArrayKeys(value, cb);
}
else {

@@ -134,2 +153,2 @@ filtered[key] = value;

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2Zvcm1zLW1hbmFnZXIvIiwic291cmNlcyI6WyJsaWIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFDQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7O0FBSXhDLE1BQU0sT0FBTyxTQUFTOzs7OztBQUFHLENBQUksTUFBd0MsRUFBRSxFQUFFLENBQ3ZFLE1BQU0sQ0FBQyxJQUFJLENBQ1QsTUFBTTs7OztBQUNKLENBQUMsS0FBSyxFQUFzQyxFQUFFLENBQUMsS0FBSyxLQUFLLElBQUksSUFBSSxPQUFPLEtBQUssS0FBSyxXQUFXLEVBQzlGLENBQ0YsQ0FBQTs7Ozs7O0FBRUgsTUFBTSxVQUFVLFdBQVcsQ0FBSSxLQUFjO0lBQzNDLElBQUksS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XR1cm4gdHlwZW9mIHdpbmRvdyAhPT0gJ3VuZGVmaW5lZCc7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBtZXJnZURlZXAodGFyZ2V0LCAuLi5zb3VyY2VzKSB7XG4gIGlmICghc291cmNlcy5sZW5ndGgpIHtcbiAgICByZXR1cm4gdGFyZ2V0O1xuICB9XG4gIGNvbnN0IHNvdXJjZSA9IHNvdXJjZXMuc2hpZnQoKTtcblxuICBpZiAoaXNPYmplY3QodGFyZ2V0KSAmJiBpc09iamVjdChzb3VyY2UpKSB7XG4gICAgZm9yIChjb25zdCBrZXkgaW4gc291cmNlKSB7XG4gICAgICBpZiAoaXNPYmplY3Qoc291cmNlW2tleV0pKSB7XG4gICAgICAgIGlmICghdGFyZ2V0W2tleV0pIHtcbiAgICAgICAgICBPYmplY3QuYXNzaWduKHRhcmdldCwgeyBba2V5XToge30gfSk7XG4gICAgICAgIH1cbiAgICAgICAgbWVyZ2VEZWVwKHRhcmdldFtrZXldLCBzb3VyY2Vba2V5XSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBPYmplY3QuYXNzaWduKHRhcmdldCwgeyBba2V5XTogc291cmNlW2tleV0gfSk7XG4gICAgICB9XG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIG1lcmdlRGVlcCh0YXJnZXQsIC4uLnNvdXJjZXMpO1xufVxuIl19

@@ -23,3 +23,3 @@ /**

if (providerConfig === void 0) { providerConfig = {}; }
return (/** @type {?} */ (tslib_1.__assign({ storage: tslib_1.__assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
return (/** @type {?} */ (tslib_1.__assign({}, defaults, { storage: tslib_1.__assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
}

@@ -63,2 +63,2 @@ var NgFormsManagerConfig = /** @class */ (function () {

});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291c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LFxuICBpbmxpbmVDb25maWc6IFBhcnRpYWw8Q29uZmlnPlxuKSB7XG4gIHJldHVybiB7XG4gICAgLi4uZGVmYXVsdHMsXG4gICAgc3RvcmFnZToge1xuICAgICAgLi4uZGVmYXVsdHMuc3RvcmFnZSxcbiAgICAgIC4uLnByb3ZpZGVyQ29uZmlnLnN0b3JhZ2UsXG4gICAgICAuLi5pbmxpbmVDb25maWcuc3RvcmFnZSxcbiAgICB9LFxuICAgIC4uLnByb3ZpZGVyQ29uZmlnLFxuICAgIC4uLmlubGluZUNvbmZpZyxcbiAgfSBhcyBDb25maWc7XG59XG5cbmV4cG9ydCBjbGFzcyBOZ0Zvcm1zTWFuYWdlckNvbmZpZyB7XG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgY29uZmlnOiBQYXJ0aWFsPENvbmZpZz4gPSB7fSkge31cblxuICBtZXJnZShpbmxpbmU6IFBhcnRpYWw8Q29uZmlnPiA9IHt9KTogQ29uZmlnIHtcbiAgICByZXR1cm4gbWVyZ2VDb25maWcoZGVmYXVsdHMsIHRoaXMuY29uZmlnLCBpbmxpbmUpO1xuICB9XG59XG5cbmV4cG9ydCBjb25zdCBOR19GT1JNU19NQU5BR0VSX0NPTkZJRyA9IG5ldyBJbmplY3Rpb25Ub2tlbjxOZ0Zvcm1zTWFuYWdlckNvbmZpZz4oXG4gICdOR19GT1JNU19NQU5BR0VSX0NPTkZJRycsXG4gIHtcbiAgICBwcm92aWRlZEluOiAncm9vdCcsXG4gICAgZmFjdG9yeTogKCkgPT4ge1xuICAgICAgcmV0dXJuIG5ldyBOZ0Zvcm1zTWFuYWdlckNvbmZpZygpO1xuICAgIH0sXG4gIH1cbik7XG4iXX0=

@@ -8,9 +8,9 @@ /**

import { Inject, Injectable, Optional } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { clone, coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils';
import { merge } from 'rxjs';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import { coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils';
import { merge, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs/operators';
import { FormsStore } from './forms-manager.store';
import { NG_FORMS_MANAGER_CONFIG, NgFormsManagerConfig } from './config';
import isEqual from 'lodash.isequal';
import { isEqual } from './isEqual';
import { deleteControl, findControl, handleFormArray, toStore } from './builders';
import * as i0 from "@angular/core";

@@ -24,18 +24,42 @@ import * as i1 from "./config";

this.config = config;
this.valueChanges = new Map();
this.instances = new Map();
this.valueChanges$$ = new Map();
this.instances$$ = new Map();
this.destroy$$ = new Subject();
this.store = new FormsStore((/** @type {?} */ ({})));
}
/**
* @param {?} formName
*
* @example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValid = /**
* @param {?} formName
NgFormsManager.prototype.validityChanges = /**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -47,13 +71,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDirty = /**
* @param {?} formName
NgFormsManager.prototype.dirtyChanges = /**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -65,13 +112,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDisabled = /**
* @param {?} formName
NgFormsManager.prototype.disableChanges = /**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -83,13 +153,13 @@ * @return {?}

/**
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValue = /**
* @param {?} formName
NgFormsManager.prototype.valueChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -101,15 +171,41 @@ * @return {?}

/**
* @template T
* @param {?} formName
*
* @example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
*/
/**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectErrors = /**
* @template T
* @param {?} formName
NgFormsManager.prototype.errorsChanges = /**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -121,34 +217,31 @@ * @return {?}

/**
* If no path specified it means that it's a single FormControl or FormArray
*/
/**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectControl = /**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
NgFormsManager.prototype.controlChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
var _this = this;
if (!path) {
return (/** @type {?} */ (this.selectForm(formName)));
}
return this.store
.select((/**
function (name, path) {
/** @type {?} */
var control$ = this.store.select((/**
* @param {?} state
* @return {?}
*/
function (state) { return state[(/** @type {?} */ (formName))]; }))
.pipe(filterNil, map((/**
* @param {?} form
function (state) { return state[(/** @type {?} */ (name))]; })).pipe(filterNil);
if (!path) {
return control$.pipe(distinctUntilChanged((/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function (a, b) { return isEqual(a, b); })));
}
return control$.pipe(map((/**
* @param {?} control
* @return {?}
*/
function (form) { return _this.resolveControl(form, path); })), distinctUntilChanged((/**
function (control) { return findControl(control, path); })), distinctUntilChanged((/**
* @param {?} a

@@ -161,4 +254,43 @@ * @param {?} b

/**
* @template T
* @param {?} formName
*
* @example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
*/
/**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.controlDestroyed = /**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
function (name) {
return this.destroy$$
.asObservable()
.pipe(filter((/**
* @param {?} controlName
* @return {?}
*/
function (controlName) { return name === controlName || controlName === '$$ALL'; })));
};
/**
* @param {?} name
* @param {?=} path

@@ -168,15 +300,14 @@ * @return {?}

NgFormsManager.prototype.getControl = /**
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
function (name, path) {
if (!path) {
return (/** @type {?} */ (this.getForm(formName)));
return (/** @type {?} */ (this.store.getValue()[name]));
}
if (this.hasForm(formName)) {
if (this.hasControl(name)) {
/** @type {?} */
var form = this.getForm(formName);
return this.resolveControl(form, path);
var control = this.getControl(name);
return findControl(control, path);
}

@@ -186,56 +317,286 @@ return null;

/**
*
* @example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
*/
/**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.hasControl = /**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (name, path) {
return !!this.getControl(name, path);
};
/**
*
* @example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.selectForm = /**
NgFormsManager.prototype.patchValue = /**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, options) {
if (options === void 0) { options = { filterNil: true }; }
return this.store
.select((/**
* @param {?} state
* @return {?}
*/
function (state) { return state[(/** @type {?} */ (formName))]; }))
.pipe(options.filterNil ? filterNil : (/**
* @param {?} s
* @return {?}
*/
function (s) { return s; }));
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).patchValue(value, options);
}
};
/**
* @template Name
* @param {?} formName
*
* @example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.getForm = /**
* @template Name
* @param {?} formName
NgFormsManager.prototype.setValue = /**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName) {
return this.store.getValue()[(/** @type {?} */ (formName))];
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).setValue(value, options);
}
};
/**
* @param {?} formName
*
* @example
*
* manager.unsubscribe('login');
*
*/
/**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.hasForm = /**
* @param {?} formName
NgFormsManager.prototype.unsubscribe = /**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
function (formName) {
return !!this.getForm(formName);
function (name) {
var _this = this;
var e_1, _a;
if (name) {
/** @type {?} */
var names = coerceArray(name);
try {
for (var names_1 = tslib_1.__values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) {
var name_1 = names_1_1.value;
if (this.valueChanges$$.has(name_1)) {
this.valueChanges$$.get(name_1).unsubscribe();
}
this.valueChanges$$.delete(name_1);
this.instances$$.delete(name_1);
this.destroy$$.next(name_1);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (names_1_1 && !names_1_1.done && (_a = names_1.return)) _a.call(names_1);
}
finally { if (e_1) throw e_1.error; }
}
}
else {
this.valueChanges$$.forEach((/**
* @param {?} subscription
* @return {?}
*/
function (subscription) {
subscription.unsubscribe();
_this.destroy$$.next('$$ALL');
}));
this.valueChanges$$.clear();
this.instances$$.clear();
}
};
/**
*
* @example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
*/
/**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.clear = /**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
name ? this.deleteControl(name) : this.store.set((/** @type {?} */ ({})));
this.removeFromStorage();
};
/**
*
* @example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
*/
/**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
this.unsubscribe(name);
this.clear(name);
};
/**
*
* @example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
*/
/**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config

@@ -245,10 +606,21 @@ * @return {THIS}

NgFormsManager.prototype.upsert = /**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config
* @return {THIS}
*/
function (formName, form, config) {
function (name, control, config) {
var _this = this;

@@ -259,14 +631,14 @@ if (config === void 0) { config = {}; }

var mergedConfig = (/** @type {?} */ ((/** @type {?} */ (this)).config.merge(config)));
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasForm(formName) === false) {
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasControl(name) === false) {
/** @type {?} */
var storageValue = (/** @type {?} */ (this)).getFromStorage(mergedConfig.storage.key);
if (storageValue[formName]) {
if (storageValue[name]) {
(/** @type {?} */ (this)).store.update((/** @type {?} */ (_a = {},
_a[formName] = mergeDeep((/** @type {?} */ (this)).buildFormStoreState(formName, form), storageValue[formName]),
_a[name] = mergeDeep(toStore(name, control), storageValue[name]),
_a)));
}
}
/** If the form already exist, patch the form with the store value */
if ((/** @type {?} */ (this)).hasForm(formName) === true) {
form.patchValue((/** @type {?} */ (this)).resolveStoreToForm(formName, form, mergedConfig.arrControlFactory), {
/** If the control already exist, patch the control with the store value */
if ((/** @type {?} */ (this)).hasControl(name) === true) {
control.patchValue((/** @type {?} */ (this)).toControlValue(name, control, mergedConfig.arrControlFactory), {
emitEvent: false,

@@ -277,7 +649,7 @@ });

/** @type {?} */
var value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
var value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}
/** @type {?} */
var unsubscribe = merge(form.valueChanges, form.statusChanges.pipe(distinctUntilChanged()))
var unsubscribe = merge(control.valueChanges, control.statusChanges.pipe(distinctUntilChanged()))
.pipe(debounceTime(mergedConfig.debounceTime))

@@ -289,80 +661,15 @@ .subscribe((/**

/** @type {?} */
var value = (/** @type {?} */ (_this)).updateStore(formName, form);
(/** @type {?} */ (_this)).updateStorage(formName, value, mergedConfig);
var value = (/** @type {?} */ (_this)).updateStore(name, control);
(/** @type {?} */ (_this)).updateStorage(name, value, mergedConfig);
}));
(/** @type {?} */ (this)).valueChanges.set(formName, unsubscribe);
(/** @type {?} */ (this)).instances.set(formName, form);
(/** @type {?} */ (this)).valueChanges$$.set(name, unsubscribe);
(/** @type {?} */ (this)).instances$$.set(name, control);
return (/** @type {?} */ (this));
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @private
* @return {?}
*/
NgFormsManager.prototype.patchValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).patchValue(value, options);
}
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.setValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).setValue(value, options);
}
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.clear = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
if (formName) {
this.removeFromStore(formName);
}
else {
this.store.set((/** @type {?} */ ({})));
}
this.removeFromStorage();
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
this.clear(formName);
this.unsubscribe(formName);
};
/**
* @return {?}
*/
NgFormsManager.prototype.removeFromStorage = /**
* @private
* @return {?}

@@ -374,39 +681,4 @@ */

/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.unsubscribe = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
var _this = this;
/** @type {?} */
var toArray = coerceArray(formName);
if (formName) {
toArray.forEach((/**
* @param {?} name
* @return {?}
*/
function (name) {
if (_this.valueChanges.has(name)) {
_this.valueChanges.get(name).unsubscribe();
_this.valueChanges.delete(name);
}
_this.instances.delete(name);
}));
}
else {
this.valueChanges.forEach((/**
* @param {?} subscription
* @return {?}
*/
function (subscription) { return subscription.unsubscribe(); }));
this.valueChanges.clear();
this.instances.clear();
}
};
/**
* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -418,3 +690,3 @@ * @param {?} config

* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -424,7 +696,7 @@ * @param {?} config

*/
function (formName, value, config) {
function (name, value, config) {
if (isBrowser() && config.persistState) {
/** @type {?} */
var storageValue = this.getFromStorage(config.storage.key);
storageValue[formName] = filterControlKeys(value);
storageValue[name] = filterControlKeys(value);
localStorage.setItem(config.storage.key, JSON.stringify(storageValue));

@@ -448,80 +720,23 @@ }

* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.removeFromStore = /**
NgFormsManager.prototype.deleteControl = /**
* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
function (formName) {
/** @type {?} */
var toArray = coerceArray(formName);
/** @type {?} */
var snapshot = this.store.getValue();
/** @type {?} */
var newState = Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
function (acc, currentFormName) {
if (toArray.includes((/** @type {?} */ (currentFormName))) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
this.store.set((/** @type {?} */ (newState)));
function (name) {
this.store.set((/** @type {?} */ (deleteControl(this.store.getValue(), coerceArray(name)))));
};
/**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.resolveControl = /**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
function (form, path) {
var _a = tslib_1.__read(path.split('.')), first = _a[0], rest = _a.slice(1);
if (rest.length === 0) {
return form.controls[first];
}
return this.find(form.controls[first], rest);
};
/**
* @private
* @param {?} name
* @param {?} control
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.find = /**
* @private
* @param {?} control
* @param {?} path
* @return {?}
*/
function (control, path) {
return path.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
function (current, name) {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control);
};
/**
* @private
* @param {?} formName
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.resolveStoreToForm = /**
NgFormsManager.prototype.toControlValue = /**
* @private
* @param {?} formName
* @param {?} name
* @param {?} control

@@ -531,12 +746,12 @@ * @param {?} arrControlFactory

*/
function (formName, control, arrControlFactory) {
function (name, control, arrControlFactory) {
/** @type {?} */
var form = this.getForm(formName);
var currentControl = this.getControl(name);
/** @type {?} */
var value = form.value;
/** It means it a single control */
if (!form.controls) {
var value = currentControl.value;
/** It means it's not a FormGroup or FormArray */
if (!currentControl.controls) {
return value;
}
this.handleFormArray(value, control, arrControlFactory);
handleFormArray(value, control, arrControlFactory);
return value;

@@ -546,163 +761,21 @@ };

* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.handleFormArray = /**
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function (formValue, control, arrControlFactory) {
var _this = this;
if (control instanceof FormArray) {
this.cleanArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) {
return ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v));
}));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
function (controlName) {
/** @type {?} */
var value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error('Please provide arrControlFactory for ' + controlName);
}
/** @type {?} */
var current_1 = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
var fc_1 = arrControlFactory[controlName];
_this.cleanArray(current_1);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) { return current_1.insert(i, fc_1(v)); }));
}
}));
}
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.cleanArray = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
while (control.length !== 0) {
control.removeAt(0);
}
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.buildFormStoreState = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
var e_1, _a;
/** @type {?} */
var value;
if (form instanceof FormControl) {
value = this.resolveFormToStore(form);
}
if (form instanceof FormGroup || form instanceof FormArray) {
// The root form group
value = tslib_1.__assign({}, this.resolveFormToStore(form), { controls: {} });
try {
for (var _b = tslib_1.__values(Object.keys(form.controls)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
/** @type {?} */
var control = form.controls[key];
if (control instanceof FormGroup || form instanceof FormArray) {
value.controls[key] = this.buildFormStoreState(formName, control);
}
else {
value.controls[key] = this.resolveFormToStore(control);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}
return value;
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
function (name, control) {
var _a;
/** @type {?} */
var value = this.buildFormStoreState(formName, form);
var value = toStore(name, control);
this.store.update((/** @type {?} */ (_a = {},
_a[formName] = value,
_a[name] = value,
_a)));
return value;
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.resolveFormToStore = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
return {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
};
NgFormsManager.decorators = [

@@ -729,3 +802,3 @@ { type: Injectable, args: [{ providedIn: 'root' },] }

*/
NgFormsManager.prototype.valueChanges;
NgFormsManager.prototype.valueChanges$$;
/**

@@ -735,3 +808,3 @@ * @type {?}

*/
NgFormsManager.prototype.instances;
NgFormsManager.prototype.instances$$;
/**

@@ -741,4 +814,9 @@ * @type {?}

*/
NgFormsManager.prototype.destroy$$;
/**
* @type {?}
* @private
*/
NgFormsManager.prototype.config;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybXMtbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BuZ25lYXQvZm9ybXMtbWFuYWdlci8iLCJzb3VyY2VzIjpbImxpYi9mb3Jtcy1tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUM3RCxPQUFPLEVBQW1CLFNBQVMsRUFBRSxXQUFXLEVBQUUsU0FBUyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDcEYsT0FBTyxFQUFFLEtBQUssRUFBRSxXQUFXLEVBQUUsaUJBQWlCLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxTQUFTLEVBQUUsTUFBTSxTQUFTLENBQUM7QUFDakcsT0FBTyxFQUFFLEtBQUssRUFBNEIsTUFBTSxNQUFNLENBQUM7QUFDdkQsT0FBTyxFQUFFLFlBQVksRUFBRSxvQkFBb0IsRUFBRSxHQUFHLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUN6RSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbkQsT0FBTyxFQUFVLHVCQUF1QixFQUFFLG9CQUFvQixFQUFFLE1BQU0sVUFBVSxDQUFDO0FBQ2pGLE9BQU8sT0FBTyxNQUFNLGdCQUFnQixDQUFDOzs7Ozs7QUFFckM7SUFNRSx3QkFBaUUsTUFBNEI7UUFBNUIsV0FBTSxHQUFOLE1BQU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xuICAgIGNvbnN0IHZhbHVlID0gY3VycmVudENvbnRyb2wudmFsdWU7XG5cbiAgICAvKiogSXQgbWVhbnMgaXQncyBub3QgYSBGb3JtR3JvdXAgb3IgRm9ybUFycmF5ICovXG4gICAgaWYgKCFjdXJyZW50Q29udHJvbC5jb250cm9scykge1xuICAgICAgcmV0dXJuIHZhbHVlO1xuICAgIH1cblxuICAgIGhhbmRsZUZvcm1BcnJheSh2YWx1ZSwgY29udHJvbCwgYXJyQ29udHJvbEZhY3RvcnkpO1xuICAgIHJldHVybiB2YWx1ZTtcbiAgfVxuXG4gIHByaXZhdGUgdXBkYXRlU3RvcmUobmFtZToga2V5b2YgRm9ybXNTdGF0ZSwgY29udHJvbDogQWJzdHJhY3RDb250cm9sKSB7XG4gICAgY29uc3QgdmFsdWUgPSB0b1N0b3JlPEZvcm1zU3RhdGU+KG5hbWUsIGNvbnRyb2wpO1xuICAgIHRoaXMuc3RvcmUudXBkYXRlKHtcbiAgICAgIFtuYW1lXTogdmFsdWUsXG4gICAgfSBhcyBhbnkpO1xuXG4gICAgcmV0dXJuIHZhbHVlO1xuICB9XG59XG4iXX0=

@@ -8,14 +8,5 @@ /**

* @record
* @template C
*/
export function AbstractGroup() { }
if (false) {
/** @type {?} */
AbstractGroup.prototype.controls;
}
/**
* @record
* @template T
*/
export function HashMap() { }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AbmduZWF0L2Zvcm1zLW1hbmFnZXIvIiwic291cmNlcyI6WyJsaWIvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBT0EsbUNBRUM7OztJQURDLGlDQUF3RDs7Ozs7O0FBSzFELDZCQUVDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQWJzdHJhY3RDb250cm9sIH0gZnJvbSAnQGFuZ3VsYXIvZm9ybXMnO1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b2w8VCA9IGFueT4gPSBQaWNrPFxuICBBYnN0cmFjdENvbnRyb2wsXG4gICd2YWxpZCcgfCAnaW52YWxpZCcgfCAnZGlzYWJsZWQnIHwgJ2Vycm9ycycgfCAndG91Y2hlZCcgfCAncHJpc3RpbmUnIHwgJ3BlbmRpbmcnIHwgJ2RpcnR5J1xuPiAmIHsgcmF3VmFsdWU6IFQ7IHZhbHVlOiBUOyBjb250cm9scz86IHsgcmVhZG9ubHkgW1AgaW4ga2V5b2YgVF06IENvbnRyb2wgfSB9O1xuXG5leHBvcnQgdHlwZSBDb250cm9sRmFjdG9yeSA9ICh2YWx1ZTogYW55KSA9PiBBYnN0cmFjdENvbnRyb2w7XG5cbmV4cG9ydCBpbnRlcmZhY2UgSGFzaE1hcDxUID0gYW55PiB7XG4gIFtrZXk6IHN0cmluZ106IFQ7XG59XG5cbmV4cG9ydCB0eXBlIEZvcm1LZXlzPEZvcm1zU3RhdGU+ID0ga2V5b2YgRm9ybXNTdGF0ZSB8IChrZXlvZiBGb3Jtc1N0YXRlKVtdO1xuIl19

@@ -66,3 +66,2 @@ /**

'valid',
'rawValue',
];

@@ -81,2 +80,19 @@ /**

/**
* @param {?} arr
* @param {?} cb
* @return {?}
*/
function filtrArrayKeys(arr, cb) {
return arr.reduce((/**
* @param {?} acc
* @param {?} control
* @param {?} index
* @return {?}
*/
function (acc, control, index) {
acc[index] = filterKeys(control, cb);
return acc;
}), []);
}
/**
* @param {?} obj

@@ -86,3 +102,3 @@ * @param {?} cb

*/
export function filterKeys(obj, cb) {
function filterKeys(obj, cb) {
var e_1, _a;

@@ -98,4 +114,7 @@ /** @type {?} */

if (isObject(value)) {
filtered[key] = filterKeys(obj[key], cb);
filtered[key] = filterKeys(value, cb);
}
else if (Array.isArray(value) && key === 'controls') {
filtered[key] = filtrArrayKeys(value, cb);
}
else {

@@ -153,2 +172,2 @@ filtered[key] = value;

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjo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YXNzaWduKHRhcmdldCwgeyBba2V5XToge30gfSk7XG4gICAgICAgIH1cbiAgICAgICAgbWVyZ2VEZWVwKHRhcmdldFtrZXldLCBzb3VyY2Vba2V5XSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBPYmplY3QuYXNzaWduKHRhcmdldCwgeyBba2V5XTogc291cmNlW2tleV0gfSk7XG4gICAgICB9XG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIG1lcmdlRGVlcCh0YXJnZXQsIC4uLnNvdXJjZXMpO1xufVxuIl19

@@ -1,6 +0,5 @@

import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { BehaviorSubject, merge } from 'rxjs';
import { BehaviorSubject, merge, Subject } from 'rxjs';
import { filter, distinctUntilChanged, map, debounceTime } from 'rxjs/operators';
import { InjectionToken, Inject, Injectable, Optional, defineInjectable, inject } from '@angular/core';
import isEqual from 'lodash.isequal';
import { FormArray, FormControl, FormGroup } from '@angular/forms';

@@ -68,3 +67,2 @@ /**

'valid',
'rawValue',
];

@@ -83,2 +81,19 @@ /**

/**
* @param {?} arr
* @param {?} cb
* @return {?}
*/
function filtrArrayKeys(arr, cb) {
return arr.reduce((/**
* @param {?} acc
* @param {?} control
* @param {?} index
* @return {?}
*/
(acc, control, index) => {
acc[index] = filterKeys(control, cb);
return acc;
}), []);
}
/**
* @param {?} obj

@@ -96,4 +111,7 @@ * @param {?} cb

if (isObject(value)) {
filtered[key] = filterKeys(obj[key], cb);
filtered[key] = filterKeys(value, cb);
}
else if (Array.isArray(value) && key === 'controls') {
filtered[key] = filtrArrayKeys(value, cb);
}
else {

@@ -204,3 +222,3 @@ filtered[key] = value;

function mergeConfig(defaults, providerConfig = {}, inlineConfig) {
return (/** @type {?} */ (Object.assign({ storage: Object.assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
return (/** @type {?} */ (Object.assign({}, defaults, { storage: Object.assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
}

@@ -235,2 +253,221 @@ class NgFormsManagerConfig {

* @fileoverview added by tsickle
* Generated from: lib/isEqual.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// https://github.com/epoberezkin/fast-deep-equal
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function isEqual(a, b) {
if (a === b) {
return true;
}
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) {
return false;
}
/** @type {?} */
var length;
/** @type {?} */
var i;
/** @type {?} */
var keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!isEqual(a[i], b[i])) {
return false;
}
}
return true;
}
if (a.constructor === RegExp) {
return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) {
return a.valueOf() === b.valueOf();
}
if (a.toString !== Object.prototype.toString) {
return a.toString() === b.toString();
}
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
return false;
}
}
for (i = length; i-- !== 0;) {
/** @type {?} */
var key = keys[i];
if (!isEqual(a[key], b[key])) {
return false;
}
}
return true;
}
// true if both NaN, false otherwise
return a !== a && b !== b;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/builders.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template FormsState
* @param {?} name
* @param {?} control
* @return {?}
*/
function toStore(name, control) {
/** @type {?} */
let value;
if (control instanceof FormControl) {
value = buildValue(control);
return value;
}
if (control instanceof FormGroup || control instanceof FormArray) {
value = buildValue(control);
for (const key of Object.keys(control.controls)) {
/** @type {?} */
const current = control.controls[key];
if (current instanceof FormGroup || current instanceof FormArray) {
value.controls[key] = toStore(name, current);
}
else {
value.controls[key] = buildValue(current);
}
}
}
return value;
}
/**
* @param {?} formValue
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function handleFormArray(formValue, control, arrControlFactory) {
if (control instanceof FormArray) {
clearFormArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v))));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
controlName => {
/** @type {?} */
const value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error(`Please provide arrControlFactory for ${controlName}`);
}
/** @type {?} */
const current = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
const fc = arrControlFactory[controlName];
clearFormArray(current);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => current.insert(i, fc(v))));
}
}));
}
}
/**
* @param {?} snapshot
* @param {?} controls
* @return {?}
*/
function deleteControl(snapshot, controls) {
return Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
(acc, currentFormName) => {
if (controls.includes(currentFormName) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
}
/**
* @param {?} control
* @param {?} path
* @return {?}
*/
function findControl(control, path) {
const [first, ...rest] = path.split('.');
if (rest.length === 0) {
return control.controls[first];
}
return rest.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
(current, name) => {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control.controls[first]);
}
/**
* @param {?} control
* @return {?}
*/
function buildValue(control) {
/** @type {?} */
const value = {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
if (control instanceof FormGroup || control instanceof FormArray) {
value['controls'] = control instanceof FormArray ? [] : {};
}
return value;
}
/**
* @param {?} control
* @return {?}
*/
function clearFormArray(control) {
while (control.length !== 0) {
control.removeAt(0);
}
}
/**
* @fileoverview added by tsickle
* Generated from: lib/forms-manager.ts

@@ -248,13 +485,21 @@ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc

this.config = config;
this.valueChanges = new Map();
this.instances = new Map();
this.valueChanges$$ = new Map();
this.instances$$ = new Map();
this.destroy$$ = new Subject();
this.store = new FormsStore((/** @type {?} */ ({})));
}
/**
* @param {?} formName
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectValid(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
validityChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -266,8 +511,15 @@ * @return {?}

/**
* @param {?} formName
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectDirty(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
dirtyChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -279,8 +531,15 @@ * @return {?}

/**
* @param {?} formName
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectDisabled(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
disableChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -292,8 +551,8 @@ * @return {?}

/**
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectValue(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
valueChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -305,9 +564,17 @@ * @return {?}

/**
* @template T
* @param {?} formName
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectErrors(formName, path) {
return this.selectControl(formName, path).pipe(map((/**
errorsChanges(name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -319,23 +586,26 @@ * @return {?}

/**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
selectControl(formName, path) {
if (!path) {
return (/** @type {?} */ (this.selectForm(formName)));
}
return this.store
.select((/**
controlChanges(name, path) {
/** @type {?} */
const control$ = this.store.select((/**
* @param {?} state
* @return {?}
*/
state => state[(/** @type {?} */ (formName))]))
.pipe(filterNil, map((/**
* @param {?} form
state => state[(/** @type {?} */ (name))])).pipe(filterNil);
if (!path) {
return control$.pipe(distinctUntilChanged((/**
* @param {?} a
* @param {?} b
* @return {?}
*/
(a, b) => isEqual(a, b))));
}
return control$.pipe(map((/**
* @param {?} control
* @return {?}
*/
form => this.resolveControl(form, path))), distinctUntilChanged((/**
control => findControl(control, path))), distinctUntilChanged((/**
* @param {?} a

@@ -348,15 +618,34 @@ * @param {?} b

/**
* @template T
* @param {?} formName
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
controlDestroyed(name) {
return this.destroy$$
.asObservable()
.pipe(filter((/**
* @param {?} controlName
* @return {?}
*/
controlName => name === controlName || controlName === '$$ALL')));
}
/**
* @param {?} name
* @param {?=} path
* @return {?}
*/
getControl(formName, path) {
getControl(name, path) {
if (!path) {
return (/** @type {?} */ (this.getForm(formName)));
return (/** @type {?} */ (this.store.getValue()[name]));
}
if (this.hasForm(formName)) {
if (this.hasControl(name)) {
/** @type {?} */
const form = this.getForm(formName);
return this.resolveControl(form, path);
const control = this.getControl(name);
return findControl(control, path);
}

@@ -366,58 +655,154 @@ return null;

/**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
hasControl(name, path) {
return !!this.getControl(name, path);
}
/**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
selectForm(formName, options = { filterNil: true }) {
return this.store
.select((/**
* @param {?} state
* @return {?}
*/
state => state[(/** @type {?} */ (formName))]))
.pipe(options.filterNil ? filterNil : (/**
* @param {?} s
* @return {?}
*/
s => s));
patchValue(name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).patchValue(value, options);
}
}
/**
* @template Name
* @param {?} formName
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
getForm(formName) {
return this.store.getValue()[(/** @type {?} */ (formName))];
setValue(name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).setValue(value, options);
}
}
/**
* @param {?} formName
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
hasForm(formName) {
return !!this.getForm(formName);
unsubscribe(name) {
if (name) {
/** @type {?} */
const names = coerceArray(name);
for (const name of names) {
if (this.valueChanges$$.has(name)) {
this.valueChanges$$.get(name).unsubscribe();
}
this.valueChanges$$.delete(name);
this.instances$$.delete(name);
this.destroy$$.next(name);
}
}
else {
this.valueChanges$$.forEach((/**
* @param {?} subscription
* @return {?}
*/
subscription => {
subscription.unsubscribe();
this.destroy$$.next('$$ALL');
}));
this.valueChanges$$.clear();
this.instances$$.clear();
}
}
/**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
clear(name) {
name ? this.deleteControl(name) : this.store.set((/** @type {?} */ ({})));
this.removeFromStorage();
}
/**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
destroy(name) {
this.unsubscribe(name);
this.clear(name);
}
/**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config
* @return {THIS}
*/
upsert(formName, form, config = {}) {
upsert(name, control, config = {}) {
/** @type {?} */
const mergedConfig = (/** @type {?} */ ((/** @type {?} */ (this)).config.merge(config)));
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasForm(formName) === false) {
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasControl(name) === false) {
/** @type {?} */
const storageValue = (/** @type {?} */ (this)).getFromStorage(mergedConfig.storage.key);
if (storageValue[formName]) {
if (storageValue[name]) {
(/** @type {?} */ (this)).store.update((/** @type {?} */ ({
[formName]: mergeDeep((/** @type {?} */ (this)).buildFormStoreState(formName, form), storageValue[formName]),
[name]: mergeDeep(toStore(name, control), storageValue[name]),
})));
}
}
/** If the form already exist, patch the form with the store value */
if ((/** @type {?} */ (this)).hasForm(formName) === true) {
form.patchValue((/** @type {?} */ (this)).resolveStoreToForm(formName, form, mergedConfig.arrControlFactory), {
/** If the control already exist, patch the control with the store value */
if ((/** @type {?} */ (this)).hasControl(name) === true) {
control.patchValue((/** @type {?} */ (this)).toControlValue(name, control, mergedConfig.arrControlFactory), {
emitEvent: false,

@@ -428,7 +813,7 @@ });

/** @type {?} */
const value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
const value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}
/** @type {?} */
const unsubscribe = merge(form.valueChanges, form.statusChanges.pipe(distinctUntilChanged()))
const unsubscribe = merge(control.valueChanges, control.statusChanges.pipe(distinctUntilChanged()))
.pipe(debounceTime(mergedConfig.debounceTime))

@@ -440,57 +825,13 @@ .subscribe((/**

/** @type {?} */
const value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
const value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}));
(/** @type {?} */ (this)).valueChanges.set(formName, unsubscribe);
(/** @type {?} */ (this)).instances.set(formName, form);
(/** @type {?} */ (this)).valueChanges$$.set(name, unsubscribe);
(/** @type {?} */ (this)).instances$$.set(name, control);
return (/** @type {?} */ (this));
}
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @private
* @return {?}
*/
patchValue(formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).patchValue(value, options);
}
}
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
setValue(formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).setValue(value, options);
}
}
/**
* @param {?=} formName
* @return {?}
*/
clear(formName) {
if (formName) {
this.removeFromStore(formName);
}
else {
this.store.set((/** @type {?} */ ({})));
}
this.removeFromStorage();
}
/**
* @param {?=} formName
* @return {?}
*/
destroy(formName) {
this.clear(formName);
this.unsubscribe(formName);
}
/**
* @return {?}
*/
removeFromStorage() {

@@ -500,34 +841,4 @@ localStorage.setItem(this.config.merge().storage.key, JSON.stringify(this.store.getValue()));

/**
* @param {?=} formName
* @return {?}
*/
unsubscribe(formName) {
/** @type {?} */
const toArray = coerceArray(formName);
if (formName) {
toArray.forEach((/**
* @param {?} name
* @return {?}
*/
name => {
if (this.valueChanges.has(name)) {
this.valueChanges.get(name).unsubscribe();
this.valueChanges.delete(name);
}
this.instances.delete(name);
}));
}
else {
this.valueChanges.forEach((/**
* @param {?} subscription
* @return {?}
*/
subscription => subscription.unsubscribe()));
this.valueChanges.clear();
this.instances.clear();
}
}
/**
* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -537,7 +848,7 @@ * @param {?} config

*/
updateStorage(formName, value, config) {
updateStorage(name, value, config) {
if (isBrowser() && config.persistState) {
/** @type {?} */
const storageValue = this.getFromStorage(config.storage.key);
storageValue[formName] = filterControlKeys(value);
storageValue[name] = filterControlKeys(value);
localStorage.setItem(config.storage.key, JSON.stringify(storageValue));

@@ -556,70 +867,25 @@ }

* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
removeFromStore(formName) {
/** @type {?} */
const toArray = coerceArray(formName);
/** @type {?} */
const snapshot = this.store.getValue();
/** @type {?} */
const newState = Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
(acc, currentFormName) => {
if (toArray.includes((/** @type {?} */ (currentFormName))) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
this.store.set((/** @type {?} */ (newState)));
deleteControl(name) {
this.store.set((/** @type {?} */ (deleteControl(this.store.getValue(), coerceArray(name)))));
}
/**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
resolveControl(form, path) {
const [first, ...rest] = path.split('.');
if (rest.length === 0) {
return form.controls[first];
}
return this.find(form.controls[first], rest);
}
/**
* @private
* @param {?} name
* @param {?} control
* @param {?} path
* @return {?}
*/
find(control, path) {
return path.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
(current, name) => {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control);
}
/**
* @private
* @param {?} formName
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
resolveStoreToForm(formName, control, arrControlFactory) {
toControlValue(name, control, arrControlFactory) {
/** @type {?} */
const form = this.getForm(formName);
const currentControl = this.getControl(name);
/** @type {?} */
const value = form.value;
/** It means it a single control */
if (!form.controls) {
const value = currentControl.value;
/** It means it's not a FormGroup or FormArray */
if (!currentControl.controls) {
return value;
}
this.handleFormArray(value, control, arrControlFactory);
handleFormArray(value, control, arrControlFactory);
return value;

@@ -629,119 +895,14 @@ }

* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
handleFormArray(formValue, control, arrControlFactory) {
if (control instanceof FormArray) {
this.cleanArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v))));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
controlName => {
/** @type {?} */
const value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error('Please provide arrControlFactory for ' + controlName);
}
/** @type {?} */
const current = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
const fc = arrControlFactory[controlName];
this.cleanArray(current);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
(v, i) => current.insert(i, fc(v))));
}
}));
}
}
/**
* @private
* @param {?} control
* @return {?}
*/
cleanArray(control) {
while (control.length !== 0) {
control.removeAt(0);
}
}
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
buildFormStoreState(formName, form) {
updateStore(name, control) {
/** @type {?} */
let value;
if (form instanceof FormControl) {
value = this.resolveFormToStore(form);
}
if (form instanceof FormGroup || form instanceof FormArray) {
// The root form group
value = Object.assign({}, this.resolveFormToStore(form), { controls: {} });
for (const key of Object.keys(form.controls)) {
/** @type {?} */
const control = form.controls[key];
if (control instanceof FormGroup || form instanceof FormArray) {
value.controls[key] = this.buildFormStoreState(formName, control);
}
else {
value.controls[key] = this.resolveFormToStore(control);
}
}
}
return value;
}
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
updateStore(formName, form) {
/** @type {?} */
const value = this.buildFormStoreState(formName, form);
const value = toStore(name, control);
this.store.update((/** @type {?} */ ({
[formName]: value,
[name]: value,
})));
return value;
}
/**
* @private
* @param {?} control
* @return {?}
*/
resolveFormToStore(control) {
return {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
}
}

@@ -748,0 +909,0 @@ NgFormsManager.decorators = [

@@ -1,7 +0,6 @@

import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { BehaviorSubject, merge } from 'rxjs';
import { BehaviorSubject, merge, Subject } from 'rxjs';
import { filter, distinctUntilChanged, map, debounceTime } from 'rxjs/operators';
import { __assign, __read, __values, __spread } from 'tslib';
import { InjectionToken, Inject, Injectable, Optional, defineInjectable, inject } from '@angular/core';
import isEqual from 'lodash.isequal';
import { __assign, __values, __spread, __read } from 'tslib';
import { FormArray, FormControl, FormGroup } from '@angular/forms';

@@ -71,3 +70,2 @@ /**

'valid',
'rawValue',
];

@@ -86,2 +84,19 @@ /**

/**
* @param {?} arr
* @param {?} cb
* @return {?}
*/
function filtrArrayKeys(arr, cb) {
return arr.reduce((/**
* @param {?} acc
* @param {?} control
* @param {?} index
* @return {?}
*/
function (acc, control, index) {
acc[index] = filterKeys(control, cb);
return acc;
}), []);
}
/**
* @param {?} obj

@@ -102,4 +117,7 @@ * @param {?} cb

if (isObject(value)) {
filtered[key] = filterKeys(obj[key], cb);
filtered[key] = filterKeys(value, cb);
}
else if (Array.isArray(value) && key === 'controls') {
filtered[key] = filtrArrayKeys(value, cb);
}
else {

@@ -241,3 +259,3 @@ filtered[key] = value;

if (providerConfig === void 0) { providerConfig = {}; }
return (/** @type {?} */ (__assign({ storage: __assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
return (/** @type {?} */ (__assign({}, defaults, { storage: __assign({}, defaults.storage, providerConfig.storage, inlineConfig.storage) }, providerConfig, inlineConfig)));
}

@@ -276,2 +294,234 @@ var NgFormsManagerConfig = /** @class */ (function () {

* @fileoverview added by tsickle
* Generated from: lib/isEqual.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// https://github.com/epoberezkin/fast-deep-equal
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function isEqual(a, b) {
if (a === b) {
return true;
}
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) {
return false;
}
/** @type {?} */
var length;
/** @type {?} */
var i;
/** @type {?} */
var keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!isEqual(a[i], b[i])) {
return false;
}
}
return true;
}
if (a.constructor === RegExp) {
return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) {
return a.valueOf() === b.valueOf();
}
if (a.toString !== Object.prototype.toString) {
return a.toString() === b.toString();
}
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) {
return false;
}
for (i = length; i-- !== 0;) {
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
return false;
}
}
for (i = length; i-- !== 0;) {
/** @type {?} */
var key = keys[i];
if (!isEqual(a[key], b[key])) {
return false;
}
}
return true;
}
// true if both NaN, false otherwise
return a !== a && b !== b;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/builders.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template FormsState
* @param {?} name
* @param {?} control
* @return {?}
*/
function toStore(name, control) {
var e_1, _a;
/** @type {?} */
var value;
if (control instanceof FormControl) {
value = buildValue(control);
return value;
}
if (control instanceof FormGroup || control instanceof FormArray) {
value = buildValue(control);
try {
for (var _b = __values(Object.keys(control.controls)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
/** @type {?} */
var current = control.controls[key];
if (current instanceof FormGroup || current instanceof FormArray) {
value.controls[key] = toStore(name, current);
}
else {
value.controls[key] = buildValue(current);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}
return value;
}
/**
* @param {?} formValue
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function handleFormArray(formValue, control, arrControlFactory) {
if (control instanceof FormArray) {
clearFormArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) {
return ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v));
}));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
function (controlName) {
/** @type {?} */
var value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error("Please provide arrControlFactory for " + controlName);
}
/** @type {?} */
var current_1 = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
var fc_1 = arrControlFactory[controlName];
clearFormArray(current_1);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) { return current_1.insert(i, fc_1(v)); }));
}
}));
}
}
/**
* @param {?} snapshot
* @param {?} controls
* @return {?}
*/
function deleteControl(snapshot, controls) {
return Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
function (acc, currentFormName) {
if (controls.includes(currentFormName) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
}
/**
* @param {?} control
* @param {?} path
* @return {?}
*/
function findControl(control, path) {
var _a = __read(path.split('.')), first = _a[0], rest = _a.slice(1);
if (rest.length === 0) {
return control.controls[first];
}
return rest.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
function (current, name) {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control.controls[first]);
}
/**
* @param {?} control
* @return {?}
*/
function buildValue(control) {
/** @type {?} */
var value = {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
if (control instanceof FormGroup || control instanceof FormArray) {
value['controls'] = control instanceof FormArray ? [] : {};
}
return value;
}
/**
* @param {?} control
* @return {?}
*/
function clearFormArray(control) {
while (control.length !== 0) {
control.removeAt(0);
}
}
/**
* @fileoverview added by tsickle
* Generated from: lib/forms-manager.ts

@@ -286,18 +536,42 @@ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc

this.config = config;
this.valueChanges = new Map();
this.instances = new Map();
this.valueChanges$$ = new Map();
this.instances$$ = new Map();
this.destroy$$ = new Subject();
this.store = new FormsStore((/** @type {?} */ ({})));
}
/**
* @param {?} formName
*
* @example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValid = /**
* @param {?} formName
NgFormsManager.prototype.validityChanges = /**
*
* \@example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -309,13 +583,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDirty = /**
* @param {?} formName
NgFormsManager.prototype.dirtyChanges = /**
*
* \@example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -327,13 +624,36 @@ * @return {?}

/**
* @param {?} formName
*
* @example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
*/
/**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectDisabled = /**
* @param {?} formName
NgFormsManager.prototype.disableChanges = /**
*
* \@example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -345,13 +665,13 @@ * @return {?}

/**
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectValue = /**
* @param {?} formName
NgFormsManager.prototype.valueChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -363,15 +683,41 @@ * @return {?}

/**
* @template T
* @param {?} formName
*
* @example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
*/
/**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectErrors = /**
* @template T
* @param {?} formName
NgFormsManager.prototype.errorsChanges = /**
*
* \@example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
* @template Errors
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
return this.selectControl(formName, path).pipe(map((/**
function (name, path) {
return this.controlChanges(name, path).pipe(map((/**
* @param {?} control

@@ -383,34 +729,31 @@ * @return {?}

/**
* If no path specified it means that it's a single FormControl or FormArray
*/
/**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.selectControl = /**
* If no path specified it means that it's a single FormControl or FormArray
* @template T
* @param {?} formName
NgFormsManager.prototype.controlChanges = /**
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
var _this = this;
if (!path) {
return (/** @type {?} */ (this.selectForm(formName)));
}
return this.store
.select((/**
function (name, path) {
/** @type {?} */
var control$ = this.store.select((/**
* @param {?} state
* @return {?}
*/
function (state) { return state[(/** @type {?} */ (formName))]; }))
.pipe(filterNil, map((/**
* @param {?} form
function (state) { return state[(/** @type {?} */ (name))]; })).pipe(filterNil);
if (!path) {
return control$.pipe(distinctUntilChanged((/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function (a, b) { return isEqual(a, b); })));
}
return control$.pipe(map((/**
* @param {?} control
* @return {?}
*/
function (form) { return _this.resolveControl(form, path); })), distinctUntilChanged((/**
function (control) { return findControl(control, path); })), distinctUntilChanged((/**
* @param {?} a

@@ -423,4 +766,43 @@ * @param {?} b

/**
* @template T
* @param {?} formName
*
* @example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
*/
/**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.controlDestroyed = /**
*
* \@example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
* @param {?} name
* @return {?}
*/
function (name) {
return this.destroy$$
.asObservable()
.pipe(filter((/**
* @param {?} controlName
* @return {?}
*/
function (controlName) { return name === controlName || controlName === '$$ALL'; })));
};
/**
* @param {?} name
* @param {?=} path

@@ -430,15 +812,14 @@ * @return {?}

NgFormsManager.prototype.getControl = /**
* @template T
* @param {?} formName
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (formName, path) {
function (name, path) {
if (!path) {
return (/** @type {?} */ (this.getForm(formName)));
return (/** @type {?} */ (this.store.getValue()[name]));
}
if (this.hasForm(formName)) {
if (this.hasControl(name)) {
/** @type {?} */
var form = this.getForm(formName);
return this.resolveControl(form, path);
var control = this.getControl(name);
return findControl(control, path);
}

@@ -448,56 +829,286 @@ return null;

/**
*
* @example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
*/
/**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
NgFormsManager.prototype.hasControl = /**
*
* \@example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
* @param {?} name
* @param {?=} path
* @return {?}
*/
function (name, path) {
return !!this.getControl(name, path);
};
/**
*
* @example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.selectForm = /**
NgFormsManager.prototype.patchValue = /**
*
* \@example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
* @template T
* @param {?} formName
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, options) {
if (options === void 0) { options = { filterNil: true }; }
return this.store
.select((/**
* @param {?} state
* @return {?}
*/
function (state) { return state[(/** @type {?} */ (formName))]; }))
.pipe(options.filterNil ? filterNil : (/**
* @param {?} s
* @return {?}
*/
function (s) { return s; }));
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).patchValue(value, options);
}
};
/**
* @template Name
* @param {?} formName
*
* @example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
*/
/**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.getForm = /**
* @template Name
* @param {?} formName
NgFormsManager.prototype.setValue = /**
*
* \@example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
* @template T
* @param {?} name
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName) {
return this.store.getValue()[(/** @type {?} */ (formName))];
function (name, value, options) {
if (this.instances$$.has(name)) {
this.instances$$.get(name).setValue(value, options);
}
};
/**
* @param {?} formName
*
* @example
*
* manager.unsubscribe('login');
*
*/
/**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.hasForm = /**
* @param {?} formName
NgFormsManager.prototype.unsubscribe = /**
*
* \@example
*
* manager.unsubscribe('login');
*
* @param {?=} name
* @return {?}
*/
function (formName) {
return !!this.getForm(formName);
function (name) {
var _this = this;
var e_1, _a;
if (name) {
/** @type {?} */
var names = coerceArray(name);
try {
for (var names_1 = __values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) {
var name_1 = names_1_1.value;
if (this.valueChanges$$.has(name_1)) {
this.valueChanges$$.get(name_1).unsubscribe();
}
this.valueChanges$$.delete(name_1);
this.instances$$.delete(name_1);
this.destroy$$.next(name_1);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (names_1_1 && !names_1_1.done && (_a = names_1.return)) _a.call(names_1);
}
finally { if (e_1) throw e_1.error; }
}
}
else {
this.valueChanges$$.forEach((/**
* @param {?} subscription
* @return {?}
*/
function (subscription) {
subscription.unsubscribe();
_this.destroy$$.next('$$ALL');
}));
this.valueChanges$$.clear();
this.instances$$.clear();
}
};
/**
*
* @example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
*/
/**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.clear = /**
*
* \@example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
name ? this.deleteControl(name) : this.store.set((/** @type {?} */ ({})));
this.removeFromStorage();
};
/**
*
* @example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
*/
/**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
*
* \@example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
* @param {?=} name
* @return {?}
*/
function (name) {
this.unsubscribe(name);
this.clear(name);
};
/**
*
* @example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
*/
/**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config

@@ -507,10 +1118,21 @@ * @return {THIS}

NgFormsManager.prototype.upsert = /**
*
* \@example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
* @template THIS
* @this {THIS}
* @param {?} formName
* @param {?} form
* @param {?} name
* @param {?} control
* @param {?=} config
* @return {THIS}
*/
function (formName, form, config) {
function (name, control, config) {
var _this = this;

@@ -521,14 +1143,14 @@ if (config === void 0) { config = {}; }

var mergedConfig = (/** @type {?} */ ((/** @type {?} */ (this)).config.merge(config)));
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasForm(formName) === false) {
if (isBrowser() && config.persistState && (/** @type {?} */ (this)).hasControl(name) === false) {
/** @type {?} */
var storageValue = (/** @type {?} */ (this)).getFromStorage(mergedConfig.storage.key);
if (storageValue[formName]) {
if (storageValue[name]) {
(/** @type {?} */ (this)).store.update((/** @type {?} */ (_a = {},
_a[formName] = mergeDeep((/** @type {?} */ (this)).buildFormStoreState(formName, form), storageValue[formName]),
_a[name] = mergeDeep(toStore(name, control), storageValue[name]),
_a)));
}
}
/** If the form already exist, patch the form with the store value */
if ((/** @type {?} */ (this)).hasForm(formName) === true) {
form.patchValue((/** @type {?} */ (this)).resolveStoreToForm(formName, form, mergedConfig.arrControlFactory), {
/** If the control already exist, patch the control with the store value */
if ((/** @type {?} */ (this)).hasControl(name) === true) {
control.patchValue((/** @type {?} */ (this)).toControlValue(name, control, mergedConfig.arrControlFactory), {
emitEvent: false,

@@ -539,7 +1161,7 @@ });

/** @type {?} */
var value = (/** @type {?} */ (this)).updateStore(formName, form);
(/** @type {?} */ (this)).updateStorage(formName, value, mergedConfig);
var value = (/** @type {?} */ (this)).updateStore(name, control);
(/** @type {?} */ (this)).updateStorage(name, value, mergedConfig);
}
/** @type {?} */
var unsubscribe = merge(form.valueChanges, form.statusChanges.pipe(distinctUntilChanged()))
var unsubscribe = merge(control.valueChanges, control.statusChanges.pipe(distinctUntilChanged()))
.pipe(debounceTime(mergedConfig.debounceTime))

@@ -551,80 +1173,15 @@ .subscribe((/**

/** @type {?} */
var value = (/** @type {?} */ (_this)).updateStore(formName, form);
(/** @type {?} */ (_this)).updateStorage(formName, value, mergedConfig);
var value = (/** @type {?} */ (_this)).updateStore(name, control);
(/** @type {?} */ (_this)).updateStorage(name, value, mergedConfig);
}));
(/** @type {?} */ (this)).valueChanges.set(formName, unsubscribe);
(/** @type {?} */ (this)).instances.set(formName, form);
(/** @type {?} */ (this)).valueChanges$$.set(name, unsubscribe);
(/** @type {?} */ (this)).instances$$.set(name, control);
return (/** @type {?} */ (this));
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @private
* @return {?}
*/
NgFormsManager.prototype.patchValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).patchValue(value, options);
}
};
/**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
NgFormsManager.prototype.setValue = /**
* @template T
* @param {?} formName
* @param {?} value
* @param {?=} options
* @return {?}
*/
function (formName, value, options) {
if (this.instances.has(formName)) {
this.instances.get(formName).setValue(value, options);
}
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.clear = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
if (formName) {
this.removeFromStore(formName);
}
else {
this.store.set((/** @type {?} */ ({})));
}
this.removeFromStorage();
};
/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.destroy = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
this.clear(formName);
this.unsubscribe(formName);
};
/**
* @return {?}
*/
NgFormsManager.prototype.removeFromStorage = /**
* @private
* @return {?}

@@ -636,39 +1193,4 @@ */

/**
* @param {?=} formName
* @return {?}
*/
NgFormsManager.prototype.unsubscribe = /**
* @param {?=} formName
* @return {?}
*/
function (formName) {
var _this = this;
/** @type {?} */
var toArray = coerceArray(formName);
if (formName) {
toArray.forEach((/**
* @param {?} name
* @return {?}
*/
function (name) {
if (_this.valueChanges.has(name)) {
_this.valueChanges.get(name).unsubscribe();
_this.valueChanges.delete(name);
}
_this.instances.delete(name);
}));
}
else {
this.valueChanges.forEach((/**
* @param {?} subscription
* @return {?}
*/
function (subscription) { return subscription.unsubscribe(); }));
this.valueChanges.clear();
this.instances.clear();
}
};
/**
* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -680,3 +1202,3 @@ * @param {?} config

* @private
* @param {?} formName
* @param {?} name
* @param {?} value

@@ -686,7 +1208,7 @@ * @param {?} config

*/
function (formName, value, config) {
function (name, value, config) {
if (isBrowser() && config.persistState) {
/** @type {?} */
var storageValue = this.getFromStorage(config.storage.key);
storageValue[formName] = filterControlKeys(value);
storageValue[name] = filterControlKeys(value);
localStorage.setItem(config.storage.key, JSON.stringify(storageValue));

@@ -710,80 +1232,23 @@ }

* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
NgFormsManager.prototype.removeFromStore = /**
NgFormsManager.prototype.deleteControl = /**
* @private
* @param {?} formName
* @param {?} name
* @return {?}
*/
function (formName) {
/** @type {?} */
var toArray = coerceArray(formName);
/** @type {?} */
var snapshot = this.store.getValue();
/** @type {?} */
var newState = Object.keys(snapshot).reduce((/**
* @param {?} acc
* @param {?} currentFormName
* @return {?}
*/
function (acc, currentFormName) {
if (toArray.includes((/** @type {?} */ (currentFormName))) === false) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}), {});
this.store.set((/** @type {?} */ (newState)));
function (name) {
this.store.set((/** @type {?} */ (deleteControl(this.store.getValue(), coerceArray(name)))));
};
/**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.resolveControl = /**
* @private
* @param {?} form
* @param {?} path
* @return {?}
*/
function (form, path) {
var _a = __read(path.split('.')), first = _a[0], rest = _a.slice(1);
if (rest.length === 0) {
return form.controls[first];
}
return this.find(form.controls[first], rest);
};
/**
* @private
* @param {?} name
* @param {?} control
* @param {?} path
* @return {?}
*/
NgFormsManager.prototype.find = /**
* @private
* @param {?} control
* @param {?} path
* @return {?}
*/
function (control, path) {
return path.reduce((/**
* @param {?} current
* @param {?} name
* @return {?}
*/
function (current, name) {
return current.controls.hasOwnProperty(name) ? current.controls[name] : null;
}), control);
};
/**
* @private
* @param {?} formName
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.resolveStoreToForm = /**
NgFormsManager.prototype.toControlValue = /**
* @private
* @param {?} formName
* @param {?} name
* @param {?} control

@@ -793,12 +1258,12 @@ * @param {?} arrControlFactory

*/
function (formName, control, arrControlFactory) {
function (name, control, arrControlFactory) {
/** @type {?} */
var form = this.getForm(formName);
var currentControl = this.getControl(name);
/** @type {?} */
var value = form.value;
/** It means it a single control */
if (!form.controls) {
var value = currentControl.value;
/** It means it's not a FormGroup or FormArray */
if (!currentControl.controls) {
return value;
}
this.handleFormArray(value, control, arrControlFactory);
handleFormArray(value, control, arrControlFactory);
return value;

@@ -808,163 +1273,21 @@ };

* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
NgFormsManager.prototype.handleFormArray = /**
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formValue
* @param {?} name
* @param {?} control
* @param {?} arrControlFactory
* @return {?}
*/
function (formValue, control, arrControlFactory) {
var _this = this;
if (control instanceof FormArray) {
this.cleanArray((/** @type {?} */ (control)));
if (!arrControlFactory) {
throw new Error('Please provide arrControlFactory');
}
formValue.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) {
return ((/** @type {?} */ (control))).insert(i, ((/** @type {?} */ (arrControlFactory)))(v));
}));
}
else {
Object.keys(formValue).forEach((/**
* @param {?} controlName
* @return {?}
*/
function (controlName) {
/** @type {?} */
var value = formValue[controlName];
if (Array.isArray(value) && control.get(controlName) instanceof FormArray) {
if (!arrControlFactory || (arrControlFactory && !(controlName in arrControlFactory))) {
throw new Error('Please provide arrControlFactory for ' + controlName);
}
/** @type {?} */
var current_1 = (/** @type {?} */ (control.get(controlName)));
/** @type {?} */
var fc_1 = arrControlFactory[controlName];
_this.cleanArray(current_1);
value.forEach((/**
* @param {?} v
* @param {?} i
* @return {?}
*/
function (v, i) { return current_1.insert(i, fc_1(v)); }));
}
}));
}
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.cleanArray = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
while (control.length !== 0) {
control.removeAt(0);
}
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.buildFormStoreState = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
var e_1, _a;
/** @type {?} */
var value;
if (form instanceof FormControl) {
value = this.resolveFormToStore(form);
}
if (form instanceof FormGroup || form instanceof FormArray) {
// The root form group
value = __assign({}, this.resolveFormToStore(form), { controls: {} });
try {
for (var _b = __values(Object.keys(form.controls)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
/** @type {?} */
var control = form.controls[key];
if (control instanceof FormGroup || form instanceof FormArray) {
value.controls[key] = this.buildFormStoreState(formName, control);
}
else {
value.controls[key] = this.resolveFormToStore(control);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}
return value;
};
/**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
NgFormsManager.prototype.updateStore = /**
* @private
* @param {?} formName
* @param {?} form
* @return {?}
*/
function (formName, form) {
function (name, control) {
var _a;
/** @type {?} */
var value = this.buildFormStoreState(formName, form);
var value = toStore(name, control);
this.store.update((/** @type {?} */ (_a = {},
_a[formName] = value,
_a[name] = value,
_a)));
return value;
};
/**
* @private
* @param {?} control
* @return {?}
*/
NgFormsManager.prototype.resolveFormToStore = /**
* @private
* @param {?} control
* @return {?}
*/
function (control) {
return {
value: clone(control.value),
// Clone object to prevent issue with third party that would be affected by store freezing.
rawValue: ((/** @type {?} */ (control))).getRawValue ? ((/** @type {?} */ (control))).getRawValue() : null,
valid: control.valid,
dirty: control.dirty,
invalid: control.invalid,
disabled: control.disabled,
errors: control.errors,
touched: control.touched,
pristine: control.pristine,
pending: control.pending,
};
};
NgFormsManager.decorators = [

@@ -971,0 +1294,0 @@ { type: Injectable, args: [{ providedIn: 'root' },] }

import { AbstractControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { _AbstractControl, AbstractGroup, ControlFactory, FormKeys, HashMap } from './types';
import { Control, ControlFactory, FormKeys, HashMap } from './types';
import { NgFormsManagerConfig } from './config';

@@ -8,49 +8,182 @@ export declare class NgFormsManager<FormsState = any> {

private readonly store;
private valueChanges;
private instances;
private valueChanges$$;
private instances$$;
private destroy$$;
constructor(config: NgFormsManagerConfig);
selectValid(formName: keyof FormsState, path?: string): Observable<boolean>;
selectDirty(formName: keyof FormsState, path?: string): Observable<boolean>;
selectDisabled(formName: keyof FormsState, path?: string): Observable<boolean>;
selectValue<T extends keyof FormsState>(formName: T, path?: string): Observable<FormsState[T]>;
selectValue<T = any>(formName: keyof FormsState, path: string): Observable<T>;
selectErrors<T = any>(formName: keyof FormsState, path?: string): Observable<T>;
/**
* If no path specified it means that it's a single FormControl or FormArray
*
* @example
*
* Whether the control is valid
*
* const valid$ = manager.validityChanges('login');
*
*/
selectControl<T = any>(formName: keyof FormsState, path?: string): Observable<_AbstractControl<T>>;
getControl<T = any>(formName: keyof FormsState, path?: string): _AbstractControl<T>;
selectForm<T extends keyof FormsState>(formName: T, options?: {
filterNil: true;
}): Observable<AbstractGroup<FormsState[T]>>;
getForm<Name extends keyof FormsState>(formName: keyof FormsState): AbstractGroup<FormsState[Name]>;
hasForm(formName: keyof FormsState): boolean;
upsert(formName: keyof FormsState, form: AbstractControl, config?: {
persistState?: boolean;
debounceTime?: number;
arrControlFactory?: ControlFactory | HashMap<ControlFactory>;
}): this;
patchValue<T extends keyof FormsState>(formName: T, value: Partial<FormsState[T]>, options?: {
validityChanges(name: keyof FormsState, path?: string): Observable<boolean>;
/**
*
* @example
*
* Whether the control is dirty
*
* const dirty$ = manager.dirtyChanges('login');
*
*/
dirtyChanges(name: keyof FormsState, path?: string): Observable<boolean>;
/**
*
* @example
*
* Whether the control is disabled
*
* const disabled$ = manager.disableChanges('login');
*
*/
disableChanges(name: keyof FormsState, path?: string): Observable<boolean>;
/**
*
* @example
*
* Observe the control's value
*
* const value$ = manager.valueChanges('login');
* const value$ = manager.valueChanges<string>('login', 'email');
*
*/
valueChanges<T = any>(name: keyof FormsState, path: string): Observable<T>;
valueChanges<T extends keyof FormsState>(name: T, path?: string): Observable<FormsState[T]>;
/**
*
* @example
*
* Observe the control's errors
*
* const errors$ = manager.errorsChanges<Errors>('login');
* const errors$ = manager.errorsChanges<Errors>('login', 'email');
*
*/
errorsChanges<Errors = any>(name: keyof FormsState, path?: string): Observable<Errors>;
/**
*
* @example
*
* Observe the control's state
*
* const control$ = manager.controlChanges('login');
* const control$ = manager.controlChanges<string>('login', 'email');
*
*/
controlChanges<State = any>(name: keyof FormsState, path: string): Observable<Control<State>>;
controlChanges<T extends keyof FormsState>(name: T, path?: string): Observable<Control<FormsState[T]>>;
/**
*
* @example
*
* Emits when the control is destroyed
*
* const control$ = manager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')))
*
*/
controlDestroyed(name: keyof FormsState): Observable<{}>;
/**
*
* @example
*
* Get the control's state
*
* const control = manager.getControl('login');
* const control = manager.getControl<string>('login', 'email');
*
*/
getControl<State = any>(name: keyof FormsState, path: string): Control<State> | null;
getControl<T extends keyof FormsState>(name: T, path?: string): Control<FormsState[T]> | null;
/**
*
* @example
*
* Whether the form exists
*
* manager.hasControl('login');
* manager.hasControl('login', 'email');
*
*/
hasControl(name: keyof FormsState, path?: string): boolean;
/**
*
* @example
*
* A proxy to the original `patchValue` method
*
* manager.patchValue('login', { email: '' });
*
*/
patchValue<T extends keyof FormsState>(name: T, value: Partial<FormsState[T]>, options?: {
onlySelf?: boolean;
emitEvent?: boolean;
}): void;
setValue<T extends keyof FormsState>(formName: keyof FormsState, value: FormsState[T], options?: {
/**
*
* @example
*
* A proxy to the original `setValue` method
*
* manager.setValue('login', { email: '', name: '' });
*
*/
setValue<T extends keyof FormsState>(name: keyof FormsState, value: FormsState[T], options?: {
onlySelf?: boolean;
emitEvent?: boolean;
}): void;
clear(formName?: FormKeys<FormsState>): void;
destroy(formName?: FormKeys<FormsState>): void;
removeFromStorage(): void;
unsubscribe(formName?: FormKeys<FormsState>): void;
/**
*
* @example
*
* manager.unsubscribe('login');
*
*/
unsubscribe(name?: FormKeys<FormsState>): void;
/**
*
* @example
*
* Removes the control from the store and from LocalStorage
*
* manager.clear('login');
*
*/
clear(name?: FormKeys<FormsState>): void;
/**
*
* @example
*
* Calls unsubscribe and clear
*
* manager.destroy('login');
*
*/
destroy(name?: FormKeys<FormsState>): void;
/**
*
* @example
*
* Register a control
*
* manager.upsert('login', this.login);
* manager.upsert('login', this.login, { persistState: true });
* manager.upsert('login', this.login, { debounceTime: 500 });
*
* manager.upsert('login', this.login, { arrControlFactory: value => new FormControl('') });
*
*/
upsert(name: keyof FormsState, control: AbstractControl, config?: {
persistState?: boolean;
debounceTime?: number;
arrControlFactory?: ControlFactory | HashMap<ControlFactory>;
}): this;
private removeFromStorage;
private updateStorage;
private getFromStorage;
private removeFromStore;
private resolveControl;
private find;
private resolveStoreToForm;
private handleFormArray;
private cleanArray;
private buildFormStoreState;
private deleteControl;
private toControlValue;
private updateStore;
private resolveFormToStore;
}
import { AbstractControl } from '@angular/forms';
export declare type _AbstractControl<T = any> = Pick<AbstractControl, 'valid' | 'invalid' | 'disabled' | 'errors' | 'touched' | 'pristine' | 'pending' | 'dirty'> & {
export declare type Control<T = any> = Pick<AbstractControl, 'valid' | 'invalid' | 'disabled' | 'errors' | 'touched' | 'pristine' | 'pending' | 'dirty'> & {
rawValue: T;
value: T;
controls?: {
readonly [P in keyof T]: Control;
};
};
export interface AbstractGroup<C = any> extends _AbstractControl<C> {
controls: {
readonly [P in keyof C]: _AbstractControl;
};
}
export declare type ControlFactory = (value: any) => AbstractControl;

@@ -12,0 +10,0 @@ export interface HashMap<T = any> {

@@ -9,4 +9,3 @@ import { Observable } from 'rxjs';

export declare function filterControlKeys(value: any): {};
export declare function filterKeys(obj: any, cb: any): {};
export declare function isBrowser(): boolean;
export declare function mergeDeep(target: any, ...sources: any[]): any;

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"NgFormsManager":{"__symbolic":"class","arity":1,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":10,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":16,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":16,"character":27},"arguments":[{"__symbolic":"reference","name":"NG_FORMS_MANAGER_CONFIG"}]}]],"parameters":[{"__symbolic":"reference","name":"NgFormsManagerConfig"}]}],"selectValid":[{"__symbolic":"method"}],"selectDirty":[{"__symbolic":"method"}],"selectDisabled":[{"__symbolic":"method"}],"selectValue":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"selectErrors":[{"__symbolic":"method"}],"selectControl":[{"__symbolic":"method"}],"getControl":[{"__symbolic":"method"}],"selectForm":[{"__symbolic":"method"}],"getForm":[{"__symbolic":"method"}],"hasForm":[{"__symbolic":"method"}],"upsert":[{"__symbolic":"method"}],"patchValue":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"removeFromStorage":[{"__symbolic":"method"}],"unsubscribe":[{"__symbolic":"method"}],"updateStorage":[{"__symbolic":"method"}],"getFromStorage":[{"__symbolic":"method"}],"removeFromStore":[{"__symbolic":"method"}],"resolveControl":[{"__symbolic":"method"}],"find":[{"__symbolic":"method"}],"resolveStoreToForm":[{"__symbolic":"method"}],"handleFormArray":[{"__symbolic":"method"}],"cleanArray":[{"__symbolic":"method"}],"buildFormStoreState":[{"__symbolic":"method"}],"updateStore":[{"__symbolic":"method"}],"resolveFormToStore":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"setAsyncValidators":{"__symbolic":"function"},"setValidators":{"__symbolic":"function"},"NgFormsManagerConfig":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":33,"character":30,"context":{"typeName":"Partial"},"module":"./lib/config"}]}],"merge":[{"__symbolic":"method"}]}},"NG_FORMS_MANAGER_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":40,"character":43},"arguments":["NG_FORMS_MANAGER_CONFIG",{"__symbolic":"error","message":"Lambda not supported","line":44,"character":13,"module":"./lib/config"}]}},"origins":{"NgFormsManager":"./lib/forms-manager","setAsyncValidators":"./lib/validators","setValidators":"./lib/validators","NgFormsManagerConfig":"./lib/config","NG_FORMS_MANAGER_CONFIG":"./lib/config"},"importAs":"@ngneat/forms-manager"}
{"__symbolic":"module","version":4,"metadata":{"NgFormsManager":{"__symbolic":"class","arity":1,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":11,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":18,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":18,"character":27},"arguments":[{"__symbolic":"reference","name":"NG_FORMS_MANAGER_CONFIG"}]}]],"parameters":[{"__symbolic":"reference","name":"NgFormsManagerConfig"}]}],"validityChanges":[{"__symbolic":"method"}],"dirtyChanges":[{"__symbolic":"method"}],"disableChanges":[{"__symbolic":"method"}],"valueChanges":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"errorsChanges":[{"__symbolic":"method"}],"controlChanges":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"controlDestroyed":[{"__symbolic":"method"}],"getControl":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"hasControl":[{"__symbolic":"method"}],"patchValue":[{"__symbolic":"method"}],"setValue":[{"__symbolic":"method"}],"unsubscribe":[{"__symbolic":"method"}],"clear":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"upsert":[{"__symbolic":"method"}],"removeFromStorage":[{"__symbolic":"method"}],"updateStorage":[{"__symbolic":"method"}],"getFromStorage":[{"__symbolic":"method"}],"deleteControl":[{"__symbolic":"method"}],"toControlValue":[{"__symbolic":"method"}],"updateStore":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"setAsyncValidators":{"__symbolic":"function"},"setValidators":{"__symbolic":"function"},"NgFormsManagerConfig":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":34,"character":30,"context":{"typeName":"Partial"},"module":"./lib/config"}]}],"merge":[{"__symbolic":"method"}]}},"NG_FORMS_MANAGER_CONFIG":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":41,"character":43},"arguments":["NG_FORMS_MANAGER_CONFIG",{"__symbolic":"error","message":"Lambda not supported","line":45,"character":13,"module":"./lib/config"}]}},"origins":{"NgFormsManager":"./lib/forms-manager","setAsyncValidators":"./lib/validators","setValidators":"./lib/validators","NgFormsManagerConfig":"./lib/config","NG_FORMS_MANAGER_CONFIG":"./lib/config"},"importAs":"@ngneat/forms-manager"}
{
"name": "@ngneat/forms-manager",
"version": "1.0.2",
"version": "2.0.0",
"description": "Forms Manager library for Angular",

@@ -25,6 +25,2 @@ "license": "MIT",

},
"dependencies": {
"lodash.isequal": "^4.5.0",
"tslib": "^1.9.0"
},
"main": "bundles/ngneat-forms-manager.umd.js",

@@ -39,3 +35,6 @@ "module": "fesm5/ngneat-forms-manager.js",

"metadata": "ngneat-forms-manager.metadata.json",
"sideEffects": false
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}

@@ -19,2 +19,3 @@ <br />

✅ Allows Typed Forms!<br>
✅ Auto persists the form's state upon user navigation.<br>

@@ -59,2 +60,5 @@ ✅ Provides an API to reactively querying any form, from anywhere. <br>

export class OnboardingComponent {
onboardingForm: FormGroup;
constructor(

@@ -88,42 +92,42 @@ private formsManager: NgFormsManager,

- `selectValid()` - Whether the control is valid
- `valueChanges()` - Observe the control's value
```ts
const isFormValid$ = formsManager.selectValid('onboarding');
const isNameValid$ = formsManager.selectValid('onboarding', 'name');
const value$ = formsManager.valueChanges('onboarding');
const nameValue$ = formsManager.valueChanges<string>('onboarding', 'name');
```
- `selectDirty()` - Whether the control is dirty
- `validityChanges()` - Whether the control is valid
```ts
const isFormDirty$ = formsManager.selectDirty('onboarding');
const isNameDirty$ = formsManager.selectDirty('onboarding', 'name');
const valid$ = formsManager.validityChanges('onboarding');
const nameValid$ = formsManager.validityChanges('onboarding', 'name');
```
- `selectDisabled()` - Whether the control is disabled
- `dirtyChanges()` - Whether the control is dirty
```ts
const isFormDisabled$ = formsManager.selectDisabled('onboarding');
const isNameDisabled$ = formsManager.selectDisabled('onboarding', 'name');
const dirty$ = formsManager.dirtyChanges('onboarding');
const nameDirty$ = formsManager.dirtyChanges('onboarding', 'name');
```
- `selectValue()` - Observe the control's value
- `disableChanges()` - Whether the control is disabled
```ts
const value$ = formsManager.selectValue('onboarding');
const nameValue$ = formsManager.selectValue<string>('onboarding', 'name');
const disabled$ = formsManager.disableChanges('onboarding');
const nameDisabled$ = formsManager.disableChanges('onboarding', 'name');
```
- `selectErrors()` - Observe the control's errors
- `errorsChanges()` - Observe the control's errors
```ts
const errors$ = formsManager.selectErrors('onboarding');
const nameErros$ = formsManager.selectErrors('onboarding', 'name');
const errors$ = formsManager.errorsChanges<Errors>('onboarding');
const nameErros$ = formsManager.errorsChanges<Errors>('onboarding', 'name');
```
- `selectControl()` - Observe the control's state
- `controlChanges()` - Observe the control's state
```ts
const control$ = formsManager.selectControl('onboarding');
const nameControl$ = formsManager.selectControl('onboarding', 'name');
const control$ = formsManager.controlChanges('onboarding');
const nameControl$ = formsManager.controlChanges<string>('onboarding', 'name');
```

@@ -135,6 +139,6 @@

const control = formsManager.getControl('onboarding');
const nameControl = formsManager.getControl('onboarding', 'name');
const nameControl = formsManager.getControl<string>('onboarding', 'name');
```
`selectControl` and `getControl` will return the following state:
`controlChanges` and `getControl` will return the following state:

@@ -156,14 +160,2 @@ ```ts

- `selectForm()` - Observe the form's state
```ts
const form$ = formsManager.selectForm('onboarding');
```
- `getForm()` - Get the form's state
```ts
const form = formsManager.getForm('onboarding');
```
- `hasForm()` - Whether the form exists

@@ -208,2 +200,8 @@

- `controlDestroyed()` - Emits when the control is destroyed
```ts
formsManager.controlChanges('login').pipe(takeUntil(controlDestroyed('login')));
```
## Persist to Local Storage

@@ -256,3 +254,3 @@

When working with a `FormArray`, it's required to pass a `factory` function that instruct how to create the `controls` inside the `FormArray`. For example:
When working with a `FormArray`, it's required to pass a `factory` function that defines how to create the `controls` inside the `FormArray`. For example:

@@ -310,3 +308,3 @@ ```ts

ngOnInit() {
this.formsManager.selectValue('onboarding').subscribe(value => {
this.formsManager.valueChanges('onboarding').subscribe(value => {
// value now typed as AppForms['onboarding']

@@ -354,2 +352,4 @@ });

<td align="center"><a href="https://www.netbasal.com"><img src="https://avatars1.githubusercontent.com/u/6745730?v=4" width="100px;" alt=""/><br /><sub><b>Netanel Basal</b></sub></a><br /><a href="https://github.com/ngneat/forms-manager/commits?author=NetanelBasal" title="Code">💻</a> <a href="https://github.com/ngneat/forms-manager/commits?author=NetanelBasal" title="Documentation">📖</a> <a href="#ideas-NetanelBasal" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/Coly010"><img src="https://avatars2.githubusercontent.com/u/12140467?v=4" width="100px;" alt=""/><br /><sub><b>Colum Ferry</b></sub></a><br /><a href="https://github.com/ngneat/forms-manager/commits?author=Coly010" title="Code">💻</a> <a href="https://github.com/ngneat/forms-manager/commits?author=Coly010" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/mehmet-erim"><img src="https://avatars0.githubusercontent.com/u/34455572?v=4" width="100px;" alt=""/><br /><sub><b>Mehmet Erim</b></sub></a><br /><a href="https://github.com/ngneat/forms-manager/commits?author=mehmet-erim" title="Documentation">📖</a></td>
</tr>

@@ -356,0 +356,0 @@ </table>

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc