@stemy/ngx-dynamic-form 19.4.9 → 19.4.11
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 +138 -71
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +82 -9
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +2 -1
- package/ngx-dynamic-form/components/dynamic-form-field/dynamic-form-field.component.d.ts +2 -1
- package/ngx-dynamic-form/components/dynamic-form-fieldset/dynamic-form-fieldset.component.d.ts +2 -1
- package/ngx-dynamic-form/components/dynamic-form-group/dynamic-form-group.component.d.ts +2 -1
- package/ngx-dynamic-form/utils/internal.d.ts +2 -1
- package/ngx-dynamic-form/utils/misc.d.ts +6 -1
- package/package.json +2 -2
- package/public_api.d.ts +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
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, distinctUntilChanged, combineLatestWith, switchMap, startWith, isObservable, first, Subject } from 'rxjs';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
4
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';
|
|
5
|
-
import { BehaviorSubject, Observable, distinctUntilChanged, combineLatestWith, switchMap, startWith, isObservable, firstValueFrom, first, Subject } from 'rxjs';
|
|
6
6
|
import * as i1 from '@angular/forms';
|
|
7
7
|
import { FormGroup as FormGroup$1, FormArray as FormArray$1, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
8
|
import { debounceTime } from 'rxjs/operators';
|
|
@@ -211,8 +211,39 @@ function getFieldsByPredicate(field, cb) {
|
|
|
211
211
|
function getFieldsByKey(field, key) {
|
|
212
212
|
return getFieldsByPredicate(field, f => f.key === key);
|
|
213
213
|
}
|
|
214
|
+
async function getSelectOptions(field) {
|
|
215
|
+
const options = field.props?.options || [];
|
|
216
|
+
if (options instanceof Observable) {
|
|
217
|
+
return firstValueFrom(options);
|
|
218
|
+
}
|
|
219
|
+
return options;
|
|
220
|
+
}
|
|
221
|
+
function replaceFieldArray(field, items) {
|
|
222
|
+
const model = field.model || [];
|
|
223
|
+
model.splice(0, model.length, ...items);
|
|
224
|
+
field.options.build(field);
|
|
225
|
+
}
|
|
226
|
+
function clearFieldArray(field) {
|
|
227
|
+
const model = field.model || [];
|
|
228
|
+
model.splice(0, model.length);
|
|
229
|
+
field.options.build(field);
|
|
230
|
+
}
|
|
231
|
+
function insertToFieldArray(field, item, ix) {
|
|
232
|
+
const model = field.model || [];
|
|
233
|
+
ix = ix == null ? model.length : ix;
|
|
234
|
+
model.splice(ix, 0, item);
|
|
235
|
+
field.options.build(field);
|
|
236
|
+
}
|
|
237
|
+
function removeFromFieldArray(field, ix) {
|
|
238
|
+
const model = field.model || [];
|
|
239
|
+
model.splice(ix, 1);
|
|
240
|
+
field.options.build(field);
|
|
241
|
+
}
|
|
214
242
|
function setFieldHidden(field, hidden = true) {
|
|
215
|
-
field.
|
|
243
|
+
field.props = {
|
|
244
|
+
...(field.props || {}),
|
|
245
|
+
hidden
|
|
246
|
+
};
|
|
216
247
|
}
|
|
217
248
|
function setFieldDisabled(field, disabled = true) {
|
|
218
249
|
field.props = {
|
|
@@ -236,9 +267,7 @@ function setFieldHooks(field, hooks) {
|
|
|
236
267
|
});
|
|
237
268
|
}
|
|
238
269
|
function additionalFieldValue(field, path) {
|
|
239
|
-
field.
|
|
240
|
-
field.props.additional = field.props.additional || {};
|
|
241
|
-
return ObjectUtils.getValue(field.props.additional, path, null, false);
|
|
270
|
+
return ObjectUtils.getValue(field.additional, path, null, false);
|
|
242
271
|
}
|
|
243
272
|
function additionalFieldValues(field, values) {
|
|
244
273
|
field.props = field.props || {};
|
|
@@ -323,6 +352,17 @@ function findRefs(property) {
|
|
|
323
352
|
: [property.items?.$ref, property.$ref].filter(isStringWithVal);
|
|
324
353
|
return refs.map(t => t.split("/").pop());
|
|
325
354
|
}
|
|
355
|
+
function arrayItemActionToExpression(action) {
|
|
356
|
+
const cb = action === false
|
|
357
|
+
? () => false
|
|
358
|
+
: (ObjectUtils.isFunction(action) ? action : () => true);
|
|
359
|
+
return (field) => {
|
|
360
|
+
// Needed to immediately reflect the changes on the view
|
|
361
|
+
field.options.detectChanges(field);
|
|
362
|
+
// Returns the actual calculated value
|
|
363
|
+
return cb(field.formControl?.value, Number(field.key), field);
|
|
364
|
+
};
|
|
365
|
+
}
|
|
326
366
|
function mergeFormFields(formFields) {
|
|
327
367
|
const res = [];
|
|
328
368
|
for (const formModel of formFields) {
|
|
@@ -406,9 +446,8 @@ class DynamicFormBuilderService {
|
|
|
406
446
|
return true;
|
|
407
447
|
});
|
|
408
448
|
for (const field of fields) {
|
|
409
|
-
const fsName =
|
|
410
|
-
// If we have a fieldset name defined
|
|
411
|
-
// then push the property fields into a group
|
|
449
|
+
const fsName = String(field.fieldSet || "");
|
|
450
|
+
// If we have a fieldset name defined, then push the property fields into a group
|
|
412
451
|
if (fsName) {
|
|
413
452
|
const fsId = !parent?.path ? fsName : `${parent.path}.${fsName}`;
|
|
414
453
|
const group = groups[fsId] || [];
|
|
@@ -427,10 +466,12 @@ class DynamicFormBuilderService {
|
|
|
427
466
|
parent,
|
|
428
467
|
fieldGroup: groups[id],
|
|
429
468
|
wrappers: ["form-fieldset"],
|
|
430
|
-
className: `dynamic-form-fieldset dynamic-form-fieldset-${id}`,
|
|
431
469
|
props: {
|
|
432
470
|
label: this.getLabel(key, key, parent, options),
|
|
433
|
-
hidden: false
|
|
471
|
+
hidden: false,
|
|
472
|
+
additional: {
|
|
473
|
+
className: `dynamic-form-fieldset dynamic-form-fieldset-${id}`
|
|
474
|
+
}
|
|
434
475
|
},
|
|
435
476
|
hooks: {},
|
|
436
477
|
expressions: {}
|
|
@@ -507,7 +548,9 @@ class DynamicFormBuilderService {
|
|
|
507
548
|
}
|
|
508
549
|
createFormGroup(key, fields, data, parent, options) {
|
|
509
550
|
data = data || {};
|
|
510
|
-
const group = this.createFormField(key, undefined, data, {
|
|
551
|
+
const group = this.createFormField(key, undefined, data, {
|
|
552
|
+
useTabs: data.useTabs === true
|
|
553
|
+
}, parent, options);
|
|
511
554
|
group.wrappers = ["form-group"];
|
|
512
555
|
const result = fields(group);
|
|
513
556
|
const handleGroup = (fieldGroup) => {
|
|
@@ -526,22 +569,29 @@ class DynamicFormBuilderService {
|
|
|
526
569
|
useTabs: data.useTabs === true,
|
|
527
570
|
tabsLabel: `${data.tabsLabel || "label"}`,
|
|
528
571
|
addItem: data.addItem !== false,
|
|
529
|
-
insertItem: data.insertItem !== false,
|
|
530
|
-
cloneItem: data.cloneItem !== false,
|
|
531
|
-
moveItem: data.moveItem !== false,
|
|
532
|
-
removeItem: data.removeItem !== false,
|
|
533
572
|
clearItems: data.clearItems !== false
|
|
534
573
|
}, parent, options);
|
|
535
574
|
const result = fields(array);
|
|
536
575
|
const handleItems = (items) => {
|
|
576
|
+
const expressions = {
|
|
577
|
+
insertItem: arrayItemActionToExpression(data.insertItem),
|
|
578
|
+
cloneItem: arrayItemActionToExpression(data.cloneItem),
|
|
579
|
+
moveItem: arrayItemActionToExpression(data.moveItem),
|
|
580
|
+
removeItem: arrayItemActionToExpression(data.removeItem)
|
|
581
|
+
};
|
|
537
582
|
if (Array.isArray(items)) {
|
|
538
583
|
array.fieldArray = {
|
|
539
584
|
wrappers: ["form-group"],
|
|
540
|
-
className: "dynamic-form-field dynamic-form-group",
|
|
541
585
|
fieldGroup: items,
|
|
586
|
+
props: {
|
|
587
|
+
additional: {
|
|
588
|
+
className: "dynamic-form-field dynamic-form-group",
|
|
589
|
+
}
|
|
590
|
+
},
|
|
542
591
|
hooks: {},
|
|
543
|
-
expressions
|
|
592
|
+
expressions
|
|
544
593
|
};
|
|
594
|
+
this.setExpressions(array.fieldArray, options);
|
|
545
595
|
return array;
|
|
546
596
|
}
|
|
547
597
|
const props = items.props || {};
|
|
@@ -559,8 +609,10 @@ class DynamicFormBuilderService {
|
|
|
559
609
|
...items,
|
|
560
610
|
props: {
|
|
561
611
|
...items.props,
|
|
562
|
-
label: ""
|
|
563
|
-
}
|
|
612
|
+
label: "",
|
|
613
|
+
},
|
|
614
|
+
hooks: {},
|
|
615
|
+
expressions
|
|
564
616
|
};
|
|
565
617
|
return array;
|
|
566
618
|
};
|
|
@@ -605,7 +657,6 @@ class DynamicFormBuilderService {
|
|
|
605
657
|
const field = {
|
|
606
658
|
key,
|
|
607
659
|
validators,
|
|
608
|
-
hide: data.hidden === true,
|
|
609
660
|
type: data.componentType || type,
|
|
610
661
|
fieldSet: String(data.fieldSet || ""),
|
|
611
662
|
resetOnHide: false,
|
|
@@ -618,11 +669,14 @@ class DynamicFormBuilderService {
|
|
|
618
669
|
props: {
|
|
619
670
|
...props,
|
|
620
671
|
disabled: data.disabled === true,
|
|
672
|
+
hidden: data.hidden === true,
|
|
621
673
|
formCheck: "nolabel",
|
|
622
674
|
required: !!validators.required,
|
|
623
675
|
label: options.labelCustomizer?.(key, data.label, parent, options.labelPrefix)
|
|
624
676
|
?? this.getLabel(key, data.label, parent, options),
|
|
625
|
-
additional: {
|
|
677
|
+
additional: {
|
|
678
|
+
classes: data.classes || []
|
|
679
|
+
}
|
|
626
680
|
},
|
|
627
681
|
modelOptions: {
|
|
628
682
|
updateOn: "change"
|
|
@@ -631,14 +685,7 @@ class DynamicFormBuilderService {
|
|
|
631
685
|
hooks: {},
|
|
632
686
|
expressions: {
|
|
633
687
|
serializer: () => data.serializer,
|
|
634
|
-
serialize: () => data.serialize
|
|
635
|
-
additional: (target) => target.props.additional,
|
|
636
|
-
className: (target) => {
|
|
637
|
-
const type = ObjectUtils.isConstructor(target.type)
|
|
638
|
-
? `${target.type.name}`.toLowerCase().replace("component", "")
|
|
639
|
-
: `${target.type || "group"}`;
|
|
640
|
-
return target.hide ? `` : [`dynamic-form-field`, `dynamic-form-field-${target.key}`, `dynamic-form-${type}`].concat(Array.isArray(data.classes) ? data.classes : [data.classes || ""]).filter(c => c?.length > 0).join(" ");
|
|
641
|
-
}
|
|
688
|
+
serialize: () => data.serialize
|
|
642
689
|
}
|
|
643
690
|
};
|
|
644
691
|
// Parent object will be available for customizers as a property, until it gets redefined by formly
|
|
@@ -652,18 +699,31 @@ class DynamicFormBuilderService {
|
|
|
652
699
|
}
|
|
653
700
|
setExpressions(field, options) {
|
|
654
701
|
const expressions = {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
702
|
+
display: target => {
|
|
703
|
+
const display = target.props?.hidden !== true;
|
|
704
|
+
if (target.fieldGroup?.length) {
|
|
705
|
+
return display && target.fieldGroup.some(f => f.display);
|
|
706
|
+
}
|
|
707
|
+
return display;
|
|
708
|
+
},
|
|
709
|
+
className: (target) => {
|
|
710
|
+
if (target.display === false) {
|
|
711
|
+
return `dynamic-form-field dynamic-form-hidden`;
|
|
712
|
+
}
|
|
713
|
+
const { classes, className } = target.additional || {};
|
|
714
|
+
if (className) {
|
|
715
|
+
return className;
|
|
665
716
|
}
|
|
666
|
-
|
|
717
|
+
const type = String(target.type || "group").replace("formly-", "");
|
|
718
|
+
const typeName = ObjectUtils.isConstructor(type)
|
|
719
|
+
? `${target.type.name}`.toLowerCase().replace("component", "")
|
|
720
|
+
: type;
|
|
721
|
+
return [`dynamic-form-field`, `dynamic-form-field-${target.key}`, `dynamic-form-${typeName}`].concat(Array.isArray(classes) ? classes : [classes || ""]).filter(c => c?.length > 0).join(" ");
|
|
722
|
+
},
|
|
723
|
+
additional: (target) => {
|
|
724
|
+
target.props = target.props || {};
|
|
725
|
+
target.props.additional = target.props.additional || {};
|
|
726
|
+
return target.props.additional;
|
|
667
727
|
},
|
|
668
728
|
path: target => {
|
|
669
729
|
const tp = target.parent;
|
|
@@ -742,34 +802,32 @@ class DynamicFormSchemaService {
|
|
|
742
802
|
return this.getFormSelectConfig($enum, property, options, parent);
|
|
743
803
|
}
|
|
744
804
|
switch (property.type) {
|
|
745
|
-
case "string":
|
|
746
|
-
case "number":
|
|
747
|
-
case "integer":
|
|
748
|
-
case "textarea":
|
|
749
|
-
// if (this.checkIsEditorProperty(property)) {
|
|
750
|
-
// return this.getFormEditorConfig(property, options, parent);
|
|
751
|
-
// }
|
|
752
|
-
if (property.format == "textarea") {
|
|
753
|
-
return this.getFormTextareaConfig(property, options, parent);
|
|
754
|
-
}
|
|
755
|
-
if (property.format == "date" || property.format == "date-time") {
|
|
756
|
-
return this.getFormDatepickerConfig(property, options, parent);
|
|
757
|
-
}
|
|
758
|
-
return this.getFormInputConfig(property, options, parent);
|
|
759
805
|
// case "object":
|
|
760
806
|
// return this.getFormEditorConfig(property, options, parent);
|
|
807
|
+
case "file":
|
|
808
|
+
case "upload":
|
|
809
|
+
return this.getFormUploadConfig(property, options, parent);
|
|
761
810
|
case "boolean":
|
|
762
811
|
return this.getFormCheckboxConfig(property, options, parent);
|
|
763
812
|
case "array":
|
|
764
813
|
return this.getFormArrayConfig(property, options, parent);
|
|
765
|
-
case "file":
|
|
766
|
-
case "upload":
|
|
767
|
-
return this.getFormUploadConfig(property, options, parent);
|
|
768
814
|
}
|
|
815
|
+
// if (this.checkIsEditorProperty(property)) {
|
|
816
|
+
// return this.getFormEditorConfig(property, options, parent);
|
|
817
|
+
// }
|
|
769
818
|
if (findRefs(property).length > 0) {
|
|
770
819
|
return this.getFormGroupConfig(property, options, parent);
|
|
771
820
|
}
|
|
772
|
-
|
|
821
|
+
if (property.format == "file" || property.format == "upload") {
|
|
822
|
+
return this.getFormUploadConfig(property, options, parent);
|
|
823
|
+
}
|
|
824
|
+
if (property.format == "textarea") {
|
|
825
|
+
return this.getFormTextareaConfig(property, options, parent);
|
|
826
|
+
}
|
|
827
|
+
if (property.format == "date" || property.format == "date-time") {
|
|
828
|
+
return this.getFormDatepickerConfig(property, options, parent);
|
|
829
|
+
}
|
|
830
|
+
return this.getFormInputConfig(property, options, parent);
|
|
773
831
|
}
|
|
774
832
|
getFormFieldData(property, options) {
|
|
775
833
|
const validators = {};
|
|
@@ -1418,6 +1476,7 @@ class DynamicFormComponent {
|
|
|
1418
1476
|
labelPrefix = input("label");
|
|
1419
1477
|
labelCustomizer = input(null);
|
|
1420
1478
|
testId = input("");
|
|
1479
|
+
useTabs = input(false);
|
|
1421
1480
|
data = input({});
|
|
1422
1481
|
fields = input(null);
|
|
1423
1482
|
fieldChanges = new Subject();
|
|
@@ -1428,11 +1487,19 @@ class DynamicFormComponent {
|
|
|
1428
1487
|
initialValue: this.languages.enableTranslations
|
|
1429
1488
|
});
|
|
1430
1489
|
config = computed(() => {
|
|
1431
|
-
|
|
1490
|
+
const options = {
|
|
1432
1491
|
labelPrefix: this.labelPrefix(),
|
|
1433
1492
|
labelCustomizer: this.labelCustomizer(),
|
|
1434
1493
|
testId: this.testId(),
|
|
1435
|
-
}
|
|
1494
|
+
};
|
|
1495
|
+
const fields = this.fields() || this.builder.resolveFormFields(this.data()?.constructor, null, options);
|
|
1496
|
+
return [
|
|
1497
|
+
this.builder.createFormGroup(null, () => fields, {
|
|
1498
|
+
label: "",
|
|
1499
|
+
useTabs: this.useTabs(),
|
|
1500
|
+
hidden: false
|
|
1501
|
+
}, null, options)
|
|
1502
|
+
];
|
|
1436
1503
|
});
|
|
1437
1504
|
group = computed(() => {
|
|
1438
1505
|
this.config();
|
|
@@ -1470,11 +1537,11 @@ class DynamicFormComponent {
|
|
|
1470
1537
|
this.options?.resetModel?.();
|
|
1471
1538
|
}
|
|
1472
1539
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1473
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { labelPrefix: { classPropertyName: "labelPrefix", publicName: "labelPrefix", isSignal: true, isRequired: false, transformFunction: null }, labelCustomizer: { classPropertyName: "labelCustomizer", publicName: "labelCustomizer", isSignal: true, isRequired: false, transformFunction: null }, testId: { classPropertyName: "testId", publicName: "testId", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n", dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LegacyFormlyForm, selector: "formly-form" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1540
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { labelPrefix: { classPropertyName: "labelPrefix", publicName: "labelPrefix", isSignal: true, isRequired: false, transformFunction: null }, labelCustomizer: { classPropertyName: "labelCustomizer", publicName: "labelCustomizer", isSignal: true, isRequired: false, transformFunction: null }, testId: { classPropertyName: "testId", publicName: "testId", isSignal: true, isRequired: false, transformFunction: null }, useTabs: { classPropertyName: "useTabs", publicName: "useTabs", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n", styles: [".dynamic-form-field.dynamic-form-hidden{display:none}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LegacyFormlyForm, selector: "formly-form" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1474
1541
|
}
|
|
1475
1542
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
1476
1543
|
type: Component,
|
|
1477
|
-
args: [{ standalone: false, selector: "dynamic-form", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n" }]
|
|
1544
|
+
args: [{ standalone: false, selector: "dynamic-form", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (config() && group()) {\n <form [formGroup]=\"group()\" (ngSubmit)=\"submit()\" autocomplete=\"off\" role=\"presentation\">\n <input type=\"submit\" [hidden]=\"true\" />\n <formly-form [model]=\"data()\"\n [fields]=\"config()\"\n [form]=\"group()\"\n [options]=\"options\"></formly-form>\n <ng-content></ng-content>\n </form>\n}\n", styles: [".dynamic-form-field.dynamic-form-hidden{display:none}\n"] }]
|
|
1478
1545
|
}], ctorParameters: () => [] });
|
|
1479
1546
|
|
|
1480
1547
|
class DynamicFormArrayComponent extends FieldArrayType {
|
|
@@ -1497,11 +1564,11 @@ class DynamicFormArrayComponent extends FieldArrayType {
|
|
|
1497
1564
|
this.currentTab.set(Math.min(this.currentTab(), length - 1));
|
|
1498
1565
|
}
|
|
1499
1566
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1500
|
-
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: "<label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n</label>\n<div class=\"field-container\">\n
|
|
1567
|
+
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: "<label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n</label>\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", 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 });
|
|
1501
1568
|
}
|
|
1502
1569
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
|
|
1503
1570
|
type: Component,
|
|
1504
|
-
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "<label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n</label>\n<div class=\"field-container\">\n
|
|
1571
|
+
args: [{ standalone: false, selector: "dynamic-form-array", encapsulation: ViewEncapsulation.None, template: "<label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n</label>\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", styles: [".form-array-item.hidden-tab{display:none}\n"] }]
|
|
1505
1572
|
}] });
|
|
1506
1573
|
|
|
1507
1574
|
class DynamicFormChipsComponent extends DynamicFieldType {
|
|
@@ -1515,11 +1582,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1515
1582
|
|
|
1516
1583
|
class DynamicFormFieldComponent extends FieldWrapper {
|
|
1517
1584
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1518
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1585
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormFieldComponent, isStandalone: false, selector: "dynamic-form-field", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n <label class=\"field-label\" [for]=\"id\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n <span class=\"field-required\" *ngIf=\"props.required\" aria-hidden=\"true\">*</span>\n </label>\n <div class=\"field-container\">\n <ng-container #fieldComponent></ng-container>\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </div>\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.LegacyFormlyValidationMessage, selector: "formly-validation-message" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1519
1586
|
}
|
|
1520
1587
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
|
|
1521
1588
|
type: Component,
|
|
1522
|
-
args: [{ standalone: false, selector: "dynamic-form-field", encapsulation: ViewEncapsulation.None, template: "<label class=\"field-label\" [for]=\"id\" *ngIf=\"props.label\">\n
|
|
1589
|
+
args: [{ standalone: false, selector: "dynamic-form-field", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n <label class=\"field-label\" [for]=\"id\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n <span class=\"field-required\" *ngIf=\"props.required\" aria-hidden=\"true\">*</span>\n </label>\n <div class=\"field-container\">\n <ng-container #fieldComponent></ng-container>\n <div *ngIf=\"showError\" class=\"field-errors invalid-feedback\">\n <formly-validation-message\n [field]=\"field\"\n id=\"{{ id }}-formly-validation-error\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n </div>\n}\n" }]
|
|
1523
1590
|
}] });
|
|
1524
1591
|
|
|
1525
1592
|
class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
@@ -1528,20 +1595,20 @@ class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
|
1528
1595
|
// console.log(this.field.parent);
|
|
1529
1596
|
}
|
|
1530
1597
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1531
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1598
|
+
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 <ng-container #fieldComponent></ng-container>\n </div>\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1532
1599
|
}
|
|
1533
1600
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, decorators: [{
|
|
1534
1601
|
type: Component,
|
|
1535
|
-
args: [{ standalone: false, selector: "dynamic-form-fieldset", encapsulation: ViewEncapsulation.None, template: "<legend class=\"field-legend\" *ngIf=\"props.label\">\n
|
|
1602
|
+
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 <ng-container #fieldComponent></ng-container>\n </div>\n}\n" }]
|
|
1536
1603
|
}] });
|
|
1537
1604
|
|
|
1538
1605
|
class DynamicFormGroupComponent extends FieldWrapper {
|
|
1539
1606
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1540
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1607
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: DynamicFormGroupComponent, isStandalone: false, selector: "dynamic-form-group", usesInheritance: true, ngImport: i0, template: "@if (field.display) {\n <label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n <tabs class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField; let ix = $index) {\n @if (props.useTabs && itemField.display && itemField.wrappers | includes: 'form-fieldset') {\n <div class=\"form-fieldset-item\"\n [tabsItem]=\"ix\"\n [label]=\"itemField.props.label\">\n <formly-field [field]=\"itemField\"></formly-field>\n </div>\n } @else {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </tabs>\n}\n", styles: [".form-fieldset-item.hidden-tab{display:none}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled", "classes"] }, { 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.IncludesPipe, name: "includes" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
|
|
1541
1608
|
}
|
|
1542
1609
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormGroupComponent, decorators: [{
|
|
1543
1610
|
type: Component,
|
|
1544
|
-
args: [{ standalone: false, selector: "dynamic-form-group", encapsulation: ViewEncapsulation.None, template: "<label class=\"field-label\" *ngIf=\"props.label\">\n
|
|
1611
|
+
args: [{ standalone: false, selector: "dynamic-form-group", encapsulation: ViewEncapsulation.None, template: "@if (field.display) {\n <label class=\"field-label\" *ngIf=\"props.label\">\n {{ props.label | translate }}\n <p class=\"field-description\" *ngIf=\"props.description\">{{ props.description | translate }}</p>\n </label>\n <tabs class=\"field-container\">\n @for (itemField of field.fieldGroup; track itemField; let ix = $index) {\n @if (props.useTabs && itemField.display && itemField.wrappers | includes: 'form-fieldset') {\n <div class=\"form-fieldset-item\"\n [tabsItem]=\"ix\"\n [label]=\"itemField.props.label\">\n <formly-field [field]=\"itemField\"></formly-field>\n </div>\n } @else {\n <formly-field [field]=\"itemField\"></formly-field>\n }\n }\n </tabs>\n}\n", styles: [".form-fieldset-item.hidden-tab{display:none}\n"] }]
|
|
1545
1612
|
}] });
|
|
1546
1613
|
|
|
1547
1614
|
class DynamicFormUploadComponent extends DynamicFieldType {
|
|
@@ -1659,5 +1726,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1659
1726
|
* Generated bundle index. Do not edit.
|
|
1660
1727
|
*/
|
|
1661
1728
|
|
|
1662
|
-
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormUploadComponent, EDITOR_FORMATS, FORM_ROOT_KEY, FormFile, FormGroup, FormInput, FormModel, FormSelect, FormSerializable, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, additionalFieldValue, additionalFieldValues, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, setFieldHooks, translationValidation, validationMessage };
|
|
1729
|
+
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormUploadComponent, EDITOR_FORMATS, FORM_ROOT_KEY, FormFile, FormGroup, FormInput, FormModel, FormSelect, FormSerializable, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, additionalFieldValue, additionalFieldValues, clearFieldArray, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, setFieldHooks, translationValidation, validationMessage };
|
|
1663
1730
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|