@stemy/ngx-dynamic-form 19.4.8 → 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 +141 -71
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +83 -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 || {};
|
|
@@ -262,6 +291,9 @@ class ConfigForSchemaWrap {
|
|
|
262
291
|
get testId() {
|
|
263
292
|
return this.opts.testId;
|
|
264
293
|
}
|
|
294
|
+
get context() {
|
|
295
|
+
return this.opts.context;
|
|
296
|
+
}
|
|
265
297
|
fieldCustomizer;
|
|
266
298
|
constructor(opts, mode, injector, schema) {
|
|
267
299
|
this.opts = opts;
|
|
@@ -320,6 +352,17 @@ function findRefs(property) {
|
|
|
320
352
|
: [property.items?.$ref, property.$ref].filter(isStringWithVal);
|
|
321
353
|
return refs.map(t => t.split("/").pop());
|
|
322
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
|
+
}
|
|
323
366
|
function mergeFormFields(formFields) {
|
|
324
367
|
const res = [];
|
|
325
368
|
for (const formModel of formFields) {
|
|
@@ -403,9 +446,8 @@ class DynamicFormBuilderService {
|
|
|
403
446
|
return true;
|
|
404
447
|
});
|
|
405
448
|
for (const field of fields) {
|
|
406
|
-
const fsName =
|
|
407
|
-
// If we have a fieldset name defined
|
|
408
|
-
// 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
|
|
409
451
|
if (fsName) {
|
|
410
452
|
const fsId = !parent?.path ? fsName : `${parent.path}.${fsName}`;
|
|
411
453
|
const group = groups[fsId] || [];
|
|
@@ -424,10 +466,12 @@ class DynamicFormBuilderService {
|
|
|
424
466
|
parent,
|
|
425
467
|
fieldGroup: groups[id],
|
|
426
468
|
wrappers: ["form-fieldset"],
|
|
427
|
-
className: `dynamic-form-fieldset dynamic-form-fieldset-${id}`,
|
|
428
469
|
props: {
|
|
429
470
|
label: this.getLabel(key, key, parent, options),
|
|
430
|
-
hidden: false
|
|
471
|
+
hidden: false,
|
|
472
|
+
additional: {
|
|
473
|
+
className: `dynamic-form-fieldset dynamic-form-fieldset-${id}`
|
|
474
|
+
}
|
|
431
475
|
},
|
|
432
476
|
hooks: {},
|
|
433
477
|
expressions: {}
|
|
@@ -504,7 +548,9 @@ class DynamicFormBuilderService {
|
|
|
504
548
|
}
|
|
505
549
|
createFormGroup(key, fields, data, parent, options) {
|
|
506
550
|
data = data || {};
|
|
507
|
-
const group = this.createFormField(key, undefined, data, {
|
|
551
|
+
const group = this.createFormField(key, undefined, data, {
|
|
552
|
+
useTabs: data.useTabs === true
|
|
553
|
+
}, parent, options);
|
|
508
554
|
group.wrappers = ["form-group"];
|
|
509
555
|
const result = fields(group);
|
|
510
556
|
const handleGroup = (fieldGroup) => {
|
|
@@ -523,22 +569,29 @@ class DynamicFormBuilderService {
|
|
|
523
569
|
useTabs: data.useTabs === true,
|
|
524
570
|
tabsLabel: `${data.tabsLabel || "label"}`,
|
|
525
571
|
addItem: data.addItem !== false,
|
|
526
|
-
insertItem: data.insertItem !== false,
|
|
527
|
-
cloneItem: data.cloneItem !== false,
|
|
528
|
-
moveItem: data.moveItem !== false,
|
|
529
|
-
removeItem: data.removeItem !== false,
|
|
530
572
|
clearItems: data.clearItems !== false
|
|
531
573
|
}, parent, options);
|
|
532
574
|
const result = fields(array);
|
|
533
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
|
+
};
|
|
534
582
|
if (Array.isArray(items)) {
|
|
535
583
|
array.fieldArray = {
|
|
536
584
|
wrappers: ["form-group"],
|
|
537
|
-
className: "dynamic-form-field dynamic-form-group",
|
|
538
585
|
fieldGroup: items,
|
|
586
|
+
props: {
|
|
587
|
+
additional: {
|
|
588
|
+
className: "dynamic-form-field dynamic-form-group",
|
|
589
|
+
}
|
|
590
|
+
},
|
|
539
591
|
hooks: {},
|
|
540
|
-
expressions
|
|
592
|
+
expressions
|
|
541
593
|
};
|
|
594
|
+
this.setExpressions(array.fieldArray, options);
|
|
542
595
|
return array;
|
|
543
596
|
}
|
|
544
597
|
const props = items.props || {};
|
|
@@ -556,8 +609,10 @@ class DynamicFormBuilderService {
|
|
|
556
609
|
...items,
|
|
557
610
|
props: {
|
|
558
611
|
...items.props,
|
|
559
|
-
label: ""
|
|
560
|
-
}
|
|
612
|
+
label: "",
|
|
613
|
+
},
|
|
614
|
+
hooks: {},
|
|
615
|
+
expressions
|
|
561
616
|
};
|
|
562
617
|
return array;
|
|
563
618
|
};
|
|
@@ -602,7 +657,6 @@ class DynamicFormBuilderService {
|
|
|
602
657
|
const field = {
|
|
603
658
|
key,
|
|
604
659
|
validators,
|
|
605
|
-
hide: data.hidden === true,
|
|
606
660
|
type: data.componentType || type,
|
|
607
661
|
fieldSet: String(data.fieldSet || ""),
|
|
608
662
|
resetOnHide: false,
|
|
@@ -615,11 +669,14 @@ class DynamicFormBuilderService {
|
|
|
615
669
|
props: {
|
|
616
670
|
...props,
|
|
617
671
|
disabled: data.disabled === true,
|
|
672
|
+
hidden: data.hidden === true,
|
|
618
673
|
formCheck: "nolabel",
|
|
619
674
|
required: !!validators.required,
|
|
620
675
|
label: options.labelCustomizer?.(key, data.label, parent, options.labelPrefix)
|
|
621
676
|
?? this.getLabel(key, data.label, parent, options),
|
|
622
|
-
additional: {
|
|
677
|
+
additional: {
|
|
678
|
+
classes: data.classes || []
|
|
679
|
+
}
|
|
623
680
|
},
|
|
624
681
|
modelOptions: {
|
|
625
682
|
updateOn: "change"
|
|
@@ -628,14 +685,7 @@ class DynamicFormBuilderService {
|
|
|
628
685
|
hooks: {},
|
|
629
686
|
expressions: {
|
|
630
687
|
serializer: () => data.serializer,
|
|
631
|
-
serialize: () => data.serialize
|
|
632
|
-
additional: (target) => target.props.additional,
|
|
633
|
-
className: (target) => {
|
|
634
|
-
const type = ObjectUtils.isConstructor(target.type)
|
|
635
|
-
? `${target.type.name}`.toLowerCase().replace("component", "")
|
|
636
|
-
: `${target.type || "group"}`;
|
|
637
|
-
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(" ");
|
|
638
|
-
}
|
|
688
|
+
serialize: () => data.serialize
|
|
639
689
|
}
|
|
640
690
|
};
|
|
641
691
|
// Parent object will be available for customizers as a property, until it gets redefined by formly
|
|
@@ -649,18 +699,31 @@ class DynamicFormBuilderService {
|
|
|
649
699
|
}
|
|
650
700
|
setExpressions(field, options) {
|
|
651
701
|
const expressions = {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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`;
|
|
662
712
|
}
|
|
663
|
-
|
|
713
|
+
const { classes, className } = target.additional || {};
|
|
714
|
+
if (className) {
|
|
715
|
+
return className;
|
|
716
|
+
}
|
|
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;
|
|
664
727
|
},
|
|
665
728
|
path: target => {
|
|
666
729
|
const tp = target.parent;
|
|
@@ -739,34 +802,32 @@ class DynamicFormSchemaService {
|
|
|
739
802
|
return this.getFormSelectConfig($enum, property, options, parent);
|
|
740
803
|
}
|
|
741
804
|
switch (property.type) {
|
|
742
|
-
case "string":
|
|
743
|
-
case "number":
|
|
744
|
-
case "integer":
|
|
745
|
-
case "textarea":
|
|
746
|
-
// if (this.checkIsEditorProperty(property)) {
|
|
747
|
-
// return this.getFormEditorConfig(property, options, parent);
|
|
748
|
-
// }
|
|
749
|
-
if (property.format == "textarea") {
|
|
750
|
-
return this.getFormTextareaConfig(property, options, parent);
|
|
751
|
-
}
|
|
752
|
-
if (property.format == "date" || property.format == "date-time") {
|
|
753
|
-
return this.getFormDatepickerConfig(property, options, parent);
|
|
754
|
-
}
|
|
755
|
-
return this.getFormInputConfig(property, options, parent);
|
|
756
805
|
// case "object":
|
|
757
806
|
// return this.getFormEditorConfig(property, options, parent);
|
|
807
|
+
case "file":
|
|
808
|
+
case "upload":
|
|
809
|
+
return this.getFormUploadConfig(property, options, parent);
|
|
758
810
|
case "boolean":
|
|
759
811
|
return this.getFormCheckboxConfig(property, options, parent);
|
|
760
812
|
case "array":
|
|
761
813
|
return this.getFormArrayConfig(property, options, parent);
|
|
762
|
-
case "file":
|
|
763
|
-
case "upload":
|
|
764
|
-
return this.getFormUploadConfig(property, options, parent);
|
|
765
814
|
}
|
|
815
|
+
// if (this.checkIsEditorProperty(property)) {
|
|
816
|
+
// return this.getFormEditorConfig(property, options, parent);
|
|
817
|
+
// }
|
|
766
818
|
if (findRefs(property).length > 0) {
|
|
767
819
|
return this.getFormGroupConfig(property, options, parent);
|
|
768
820
|
}
|
|
769
|
-
|
|
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);
|
|
770
831
|
}
|
|
771
832
|
getFormFieldData(property, options) {
|
|
772
833
|
const validators = {};
|
|
@@ -1415,6 +1476,7 @@ class DynamicFormComponent {
|
|
|
1415
1476
|
labelPrefix = input("label");
|
|
1416
1477
|
labelCustomizer = input(null);
|
|
1417
1478
|
testId = input("");
|
|
1479
|
+
useTabs = input(false);
|
|
1418
1480
|
data = input({});
|
|
1419
1481
|
fields = input(null);
|
|
1420
1482
|
fieldChanges = new Subject();
|
|
@@ -1425,11 +1487,19 @@ class DynamicFormComponent {
|
|
|
1425
1487
|
initialValue: this.languages.enableTranslations
|
|
1426
1488
|
});
|
|
1427
1489
|
config = computed(() => {
|
|
1428
|
-
|
|
1490
|
+
const options = {
|
|
1429
1491
|
labelPrefix: this.labelPrefix(),
|
|
1430
1492
|
labelCustomizer: this.labelCustomizer(),
|
|
1431
1493
|
testId: this.testId(),
|
|
1432
|
-
}
|
|
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
|
+
];
|
|
1433
1503
|
});
|
|
1434
1504
|
group = computed(() => {
|
|
1435
1505
|
this.config();
|
|
@@ -1467,11 +1537,11 @@ class DynamicFormComponent {
|
|
|
1467
1537
|
this.options?.resetModel?.();
|
|
1468
1538
|
}
|
|
1469
1539
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1470
|
-
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 });
|
|
1471
1541
|
}
|
|
1472
1542
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
1473
1543
|
type: Component,
|
|
1474
|
-
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"] }]
|
|
1475
1545
|
}], ctorParameters: () => [] });
|
|
1476
1546
|
|
|
1477
1547
|
class DynamicFormArrayComponent extends FieldArrayType {
|
|
@@ -1494,11 +1564,11 @@ class DynamicFormArrayComponent extends FieldArrayType {
|
|
|
1494
1564
|
this.currentTab.set(Math.min(this.currentTab(), length - 1));
|
|
1495
1565
|
}
|
|
1496
1566
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1497
|
-
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 });
|
|
1498
1568
|
}
|
|
1499
1569
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
|
|
1500
1570
|
type: Component,
|
|
1501
|
-
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"] }]
|
|
1502
1572
|
}] });
|
|
1503
1573
|
|
|
1504
1574
|
class DynamicFormChipsComponent extends DynamicFieldType {
|
|
@@ -1512,11 +1582,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1512
1582
|
|
|
1513
1583
|
class DynamicFormFieldComponent extends FieldWrapper {
|
|
1514
1584
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1515
|
-
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 });
|
|
1516
1586
|
}
|
|
1517
1587
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
|
|
1518
1588
|
type: Component,
|
|
1519
|
-
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" }]
|
|
1520
1590
|
}] });
|
|
1521
1591
|
|
|
1522
1592
|
class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
@@ -1525,20 +1595,20 @@ class DynamicFormFieldsetComponent extends FieldWrapper {
|
|
|
1525
1595
|
// console.log(this.field.parent);
|
|
1526
1596
|
}
|
|
1527
1597
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1528
|
-
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 });
|
|
1529
1599
|
}
|
|
1530
1600
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldsetComponent, decorators: [{
|
|
1531
1601
|
type: Component,
|
|
1532
|
-
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" }]
|
|
1533
1603
|
}] });
|
|
1534
1604
|
|
|
1535
1605
|
class DynamicFormGroupComponent extends FieldWrapper {
|
|
1536
1606
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1537
|
-
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 });
|
|
1538
1608
|
}
|
|
1539
1609
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormGroupComponent, decorators: [{
|
|
1540
1610
|
type: Component,
|
|
1541
|
-
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"] }]
|
|
1542
1612
|
}] });
|
|
1543
1613
|
|
|
1544
1614
|
class DynamicFormUploadComponent extends DynamicFieldType {
|
|
@@ -1656,5 +1726,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
1656
1726
|
* Generated bundle index. Do not edit.
|
|
1657
1727
|
*/
|
|
1658
1728
|
|
|
1659
|
-
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 };
|
|
1660
1730
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|