@stemy/ngx-dynamic-form 19.9.13 → 19.9.15
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Inject, Injectable, untracked, input, Renderer2, ElementRef, computed, signal, effect, HostBinding, Directive, Input, Pipe, Type, Component,
|
|
2
|
+
import { InjectionToken, inject, Inject, Injectable, untracked, input, Renderer2, ElementRef, computed, signal, effect, HostBinding, Directive, Input, Pipe, Type, Component, Injector, output, ChangeDetectionStrategy, ViewEncapsulation, viewChild, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from '@stemy/ngx-utils';
|
|
4
4
|
import { cachedFactory, ReflectUtils, ObjectUtils, LANGUAGE_SERVICE, ForbiddenZone, ArrayUtils, API_SERVICE, StringUtils, AsyncMethodBase, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
5
|
-
import { of, merge, Observable, firstValueFrom, BehaviorSubject, combineLatestWith, switchMap, distinctUntilChanged, first, Subject, filter } from 'rxjs';
|
|
5
|
+
import { of, merge, Observable, firstValueFrom, BehaviorSubject, combineLatestWith, switchMap, distinctUntilChanged, first, Subject, map, filter } from 'rxjs';
|
|
6
6
|
import { debounceTime } from 'rxjs/operators';
|
|
7
7
|
import { __decorate } from 'tslib';
|
|
8
8
|
import * as i1 from '@angular/forms';
|
|
@@ -743,6 +743,10 @@ class DynamicFormBuilderService {
|
|
|
743
743
|
},
|
|
744
744
|
};
|
|
745
745
|
switch (type) {
|
|
746
|
+
case "checkbox":
|
|
747
|
+
data.defaultValue = data.defaultValue ?? true;
|
|
748
|
+
console.log("Helo", key, data);
|
|
749
|
+
break;
|
|
746
750
|
case "number":
|
|
747
751
|
case "integer":
|
|
748
752
|
props.min = convertToNumber(data.min, MIN_INPUT_NUM);
|
|
@@ -818,11 +822,11 @@ class DynamicFormBuilderService {
|
|
|
818
822
|
}
|
|
819
823
|
createFormGroup(key, fields, data, parent, options) {
|
|
820
824
|
data = data || {};
|
|
825
|
+
data.defaultValue = data.defaultValue ?? {};
|
|
821
826
|
const group = this.createFormField(key, undefined, data, {
|
|
822
827
|
useTabs: data.useTabs === true,
|
|
823
828
|
}, parent, options);
|
|
824
829
|
group.asFieldSet = data.asFieldSet === true;
|
|
825
|
-
group.defaultValue = {};
|
|
826
830
|
const result = fields(group.asFieldSet ? parent : group);
|
|
827
831
|
const handleGroup = (fieldGroup) => {
|
|
828
832
|
group.fieldGroup = fieldGroup;
|
|
@@ -834,10 +838,8 @@ class DynamicFormBuilderService {
|
|
|
834
838
|
}
|
|
835
839
|
createFormArray(key, fields, data, parent, options) {
|
|
836
840
|
data = data || {};
|
|
841
|
+
data.defaultValue = data.defaultValue ?? [];
|
|
837
842
|
const array = this.createFormField(key, "array", data, {
|
|
838
|
-
// initialCount: data.initialCount || 0,
|
|
839
|
-
// sortable: data.sortable || false,
|
|
840
|
-
defaultValue: [],
|
|
841
843
|
useTabs: data.useTabs === true,
|
|
842
844
|
tabsLabel: `${data.tabsLabel || "label"}`,
|
|
843
845
|
insertItem: data.insertItem,
|
|
@@ -970,6 +972,7 @@ class DynamicFormBuilderService {
|
|
|
970
972
|
const prefix = data.labelPrefix ?? parent?.labelPrefix;
|
|
971
973
|
const field = {
|
|
972
974
|
...this.createFormSerializer(key, data),
|
|
975
|
+
defaultValue: data.defaultValue ?? null,
|
|
973
976
|
fieldSet: String(data.fieldSet || ""),
|
|
974
977
|
labelPrefix: prefix,
|
|
975
978
|
controlTemplateKey: String(data.controlTemplateKey || ""),
|
|
@@ -1190,6 +1193,7 @@ class DynamicFormSchemaService {
|
|
|
1190
1193
|
classes: property.classes,
|
|
1191
1194
|
layout: property.layout,
|
|
1192
1195
|
serialize: property.serialize,
|
|
1196
|
+
defaultValue: property.default,
|
|
1193
1197
|
fieldSet: property.fieldSet,
|
|
1194
1198
|
labelPrefix: property.labelPrefix,
|
|
1195
1199
|
purposes: property.purposes || property.purpose,
|
|
@@ -2027,9 +2031,21 @@ class DynamicFormComponent {
|
|
|
2027
2031
|
legacyLabels = input(false);
|
|
2028
2032
|
data = input({});
|
|
2029
2033
|
fields = input(null);
|
|
2030
|
-
|
|
2034
|
+
options = {
|
|
2035
|
+
fieldChanges: new Subject(),
|
|
2036
|
+
formState: {
|
|
2037
|
+
injector: inject(Injector)
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
fieldChanges = this.options.fieldChanges.pipe(map(changes => ({
|
|
2041
|
+
...changes,
|
|
2042
|
+
form: this
|
|
2043
|
+
})));
|
|
2031
2044
|
init = this.fieldChanges.pipe(first());
|
|
2032
|
-
valueChanges = this.fieldChanges
|
|
2045
|
+
valueChanges = this.fieldChanges
|
|
2046
|
+
.pipe(filter(c => c.type === "valueChanges"));
|
|
2047
|
+
expressionChanges = this.fieldChanges
|
|
2048
|
+
.pipe(filter(c => c.type === "expressionChanges"));
|
|
2033
2049
|
language = toSignal(this.events.languageChanged, {
|
|
2034
2050
|
initialValue: this.languages.currentLanguage
|
|
2035
2051
|
});
|
|
@@ -2067,13 +2083,8 @@ class DynamicFormComponent {
|
|
|
2067
2083
|
onSubmit = output();
|
|
2068
2084
|
onFieldChanges = outputFromObservable(this.fieldChanges);
|
|
2069
2085
|
onValueChanges = outputFromObservable(this.valueChanges);
|
|
2086
|
+
onExpressionChanges = outputFromObservable(this.expressionChanges);
|
|
2070
2087
|
onInit = outputFromObservable(this.init);
|
|
2071
|
-
options = {
|
|
2072
|
-
fieldChanges: this.fieldChanges,
|
|
2073
|
-
formState: {
|
|
2074
|
-
injector: inject(Injector)
|
|
2075
|
-
}
|
|
2076
|
-
};
|
|
2077
2088
|
constructor(forms, templates) {
|
|
2078
2089
|
this.forms = forms;
|
|
2079
2090
|
this.templates = templates;
|
|
@@ -2108,7 +2119,7 @@ class DynamicFormComponent {
|
|
|
2108
2119
|
return field?.formControl ?? null;
|
|
2109
2120
|
}
|
|
2110
2121
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, deps: [{ token: DynamicFormService }, { token: DynamicFormTemplateService }], target: i0.ɵɵFactoryTarget.Component });
|
|
2111
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { globalTemplatePrefix: { classPropertyName: "globalTemplatePrefix", publicName: "globalTemplatePrefix", isSignal: true, isRequired: false, transformFunction: null }, 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" }, providers: [DynamicFormTemplateService], 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}.dynamic-form-field>.field-label{position:relative}.dynamic-form-field>.field-label>.field-description{font-size:.95em;font-weight:400;color:#777;margin:0}\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 });
|
|
2122
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: DynamicFormComponent, isStandalone: false, selector: "dynamic-form", inputs: { globalTemplatePrefix: { classPropertyName: "globalTemplatePrefix", publicName: "globalTemplatePrefix", isSignal: true, isRequired: false, transformFunction: null }, 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", onExpressionChanges: "onExpressionChanges", onInit: "onInit" }, providers: [DynamicFormTemplateService], 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}.dynamic-form-field>.field-label{position:relative}.dynamic-form-field>.field-label>.field-description{font-size:.95em;font-weight:400;color:#777;margin:0}\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 });
|
|
2112
2123
|
}
|
|
2113
2124
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormComponent, decorators: [{
|
|
2114
2125
|
type: Component,
|