@rxap/material-form-system 16.0.3-dev.0 → 17.0.1-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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/esm2022/index.mjs +11 -7
- package/esm2022/lib/chip-input-adapter.directive.mjs +5 -5
- package/esm2022/lib/chip-list-iterator.directive.mjs +5 -5
- package/esm2022/lib/compare-with.directive.mjs +6 -6
- package/esm2022/lib/control-error.directive.mjs +6 -6
- package/esm2022/lib/control-errors.directive.mjs +6 -6
- package/esm2022/lib/form-controls/form-controls.component.mjs +6 -6
- package/esm2022/lib/form-field-hide-show.directive.mjs +8 -7
- package/esm2022/lib/input-clear-button.directive.mjs +6 -6
- package/esm2022/lib/material-form-system.module.mjs +5 -5
- package/esm2022/lib/required.directive.mjs +6 -6
- package/fesm2022/rxap-material-form-system.mjs +387 -384
- package/fesm2022/rxap-material-form-system.mjs.map +1 -1
- package/index.d.ts +6 -6
- package/package.json +39 -39
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import * as i1 from '@angular/material/form-field';
|
|
4
|
-
import { MAT_FORM_FIELD, MatFormField } from '@angular/material/form-field';
|
|
2
|
+
import { EventEmitter, isDevMode, ChangeDetectorRef, Component, ChangeDetectionStrategy, Inject, Optional, Input, Output, Directive, TemplateRef, ViewContainerRef, Renderer2, ElementRef, HostBinding, HostListener, NgModule } from '@angular/core';
|
|
5
3
|
import * as i3 from '@rxap/forms';
|
|
6
|
-
import { controlErrorChanges$, RxapFormControl
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import { MatSelect } from '@angular/material/select';
|
|
10
|
-
import { getFromObject, equals, coerceBoolean, clone, unique } from '@rxap/utilities';
|
|
11
|
-
import { __decorate, __metadata } from 'tslib';
|
|
12
|
-
import { Subscription, of } from 'rxjs';
|
|
13
|
-
import { RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, RXAP_FORM_SYSTEM_HIDE_METADATA, RXAP_FORM_SYSTEM_SHOW_METADATA, ExtractFormDefinitionMixin } from '@rxap/form-system';
|
|
14
|
-
import { Mixin } from '@rxap/mixin';
|
|
15
|
-
import { getMetadata } from '@rxap/reflect-metadata';
|
|
4
|
+
import { FormDirective, controlErrorChanges$, RxapFormControl } from '@rxap/forms';
|
|
5
|
+
import { coerceBoolean, clone, unique, getFromObject, equals } from '@rxap/utilities';
|
|
6
|
+
import { take, tap, filter, startWith, catchError } from 'rxjs/operators';
|
|
16
7
|
import * as i5 from '@angular/router';
|
|
17
8
|
import { Router } from '@angular/router';
|
|
18
9
|
import * as i4 from '@angular/material/snack-bar';
|
|
@@ -20,11 +11,307 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
|
20
11
|
import * as i2 from '@angular/material/progress-spinner';
|
|
21
12
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
22
13
|
import { NgClass, NgIf, AsyncPipe } from '@angular/common';
|
|
23
|
-
import * as i1
|
|
14
|
+
import * as i1 from '@angular/material/button';
|
|
24
15
|
import { MatButtonModule } from '@angular/material/button';
|
|
25
16
|
import { ENTER, COMMA } from '@angular/cdk/keycodes';
|
|
26
17
|
import * as i2$1 from '@angular/forms';
|
|
27
|
-
import * as i1$
|
|
18
|
+
import * as i1$1 from '@angular/material/chips';
|
|
19
|
+
import * as i1$2 from '@angular/material/select';
|
|
20
|
+
import { MatSelect } from '@angular/material/select';
|
|
21
|
+
import * as i1$3 from '@angular/material/form-field';
|
|
22
|
+
import { MAT_FORM_FIELD, MatFormField } from '@angular/material/form-field';
|
|
23
|
+
import { __decorate, __metadata } from 'tslib';
|
|
24
|
+
import { Subscription, of } from 'rxjs';
|
|
25
|
+
import { RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, RXAP_FORM_SYSTEM_HIDE_METADATA, RXAP_FORM_SYSTEM_SHOW_METADATA, ExtractFormDefinitionMixin } from '@rxap/form-system';
|
|
26
|
+
import { Mixin } from '@rxap/mixin';
|
|
27
|
+
import { getMetadata } from '@rxap/reflect-metadata';
|
|
28
|
+
|
|
29
|
+
class FormControlsComponent {
|
|
30
|
+
constructor(formDirective, cdr, snackBar, router) {
|
|
31
|
+
this.formDirective = formDirective;
|
|
32
|
+
this.cdr = cdr;
|
|
33
|
+
this.snackBar = snackBar;
|
|
34
|
+
this.router = router;
|
|
35
|
+
this.invalid = false;
|
|
36
|
+
this.close = new EventEmitter();
|
|
37
|
+
this.submitted = new EventEmitter();
|
|
38
|
+
this.isDevMode = isDevMode();
|
|
39
|
+
/**
|
|
40
|
+
* Collection of successful submitted values
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
this._submitted = [];
|
|
44
|
+
this._allowResubmit = false;
|
|
45
|
+
}
|
|
46
|
+
get allowResubmit() {
|
|
47
|
+
return this._allowResubmit;
|
|
48
|
+
}
|
|
49
|
+
set allowResubmit(value) {
|
|
50
|
+
this._allowResubmit = coerceBoolean(value);
|
|
51
|
+
}
|
|
52
|
+
ngOnInit() {
|
|
53
|
+
this.submitting$ = this.formDirective.submitting$;
|
|
54
|
+
this.close
|
|
55
|
+
.pipe(take(1), tap(() => {
|
|
56
|
+
if (this.navigateAfterSubmit) {
|
|
57
|
+
if (this.router) {
|
|
58
|
+
return this.router.navigate(this.navigateAfterSubmit);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.warn('The Router is not available. Ensure that tha RouterModule is imported');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}))
|
|
66
|
+
.subscribe();
|
|
67
|
+
}
|
|
68
|
+
reset() {
|
|
69
|
+
this.invalid = false;
|
|
70
|
+
this.formDirective.reset();
|
|
71
|
+
}
|
|
72
|
+
cancel() {
|
|
73
|
+
this.close.emit();
|
|
74
|
+
}
|
|
75
|
+
submit(closeAfterSubmit) {
|
|
76
|
+
this.formDirective.form.markAllAsDirty();
|
|
77
|
+
this.formDirective.form.markAllAsTouched();
|
|
78
|
+
this.formDirective.cdr.markForCheck();
|
|
79
|
+
// eslint-disable-next-line prefer-const
|
|
80
|
+
let submitSubscription;
|
|
81
|
+
const invalidSubmitSubscription = this.formDirective.invalidSubmit
|
|
82
|
+
.pipe(take(1), tap(() => 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 })))
|
|
83
|
+
.subscribe();
|
|
84
|
+
submitSubscription = this.formDirective.rxapSubmit
|
|
85
|
+
.pipe(take(1), tap((value) => {
|
|
86
|
+
const clonedValue = clone(value);
|
|
87
|
+
this._submitted.push(clonedValue);
|
|
88
|
+
this.submitted.emit(clonedValue);
|
|
89
|
+
if (closeAfterSubmit) {
|
|
90
|
+
this.close.emit(this._submitted.length > 1 ? this._submitted : this._submitted[0]);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (typeof this.formDirective.formDefinition.rxapReuse === 'function') {
|
|
94
|
+
this.formDirective.formDefinition.rxapReuse();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
invalidSubmitSubscription.unsubscribe();
|
|
98
|
+
this.invalid = false;
|
|
99
|
+
this.cdr.detectChanges();
|
|
100
|
+
}))
|
|
101
|
+
.subscribe();
|
|
102
|
+
this.formDirective.onSubmit(new Event('submit'));
|
|
103
|
+
}
|
|
104
|
+
logCurrentFormState() {
|
|
105
|
+
console.log(clone(this.formDirective.form.value));
|
|
106
|
+
}
|
|
107
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: FormControlsComponent, deps: [{ token: FormDirective }, { token: ChangeDetectorRef }, { token: MatSnackBar }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
108
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.3", type: FormControlsComponent, isStandalone: true, selector: "rxap-form-controls", inputs: { navigateAfterSubmit: "navigateAfterSubmit", allowResubmit: "allowResubmit" }, outputs: { close: "close", submitted: "submitted" }, ngImport: i0, template: "<div class=\"flex flex-row justify-between items-center gap-8\">\n <div class=\"flex grow-0 flex-row justify-end items-center gap-8 w-full\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n color=\"warn\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"submit(true)\" *ngIf=\"allowResubmit\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit and Close</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"logCurrentFormState()\" *ngIf=\"isDevMode\" mat-button type=\"button\" class=\"grow-0\">\n Current Form State\n </button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i2.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "ngmodule", type: MatSnackBarModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
109
|
+
}
|
|
110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: FormControlsComponent, decorators: [{
|
|
111
|
+
type: Component,
|
|
112
|
+
args: [{ selector: 'rxap-form-controls', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
113
|
+
MatButtonModule,
|
|
114
|
+
NgClass,
|
|
115
|
+
MatProgressSpinnerModule,
|
|
116
|
+
NgIf,
|
|
117
|
+
AsyncPipe,
|
|
118
|
+
MatSnackBarModule,
|
|
119
|
+
], template: "<div class=\"flex flex-row justify-between items-center gap-8\">\n <div class=\"flex grow-0 flex-row justify-end items-center gap-8 w-full\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n color=\"warn\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"submit(true)\" *ngIf=\"allowResubmit\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit and Close</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"logCurrentFormState()\" *ngIf=\"isDevMode\" mat-button type=\"button\" class=\"grow-0\">\n Current Form State\n </button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"] }]
|
|
120
|
+
}], ctorParameters: () => [{ type: i3.FormDirective, decorators: [{
|
|
121
|
+
type: Inject,
|
|
122
|
+
args: [FormDirective]
|
|
123
|
+
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
124
|
+
type: Inject,
|
|
125
|
+
args: [ChangeDetectorRef]
|
|
126
|
+
}] }, { type: i4.MatSnackBar, decorators: [{
|
|
127
|
+
type: Inject,
|
|
128
|
+
args: [MatSnackBar]
|
|
129
|
+
}] }, { type: i5.Router, decorators: [{
|
|
130
|
+
type: Optional
|
|
131
|
+
}, {
|
|
132
|
+
type: Inject,
|
|
133
|
+
args: [Router]
|
|
134
|
+
}] }], propDecorators: { navigateAfterSubmit: [{
|
|
135
|
+
type: Input
|
|
136
|
+
}], close: [{
|
|
137
|
+
type: Output
|
|
138
|
+
}], submitted: [{
|
|
139
|
+
type: Output
|
|
140
|
+
}], allowResubmit: [{
|
|
141
|
+
type: Input
|
|
142
|
+
}] } });
|
|
143
|
+
|
|
144
|
+
class ChipInputAdapterDirective {
|
|
145
|
+
constructor(matChipInput, ngControl) {
|
|
146
|
+
this.matChipInput = matChipInput;
|
|
147
|
+
this.ngControl = ngControl;
|
|
148
|
+
this.matChipInput.separatorKeyCodes = [ENTER, COMMA];
|
|
149
|
+
this.matChipInput.addOnBlur = true;
|
|
150
|
+
}
|
|
151
|
+
ngOnDestroy() {
|
|
152
|
+
this._subscription?.unsubscribe();
|
|
153
|
+
}
|
|
154
|
+
ngOnInit() {
|
|
155
|
+
this._subscription = this.matChipInput.chipEnd
|
|
156
|
+
.pipe(filter((add) => !!add.value?.trim()), tap((add) => {
|
|
157
|
+
const value = this.ngControl.value ?? [];
|
|
158
|
+
this.ngControl.control?.setValue([...value, add.value].filter(unique()));
|
|
159
|
+
this.matChipInput.clear();
|
|
160
|
+
}))
|
|
161
|
+
.subscribe();
|
|
162
|
+
}
|
|
163
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ChipInputAdapterDirective, deps: [{ token: i1$1.MatChipInput }, { token: i2$1.NgControl }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
164
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: ChipInputAdapterDirective, isStandalone: true, selector: "[matChipInputFor][rxapChipInputAdapter]", ngImport: i0 }); }
|
|
165
|
+
}
|
|
166
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ChipInputAdapterDirective, decorators: [{
|
|
167
|
+
type: Directive,
|
|
168
|
+
args: [{
|
|
169
|
+
selector: '[matChipInputFor][rxapChipInputAdapter]',
|
|
170
|
+
standalone: true,
|
|
171
|
+
}]
|
|
172
|
+
}], ctorParameters: () => [{ type: i1$1.MatChipInput }, { type: i2$1.NgControl }] });
|
|
173
|
+
|
|
174
|
+
function getTypeName(type) {
|
|
175
|
+
return type['name'] || typeof type;
|
|
176
|
+
}
|
|
177
|
+
class RecordViewTuple {
|
|
178
|
+
constructor(record, view) {
|
|
179
|
+
this.record = record;
|
|
180
|
+
this.view = view;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
class ChipListIteratorDirective {
|
|
184
|
+
constructor(template, viewContainerRef, ngControl, differs) {
|
|
185
|
+
this.template = template;
|
|
186
|
+
this.viewContainerRef = viewContainerRef;
|
|
187
|
+
this.ngControl = ngControl;
|
|
188
|
+
this.differs = differs;
|
|
189
|
+
this._dirty = true;
|
|
190
|
+
this._differ = null;
|
|
191
|
+
}
|
|
192
|
+
ngOnInit() {
|
|
193
|
+
this._subscription = this.ngControl.valueChanges
|
|
194
|
+
?.pipe(startWith(this.ngControl.value), filter((value) => Array.isArray(value)), tap((items) => {
|
|
195
|
+
this._dirty = false;
|
|
196
|
+
// React on ngForOf changes only once all inputs have been initialized
|
|
197
|
+
const value = items;
|
|
198
|
+
if (!this._differ && value) {
|
|
199
|
+
try {
|
|
200
|
+
this._differ = this.differs.find(value).create((_, item) => item);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
throw new Error(`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (this._differ) {
|
|
207
|
+
const changes = this._differ.diff(items);
|
|
208
|
+
if (changes) {
|
|
209
|
+
this.applyChanges(changes);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}))
|
|
213
|
+
.subscribe();
|
|
214
|
+
}
|
|
215
|
+
ngOnDestroy() {
|
|
216
|
+
this._subscription?.unsubscribe();
|
|
217
|
+
}
|
|
218
|
+
applyChanges(changes) {
|
|
219
|
+
const insertTuples = [];
|
|
220
|
+
changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
|
|
221
|
+
if (item.previousIndex == null) {
|
|
222
|
+
// NgForOf is never "null" or "undefined" here because the differ detected
|
|
223
|
+
// that a new item needs to be inserted from the iterable. This implies that
|
|
224
|
+
// there is an iterable value for "_ngForOf".
|
|
225
|
+
const view = this.viewContainerRef.createEmbeddedView(this.template, {
|
|
226
|
+
$implicit: item.item,
|
|
227
|
+
onRemoved: this.onRemoved.bind(this),
|
|
228
|
+
}, currentIndex === null ? undefined : currentIndex);
|
|
229
|
+
const tuple = new RecordViewTuple(item, view);
|
|
230
|
+
insertTuples.push(tuple);
|
|
231
|
+
}
|
|
232
|
+
else if (currentIndex == null) {
|
|
233
|
+
this.viewContainerRef.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
|
|
234
|
+
}
|
|
235
|
+
else if (adjustedPreviousIndex !== null) {
|
|
236
|
+
const view = this.viewContainerRef.get(adjustedPreviousIndex);
|
|
237
|
+
this.viewContainerRef.move(view, currentIndex);
|
|
238
|
+
const tuple = new RecordViewTuple(item, view);
|
|
239
|
+
insertTuples.push(tuple);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
for (let i = 0; i < insertTuples.length; i++) {
|
|
243
|
+
this.perViewChange(insertTuples[i].view, insertTuples[i].record);
|
|
244
|
+
}
|
|
245
|
+
changes.forEachIdentityChange((record) => {
|
|
246
|
+
const viewRef = (this.viewContainerRef.get(record.currentIndex));
|
|
247
|
+
viewRef.context.$implicit = record.item;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
onRemoved($event) {
|
|
251
|
+
this.ngControl.control?.setValue((this.ngControl.value ?? []).filter((item) => item !== $event.chip.value));
|
|
252
|
+
}
|
|
253
|
+
perViewChange(view, record) {
|
|
254
|
+
view.context.$implicit = record.item;
|
|
255
|
+
}
|
|
256
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ChipListIteratorDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: i2$1.NgControl }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
257
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: ChipListIteratorDirective, isStandalone: true, selector: "[rxapChipListIterator]", ngImport: i0 }); }
|
|
258
|
+
}
|
|
259
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ChipListIteratorDirective, decorators: [{
|
|
260
|
+
type: Directive,
|
|
261
|
+
args: [{
|
|
262
|
+
selector: '[rxapChipListIterator]',
|
|
263
|
+
standalone: true,
|
|
264
|
+
}]
|
|
265
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: i2$1.NgControl }, { type: i0.IterableDiffers }] });
|
|
266
|
+
|
|
267
|
+
class CompareWithDirective {
|
|
268
|
+
constructor(matSelect) {
|
|
269
|
+
this.matSelect = matSelect;
|
|
270
|
+
}
|
|
271
|
+
ngOnInit() {
|
|
272
|
+
this.matSelect.compareWith = this.compareWith.bind(this);
|
|
273
|
+
}
|
|
274
|
+
compareWith(o1, o2) {
|
|
275
|
+
if (this.objectPath) {
|
|
276
|
+
if (typeof o1 !== 'object' || typeof o2 !== 'object') {
|
|
277
|
+
if (isDevMode()) {
|
|
278
|
+
console.warn('At least one of the select options value is not an object');
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (o1 === null || o1 === undefined || o2 === null || o2 === undefined) {
|
|
283
|
+
if (isDevMode()) {
|
|
284
|
+
console.warn('At least one of the select options value is undefined or null');
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const o1Value = getFromObject(o1, this.objectPath);
|
|
289
|
+
const o2Value = getFromObject(o2, this.objectPath);
|
|
290
|
+
if (o1Value === undefined || o2Value === undefined) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
return o1Value === o2Value;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
return equals(o1, o2);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: CompareWithDirective, deps: [{ token: MatSelect }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
300
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: CompareWithDirective, isStandalone: true, selector: "mat-select[rxapCompareWith]", inputs: { objectPath: ["rxapCompareWith", "objectPath"] }, ngImport: i0 }); }
|
|
301
|
+
}
|
|
302
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: CompareWithDirective, decorators: [{
|
|
303
|
+
type: Directive,
|
|
304
|
+
args: [{
|
|
305
|
+
selector: 'mat-select[rxapCompareWith]',
|
|
306
|
+
standalone: true,
|
|
307
|
+
}]
|
|
308
|
+
}], ctorParameters: () => [{ type: i1$2.MatSelect, decorators: [{
|
|
309
|
+
type: Inject,
|
|
310
|
+
args: [MatSelect]
|
|
311
|
+
}] }], propDecorators: { objectPath: [{
|
|
312
|
+
type: Input,
|
|
313
|
+
args: ['rxapCompareWith']
|
|
314
|
+
}] } });
|
|
28
315
|
|
|
29
316
|
class ControlErrorDirective {
|
|
30
317
|
constructor(formField, template, viewContainerRef, cdr) {
|
|
@@ -69,16 +356,16 @@ class ControlErrorDirective {
|
|
|
69
356
|
}
|
|
70
357
|
this.cdr.detectChanges();
|
|
71
358
|
}
|
|
72
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
73
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
359
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ControlErrorDirective, deps: [{ token: MAT_FORM_FIELD }, { token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
360
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: ControlErrorDirective, isStandalone: true, selector: "[rxapControlError]", inputs: { key: ["rxapControlErrorKey", "key"] }, ngImport: i0 }); }
|
|
74
361
|
}
|
|
75
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
362
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ControlErrorDirective, decorators: [{
|
|
76
363
|
type: Directive,
|
|
77
364
|
args: [{
|
|
78
365
|
selector: '[rxapControlError]',
|
|
79
366
|
standalone: true,
|
|
80
367
|
}]
|
|
81
|
-
}], ctorParameters:
|
|
368
|
+
}], ctorParameters: () => [{ type: i1$3.MatFormField, decorators: [{
|
|
82
369
|
type: Inject,
|
|
83
370
|
args: [MAT_FORM_FIELD]
|
|
84
371
|
}] }, { type: i0.TemplateRef, decorators: [{
|
|
@@ -90,7 +377,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
90
377
|
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
91
378
|
type: Inject,
|
|
92
379
|
args: [ChangeDetectorRef]
|
|
93
|
-
}] }]
|
|
380
|
+
}] }], propDecorators: { key: [{
|
|
94
381
|
type: Input,
|
|
95
382
|
args: [{
|
|
96
383
|
required: true,
|
|
@@ -136,16 +423,16 @@ class ControlErrorsDirective {
|
|
|
136
423
|
}
|
|
137
424
|
this.cdr.detectChanges();
|
|
138
425
|
}
|
|
139
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
140
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
426
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ControlErrorsDirective, deps: [{ token: MAT_FORM_FIELD }, { token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
427
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: ControlErrorsDirective, isStandalone: true, selector: "[rxapControlErrors]", ngImport: i0 }); }
|
|
141
428
|
}
|
|
142
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
429
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: ControlErrorsDirective, decorators: [{
|
|
143
430
|
type: Directive,
|
|
144
431
|
args: [{
|
|
145
432
|
selector: '[rxapControlErrors]',
|
|
146
433
|
standalone: true,
|
|
147
434
|
}]
|
|
148
|
-
}], ctorParameters:
|
|
435
|
+
}], ctorParameters: () => [{ type: i1$3.MatFormField, decorators: [{
|
|
149
436
|
type: Inject,
|
|
150
437
|
args: [MAT_FORM_FIELD]
|
|
151
438
|
}] }, { type: i0.TemplateRef, decorators: [{
|
|
@@ -153,142 +440,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
153
440
|
args: [TemplateRef]
|
|
154
441
|
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
155
442
|
type: Inject,
|
|
156
|
-
args: [ViewContainerRef]
|
|
157
|
-
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
158
|
-
type: Inject,
|
|
159
|
-
args: [ChangeDetectorRef]
|
|
160
|
-
}] }]
|
|
161
|
-
|
|
162
|
-
class InputClearButtonDirective {
|
|
163
|
-
constructor(formField) {
|
|
164
|
-
this.formField = formField;
|
|
165
|
-
this.type = 'button';
|
|
166
|
-
this.tabIndex = '-1';
|
|
167
|
-
}
|
|
168
|
-
get control() {
|
|
169
|
-
return this.formField._control;
|
|
170
|
-
}
|
|
171
|
-
get isDisabled() {
|
|
172
|
-
return this.control.disabled;
|
|
173
|
-
}
|
|
174
|
-
onClick() {
|
|
175
|
-
if (this.control.ngControl) {
|
|
176
|
-
if (this.control.ngControl.control) {
|
|
177
|
-
this.control.ngControl.control.setValue(null);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
this.control.ngControl.reset();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
console.log('InputClearButtonDirective.onClick', 'value = null');
|
|
185
|
-
this.control.value = null;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InputClearButtonDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
189
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: InputClearButtonDirective, isStandalone: true, selector: "[rxapInputClearButton]", host: { listeners: { "click": "onClick()" }, properties: { "attr.type": "this.type", "attr.tabindex": "this.tabIndex", "disabled": "this.isDisabled" } }, ngImport: i0 }); }
|
|
190
|
-
}
|
|
191
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InputClearButtonDirective, decorators: [{
|
|
192
|
-
type: Directive,
|
|
193
|
-
args: [{
|
|
194
|
-
selector: '[rxapInputClearButton]',
|
|
195
|
-
standalone: true,
|
|
196
|
-
}]
|
|
197
|
-
}], ctorParameters: function () { return [{ type: i1.MatFormField, decorators: [{
|
|
198
|
-
type: Inject,
|
|
199
|
-
args: [MAT_FORM_FIELD]
|
|
200
|
-
}] }]; }, propDecorators: { type: [{
|
|
201
|
-
type: HostBinding,
|
|
202
|
-
args: ['attr.type']
|
|
203
|
-
}], tabIndex: [{
|
|
204
|
-
type: HostBinding,
|
|
205
|
-
args: ['attr.tabindex']
|
|
206
|
-
}], isDisabled: [{
|
|
207
|
-
type: HostBinding,
|
|
208
|
-
args: ['disabled']
|
|
209
|
-
}], onClick: [{
|
|
210
|
-
type: HostListener,
|
|
211
|
-
args: ['click']
|
|
212
|
-
}] } });
|
|
213
|
-
|
|
214
|
-
class RequiredDirective {
|
|
215
|
-
constructor(formField) {
|
|
216
|
-
this.formField = formField;
|
|
217
|
-
}
|
|
218
|
-
ngAfterContentInit() {
|
|
219
|
-
const control = this.formField._control.ngControl?.control;
|
|
220
|
-
if (control) {
|
|
221
|
-
const hasRequiredValidator = Reflect.get(control, 'hasRequiredValidator');
|
|
222
|
-
if (hasRequiredValidator) {
|
|
223
|
-
this.formField._control.required = true;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
throw new Error('The form field has not a control associated!');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RequiredDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
231
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: RequiredDirective, isStandalone: true, selector: "[formControlName][rxapRequired],[formControl][rxapRequired]", ngImport: i0 }); }
|
|
232
|
-
}
|
|
233
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RequiredDirective, decorators: [{
|
|
234
|
-
type: Directive,
|
|
235
|
-
args: [{
|
|
236
|
-
selector: '[formControlName][rxapRequired],[formControl][rxapRequired]',
|
|
237
|
-
standalone: true,
|
|
238
|
-
}]
|
|
239
|
-
}], ctorParameters: function () { return [{ type: i1.MatFormField, decorators: [{
|
|
240
|
-
type: Inject,
|
|
241
|
-
args: [MAT_FORM_FIELD]
|
|
242
|
-
}] }]; } });
|
|
243
|
-
|
|
244
|
-
class CompareWithDirective {
|
|
245
|
-
constructor(matSelect) {
|
|
246
|
-
this.matSelect = matSelect;
|
|
247
|
-
}
|
|
248
|
-
ngOnInit() {
|
|
249
|
-
this.matSelect.compareWith = this.compareWith.bind(this);
|
|
250
|
-
}
|
|
251
|
-
compareWith(o1, o2) {
|
|
252
|
-
if (this.objectPath) {
|
|
253
|
-
if (typeof o1 !== 'object' || typeof o2 !== 'object') {
|
|
254
|
-
if (isDevMode()) {
|
|
255
|
-
console.warn('At least one of the select options value is not an object');
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
if (o1 === null || o1 === undefined || o2 === null || o2 === undefined) {
|
|
260
|
-
if (isDevMode()) {
|
|
261
|
-
console.warn('At least one of the select options value is undefined or null');
|
|
262
|
-
}
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
const o1Value = getFromObject(o1, this.objectPath);
|
|
266
|
-
const o2Value = getFromObject(o2, this.objectPath);
|
|
267
|
-
if (o1Value === undefined || o2Value === undefined) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
return o1Value === o2Value;
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
return equals(o1, o2);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CompareWithDirective, deps: [{ token: MatSelect }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
277
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: CompareWithDirective, isStandalone: true, selector: "mat-select[rxapCompareWith]", inputs: { objectPath: ["rxapCompareWith", "objectPath"] }, ngImport: i0 }); }
|
|
278
|
-
}
|
|
279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CompareWithDirective, decorators: [{
|
|
280
|
-
type: Directive,
|
|
281
|
-
args: [{
|
|
282
|
-
selector: 'mat-select[rxapCompareWith]',
|
|
283
|
-
standalone: true,
|
|
284
|
-
}]
|
|
285
|
-
}], ctorParameters: function () { return [{ type: i1$1.MatSelect, decorators: [{
|
|
286
|
-
type: Inject,
|
|
287
|
-
args: [MatSelect]
|
|
288
|
-
}] }]; }, propDecorators: { objectPath: [{
|
|
289
|
-
type: Input,
|
|
290
|
-
args: ['rxapCompareWith']
|
|
291
|
-
}] } });
|
|
443
|
+
args: [ViewContainerRef]
|
|
444
|
+
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
445
|
+
type: Inject,
|
|
446
|
+
args: [ChangeDetectorRef]
|
|
447
|
+
}] }] });
|
|
292
448
|
|
|
293
449
|
class ExtractHideShowMixin {
|
|
294
450
|
extractOptions(formDefinition = this.formDefinition, controlId = this.control?.controlId ?? this.controlId) {
|
|
@@ -392,8 +548,8 @@ let FormFieldHideShowDirective = class FormFieldHideShowDirective {
|
|
|
392
548
|
reset() {
|
|
393
549
|
this.renderer.removeStyle(this.elementRef.nativeElement, 'display');
|
|
394
550
|
}
|
|
395
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
396
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
551
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: FormFieldHideShowDirective, deps: [{ token: MAT_FORM_FIELD }, { token: Renderer2 }, { token: ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
552
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: FormFieldHideShowDirective, isStandalone: true, selector: "mat-form-field[rxapHideShow]", ngImport: i0 }); }
|
|
397
553
|
};
|
|
398
554
|
FormFieldHideShowDirective = __decorate([
|
|
399
555
|
Mixin(ExtractHideShowMixin, ExtractFormDefinitionMixin),
|
|
@@ -401,13 +557,13 @@ FormFieldHideShowDirective = __decorate([
|
|
|
401
557
|
Renderer2,
|
|
402
558
|
ElementRef])
|
|
403
559
|
], FormFieldHideShowDirective);
|
|
404
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
560
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: FormFieldHideShowDirective, decorators: [{
|
|
405
561
|
type: Directive,
|
|
406
562
|
args: [{
|
|
407
563
|
selector: 'mat-form-field[rxapHideShow]',
|
|
408
564
|
standalone: true,
|
|
409
565
|
}]
|
|
410
|
-
}], ctorParameters:
|
|
566
|
+
}], ctorParameters: () => [{ type: i1$3.MatFormField, decorators: [{
|
|
411
567
|
type: Inject,
|
|
412
568
|
args: [MAT_FORM_FIELD]
|
|
413
569
|
}] }, { type: i0.Renderer2, decorators: [{
|
|
@@ -416,249 +572,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
416
572
|
}] }, { type: i0.ElementRef, decorators: [{
|
|
417
573
|
type: Inject,
|
|
418
574
|
args: [ElementRef]
|
|
419
|
-
}] }]
|
|
575
|
+
}] }] });
|
|
420
576
|
|
|
421
|
-
class
|
|
422
|
-
constructor(
|
|
423
|
-
this.
|
|
424
|
-
this.
|
|
425
|
-
this.
|
|
426
|
-
this.router = router;
|
|
427
|
-
this.invalid = false;
|
|
428
|
-
this.close = new EventEmitter();
|
|
429
|
-
this.submitted = new EventEmitter();
|
|
430
|
-
this.isDevMode = isDevMode();
|
|
431
|
-
/**
|
|
432
|
-
* Collection of successful submitted values
|
|
433
|
-
* @private
|
|
434
|
-
*/
|
|
435
|
-
this._submitted = [];
|
|
436
|
-
this._allowResubmit = false;
|
|
437
|
-
}
|
|
438
|
-
get allowResubmit() {
|
|
439
|
-
return this._allowResubmit;
|
|
440
|
-
}
|
|
441
|
-
set allowResubmit(value) {
|
|
442
|
-
this._allowResubmit = coerceBoolean(value);
|
|
443
|
-
}
|
|
444
|
-
ngOnInit() {
|
|
445
|
-
this.submitting$ = this.formDirective.submitting$;
|
|
446
|
-
this.close
|
|
447
|
-
.pipe(take(1), tap(() => {
|
|
448
|
-
if (this.navigateAfterSubmit) {
|
|
449
|
-
if (this.router) {
|
|
450
|
-
return this.router.navigate(this.navigateAfterSubmit);
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
console.warn('The Router is not available. Ensure that tha RouterModule is imported');
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
return Promise.resolve();
|
|
457
|
-
}))
|
|
458
|
-
.subscribe();
|
|
577
|
+
class InputClearButtonDirective {
|
|
578
|
+
constructor(formField) {
|
|
579
|
+
this.formField = formField;
|
|
580
|
+
this.type = 'button';
|
|
581
|
+
this.tabIndex = '-1';
|
|
459
582
|
}
|
|
460
|
-
|
|
461
|
-
this.
|
|
462
|
-
this.formDirective.reset();
|
|
583
|
+
get control() {
|
|
584
|
+
return this.formField._control;
|
|
463
585
|
}
|
|
464
|
-
|
|
465
|
-
this.
|
|
586
|
+
get isDisabled() {
|
|
587
|
+
return this.control.disabled;
|
|
466
588
|
}
|
|
467
|
-
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// eslint-disable-next-line prefer-const
|
|
472
|
-
let submitSubscription;
|
|
473
|
-
const invalidSubmitSubscription = this.formDirective.invalidSubmit
|
|
474
|
-
.pipe(take(1), tap(() => 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 })))
|
|
475
|
-
.subscribe();
|
|
476
|
-
submitSubscription = this.formDirective.rxapSubmit
|
|
477
|
-
.pipe(take(1), tap((value) => {
|
|
478
|
-
const clonedValue = clone(value);
|
|
479
|
-
this._submitted.push(clonedValue);
|
|
480
|
-
this.submitted.emit(clonedValue);
|
|
481
|
-
if (closeAfterSubmit) {
|
|
482
|
-
this.close.emit(this._submitted.length > 1 ? this._submitted : this._submitted[0]);
|
|
589
|
+
onClick() {
|
|
590
|
+
if (this.control.ngControl) {
|
|
591
|
+
if (this.control.ngControl.control) {
|
|
592
|
+
this.control.ngControl.control.setValue(null);
|
|
483
593
|
}
|
|
484
594
|
else {
|
|
485
|
-
|
|
486
|
-
this.formDirective.formDefinition.rxapReuse();
|
|
487
|
-
}
|
|
595
|
+
this.control.ngControl.reset();
|
|
488
596
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
this.formDirective.onSubmit(new Event('submit'));
|
|
495
|
-
}
|
|
496
|
-
logCurrentFormState() {
|
|
497
|
-
console.log(clone(this.formDirective.form.value));
|
|
498
|
-
}
|
|
499
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FormControlsComponent, deps: [{ token: FormDirective }, { token: ChangeDetectorRef }, { token: MatSnackBar }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
500
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: FormControlsComponent, isStandalone: true, selector: "rxap-form-controls", inputs: { navigateAfterSubmit: "navigateAfterSubmit", allowResubmit: "allowResubmit" }, outputs: { close: "close", submitted: "submitted" }, ngImport: i0, template: "<div class=\"flex flex-row justify-between items-center gap-8\">\n <div class=\"flex grow-0 flex-row justify-end items-center gap-8 w-full\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n color=\"warn\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"submit(true)\" *ngIf=\"allowResubmit\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit and Close</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"logCurrentFormState()\" *ngIf=\"isDevMode\" mat-button type=\"button\" class=\"grow-0\">\n Current Form State\n </button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1$2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i2.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "ngmodule", type: MatSnackBarModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
501
|
-
}
|
|
502
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FormControlsComponent, decorators: [{
|
|
503
|
-
type: Component,
|
|
504
|
-
args: [{ selector: 'rxap-form-controls', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
505
|
-
MatButtonModule,
|
|
506
|
-
NgClass,
|
|
507
|
-
MatProgressSpinnerModule,
|
|
508
|
-
NgIf,
|
|
509
|
-
AsyncPipe,
|
|
510
|
-
MatSnackBarModule,
|
|
511
|
-
], template: "<div class=\"flex flex-row justify-between items-center gap-8\">\n <div class=\"flex grow-0 flex-row justify-end items-center gap-8 w-full\">\n <button (click)=\"reset()\"\n [disabled]=\"submitting$ | async\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\"\n [disabled]=\"submitting$ | async\"\n color=\"warn\"\n class=\"grow-0\"\n mat-stroked-button\n type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"submit(!allowResubmit)\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"submit(true)\" *ngIf=\"allowResubmit\"\n [disabled]=\"submitting$ | async\"\n [ngClass]=\"{ invalid: invalid }\"\n color=\"primary\"\n class=\"grow-0\"\n mat-raised-button\n type=\"button\">\n <span class=\"flex flex-row items-center gap-2\">\n <span class=\"grow-0\">\n <ng-container i18n>Submit and Close</ng-container>\n </span>\n <mat-spinner [diameter]=\"15\" *ngIf=\"submitting$ | async\" color=\"accent\" class=\"grow-0\"\n mode=\"indeterminate\"></mat-spinner>\n </span>\n </button>\n <button (click)=\"logCurrentFormState()\" *ngIf=\"isDevMode\" mat-button type=\"button\" class=\"grow-0\">\n Current Form State\n </button>\n </div>\n</div>\n", styles: ["button{overflow:hidden}button.invalid{border:6px solid darkred}\n"] }]
|
|
512
|
-
}], ctorParameters: function () { return [{ type: i3.FormDirective, decorators: [{
|
|
513
|
-
type: Inject,
|
|
514
|
-
args: [FormDirective]
|
|
515
|
-
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
516
|
-
type: Inject,
|
|
517
|
-
args: [ChangeDetectorRef]
|
|
518
|
-
}] }, { type: i4.MatSnackBar, decorators: [{
|
|
519
|
-
type: Inject,
|
|
520
|
-
args: [MatSnackBar]
|
|
521
|
-
}] }, { type: i5.Router, decorators: [{
|
|
522
|
-
type: Optional
|
|
523
|
-
}, {
|
|
524
|
-
type: Inject,
|
|
525
|
-
args: [Router]
|
|
526
|
-
}] }]; }, propDecorators: { navigateAfterSubmit: [{
|
|
527
|
-
type: Input
|
|
528
|
-
}], close: [{
|
|
529
|
-
type: Output
|
|
530
|
-
}], submitted: [{
|
|
531
|
-
type: Output
|
|
532
|
-
}], allowResubmit: [{
|
|
533
|
-
type: Input
|
|
534
|
-
}] } });
|
|
535
|
-
|
|
536
|
-
class ChipInputAdapterDirective {
|
|
537
|
-
constructor(matChipInput, ngControl) {
|
|
538
|
-
this.matChipInput = matChipInput;
|
|
539
|
-
this.ngControl = ngControl;
|
|
540
|
-
this.matChipInput.separatorKeyCodes = [ENTER, COMMA];
|
|
541
|
-
this.matChipInput.addOnBlur = true;
|
|
542
|
-
}
|
|
543
|
-
ngOnDestroy() {
|
|
544
|
-
this._subscription?.unsubscribe();
|
|
545
|
-
}
|
|
546
|
-
ngOnInit() {
|
|
547
|
-
this._subscription = this.matChipInput.chipEnd
|
|
548
|
-
.pipe(filter((add) => !!add.value?.trim()), tap((add) => {
|
|
549
|
-
const value = this.ngControl.value ?? [];
|
|
550
|
-
this.ngControl.control?.setValue([...value, add.value].filter(unique()));
|
|
551
|
-
this.matChipInput.clear();
|
|
552
|
-
}))
|
|
553
|
-
.subscribe();
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
console.log('InputClearButtonDirective.onClick', 'value = null');
|
|
600
|
+
this.control.value = null;
|
|
601
|
+
}
|
|
554
602
|
}
|
|
555
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
556
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
603
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: InputClearButtonDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
604
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: InputClearButtonDirective, isStandalone: true, selector: "[rxapInputClearButton]", host: { listeners: { "click": "onClick()" }, properties: { "attr.type": "this.type", "attr.tabindex": "this.tabIndex", "disabled": "this.isDisabled" } }, ngImport: i0 }); }
|
|
557
605
|
}
|
|
558
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
606
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: InputClearButtonDirective, decorators: [{
|
|
559
607
|
type: Directive,
|
|
560
608
|
args: [{
|
|
561
|
-
selector: '[
|
|
609
|
+
selector: '[rxapInputClearButton]',
|
|
562
610
|
standalone: true,
|
|
563
611
|
}]
|
|
564
|
-
}], ctorParameters:
|
|
612
|
+
}], ctorParameters: () => [{ type: i1$3.MatFormField, decorators: [{
|
|
613
|
+
type: Inject,
|
|
614
|
+
args: [MAT_FORM_FIELD]
|
|
615
|
+
}] }], propDecorators: { type: [{
|
|
616
|
+
type: HostBinding,
|
|
617
|
+
args: ['attr.type']
|
|
618
|
+
}], tabIndex: [{
|
|
619
|
+
type: HostBinding,
|
|
620
|
+
args: ['attr.tabindex']
|
|
621
|
+
}], isDisabled: [{
|
|
622
|
+
type: HostBinding,
|
|
623
|
+
args: ['disabled']
|
|
624
|
+
}], onClick: [{
|
|
625
|
+
type: HostListener,
|
|
626
|
+
args: ['click']
|
|
627
|
+
}] } });
|
|
565
628
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
class RecordViewTuple {
|
|
570
|
-
constructor(record, view) {
|
|
571
|
-
this.record = record;
|
|
572
|
-
this.view = view;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
class ChipListIteratorDirective {
|
|
576
|
-
constructor(template, viewContainerRef, ngControl, differs) {
|
|
577
|
-
this.template = template;
|
|
578
|
-
this.viewContainerRef = viewContainerRef;
|
|
579
|
-
this.ngControl = ngControl;
|
|
580
|
-
this.differs = differs;
|
|
581
|
-
this._dirty = true;
|
|
582
|
-
this._differ = null;
|
|
583
|
-
}
|
|
584
|
-
ngOnInit() {
|
|
585
|
-
this._subscription = this.ngControl.valueChanges
|
|
586
|
-
?.pipe(startWith(this.ngControl.value), filter((value) => Array.isArray(value)), tap((items) => {
|
|
587
|
-
this._dirty = false;
|
|
588
|
-
// React on ngForOf changes only once all inputs have been initialized
|
|
589
|
-
const value = items;
|
|
590
|
-
if (!this._differ && value) {
|
|
591
|
-
try {
|
|
592
|
-
this._differ = this.differs.find(value).create((_, item) => item);
|
|
593
|
-
}
|
|
594
|
-
catch {
|
|
595
|
-
throw new Error(`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
if (this._differ) {
|
|
599
|
-
const changes = this._differ.diff(items);
|
|
600
|
-
if (changes) {
|
|
601
|
-
this.applyChanges(changes);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}))
|
|
605
|
-
.subscribe();
|
|
606
|
-
}
|
|
607
|
-
ngOnDestroy() {
|
|
608
|
-
this._subscription?.unsubscribe();
|
|
629
|
+
class RequiredDirective {
|
|
630
|
+
constructor(formField) {
|
|
631
|
+
this.formField = formField;
|
|
609
632
|
}
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
// there is an iterable value for "_ngForOf".
|
|
617
|
-
const view = this.viewContainerRef.createEmbeddedView(this.template, {
|
|
618
|
-
$implicit: item.item,
|
|
619
|
-
onRemoved: this.onRemoved.bind(this),
|
|
620
|
-
}, currentIndex === null ? undefined : currentIndex);
|
|
621
|
-
const tuple = new RecordViewTuple(item, view);
|
|
622
|
-
insertTuples.push(tuple);
|
|
623
|
-
}
|
|
624
|
-
else if (currentIndex == null) {
|
|
625
|
-
this.viewContainerRef.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
|
|
626
|
-
}
|
|
627
|
-
else if (adjustedPreviousIndex !== null) {
|
|
628
|
-
const view = this.viewContainerRef.get(adjustedPreviousIndex);
|
|
629
|
-
this.viewContainerRef.move(view, currentIndex);
|
|
630
|
-
const tuple = new RecordViewTuple(item, view);
|
|
631
|
-
insertTuples.push(tuple);
|
|
633
|
+
ngAfterContentInit() {
|
|
634
|
+
const control = this.formField._control.ngControl?.control;
|
|
635
|
+
if (control) {
|
|
636
|
+
const hasRequiredValidator = Reflect.get(control, 'hasRequiredValidator');
|
|
637
|
+
if (hasRequiredValidator) {
|
|
638
|
+
this.formField._control.required = true;
|
|
632
639
|
}
|
|
633
|
-
});
|
|
634
|
-
for (let i = 0; i < insertTuples.length; i++) {
|
|
635
|
-
this.perViewChange(insertTuples[i].view, insertTuples[i].record);
|
|
636
640
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
onRemoved($event) {
|
|
643
|
-
this.ngControl.control?.setValue((this.ngControl.value ?? []).filter((item) => item !== $event.chip.value));
|
|
644
|
-
}
|
|
645
|
-
perViewChange(view, record) {
|
|
646
|
-
view.context.$implicit = record.item;
|
|
641
|
+
else {
|
|
642
|
+
throw new Error('The form field has not a control associated!');
|
|
643
|
+
}
|
|
647
644
|
}
|
|
648
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
649
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
645
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: RequiredDirective, deps: [{ token: MAT_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
646
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.3", type: RequiredDirective, isStandalone: true, selector: "[formControlName][rxapRequired],[formControl][rxapRequired]", ngImport: i0 }); }
|
|
650
647
|
}
|
|
651
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
648
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: RequiredDirective, decorators: [{
|
|
652
649
|
type: Directive,
|
|
653
650
|
args: [{
|
|
654
|
-
selector: '[
|
|
651
|
+
selector: '[formControlName][rxapRequired],[formControl][rxapRequired]',
|
|
655
652
|
standalone: true,
|
|
656
653
|
}]
|
|
657
|
-
}], ctorParameters:
|
|
654
|
+
}], ctorParameters: () => [{ type: i1$3.MatFormField, decorators: [{
|
|
655
|
+
type: Inject,
|
|
656
|
+
args: [MAT_FORM_FIELD]
|
|
657
|
+
}] }] });
|
|
658
658
|
|
|
659
659
|
class MaterialFormSystemModule {
|
|
660
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
661
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
660
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: MaterialFormSystemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
661
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.3", ngImport: i0, type: MaterialFormSystemModule, imports: [ControlErrorDirective,
|
|
662
662
|
ControlErrorsDirective,
|
|
663
663
|
InputClearButtonDirective,
|
|
664
664
|
RequiredDirective,
|
|
@@ -667,9 +667,9 @@ class MaterialFormSystemModule {
|
|
|
667
667
|
InputClearButtonDirective,
|
|
668
668
|
RequiredDirective,
|
|
669
669
|
FormFieldHideShowDirective] }); }
|
|
670
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
670
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: MaterialFormSystemModule }); }
|
|
671
671
|
}
|
|
672
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
672
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: MaterialFormSystemModule, decorators: [{
|
|
673
673
|
type: NgModule,
|
|
674
674
|
args: [{
|
|
675
675
|
exports: [
|
|
@@ -689,6 +689,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
689
689
|
}]
|
|
690
690
|
}] });
|
|
691
691
|
|
|
692
|
+
// region form-controls
|
|
693
|
+
// endregion
|
|
694
|
+
|
|
692
695
|
/**
|
|
693
696
|
* Generated bundle index. Do not edit.
|
|
694
697
|
*/
|