@stemy/ngx-dynamic-form 19.9.37 → 19.9.39
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,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, Inject, Injectable, untracked, input, Renderer2, ElementRef, computed, signal, effect, HostBinding, Directive, Input, Optional, Pipe, Type, Component, Injector, output, ChangeDetectionStrategy, ViewEncapsulation, viewChild, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from '@stemy/ngx-utils';
|
|
4
|
-
import { cachedFactory, ReflectUtils, ObjectUtils, convertToDateFormat, LANGUAGE_SERVICE, convertToDate, ForbiddenZone, SetUtils, ArrayUtils, API_SERVICE, StringUtils, AsyncMethodBase, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
4
|
+
import { cachedFactory, ReflectUtils, ObjectUtils, convertToDateFormat, LANGUAGE_SERVICE, convertToDate, ForbiddenZone, SetUtils, ArrayUtils, API_SERVICE, ROOT_ELEMENT, StringUtils, Enum, AsyncMethodBase, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
5
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 * as i1 from '@angular/forms';
|
|
@@ -673,10 +673,12 @@ function getFormValidationErrors(controls, parentPath = "") {
|
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
class DynamicFormBuilderService {
|
|
676
|
-
constructor(injector, events, api, languages, defaultNumericStep) {
|
|
676
|
+
constructor(injector, events, universal, api, rootElement, languages, defaultNumericStep) {
|
|
677
677
|
this.injector = injector;
|
|
678
678
|
this.events = events;
|
|
679
|
+
this.universal = universal;
|
|
679
680
|
this.api = api;
|
|
681
|
+
this.rootElement = rootElement;
|
|
680
682
|
this.languages = languages;
|
|
681
683
|
this.defaultNumericStep = defaultNumericStep;
|
|
682
684
|
const lang = new BehaviorSubject(this.languages.currentLanguage);
|
|
@@ -793,13 +795,25 @@ class DynamicFormBuilderService {
|
|
|
793
795
|
case "checkbox":
|
|
794
796
|
data.defaultValue = data.defaultValue ?? false;
|
|
795
797
|
break;
|
|
798
|
+
case "color":
|
|
799
|
+
const styles = this.rootElement && this.universal.isBrowser
|
|
800
|
+
? getComputedStyle(this.rootElement)
|
|
801
|
+
: null;
|
|
802
|
+
const value = (!styles ? "#DEDEDE" : null)
|
|
803
|
+
|| styles.getPropertyValue("--primary-color")
|
|
804
|
+
|| styles.getPropertyValue("--mat-sys-primary")
|
|
805
|
+
|| "#DEDEDE";
|
|
806
|
+
data.defaultValue = data.defaultValue ?? value;
|
|
807
|
+
break;
|
|
796
808
|
case "number":
|
|
797
809
|
case "integer":
|
|
810
|
+
data.defaultValue = 0;
|
|
798
811
|
props.min = convertToNumber(data.min, MIN_INPUT_NUM);
|
|
799
812
|
props.max = convertToNumber(data.max, MAX_INPUT_NUM);
|
|
800
813
|
break;
|
|
801
814
|
case "date":
|
|
802
815
|
case "datetime-local":
|
|
816
|
+
data.defaultValue = data.defaultValue ?? convertToDateFormat(new Date(), type);
|
|
803
817
|
props.min = convertToDateFormat(data.min, type);
|
|
804
818
|
props.max = convertToDateFormat(data.max, type);
|
|
805
819
|
break;
|
|
@@ -1136,7 +1150,7 @@ class DynamicFormBuilderService {
|
|
|
1136
1150
|
path: target => {
|
|
1137
1151
|
const tp = target.parent;
|
|
1138
1152
|
const prefix = tp?.path || "";
|
|
1139
|
-
return [prefix, String(target.key ?? "")].filter(ObjectUtils.isStringWithValue).join("
|
|
1153
|
+
return [prefix, String(target.key ?? "")].filter(ObjectUtils.isStringWithValue).join(".");
|
|
1140
1154
|
},
|
|
1141
1155
|
testId: target => {
|
|
1142
1156
|
const tp = target.parent;
|
|
@@ -1153,14 +1167,17 @@ class DynamicFormBuilderService {
|
|
|
1153
1167
|
});
|
|
1154
1168
|
return field;
|
|
1155
1169
|
}
|
|
1156
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormBuilderService, deps: [{ token: i0.Injector }, { token: i2.EventsService }, { token: API_SERVICE }, { token: LANGUAGE_SERVICE }, { token: DEFAULT_NUMERIC_STEP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1170
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormBuilderService, deps: [{ token: i0.Injector }, { token: i2.EventsService }, { token: i2.UniversalService }, { token: API_SERVICE }, { token: ROOT_ELEMENT }, { token: LANGUAGE_SERVICE }, { token: DEFAULT_NUMERIC_STEP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1157
1171
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormBuilderService }); }
|
|
1158
1172
|
}
|
|
1159
1173
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormBuilderService, decorators: [{
|
|
1160
1174
|
type: Injectable
|
|
1161
|
-
}], ctorParameters: () => [{ type: i0.Injector }, { type: i2.EventsService }, { type: undefined, decorators: [{
|
|
1175
|
+
}], ctorParameters: () => [{ type: i0.Injector }, { type: i2.EventsService }, { type: i2.UniversalService }, { type: undefined, decorators: [{
|
|
1162
1176
|
type: Inject,
|
|
1163
1177
|
args: [API_SERVICE]
|
|
1178
|
+
}] }, { type: HTMLElement, decorators: [{
|
|
1179
|
+
type: Inject,
|
|
1180
|
+
args: [ROOT_ELEMENT]
|
|
1164
1181
|
}] }, { type: undefined, decorators: [{
|
|
1165
1182
|
type: Inject,
|
|
1166
1183
|
args: [LANGUAGE_SERVICE]
|
|
@@ -1733,7 +1750,8 @@ class DynamicFormService {
|
|
|
1733
1750
|
Object.assign(result, group);
|
|
1734
1751
|
continue;
|
|
1735
1752
|
}
|
|
1736
|
-
|
|
1753
|
+
const value = control.value;
|
|
1754
|
+
result[key] = value instanceof Enum ? value.value : value;
|
|
1737
1755
|
}
|
|
1738
1756
|
return result;
|
|
1739
1757
|
}
|