@rxap/material-form-system 12.0.11 → 13.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/esm2020/index.mjs +12 -0
  2. package/esm2020/lib/chip-input-adapter.directive.mjs +50 -0
  3. package/esm2020/lib/chip-list-iterator.directive.mjs +107 -0
  4. package/esm2020/lib/compare-with.directive.mjs +65 -0
  5. package/esm2020/lib/control-error.directive.mjs +89 -0
  6. package/esm2020/lib/control-errors.directive.mjs +79 -0
  7. package/esm2020/lib/form-controls/form-controls.component.mjs +123 -0
  8. package/esm2020/lib/form-controls/form-controls.component.module.mjs +42 -0
  9. package/esm2020/lib/form-field-hide-show.directive.mjs +151 -0
  10. package/esm2020/lib/input-clear-button.directive.mjs +61 -0
  11. package/esm2020/lib/material-form-system.module.mjs +33 -0
  12. package/esm2020/lib/required.directive.mjs +45 -0
  13. package/esm2020/rxap-material-form-system.mjs +5 -0
  14. package/fesm2015/rxap-material-form-system.mjs +831 -0
  15. package/fesm2015/rxap-material-form-system.mjs.map +1 -0
  16. package/{fesm2015/rxap-material-form-system.js → fesm2020/rxap-material-form-system.mjs} +217 -92
  17. package/fesm2020/rxap-material-form-system.mjs.map +1 -0
  18. package/index.d.ts +2 -0
  19. package/lib/chip-input-adapter.directive.d.ts +19 -0
  20. package/lib/chip-list-iterator.directive.d.ts +30 -0
  21. package/package.json +41 -26
  22. package/src/schematics/ng-add/index.js +1 -1
  23. package/src/schematics/ng-add/index.js.map +1 -1
  24. package/bundles/rxap-material-form-system.umd.js +0 -1090
  25. package/bundles/rxap-material-form-system.umd.js.map +0 -1
  26. package/esm2015/index.js +0 -10
  27. package/esm2015/index.js.map +0 -1
  28. package/esm2015/lib/compare-with.directive.js +0 -65
  29. package/esm2015/lib/compare-with.directive.js.map +0 -1
  30. package/esm2015/lib/control-error.directive.js +0 -91
  31. package/esm2015/lib/control-error.directive.js.map +0 -1
  32. package/esm2015/lib/control-errors.directive.js +0 -81
  33. package/esm2015/lib/control-errors.directive.js.map +0 -1
  34. package/esm2015/lib/form-controls/form-controls.component.js +0 -129
  35. package/esm2015/lib/form-controls/form-controls.component.js.map +0 -1
  36. package/esm2015/lib/form-controls/form-controls.component.module.js +0 -42
  37. package/esm2015/lib/form-controls/form-controls.component.module.js.map +0 -1
  38. package/esm2015/lib/form-field-hide-show.directive.js +0 -161
  39. package/esm2015/lib/form-field-hide-show.directive.js.map +0 -1
  40. package/esm2015/lib/input-clear-button.directive.js +0 -61
  41. package/esm2015/lib/input-clear-button.directive.js.map +0 -1
  42. package/esm2015/lib/material-form-system.module.js +0 -33
  43. package/esm2015/lib/material-form-system.module.js.map +0 -1
  44. package/esm2015/lib/required.directive.js +0 -46
  45. package/esm2015/lib/required.directive.js.map +0 -1
  46. package/esm2015/rxap-material-form-system.js +0 -5
  47. package/esm2015/rxap-material-form-system.js.map +0 -1
  48. package/fesm2015/rxap-material-form-system.js.map +0 -1
@@ -0,0 +1,831 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import * as i0 from '@angular/core';
3
+ import { TemplateRef, ViewContainerRef, ChangeDetectorRef, Directive, Inject, Input, NgModule, HostBinding, HostListener, Renderer2, ElementRef, isDevMode, EventEmitter, Component, ChangeDetectionStrategy, Optional, Output } from '@angular/core';
4
+ import * as i1 from '@angular/material/form-field';
5
+ import { MAT_FORM_FIELD, MatFormField } from '@angular/material/form-field';
6
+ import * as i6 from '@rxap/forms';
7
+ import { controlErrorChanges$, RxapFormControl, FormDirective, RxapFormsModule } from '@rxap/forms';
8
+ import { tap, startWith, catchError, take, filter } from 'rxjs/operators';
9
+ import { Required, getFromObject, equals, coerceBoolean, clone, unique } from '@rxap/utilities';
10
+ import { Subscription, of } from 'rxjs';
11
+ import { RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, RXAP_FORM_SYSTEM_HIDE_METADATA, RXAP_FORM_SYSTEM_SHOW_METADATA, ExtractFormDefinitionMixin } from '@rxap/form-system';
12
+ import { Mixin } from '@rxap/mixin';
13
+ import { getMetadata } from '@rxap/utilities/reflect-metadata';
14
+ import * as i1$1 from '@angular/material/select';
15
+ import { MatSelect } from '@angular/material/select';
16
+ import * as i8 from '@angular/router';
17
+ import { Router } from '@angular/router';
18
+ import * as i7 from '@angular/material/snack-bar';
19
+ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
20
+ import '@angular/localize/init';
21
+ import * as i1$2 from '@angular/material/button';
22
+ import { MatButtonModule } from '@angular/material/button';
23
+ import * as i2 from '@angular/material/progress-spinner';
24
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
25
+ import * as i3 from '@angular/flex-layout/flex';
26
+ import * as i4 from '@angular/flex-layout/extended';
27
+ import * as i5 from '@angular/common';
28
+ import { CommonModule } from '@angular/common';
29
+ import { FlexLayoutModule } from '@angular/flex-layout';
30
+ import { ENTER, COMMA } from '@angular/cdk/keycodes';
31
+ import * as i1$3 from '@angular/material/chips';
32
+ import * as i2$1 from '@angular/forms';
33
+ import { log } from '@rxap/utilities/rxjs';
34
+
35
+ class ControlErrorDirective {
36
+ constructor(formField, template, viewContainerRef, cdr) {
37
+ this.formField = formField;
38
+ this.template = template;
39
+ this.viewContainerRef = viewContainerRef;
40
+ this.cdr = cdr;
41
+ }
42
+ static ngTemplateContextGuard(dir, ctx) {
43
+ return true;
44
+ }
45
+ ngAfterContentInit() {
46
+ var _a;
47
+ const control = (_a = this.formField._control.ngControl) === null || _a === void 0 ? void 0 : _a.control;
48
+ if (control) {
49
+ this._control = control;
50
+ this._subscription = controlErrorChanges$(control)
51
+ .pipe(tap((errors) => this.render(errors)))
52
+ .subscribe();
53
+ }
54
+ else {
55
+ throw new Error('The form field has not a control associated!');
56
+ }
57
+ }
58
+ render(errors) {
59
+ this.viewContainerRef.clear();
60
+ if (errors && errors.hasOwnProperty(this.key)) {
61
+ const error = errors[this.key];
62
+ if (!this._control) {
63
+ throw new Error('The control is not defined!');
64
+ }
65
+ this.viewContainerRef.createEmbeddedView(this.template, {
66
+ $implicit: error,
67
+ control: this._control,
68
+ });
69
+ }
70
+ this.cdr.detectChanges();
71
+ }
72
+ ngOnDestroy() {
73
+ var _a;
74
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
75
+ }
76
+ }
77
+ ControlErrorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirective, deps: [{ token: MAT_FORM_FIELD }, { token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
78
+ ControlErrorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: ControlErrorDirective, selector: "[rxapControlError]", inputs: { key: ["rxapControlErrorKey", "key"] }, ngImport: i0 });
79
+ __decorate([
80
+ Required,
81
+ __metadata("design:type", String)
82
+ ], ControlErrorDirective.prototype, "key", void 0);
83
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirective, decorators: [{
84
+ type: Directive,
85
+ args: [{
86
+ // tslint:disable-next-line:directive-selector
87
+ selector: '[rxapControlError]',
88
+ }]
89
+ }], ctorParameters: function () {
90
+ return [{ type: i1.MatFormField, decorators: [{
91
+ type: Inject,
92
+ args: [MAT_FORM_FIELD]
93
+ }] }, { type: i0.TemplateRef, decorators: [{
94
+ type: Inject,
95
+ args: [TemplateRef]
96
+ }] }, { type: i0.ViewContainerRef, decorators: [{
97
+ type: Inject,
98
+ args: [ViewContainerRef]
99
+ }] }, { type: i0.ChangeDetectorRef, decorators: [{
100
+ type: Inject,
101
+ args: [ChangeDetectorRef]
102
+ }] }];
103
+ }, propDecorators: { key: [{
104
+ type: Input,
105
+ args: ['rxapControlErrorKey']
106
+ }] } });
107
+ class ControlErrorDirectiveModule {
108
+ }
109
+ ControlErrorDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
110
+ ControlErrorDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirectiveModule, declarations: [ControlErrorDirective], exports: [ControlErrorDirective] });
111
+ ControlErrorDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirectiveModule });
112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorDirectiveModule, decorators: [{
113
+ type: NgModule,
114
+ args: [{
115
+ declarations: [ControlErrorDirective],
116
+ exports: [ControlErrorDirective],
117
+ }]
118
+ }] });
119
+
120
+ class ControlErrorsDirective {
121
+ constructor(formField, template, viewContainerRef, cdr) {
122
+ this.formField = formField;
123
+ this.template = template;
124
+ this.viewContainerRef = viewContainerRef;
125
+ this.cdr = cdr;
126
+ }
127
+ static ngTemplateContextGuard(dir, ctx) {
128
+ return true;
129
+ }
130
+ ngAfterContentInit() {
131
+ var _a;
132
+ const control = (_a = this.formField._control.ngControl) === null || _a === void 0 ? void 0 : _a.control;
133
+ if (control) {
134
+ this._control = control;
135
+ this._subscription = controlErrorChanges$(control)
136
+ .pipe(tap((errors) => this.render(errors)))
137
+ .subscribe();
138
+ }
139
+ else {
140
+ throw new Error('The form field has not a control associated!');
141
+ }
142
+ }
143
+ render(errors) {
144
+ this.viewContainerRef.clear();
145
+ if (errors) {
146
+ if (!this._control) {
147
+ throw new Error('The control is not defined!');
148
+ }
149
+ this.viewContainerRef.createEmbeddedView(this.template, {
150
+ $implicit: errors,
151
+ control: this._control,
152
+ });
153
+ }
154
+ this.cdr.detectChanges();
155
+ }
156
+ ngOnDestroy() {
157
+ var _a;
158
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
159
+ }
160
+ }
161
+ ControlErrorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirective, deps: [{ token: MAT_FORM_FIELD }, { token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
162
+ ControlErrorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: ControlErrorsDirective, selector: "[rxapControlErrors]", ngImport: i0 });
163
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirective, decorators: [{
164
+ type: Directive,
165
+ args: [{
166
+ // tslint:disable-next-line:directive-selector
167
+ selector: '[rxapControlErrors]',
168
+ }]
169
+ }], ctorParameters: function () {
170
+ return [{ type: i1.MatFormField, decorators: [{
171
+ type: Inject,
172
+ args: [MAT_FORM_FIELD]
173
+ }] }, { type: i0.TemplateRef, decorators: [{
174
+ type: Inject,
175
+ args: [TemplateRef]
176
+ }] }, { type: i0.ViewContainerRef, decorators: [{
177
+ type: Inject,
178
+ args: [ViewContainerRef]
179
+ }] }, { type: i0.ChangeDetectorRef, decorators: [{
180
+ type: Inject,
181
+ args: [ChangeDetectorRef]
182
+ }] }];
183
+ } });
184
+ class ControlErrorsDirectiveModule {
185
+ }
186
+ ControlErrorsDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
187
+ ControlErrorsDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirectiveModule, declarations: [ControlErrorsDirective], exports: [ControlErrorsDirective] });
188
+ ControlErrorsDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirectiveModule });
189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlErrorsDirectiveModule, decorators: [{
190
+ type: NgModule,
191
+ args: [{
192
+ declarations: [ControlErrorsDirective],
193
+ exports: [ControlErrorsDirective],
194
+ }]
195
+ }] });
196
+
197
+ class InputClearButtonDirective {
198
+ constructor(formField) {
199
+ this.formField = formField;
200
+ this.type = 'button';
201
+ this.tabIndex = '-1';
202
+ }
203
+ get control() {
204
+ return this.formField._control;
205
+ }
206
+ get isDisabled() {
207
+ return this.control.disabled;
208
+ }
209
+ onClick() {
210
+ if (this.control.ngControl) {
211
+ this.control.ngControl.reset();
212
+ }
213
+ else {
214
+ this.control.value = null;
215
+ }
216
+ }
217
+ }
218
+ InputClearButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive });
219
+ InputClearButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: InputClearButtonDirective, selector: "[rxapInputClearButton]", host: { listeners: { "click": "onClick()" }, properties: { "attr.type": "this.type", "attr.tabindex": "this.tabIndex", "disabled": "this.isDisabled" } }, ngImport: i0 });
220
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirective, decorators: [{
221
+ type: Directive,
222
+ args: [{
223
+ selector: '[rxapInputClearButton]'
224
+ }]
225
+ }], ctorParameters: function () {
226
+ return [{ type: i1.MatFormField, decorators: [{
227
+ type: Inject,
228
+ args: [MAT_FORM_FIELD]
229
+ }] }];
230
+ }, propDecorators: { type: [{
231
+ type: HostBinding,
232
+ args: ['attr.type']
233
+ }], tabIndex: [{
234
+ type: HostBinding,
235
+ args: ['attr.tabindex']
236
+ }], isDisabled: [{
237
+ type: HostBinding,
238
+ args: ['disabled']
239
+ }], onClick: [{
240
+ type: HostListener,
241
+ args: ['click']
242
+ }] } });
243
+ class InputClearButtonDirectiveModule {
244
+ }
245
+ InputClearButtonDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
246
+ InputClearButtonDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirectiveModule, declarations: [InputClearButtonDirective], exports: [InputClearButtonDirective] });
247
+ InputClearButtonDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirectiveModule });
248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputClearButtonDirectiveModule, decorators: [{
249
+ type: NgModule,
250
+ args: [{
251
+ declarations: [InputClearButtonDirective],
252
+ exports: [InputClearButtonDirective]
253
+ }]
254
+ }] });
255
+
256
+ class RequiredDirective {
257
+ constructor(formField) {
258
+ this.formField = formField;
259
+ }
260
+ ngAfterContentInit() {
261
+ var _a;
262
+ const control = (_a = this.formField._control.ngControl) === null || _a === void 0 ? void 0 : _a.control;
263
+ if (control) {
264
+ const hasRequiredValidator = Reflect.get(control, 'hasRequiredValidator');
265
+ if (hasRequiredValidator) {
266
+ this.formField._control.required = true;
267
+ }
268
+ }
269
+ else {
270
+ throw new Error('The form field has not a control associated!');
271
+ }
272
+ }
273
+ }
274
+ RequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive });
275
+ RequiredDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: RequiredDirective, selector: "[formControlName][rxapRequired]", ngImport: i0 });
276
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirective, decorators: [{
277
+ type: Directive,
278
+ args: [{
279
+ selector: '[formControlName][rxapRequired]'
280
+ }]
281
+ }], ctorParameters: function () {
282
+ return [{ type: i1.MatFormField, decorators: [{
283
+ type: Inject,
284
+ args: [MAT_FORM_FIELD]
285
+ }] }];
286
+ } });
287
+ class RequiredDirectiveModule {
288
+ }
289
+ RequiredDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
290
+ RequiredDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirectiveModule, declarations: [RequiredDirective], exports: [RequiredDirective] });
291
+ RequiredDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirectiveModule });
292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: RequiredDirectiveModule, decorators: [{
293
+ type: NgModule,
294
+ args: [{
295
+ exports: [RequiredDirective],
296
+ declarations: [RequiredDirective]
297
+ }]
298
+ }] });
299
+
300
+ class ExtractHideShowMixin {
301
+ extractOptions(formDefinition, controlId) {
302
+ var _a, _b, _c;
303
+ if (formDefinition === void 0) { formDefinition = this.formDefinition; }
304
+ if (controlId === void 0) { controlId = (_b = (_a = this.control) === null || _a === void 0 ? void 0 : _a.controlId) !== null && _b !== void 0 ? _b : this.controlId; }
305
+ const map = (_c = getMetadata(RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, Object.getPrototypeOf(formDefinition))) !== null && _c !== void 0 ? _c : null;
306
+ if (!map || !map.has(controlId)) {
307
+ return {};
308
+ }
309
+ return map.get(controlId);
310
+ }
311
+ extractHideFunction(formDefinition, controlId) {
312
+ var _a, _b, _c;
313
+ if (formDefinition === void 0) { formDefinition = this.formDefinition; }
314
+ if (controlId === void 0) { controlId = (_b = (_a = this.control) === null || _a === void 0 ? void 0 : _a.controlId) !== null && _b !== void 0 ? _b : this.controlId; }
315
+ const map = (_c = getMetadata(RXAP_FORM_SYSTEM_HIDE_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _c !== void 0 ? _c : null;
316
+ if (!map || !map.has(controlId)) {
317
+ return null;
318
+ }
319
+ return map.get(controlId);
320
+ }
321
+ extractShowFunction(formDefinition, controlId) {
322
+ var _a, _b, _c;
323
+ if (formDefinition === void 0) { formDefinition = this.formDefinition; }
324
+ if (controlId === void 0) { controlId = (_b = (_a = this.control) === null || _a === void 0 ? void 0 : _a.controlId) !== null && _b !== void 0 ? _b : this.controlId; }
325
+ const map = (_c = getMetadata(RXAP_FORM_SYSTEM_SHOW_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _c !== void 0 ? _c : null;
326
+ if (!map || !map.has(controlId)) {
327
+ return null;
328
+ }
329
+ return map.get(controlId);
330
+ }
331
+ }
332
+ // TODO : create mixin for hide and show logic (this class and ControlHideShowDirective in @rxap/form-system)
333
+ let FormFieldHideShowDirective = class FormFieldHideShowDirective {
334
+ constructor(formField, renderer, elementRef) {
335
+ this.formField = formField;
336
+ this.renderer = renderer;
337
+ this.elementRef = elementRef;
338
+ this.subscription = new Subscription();
339
+ }
340
+ ngAfterContentInit() {
341
+ var _a;
342
+ const control = (_a = this.formField._control.ngControl) === null || _a === void 0 ? void 0 : _a.control;
343
+ if (!control) {
344
+ throw new Error('The form field has not a control associated!');
345
+ }
346
+ if (!(control instanceof RxapFormControl)) {
347
+ throw new Error('The associated control is not a RxapFormControl');
348
+ }
349
+ this.control = control;
350
+ this.formDefinition = this.extractFormDefinition(control);
351
+ const hideFunction = this.extractHideFunction(this.formDefinition);
352
+ const showFunction = this.extractShowFunction(this.formDefinition);
353
+ const options = this.extractOptions(this.formDefinition);
354
+ let changeTrigger = this.formDefinition.rxapFormGroup.valueChanges;
355
+ if (options.rootChange) {
356
+ changeTrigger = this.formDefinition.rxapFormGroup.root.valueChanges;
357
+ }
358
+ changeTrigger = changeTrigger.pipe(startWith(null));
359
+ if (showFunction) {
360
+ this.subscription.add(changeTrigger.pipe(tap(() => {
361
+ // TODO : resubscribe if the showFunction throws an error
362
+ const show = showFunction.call(this.formDefinition, control);
363
+ switch (show) {
364
+ case true:
365
+ this.show();
366
+ break;
367
+ case false:
368
+ this.hide();
369
+ break;
370
+ case null:
371
+ this.reset();
372
+ break;
373
+ }
374
+ }), catchError(err => {
375
+ console.error(err);
376
+ return of(null);
377
+ })).subscribe());
378
+ }
379
+ if (hideFunction) {
380
+ this.subscription.add(changeTrigger.pipe(tap(() => {
381
+ // TODO : resubscribe if the hideFunction throws an error
382
+ const hide = hideFunction.call(this.formDefinition, control);
383
+ switch (hide) {
384
+ case true:
385
+ this.hide();
386
+ break;
387
+ case false:
388
+ this.show();
389
+ break;
390
+ case null:
391
+ this.reset();
392
+ break;
393
+ }
394
+ }), catchError(err => {
395
+ console.error(err);
396
+ return of(null);
397
+ })).subscribe());
398
+ }
399
+ }
400
+ ngOnDestroy() {
401
+ this.subscription.unsubscribe();
402
+ }
403
+ hide() {
404
+ this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'none');
405
+ }
406
+ show() {
407
+ this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'block');
408
+ }
409
+ reset() {
410
+ this.renderer.removeStyle(this.elementRef.nativeElement, 'display');
411
+ }
412
+ };
413
+ FormFieldHideShowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirective, deps: [{ token: MAT_FORM_FIELD }, { token: Renderer2 }, { token: ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
414
+ FormFieldHideShowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: FormFieldHideShowDirective, selector: "mat-form-field[rxapHideShow]", ngImport: i0 });
415
+ FormFieldHideShowDirective = __decorate([
416
+ Mixin(ExtractHideShowMixin, ExtractFormDefinitionMixin),
417
+ __metadata("design:paramtypes", [MatFormField,
418
+ Renderer2,
419
+ ElementRef])
420
+ ], FormFieldHideShowDirective);
421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirective, decorators: [{
422
+ type: Directive,
423
+ args: [{
424
+ selector: 'mat-form-field[rxapHideShow]'
425
+ }]
426
+ }], ctorParameters: function () {
427
+ return [{ type: i1.MatFormField, decorators: [{
428
+ type: Inject,
429
+ args: [MAT_FORM_FIELD]
430
+ }] }, { type: i0.Renderer2, decorators: [{
431
+ type: Inject,
432
+ args: [Renderer2]
433
+ }] }, { type: i0.ElementRef, decorators: [{
434
+ type: Inject,
435
+ args: [ElementRef]
436
+ }] }];
437
+ } });
438
+ class FormFieldHideShowDirectiveModule {
439
+ }
440
+ FormFieldHideShowDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
441
+ FormFieldHideShowDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirectiveModule, declarations: [FormFieldHideShowDirective], exports: [FormFieldHideShowDirective] });
442
+ FormFieldHideShowDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirectiveModule });
443
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormFieldHideShowDirectiveModule, decorators: [{
444
+ type: NgModule,
445
+ args: [{
446
+ declarations: [FormFieldHideShowDirective],
447
+ exports: [FormFieldHideShowDirective]
448
+ }]
449
+ }] });
450
+
451
+ class MaterialFormSystemModule {
452
+ }
453
+ MaterialFormSystemModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: MaterialFormSystemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
454
+ MaterialFormSystemModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: MaterialFormSystemModule, exports: [ControlErrorDirectiveModule,
455
+ ControlErrorsDirectiveModule,
456
+ InputClearButtonDirectiveModule,
457
+ RequiredDirectiveModule,
458
+ FormFieldHideShowDirectiveModule] });
459
+ MaterialFormSystemModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: MaterialFormSystemModule, imports: [ControlErrorDirectiveModule,
460
+ ControlErrorsDirectiveModule,
461
+ InputClearButtonDirectiveModule,
462
+ RequiredDirectiveModule,
463
+ FormFieldHideShowDirectiveModule] });
464
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: MaterialFormSystemModule, decorators: [{
465
+ type: NgModule,
466
+ args: [{
467
+ exports: [
468
+ ControlErrorDirectiveModule,
469
+ ControlErrorsDirectiveModule,
470
+ InputClearButtonDirectiveModule,
471
+ RequiredDirectiveModule,
472
+ FormFieldHideShowDirectiveModule
473
+ ]
474
+ }]
475
+ }] });
476
+
477
+ class CompareWithDirective {
478
+ constructor(matSelect) {
479
+ this.matSelect = matSelect;
480
+ }
481
+ ngOnInit() {
482
+ this.matSelect.compareWith = this.compareWith.bind(this);
483
+ }
484
+ compareWith(o1, o2) {
485
+ if (this.objectPath) {
486
+ if (typeof o1 !== 'object' || typeof o2 !== 'object') {
487
+ if (isDevMode()) {
488
+ console.warn('At least one of the select options value is not an object');
489
+ }
490
+ return false;
491
+ }
492
+ if (o1 === null || o1 === undefined || o2 === null || o2 === undefined) {
493
+ if (isDevMode()) {
494
+ console.warn('At least one of the select options value is undefined or null');
495
+ }
496
+ return false;
497
+ }
498
+ const o1Value = getFromObject(o1, this.objectPath);
499
+ const o2Value = getFromObject(o2, this.objectPath);
500
+ if (o1Value === undefined || o2Value === undefined) {
501
+ return false;
502
+ }
503
+ return o1Value === o2Value;
504
+ }
505
+ else {
506
+ return equals(o1, o2);
507
+ }
508
+ }
509
+ }
510
+ CompareWithDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirective, deps: [{ token: MatSelect }], target: i0.ɵɵFactoryTarget.Directive });
511
+ CompareWithDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: CompareWithDirective, selector: "mat-select[rxapCompareWith]", inputs: { objectPath: ["rxapCompareWith", "objectPath"] }, ngImport: i0 });
512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirective, decorators: [{
513
+ type: Directive,
514
+ args: [{
515
+ selector: 'mat-select[rxapCompareWith]',
516
+ }]
517
+ }], ctorParameters: function () {
518
+ return [{ type: i1$1.MatSelect, decorators: [{
519
+ type: Inject,
520
+ args: [MatSelect]
521
+ }] }];
522
+ }, propDecorators: { objectPath: [{
523
+ type: Input,
524
+ args: ['rxapCompareWith']
525
+ }] } });
526
+ class CompareWithDirectiveModule {
527
+ }
528
+ CompareWithDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
529
+ CompareWithDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirectiveModule, declarations: [CompareWithDirective], exports: [CompareWithDirective] });
530
+ CompareWithDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirectiveModule });
531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: CompareWithDirectiveModule, decorators: [{
532
+ type: NgModule,
533
+ args: [{
534
+ declarations: [CompareWithDirective],
535
+ exports: [CompareWithDirective],
536
+ }]
537
+ }] });
538
+
539
+ class FormControlsComponent {
540
+ constructor(formDirective, cdr, snackBar, router) {
541
+ this.formDirective = formDirective;
542
+ this.cdr = cdr;
543
+ this.snackBar = snackBar;
544
+ this.router = router;
545
+ this._allowResubmit = false;
546
+ this.invalid = false;
547
+ this.close = new EventEmitter();
548
+ this.submitted = new EventEmitter();
549
+ this.isDevMode = isDevMode();
550
+ /**
551
+ * Collection of successful submitted values
552
+ * @private
553
+ */
554
+ this._submitted = [];
555
+ }
556
+ set allowResubmit(value) {
557
+ this._allowResubmit = coerceBoolean(value);
558
+ }
559
+ get allowResubmit() {
560
+ return this._allowResubmit;
561
+ }
562
+ ngOnInit() {
563
+ this.submitting$ = this.formDirective.submitting$;
564
+ this.close
565
+ .pipe(take(1), tap(() => {
566
+ if (this.navigateAfterSubmit) {
567
+ if (this.router) {
568
+ return this.router.navigate(this.navigateAfterSubmit);
569
+ }
570
+ else {
571
+ console.warn('The Router is not available. Ensure that tha RouterModule is imported');
572
+ }
573
+ }
574
+ return Promise.resolve();
575
+ }))
576
+ .subscribe();
577
+ }
578
+ reset() {
579
+ this.invalid = false;
580
+ this.formDirective.reset();
581
+ }
582
+ cancel() {
583
+ this.close.emit();
584
+ }
585
+ submit(closeAfterSubmit) {
586
+ this.formDirective.form.markAllAsDirty();
587
+ this.formDirective.form.markAllAsTouched();
588
+ this.formDirective.cdr.markForCheck();
589
+ let submitSubscription;
590
+ const invalidSubmitSubscription = this.formDirective.invalidSubmit
591
+ .pipe(take(1), tap(() => submitSubscription === null || submitSubscription === void 0 ? void 0 : submitSubscription.unsubscribe()), tap(() => (this.invalid = true)), tap(() => this.cdr.detectChanges()), tap(() => this.snackBar.open($localize `:@@rxap-material.form-system.form-controls.form-is-invalid:Form is not valid`, 'ok', { duration: 5000 })))
592
+ .subscribe();
593
+ submitSubscription = this.formDirective.rxapSubmit
594
+ .pipe(take(1), tap((value) => {
595
+ const clonedValue = clone(value);
596
+ this._submitted.push(clonedValue);
597
+ this.submitted.emit(clonedValue);
598
+ if (closeAfterSubmit) {
599
+ this.close.emit(this._submitted.length > 1 ? this._submitted : this._submitted[0]);
600
+ }
601
+ else {
602
+ if (typeof this.formDirective.formDefinition.rxapReuse === 'function') {
603
+ this.formDirective.formDefinition.rxapReuse();
604
+ }
605
+ }
606
+ invalidSubmitSubscription.unsubscribe();
607
+ this.invalid = false;
608
+ this.cdr.detectChanges();
609
+ }))
610
+ .subscribe();
611
+ this.formDirective.onSubmit(new Event('submit'));
612
+ }
613
+ logCurrentFormState() {
614
+ console.log(clone(this.formDirective.form.value));
615
+ }
616
+ }
617
+ FormControlsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponent, deps: [{ token: FormDirective }, { token: ChangeDetectorRef }, { token: MatSnackBar }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.Component });
618
+ FormControlsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: FormControlsComponent, selector: "rxap-form-controls", inputs: { allowResubmit: "allowResubmit", navigateAfterSubmit: "navigateAfterSubmit" }, outputs: { close: "close", submitted: "submitted" }, host: { classAttribute: "mfd-form-controls" }, ngImport: i0, template: "<div fxLayout=\"row\" fxLayoutAlign=\"space-between center\" fxLayoutGap=\"32px\">\n <div fxFlex=\"nogrow\" fxLayout=\"row\" fxLayoutAlign=\"end center\" fxLayoutGap=\"32px\" style=\"width: 100%\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.reset\"\n mat-stroked-button>\n Reset\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n color=\"warn\" fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.cancel\"\n mat-stroked-button>\n Cancel\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n color=\"primary\"\n fxFlex=\"nogrow\"\n [ngClass]=\"{ invalid: invalid }\"\n mat-raised-button>\n <span fxLayout=\"row\" fxLayoutGap=\"4px\" fxLayoutAlign=\"start center\">\n <span fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.submit\">Submit</span>\n <mat-spinner [fxShow]=\"submitting$ | async\" fxFlex=\"nogrow\" mode=\"indeterminate\" [diameter]=\"15\" color=\"accent\"></mat-spinner>\n </span>\n </button>\n <button *ngIf=\"allowResubmit\" (click)=\"submit(true)\"\n type=\"button\"\n color=\"primary\"\n fxFlex=\"nogrow\"\n [ngClass]=\"{ invalid: invalid }\"\n [disabled]=\"submitting$ | async\"\n mat-raised-button>\n <span fxLayout=\"row\" fxLayoutGap=\"4px\" fxLayoutAlign=\"start center\">\n <span fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.submit-and-close\">\n Submit and Close\n </span>\n <mat-spinner [fxShow]=\"submitting$ | async\" fxFlex=\"nogrow\" mode=\"indeterminate\" [diameter]=\"15\" color=\"accent\"></mat-spinner>\n </span>\n </button>\n <button *ngIf=\"isDevMode\" type=\"button\" mat-button fxFlex=\"nogrow\" (click)=\"logCurrentFormState()\">Current Form State</button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"], components: [{ type: i1$2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i2.MatSpinner, selector: "mat-spinner", inputs: ["color"] }], directives: [{ type: i3.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i3.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { type: i3.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { type: i3.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { type: i4.DefaultClassDirective, selector: " [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl], [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl], [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.DefaultShowHideDirective, selector: " [fxShow], [fxShow.print], [fxShow.xs], [fxShow.sm], [fxShow.md], [fxShow.lg], [fxShow.xl], [fxShow.lt-sm], [fxShow.lt-md], [fxShow.lt-lg], [fxShow.lt-xl], [fxShow.gt-xs], [fxShow.gt-sm], [fxShow.gt-md], [fxShow.gt-lg], [fxHide], [fxHide.print], [fxHide.xs], [fxHide.sm], [fxHide.md], [fxHide.lg], [fxHide.xl], [fxHide.lt-sm], [fxHide.lt-md], [fxHide.lt-lg], [fxHide.lt-xl], [fxHide.gt-xs], [fxHide.gt-sm], [fxHide.gt-md], [fxHide.gt-lg]", inputs: ["fxShow", "fxShow.print", "fxShow.xs", "fxShow.sm", "fxShow.md", "fxShow.lg", "fxShow.xl", "fxShow.lt-sm", "fxShow.lt-md", "fxShow.lt-lg", "fxShow.lt-xl", "fxShow.gt-xs", "fxShow.gt-sm", "fxShow.gt-md", "fxShow.gt-lg", "fxHide", "fxHide.print", "fxHide.xs", "fxHide.sm", "fxHide.md", "fxHide.lg", "fxHide.xl", "fxHide.lt-sm", "fxHide.lt-md", "fxHide.lt-lg", "fxHide.lt-xl", "fxHide.gt-xs", "fxHide.gt-sm", "fxHide.gt-md", "fxHide.gt-lg"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i5.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
619
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponent, decorators: [{
620
+ type: Component,
621
+ args: [{ selector: 'rxap-form-controls', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'mfd-form-controls' }, template: "<div fxLayout=\"row\" fxLayoutAlign=\"space-between center\" fxLayoutGap=\"32px\">\n <div fxFlex=\"nogrow\" fxLayout=\"row\" fxLayoutAlign=\"end center\" fxLayoutGap=\"32px\" style=\"width: 100%\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.reset\"\n mat-stroked-button>\n Reset\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n color=\"warn\" fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.cancel\"\n mat-stroked-button>\n Cancel\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n type=\"button\"\n color=\"primary\"\n fxFlex=\"nogrow\"\n [ngClass]=\"{ invalid: invalid }\"\n mat-raised-button>\n <span fxLayout=\"row\" fxLayoutGap=\"4px\" fxLayoutAlign=\"start center\">\n <span fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.submit\">Submit</span>\n <mat-spinner [fxShow]=\"submitting$ | async\" fxFlex=\"nogrow\" mode=\"indeterminate\" [diameter]=\"15\" color=\"accent\"></mat-spinner>\n </span>\n </button>\n <button *ngIf=\"allowResubmit\" (click)=\"submit(true)\"\n type=\"button\"\n color=\"primary\"\n fxFlex=\"nogrow\"\n [ngClass]=\"{ invalid: invalid }\"\n [disabled]=\"submitting$ | async\"\n mat-raised-button>\n <span fxLayout=\"row\" fxLayoutGap=\"4px\" fxLayoutAlign=\"start center\">\n <span fxFlex=\"nogrow\"\n i18n=\"@@rxap-material.form-system.components.form-controls.submit-and-close\">\n Submit and Close\n </span>\n <mat-spinner [fxShow]=\"submitting$ | async\" fxFlex=\"nogrow\" mode=\"indeterminate\" [diameter]=\"15\" color=\"accent\"></mat-spinner>\n </span>\n </button>\n <button *ngIf=\"isDevMode\" type=\"button\" mat-button fxFlex=\"nogrow\" (click)=\"logCurrentFormState()\">Current Form State</button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"] }]
622
+ }], ctorParameters: function () {
623
+ return [{ type: i6.FormDirective, decorators: [{
624
+ type: Inject,
625
+ args: [FormDirective]
626
+ }] }, { type: i0.ChangeDetectorRef, decorators: [{
627
+ type: Inject,
628
+ args: [ChangeDetectorRef]
629
+ }] }, { type: i7.MatSnackBar, decorators: [{
630
+ type: Inject,
631
+ args: [MatSnackBar]
632
+ }] }, { type: i8.Router, decorators: [{
633
+ type: Optional
634
+ }, {
635
+ type: Inject,
636
+ args: [Router]
637
+ }] }];
638
+ }, propDecorators: { allowResubmit: [{
639
+ type: Input
640
+ }], navigateAfterSubmit: [{
641
+ type: Input
642
+ }], close: [{
643
+ type: Output
644
+ }], submitted: [{
645
+ type: Output
646
+ }] } });
647
+
648
+ class FormControlsComponentModule {
649
+ }
650
+ FormControlsComponentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
651
+ FormControlsComponentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponentModule, declarations: [FormControlsComponent], imports: [MatProgressSpinnerModule,
652
+ FlexLayoutModule,
653
+ MatButtonModule,
654
+ CommonModule,
655
+ RxapFormsModule,
656
+ MatSnackBarModule], exports: [FormControlsComponent] });
657
+ FormControlsComponentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponentModule, imports: [[
658
+ MatProgressSpinnerModule,
659
+ FlexLayoutModule,
660
+ MatButtonModule,
661
+ CommonModule,
662
+ RxapFormsModule,
663
+ MatSnackBarModule,
664
+ ]] });
665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormControlsComponentModule, decorators: [{
666
+ type: NgModule,
667
+ args: [{
668
+ declarations: [FormControlsComponent],
669
+ imports: [
670
+ MatProgressSpinnerModule,
671
+ FlexLayoutModule,
672
+ MatButtonModule,
673
+ CommonModule,
674
+ RxapFormsModule,
675
+ MatSnackBarModule,
676
+ ],
677
+ exports: [FormControlsComponent]
678
+ }]
679
+ }] });
680
+
681
+ class ChipInputAdapterDirective {
682
+ constructor(matChipInput, ngControl) {
683
+ this.matChipInput = matChipInput;
684
+ this.ngControl = ngControl;
685
+ this.matChipInput.separatorKeyCodes = [ENTER, COMMA];
686
+ this.matChipInput.addOnBlur = true;
687
+ }
688
+ ngOnDestroy() {
689
+ var _a;
690
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
691
+ }
692
+ ngOnInit() {
693
+ this._subscription = this.matChipInput.chipEnd
694
+ .pipe(filter((add) => { var _a; return !!((_a = add.value) === null || _a === void 0 ? void 0 : _a.trim()); }), tap((add) => {
695
+ var _a, _b;
696
+ const value = (_a = this.ngControl.value) !== null && _a !== void 0 ? _a : [];
697
+ (_b = this.ngControl.control) === null || _b === void 0 ? void 0 : _b.setValue([...value, add.value].filter(unique()));
698
+ this.matChipInput.clear();
699
+ }))
700
+ .subscribe();
701
+ }
702
+ }
703
+ ChipInputAdapterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirective, deps: [{ token: i1$3.MatChipInput }, { token: i2$1.NgControl }], target: i0.ɵɵFactoryTarget.Directive });
704
+ ChipInputAdapterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: ChipInputAdapterDirective, selector: "[matChipInputFor][rxapChipInputAdapter]", ngImport: i0 });
705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirective, decorators: [{
706
+ type: Directive,
707
+ args: [{
708
+ selector: '[matChipInputFor][rxapChipInputAdapter]'
709
+ }]
710
+ }], ctorParameters: function () { return [{ type: i1$3.MatChipInput }, { type: i2$1.NgControl }]; } });
711
+ class ChipInputAdapterDirectiveModule {
712
+ }
713
+ ChipInputAdapterDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
714
+ ChipInputAdapterDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirectiveModule, declarations: [ChipInputAdapterDirective], exports: [ChipInputAdapterDirective] });
715
+ ChipInputAdapterDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirectiveModule });
716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipInputAdapterDirectiveModule, decorators: [{
717
+ type: NgModule,
718
+ args: [{
719
+ exports: [ChipInputAdapterDirective],
720
+ declarations: [ChipInputAdapterDirective]
721
+ }]
722
+ }] });
723
+
724
+ function getTypeName(type) {
725
+ return type['name'] || typeof type;
726
+ }
727
+ class RecordViewTuple {
728
+ constructor(record, view) {
729
+ this.record = record;
730
+ this.view = view;
731
+ }
732
+ }
733
+ class ChipListIteratorDirective {
734
+ constructor(template, viewContainerRef, ngControl, differs) {
735
+ this.template = template;
736
+ this.viewContainerRef = viewContainerRef;
737
+ this.ngControl = ngControl;
738
+ this.differs = differs;
739
+ this._dirty = true;
740
+ this._differ = null;
741
+ }
742
+ ngOnInit() {
743
+ var _a;
744
+ this._subscription = (_a = this.ngControl.valueChanges) === null || _a === void 0 ? void 0 : _a.pipe(startWith(this.ngControl.value), log('test'), filter((value) => Array.isArray(value)), tap((items) => {
745
+ this._dirty = false;
746
+ // React on ngForOf changes only once all inputs have been initialized
747
+ const value = items;
748
+ if (!this._differ && value) {
749
+ try {
750
+ this._differ = this.differs.find(value).create((_, item) => item);
751
+ }
752
+ catch (_a) {
753
+ throw new Error(`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
754
+ }
755
+ }
756
+ if (this._differ) {
757
+ const changes = this._differ.diff(items);
758
+ if (changes) {
759
+ this.applyChanges(changes);
760
+ }
761
+ }
762
+ })).subscribe();
763
+ }
764
+ ngOnDestroy() {
765
+ var _a;
766
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
767
+ }
768
+ applyChanges(changes) {
769
+ const insertTuples = [];
770
+ changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
771
+ if (item.previousIndex == null) {
772
+ // NgForOf is never "null" or "undefined" here because the differ detected
773
+ // that a new item needs to be inserted from the iterable. This implies that
774
+ // there is an iterable value for "_ngForOf".
775
+ const view = this.viewContainerRef.createEmbeddedView(this.template, { $implicit: item.item, onRemoved: this.onRemoved.bind(this) }, currentIndex === null ? undefined : currentIndex);
776
+ const tuple = new RecordViewTuple(item, view);
777
+ insertTuples.push(tuple);
778
+ }
779
+ else if (currentIndex == null) {
780
+ this.viewContainerRef.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
781
+ }
782
+ else if (adjustedPreviousIndex !== null) {
783
+ const view = this.viewContainerRef.get(adjustedPreviousIndex);
784
+ this.viewContainerRef.move(view, currentIndex);
785
+ const tuple = new RecordViewTuple(item, view);
786
+ insertTuples.push(tuple);
787
+ }
788
+ });
789
+ for (let i = 0; i < insertTuples.length; i++) {
790
+ this.perViewChange(insertTuples[i].view, insertTuples[i].record);
791
+ }
792
+ changes.forEachIdentityChange((record) => {
793
+ const viewRef = (this.viewContainerRef.get(record.currentIndex));
794
+ viewRef.context.$implicit = record.item;
795
+ });
796
+ }
797
+ onRemoved($event) {
798
+ var _a, _b;
799
+ (_a = this.ngControl.control) === null || _a === void 0 ? void 0 : _a.setValue(((_b = this.ngControl.value) !== null && _b !== void 0 ? _b : []).filter((item) => item !== $event.chip.value));
800
+ }
801
+ perViewChange(view, record) {
802
+ view.context.$implicit = record.item;
803
+ }
804
+ }
805
+ ChipListIteratorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i2$1.NgControl }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });
806
+ ChipListIteratorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: ChipListIteratorDirective, selector: "[rxapChipListIterator]", ngImport: i0 });
807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirective, decorators: [{
808
+ type: Directive,
809
+ args: [{
810
+ selector: '[rxapChipListIterator]'
811
+ }]
812
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: i2$1.NgControl }, { type: i0.IterableDiffers }]; } });
813
+ class ChipListIteratorDirectiveModule {
814
+ }
815
+ ChipListIteratorDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
816
+ ChipListIteratorDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirectiveModule, declarations: [ChipListIteratorDirective], exports: [ChipListIteratorDirective] });
817
+ ChipListIteratorDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirectiveModule });
818
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ChipListIteratorDirectiveModule, decorators: [{
819
+ type: NgModule,
820
+ args: [{
821
+ exports: [ChipListIteratorDirective],
822
+ declarations: [ChipListIteratorDirective]
823
+ }]
824
+ }] });
825
+
826
+ /**
827
+ * Generated bundle index. Do not edit.
828
+ */
829
+
830
+ export { ChipInputAdapterDirective, ChipInputAdapterDirectiveModule, ChipListIteratorDirective, ChipListIteratorDirectiveModule, CompareWithDirective, CompareWithDirectiveModule, ControlErrorDirective, ControlErrorDirectiveModule, ControlErrorsDirective, ControlErrorsDirectiveModule, ExtractHideShowMixin, FormControlsComponent, FormControlsComponentModule, FormFieldHideShowDirective, FormFieldHideShowDirectiveModule, InputClearButtonDirective, InputClearButtonDirectiveModule, MaterialFormSystemModule, RequiredDirective, RequiredDirectiveModule };
831
+ //# sourceMappingURL=rxap-material-form-system.mjs.map