@stemy/ngx-dynamic-form 19.4.0 → 19.4.2

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.
@@ -2,13 +2,13 @@ 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
3
  import { Subject, BehaviorSubject, startWith, distinctUntilChanged, switchMap, from, isObservable, firstValueFrom, first } from 'rxjs';
4
4
  import * as i0 from '@angular/core';
5
- import { Inject, Injectable, input, output, inject, Renderer2, ElementRef, computed, signal, effect, HostListener, HostBinding, Directive, Injector, ChangeDetectionStrategy, ViewEncapsulation, Component, makeEnvironmentProviders, NgModule } 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
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 { outputToObservable, toSignal, rxResource } from '@angular/core/rxjs-interop';
9
9
  import { debounceTime } from 'rxjs/operators';
10
10
  import * as i3 from '@ngx-formly/core';
11
- import { FieldArrayType, FieldType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
11
+ import { FieldType, ɵobserve as _observe, FieldArrayType, FieldWrapper, provideFormlyConfig, provideFormlyCore, FormlyModule } from '@ngx-formly/core';
12
12
  import * as i1$1 from '@angular/common';
13
13
  import { CommonModule } from '@angular/common';
14
14
 
@@ -560,9 +560,10 @@ class DynamicFormBuilderService {
560
560
  option.id = option.id ?? option.value;
561
561
  }
562
562
  const control = field.formControl;
563
+ field.defaultValue = options[0]?.value ?? null;
563
564
  if (field.props.multiple || options.length === 0 || options.findIndex(o => o.value === control.value) >= 0)
564
565
  return options;
565
- control.setValue(options[0].value);
566
+ control.setValue(field.defaultValue);
566
567
  return options;
567
568
  }
568
569
  getLabel(key, label, parent, options) {
@@ -621,6 +622,19 @@ class DynamicFormBuilderService {
621
622
  }
622
623
  setExpressions(field, options) {
623
624
  const expressions = {
625
+ tabs: target => {
626
+ if (target.fieldArray) {
627
+ const group = target.fieldGroup || [];
628
+ return group.map((g, ix) => {
629
+ const label = ObjectUtils.getValue(g.formControl?.value, target.props?.tabsLabel || "label", ix);
630
+ return {
631
+ value: ix,
632
+ label: `${label}`
633
+ };
634
+ });
635
+ }
636
+ return [];
637
+ },
624
638
  path: target => {
625
639
  const tp = target.parent;
626
640
  const key = !target.key ? `` : `.${target.key}`;
@@ -1253,6 +1267,108 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1253
1267
  args: ["click"]
1254
1268
  }] } });
1255
1269
 
1270
+ class DynamicFieldType extends FieldType {
1271
+ stateChanges = new Subject();
1272
+ _errorState = false;
1273
+ _focused = false;
1274
+ ngOnDestroy() {
1275
+ delete this.formField?._control;
1276
+ this.stateChanges.complete();
1277
+ }
1278
+ setDescribedByIds(_ids) {
1279
+ }
1280
+ onContainerClick(_event) {
1281
+ this.field.focus = true;
1282
+ this.stateChanges.next();
1283
+ }
1284
+ get errorState() {
1285
+ const showError = this.options.showError(this);
1286
+ if (showError !== this._errorState) {
1287
+ this._errorState = showError;
1288
+ this.stateChanges.next();
1289
+ }
1290
+ return showError;
1291
+ }
1292
+ get controlType() {
1293
+ if (this.props.type) {
1294
+ return this.props.type;
1295
+ }
1296
+ const type = this.field.type;
1297
+ return type instanceof Type ? type.prototype.constructor.name : type;
1298
+ }
1299
+ get focused() {
1300
+ const focused = !!this.field.focus && !this.disabled;
1301
+ if (focused !== this._focused) {
1302
+ this._focused = focused;
1303
+ this.stateChanges.next();
1304
+ }
1305
+ return focused;
1306
+ }
1307
+ get disabled() {
1308
+ return !!this.props.disabled;
1309
+ }
1310
+ get required() {
1311
+ return !!this.props.required;
1312
+ }
1313
+ get placeholder() {
1314
+ return this.props.placeholder || "";
1315
+ }
1316
+ get shouldPlaceholderFloat() {
1317
+ return this.shouldLabelFloat;
1318
+ }
1319
+ get value() {
1320
+ return this.formControl?.value;
1321
+ }
1322
+ set value(value) {
1323
+ this.formControl?.patchValue(value);
1324
+ }
1325
+ get ngControl() {
1326
+ return this.formControl;
1327
+ }
1328
+ get empty() {
1329
+ return this.value == null || this.value?.length === 0;
1330
+ }
1331
+ get shouldLabelFloat() {
1332
+ return this.focused || !this.empty;
1333
+ }
1334
+ get formField() {
1335
+ return this.field?.["_formField"];
1336
+ }
1337
+ ngAfterViewInit() {
1338
+ const control = this;
1339
+ if (this.formField && control !== this.formField._control) {
1340
+ this.formField._control = control;
1341
+ // temporary fix for https://github.com/angular/material2/issues/6728
1342
+ const ngControl = control?.ngControl;
1343
+ if (ngControl?.valueAccessor?.hasOwnProperty("_formField")) {
1344
+ ngControl.valueAccessor["_formField"] = this.formField;
1345
+ }
1346
+ if (ngControl?.valueAccessor?.hasOwnProperty("_parentFormField")) {
1347
+ ngControl.valueAccessor["_parentFormField"] = this.formField;
1348
+ }
1349
+ ["prefix", "suffix", "textPrefix", "textSuffix"].forEach((type) => _observe(this.field, ["props", type], ({ currentValue }) => currentValue &&
1350
+ Promise.resolve().then(() => {
1351
+ this.options.detectChanges(this.field);
1352
+ })));
1353
+ // https://github.com/angular/components/issues/16209
1354
+ const setDescribedByIds = control.setDescribedByIds.bind(control);
1355
+ control.setDescribedByIds = (ids) => {
1356
+ setTimeout(() => setDescribedByIds(ids));
1357
+ };
1358
+ }
1359
+ }
1360
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFieldType, deps: null, target: i0.ɵɵFactoryTarget.Component });
1361
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFieldType, isStandalone: false, selector: "dynamic-field-type", usesInheritance: true, ngImport: i0, template: "", isInline: true });
1362
+ }
1363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFieldType, decorators: [{
1364
+ type: Component,
1365
+ args: [{
1366
+ standalone: false,
1367
+ selector: "dynamic-field-type",
1368
+ template: ""
1369
+ }]
1370
+ }] });
1371
+
1256
1372
  class DynamicFormComponent {
1257
1373
  builder = inject(DynamicFormBuilderService);
1258
1374
  events = inject(EventsService);
@@ -1312,7 +1428,7 @@ class DynamicFormComponent {
1312
1428
  this.options?.resetModel?.();
1313
1429
  }
1314
1430
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1315
- 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.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1431
+ 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 });
1316
1432
  }
1317
1433
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormComponent, decorators: [{
1318
1434
  type: Component,
@@ -1321,23 +1437,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1321
1437
 
1322
1438
  class DynamicFormArrayComponent extends FieldArrayType {
1323
1439
  currentTab = signal(0);
1324
- clear() {
1440
+ clearItems() {
1325
1441
  const control = this.formControl;
1326
1442
  while (control.length > 0) {
1327
1443
  this.remove(0);
1328
1444
  }
1445
+ this.currentTab.set(0);
1446
+ }
1447
+ addItem(i) {
1448
+ i = i == null ? this.field.fieldGroup.length : i;
1449
+ this.add(i);
1450
+ this.currentTab.set(i);
1451
+ }
1452
+ removeItem(i) {
1453
+ this.remove(i);
1454
+ const length = this.field.fieldGroup.length;
1455
+ this.currentTab.set(Math.min(this.currentTab(), length - 1));
1329
1456
  }
1330
1457
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1331
- 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 @if (props.useTabs) {\n <ul class=\"form-array-tabs\">\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n <li>\n <a class=\"btn\" [ngClass]=\"[currentTab() === ix ? 'btn-primary' : 'btn-secondary']\"\n (click)=\"currentTab.set(ix)\">\n {{ (field.formControl.value | getValue : props.tabsLabel) || ix + 1 }}\n </a>\n </li>\n }\n </ul>\n }\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n @if (!props.useTabs || ix === currentTab()) {\n <div class=\"form-array-item\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"remove(ix)\">\n <i icon=\"trash-outline\"></i>\n </button>\n }\n @if (props.insertItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"add(ix)\">\n <i icon=\"plus-outline\"></i>\n </button>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n }\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"clear()\">\n <i icon=\"trash-outline\"></i>\n {{ 'button.clear-items' | translate }}\n </button>\n }\n @if (props.addItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"add()\">\n <i icon=\"plus-outline\"></i>\n {{ 'button.insert-item' | translate }}\n </button>\n }\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.IconDirective, selector: "[icon]", inputs: ["icon", "activeIcon", "active"], outputs: ["activeChange"] }, { kind: "component", type: i3.FormlyField, selector: "formly-field", inputs: ["field"] }, { kind: "pipe", type: i2.GetValuePipe, name: "getValue" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
1458
+ 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 @if (props.useTabs) {\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(field.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (props.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n </tabs>\n } @else {\n @for (field of field.fieldGroup; track field; let ix = $index) {\n <div class=\"form-array-item\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (props.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n }\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: i2.TabsItemDirective, selector: "[tabsItem]", inputs: ["tabsItem", "label", "tooltip", "icon", "disabled"] }, { kind: "component", type: i2.BtnComponent, selector: "btn", inputs: ["label", "tooltip", "icon", "disabled", "style", "size"] }, { kind: "component", type: i2.TabsComponent, selector: "tabs", inputs: ["value", "options", "style", "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 });
1332
1459
  }
1333
1460
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormArrayComponent, decorators: [{
1334
1461
  type: Component,
1335
- 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 @if (props.useTabs) {\n <ul class=\"form-array-tabs\">\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n <li>\n <a class=\"btn\" [ngClass]=\"[currentTab() === ix ? 'btn-primary' : 'btn-secondary']\"\n (click)=\"currentTab.set(ix)\">\n {{ (field.formControl.value | getValue : props.tabsLabel) || ix + 1 }}\n </a>\n </li>\n }\n </ul>\n }\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n @if (!props.useTabs || ix === currentTab()) {\n <div class=\"form-array-item\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"remove(ix)\">\n <i icon=\"trash-outline\"></i>\n </button>\n }\n @if (props.insertItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"add(ix)\">\n <i icon=\"plus-outline\"></i>\n </button>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n }\n <div class=\"form-array-buttons\">\n @if (props.clearItems) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"clear()\">\n <i icon=\"trash-outline\"></i>\n {{ 'button.clear-items' | translate }}\n </button>\n }\n @if (props.addItem) {\n <button type=\"button\" class=\"btn btn-sm btn-primary\" (click)=\"add()\">\n <i icon=\"plus-outline\"></i>\n {{ 'button.insert-item' | translate }}\n </button>\n }\n </div>\n</div>\n" }]
1462
+ 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 @if (props.useTabs) {\n <tabs class=\"form-array-items\" [(value)]=\"currentTab\">\n @for (field of field.fieldGroup; track field.key; let ix = $index) {\n <div class=\"form-array-item\"\n [tabsItem]=\"ix\"\n [label]=\"(field.formControl.value | getValue : props.tabsLabel) || ix + 1\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (props.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n </tabs>\n } @else {\n @for (field of field.fieldGroup; track field; let ix = $index) {\n <div class=\"form-array-item\">\n <div class=\"form-array-buttons\">\n @if (props.removeItem) {\n <btn icon=\"trash\" (click)=\"removeItem(ix)\"></btn>\n }\n @if (props.insertItem) {\n <btn icon=\"plus\" (click)=\"addItem(ix)\"></btn>\n }\n </div>\n <formly-field [field]=\"field\"></formly-field>\n </div>\n }\n }\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"] }]
1336
1463
  }] });
1337
1464
 
1338
- class DynamicFormChipsComponent extends FieldType {
1465
+ class DynamicFormChipsComponent extends DynamicFieldType {
1339
1466
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormChipsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1340
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormChipsComponent, isStandalone: false, selector: "dynamic-form-chips", usesInheritance: true, ngImport: i0, template: "<chips [formControl]=\"formControl\"\n [type]=\"props.type\"\n [step]=\"props.step\"\n [minLength]=\"props.minLength\"\n [maxLength]=\"props.maxLength\"\n [min]=\"props.min\"\n [max]=\"props.max\"\n [multiple]=\"props.multiple\"\n [formlyAttributes]=\"field\">\n</chips>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.ChipsComponent, selector: "chips", inputs: ["value", "multiple", "disabled", "type", "min", "max", "minLength", "maxLength", "step", "placeholder", "unique", "options"], outputs: ["valueChange"] }, { kind: "directive", type: i3.ɵFormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1467
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormChipsComponent, isStandalone: false, selector: "dynamic-form-chips", usesInheritance: true, ngImport: i0, template: "<chips [formControl]=\"formControl\"\n [type]=\"props.type\"\n [step]=\"props.step\"\n [minLength]=\"props.minLength\"\n [maxLength]=\"props.maxLength\"\n [min]=\"props.min\"\n [max]=\"props.max\"\n [multiple]=\"props.multiple\"\n [formlyAttributes]=\"field\">\n</chips>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.ChipsComponent, selector: "chips", inputs: ["value", "multiple", "disabled", "type", "min", "max", "minLength", "maxLength", "step", "placeholder", "unique", "options"], outputs: ["valueChange"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1341
1468
  }
1342
1469
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormChipsComponent, decorators: [{
1343
1470
  type: Component,
@@ -1346,7 +1473,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1346
1473
 
1347
1474
  class DynamicFormFieldComponent extends FieldWrapper {
1348
1475
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1349
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormFieldComponent, isStandalone: false, selector: "dynamic-form-field", usesInheritance: true, ngImport: i0, template: "<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 && props.hideRequiredMarker !== true\" 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 id=\"{{ id }}-formly-validation-error\"\n [field]=\"field\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
1476
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormFieldComponent, isStandalone: false, selector: "dynamic-form-field", usesInheritance: true, ngImport: i0, template: "<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 && props.hideRequiredMarker !== true\" 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 id=\"{{ id }}-formly-validation-error\"\n [field]=\"field\"\n role=\"alert\"\n ></formly-validation-message>\n </div>\n</div>\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 });
1350
1477
  }
1351
1478
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormFieldComponent, decorators: [{
1352
1479
  type: Component,
@@ -1375,9 +1502,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1375
1502
  args: [{ standalone: false, selector: "dynamic-form-group", 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<ng-container #fieldComponent></ng-container>\n" }]
1376
1503
  }] });
1377
1504
 
1378
- class DynamicFormUploadComponent extends FieldType {
1505
+ class DynamicFormUploadComponent extends DynamicFieldType {
1379
1506
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormUploadComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1380
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormUploadComponent, isStandalone: false, selector: "dynamic-form-upload", usesInheritance: true, ngImport: i0, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.UploadComponent, selector: "upload", inputs: ["value", "disabled", "inline", "accept", "baseUrl", "message", "multiple", "buttonText", "makeUpload", "preProcess"], outputs: ["onUploaded", "onRemove"] }, { kind: "directive", type: i3.ɵFormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1507
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: DynamicFormUploadComponent, isStandalone: false, selector: "dynamic-form-upload", usesInheritance: true, ngImport: i0, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.UploadComponent, selector: "upload", inputs: ["value", "disabled", "inline", "accept", "baseUrl", "message", "multiple", "buttonText", "makeUpload", "preProcess"], outputs: ["onUploaded", "onRemove"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1381
1508
  }
1382
1509
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DynamicFormUploadComponent, decorators: [{
1383
1510
  type: Component,
@@ -1386,6 +1513,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1386
1513
 
1387
1514
  // --- Components ---
1388
1515
  const components = [
1516
+ DynamicFieldType,
1389
1517
  DynamicFormComponent,
1390
1518
  DynamicFormArrayComponent,
1391
1519
  DynamicFormChipsComponent,
@@ -1403,28 +1531,24 @@ const pipes = [];
1403
1531
 
1404
1532
  class NgxDynamicFormModule {
1405
1533
  static getProviders(config) {
1406
- const { providers } = FormlyModule.forRoot({
1407
- types: [
1408
- { name: "array", component: DynamicFormArrayComponent },
1409
- { name: "chips", component: DynamicFormChipsComponent },
1410
- { name: "upload", component: DynamicFormUploadComponent, wrappers: ["form-field"] },
1411
- { name: "file", extends: "upload" },
1412
- { name: "translation", extends: "array" },
1413
- ...(config?.types || [])
1414
- ],
1415
- wrappers: [
1416
- { name: "form-field", component: DynamicFormFieldComponent },
1417
- { name: "form-fieldset", component: DynamicFormFieldsetComponent },
1418
- { name: "form-group", component: DynamicFormGroupComponent },
1419
- ...(config?.wrappers || [])
1420
- ],
1421
- extras: {
1422
- renderFormlyFieldElement: false,
1423
- ...(config?.extras || {})
1424
- }
1425
- });
1534
+ const formlyConfigs = (config?.options || []).map(provideFormlyConfig);
1426
1535
  return [
1427
- ...providers,
1536
+ provideFormlyCore({
1537
+ types: [
1538
+ { name: "array", component: DynamicFormArrayComponent },
1539
+ { name: "chips", component: DynamicFormChipsComponent, wrappers: ["form-field"] },
1540
+ { name: "upload", component: DynamicFormUploadComponent, wrappers: ["form-field"] }
1541
+ ],
1542
+ wrappers: [
1543
+ { name: "form-field", component: DynamicFormFieldComponent },
1544
+ { name: "form-fieldset", component: DynamicFormFieldsetComponent },
1545
+ { name: "form-group", component: DynamicFormGroupComponent }
1546
+ ],
1547
+ extras: {
1548
+ renderFormlyFieldElement: false
1549
+ }
1550
+ }),
1551
+ ...formlyConfigs,
1428
1552
  DynamicFormService,
1429
1553
  DynamicFormBuilderService,
1430
1554
  DynamicFormSchemaService
@@ -1440,10 +1564,11 @@ class NgxDynamicFormModule {
1440
1564
  return makeEnvironmentProviders(NgxDynamicFormModule.getProviders(config));
1441
1565
  }
1442
1566
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgxDynamicFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1443
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: NgxDynamicFormModule, declarations: [DynamicFormComponent, DynamicFormArrayComponent, DynamicFormChipsComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormUploadComponent, AsyncSubmitDirective], imports: [CommonModule,
1567
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: NgxDynamicFormModule, declarations: [DynamicFieldType, DynamicFormComponent, DynamicFormArrayComponent, DynamicFormChipsComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormUploadComponent, AsyncSubmitDirective], imports: [CommonModule,
1444
1568
  FormsModule,
1445
1569
  ReactiveFormsModule,
1446
- NgxUtilsModule, i3.FormlyModule], exports: [DynamicFormComponent, DynamicFormArrayComponent, DynamicFormChipsComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormUploadComponent, AsyncSubmitDirective, FormsModule,
1570
+ NgxUtilsModule,
1571
+ FormlyModule], exports: [DynamicFieldType, DynamicFormComponent, DynamicFormArrayComponent, DynamicFormChipsComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormUploadComponent, AsyncSubmitDirective, FormsModule,
1447
1572
  ReactiveFormsModule,
1448
1573
  NgxUtilsModule,
1449
1574
  FormlyModule] });
@@ -1453,7 +1578,7 @@ class NgxDynamicFormModule {
1453
1578
  FormsModule,
1454
1579
  ReactiveFormsModule,
1455
1580
  NgxUtilsModule,
1456
- FormlyModule.forChild(), FormsModule,
1581
+ FormlyModule, FormsModule,
1457
1582
  ReactiveFormsModule,
1458
1583
  NgxUtilsModule,
1459
1584
  FormlyModule] });
@@ -1471,7 +1596,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1471
1596
  FormsModule,
1472
1597
  ReactiveFormsModule,
1473
1598
  NgxUtilsModule,
1474
- FormlyModule.forChild()
1599
+ FormlyModule
1475
1600
  ],
1476
1601
  exports: [
1477
1602
  ...components,
@@ -1492,5 +1617,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1492
1617
  * Generated bundle index. Do not edit.
1493
1618
  */
1494
1619
 
1495
- export { AsyncSubmitDirective, 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, additionalFieldValues, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, translationValidation, validationMessage };
1620
+ 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, additionalFieldValues, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, replaceSpecialChars, requiredValidation, setFieldDisabled, setFieldHidden, translationValidation, validationMessage };
1496
1621
  //# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map