@stemy/ngx-dynamic-form 19.9.39 → 19.9.40

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.
@@ -16,8 +16,13 @@ import { FormlySelectModule } from '@ngx-formly/core/select';
16
16
 
17
17
  // --- Basic frm constants ---
18
18
  const FORM_ROOT_ID = "__root";
19
+ function formSchemaNotFound(name) {
20
+ console.warn(`Schema with name "${name}" not found.`);
21
+ return [];
22
+ }
19
23
  // --- Module Configuration ---
20
24
  const DEFAULT_NUMERIC_STEP = new InjectionToken("DEFAULT_NUMERIC_STEP");
25
+ const FORM_SCHEMA_NOT_FOUND = new InjectionToken("FORM_SCHEMA_NOT_FOUND");
21
26
 
22
27
  function customizeFormField(...providers) {
23
28
  const factory = cachedFactory(providers);
@@ -337,7 +342,6 @@ function isFieldHidden(field) {
337
342
  const MIN_INPUT_NUM = -1999999999;
338
343
  const MAX_INPUT_NUM = 1999999999;
339
344
  const EDITOR_TYPES = ["php", "json", "html", "css", "scss"];
340
- const CUSTOM_INPUT_TYPES = ["checkbox", "textarea", "wysiwyg", "date", "password"];
341
345
 
342
346
  function validationMessage(errorKey) {
343
347
  const key = `form.error.${errorKey}`;
@@ -671,6 +675,7 @@ function getFormValidationErrors(controls, parentPath = "") {
671
675
  });
672
676
  return errors;
673
677
  }
678
+ const CUSTOM_INPUT_TYPES = ["checkbox", "textarea", "wysiwyg", "date", "password"];
674
679
 
675
680
  class DynamicFormBuilderService {
676
681
  constructor(injector, events, universal, api, rootElement, languages, defaultNumericStep) {
@@ -1619,11 +1624,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImpo
1619
1624
  }], ctorParameters: () => [{ type: i2.OpenApiService }, { type: i0.Injector }, { type: DynamicFormBuilderService }] });
1620
1625
 
1621
1626
  class DynamicFormService {
1622
- constructor(fs, fb, injector, api) {
1627
+ constructor(fs, fb, injector, schemaNotFound) {
1623
1628
  this.fs = fs;
1624
1629
  this.fb = fb;
1625
1630
  this.injector = injector;
1626
- this.api = api;
1631
+ this.schemaNotFound = schemaNotFound;
1627
1632
  }
1628
1633
  async getFormFieldsForSchema(name, customizeOrOptions) {
1629
1634
  const group = await this.getFormFieldGroupBySchemaName(name, customizeOrOptions, "getFormFieldsForSchema");
@@ -1634,26 +1639,23 @@ class DynamicFormService {
1634
1639
  }
1635
1640
  async getFormFieldGroupBySchemaName(name, customizeOrOptions, restrictedMethod) {
1636
1641
  const schema = await this.fs.getSchema(name);
1637
- if (!schema) {
1638
- console.warn(`Schema with name "${name}" not found.`);
1639
- return {
1640
- id: FORM_ROOT_ID,
1641
- path: "",
1642
- wrappers: ["form-group"],
1643
- fieldGroup: [],
1644
- props: {},
1645
- hooks: {},
1646
- expressions: {}
1647
- };
1648
- }
1649
1642
  const wrapOptions = await toWrapOptions(customizeOrOptions, this.injector, schema, `"DynamicFormService.${restrictedMethod}" is called from a customizer, which is not allowed. Please use DynamicFormSchemaService instead!`);
1650
- const config = await this.fb.createFormGroup(null, parent => {
1651
- return this.fs.getFormFieldsForSchema(schema, parent, wrapOptions);
1652
- }, {
1643
+ const rootData = {
1653
1644
  label: "",
1654
1645
  hidden: false,
1655
1646
  className: "dynamic-form-root-group"
1656
- }, null, wrapOptions);
1647
+ };
1648
+ let config;
1649
+ if (!schema) {
1650
+ config = await this.fb.createFormGroup(null, async (parent) => {
1651
+ return this.schemaNotFound(name, parent, wrapOptions, this.injector);
1652
+ }, rootData, null, wrapOptions);
1653
+ }
1654
+ else {
1655
+ config = await this.fb.createFormGroup(null, parent => {
1656
+ return this.fs.getFormFieldsForSchema(schema, parent, wrapOptions);
1657
+ }, rootData, null, wrapOptions);
1658
+ }
1657
1659
  const fields = config.fieldGroup || [];
1658
1660
  const fieldGroup = [...fields];
1659
1661
  config.id = FORM_ROOT_ID;
@@ -1774,14 +1776,14 @@ class DynamicFormService {
1774
1776
  }
1775
1777
  });
1776
1778
  }
1777
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormService, deps: [{ token: DynamicFormSchemaService }, { token: DynamicFormBuilderService }, { token: i0.Injector }, { token: API_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
1779
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormService, deps: [{ token: DynamicFormSchemaService }, { token: DynamicFormBuilderService }, { token: i0.Injector }, { token: FORM_SCHEMA_NOT_FOUND }], target: i0.ɵɵFactoryTarget.Injectable }); }
1778
1780
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormService }); }
1779
1781
  }
1780
1782
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormService, decorators: [{
1781
1783
  type: Injectable
1782
1784
  }], ctorParameters: () => [{ type: DynamicFormSchemaService }, { type: DynamicFormBuilderService }, { type: i0.Injector }, { type: undefined, decorators: [{
1783
1785
  type: Inject,
1784
- args: [API_SERVICE]
1786
+ args: [FORM_SCHEMA_NOT_FOUND]
1785
1787
  }] }] });
1786
1788
 
1787
1789
  const templateTypes = ["control", "label", "input", "prefix", "suffix"];
@@ -2492,6 +2494,10 @@ class NgxDynamicFormModule {
2492
2494
  {
2493
2495
  provide: DEFAULT_NUMERIC_STEP,
2494
2496
  useValue: (config?.defaultNumericStep ?? 1)
2497
+ },
2498
+ {
2499
+ provide: FORM_SCHEMA_NOT_FOUND,
2500
+ useValue: (config?.schemaNotFound ?? formSchemaNotFound)
2495
2501
  }
2496
2502
  ];
2497
2503
  }
@@ -2564,5 +2570,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImpo
2564
2570
  * Generated bundle index. Do not edit.
2565
2571
  */
2566
2572
 
2567
- export { AsyncSubmitDirective, DEFAULT_NUMERIC_STEP, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormDateComponent, DynamicFormEditorComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormPasswordComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTemplateDirective, DynamicFormTemplatePipe, DynamicFormTemplateService, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_TYPES, FORM_ROOT_ID, FormArray, FormDate, FormFieldSet, FormGroup, FormInput, FormSelect, FormSerializable, FormStatic, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, RichTranslationModel, TranslationModel, addFieldValidators, arrayLengthValidation, clearFieldArray, controlStatus, controlValues, convertToNumber, customizeFormField, emailValidation, enumValidation, equalsValidation, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, isFieldHidden, isFieldVisible, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDefault, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldMinDate, setFieldProp, setFieldProps, setFieldSerialize, setFieldValue, translationValidation };
2573
+ export { AsyncSubmitDirective, DEFAULT_NUMERIC_STEP, DynamicFieldType, DynamicFormAlertComponent, DynamicFormArrayComponent, DynamicFormBuilderService, DynamicFormChipsComponent, DynamicFormComponent, DynamicFormDateComponent, DynamicFormEditorComponent, DynamicFormFieldComponent, DynamicFormFieldsetComponent, DynamicFormGroupComponent, DynamicFormPasswordComponent, DynamicFormSchemaService, DynamicFormService, DynamicFormStaticComponent, DynamicFormTemplateDirective, DynamicFormTemplatePipe, DynamicFormTemplateService, DynamicFormTranslationComponent, DynamicFormUploadComponent, DynamicFormWysiwygComponent, EDITOR_TYPES, FORM_ROOT_ID, FORM_SCHEMA_NOT_FOUND, FormArray, FormDate, FormFieldSet, FormGroup, FormInput, FormSelect, FormSerializable, FormStatic, FormUpload, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, RichTranslationModel, TranslationModel, addFieldValidators, arrayLengthValidation, clearFieldArray, controlStatus, controlValues, convertToNumber, customizeFormField, emailValidation, enumValidation, equalsValidation, formSchemaNotFound, getFieldByPath, getFieldsByKey, getFieldsByPredicate, getSelectOptions, insertToFieldArray, isFieldHidden, isFieldVisible, jsonValidation, maxLengthValidation, maxValueValidation, minLengthValidation, minValueValidation, phoneValidation, removeFieldValidators, removeFromFieldArray, replaceFieldArray, replaceSpecialChars, requiredValidation, setFieldDefault, setFieldDisabled, setFieldHidden, setFieldHooks, setFieldMinDate, setFieldProp, setFieldProps, setFieldSerialize, setFieldValue, translationValidation };
2568
2574
  //# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map