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 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
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 |
|
61 |
|
62 |
|
63 | var EclatRecursiveConfig = (function () {
|
64 | function EclatRecursiveConfig() {
|
65 | }
|
66 | return EclatRecursiveConfig;
|
67 | }());
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 | (function (EclatFormUtility) {
|
80 | |
81 |
|
82 |
|
83 |
|
84 |
|
85 | function isEclatFormControlConfig(eclatForm) {
|
86 | if (Array.isArray(eclatForm)) {
|
87 | return true;
|
88 | }
|
89 | return false;
|
90 | }
|
91 | EclatFormUtility.isEclatFormControlConfig = isEclatFormControlConfig;
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | function isEclatFormGroupConfig(eclatForm) {
|
98 | if ((( (eclatForm))).controlsRules) {
|
99 | return true;
|
100 | }
|
101 | return false;
|
102 | }
|
103 | EclatFormUtility.isEclatFormGroupConfig = isEclatFormGroupConfig;
|
104 | |
105 |
|
106 |
|
107 |
|
108 |
|
109 | function isEclatFormArrayConfig(eclatForm) {
|
110 | if ((( (eclatForm))).controlConfig) {
|
111 | return true;
|
112 | }
|
113 | return false;
|
114 | }
|
115 | EclatFormUtility.isEclatFormArrayConfig = isEclatFormArrayConfig;
|
116 | |
117 |
|
118 |
|
119 |
|
120 |
|
121 | function eclatRecursiveTransformer(data) {
|
122 |
|
123 | var path = recursivePathFinder(data);
|
124 | if (!path) {
|
125 | throw Error();
|
126 | }
|
127 |
|
128 | var paths = path.split('.');
|
129 |
|
130 | var latestPath = ( (paths.pop()));
|
131 | paths.reduce(( |
132 |
|
133 |
|
134 |
|
135 |
|
136 | function (acc, cur) {
|
137 | return acc[cur];
|
138 | }), ( (data)))[latestPath] = data;
|
139 | return ( (data));
|
140 | }
|
141 | EclatFormUtility.eclatRecursiveTransformer = eclatRecursiveTransformer;
|
142 | })(exports.EclatFormUtility || (exports.EclatFormUtility = {}));
|
143 | |
144 |
|
145 |
|
146 |
|
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 |
|
155 | var found_1 = null;
|
156 | data.some(( |
157 |
|
158 |
|
159 |
|
160 |
|
161 | function (value, key) {
|
162 |
|
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 |
|
178 | var found_2 = null;
|
179 | Object.entries(data).some(( |
180 |
|
181 |
|
182 |
|
183 | function (_a) {
|
184 | var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
185 |
|
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 |
|
204 |
|
205 |
|
206 | |
207 |
|
208 |
|
209 |
|
210 | var |
211 |
|
212 |
|
213 |
|
214 | AbstractEclatFormControl = (function () {
|
215 | function AbstractEclatFormControl(rules) {
|
216 |
|
217 | var validators = [];
|
218 |
|
219 | var asyncValidators = [];
|
220 |
|
221 | var errorMapping = {};
|
222 | if (rules) {
|
223 | rules.forEach(( |
224 |
|
225 |
|
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 |
|
253 |
|
254 |
|
255 |
|
256 | function (acc, _a) {
|
257 | var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
258 | if (value) {
|
259 |
|
260 | var temp = _this.rules[key];
|
261 |
|
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 | }), ( ([])));
|
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 |
|
308 |
|
309 |
|
310 |
|
311 | AbstractEclatFormControl.prototype.disable = |
312 |
|
313 |
|
314 |
|
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 |
|
330 |
|
331 |
|
332 | |
333 |
|
334 |
|
335 |
|
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 |
|
351 |
|
352 | var |
353 |
|
354 |
|
355 | EclatFormControl = (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 |
|
367 |
|
368 |
|
369 |
|
370 | EclatFormControl.prototype.patchState = |
371 |
|
372 |
|
373 |
|
374 |
|
375 | function (data, emitEvent) {
|
376 | if (emitEvent === void 0) { emitEvent = true; }
|
377 | this.control.patchValue(data, { emitEvent: emitEvent });
|
378 | };
|
379 | |
380 |
|
381 |
|
382 |
|
383 |
|
384 | EclatFormControl.prototype.resetState = |
385 |
|
386 |
|
387 |
|
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 |
|
397 |
|
398 | var |
399 |
|
400 |
|
401 | EclatFormGroup = (function (_super) {
|
402 | __extends(EclatFormGroup, _super);
|
403 | function EclatFormGroup(dfg, initialData) {
|
404 | var _this = _super.call(this, dfg.rules) || this;
|
405 |
|
406 | var children = {};
|
407 |
|
408 | var controls = {};
|
409 | Object.keys(dfg.controlsRules).forEach(( |
410 |
|
411 |
|
412 |
|
413 | function (key) {
|
414 |
|
415 | var value = dfg.controlsRules[( (key))];
|
416 |
|
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 |
|
432 |
|
433 |
|
434 |
|
435 | EclatFormGroup.prototype.patchState = |
436 |
|
437 |
|
438 |
|
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 |
|
449 |
|
450 |
|
451 | function (_a) {
|
452 | var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
453 | if (_this.children[( (key))]) {
|
454 | _this.children[( (key))].patchState(value, false);
|
455 | }
|
456 | }));
|
457 | this.control.patchValue({}, { emitEvent: emitEvent });
|
458 | };
|
459 | |
460 |
|
461 |
|
462 |
|
463 |
|
464 | EclatFormGroup.prototype.resetState = |
465 |
|
466 |
|
467 |
|
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 |
|
478 |
|
479 |
|
480 | function (_a) {
|
481 | var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
482 | if (_this.children[( (key))]) {
|
483 | _this.children[( (key))].resetState(value, false);
|
484 | }
|
485 | }));
|
486 | this.control.reset(undefined, { emitEvent: emitEvent });
|
487 | };
|
488 | |
489 |
|
490 |
|
491 |
|
492 |
|
493 | EclatFormGroup.prototype.getChild = |
494 |
|
495 |
|
496 |
|
497 |
|
498 | function (key) {
|
499 | return this.children[key];
|
500 | };
|
501 | |
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 | EclatFormGroup.prototype.addChild = |
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 | function (key, config, data) {
|
516 |
|
517 | var eclatControl = getEclatControl(config);
|
518 | if (eclatControl) {
|
519 | eclatControl.resetState(data);
|
520 | this.children[key] = ( (eclatControl));
|
521 | this.control.addControl(key, this.children[key].control);
|
522 | }
|
523 | };
|
524 | |
525 |
|
526 |
|
527 |
|
528 |
|
529 | EclatFormGroup.prototype.removeChild = |
530 |
|
531 |
|
532 |
|
533 |
|
534 | function (key) {
|
535 | delete this.children[key];
|
536 | this.control.removeControl(key);
|
537 | };
|
538 | return EclatFormGroup;
|
539 | }(AbstractEclatFormControl));
|
540 | |
541 |
|
542 |
|
543 | var |
544 |
|
545 |
|
546 | EclatFormArray = (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 |
|
560 |
|
561 |
|
562 | EclatFormArray.prototype.addChild = |
563 |
|
564 |
|
565 |
|
566 | function (data) {
|
567 |
|
568 | var eclatControl = getEclatControl(this.childConfig);
|
569 | if (eclatControl) {
|
570 | eclatControl.resetState(data);
|
571 | this.children.push(( (eclatControl)));
|
572 | this.control.push(eclatControl.control);
|
573 | }
|
574 | };
|
575 | |
576 |
|
577 |
|
578 |
|
579 | EclatFormArray.prototype.removeChild = |
580 |
|
581 |
|
582 |
|
583 | function (index) {
|
584 | this.children.splice(index, 1);
|
585 | this.control.removeAt(index);
|
586 | };
|
587 | |
588 |
|
589 |
|
590 |
|
591 |
|
592 | EclatFormArray.prototype.patchState = |
593 |
|
594 |
|
595 |
|
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 |
|
608 |
|
609 |
|
610 | function (d) {
|
611 |
|
612 | var eclatControl = getEclatControl(_this.childConfig);
|
613 | if (eclatControl) {
|
614 | eclatControl.patchState(d, false);
|
615 | _this.children.push(( (eclatControl)));
|
616 | _this.control.push(eclatControl.control);
|
617 | }
|
618 | }));
|
619 | this.control.patchValue([], { emitEvent: emitEvent });
|
620 | };
|
621 | |
622 |
|
623 |
|
624 |
|
625 |
|
626 | EclatFormArray.prototype.resetState = |
627 |
|
628 |
|
629 |
|
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 |
|
642 |
|
643 |
|
644 | function (d) {
|
645 |
|
646 | var eclatControl = getEclatControl(_this.childConfig);
|
647 | if (eclatControl) {
|
648 | eclatControl.resetState(d, false);
|
649 | _this.children.push(( (eclatControl)));
|
650 | _this.control.push(eclatControl.control);
|
651 | }
|
652 | }));
|
653 | this.control.reset(undefined, { emitEvent: emitEvent });
|
654 | };
|
655 | |
656 |
|
657 |
|
658 |
|
659 | EclatFormArray.prototype.getChild = |
660 |
|
661 |
|
662 |
|
663 | function (index) {
|
664 | return this.children[index];
|
665 | };
|
666 | return EclatFormArray;
|
667 | }(AbstractEclatFormControl));
|
668 |
|
669 | |
670 |
|
671 |
|
672 |
|
673 | |
674 |
|
675 |
|
676 | var |
677 |
|
678 |
|
679 | EclatFormContext = (function () {
|
680 | function EclatFormContext($implicit) {
|
681 | this.$implicit = $implicit;
|
682 | }
|
683 | return EclatFormContext;
|
684 | }());
|
685 | |
686 |
|
687 |
|
688 | var EclatFormOfDirective = (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 |
|
712 |
|
713 |
|
714 |
|
715 | EclatFormOfDirective.prototype.setContext = |
716 |
|
717 |
|
718 |
|
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 |
|
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 |
|
748 |
|
749 |
|
750 | |
751 |
|
752 |
|
753 |
|
754 | var EclatFormContainerDirective = (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 |
|
781 |
|
782 | EclatFormContainerDirective.prototype.submit = |
783 |
|
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 |
|
798 |
|
799 |
|
800 | |
801 |
|
802 |
|
803 | var |
804 |
|
805 |
|
806 | EclatFormErrorContext = (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 |
|
824 |
|
825 | var EclatFormErrorDirective = (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 |
|
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 |
|
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 |
|
886 |
|
887 | EclatFormErrorDirective.prototype.ngOnInit = |
888 |
|
889 |
|
890 | function () {
|
891 | var _this = this;
|
892 | this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe(( |
893 |
|
894 |
|
895 |
|
896 | function (formControl) {
|
897 | if (formControl && _this.latestControlName) {
|
898 | _this.eclatFormError = formControl.getChild(_this.latestControlName);
|
899 | }
|
900 | }));
|
901 | };
|
902 | |
903 |
|
904 |
|
905 | EclatFormErrorDirective.prototype.ngOnDestroy = |
906 |
|
907 |
|
908 | function () {
|
909 | this.onDestroy$.next();
|
910 | };
|
911 | |
912 |
|
913 |
|
914 |
|
915 |
|
916 | EclatFormErrorDirective.prototype.setContext = |
917 |
|
918 |
|
919 |
|
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 |
|
936 |
|
937 | function () {
|
938 | _this.checkValidity(control);
|
939 | }));
|
940 | };
|
941 | |
942 |
|
943 |
|
944 |
|
945 |
|
946 | EclatFormErrorDirective.prototype.checkValidity = |
947 |
|
948 |
|
949 |
|
950 |
|
951 | function (control) {
|
952 |
|
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 |
|
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 |
|
985 |
|
986 |
|
987 | |
988 |
|
989 |
|
990 | var EclatFormGroupDirective = (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 |
|
1008 |
|
1009 |
|
1010 | EclatFormGroupDirective.prototype.getChild = |
1011 |
|
1012 |
|
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 |
|
1027 |
|
1028 | function () { return EclatFormGroupDirective; })),
|
1029 | }],
|
1030 | },] }
|
1031 | ];
|
1032 |
|
1033 | EclatFormGroupDirective.ctorParameters = function () { return []; };
|
1034 | EclatFormGroupDirective.propDecorators = {
|
1035 | eclatFormGroup: [{ type: core.Input }]
|
1036 | };
|
1037 | return EclatFormGroupDirective;
|
1038 | }(EclatFormContainerDirective));
|
1039 |
|
1040 | |
1041 |
|
1042 |
|
1043 |
|
1044 | |
1045 |
|
1046 |
|
1047 | var EclatFormGroupNameDirective = (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(( (this.parent.getChild(name))));
|
1063 | },
|
1064 | enumerable: true,
|
1065 | configurable: true
|
1066 | });
|
1067 | |
1068 |
|
1069 |
|
1070 | EclatFormGroupNameDirective.prototype.ngOnDestroy = |
1071 |
|
1072 |
|
1073 | function () {
|
1074 | this.onDestroy$.next();
|
1075 | };
|
1076 | |
1077 |
|
1078 |
|
1079 | EclatFormGroupNameDirective.prototype.ngOnInit = |
1080 |
|
1081 |
|
1082 | function () {
|
1083 | var _this = this;
|
1084 | this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe(( |
1085 |
|
1086 |
|
1087 | function () {
|
1088 | _this.eclatFormGroupName = _this.latestName;
|
1089 | }));
|
1090 | };
|
1091 | |
1092 |
|
1093 |
|
1094 |
|
1095 | EclatFormGroupNameDirective.prototype.getChild = |
1096 |
|
1097 |
|
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 |
|
1112 |
|
1113 | function () { return EclatFormGroupNameDirective; })),
|
1114 | }],
|
1115 | },] }
|
1116 | ];
|
1117 |
|
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 |
|
1129 |
|
1130 |
|
1131 | |
1132 |
|
1133 |
|
1134 | var EclatFormArrayNameDirective = (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(( (this.parent.getChild(name))));
|
1150 | },
|
1151 | enumerable: true,
|
1152 | configurable: true
|
1153 | });
|
1154 | |
1155 |
|
1156 |
|
1157 | EclatFormArrayNameDirective.prototype.ngOnDestroy = |
1158 |
|
1159 |
|
1160 | function () {
|
1161 | this.onDestroy$.next();
|
1162 | };
|
1163 | |
1164 |
|
1165 |
|
1166 | EclatFormArrayNameDirective.prototype.ngOnInit = |
1167 |
|
1168 |
|
1169 | function () {
|
1170 | var _this = this;
|
1171 | this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe(( |
1172 |
|
1173 |
|
1174 | function () {
|
1175 | _this.eclatFormArrayName = _this.latestName;
|
1176 | }));
|
1177 | };
|
1178 | |
1179 |
|
1180 |
|
1181 |
|
1182 | EclatFormArrayNameDirective.prototype.getChild = |
1183 |
|
1184 |
|
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 |
|
1199 |
|
1200 | function () { return EclatFormArrayNameDirective; })),
|
1201 | }],
|
1202 | },] }
|
1203 | ];
|
1204 |
|
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 |
|
1216 |
|
1217 |
|
1218 | |
1219 |
|
1220 |
|
1221 | var EclatFormArrayDirective = (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 |
|
1239 |
|
1240 |
|
1241 | EclatFormArrayDirective.prototype.getChild = |
1242 |
|
1243 |
|
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 |
|
1258 |
|
1259 | function () { return EclatFormArrayDirective; })),
|
1260 | }],
|
1261 | },] }
|
1262 | ];
|
1263 |
|
1264 | EclatFormArrayDirective.ctorParameters = function () { return []; };
|
1265 | EclatFormArrayDirective.propDecorators = {
|
1266 | eclatFormArray: [{ type: core.Input }]
|
1267 | };
|
1268 | return EclatFormArrayDirective;
|
1269 | }(EclatFormContainerDirective));
|
1270 |
|
1271 | |
1272 |
|
1273 |
|
1274 |
|
1275 | |
1276 |
|
1277 |
|
1278 | var EclatFormArrayChildrenDirective = (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 |
|
1288 |
|
1289 | EclatFormArrayChildrenDirective.prototype.ngOnDestroy = |
1290 |
|
1291 |
|
1292 | function () {
|
1293 | this.onDestroy$.next();
|
1294 | };
|
1295 | |
1296 |
|
1297 |
|
1298 | EclatFormArrayChildrenDirective.prototype.ngOnInit = |
1299 |
|
1300 |
|
1301 | function () {
|
1302 | var _this = this;
|
1303 | this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe(( |
1304 |
|
1305 |
|
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 |
|
1315 |
|
1316 | function () {
|
1317 | _this.onChange(formControl);
|
1318 | }));
|
1319 | }
|
1320 | }));
|
1321 | };
|
1322 | |
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 | EclatFormArrayChildrenDirective.prototype.onChange = |
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 | function (control) {
|
1333 | var _this = this;
|
1334 |
|
1335 | var children = [];
|
1336 |
|
1337 | var controlChildrenLength = control.children.length;
|
1338 | control.children.forEach(( |
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 | function (c, index) {
|
1344 |
|
1345 | var lastIndex = _this.latestChildren.findIndex(( |
1346 |
|
1347 |
|
1348 |
|
1349 | function (o) { return o === c; }));
|
1350 |
|
1351 | var first = index === 0;
|
1352 |
|
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 |
|
1359 | var embeddedView = ( (( (_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 |
|
1378 | EclatFormArrayChildrenDirective.ctorParameters = function () { return [
|
1379 | { type: core.TemplateRef },
|
1380 | { type: core.ViewContainerRef },
|
1381 | { type: EclatFormContainerDirective }
|
1382 | ]; };
|
1383 | return EclatFormArrayChildrenDirective;
|
1384 | }());
|
1385 |
|
1386 | |
1387 |
|
1388 |
|
1389 |
|
1390 | var EclatFormSubmitDirective = (function () {
|
1391 | function EclatFormSubmitDirective(parent) {
|
1392 | this.parent = parent;
|
1393 | }
|
1394 | |
1395 |
|
1396 |
|
1397 | EclatFormSubmitDirective.prototype.onClick = |
1398 |
|
1399 |
|
1400 | function () {
|
1401 | this.parent.submit();
|
1402 | };
|
1403 | EclatFormSubmitDirective.decorators = [
|
1404 | { type: core.Directive, args: [{ selector: '[eclatFormSubmit]' },] }
|
1405 | ];
|
1406 |
|
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 |
|
1418 |
|
1419 |
|
1420 | |
1421 |
|
1422 |
|
1423 | var EclatFormArrayAddDirective = (function () {
|
1424 | function EclatFormArrayAddDirective(parent) {
|
1425 | this.parent = parent;
|
1426 | }
|
1427 | |
1428 |
|
1429 |
|
1430 | EclatFormArrayAddDirective.prototype.onClick = |
1431 |
|
1432 |
|
1433 | function () {
|
1434 |
|
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 |
|
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 |
|
1458 |
|
1459 |
|
1460 | |
1461 |
|
1462 |
|
1463 | var |
1464 |
|
1465 |
|
1466 | EclatFormValueContext = (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 |
|
1484 |
|
1485 | var EclatFormValueDirective = (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 |
|
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 |
|
1542 |
|
1543 | EclatFormValueDirective.prototype.ngOnInit = |
1544 |
|
1545 |
|
1546 | function () {
|
1547 | var _this = this;
|
1548 | this.parent.formControl$.pipe(operators.takeUntil(this.onDestroy$)).subscribe(( |
1549 |
|
1550 |
|
1551 |
|
1552 | function (formControl) {
|
1553 | if (formControl && _this.latestControlName) {
|
1554 | _this.eclatFormValue = formControl.getChild(_this.latestControlName);
|
1555 | }
|
1556 | }));
|
1557 | };
|
1558 | |
1559 |
|
1560 |
|
1561 | EclatFormValueDirective.prototype.ngOnDestroy = |
1562 |
|
1563 |
|
1564 | function () {
|
1565 | this.onDestroy$.next();
|
1566 | };
|
1567 | |
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 | EclatFormValueDirective.prototype.setContext = |
1573 |
|
1574 |
|
1575 |
|
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 |
|
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 |
|
1605 |
|
1606 |
|
1607 | |
1608 |
|
1609 |
|
1610 | var EclatFormGroupBinderDirective = (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 |
|
1628 |
|
1629 |
|
1630 | EclatFormGroupBinderDirective.prototype.ngOnChanges = |
1631 |
|
1632 |
|
1633 |
|
1634 | function (changes) {
|
1635 |
|
1636 | var eclatFormGroupChanges = changes.eclatFormGroup;
|
1637 | if (eclatFormGroupChanges) {
|
1638 |
|
1639 | var prevValue = eclatFormGroupChanges.previousValue ? eclatFormGroupChanges.previousValue.control : undefined;
|
1640 |
|
1641 | var currentValue = eclatFormGroupChanges.currentValue.control;
|
1642 |
|
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 |
|
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 |
|
1667 |
|
1668 |
|
1669 | |
1670 |
|
1671 |
|
1672 | var EclatFormGroupNameBinderDirective = (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 |
|
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 |
|
1708 |
|
1709 |
|
1710 | |
1711 |
|
1712 |
|
1713 | var EclatFormArrayNameBinderDirective = (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 |
|
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 |
|
1749 |
|
1750 |
|
1751 | |
1752 |
|
1753 |
|
1754 | var EclatFormArrayRemoveDirective = (function () {
|
1755 | function EclatFormArrayRemoveDirective(parent) {
|
1756 | this.parent = parent;
|
1757 | }
|
1758 | |
1759 |
|
1760 |
|
1761 | EclatFormArrayRemoveDirective.prototype.onClick = |
1762 |
|
1763 |
|
1764 | function () {
|
1765 |
|
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 |
|
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 |
|
1789 |
|
1790 |
|
1791 | var EclatFormModule = (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 |
|