@stemy/ngx-dynamic-form 19.5.5 → 19.5.7
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/fesm2022/stemy-ngx-dynamic-form.mjs +59 -44
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +2 -1
- package/ngx-dynamic-form/components/dynamic-form-fieldset/dynamic-form-fieldset.component.d.ts +0 -1
- package/ngx-dynamic-form/directives/async-submit.directive.d.ts +4 -3
- package/ngx-dynamic-form/utils/misc.d.ts +10 -2
- package/package.json +1 -1
- package/public_api.d.ts +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i2 from '@stemy/ngx-utils';
|
|
2
2
|
import { cachedFactory, ReflectUtils, ObjectUtils, LANGUAGE_SERVICE, ForbiddenZone, API_SERVICE, StringUtils, TOASTER_SERVICE, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
3
|
-
import { Observable, firstValueFrom, BehaviorSubject,
|
|
3
|
+
import { of, merge, Observable, firstValueFrom, BehaviorSubject, combineLatestWith, switchMap, distinctUntilChanged, first, Subject } from 'rxjs';
|
|
4
|
+
import { debounceTime } from 'rxjs/operators';
|
|
4
5
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { Inject, Injectable, input, output, inject, Renderer2, ElementRef, computed, signal, effect, HostListener, HostBinding, Directive, Type, Component, Injector, ChangeDetectionStrategy, ViewEncapsulation, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
6
|
+
import { Inject, Injectable, input, output, inject, Renderer2, ElementRef, computed, signal, effect, untracked, HostListener, HostBinding, Directive, Type, Component, Injector, ChangeDetectionStrategy, ViewEncapsulation, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
6
7
|
import * as i1 from '@angular/forms';
|
|
7
8
|
import { FormGroup as FormGroup$1, FormArray as FormArray$1, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
-
import { debounceTime } from 'rxjs/operators';
|
|
9
9
|
import { outputToObservable, toSignal, rxResource } from '@angular/core/rxjs-interop';
|
|
10
10
|
import * as i3 from '@ngx-formly/core';
|
|
11
11
|
import { FieldType, ɵobserve as _observe, FieldArrayType, FieldWrapper, provideFormlyConfig, provideFormlyCore, FormlyModule } from '@ngx-formly/core';
|
|
@@ -221,6 +221,16 @@ function maxValueValidation(max, each) {
|
|
|
221
221
|
function replaceSpecialChars(str, to = "-") {
|
|
222
222
|
return `${str}`.replace(/[&\/\\#, +()$~%.@'":*?<>{}]/g, to);
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Creates a new observable that always starts with the controls current value.
|
|
226
|
+
* @param control AbstractControl to retrieve value changes from
|
|
227
|
+
* @param timeout Additional timeout
|
|
228
|
+
*/
|
|
229
|
+
function controlValues(control, timeout = 500) {
|
|
230
|
+
const initial$ = of(control.value); // Emit immediately
|
|
231
|
+
const changes$ = control.valueChanges.pipe(debounceTime(timeout));
|
|
232
|
+
return merge(initial$, changes$);
|
|
233
|
+
}
|
|
224
234
|
function getFieldByPath(field, path) {
|
|
225
235
|
if (field.path === path) {
|
|
226
236
|
return field;
|
|
@@ -311,8 +321,8 @@ function additionalFieldValues(field, values) {
|
|
|
311
321
|
const additional = field.props?.additional || {};
|
|
312
322
|
setFieldProp(field, "additional", additional);
|
|
313
323
|
}
|
|
314
|
-
const MIN_INPUT_NUM = -
|
|
315
|
-
const MAX_INPUT_NUM =
|
|
324
|
+
const MIN_INPUT_NUM = -1999999999;
|
|
325
|
+
const MAX_INPUT_NUM = 1999999999;
|
|
316
326
|
const EDITOR_FORMATS = ["php", "json", "html", "css", "scss"];
|
|
317
327
|
|
|
318
328
|
class ConfigForSchemaWrap {
|
|
@@ -524,24 +534,34 @@ class DynamicFormBuilderService {
|
|
|
524
534
|
data = data || {};
|
|
525
535
|
const type = `${data.type || "text"}`;
|
|
526
536
|
const autocomplete = data.autocomplete || (type === "password" ? "new-password" : "none");
|
|
527
|
-
|
|
537
|
+
const props = {
|
|
528
538
|
type,
|
|
529
539
|
autocomplete,
|
|
530
540
|
pattern: ObjectUtils.isString(data.pattern) ? data.pattern : "",
|
|
531
541
|
step: data.step,
|
|
532
542
|
cols: data.cols || null,
|
|
533
543
|
rows: data.rows || 10,
|
|
534
|
-
min: isNaN(data.min) ? undefined : data.min,
|
|
535
|
-
max: isNaN(data.max) ? undefined : data.max,
|
|
536
|
-
minLength: isNaN(data.minLength) ? 0 : data.minLength,
|
|
537
|
-
maxLength: isNaN(data.maxLength) ? MAX_INPUT_NUM : data.maxLength,
|
|
538
544
|
placeholder: data.placeholder || "",
|
|
539
545
|
indeterminate: data.indeterminate || false,
|
|
540
546
|
suffix: data.suffix || "",
|
|
541
547
|
attributes: {
|
|
542
548
|
autocomplete
|
|
543
549
|
},
|
|
544
|
-
}
|
|
550
|
+
};
|
|
551
|
+
switch (type) {
|
|
552
|
+
case "number":
|
|
553
|
+
case "integer":
|
|
554
|
+
props.min = isNaN(data.min) ? MIN_INPUT_NUM : data.min;
|
|
555
|
+
props.max = isNaN(data.max) ? MAX_INPUT_NUM : data.max;
|
|
556
|
+
break;
|
|
557
|
+
case "string":
|
|
558
|
+
case "text":
|
|
559
|
+
case "textarea":
|
|
560
|
+
props.minLength = isNaN(data.minLength) ? 0 : data.minLength;
|
|
561
|
+
props.maxLength = isNaN(data.maxLength) ? MAX_INPUT_NUM : data.maxLength;
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
return this.createFormField(key, type === "checkbox" || type === "textarea" ? type : "input", data, props, parent, options);
|
|
545
565
|
}
|
|
546
566
|
createFormSelect(key, data, parent, options) {
|
|
547
567
|
data = data || {};
|
|
@@ -556,12 +576,12 @@ class DynamicFormBuilderService {
|
|
|
556
576
|
onInit: target => {
|
|
557
577
|
const options = data.options(target);
|
|
558
578
|
const root = target.formControl.root;
|
|
559
|
-
target
|
|
579
|
+
setFieldProp(target, "options", options instanceof Observable
|
|
560
580
|
? options
|
|
561
|
-
: root.
|
|
581
|
+
: controlValues(root).pipe(combineLatestWith(this.language), switchMap(async () => {
|
|
562
582
|
const results = await data.options(target) || [];
|
|
563
583
|
return this.fixSelectOptions(target, results);
|
|
564
|
-
}));
|
|
584
|
+
})));
|
|
565
585
|
}
|
|
566
586
|
});
|
|
567
587
|
return field;
|
|
@@ -768,9 +788,7 @@ class DynamicFormBuilderService {
|
|
|
768
788
|
return [`dynamic-form-field`, `dynamic-form-field-${target.key}`, `dynamic-form-${typeName}`].concat(Array.isArray(classes) ? classes : [classes || ""]).filter(c => c?.length > 0).join(" ");
|
|
769
789
|
},
|
|
770
790
|
additional: (target) => {
|
|
771
|
-
|
|
772
|
-
target.props.additional = target.props.additional || {};
|
|
773
|
-
return target.props.additional;
|
|
791
|
+
return target.props?.additional || {};
|
|
774
792
|
},
|
|
775
793
|
path: target => {
|
|
776
794
|
const tp = target.parent;
|
|
@@ -1046,7 +1064,7 @@ class DynamicFormSchemaService {
|
|
|
1046
1064
|
}
|
|
1047
1065
|
getFormEndpointOptions(property, field) {
|
|
1048
1066
|
const root = field.formControl.root;
|
|
1049
|
-
return root.
|
|
1067
|
+
return controlValues(root).pipe(combineLatestWith(this.builder.language), switchMap(async () => {
|
|
1050
1068
|
const entries = Object.entries(root.controls || {});
|
|
1051
1069
|
const endpoint = entries.reduce((res, [key, control]) => {
|
|
1052
1070
|
return this.replaceOptionsEndpoint(res, key, control.value);
|
|
@@ -1082,11 +1100,8 @@ class DynamicFormSchemaService {
|
|
|
1082
1100
|
current = current.parent || current;
|
|
1083
1101
|
}
|
|
1084
1102
|
control = !path ? control : control.get(path);
|
|
1085
|
-
return control.
|
|
1086
|
-
const
|
|
1087
|
-
const finalOpts = isObservable(currentOpts)
|
|
1088
|
-
? await firstValueFrom(currentOpts)
|
|
1089
|
-
: (Array.isArray(currentOpts) ? currentOpts : []);
|
|
1103
|
+
return controlValues(control).pipe(combineLatestWith(this.builder.language), switchMap(async ([ctrlValue]) => {
|
|
1104
|
+
const finalOpts = await getSelectOptions(current);
|
|
1090
1105
|
return this.builder.fixSelectOptions(field, (!Array.isArray(ctrlValue) ? [] : ctrlValue).map(value => {
|
|
1091
1106
|
const modelOption = finalOpts.find(t => t.value == value);
|
|
1092
1107
|
return { value, label: modelOption?.label || value };
|
|
@@ -1320,6 +1335,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1320
1335
|
|
|
1321
1336
|
class AsyncSubmitDirective {
|
|
1322
1337
|
method = input(null, { alias: "async-submit" });
|
|
1338
|
+
mode = input("click");
|
|
1323
1339
|
form = input();
|
|
1324
1340
|
context = input();
|
|
1325
1341
|
onSuccess = output();
|
|
@@ -1344,11 +1360,9 @@ class AsyncSubmitDirective {
|
|
|
1344
1360
|
return this.loading();
|
|
1345
1361
|
}
|
|
1346
1362
|
constructor() {
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1363
|
+
if (this.elem.nativeElement.tagName === "BUTTON") {
|
|
1364
|
+
this.renderer.setAttribute(this.elem.nativeElement, "type", "button");
|
|
1365
|
+
}
|
|
1352
1366
|
effect(() => {
|
|
1353
1367
|
const status = this.status();
|
|
1354
1368
|
const cb = this.callback();
|
|
@@ -1361,7 +1375,8 @@ class AsyncSubmitDirective {
|
|
|
1361
1375
|
});
|
|
1362
1376
|
effect(() => {
|
|
1363
1377
|
const form = this.form();
|
|
1364
|
-
|
|
1378
|
+
const mode = this.mode();
|
|
1379
|
+
if (!form || mode === "click")
|
|
1365
1380
|
return;
|
|
1366
1381
|
const sub = outputToObservable(form.onSubmit)
|
|
1367
1382
|
.pipe(debounceTime(200)).subscribe(() => this.callMethod());
|
|
@@ -1369,7 +1384,10 @@ class AsyncSubmitDirective {
|
|
|
1369
1384
|
});
|
|
1370
1385
|
}
|
|
1371
1386
|
click() {
|
|
1372
|
-
const
|
|
1387
|
+
const mode = untracked(() => this.mode());
|
|
1388
|
+
if (mode === "submit")
|
|
1389
|
+
return;
|
|
1390
|
+
const status = untracked(() => this.status());
|
|
1373
1391
|
if (status !== "VALID" && status !== "INVALID") {
|
|
1374
1392
|
this.callback.set(() => this.callMethod());
|
|
1375
1393
|
return;
|
|
@@ -1377,10 +1395,12 @@ class AsyncSubmitDirective {
|
|
|
1377
1395
|
this.callMethod();
|
|
1378
1396
|
}
|
|
1379
1397
|
callMethod() {
|
|
1380
|
-
|
|
1398
|
+
const loading = untracked(() => this.loading());
|
|
1399
|
+
if (loading)
|
|
1381
1400
|
return;
|
|
1382
1401
|
this.loading.set(true);
|
|
1383
|
-
this.method()
|
|
1402
|
+
const [method, form, context] = untracked(() => [this.method(), this.form(), this.context()]);
|
|
1403
|
+
method(form, context).then(result => {
|
|
1384
1404
|
this.loading.set(false);
|
|
1385
1405
|
if (result) {
|
|
1386
1406
|
this.onSuccess.emit(result);
|
|
@@ -1395,7 +1415,7 @@ class AsyncSubmitDirective {
|
|
|
1395
1415
|
});
|
|
1396
1416
|
}
|
|
1397
1417
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AsyncSubmitDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1398
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.14", type: AsyncSubmitDirective, isStandalone: false, selector: "[async-submit]", inputs: { method: { classPropertyName: "method", publicName: "async-submit", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSuccess: "onSuccess", onError: "onError" }, host: { listeners: { "click": "click()" }, properties: { "class.disabled": "this.isDisabled", "class.loading": "this.isLoading" } }, exportAs: ["async-submit"], ngImport: i0 });
|
|
1418
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.14", type: AsyncSubmitDirective, isStandalone: false, selector: "[async-submit]", inputs: { method: { classPropertyName: "method", publicName: "async-submit", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSuccess: "onSuccess", onError: "onError" }, host: { listeners: { "click": "click()" }, properties: { "class.disabled": "this.isDisabled", "class.loading": "this.isLoading" } }, exportAs: ["async-submit"], ngImport: i0 });
|
|
1399
1419
|
}
|
|
1400
1420
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AsyncSubmitDirective, decorators: [{
|
|
1401
1421
|
type: Directive,
|
|
@@ -1578,8 +1598,7 @@ class DynamicFormComponent {
|
|
|
1578
1598
|
});
|
|
1579
1599
|
}
|
|
1580
1600
|
submit() {
|
|
1581
|
-
|
|
1582
|
-
// this.onSubmit.emit(this);
|
|
1601
|
+
this.onSubmit.emit(this);
|
|
1583
1602
|
}
|
|
1584
1603
|
reset() {
|
|
1585
1604
|
this.options?.resetModel?.();
|
|
@@ -1612,11 +1631,11 @@ class DynamicFormArrayComponent extends FieldArrayType {
|
|
|
1612
1631
|
this.currentTab.set(Math.min(this.currentTab(), length - 1));
|
|
1613
1632
|
}
|
|
1614
1633
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1615
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormArrayComponent, isStandalone: false, selector: "dynamic-form-array", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n @if (props.label && props.hideLabel !== true) {\n <label class=\"field-label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled", "classes"] }, { kind: "component", type: i2.BtnComponent, selector: "btn", inputs: ["label", "tooltip", "icon", "disabled", "type", "size"] }, { kind: "component", type: i2.TabsComponent, selector: "tabs", inputs: ["value", "options", "type", "size"], outputs: ["valueChange"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "pipe", type: i2.GetValuePipe, name: "getValue" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1634
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormArrayComponent, isStandalone: false, selector: "dynamic-form-array", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n @if (props.label && props.hideLabel !== true) {\n <label class=\"field-label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}.form-array-buttons{display:flex;gap:5px;margin-bottom:5px}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled", "classes"] }, { kind: "component", type: i2.BtnComponent, selector: "btn", inputs: ["label", "tooltip", "icon", "disabled", "type", "size"] }, { kind: "component", type: i2.TabsComponent, selector: "tabs", inputs: ["value", "options", "type", "size"], outputs: ["valueChange"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "pipe", type: i2.GetValuePipe, name: "getValue" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1616
1635
|
}
|
|
1617
1636
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
|
|
1618
1637
|
type: Component,
|
|
1619
|
-
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n @if (props.label && props.hideLabel !== true) {\n <label class=\"field-label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}\n"] }]
|
|
1638
|
+
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n @if (props.label && props.hideLabel !== true) {\n <label class=\"field-label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n }\n <div class=\"field-container\">\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (itemField of field.fieldGroup; track itemField.key; let ix = $index) {\n <ng-template #fieldContent>\n <div class=\"form-array-buttons\">\n @if (itemField.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (itemField.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"itemField\"></formly-field>\n </ng-template>\n @if (props.useTabs) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(itemField.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n } @else {\n <div class=\"form-array-item\">\n <ng-container [ngTemplateOutlet]=\"fieldContent\"></ng-container>\n </div>\n }\n }\n </tabs>\n\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <btn icon=\"trash\" label=\"button.clear-items\" (click)=\"clearItems()\"></btn>\n }\n @if (props.addItem) {\n <btn icon=\"plus\" label=\"button.insert-item\" (click)=\"addItem()\"></btn>\n }\n </div>\n </div>\n}\n", styles: [".form-array-item.hidden-tab{display:none}.form-array-buttons{display:flex;gap:5px;margin-bottom:5px}\n"] }]
|
|
1620
1639
|
}] });
|
|
1621
1640
|
|
|
1622
1641
|
class DynamicFormChipsComponent extends DynamicFieldType {
|
|
@@ -1638,16 +1657,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1638
1657
|
}] });
|
|
1639
1658
|
|
|
1640
1659
|
class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
1641
|
-
ngOnInit() {
|
|
1642
|
-
// console.log(this.field.id, this.field.props?.label, this.options);
|
|
1643
|
-
// console.log(this.field.parent);
|
|
1644
|
-
}
|
|
1645
1660
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1646
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormFieldsetComponent, isStandalone: false, selector: "dynamic-form-fieldset", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"props.label && !field.parent.props.useTabs\">\n {{ props.label | translate }}\n </legend>\n <div class=\"field-container\">\n <
|
|
1661
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormFieldsetComponent, isStandalone: false, selector: "dynamic-form-fieldset", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"props.label && !field.parent.props.useTabs\">\n {{ props.label | translate }}\n </legend>\n <div class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField) {\n @if (itemField.display) {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </div>\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.LegacyFormlyField, selector: "formly-field" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1647
1662
|
}
|
|
1648
1663
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, decorators: [{
|
|
1649
1664
|
type: Component,
|
|
1650
|
-
args: [{ standalone: false, selector: "dynamic-form-fieldset", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"props.label && !field.parent.props.useTabs\">\n {{ props.label | translate }}\n </legend>\n <div class=\"field-container\">\n <
|
|
1665
|
+
args: [{ standalone: false, selector: "dynamic-form-fieldset", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n <legend class=\"field-legend\" *ngIf=\"props.label && !field.parent.props.useTabs\">\n {{ props.label | translate }}\n </legend>\n <div class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField) {\n @if (itemField.display) {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </div>\n}\n" }]
|
|
1651
1666
|
}] });
|
|
1652
1667
|
|
|
1653
1668
|
class DynamicFormGroupComponent extends FieldWrapper {
|
|
@@ -1775,5 +1790,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1775
1790
|
* Generated bundle index. Do not edit.
|
|
1776
1791
|
*/
|
|
1777
1792
|
|
|
1778
|
-
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormUploadComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormFile, FormGroup, FormInput, FormModel, FormSelect, FormSerializable, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, addFieldValidators, additionalFieldValue, additionalFieldValues, clearFieldArray, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldProp, translationValidation };
|
|
1793
|
+
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormUploadComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormFile, FormGroup, FormInput, FormModel, FormSelect, FormSerializable, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, addFieldValidators, additionalFieldValue, additionalFieldValues, clearFieldArray, controlValues, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldProp, translationValidation };
|
|
1779
1794
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|