@stemy/ngx-dynamic-form 10.2.27 → 10.2.28

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.
Files changed (26) hide show
  1. package/bundles/stemy-ngx-dynamic-form.umd.js +141 -18
  2. package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
  3. package/bundles/stemy-ngx-dynamic-form.umd.min.js +1 -1
  4. package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +1 -1
  5. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-array.component.js +53 -0
  6. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.js +13 -2
  7. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-group.component.js +53 -0
  8. package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form.component.js +12 -2
  9. package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +8 -10
  10. package/esm2015/ngx-dynamic-form/utils/misc.js +15 -1
  11. package/esm2015/public_api.js +3 -1
  12. package/esm2015/stemy-ngx-dynamic-form.js +1 -2
  13. package/fesm2015/stemy-ngx-dynamic-form.js +138 -17
  14. package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
  15. package/ngx-dynamic-form/components/base/dynamic-base-form-array.component.d.ts +20 -0
  16. package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +1 -0
  17. package/ngx-dynamic-form/components/base/dynamic-base-form-group.component.d.ts +20 -0
  18. package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +2 -1
  19. package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +3 -1
  20. package/ngx-dynamic-form/utils/misc.d.ts +2 -0
  21. package/package.json +1 -1
  22. package/public_api.d.ts +2 -0
  23. package/stemy-ngx-dynamic-form.d.ts +0 -1
  24. package/stemy-ngx-dynamic-form.metadata.json +1 -1
  25. package/esm2015/ngx-dynamic-form/services/dynamic-form-validation.service.js +0 -11
  26. package/ngx-dynamic-form/services/dynamic-form-validation.service.d.ts +0 -5
@@ -1,9 +1,9 @@
1
1
  import { ReflectUtils, ObjectUtils, UniqueUtils, StringUtils, OpenApiService, TOASTER_SERVICE, ObservableUtils, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
2
2
  import { Subject, Subscription } from 'rxjs';
3
3
  import { __awaiter } from 'tslib';
4
- import { EventEmitter, Injectable, Directive, Inject, ChangeDetectorRef, ElementRef, Renderer2, Input, Output, HostBinding, HostListener, QueryList, Component, ChangeDetectionStrategy, ContentChildren, ViewChildren, ViewChild, ComponentFactoryResolver, ViewContainerRef, NgModule } from '@angular/core';
4
+ import { EventEmitter, Injectable, Directive, Inject, ChangeDetectorRef, ElementRef, Renderer2, Input, Output, HostBinding, HostListener, QueryList, Component, ChangeDetectionStrategy, ContentChildren, ViewChildren, ViewChild, forwardRef, ComponentFactoryResolver, ViewContainerRef, NgModule } from '@angular/core';
5
5
  import { FormGroup, FormArray, NgForm, FormsModule, ReactiveFormsModule, NG_VALIDATORS } from '@angular/forms';
6
- import { DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormService as DynamicFormService$1, DynamicSelectModel, DynamicFormGroupModel, DynamicInputModel, DynamicFileUploadModel, DynamicCheckboxModel, DynamicTextAreaModel, DynamicFormComponentService, DynamicFormValidationService as DynamicFormValidationService$1, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormLayoutService, DynamicFormRelationService, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
6
+ import { DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormService as DynamicFormService$1, DynamicSelectModel, DynamicFormGroupModel, DynamicInputModel, DynamicFileUploadModel, DynamicCheckboxModel, DynamicTextAreaModel, DynamicFormComponentService, DynamicFormValidationService, DynamicFormComponent, DynamicTemplateDirective, DynamicFormArrayComponent, DynamicFormLayoutService, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormRelationService, DynamicFormGroupComponent, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
7
7
  import { first } from 'rxjs/operators';
8
8
  import { CommonModule } from '@angular/common';
9
9
 
@@ -239,6 +239,20 @@ class FormSelectSubject extends FormSubject {
239
239
 
240
240
  function isStringWithVal(val) {
241
241
  return typeof val == "string" && val.length > 0;
242
+ }
243
+ function collectPathAble(start, getter) {
244
+ if (!start || !getter(start))
245
+ return [];
246
+ const parts = [];
247
+ let currentPath = start;
248
+ while (currentPath) {
249
+ const val = getter(currentPath);
250
+ if (val) {
251
+ parts.unshift(val);
252
+ }
253
+ currentPath = currentPath.parent;
254
+ }
255
+ return parts;
242
256
  }
243
257
 
244
258
  class DynamicFormArrayModel extends DynamicFormArrayModel$1 {
@@ -649,7 +663,7 @@ DynamicFormService.decorators = [
649
663
  ];
650
664
  DynamicFormService.ctorParameters = () => [
651
665
  { type: DynamicFormComponentService },
652
- { type: DynamicFormValidationService$1 },
666
+ { type: DynamicFormValidationService },
653
667
  { type: OpenApiService }
654
668
  ];
655
669
 
@@ -815,6 +829,15 @@ class DynamicBaseFormComponent extends DynamicFormComponent {
815
829
  this.formService.clearFormArray(formArray, formArrayModel);
816
830
  this.changeDetectorRef.detectChanges();
817
831
  }
832
+ getClass(model) {
833
+ const parts = collectPathAble(model, p => p.id);
834
+ if (parts.length == 0)
835
+ return "";
836
+ if (model instanceof DynamicFormGroupModel) {
837
+ return `form-group-${parts.join("-")}`;
838
+ }
839
+ return `form-control-${parts.join("-")}`;
840
+ }
818
841
  validate(showErrors = true) {
819
842
  if (!this.group)
820
843
  return Promise.resolve();
@@ -872,6 +895,56 @@ DynamicBaseFormComponent.propDecorators = {
872
895
  ngForm: [{ type: ViewChild, args: [NgForm,] }]
873
896
  };
874
897
 
898
+ class DynamicBaseFormArrayComponent extends DynamicFormArrayComponent {
899
+ constructor(layoutService, validationService) {
900
+ super(layoutService, validationService);
901
+ this.layoutService = layoutService;
902
+ this.validationService = validationService;
903
+ this.blur = new EventEmitter();
904
+ this.change = new EventEmitter();
905
+ this.customEvent = new EventEmitter();
906
+ this.focus = new EventEmitter();
907
+ }
908
+ getClass(context, place, model) {
909
+ return [
910
+ context == "element" ? this.getModelClass(model) : null,
911
+ super.getClass(context, place, model)
912
+ ].filter(cls => !!cls).join(" ");
913
+ }
914
+ getModelClass(model) {
915
+ const parts = collectPathAble(model, p => p.id);
916
+ if (parts.length == 0)
917
+ return "";
918
+ if (model instanceof DynamicFormGroupModel) {
919
+ return `form-group-${parts.join("-")}`;
920
+ }
921
+ return `form-control-${parts.join("-")}`;
922
+ }
923
+ }
924
+ DynamicBaseFormArrayComponent.decorators = [
925
+ { type: Component, args: [{
926
+ selector: "dynamic-base-form-array",
927
+ template: "",
928
+ changeDetection: ChangeDetectionStrategy.OnPush
929
+ },] }
930
+ ];
931
+ DynamicBaseFormArrayComponent.ctorParameters = () => [
932
+ { type: DynamicFormLayoutService },
933
+ { type: DynamicFormValidationService }
934
+ ];
935
+ DynamicBaseFormArrayComponent.propDecorators = {
936
+ formLayout: [{ type: Input }],
937
+ group: [{ type: Input }],
938
+ layout: [{ type: Input }],
939
+ model: [{ type: Input }],
940
+ templates: [{ type: Input }],
941
+ blur: [{ type: Output }],
942
+ change: [{ type: Output }],
943
+ customEvent: [{ type: Output }],
944
+ focus: [{ type: Output }],
945
+ components: [{ type: ViewChildren, args: [forwardRef(() => DynamicFormControlContainerComponent),] }]
946
+ };
947
+
875
948
  class DynamicBaseFormControlContainerComponent extends DynamicFormControlContainerComponent {
876
949
  constructor(form, changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService) {
877
950
  super(changeDetectorRef, componentFactoryResolver, layoutService, validationService, componentService, relationService);
@@ -916,6 +989,16 @@ class DynamicBaseFormControlContainerComponent extends DynamicFormControlContain
916
989
  super.ngOnDestroy();
917
990
  this.onDetectChanges.unsubscribe();
918
991
  }
992
+ getLabel() {
993
+ var _a;
994
+ const label = collectPathAble(this.model, p => p.label);
995
+ if (label.length == 0)
996
+ return "";
997
+ if ((_a = this.form) === null || _a === void 0 ? void 0 : _a.labelPrefix) {
998
+ label.unshift(this.form.labelPrefix);
999
+ }
1000
+ return label.join(".");
1001
+ }
919
1002
  createFormControlComponent() {
920
1003
  var _a;
921
1004
  super.createFormControlComponent();
@@ -940,7 +1023,7 @@ DynamicBaseFormControlContainerComponent.ctorParameters = () => [
940
1023
  { type: ChangeDetectorRef },
941
1024
  { type: ComponentFactoryResolver },
942
1025
  { type: DynamicFormLayoutService },
943
- { type: DynamicFormValidationService$1 },
1026
+ { type: DynamicFormValidationService },
944
1027
  { type: DynamicFormComponentService },
945
1028
  { type: DynamicFormRelationService }
946
1029
  ];
@@ -959,19 +1042,62 @@ DynamicBaseFormControlContainerComponent.propDecorators = {
959
1042
  componentViewContainerRef: [{ type: ViewChild, args: ["componentViewContainer", { read: ViewContainerRef, static: true },] }]
960
1043
  };
961
1044
 
962
- class DynamicFormValidationService extends DynamicFormValidationService$1 {
963
- showErrorMessages(control, model, hasFocus) {
964
- return super.showErrorMessages(control, model, hasFocus);
1045
+ class DynamicBaseFormGroupComponent extends DynamicFormGroupComponent {
1046
+ constructor(layoutService, validationService) {
1047
+ super(layoutService, validationService);
1048
+ this.layoutService = layoutService;
1049
+ this.validationService = validationService;
1050
+ this.blur = new EventEmitter();
1051
+ this.change = new EventEmitter();
1052
+ this.customEvent = new EventEmitter();
1053
+ this.focus = new EventEmitter();
1054
+ }
1055
+ getClass(context, place, model) {
1056
+ return [
1057
+ context == "element" ? this.getModelClass(model) : null,
1058
+ super.getClass(context, place, model)
1059
+ ].filter(cls => !!cls).join(" ");
1060
+ }
1061
+ getModelClass(model) {
1062
+ const parts = collectPathAble(model, p => p.id);
1063
+ if (parts.length == 0)
1064
+ return "";
1065
+ if (model instanceof DynamicFormGroupModel) {
1066
+ return `form-group-${parts.join("-")}`;
1067
+ }
1068
+ return `form-control-${parts.join("-")}`;
965
1069
  }
966
1070
  }
967
- DynamicFormValidationService.decorators = [
968
- { type: Injectable }
969
- ];
1071
+ DynamicBaseFormGroupComponent.decorators = [
1072
+ { type: Component, args: [{
1073
+ selector: "dynamic-base-form-group",
1074
+ template: "",
1075
+ changeDetection: ChangeDetectionStrategy.OnPush
1076
+ },] }
1077
+ ];
1078
+ DynamicBaseFormGroupComponent.ctorParameters = () => [
1079
+ { type: DynamicFormLayoutService },
1080
+ { type: DynamicFormValidationService }
1081
+ ];
1082
+ DynamicBaseFormGroupComponent.propDecorators = {
1083
+ formLayout: [{ type: Input }],
1084
+ group: [{ type: Input }],
1085
+ layout: [{ type: Input }],
1086
+ model: [{ type: Input }],
1087
+ templates: [{ type: Input }],
1088
+ blur: [{ type: Output }],
1089
+ change: [{ type: Output }],
1090
+ customEvent: [{ type: Output }],
1091
+ focus: [{ type: Output }],
1092
+ components: [{ type: ViewChildren, args: [forwardRef(() => DynamicFormControlContainerComponent),] }]
1093
+ };
970
1094
 
971
1095
  // --- Components ---
972
1096
  const components = [
973
1097
  DynamicBaseFormComponent,
974
- DynamicBaseFormControlContainerComponent
1098
+ DynamicBaseFormArrayComponent,
1099
+ DynamicBaseFormControlContainerComponent,
1100
+ DynamicBaseFormGroupComponent
975
1101
  ];
976
1102
  // --- Directives ---
977
1103
  const directives = [
@@ -994,14 +1120,9 @@ class NgxDynamicFormModule {
994
1120
  ngModule: NgxDynamicFormModule,
995
1121
  providers: [
996
1122
  DynamicFormService,
997
- DynamicFormValidationService,
998
1123
  {
999
1124
  provide: DynamicFormService$1,
1000
1125
  useExisting: DynamicFormService
1001
- },
1002
- {
1003
- provide: DynamicFormValidationService$1,
1004
- useExisting: DynamicFormValidationService
1005
1126
  }
1006
1127
  ]
1007
1128
  };
@@ -1049,5 +1170,5 @@ NgxDynamicFormModule.decorators = [
1049
1170
  * Generated bundle index. Do not edit.
1050
1171
  */
1051
1172
 
1052
- export { AsyncSubmitDirective, DynamicBaseFormComponent, DynamicBaseFormControlContainerComponent, DynamicFormService, FormFieldSet, FormFile, FormInput, FormModel, FormSelect, FormSelectSubject, FormSerializable, FormStatic, FormSubject, NgxDynamicFormModule, createFormControl, createFormInput, createFormModel, createFormSelect, createFormStatic, defaultSerializer, defineFormControl, getFormControl, getFormFieldSets, getFormSerializer, validateItemsMaxLength, validateItemsMaxValue, validateItemsMinLength, validateItemsMinValue, validateJSON, validatePhone, validateRequiredTranslation, components as ɵa, directives as ɵb, pipes as ɵc, DynamicFormValidationService as ɵd };
1173
+ export { AsyncSubmitDirective, DynamicBaseFormArrayComponent, DynamicBaseFormComponent, DynamicBaseFormControlContainerComponent, DynamicBaseFormGroupComponent, DynamicFormService, FormFieldSet, FormFile, FormInput, FormModel, FormSelect, FormSelectSubject, FormSerializable, FormStatic, FormSubject, NgxDynamicFormModule, createFormControl, createFormInput, createFormModel, createFormSelect, createFormStatic, defaultSerializer, defineFormControl, getFormControl, getFormFieldSets, getFormSerializer, validateItemsMaxLength, validateItemsMaxValue, validateItemsMinLength, validateItemsMinValue, validateJSON, validatePhone, validateRequiredTranslation, components as ɵa, directives as ɵb, pipes as ɵc };
1053
1174
  //# sourceMappingURL=stemy-ngx-dynamic-form.js.map