@stemy/ngx-dynamic-form 19.9.30 → 19.9.32

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.
@@ -40,10 +40,8 @@ function defineFormControl(target, propertyKey, cb) {
40
40
  const fields = ReflectUtils.getMetadata("dynamicFormFields", target) || new Set();
41
41
  const existing = ReflectUtils.getMetadata("dynamicFormField", target, propertyKey);
42
42
  const builder = (fb, opts, path) => {
43
- const data = ObjectUtils.isFunction(existing) ? existing(fb, opts, path) : {
44
- priority: Number.MAX_SAFE_INTEGER
45
- };
46
- return ObjectUtils.assign(data, cb(fb, opts, path) || {});
43
+ const data = ObjectUtils.isFunction(existing) ? existing(fb, opts, path) : {};
44
+ return ObjectUtils.assign(cb(fb, opts, path) || {}, data);
47
45
  };
48
46
  fields.add(propertyKey);
49
47
  ReflectUtils.defineMetadata("dynamicFormField", builder, target, propertyKey);
@@ -679,7 +677,7 @@ class DynamicFormBuilderService {
679
677
  id,
680
678
  parent,
681
679
  schemas: new Set(),
682
- discriminator: parent.discriminator,
680
+ discriminator: parent?.discriminator,
683
681
  fieldGroup: fields,
684
682
  wrappers: ["form-fieldset"],
685
683
  props: {
@@ -805,7 +803,6 @@ class DynamicFormBuilderService {
805
803
  setFieldProp(target, "options", options instanceof Observable
806
804
  ? options
807
805
  : controlValues(root).pipe(combineLatestWith(this.language), switchMap(async (a, b) => {
808
- console.log(a, b, "????", target.key, target.formControl?.value);
809
806
  const results = await factory(target, this.injector) || [];
810
807
  return this.fixSelectOptions(target, results);
811
808
  })));
@@ -830,11 +827,15 @@ class DynamicFormBuilderService {
830
827
  data.multiple = true;
831
828
  console.warn(`File upload property "multi" is deprecated. Use "multiple" instead.`);
832
829
  }
830
+ const baseUrl = data.url?.startsWith("http") ? data.url : this.api.url(data.url || "assets");
833
831
  return this.createFormField(key, "upload", data, {
834
832
  inline: data.inline === true,
835
833
  multiple: data.multiple === true,
836
834
  accept: data.accept || [".png", ".jpg"],
837
- url: data.url?.startsWith("http") ? data.url : this.api.url(data.url || "assets"),
835
+ url: baseUrl,
836
+ uploadUrl: data.url?.startsWith("http")
837
+ ? data.uploadUrl
838
+ : (data.uploadUrl ? this.api.url(data.uploadUrl || "assets") : baseUrl),
838
839
  maxSize: isNaN(data.maxSize) ? MAX_INPUT_NUM : data.maxSize,
839
840
  uploadOptions: data.uploadOptions || {},
840
841
  createUploadData: data.createUploadData
@@ -1202,6 +1203,12 @@ class DynamicFormSchemaService {
1202
1203
  return !field ? [] : options.customize(field, property, schema);
1203
1204
  }
1204
1205
  async getFormFieldForProp(property, options, parent) {
1206
+ // First check property references, because a dynamic schema can be a type of object which we use for editor
1207
+ const refs = await this.openApi.getReferences(property, options.schema);
1208
+ if (refs.length > 0) {
1209
+ return this.getFormGroupConfig(property, options, parent);
1210
+ }
1211
+ // Then check the property type
1205
1212
  switch (property.type) {
1206
1213
  case "object":
1207
1214
  return this.getFormEditorConfig(property, options, parent);
@@ -1229,10 +1236,6 @@ class DynamicFormSchemaService {
1229
1236
  if (property.format == "date" || property.format == "date-time") {
1230
1237
  return this.getFormDatepickerConfig(property, options, parent);
1231
1238
  }
1232
- const refs = await this.openApi.getReferences(property, options.schema);
1233
- if (refs.length > 0) {
1234
- return this.getFormGroupConfig(property, options, parent);
1235
- }
1236
1239
  if (this.checkIsEditorProperty(property)) {
1237
1240
  return this.getFormEditorConfig(property, options, parent);
1238
1241
  }
@@ -1325,7 +1328,7 @@ class DynamicFormSchemaService {
1325
1328
  break;
1326
1329
  }
1327
1330
  const sub = property.type == "array" ? property.items || property : property;
1328
- const input = this.builder.createFormInput(property.id, {
1331
+ return this.builder.createFormInput(property.id, {
1329
1332
  ...this.getFormFieldData(property, options),
1330
1333
  type,
1331
1334
  autocomplete: property.autocomplete,
@@ -1339,7 +1342,6 @@ class DynamicFormSchemaService {
1339
1342
  indeterminate: property.indeterminate,
1340
1343
  suffix: property.suffix
1341
1344
  }, parent, options);
1342
- return input;
1343
1345
  }
1344
1346
  getFormTextareaConfig(property, options, parent) {
1345
1347
  return this.builder.createFormInput(property.id, {
@@ -2301,11 +2303,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImpo
2301
2303
 
2302
2304
  class DynamicFormUploadComponent extends DynamicFieldType {
2303
2305
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormUploadComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2304
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.22", type: DynamicFormUploadComponent, isStandalone: false, selector: "dynamic-form-upload", usesInheritance: true, ngImport: i0, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.UploadComponent, selector: "upload", inputs: ["value", "disabled", "inline", "accept", "baseUrl", "message", "multiple", "buttonText", "makeUpload", "preProcess"], outputs: ["onUploaded", "onRemove"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
2306
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.22", type: DynamicFormUploadComponent, isStandalone: false, selector: "dynamic-form-upload", usesInheritance: true, ngImport: i0, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [uploadUrl]=\"props.uploadUrl\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.UploadComponent, selector: "upload", inputs: ["value", "disabled", "inline", "accept", "baseUrl", "uploadUrl", "message", "multiple", "buttonText", "makeUpload", "preProcess"], outputs: ["onUploaded", "onRemove"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
2305
2307
  }
2306
2308
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormUploadComponent, decorators: [{
2307
2309
  type: Component,
2308
- args: [{ standalone: false, selector: "dynamic-form-upload", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n" }]
2310
+ args: [{ standalone: false, selector: "dynamic-form-upload", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<upload [formControl]=\"formControl\"\n [multiple]=\"props.multiple\"\n [inline]=\"props.inline\"\n [accept]=\"props.accept\"\n [baseUrl]=\"props.url\"\n [uploadUrl]=\"props.uploadUrl\"\n [makeUpload]=\"props.createUploadData\"\n [formlyAttributes]=\"field\">\n</upload>\n" }]
2309
2311
  }] });
2310
2312
 
2311
2313
  class DynamicFormWysiwygComponent extends DynamicFieldType {