UNPKG

65.8 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
3 typeof define === 'function' && define.amd ? define('@eclat/form', ['exports', '@angular/core', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
4 (global = global || self, factory((global.eclat = global.eclat || {}, global.eclat.form = {}), global.ng.core, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.common));
5}(this, function (exports, core, forms, rxjs, operators, common) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation. All rights reserved.
9 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10 this file except in compliance with the License. You may obtain a copy of the
11 License at http://www.apache.org/licenses/LICENSE-2.0
12
13 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 MERCHANTABLITY OR NON-INFRINGEMENT.
17
18 See the Apache Version 2.0 License for specific language governing permissions
19 and limitations under the License.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22
23 var extendStatics = function(d, b) {
24 extendStatics = Object.setPrototypeOf ||
25 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27 return extendStatics(d, b);
28 };
29
30 function __extends(d, b) {
31 extendStatics(d, b);
32 function __() { this.constructor = d; }
33 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34 }
35
36 function __read(o, n) {
37 var m = typeof Symbol === "function" && o[Symbol.iterator];
38 if (!m) return o;
39 var i = m.call(o), r, ar = [], e;
40 try {
41 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42 }
43 catch (error) { e = { error: error }; }
44 finally {
45 try {
46 if (r && !r.done && (m = i["return"])) m.call(i);
47 }
48 finally { if (e) throw e.error; }
49 }
50 return ar;
51 }
52
53 function __spread() {
54 for (var ar = [], i = 0; i < arguments.length; i++)
55 ar = ar.concat(__read(arguments[i]));
56 return ar;
57 }
58
59 /**
60 * @fileoverview added by tsickle
61 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
62 */
63 var EclatRecursiveConfig = /** @class */ (function () {
64 function EclatRecursiveConfig() {
65 }
66 return EclatRecursiveConfig;
67 }());
68
69 /**
70 * @fileoverview added by tsickle
71 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
72 */
73
74 /**
75 * @fileoverview added by tsickle
76 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
77 */
78
79 (function (EclatFormUtility) {
80 /**
81 * @template T
82 * @param {?} eclatForm
83 * @return {?}
84 */
85 function isEclatFormControlConfig(eclatForm) {
86 if (Array.isArray(eclatForm)) {
87 return true;
88 }
89 return false;
90 }
91 EclatFormUtility.isEclatFormControlConfig = isEclatFormControlConfig;
92 /**
93 * @template T
94 * @param {?} eclatForm
95 * @return {?}
96 */
97 function isEclatFormGroupConfig(eclatForm) {
98 if (((/** @type {?} */ (eclatForm))).controlsRules) {
99 return true;
100 }
101 return false;
102 }
103 EclatFormUtility.isEclatFormGroupConfig = isEclatFormGroupConfig;
104 /**
105 * @template T
106 * @param {?} eclatForm
107 * @return {?}
108 */
109 function isEclatFormArrayConfig(eclatForm) {
110 if (((/** @type {?} */ (eclatForm))).controlConfig) {
111 return true;
112 }
113 return false;
114 }
115 EclatFormUtility.isEclatFormArrayConfig = isEclatFormArrayConfig;
116 /**
117 * @template T
118 * @param {?} data
119 * @return {?}
120 */
121 function eclatRecursiveTransformer(data) {
122 /** @type {?} */
123 var path = recursivePathFinder(data);
124 if (!path) {
125 throw Error();
126 }
127 /** @type {?} */
128 var paths = path.split('.');
129 /** @type {?} */
130 var latestPath = (/** @type {?} */ (paths.pop()));
131 paths.reduce((/**
132 * @param {?} acc
133 * @param {?} cur
134 * @return {?}
135 */
136 function (acc, cur) {
137 return acc[cur];
138 }), (/** @type {?} */ (data)))[latestPath] = data;
139 return (/** @type {?} */ (data));
140 }
141 EclatFormUtility.eclatRecursiveTransformer = eclatRecursiveTransformer;
142 })(exports.EclatFormUtility || (exports.EclatFormUtility = {}));
143 /**
144 * @param {?} data
145 * @param {?=} path
146 * @return {?}
147 */
148 function recursivePathFinder(data, path) {
149 if (path === void 0) { path = null; }
150 if (data instanceof EclatRecursiveConfig) {
151 return '';
152 }
153 if (Array.isArray(data)) {
154 /** @type {?} */
155 var found_1 = null;
156 data.some((/**
157 * @param {?} value
158 * @param {?} key
159 * @return {?}
160 */
161 function (value, key) {
162 /** @type {?} */
163 var temp = recursivePathFinder(value, path);
164 if (temp !== null) {
165 if (temp) {
166 found_1 = key + '.' + temp;
167 }
168 else {
169 found_1 = key.toString();
170 }
171 }
172 return !!found_1;
173 }));
174 return found_1;
175 }
176 if (data === Object(data)) {
177 /** @type {?} */
178 var found_2 = null;
179 Object.entries(data).some((/**
180 * @param {?} __0
181 * @return {?}
182 */
183 function (_a) {
184 var _b = __read(_a, 2), key = _b[0], value = _b[1];
185 /** @type {?} */
186 var temp = recursivePathFinder(value, path);
187 if (temp !== null) {
188 if (temp) {
189 found_2 = key + '.' + temp;
190 }
191 else {
192 found_2 = key;
193 }
194 }
195 return !!found_2;
196 }));
197 return found_2;
198 }
199 return null;
200 }
201
202 /**
203 * @fileoverview added by tsickle
204 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
205 */
206 /**
207 * @abstract
208 * @template T, C
209 */
210 var /**
211 * @abstract
212 * @template T, C
213 */
214 AbstractEclatFormControl = /** @class */ (function () {
215 function AbstractEclatFormControl(rules) {
216 /** @type {?} */
217 var validators = [];
218 /** @type {?} */
219 var asyncValidators = [];
220 /** @type {?} */
221 var errorMapping = {};
222 if (rules) {
223 rules.forEach((/**
224 * @param {?} __0
225 * @return {?}
226 */
227 function (_a) {
228 var validator = _a.validator, asyncValidator = _a.asyncValidator, key = _a.key, message = _a.message;
229 errorMapping[key] = message;
230 if (validator) {
231 validators.push(validator);
232 }
233 if (asyncValidator) {
234 asyncValidators.push(asyncValidator);
235 }
236 }));
237 }
238 this.rules = errorMapping;
239 this.validators = validators;
240 this.asyncValidators = asyncValidators;
241 }
242 Object.defineProperty(AbstractEclatFormControl.prototype, "errorMessages", {
243 get: /**
244 * @return {?}
245 */
246 function () {
247 var _this = this;
248 if (!this.control.errors) {
249 return [];
250 }
251 return Object.entries(this.control.errors).reduce((/**
252 * @param {?} acc
253 * @param {?} __1
254 * @return {?}
255 */
256 function (acc, _a) {
257 var _b = __read(_a, 2), key = _b[0], value = _b[1];
258 if (value) {
259 /** @type {?} */
260 var temp = _this.rules[key];
261 /** @type {?} */
262 var errors = typeof temp === 'function' ? temp(_this) : temp;
263 if (Array.isArray(errors)) {
264 acc.push.apply(acc, __spread(errors));
265 }
266 else {
267 acc.push(errors);
268 }
269 }
270 return acc;
271 }), (/** @type {?} */ ([])));
272 },
273 enumerable: true,
274 configurable: true
275 });
276 Object.defineProperty(AbstractEclatFormControl.prototype, "value", {
277 get: /**
278 * @return {?}
279 */
280 function () {
281 return this.control.value;
282 },
283 enumerable: true,
284 configurable: true
285 });
286 Object.defineProperty(AbstractEclatFormControl.prototype, "valid", {
287 get: /**
288 * @return {?}
289 */
290 function () {
291 return this.control.valid;
292 },
293 enumerable: true,
294 configurable: true
295 });
296 Object.defineProperty(AbstractEclatFormControl.prototype, "valueChanges", {
297 get: /**
298 * @return {?}
299 */
300 function () {
301 return this.control.valueChanges;
302 },
303 enumerable: true,
304 configurable: true
305 });
306 /**
307 * @param {?=} isDisabled
308 * @param {?=} opts
309 * @return {?}
310 */
311 AbstractEclatFormControl.prototype.disable = /**
312 * @param {?=} isDisabled
313 * @param {?=} opts
314 * @return {?}
315 */
316 function (isDisabled, opts) {
317 if (isDisabled === void 0) { isDisabled = true; }
318 if (isDisabled) {
319 this.control.disable(opts);
320 }
321 else {
322 this.control.enable(opts);
323 }
324 };
325 return AbstractEclatFormControl;
326 }());
327
328 /**
329 * @fileoverview added by tsickle
330 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
331 */
332 /**
333 * @param {?} config
334 * @param {?=} data
335 * @return {?}
336 */
337 function getEclatControl(config, data) {
338 if (exports.EclatFormUtility.isEclatFormControlConfig(config)) {
339 return new EclatFormControl(config, data);
340 }
341 if (exports.EclatFormUtility.isEclatFormGroupConfig(config)) {
342 return new EclatFormGroup(config, data);
343 }
344 if (exports.EclatFormUtility.isEclatFormArrayConfig(config)) {
345 return new EclatFormArray(config, data);
346 }
347 return null;
348 }
349 /**
350 * @template T
351 */
352 var /**
353 * @template T
354 */
355 EclatFormControl = /** @class */ (function (_super) {
356 __extends(EclatFormControl, _super);
357 function EclatFormControl(config, initialData) {
358 var _this = _super.call(this, config) || this;
359 _this.control = new forms.FormControl(null, _this.validators, _this.asyncValidators);
360 if (initialData) {
361 _this.resetState(initialData);
362 }
363 return _this;
364 }
365 /**
366 * @param {?} data
367 * @param {?=} emitEvent
368 * @return {?}
369 */
370 EclatFormControl.prototype.patchState = /**
371 * @param {?} data
372 * @param {?=} emitEvent
373 * @return {?}
374 */
375 function (data, emitEvent) {
376 if (emitEvent === void 0) { emitEvent = true; }
377 this.control.patchValue(data, { emitEvent: emitEvent });
378 };
379 /**
380 * @param {?} data
381 * @param {?=} emitEvent
382 * @return {?}
383 */
384 EclatFormControl.prototype.resetState = /**
385 * @param {?} data
386 * @param {?=} emitEvent
387 * @return {?}
388 */
389 function (data, emitEvent) {
390 if (emitEvent === void 0) { emitEvent = true; }
391 this.control.reset(data, { emitEvent: emitEvent });
392 };
393 return EclatFormControl;
394 }(AbstractEclatFormControl));
395 /**
396 * @template T
397 */
398 var /**
399 * @template T
400 */
401 EclatFormGroup = /** @class */ (function (_super) {
402 __extends(EclatFormGroup, _super);
403 function EclatFormGroup(dfg, initialData) {
404 var _this = _super.call(this, dfg.rules) || this;
405 /** @type {?} */
406 var children = {};
407 /** @type {?} */
408 var controls = {};
409 Object.keys(dfg.controlsRules).forEach((/**
410 * @param {?} key
411 * @return {?}
412 */
413 function (key) {
414 /** @type {?} */
415 var value = dfg.controlsRules[(/** @type {?} */ (key))];
416 /** @type {?} */
417 var eclatControl = getEclatControl(value);
418 if (eclatControl) {
419 children[key] = eclatControl;
420 controls[key] = eclatControl.control;
421 }
422 }));
423 _this.control = new forms.FormGroup(controls, _this.validators, _this.asyncValidators);
424 _this.children = children;
425 if (initialData) {
426 _this.resetState(initialData);
427 }
428 return _this;
429 }
430 /**
431 * @param {?} data
432 * @param {?=} emitEvent
433 * @return {?}
434 */
435 EclatFormGroup.prototype.patchState = /**
436 * @param {?} data
437 * @param {?=} emitEvent
438 * @return {?}
439 */
440 function (data, emitEvent) {
441 var _this = this;
442 if (emitEvent === void 0) { emitEvent = true; }
443 if (!data) {
444 console.warn("Expect an object, but " + data + " is given");
445 return;
446 }
447 Object.entries(data).forEach((/**
448 * @param {?} __0
449 * @return {?}
450 */
451 function (_a) {
452 var _b = __read(_a, 2), key = _b[0], value = _b[1];
453 if (_this.children[(/** @type {?} */ (key))]) {
454 _this.children[(/** @type {?} */ (key))].patchState(value, false);
455 }
456 }));
457 this.control.patchValue({}, { emitEvent: emitEvent });
458 };
459 /**
460 * @param {?} data
461 * @param {?=} emitEvent
462 * @return {?}
463 */
464 EclatFormGroup.prototype.resetState = /**
465 * @param {?} data
466 * @param {?=} emitEvent
467 * @return {?}
468 */
469 function (data, emitEvent) {
470 var _this = this;
471 if (emitEvent === void 0) { emitEvent = true; }
472 if (!data) {
473 console.warn("Expect an object, but " + data + " is given");
474 return;
475 }
476 Object.entries(data).forEach((/**
477 * @param {?} __0
478 * @return {?}
479 */
480 function (_a) {
481 var _b = __read(_a, 2), key = _b[0], value = _b[1];
482 if (_this.children[(/** @type {?} */ (key))]) {
483 _this.children[(/** @type {?} */ (key))].resetState(value, false);
484 }
485 }));
486 this.control.reset(undefined, { emitEvent: emitEvent });
487 };
488 /**
489 * @template P
490 * @param {?} key
491 * @return {?}
492 */
493 EclatFormGroup.prototype.getChild = /**
494 * @template P
495 * @param {?} key
496 * @return {?}
497 */
498 function (key) {
499 return this.children[key];
500 };
501 /**
502 * @private
503 * @param {?} key
504 * @param {?} config
505 * @param {?} data
506 * @return {?}
507 */
508 EclatFormGroup.prototype.addChild = /**
509 * @private
510 * @param {?} key
511 * @param {?} config
512 * @param {?} data
513 * @return {?}
514 */
515 function (key, config, data) {
516 /** @type {?} */
517 var eclatControl = getEclatControl(config);
518 if (eclatControl) {
519 eclatControl.resetState(data);
520 this.children[key] = (/** @type {?} */ (eclatControl));
521 this.control.addControl(key, this.children[key].control);
522 }
523 };
524 /**
525 * @private
526 * @param {?} key
527 * @return {?}
528 */
529 EclatFormGroup.prototype.removeChild = /**
530 * @private
531 * @param {?} key
532 * @return {?}
533 */
534 function (key) {
535 delete this.children[key];
536 this.control.removeControl(key);
537 };
538 return EclatFormGroup;
539 }(AbstractEclatFormControl));
540 /**
541 * @template T
542 */
543 var /**
544 * @template T
545 */
546 EclatFormArray = /** @class */ (function (_super) {
547 __extends(EclatFormArray, _super);
548 function EclatFormArray(dfa, initialData) {
549 var _this = _super.call(this, dfa.rules) || this;
550 _this.control = new forms.FormArray([], _this.validators, _this.asyncValidators);
551 _this.childConfig = dfa.controlConfig;
552 _this.children = [];
553 if (initialData) {
554 _this.resetState(initialData);
555 }
556 return _this;
557 }
558 /**
559 * @param {?=} data
560 * @return {?}
561 */
562 EclatFormArray.prototype.addChild = /**
563 * @param {?=} data
564 * @return {?}
565 */
566 function (data) {
567 /** @type {?} */
568 var eclatControl = getEclatControl(this.childConfig);
569 if (eclatControl) {
570 eclatControl.resetState(data);
571 this.children.push((/** @type {?} */ (eclatControl)));
572 this.control.push(eclatControl.control);
573 }
574 };
575 /**
576 * @param {?} index
577 * @return {?}
578 */
579 EclatFormArray.prototype.removeChild = /**
580 * @param {?} index
581 * @return {?}
582 */
583 function (index) {
584 this.children.splice(index, 1);
585 this.control.removeAt(index);
586 };
587 /**
588 * @param {?} data
589 * @param {?=} emitEvent
590 * @return {?}
591 */
592 EclatFormArray.prototype.patchState = /**
593 * @param {?} data
594 * @param {?=} emitEvent
595 * @return {?}
596 */
597 function (data, emitEvent) {
598 var _this = this;
599 if (emitEvent === void 0) { emitEvent = true; }
600 if (!data) {
601 console.warn("Expect an array, but " + data + " is given");
602 return;
603 }
604 this.control.controls = [];
605 this.children = [];
606 data.forEach((/**
607 * @param {?} d
608 * @return {?}
609 */
610 function (d) {
611 /** @type {?} */
612 var eclatControl = getEclatControl(_this.childConfig);
613 if (eclatControl) {
614 eclatControl.patchState(d, false);
615 _this.children.push((/** @type {?} */ (eclatControl)));
616 _this.control.push(eclatControl.control);
617 }
618 }));
619 this.control.patchValue([], { emitEvent: emitEvent });
620 };
621 /**
622 * @param {?} data
623 * @param {?=} emitEvent
624 * @return {?}
625 */
626 EclatFormArray.prototype.resetState = /**
627 * @param {?} data
628 * @param {?=} emitEvent
629 * @return {?}
630 */
631 function (data, emitEvent) {
632 var _this = this;
633 if (emitEvent === void 0) { emitEvent = true; }
634 if (!data) {
635 console.warn("Expect an array, but " + data + " is given");
636 return;
637 }
638 this.control.controls = [];
639 this.children = [];
640 data.forEach((/**
641 * @param {?} d
642 * @return {?}
643 */
644 function (d) {
645 /** @type {?} */
646 var eclatControl = getEclatControl(_this.childConfig);
647 if (eclatControl) {
648 eclatControl.resetState(d, false);
649 _this.children.push((/** @type {?} */ (eclatControl)));
650 _this.control.push(eclatControl.control);
651 }
652 }));
653 this.control.reset(undefined, { emitEvent: emitEvent });
654 };
655 /**
656 * @param {?} index
657 * @return {?}
658 */
659 EclatFormArray.prototype.getChild = /**
660 * @param {?} index
661 * @return {?}
662 */
663 function (index) {
664 return this.children[index];
665 };
666 return EclatFormArray;
667 }(AbstractEclatFormControl));
668
669 /**
670 * @fileoverview added by tsickle
671 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
672 */
673 /**
674 * @template T
675 */
676 var /**
677 * @template T
678 */
679 EclatFormContext = /** @class */ (function () {
680 function EclatFormContext($implicit) {
681 this.$implicit = $implicit;
682 }
683 return EclatFormContext;
684 }());
685 /**
686 * @template T
687 */
688 var EclatFormOfDirective = /** @class */ (function () {
689 function EclatFormOfDirective(templateRef, viewContainer) {
690 this.templateRef = templateRef;
691 this.viewContainer = viewContainer;
692 }
693 Object.defineProperty(EclatFormOfDirective.prototype, "eclatFormOf", {
694 set: /**
695 * @param {?} state
696 * @return {?}
697 */
698 function (state) {
699 if (!this.context || !this.latestState || this.latestState.config !== state.config) {
700 this.setContext(getEclatControl(state.config, state.data));
701 }
702 else if (this.latestState.data !== state.data) {
703 this.context.$implicit.resetState(state.data);
704 }
705 this.latestState = state;
706 },
707 enumerable: true,
708 configurable: true
709 });
710 /**
711 * @private
712 * @param {?=} control
713 * @return {?}
714 */
715 EclatFormOfDirective.prototype.setContext = /**
716 * @private
717 * @param {?=} control
718 * @return {?}
719 */
720 function (control) {
721 if (!control) {
722 throw new Error('control not found');
723 }
724 if (!this.context) {
725 this.context = new EclatFormContext(control);
726 this.viewContainer.createEmbeddedView(this.templateRef, this.context);
727 }
728 else {
729 this.context.$implicit = control;
730 }
731 };
732 EclatFormOfDirective.decorators = [
733 { type: core.Directive, args: [{ selector: '[eclatForm][eclatFormOf]' },] }
734 ];
735 /** @nocollapse */
736 EclatFormOfDirective.ctorParameters = function () { return [
737 { type: core.TemplateRef },
738 { type: core.ViewContainerRef }
739 ]; };
740 EclatFormOfDirective.propDecorators = {
741 eclatFormOf: [{ type: core.Input }]
742 };
743 return EclatFormOfDirective;
744 }());
745
746 /**
747 * @fileoverview added by tsickle
748 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
749 */
750 /**
751 * @abstract
752 * @template T
753 */
754 var EclatFormContainerDirective = /** @class */ (function () {
755 function EclatFormContainerDirective() {
756 this._formControl = new rxjs.BehaviorSubject(undefined);
757 this.onSubmit = new core.EventEmitter();
758 }
759 Object.defineProperty(EclatFormContainerDirective.prototype, "formControl", {
760 get: /**
761 * @return {?}
762 */
763 function () {
764 return this._formControl.getValue();
765 },
766 enumerable: true,
767 configurable: true
768 });
769 Object.defineProperty(EclatFormContainerDirective.prototype, "formControl$", {
770 get: /**
771 * @return {?}
772 */
773 function () {
774 return this._formControl.asObservable();
775 },
776 enumerable: true,
777 configurable: true
778 });
779 /**
780 * @return {?}
781 */
782 EclatFormContainerDirective.prototype.submit = /**
783 * @return {?}
784 */
785 function () {
786 if (this.formControl) {
787 this.onSubmit.emit(this.formControl.value);
788 }
789 };
790 EclatFormContainerDirective.propDecorators = {
791 onSubmit: [{ type: core.Output }]
792 };
793 return EclatFormContainerDirective;
794 }());
795
796 /**
797 * @fileoverview added by tsickle
798 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
799 */
800 /**
801 * @template T
802 */
803 var /**
804 * @template T
805 */
806 EclatFormErrorContext = /** @class */ (function () {
807 function EclatFormErrorContext(control) {
808 this.control = control;
809 }
810 Object.defineProperty(EclatFormErrorContext.prototype, "$implicit", {
811 get: /**
812 * @return {?}
813 */
814 function () {
815 return this.control.errorMessages;
816 },
817 enumerable: true,
818 configurable: true
819 });
820 return EclatFormErrorContext;
821 }());
822 /**
823 * @template T
824 */
825 var EclatFormErrorDirective = /** @class */ (function () {
826 function EclatFormErrorDirective(templateRef, viewContainer, parent) {
827 this.templateRef = templateRef;
828 this.viewContainer = viewContainer;
829 this.parent = parent;
830 this.onDestroy$ = new rxjs.Subject();
831 this.errorMatcher = (/**
832 * @return {?}
833 */
834 function () { return true; });
835 }
836 Object.defineProperty(EclatFormErrorDirective.prototype, "eclatControl", {
837 set: /**
838 * @param {?} control
839 * @return {?}
840 */
841 function (control) {
842 this.setContext(control);
843 },
844 enumerable: true,
845 configurable: true
846 });
847 Object.defineProperty(EclatFormErrorDirective.prototype, "eclatControlName", {
848 set: /**
849 * @param {?} controlName
850 * @return {?}
851 */
852 function (controlName) {
853 if (!this.parent.formControl) {
854 throw new Error('parent formControl not exist');
855 }
856 /** @type {?} */
857 var instance = !controlName ? this.parent.formControl : this.parent.formControl.getChild(controlName);
858 if (!instance) {
859 throw new Error('control not found');
860 return;
861 }
862 this.latestControlName = controlName;
863 this.setContext(instance);
864 },
865 enumerable: true,
866 configurable: true
867 });
868 Object.defineProperty(EclatFormErrorDirective.prototype, "eclatFormError", {
869 set: /**
870 * @param {?} control
871 * @return {?}
872 */
873 function (control) {
874 if (control instanceof AbstractEclatFormControl) {
875 this.setContext(control);
876 }
877 else {
878 this.eclatControlName = control;
879 }
880 },
881 enumerable: true,
882 configurable: true
883 });
884 /**
885 * @return {?}
886 */
887 EclatFormErrorDirective.prototype.ngOnInit = /**
888 * @return {?}
889 */
890 function () {
891 var _this = this;
892 this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
893 * @param {?} formControl
894 * @return {?}
895 */
896 function (formControl) {
897 if (formControl && _this.latestControlName) {
898 _this.eclatFormError = formControl.getChild(_this.latestControlName);
899 }
900 }));
901 };
902 /**
903 * @return {?}
904 */
905 EclatFormErrorDirective.prototype.ngOnDestroy = /**
906 * @return {?}
907 */
908 function () {
909 this.onDestroy$.next();
910 };
911 /**
912 * @private
913 * @param {?} control
914 * @return {?}
915 */
916 EclatFormErrorDirective.prototype.setContext = /**
917 * @private
918 * @param {?} control
919 * @return {?}
920 */
921 function (control) {
922 var _this = this;
923 if (!this.context) {
924 this.context = new EclatFormErrorContext(control);
925 this.viewContainer.createEmbeddedView(this.templateRef, this.context);
926 }
927 else if (this.context.control !== control) {
928 this.context.control = control;
929 }
930 if (this.valueChangesSub) {
931 this.valueChangesSub.unsubscribe();
932 }
933 this.checkValidity(control);
934 this.valueChangesSub = control.valueChanges.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
935 * @return {?}
936 */
937 function () {
938 _this.checkValidity(control);
939 }));
940 };
941 /**
942 * @private
943 * @param {?} control
944 * @return {?}
945 */
946 EclatFormErrorDirective.prototype.checkValidity = /**
947 * @private
948 * @param {?} control
949 * @return {?}
950 */
951 function (control) {
952 /** @type {?} */
953 var isAttached = !!this.viewContainer.length;
954 if (!control.valid && this.errorMatcher(control)) {
955 if (!isAttached) {
956 this.viewContainer.createEmbeddedView(this.templateRef, this.context);
957 }
958 }
959 else {
960 if (isAttached) {
961 this.viewContainer.remove();
962 }
963 }
964 };
965 EclatFormErrorDirective.decorators = [
966 { type: core.Directive, args: [{ selector: '[eclatFormError]' },] }
967 ];
968 /** @nocollapse */
969 EclatFormErrorDirective.ctorParameters = function () { return [
970 { type: core.TemplateRef },
971 { type: core.ViewContainerRef },
972 { type: EclatFormContainerDirective }
973 ]; };
974 EclatFormErrorDirective.propDecorators = {
975 errorMatcher: [{ type: core.Input }],
976 eclatControl: [{ type: core.Input }],
977 eclatControlName: [{ type: core.Input }],
978 eclatFormError: [{ type: core.Input }]
979 };
980 return EclatFormErrorDirective;
981 }());
982
983 /**
984 * @fileoverview added by tsickle
985 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
986 */
987 /**
988 * @template T
989 */
990 var EclatFormGroupDirective = /** @class */ (function (_super) {
991 __extends(EclatFormGroupDirective, _super);
992 function EclatFormGroupDirective() {
993 return _super.call(this) || this;
994 }
995 Object.defineProperty(EclatFormGroupDirective.prototype, "eclatFormGroup", {
996 set: /**
997 * @param {?} formGroup
998 * @return {?}
999 */
1000 function (formGroup) {
1001 this._formControl.next(formGroup);
1002 },
1003 enumerable: true,
1004 configurable: true
1005 });
1006 /**
1007 * @param {?} key
1008 * @return {?}
1009 */
1010 EclatFormGroupDirective.prototype.getChild = /**
1011 * @param {?} key
1012 * @return {?}
1013 */
1014 function (key) {
1015 if (this.formControl) {
1016 return this.formControl.getChild(key);
1017 }
1018 return undefined;
1019 };
1020 EclatFormGroupDirective.decorators = [
1021 { type: core.Directive, args: [{
1022 selector: '[eclatFormGroup]',
1023 providers: [{
1024 provide: EclatFormContainerDirective,
1025 useExisting: core.forwardRef((/**
1026 * @return {?}
1027 */
1028 function () { return EclatFormGroupDirective; })),
1029 }],
1030 },] }
1031 ];
1032 /** @nocollapse */
1033 EclatFormGroupDirective.ctorParameters = function () { return []; };
1034 EclatFormGroupDirective.propDecorators = {
1035 eclatFormGroup: [{ type: core.Input }]
1036 };
1037 return EclatFormGroupDirective;
1038 }(EclatFormContainerDirective));
1039
1040 /**
1041 * @fileoverview added by tsickle
1042 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1043 */
1044 /**
1045 * @template T
1046 */
1047 var EclatFormGroupNameDirective = /** @class */ (function (_super) {
1048 __extends(EclatFormGroupNameDirective, _super);
1049 function EclatFormGroupNameDirective(parent) {
1050 var _this = _super.call(this) || this;
1051 _this.parent = parent;
1052 _this.onDestroy$ = new rxjs.Subject();
1053 return _this;
1054 }
1055 Object.defineProperty(EclatFormGroupNameDirective.prototype, "eclatFormGroupName", {
1056 set: /**
1057 * @param {?} name
1058 * @return {?}
1059 */
1060 function (name) {
1061 this.latestName = name;
1062 this._formControl.next((/** @type {?} */ (this.parent.getChild(name))));
1063 },
1064 enumerable: true,
1065 configurable: true
1066 });
1067 /**
1068 * @return {?}
1069 */
1070 EclatFormGroupNameDirective.prototype.ngOnDestroy = /**
1071 * @return {?}
1072 */
1073 function () {
1074 this.onDestroy$.next();
1075 };
1076 /**
1077 * @return {?}
1078 */
1079 EclatFormGroupNameDirective.prototype.ngOnInit = /**
1080 * @return {?}
1081 */
1082 function () {
1083 var _this = this;
1084 this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
1085 * @return {?}
1086 */
1087 function () {
1088 _this.eclatFormGroupName = _this.latestName;
1089 }));
1090 };
1091 /**
1092 * @param {?} key
1093 * @return {?}
1094 */
1095 EclatFormGroupNameDirective.prototype.getChild = /**
1096 * @param {?} key
1097 * @return {?}
1098 */
1099 function (key) {
1100 if (this.formControl) {
1101 return this.formControl.getChild(key);
1102 }
1103 return undefined;
1104 };
1105 EclatFormGroupNameDirective.decorators = [
1106 { type: core.Directive, args: [{
1107 selector: '[eclatFormGroupName]',
1108 providers: [{
1109 provide: EclatFormContainerDirective,
1110 useExisting: core.forwardRef((/**
1111 * @return {?}
1112 */
1113 function () { return EclatFormGroupNameDirective; })),
1114 }],
1115 },] }
1116 ];
1117 /** @nocollapse */
1118 EclatFormGroupNameDirective.ctorParameters = function () { return [
1119 { type: EclatFormContainerDirective, decorators: [{ type: core.SkipSelf }] }
1120 ]; };
1121 EclatFormGroupNameDirective.propDecorators = {
1122 eclatFormGroupName: [{ type: core.Input }]
1123 };
1124 return EclatFormGroupNameDirective;
1125 }(EclatFormContainerDirective));
1126
1127 /**
1128 * @fileoverview added by tsickle
1129 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1130 */
1131 /**
1132 * @template T
1133 */
1134 var EclatFormArrayNameDirective = /** @class */ (function (_super) {
1135 __extends(EclatFormArrayNameDirective, _super);
1136 function EclatFormArrayNameDirective(parent) {
1137 var _this = _super.call(this) || this;
1138 _this.parent = parent;
1139 _this.onDestroy$ = new rxjs.Subject();
1140 return _this;
1141 }
1142 Object.defineProperty(EclatFormArrayNameDirective.prototype, "eclatFormArrayName", {
1143 set: /**
1144 * @param {?} name
1145 * @return {?}
1146 */
1147 function (name) {
1148 this.latestName = name;
1149 this._formControl.next((/** @type {?} */ (this.parent.getChild(name))));
1150 },
1151 enumerable: true,
1152 configurable: true
1153 });
1154 /**
1155 * @return {?}
1156 */
1157 EclatFormArrayNameDirective.prototype.ngOnDestroy = /**
1158 * @return {?}
1159 */
1160 function () {
1161 this.onDestroy$.next();
1162 };
1163 /**
1164 * @return {?}
1165 */
1166 EclatFormArrayNameDirective.prototype.ngOnInit = /**
1167 * @return {?}
1168 */
1169 function () {
1170 var _this = this;
1171 this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
1172 * @return {?}
1173 */
1174 function () {
1175 _this.eclatFormArrayName = _this.latestName;
1176 }));
1177 };
1178 /**
1179 * @param {?} key
1180 * @return {?}
1181 */
1182 EclatFormArrayNameDirective.prototype.getChild = /**
1183 * @param {?} key
1184 * @return {?}
1185 */
1186 function (key) {
1187 if (this.formControl) {
1188 return this.formControl.getChild(key);
1189 }
1190 return undefined;
1191 };
1192 EclatFormArrayNameDirective.decorators = [
1193 { type: core.Directive, args: [{
1194 selector: '[eclatFormArrayName]',
1195 providers: [{
1196 provide: EclatFormContainerDirective,
1197 useExisting: core.forwardRef((/**
1198 * @return {?}
1199 */
1200 function () { return EclatFormArrayNameDirective; })),
1201 }],
1202 },] }
1203 ];
1204 /** @nocollapse */
1205 EclatFormArrayNameDirective.ctorParameters = function () { return [
1206 { type: EclatFormContainerDirective, decorators: [{ type: core.SkipSelf }] }
1207 ]; };
1208 EclatFormArrayNameDirective.propDecorators = {
1209 eclatFormArrayName: [{ type: core.Input }]
1210 };
1211 return EclatFormArrayNameDirective;
1212 }(EclatFormContainerDirective));
1213
1214 /**
1215 * @fileoverview added by tsickle
1216 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1217 */
1218 /**
1219 * @template T
1220 */
1221 var EclatFormArrayDirective = /** @class */ (function (_super) {
1222 __extends(EclatFormArrayDirective, _super);
1223 function EclatFormArrayDirective() {
1224 return _super.call(this) || this;
1225 }
1226 Object.defineProperty(EclatFormArrayDirective.prototype, "eclatFormArray", {
1227 set: /**
1228 * @param {?} formArray
1229 * @return {?}
1230 */
1231 function (formArray) {
1232 this._formControl.next(formArray);
1233 },
1234 enumerable: true,
1235 configurable: true
1236 });
1237 /**
1238 * @param {?} key
1239 * @return {?}
1240 */
1241 EclatFormArrayDirective.prototype.getChild = /**
1242 * @param {?} key
1243 * @return {?}
1244 */
1245 function (key) {
1246 if (this.formControl) {
1247 return this.formControl.getChild(key);
1248 }
1249 return undefined;
1250 };
1251 EclatFormArrayDirective.decorators = [
1252 { type: core.Directive, args: [{
1253 selector: '[eclatFormArray]',
1254 providers: [{
1255 provide: EclatFormContainerDirective,
1256 useExisting: core.forwardRef((/**
1257 * @return {?}
1258 */
1259 function () { return EclatFormArrayDirective; })),
1260 }],
1261 },] }
1262 ];
1263 /** @nocollapse */
1264 EclatFormArrayDirective.ctorParameters = function () { return []; };
1265 EclatFormArrayDirective.propDecorators = {
1266 eclatFormArray: [{ type: core.Input }]
1267 };
1268 return EclatFormArrayDirective;
1269 }(EclatFormContainerDirective));
1270
1271 /**
1272 * @fileoverview added by tsickle
1273 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1274 */
1275 /**
1276 * @template T
1277 */
1278 var EclatFormArrayChildrenDirective = /** @class */ (function () {
1279 function EclatFormArrayChildrenDirective(templateRef, viewContainer, parent) {
1280 this.templateRef = templateRef;
1281 this.viewContainer = viewContainer;
1282 this.parent = parent;
1283 this.onDestroy$ = new rxjs.Subject();
1284 this.latestChildren = [];
1285 }
1286 /**
1287 * @return {?}
1288 */
1289 EclatFormArrayChildrenDirective.prototype.ngOnDestroy = /**
1290 * @return {?}
1291 */
1292 function () {
1293 this.onDestroy$.next();
1294 };
1295 /**
1296 * @return {?}
1297 */
1298 EclatFormArrayChildrenDirective.prototype.ngOnInit = /**
1299 * @return {?}
1300 */
1301 function () {
1302 var _this = this;
1303 this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
1304 * @param {?} formControl
1305 * @return {?}
1306 */
1307 function (formControl) {
1308 if (formControl) {
1309 if (_this.valueChangeSubs) {
1310 _this.valueChangeSubs.unsubscribe();
1311 }
1312 _this.onChange(formControl);
1313 _this.valueChangeSubs = formControl.valueChanges.pipe(operators.takeUntil(_this.onDestroy$)).subscribe((/**
1314 * @return {?}
1315 */
1316 function () {
1317 _this.onChange(formControl);
1318 }));
1319 }
1320 }));
1321 };
1322 /**
1323 * @private
1324 * @param {?} control
1325 * @return {?}
1326 */
1327 EclatFormArrayChildrenDirective.prototype.onChange = /**
1328 * @private
1329 * @param {?} control
1330 * @return {?}
1331 */
1332 function (control) {
1333 var _this = this;
1334 /** @type {?} */
1335 var children = [];
1336 /** @type {?} */
1337 var controlChildrenLength = control.children.length;
1338 control.children.forEach((/**
1339 * @param {?} c
1340 * @param {?} index
1341 * @return {?}
1342 */
1343 function (c, index) {
1344 /** @type {?} */
1345 var lastIndex = _this.latestChildren.findIndex((/**
1346 * @param {?} o
1347 * @return {?}
1348 */
1349 function (o) { return o === c; }));
1350 /** @type {?} */
1351 var first = index === 0;
1352 /** @type {?} */
1353 var last = index === (controlChildrenLength - 1);
1354 if (lastIndex < 0) {
1355 _this.viewContainer.createEmbeddedView(_this.templateRef, { $implicit: index, last: last, first: first }, index);
1356 }
1357 else if (lastIndex !== index) {
1358 /** @type {?} */
1359 var embeddedView = (/** @type {?} */ ((/** @type {?} */ (_this.viewContainer.get(lastIndex)))));
1360 embeddedView.context.$implicit = index;
1361 embeddedView.context.last = last;
1362 embeddedView.context.first = first;
1363 _this.viewContainer.move(embeddedView, index);
1364 }
1365 children.push(c);
1366 }));
1367 while (this.viewContainer.length > controlChildrenLength) {
1368 this.viewContainer.remove();
1369 }
1370 this.latestChildren = children;
1371 };
1372 EclatFormArrayChildrenDirective.decorators = [
1373 { type: core.Directive, args: [{
1374 selector: '[eclatFormArrayChildren]',
1375 },] }
1376 ];
1377 /** @nocollapse */
1378 EclatFormArrayChildrenDirective.ctorParameters = function () { return [
1379 { type: core.TemplateRef },
1380 { type: core.ViewContainerRef },
1381 { type: EclatFormContainerDirective }
1382 ]; };
1383 return EclatFormArrayChildrenDirective;
1384 }());
1385
1386 /**
1387 * @fileoverview added by tsickle
1388 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1389 */
1390 var EclatFormSubmitDirective = /** @class */ (function () {
1391 function EclatFormSubmitDirective(parent) {
1392 this.parent = parent;
1393 }
1394 /**
1395 * @return {?}
1396 */
1397 EclatFormSubmitDirective.prototype.onClick = /**
1398 * @return {?}
1399 */
1400 function () {
1401 this.parent.submit();
1402 };
1403 EclatFormSubmitDirective.decorators = [
1404 { type: core.Directive, args: [{ selector: '[eclatFormSubmit]' },] }
1405 ];
1406 /** @nocollapse */
1407 EclatFormSubmitDirective.ctorParameters = function () { return [
1408 { type: EclatFormContainerDirective }
1409 ]; };
1410 EclatFormSubmitDirective.propDecorators = {
1411 onClick: [{ type: core.HostListener, args: ['click', ['$event'],] }, { type: core.HostListener, args: ['tap', ['$event'],] }]
1412 };
1413 return EclatFormSubmitDirective;
1414 }());
1415
1416 /**
1417 * @fileoverview added by tsickle
1418 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1419 */
1420 /**
1421 * @template T
1422 */
1423 var EclatFormArrayAddDirective = /** @class */ (function () {
1424 function EclatFormArrayAddDirective(parent) {
1425 this.parent = parent;
1426 }
1427 /**
1428 * @return {?}
1429 */
1430 EclatFormArrayAddDirective.prototype.onClick = /**
1431 * @return {?}
1432 */
1433 function () {
1434 /** @type {?} */
1435 var control = this.parent.formControl;
1436 if (control) {
1437 control.addChild(this.value);
1438 }
1439 };
1440 EclatFormArrayAddDirective.decorators = [
1441 { type: core.Directive, args: [{
1442 selector: '[eclatFormAddChildren]',
1443 },] }
1444 ];
1445 /** @nocollapse */
1446 EclatFormArrayAddDirective.ctorParameters = function () { return [
1447 { type: EclatFormContainerDirective }
1448 ]; };
1449 EclatFormArrayAddDirective.propDecorators = {
1450 value: [{ type: core.Input, args: ['eclatFormAddChildren',] }],
1451 onClick: [{ type: core.HostListener, args: ['click', ['$event'],] }]
1452 };
1453 return EclatFormArrayAddDirective;
1454 }());
1455
1456 /**
1457 * @fileoverview added by tsickle
1458 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1459 */
1460 /**
1461 * @template T
1462 */
1463 var /**
1464 * @template T
1465 */
1466 EclatFormValueContext = /** @class */ (function () {
1467 function EclatFormValueContext(control) {
1468 this.control = control;
1469 }
1470 Object.defineProperty(EclatFormValueContext.prototype, "$implicit", {
1471 get: /**
1472 * @return {?}
1473 */
1474 function () {
1475 return this.control.value;
1476 },
1477 enumerable: true,
1478 configurable: true
1479 });
1480 return EclatFormValueContext;
1481 }());
1482 /**
1483 * @template T
1484 */
1485 var EclatFormValueDirective = /** @class */ (function () {
1486 function EclatFormValueDirective(templateRef, viewContainer, parent) {
1487 this.templateRef = templateRef;
1488 this.viewContainer = viewContainer;
1489 this.parent = parent;
1490 this.onDestroy$ = new rxjs.Subject();
1491 }
1492 Object.defineProperty(EclatFormValueDirective.prototype, "eclatControl", {
1493 set: /**
1494 * @param {?} control
1495 * @return {?}
1496 */
1497 function (control) {
1498 this.setContext(control);
1499 },
1500 enumerable: true,
1501 configurable: true
1502 });
1503 Object.defineProperty(EclatFormValueDirective.prototype, "eclatControlName", {
1504 set: /**
1505 * @param {?} controlName
1506 * @return {?}
1507 */
1508 function (controlName) {
1509 if (!this.parent.formControl) {
1510 throw new Error('parent formControl not exist');
1511 }
1512 /** @type {?} */
1513 var instance = this.parent.formControl.getChild(controlName);
1514 if (!instance) {
1515 throw new Error('control not found');
1516 return;
1517 }
1518 this.latestControlName = controlName;
1519 this.setContext(instance);
1520 },
1521 enumerable: true,
1522 configurable: true
1523 });
1524 Object.defineProperty(EclatFormValueDirective.prototype, "eclatFormValue", {
1525 set: /**
1526 * @param {?} control
1527 * @return {?}
1528 */
1529 function (control) {
1530 if (control instanceof AbstractEclatFormControl) {
1531 this.setContext(control);
1532 }
1533 else if (control || control === 0) {
1534 this.eclatControlName = control;
1535 }
1536 },
1537 enumerable: true,
1538 configurable: true
1539 });
1540 /**
1541 * @return {?}
1542 */
1543 EclatFormValueDirective.prototype.ngOnInit = /**
1544 * @return {?}
1545 */
1546 function () {
1547 var _this = this;
1548 this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe((/**
1549 * @param {?} formControl
1550 * @return {?}
1551 */
1552 function (formControl) {
1553 if (formControl && _this.latestControlName) {
1554 _this.eclatFormValue = formControl.getChild(_this.latestControlName);
1555 }
1556 }));
1557 };
1558 /**
1559 * @return {?}
1560 */
1561 EclatFormValueDirective.prototype.ngOnDestroy = /**
1562 * @return {?}
1563 */
1564 function () {
1565 this.onDestroy$.next();
1566 };
1567 /**
1568 * @private
1569 * @param {?} control
1570 * @return {?}
1571 */
1572 EclatFormValueDirective.prototype.setContext = /**
1573 * @private
1574 * @param {?} control
1575 * @return {?}
1576 */
1577 function (control) {
1578 if (!this.context) {
1579 this.context = new EclatFormValueContext(control);
1580 this.viewContainer.createEmbeddedView(this.templateRef, this.context);
1581 }
1582 else if (this.context.control !== control) {
1583 this.context.control = control;
1584 }
1585 };
1586 EclatFormValueDirective.decorators = [
1587 { type: core.Directive, args: [{ selector: '[eclatFormValue]' },] }
1588 ];
1589 /** @nocollapse */
1590 EclatFormValueDirective.ctorParameters = function () { return [
1591 { type: core.TemplateRef },
1592 { type: core.ViewContainerRef },
1593 { type: EclatFormContainerDirective }
1594 ]; };
1595 EclatFormValueDirective.propDecorators = {
1596 eclatControl: [{ type: core.Input }],
1597 eclatControlName: [{ type: core.Input }],
1598 eclatFormValue: [{ type: core.Input }]
1599 };
1600 return EclatFormValueDirective;
1601 }());
1602
1603 /**
1604 * @fileoverview added by tsickle
1605 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1606 */
1607 /**
1608 * @template T
1609 */
1610 var EclatFormGroupBinderDirective = /** @class */ (function (_super) {
1611 __extends(EclatFormGroupBinderDirective, _super);
1612 function EclatFormGroupBinderDirective() {
1613 return _super !== null && _super.apply(this, arguments) || this;
1614 }
1615 Object.defineProperty(EclatFormGroupBinderDirective.prototype, "eclatFormGroup", {
1616 set: /**
1617 * @param {?} formGroup
1618 * @return {?}
1619 */
1620 function (formGroup) {
1621 this.form = formGroup.control;
1622 },
1623 enumerable: true,
1624 configurable: true
1625 });
1626 /**
1627 * @param {?} changes
1628 * @return {?}
1629 */
1630 EclatFormGroupBinderDirective.prototype.ngOnChanges = /**
1631 * @param {?} changes
1632 * @return {?}
1633 */
1634 function (changes) {
1635 /** @type {?} */
1636 var eclatFormGroupChanges = changes.eclatFormGroup;
1637 if (eclatFormGroupChanges) {
1638 /** @type {?} */
1639 var prevValue = eclatFormGroupChanges.previousValue ? eclatFormGroupChanges.previousValue.control : undefined;
1640 /** @type {?} */
1641 var currentValue = eclatFormGroupChanges.currentValue.control;
1642 /** @type {?} */
1643 var firstChange = eclatFormGroupChanges.firstChange;
1644 _super.prototype.ngOnChanges.call(this, { form: new core.SimpleChange(prevValue, currentValue, firstChange) });
1645 }
1646 };
1647 EclatFormGroupBinderDirective.decorators = [
1648 { type: core.Directive, args: [{
1649 selector: '[eclatFormGroup]',
1650 providers: [{
1651 provide: forms.ControlContainer,
1652 useExisting: core.forwardRef((/**
1653 * @return {?}
1654 */
1655 function () { return EclatFormGroupBinderDirective; })),
1656 }],
1657 },] }
1658 ];
1659 EclatFormGroupBinderDirective.propDecorators = {
1660 eclatFormGroup: [{ type: core.Input }]
1661 };
1662 return EclatFormGroupBinderDirective;
1663 }(forms.FormGroupDirective));
1664
1665 /**
1666 * @fileoverview added by tsickle
1667 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1668 */
1669 /**
1670 * @template T
1671 */
1672 var EclatFormGroupNameBinderDirective = /** @class */ (function (_super) {
1673 __extends(EclatFormGroupNameBinderDirective, _super);
1674 function EclatFormGroupNameBinderDirective() {
1675 return _super !== null && _super.apply(this, arguments) || this;
1676 }
1677 Object.defineProperty(EclatFormGroupNameBinderDirective.prototype, "eclatFormGroupName", {
1678 set: /**
1679 * @param {?} name
1680 * @return {?}
1681 */
1682 function (name) {
1683 this.name = name;
1684 },
1685 enumerable: true,
1686 configurable: true
1687 });
1688 EclatFormGroupNameBinderDirective.decorators = [
1689 { type: core.Directive, args: [{
1690 selector: '[eclatFormGroupName]',
1691 providers: [{
1692 provide: forms.ControlContainer,
1693 useExisting: core.forwardRef((/**
1694 * @return {?}
1695 */
1696 function () { return EclatFormGroupNameBinderDirective; })),
1697 }],
1698 },] }
1699 ];
1700 EclatFormGroupNameBinderDirective.propDecorators = {
1701 eclatFormGroupName: [{ type: core.Input }]
1702 };
1703 return EclatFormGroupNameBinderDirective;
1704 }(forms.FormGroupName));
1705
1706 /**
1707 * @fileoverview added by tsickle
1708 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1709 */
1710 /**
1711 * @template T
1712 */
1713 var EclatFormArrayNameBinderDirective = /** @class */ (function (_super) {
1714 __extends(EclatFormArrayNameBinderDirective, _super);
1715 function EclatFormArrayNameBinderDirective() {
1716 return _super !== null && _super.apply(this, arguments) || this;
1717 }
1718 Object.defineProperty(EclatFormArrayNameBinderDirective.prototype, "eclatFormArrayName", {
1719 set: /**
1720 * @param {?} name
1721 * @return {?}
1722 */
1723 function (name) {
1724 this.name = name;
1725 },
1726 enumerable: true,
1727 configurable: true
1728 });
1729 EclatFormArrayNameBinderDirective.decorators = [
1730 { type: core.Directive, args: [{
1731 selector: '[eclatFormArrayName]',
1732 providers: [{
1733 provide: forms.ControlContainer,
1734 useExisting: core.forwardRef((/**
1735 * @return {?}
1736 */
1737 function () { return EclatFormArrayNameBinderDirective; })),
1738 }],
1739 },] }
1740 ];
1741 EclatFormArrayNameBinderDirective.propDecorators = {
1742 eclatFormArrayName: [{ type: core.Input }]
1743 };
1744 return EclatFormArrayNameBinderDirective;
1745 }(forms.FormArrayName));
1746
1747 /**
1748 * @fileoverview added by tsickle
1749 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1750 */
1751 /**
1752 * @template T
1753 */
1754 var EclatFormArrayRemoveDirective = /** @class */ (function () {
1755 function EclatFormArrayRemoveDirective(parent) {
1756 this.parent = parent;
1757 }
1758 /**
1759 * @return {?}
1760 */
1761 EclatFormArrayRemoveDirective.prototype.onClick = /**
1762 * @return {?}
1763 */
1764 function () {
1765 /** @type {?} */
1766 var control = this.parent.formControl;
1767 if (control) {
1768 control.removeChild(this.index);
1769 }
1770 };
1771 EclatFormArrayRemoveDirective.decorators = [
1772 { type: core.Directive, args: [{
1773 selector: '[eclatFormRemoveChildren]',
1774 },] }
1775 ];
1776 /** @nocollapse */
1777 EclatFormArrayRemoveDirective.ctorParameters = function () { return [
1778 { type: EclatFormContainerDirective }
1779 ]; };
1780 EclatFormArrayRemoveDirective.propDecorators = {
1781 index: [{ type: core.Input, args: ['eclatFormRemoveChildren',] }],
1782 onClick: [{ type: core.HostListener, args: ['click', ['$event'],] }]
1783 };
1784 return EclatFormArrayRemoveDirective;
1785 }());
1786
1787 /**
1788 * @fileoverview added by tsickle
1789 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1790 */
1791 var EclatFormModule = /** @class */ (function () {
1792 function EclatFormModule() {
1793 }
1794 EclatFormModule.decorators = [
1795 { type: core.NgModule, args: [{
1796 imports: [common.CommonModule, forms.ReactiveFormsModule],
1797 declarations: [EclatFormOfDirective, EclatFormErrorDirective, EclatFormGroupDirective, EclatFormGroupNameDirective, EclatFormArrayDirective, EclatFormArrayNameDirective, EclatFormArrayChildrenDirective, EclatFormSubmitDirective, EclatFormArrayAddDirective, EclatFormValueDirective, EclatFormGroupBinderDirective, EclatFormGroupNameBinderDirective, EclatFormArrayNameBinderDirective, EclatFormArrayRemoveDirective],
1798 exports: [common.CommonModule, forms.ReactiveFormsModule, EclatFormOfDirective, EclatFormErrorDirective, EclatFormGroupDirective, EclatFormGroupNameDirective, EclatFormArrayDirective, EclatFormArrayNameDirective, EclatFormArrayChildrenDirective, EclatFormSubmitDirective, EclatFormArrayAddDirective, EclatFormValueDirective, EclatFormGroupBinderDirective, EclatFormGroupNameBinderDirective, EclatFormArrayNameBinderDirective, EclatFormArrayRemoveDirective],
1799 },] }
1800 ];
1801 return EclatFormModule;
1802 }());
1803
1804 exports.AbstractEclatFormControl = AbstractEclatFormControl;
1805 exports.EclatFormArray = EclatFormArray;
1806 exports.EclatFormContext = EclatFormContext;
1807 exports.EclatFormControl = EclatFormControl;
1808 exports.EclatFormErrorDirective = EclatFormErrorDirective;
1809 exports.EclatFormGroup = EclatFormGroup;
1810 exports.EclatFormGroupDirective = EclatFormGroupDirective;
1811 exports.EclatFormModule = EclatFormModule;
1812 exports.EclatFormOfDirective = EclatFormOfDirective;
1813 exports.EclatRecursiveConfig = EclatRecursiveConfig;
1814 exports.getEclatControl = getEclatControl;
1815 exports.ɵa = EclatFormContainerDirective;
1816 exports.ɵb = EclatFormGroupNameDirective;
1817 exports.ɵc = EclatFormArrayDirective;
1818 exports.ɵd = EclatFormArrayNameDirective;
1819 exports.ɵe = EclatFormArrayChildrenDirective;
1820 exports.ɵf = EclatFormSubmitDirective;
1821 exports.ɵg = EclatFormArrayAddDirective;
1822 exports.ɵh = EclatFormValueDirective;
1823 exports.ɵi = EclatFormGroupBinderDirective;
1824 exports.ɵj = EclatFormGroupNameBinderDirective;
1825 exports.ɵk = EclatFormArrayNameBinderDirective;
1826 exports.ɵl = EclatFormArrayRemoveDirective;
1827
1828 Object.defineProperty(exports, '__esModule', { value: true });
1829
1830}));
1831//# sourceMappingURL=eclat-form.umd.js.map