@dmitryvim/form-builder 0.2.3 → 0.2.4

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.
@@ -2762,6 +2762,7 @@ var defaultConfig = {
2762
2762
  onUploadError: null,
2763
2763
  onDownloadError: null,
2764
2764
  debounceMs: 300,
2765
+ verboseErrors: false,
2765
2766
  enableFilePreview: true,
2766
2767
  maxPreviewSize: "200px",
2767
2768
  readonly: false,
@@ -3061,15 +3062,7 @@ var FormBuilderInstance = class {
3061
3062
  constructor(config) {
3062
3063
  this.instanceId = generateInstanceId();
3063
3064
  this.state = createInstanceState(config);
3064
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
3065
- if (config == null ? void 0 : config.getThumbnail) {
3066
- const testResult = config.getThumbnail("test-id");
3067
- if (!(testResult instanceof Promise)) {
3068
- console.warn(
3069
- "[form-builder] getThumbnail must be async (return Promise). Wrap your function: async (id) => { ... }"
3070
- );
3071
- }
3072
- }
3065
+ if (this.state.config.verboseErrors) {
3073
3066
  if (!globalThis.__formBuilderInstances) {
3074
3067
  globalThis.__formBuilderInstances = /* @__PURE__ */ new Set();
3075
3068
  }
@@ -3523,28 +3516,32 @@ var FormBuilderInstance = class {
3523
3516
  }
3524
3517
  const schema = this.state.schema;
3525
3518
  const formRoot = this.state.formRoot;
3519
+ const actions = this.state.externalActions;
3526
3520
  const emptyPrefill = this.buildHiddenFieldsData(schema.elements);
3527
- this.renderForm(formRoot, schema, emptyPrefill);
3521
+ this.renderForm(formRoot, schema, emptyPrefill, actions || void 0);
3528
3522
  }
3529
3523
  /**
3530
3524
  * Build prefill data for hidden fields only
3531
3525
  * Hidden fields should retain their values when clearing
3526
+ * Builds nested objects instead of flattened dotted keys
3532
3527
  */
3533
- buildHiddenFieldsData(elements, parentPath = "") {
3528
+ buildHiddenFieldsData(elements) {
3534
3529
  const data = {};
3535
3530
  for (const element of elements) {
3536
3531
  const key = element.key;
3537
- const fieldPath = parentPath ? `${parentPath}.${key}` : key;
3538
3532
  if (element.hidden && element.default !== void 0) {
3539
- data[fieldPath] = element.default;
3533
+ data[key] = element.default;
3540
3534
  }
3541
3535
  if (element.type === "container" || element.type === "group") {
3542
3536
  const containerElement = element;
3543
- const nestedData = this.buildHiddenFieldsData(
3544
- containerElement.elements,
3545
- fieldPath
3546
- );
3547
- Object.assign(data, nestedData);
3537
+ const nestedData = this.buildHiddenFieldsData(containerElement.elements);
3538
+ if (Object.keys(nestedData).length > 0) {
3539
+ if (!(key in data)) {
3540
+ data[key] = nestedData;
3541
+ } else if (typeof data[key] === "object" && data[key] !== null && !Array.isArray(data[key])) {
3542
+ data[key] = { ...data[key], ...nestedData };
3543
+ }
3544
+ }
3548
3545
  }
3549
3546
  }
3550
3547
  return data;
@@ -3626,7 +3623,7 @@ var FormBuilderInstance = class {
3626
3623
  this.state.formRoot = null;
3627
3624
  this.state.schema = null;
3628
3625
  this.state.externalActions = null;
3629
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
3626
+ if (this.state.config.verboseErrors) {
3630
3627
  (_a = globalThis.__formBuilderInstances) == null ? void 0 : _a.delete(this.instanceId);
3631
3628
  }
3632
3629
  }