@rxap/material-form-system 14.0.4-dev.0 → 16.0.0-dev.0

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