@stemy/ngx-dynamic-form 19.1.9 → 19.1.10

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 i1 from '@ng-dynamic-forms/core';
2
- import { DynamicInputControlModel, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, serializable, DynamicFormArrayGroupModel as DynamicFormArrayGroupModel$1, DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormGroupModel as DynamicFormGroupModel$1, DynamicFormOption as DynamicFormOption$1, DynamicSelectModel as DynamicSelectModel$1, DynamicCheckboxModel, DynamicDatePickerModel, DynamicInputModel, DynamicTextAreaModel, DynamicFileUploadModel, DynamicFormService as DynamicFormService$1, DynamicRadioGroupModel, DynamicFormValueControlModel, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormArrayComponent, DynamicFormControlComponent, DynamicFormGroupComponent, DYNAMIC_FORM_CONTROL_MAP_FN, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
2
+ import { DynamicInputControlModel, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, serializable, DynamicFormArrayGroupModel as DynamicFormArrayGroupModel$1, DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormGroupModel as DynamicFormGroupModel$1, DynamicFormOption as DynamicFormOption$1, DynamicSelectModel as DynamicSelectModel$1, DynamicCheckboxModel, DynamicDatePickerModel, DynamicInputModel, DynamicTextAreaModel, DynamicFileUploadModel, DynamicFormService as DynamicFormService$1, DynamicRadioGroupModel, DynamicFormValueControlModel, isString, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormArrayComponent, DynamicFormControlComponent, DynamicFormGroupComponent, DYNAMIC_FORM_CONTROL_MAP_FN, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
3
3
  export { DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP, DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, DYNAMIC_FORM_CONTROL_TYPE_FILE_UPLOAD, DYNAMIC_FORM_CONTROL_TYPE_GROUP, DYNAMIC_FORM_CONTROL_TYPE_INPUT, DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP, DYNAMIC_FORM_CONTROL_TYPE_SELECT, DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA, DynamicCheckboxGroupModel, DynamicCheckboxModel, DynamicDatePickerModel, DynamicFileUploadModel, DynamicFormControlComponent, DynamicFormControlModel, DynamicFormsCoreModule, DynamicInputModel, DynamicListDirective, DynamicRadioGroupModel, DynamicTemplateDirective, DynamicTextAreaModel } from '@ng-dynamic-forms/core';
4
4
  import * as i2 from '@stemy/ngx-utils';
5
- import { ObjectUtils, TimerUtils, cachedFactory, StringUtils, OpenApiService, TOASTER_SERVICE, ObservableUtils, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
5
+ import { ObjectUtils, TimerUtils, cachedFactory, StringUtils, OpenApiService, ObservableUtils, TOASTER_SERVICE, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
6
6
  import { __decorate } from 'tslib';
7
7
  import { BehaviorSubject, isObservable, of, Subject, firstValueFrom, Subscription } from 'rxjs';
8
8
  import { map, debounceTime, first, groupBy, mergeMap } from 'rxjs/operators';
@@ -748,38 +748,41 @@ class DynamicFormService extends DynamicFormService$1 {
748
748
  this.api.cache = {};
749
749
  this.schemas = await this.openApi.getSchemas();
750
750
  const fieldSets = [];
751
- const options = ObjectUtils.isObject(customizeOrOptions) ? customizeOrOptions : {};
752
- const customizeModel = ObjectUtils.isFunction(customizeOrOptions)
753
- ? customizeOrOptions : options.customizer;
754
- const customizeModels = async (property, schema, modelType, config, path) => {
755
- const pathPrefix = !path ? `` : `${path}.`;
756
- config.label = !config.label || !options.labelPrefix
757
- ? config.label || ""
758
- : await this.language.getTranslation(`${options.labelPrefix}.${pathPrefix}${config.label}`);
759
- const model = new modelType(config);
760
- if (model instanceof DynamicFormValueControlModel) {
761
- model.value = (model instanceof DynamicDatePickerModel)
762
- ? this.convertToDate(property.default) : property.default;
763
- }
764
- const layout = `${pathPrefix}${model.id}`.toLowerCase().replace(/\./g, "-");
765
- model.layout = {
766
- grid: {
767
- host: `${layout} control-${model.id}`,
768
- container: `${layout}-container`
751
+ const schemaOptions = ObjectUtils.isObject(customizeOrOptions) ? customizeOrOptions : {};
752
+ const customizeModel = ObjectUtils.isFunction(customizeOrOptions) ? customizeOrOptions : schemaOptions.customizer;
753
+ const schema = this.schemas[name];
754
+ const wrapOptions = {
755
+ ...schemaOptions,
756
+ schema,
757
+ customizer: async (property, options, modelType, config, path) => {
758
+ const pathPrefix = !path ? `` : `${path}.`;
759
+ config.label = !config.label || !options.labelPrefix
760
+ ? config.label || ""
761
+ : await this.language.getTranslation(`${options.labelPrefix}.${pathPrefix}${config.label}`);
762
+ const model = new modelType(config);
763
+ if (model instanceof DynamicFormValueControlModel) {
764
+ model.value = (model instanceof DynamicDatePickerModel)
765
+ ? this.convertToDate(property.default) : property.default;
766
+ }
767
+ const layout = `${pathPrefix}${model.id}`.toLowerCase().replace(/\./g, "-");
768
+ model.layout = {
769
+ grid: {
770
+ host: `${layout} control-${model.id}`,
771
+ container: `${layout}-container`
772
+ }
773
+ };
774
+ if (!ObjectUtils.isFunction(customizeModel))
775
+ return [model];
776
+ let res = customizeModel(property, schema, model, config, this.injector);
777
+ if (!res)
778
+ return [model];
779
+ if (res instanceof Promise) {
780
+ res = await res;
769
781
  }
770
- };
771
- if (!ObjectUtils.isFunction(customizeModel))
772
- return [model];
773
- let res = customizeModel(property, schema, model, config, this.injector);
774
- if (!res)
775
- return [model];
776
- if (res instanceof Promise) {
777
- res = await res;
782
+ return Array.isArray(res) ? res : [res];
778
783
  }
779
- return Array.isArray(res) ? res : [res];
780
784
  };
781
- const schema = this.schemas[name];
782
- const controls = await this.getFormModelForSchemaDef(schema, fieldSets, customizeModels, "");
785
+ const controls = await this.getFormModelForSchemaDef(schema, fieldSets, wrapOptions, "");
783
786
  const group = [...controls];
784
787
  // Add id fields if necessary
785
788
  if (controls.length > 0) {
@@ -794,11 +797,11 @@ class DynamicFormService extends DynamicFormService$1 {
794
797
  group,
795
798
  fieldSets
796
799
  };
797
- const root = await customizeModels({
800
+ const root = await wrapOptions.customizer({
798
801
  id: "root",
799
802
  type: "object",
800
803
  properties: schema?.properties || {}
801
- }, schema, DynamicFormGroupModel, config, "");
804
+ }, wrapOptions, DynamicFormGroupModel, config, "");
802
805
  // Check if the customized root wrapper returned an array
803
806
  controls.length = 0;
804
807
  for (const model of root) {
@@ -814,7 +817,7 @@ class DynamicFormService extends DynamicFormService$1 {
814
817
  group: controls
815
818
  });
816
819
  }
817
- async getFormModelForSchemaDef(schema, fieldSets, customizeModels, path) {
820
+ async getFormModelForSchemaDef(schema, fieldSets, options, path) {
818
821
  if (!schema)
819
822
  return [];
820
823
  const keys = Object.keys(schema.properties || {});
@@ -831,7 +834,7 @@ class DynamicFormService extends DynamicFormService$1 {
831
834
  fieldSets.push({ id: fsName, legend: `legend.${fsName}`, fields: [p] });
832
835
  }
833
836
  }
834
- const models = await this.getFormControlModels(property, schema, customizeModels, path);
837
+ const models = await this.getFormControlModels(property, options, path);
835
838
  controls.push(...models);
836
839
  }
837
840
  return controls.filter(t => null !== t);
@@ -841,13 +844,13 @@ class DynamicFormService extends DynamicFormService$1 {
841
844
  return false;
842
845
  return EDITOR_FORMATS.indexOf(property.format) >= 0 || property.format.endsWith("script");
843
846
  }
844
- async getFormControlModels(property, schema, customizeModels, path) {
847
+ async getFormControlModels(property, options, path) {
845
848
  const $enum = property.items?.enum || property.enum;
846
849
  if (Array.isArray($enum) || isStringWithVal(property.optionsPath) || isStringWithVal(property.endpoint)) {
847
850
  if (property.format == "radio") {
848
- return customizeModels(property, schema, DynamicRadioGroupModel, this.getFormRadioConfig(property, schema), path);
851
+ return options.customizer(property, options, DynamicRadioGroupModel, this.getFormRadioConfig(property, options), path);
849
852
  }
850
- return customizeModels(property, schema, DynamicSelectModel, this.getFormSelectConfig(property, schema), path);
853
+ return options.customizer(property, options, DynamicSelectModel, this.getFormSelectConfig(property, options), path);
851
854
  }
852
855
  switch (property.type) {
853
856
  case "string":
@@ -855,31 +858,31 @@ class DynamicFormService extends DynamicFormService$1 {
855
858
  case "integer":
856
859
  case "textarea":
857
860
  if (this.checkIsEditorProperty(property)) {
858
- return customizeModels(property, schema, DynamicEditorModel, this.getFormEditorConfig(property, schema), path);
861
+ return options.customizer(property, options, DynamicEditorModel, this.getFormEditorConfig(property, options), path);
859
862
  }
860
863
  if (property.format == "textarea") {
861
- return customizeModels(property, schema, DynamicTextAreaModel, this.getFormTextareaConfig(property, schema), path);
864
+ return options.customizer(property, options, DynamicTextAreaModel, this.getFormTextareaConfig(property, options), path);
862
865
  }
863
866
  if (property.format == "date") {
864
- return customizeModels(property, schema, DynamicDatePickerModel, this.getFormDatepickerConfig(property, schema), path);
867
+ return options.customizer(property, options, DynamicDatePickerModel, this.getFormDatepickerConfig(property, options), path);
865
868
  }
866
- return customizeModels(property, schema, DynamicInputModel, this.getFormInputConfig(property, schema), path);
869
+ return options.customizer(property, options, DynamicInputModel, this.getFormInputConfig(property, options), path);
867
870
  case "object":
868
- return customizeModels(property, schema, DynamicEditorModel, this.getFormEditorConfig(property, schema), path);
871
+ return options.customizer(property, options, DynamicEditorModel, this.getFormEditorConfig(property, options), path);
869
872
  case "boolean":
870
- return customizeModels(property, schema, DynamicCheckboxModel, this.getFormCheckboxConfig(property, schema), path);
873
+ return options.customizer(property, options, DynamicCheckboxModel, this.getFormCheckboxConfig(property, options), path);
871
874
  case "array":
872
875
  if (findRefs(property).length > 0) {
873
- return customizeModels(property, schema, DynamicFormArrayModel, await this.getFormArrayConfig(property, schema, customizeModels, path), path);
876
+ return options.customizer(property, options, DynamicFormArrayModel, await this.getFormArrayConfig(property, options, path), path);
874
877
  }
875
878
  else {
876
- return customizeModels(property, schema, DynamicInputModel, this.getFormInputConfig(property, schema), path);
879
+ return options.customizer(property, options, DynamicInputModel, this.getFormInputConfig(property, options), path);
877
880
  }
878
881
  case "file":
879
- return customizeModels(property, schema, DynamicFileUploadModel, this.getFormUploadConfig(property, schema), path);
882
+ return options.customizer(property, options, DynamicFileUploadModel, this.getFormUploadConfig(property, options), path);
880
883
  }
881
884
  if (findRefs(property).length > 0) {
882
- return customizeModels(property, schema, DynamicFormGroupModel, await this.getFormGroupConfig(property, schema, customizeModels, !path ? property.id : `${path}.${property.id}`), path);
885
+ return options.customizer(property, options, DynamicFormGroupModel, await this.getFormGroupConfig(property, options, !path ? property.id : `${path}.${property.id}`), path);
883
886
  }
884
887
  return [];
885
888
  }
@@ -898,10 +901,11 @@ class DynamicFormService extends DynamicFormService$1 {
898
901
  }
899
902
  return parent;
900
903
  }
901
- getFormControlConfig(property, schema) {
902
- const validators = this.getValidators(property, schema);
904
+ getFormControlConfig(property, options) {
905
+ const validators = this.getValidators(property, options);
903
906
  const errorMessages = Object.keys(validators).reduce((res, key) => {
904
- res[key] = `error.${key}`;
907
+ res[key] = options.labelPrefix
908
+ ? this.language.getTranslationSync(`${options.labelPrefix}.error.${key}`) : `error.${key}`;
905
909
  return res;
906
910
  }, {});
907
911
  return {
@@ -917,11 +921,11 @@ class DynamicFormService extends DynamicFormService$1 {
917
921
  }, property)
918
922
  };
919
923
  }
920
- async getFormArrayConfig(property, schema, customizeModels, path) {
924
+ async getFormArrayConfig(property, options, path) {
921
925
  const fieldSets = [];
922
926
  const subSchemas = findRefs(property).map(ref => this.schemas[ref]);
923
- const subModels = await Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, customizeModels, path)));
924
- return Object.assign(this.getFormControlConfig(property, schema), {
927
+ const subModels = await Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, options, path)));
928
+ return Object.assign(this.getFormControlConfig(property, options), {
925
929
  groupFactory: () => mergeFormModels(ObjectUtils.copy(subModels)),
926
930
  initialCount: property.initialCount || 0,
927
931
  sortable: property.sortable || false,
@@ -934,16 +938,16 @@ class DynamicFormService extends DynamicFormService$1 {
934
938
  clearItems: property.clearItems !== false
935
939
  });
936
940
  }
937
- async getFormGroupConfig(property, schema, customizeModels, path) {
941
+ async getFormGroupConfig(property, options, path) {
938
942
  const fieldSets = [];
939
943
  const subSchemas = findRefs(property).map(ref => this.schemas[ref]);
940
- const subModels = await Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, customizeModels, path)));
941
- return Object.assign(this.getFormControlConfig(property, schema), {
944
+ const subModels = await Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, options, path)));
945
+ return Object.assign(this.getFormControlConfig(property, options), {
942
946
  fieldSets,
943
947
  group: mergeFormModels(subModels)
944
948
  });
945
949
  }
946
- getFormInputConfig(property, schema) {
950
+ getFormInputConfig(property, options) {
947
951
  let inputType = StringUtils.has(property.id, "password", "Password") ? "password" : (property.format || property.items?.type || property.type);
948
952
  switch (inputType) {
949
953
  case "string":
@@ -960,7 +964,7 @@ class DynamicFormService extends DynamicFormService$1 {
960
964
  break;
961
965
  }
962
966
  const sub = property.type == "array" ? property.items || property : property;
963
- return Object.assign(this.getFormControlConfig(property, schema), {
967
+ return Object.assign(this.getFormControlConfig(property, options), {
964
968
  inputType,
965
969
  autoComplete: property.autoComplete || "off",
966
970
  multiple: property.type == "array",
@@ -975,9 +979,9 @@ class DynamicFormService extends DynamicFormService$1 {
975
979
  placeholder: property.placeholder || ""
976
980
  });
977
981
  }
978
- getFormEditorConfig(property, schema) {
982
+ getFormEditorConfig(property, options) {
979
983
  const sub = property.type == "array" ? property.items || property : property;
980
- return Object.assign(this.getFormControlConfig(property, schema), {
984
+ return Object.assign(this.getFormControlConfig(property, options), {
981
985
  inputType: property.format || "json",
982
986
  convertObject: property.type !== "string",
983
987
  autoComplete: property.autoComplete || "off",
@@ -991,8 +995,8 @@ class DynamicFormService extends DynamicFormService$1 {
991
995
  placeholder: property.placeholder || ""
992
996
  });
993
997
  }
994
- getFormTextareaConfig(property, schema) {
995
- return Object.assign(this.getFormControlConfig(property, schema), {
998
+ getFormTextareaConfig(property, options) {
999
+ return Object.assign(this.getFormControlConfig(property, options), {
996
1000
  cols: property.cols || null,
997
1001
  rows: property.rows || 10,
998
1002
  wrap: property.wrap || false,
@@ -1003,22 +1007,24 @@ class DynamicFormService extends DynamicFormService$1 {
1003
1007
  placeholder: property.placeholder || ""
1004
1008
  });
1005
1009
  }
1006
- getFormDatepickerConfig(property, schema) {
1007
- return Object.assign(this.getFormControlConfig(property, schema), {
1010
+ getFormDatepickerConfig(property, options) {
1011
+ return Object.assign(this.getFormControlConfig(property, options), {
1008
1012
  format: property.dateFormat || "dd.MM.yyyy",
1009
1013
  min: this.convertToDate(property.min),
1010
1014
  max: this.convertToDate(property.max),
1011
1015
  });
1012
1016
  }
1013
- getFormSelectOptions(property, schema) {
1017
+ getFormSelectOptions(property, options) {
1014
1018
  const $enum = property.items?.enum || property.enum;
1015
1019
  if (Array.isArray($enum)) {
1016
1020
  return new FormSelectSubject((selectModel, formControl) => {
1017
- const options = $enum.map(value => {
1018
- const label = property.translatable ? `${property.id}.${value}` : `${value}`;
1021
+ const selectOptions = $enum.map(value => {
1022
+ const label = options.labelPrefix
1023
+ ? this.language.getTranslationSync(`${options.labelPrefix}.${property.id}.${value}`)
1024
+ : `${property.id}.${value}`;
1019
1025
  return { value, label };
1020
1026
  });
1021
- return this.fixSelectOptions(selectModel, formControl, options);
1027
+ return this.fixSelectOptions(selectModel, formControl, selectOptions);
1022
1028
  });
1023
1029
  }
1024
1030
  if (isStringWithVal(property.optionsPath)) {
@@ -1077,24 +1083,24 @@ class DynamicFormService extends DynamicFormService$1 {
1077
1083
  return this.fixSelectOptions(selectModel, control, options);
1078
1084
  });
1079
1085
  }
1080
- getFormRadioConfig(property, schema) {
1081
- return Object.assign(this.getFormControlConfig(property, schema), {
1082
- options: this.getFormSelectOptions(property, schema),
1086
+ getFormRadioConfig(property, options) {
1087
+ return Object.assign(this.getFormControlConfig(property, options), {
1088
+ options: this.getFormSelectOptions(property, options),
1083
1089
  });
1084
1090
  }
1085
- getFormSelectConfig(property, schema) {
1086
- return Object.assign(this.getFormControlConfig(property, schema), {
1087
- options: this.getFormSelectOptions(property, schema),
1091
+ getFormSelectConfig(property, options) {
1092
+ return Object.assign(this.getFormControlConfig(property, options), {
1093
+ options: this.getFormSelectOptions(property, options),
1088
1094
  multiple: property.type == "array",
1089
1095
  groupBy: property.groupBy,
1090
1096
  inline: property.inline,
1091
1097
  allowEmpty: property.allowEmpty,
1092
1098
  });
1093
1099
  }
1094
- getFormUploadConfig(property, schema) {
1100
+ getFormUploadConfig(property, options) {
1095
1101
  const url = this.api.url(property.url || "assets");
1096
1102
  const { accept, autoUpload, maxSize, minSize, removeUrl, showFileList } = property;
1097
- return Object.assign(this.getFormControlConfig(property, schema), {
1103
+ return Object.assign(this.getFormControlConfig(property, options), {
1098
1104
  url,
1099
1105
  accept,
1100
1106
  autoUpload,
@@ -1104,8 +1110,8 @@ class DynamicFormService extends DynamicFormService$1 {
1104
1110
  showFileList
1105
1111
  });
1106
1112
  }
1107
- getFormCheckboxConfig(property, schema) {
1108
- return Object.assign(this.getFormControlConfig(property, schema), {
1113
+ getFormCheckboxConfig(property, options) {
1114
+ return Object.assign(this.getFormControlConfig(property, options), {
1109
1115
  indeterminate: property.indeterminate || false
1110
1116
  });
1111
1117
  }
@@ -1136,8 +1142,9 @@ class DynamicFormService extends DynamicFormService$1 {
1136
1142
  }
1137
1143
  return options;
1138
1144
  }
1139
- getValidators(property, schema) {
1145
+ getValidators(property, options) {
1140
1146
  const validators = {};
1147
+ const schema = options.schema;
1141
1148
  if (ObjectUtils.isArray(schema.required) && schema.required.indexOf(property.id) >= 0) {
1142
1149
  validators.required = null;
1143
1150
  }
@@ -1160,6 +1167,9 @@ class DynamicFormService extends DynamicFormService$1 {
1160
1167
  if (!isNaN(property.maximum)) {
1161
1168
  validators.max = property.maximum;
1162
1169
  }
1170
+ if (isString(property.pattern) && property.pattern.length) {
1171
+ validators.pattern = property.pattern;
1172
+ }
1163
1173
  switch (property.format) {
1164
1174
  case "email":
1165
1175
  validators.email = null;
@@ -1198,6 +1208,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1198
1208
  class AsyncSubmitDirective {
1199
1209
  toaster;
1200
1210
  cdr;
1211
+ zone;
1201
1212
  elem;
1202
1213
  renderer;
1203
1214
  method;
@@ -1208,8 +1219,7 @@ class AsyncSubmitDirective {
1208
1219
  loading;
1209
1220
  disabled;
1210
1221
  callback;
1211
- onStatusChange;
1212
- onSubmit;
1222
+ subscription;
1213
1223
  get isDisabled() {
1214
1224
  return this.disabled;
1215
1225
  }
@@ -1224,9 +1234,10 @@ class AsyncSubmitDirective {
1224
1234
  get isLoading() {
1225
1235
  return this.loading;
1226
1236
  }
1227
- constructor(toaster, cdr, elem, renderer) {
1237
+ constructor(toaster, cdr, zone, elem, renderer) {
1228
1238
  this.toaster = toaster;
1229
1239
  this.cdr = cdr;
1240
+ this.zone = zone;
1230
1241
  this.elem = elem;
1231
1242
  this.renderer = renderer;
1232
1243
  this.onSuccess = new EventEmitter();
@@ -1235,12 +1246,29 @@ class AsyncSubmitDirective {
1235
1246
  return;
1236
1247
  renderer.setAttribute(elem.nativeElement, "type", "button");
1237
1248
  }
1238
- ngOnInit() {
1249
+ ngOnChanges(changes) {
1250
+ // Clear old subscription
1251
+ this.subscription?.unsubscribe();
1252
+ // Check if form changed
1253
+ if (changes.form) {
1254
+ const form = changes.form.currentValue;
1255
+ if (!form)
1256
+ return;
1257
+ // Force form for checking changes after fields get autofilled by the browser
1258
+ // setTimeout(() => {
1259
+ // console.log(
1260
+ // this.elem.nativeElement,
1261
+ // this.elem.nativeElement.focus
1262
+ // );
1263
+ // this.elem.nativeElement.focus?.();
1264
+ // }, 1500);
1265
+ }
1266
+ // Handle other things if we have a form instance
1239
1267
  if (!this.form)
1240
1268
  return;
1241
1269
  this.isDisabled = this.form.group?.status !== "VALID";
1242
1270
  this.cdr.detectChanges();
1243
- this.onStatusChange = this.form.group?.statusChanges.subscribe(() => {
1271
+ this.subscription = ObservableUtils.multiSubscription(this.form.group?.statusChanges.subscribe(() => {
1244
1272
  const status = this.form.group?.status;
1245
1273
  this.isDisabled = status !== "VALID";
1246
1274
  this.cdr.detectChanges();
@@ -1250,14 +1278,10 @@ class AsyncSubmitDirective {
1250
1278
  this.callback();
1251
1279
  }
1252
1280
  this.callback = null;
1253
- });
1254
- this.onSubmit = this.form.onSubmit?.pipe(debounceTime(200)).subscribe(() => this.callMethod());
1281
+ }), this.form.onSubmit?.pipe(debounceTime(200)).subscribe(() => this.callMethod()));
1255
1282
  }
1256
1283
  ngOnDestroy() {
1257
- if (this.onStatusChange)
1258
- this.onStatusChange.unsubscribe();
1259
- if (this.onSubmit)
1260
- this.onSubmit.unsubscribe();
1284
+ this.subscription?.unsubscribe();
1261
1285
  }
1262
1286
  click() {
1263
1287
  this.callback = () => this.callMethod();
@@ -1285,8 +1309,8 @@ class AsyncSubmitDirective {
1285
1309
  this.toaster.error(reason.message, reason.context);
1286
1310
  });
1287
1311
  }
1288
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AsyncSubmitDirective, deps: [{ token: TOASTER_SERVICE }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
1289
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: AsyncSubmitDirective, isStandalone: false, selector: "[async-submit]", inputs: { method: ["async-submit", "method"], form: "form", context: "context" }, outputs: { onSuccess: "onSuccess", onError: "onError" }, host: { listeners: { "click": "click()" }, properties: { "class.disabled": "this.isDisabled", "class.loading": "this.isLoading" } }, exportAs: ["async-submit"], ngImport: i0 });
1312
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AsyncSubmitDirective, deps: [{ token: TOASTER_SERVICE }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
1313
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.3", type: AsyncSubmitDirective, isStandalone: false, selector: "[async-submit]", inputs: { method: ["async-submit", "method"], form: "form", context: "context" }, outputs: { onSuccess: "onSuccess", onError: "onError" }, host: { listeners: { "click": "click()" }, properties: { "class.disabled": "this.isDisabled", "class.loading": "this.isLoading" } }, exportAs: ["async-submit"], usesOnChanges: true, ngImport: i0 });
1290
1314
  }
1291
1315
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AsyncSubmitDirective, decorators: [{
1292
1316
  type: Directive,
@@ -1298,7 +1322,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1298
1322
  }], ctorParameters: () => [{ type: undefined, decorators: [{
1299
1323
  type: Inject,
1300
1324
  args: [TOASTER_SERVICE]
1301
- }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { method: [{
1325
+ }] }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { method: [{
1302
1326
  type: Input,
1303
1327
  args: ["async-submit"]
1304
1328
  }], form: [{