@stemy/ngx-dynamic-form 19.8.12 → 19.8.14
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 +16 -6
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +3 -1
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +6 -2
- package/ngx-dynamic-form/utils/misc.d.ts +1 -0
- package/package.json +3 -3
- package/public_api.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i2 from '@stemy/ngx-utils';
|
|
2
2
|
import { cachedFactory, ReflectUtils, ObjectUtils, LANGUAGE_SERVICE, FactoryDependencies, ForbiddenZone, ArrayUtils, API_SERVICE, StringUtils, AsyncMethodBase, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
3
|
-
import { of, merge, Observable, firstValueFrom, BehaviorSubject, combineLatestWith, switchMap, distinctUntilChanged, first, Subject } from 'rxjs';
|
|
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';
|
|
@@ -256,6 +256,9 @@ function setFieldProps(field, values) {
|
|
|
256
256
|
function setFieldProp(field, prop, value) {
|
|
257
257
|
return setFieldProps(field, { [prop]: value });
|
|
258
258
|
}
|
|
259
|
+
function setFieldSerialize(field, serialize = true) {
|
|
260
|
+
field.serialize = ObjectUtils.isFunction(serialize) ? serialize : () => serialize;
|
|
261
|
+
}
|
|
259
262
|
function setFieldHidden(field, hidden = true) {
|
|
260
263
|
setFieldProp(field, "__hidden", ObjectUtils.isFunction(hidden) ? hidden : () => hidden);
|
|
261
264
|
}
|
|
@@ -541,6 +544,7 @@ async function toWrapOptions(customizeOrOptions, injector, schema, errorMsg) {
|
|
|
541
544
|
let schemaOptions = customizeOrOptions;
|
|
542
545
|
if (!ObjectUtils.isObject(schemaOptions)) {
|
|
543
546
|
schemaOptions = {
|
|
547
|
+
context: {},
|
|
544
548
|
fieldCustomizer: customizeOrOptions
|
|
545
549
|
};
|
|
546
550
|
}
|
|
@@ -838,8 +842,8 @@ class DynamicFormBuilderService {
|
|
|
838
842
|
if (lang && translation) {
|
|
839
843
|
// Use translation component if the sub items are correct
|
|
840
844
|
array.type = "translation";
|
|
841
|
-
lang.serialize = () => true;
|
|
842
845
|
setFieldHidden(lang);
|
|
846
|
+
setFieldSerialize(lang);
|
|
843
847
|
setFieldProp(translation, "label", "");
|
|
844
848
|
}
|
|
845
849
|
this.setExpressions(array.fieldArray, options);
|
|
@@ -912,7 +916,9 @@ class DynamicFormBuilderService {
|
|
|
912
916
|
options = options || { labelPrefix: "" };
|
|
913
917
|
const labelPrefix = !ObjectUtils.isString(options.labelPrefix) ? `` : options.labelPrefix;
|
|
914
918
|
if (ObjectUtils.isFunction(options.labelCustomizer)) {
|
|
915
|
-
|
|
919
|
+
const customLabel = options.labelCustomizer(key, label, parent, labelPrefix);
|
|
920
|
+
if (ObjectUtils.isString(customLabel))
|
|
921
|
+
return customLabel;
|
|
916
922
|
}
|
|
917
923
|
// Exceptional case, to be able to have an "empty" label element in the HTML just to fill the space.
|
|
918
924
|
if (label === " ")
|
|
@@ -1776,6 +1782,8 @@ class DynamicFormComponent {
|
|
|
1776
1782
|
data = input({});
|
|
1777
1783
|
fields = input(null);
|
|
1778
1784
|
fieldChanges = new Subject();
|
|
1785
|
+
init = this.fieldChanges.pipe(first());
|
|
1786
|
+
valueChanges = this.fieldChanges.pipe(filter(c => c.type === "valueChanges"));
|
|
1779
1787
|
language = toSignal(this.events.languageChanged, {
|
|
1780
1788
|
initialValue: this.languages.currentLanguage
|
|
1781
1789
|
});
|
|
@@ -1812,7 +1820,9 @@ class DynamicFormComponent {
|
|
|
1812
1820
|
});
|
|
1813
1821
|
status = computed(() => this.status$.value());
|
|
1814
1822
|
onSubmit = output();
|
|
1815
|
-
|
|
1823
|
+
onFieldChanges = outputFromObservable(this.fieldChanges);
|
|
1824
|
+
onValueChanges = outputFromObservable(this.valueChanges);
|
|
1825
|
+
onInit = outputFromObservable(this.init);
|
|
1816
1826
|
options = {
|
|
1817
1827
|
fieldChanges: this.fieldChanges,
|
|
1818
1828
|
formState: {
|
|
@@ -1849,7 +1859,7 @@ class DynamicFormComponent {
|
|
|
1849
1859
|
return field?.formControl ?? null;
|
|
1850
1860
|
}
|
|
1851
1861
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, deps: [{ token: DynamicFormService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1852
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", 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 }, legacyLabels: { classPropertyName: "legacyLabels", publicName: "legacyLabels", 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",
|
|
1862
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", 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 }, legacyLabels: { classPropertyName: "legacyLabels", publicName: "legacyLabels", 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", onFieldChanges: "onFieldChanges", onValueChanges: "onValueChanges", onInit: "onInit" }, 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 });
|
|
1853
1863
|
}
|
|
1854
1864
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
1855
1865
|
type: Component,
|
|
@@ -2119,5 +2129,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
|
|
|
2119
2129
|
* Generated bundle index. Do not edit.
|
|
2120
2130
|
*/
|
|
2121
2131
|
|
|
2122
|
-
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, 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, setFieldValue, translationValidation };
|
|
2132
|
+
export { AsyncSubmitDirective, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, 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 };
|
|
2123
2133
|
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|