@stemy/ngx-dynamic-form 19.9.0 → 19.9.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.
- package/fesm2022/stemy-ngx-dynamic-form.mjs +36 -25
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +2 -1
- package/ngx-dynamic-form/models/utils.d.ts +1 -2
- package/ngx-dynamic-form/services/dynamic-form-builder.service.d.ts +2 -1
- package/ngx-dynamic-form/utils/validation.d.ts +2 -1
- package/package.json +2 -2
- package/public_api.d.ts +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as i2 from '@stemy/ngx-utils';
|
|
2
|
-
import { cachedFactory, ReflectUtils, ObjectUtils, LANGUAGE_SERVICE,
|
|
2
|
+
import { cachedFactory, ReflectUtils, ObjectUtils, LANGUAGE_SERVICE, ForbiddenZone, ArrayUtils, API_SERVICE, StringUtils, AsyncMethodBase, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
3
3
|
import { of, merge, Observable, firstValueFrom, BehaviorSubject, combineLatestWith, switchMap, distinctUntilChanged, first, Subject, filter } from 'rxjs';
|
|
4
4
|
import { debounceTime } from 'rxjs/operators';
|
|
5
5
|
import { __decorate } from 'tslib';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
7
|
-
import { Inject, Injectable, untracked, input,
|
|
7
|
+
import { inject, Inject, Injectable, untracked, input, Renderer2, ElementRef, computed, signal, effect, HostBinding, Directive, Input, Pipe, Type, Component, output, Injector, ChangeDetectionStrategy, ViewEncapsulation, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
8
8
|
import * as i1 from '@angular/forms';
|
|
9
9
|
import { FormGroup as FormGroup$1, FormArray as FormArray$1, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
10
10
|
import { outputToObservable, toSignal, rxResource, outputFromObservable } from '@angular/core/rxjs-interop';
|
|
@@ -431,9 +431,17 @@ function maxValueValidation(max, each) {
|
|
|
431
431
|
return v == null || v <= max;
|
|
432
432
|
}, "maxValue");
|
|
433
433
|
}
|
|
434
|
+
function setFieldMinDate(field, min) {
|
|
435
|
+
setFieldDefault(field, min);
|
|
436
|
+
setFieldProp(field, "min", min);
|
|
437
|
+
setFieldValue(field, min);
|
|
438
|
+
removeFieldValidators(field, "minValue");
|
|
439
|
+
addFieldValidators(field, [minValueValidation(min)]);
|
|
440
|
+
}
|
|
434
441
|
|
|
435
442
|
class ModelUtils {
|
|
436
|
-
static getLanguages(
|
|
443
|
+
static getLanguages() {
|
|
444
|
+
const language = inject(LANGUAGE_SERVICE);
|
|
437
445
|
return async () => {
|
|
438
446
|
return language.languages.map(id => {
|
|
439
447
|
return { id, label: id };
|
|
@@ -441,9 +449,6 @@ class ModelUtils {
|
|
|
441
449
|
};
|
|
442
450
|
}
|
|
443
451
|
}
|
|
444
|
-
__decorate([
|
|
445
|
-
FactoryDependencies(LANGUAGE_SERVICE)
|
|
446
|
-
], ModelUtils, "getLanguages", null);
|
|
447
452
|
|
|
448
453
|
class RichTranslationModel {
|
|
449
454
|
lang = "";
|
|
@@ -640,6 +645,23 @@ class DynamicFormBuilderService {
|
|
|
640
645
|
return typeof itemType === "function" ? this.resolveFormFields(itemType, sp, options) : this.createFormInput("", typeof itemType === "string" ? { type: `${itemType}` } : itemType, sp, options);
|
|
641
646
|
}, data, parent, options);
|
|
642
647
|
}
|
|
648
|
+
createFieldSet(set, fields, parent, options) {
|
|
649
|
+
const id = !parent?.path ? set.id : `${parent.path}.${set.id}`;
|
|
650
|
+
return this.setExpressions({
|
|
651
|
+
id,
|
|
652
|
+
parent,
|
|
653
|
+
fieldGroup: fields,
|
|
654
|
+
wrappers: ["form-fieldset"],
|
|
655
|
+
props: {
|
|
656
|
+
label: this.getLabel(set.id, set.label, set.labelPrefix, parent, options, "title"),
|
|
657
|
+
hidden: false,
|
|
658
|
+
classes: toStringArray(set.classes),
|
|
659
|
+
layout: toStringArray(set.layout),
|
|
660
|
+
},
|
|
661
|
+
hooks: {},
|
|
662
|
+
expressions: {}
|
|
663
|
+
}, options);
|
|
664
|
+
}
|
|
643
665
|
createFieldSets(fields, parent, options, sets = []) {
|
|
644
666
|
const result = [];
|
|
645
667
|
const groups = {};
|
|
@@ -656,27 +678,12 @@ class DynamicFormBuilderService {
|
|
|
656
678
|
// If we have a fieldset name defined, then push the property fields into a group
|
|
657
679
|
if (fsName) {
|
|
658
680
|
const id = !parent?.path ? fsName : `${parent.path}.${fsName}`;
|
|
659
|
-
const set = sets.find(s => s.id === fsName);
|
|
681
|
+
const set = sets.find(s => s.id === fsName) || { id: fsName, layout: "" };
|
|
660
682
|
let fieldGroup = groups[id];
|
|
661
683
|
if (!fieldGroup) {
|
|
662
684
|
fieldGroup = [];
|
|
663
|
-
const fieldSet = {
|
|
664
|
-
id,
|
|
665
|
-
parent,
|
|
666
|
-
fieldGroup,
|
|
667
|
-
wrappers: ["form-fieldset"],
|
|
668
|
-
props: {
|
|
669
|
-
label: this.getLabel(fsName, set?.label, set?.labelPrefix, parent, options, "title"),
|
|
670
|
-
hidden: false,
|
|
671
|
-
classes: toStringArray(set?.classes),
|
|
672
|
-
layout: toStringArray(set?.layout),
|
|
673
|
-
},
|
|
674
|
-
hooks: {},
|
|
675
|
-
expressions: {}
|
|
676
|
-
};
|
|
677
|
-
this.setExpressions(fieldSet, options);
|
|
678
685
|
groups[id] = fieldGroup;
|
|
679
|
-
result.push(
|
|
686
|
+
result.push(this.createFieldSet(set, fieldGroup, parent, options));
|
|
680
687
|
}
|
|
681
688
|
fieldGroup.push(field);
|
|
682
689
|
continue;
|
|
@@ -995,7 +1002,10 @@ class DynamicFormBuilderService {
|
|
|
995
1002
|
configurable: true
|
|
996
1003
|
});
|
|
997
1004
|
// Set expressions
|
|
998
|
-
|
|
1005
|
+
const validators = ObjectUtils.isArray(data.validators)
|
|
1006
|
+
? data.validators.map(v => ReflectUtils.resolve(v, this.injector))
|
|
1007
|
+
: data.validators;
|
|
1008
|
+
addFieldValidators(field, validators);
|
|
999
1009
|
this.setExpressions(field, options);
|
|
1000
1010
|
return field;
|
|
1001
1011
|
}
|
|
@@ -1054,6 +1064,7 @@ class DynamicFormBuilderService {
|
|
|
1054
1064
|
field[key] = expression(field);
|
|
1055
1065
|
}
|
|
1056
1066
|
});
|
|
1067
|
+
return field;
|
|
1057
1068
|
}
|
|
1058
1069
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormBuilderService, deps: [{ token: i0.Injector }, { token: i2.EventsService }, { token: API_SERVICE }, { token: LANGUAGE_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1059
1070
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormBuilderService });
|
|
@@ -2324,5 +2335,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
2324
2335
|
* Generated bundle index. Do not edit.
|
|
2325
2336
|
*/
|
|
2326
2337
|
|
|
2327
|
-
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTemplateDirective, DynamicFormTemplatePipe, DynamicFormTemplateService, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormArray, FormFieldSet, FormGroup, FormInput, FormSelect, FormSerializable, FormStatic, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, RichTranslationModel, TranslationModel, addFieldValidators, arrayLengthValidation, clearFieldArray, controlStatus, controlValues, convertToDate, convertToDateFormat, convertToNumber, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, isFieldHidden, isFieldVisible, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDefault, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldProp, setFieldProps, setFieldSerialize, setFieldValue, translationValidation };
|
|
2338
|
+
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTemplateDirective, DynamicFormTemplatePipe, DynamicFormTemplateService, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_FORMATS, FORM_ROOT_ID, FormArray, FormFieldSet, FormGroup, FormInput, FormSelect, FormSerializable, FormStatic, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, RichTranslationModel, TranslationModel, addFieldValidators, arrayLengthValidation, clearFieldArray, controlStatus, controlValues, convertToDate, convertToDateFormat, convertToNumber, customizeFormField, emailValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, isFieldHidden, isFieldVisible, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDefault, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldMinDate, setFieldProp, setFieldProps, setFieldSerialize, setFieldValue, translationValidation };
|
|
2328
2339
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|